]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ntp/kernel/clkinit.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ntp / kernel / clkinit.c
1 /*
2 **      dynamically loadable clk driver
3 **
4 **      william robertson <rob@agate.berkeley.edu>  
5 */
6
7 #include <sys/types.h>
8 #include <sys/conf.h>
9 #include <sys/errno.h>
10 #include <sys/stream.h>
11 #include <sys/syslog.h>
12
13 #include <sun/openprom.h>
14 #include <sun/vddrv.h>
15
16 extern int findmod();           /* os/str_io.c */
17
18 extern struct streamtab clkinfo;
19
20 struct vdldrv vd = {
21      VDMAGIC_USER,
22      "clk"
23   };
24
25
26 int
27 xxxinit(function_code, vdp, vdi, vds)
28 unsigned int function_code;
29 struct vddrv *vdp;
30 addr_t vdi;
31 struct vdstat *vds;
32 {
33      register int i = 0;
34      register int j;
35
36      switch (function_code) {
37         case VDLOAD:
38
39           if (findmod("clk") >= 0) {
40                log(LOG_ERR, "clk stream module already loaded\n");
41                return (EADDRINUSE);
42           }
43  
44           i = findmod("\0");
45
46           if (i == -1 || fmodsw[i].f_name[0] != '\0') 
47             return(-1);
48
49           for (j = 0; vd.Drv_name[j] != '\0'; j++)      /* XXX check bounds */
50             fmodsw[i].f_name[j] = vd.Drv_name[j];
51
52           fmodsw[i].f_name[j] = '\0';
53           fmodsw[i].f_str = &clkinfo;
54
55           vdp->vdd_vdtab = (struct vdlinkage *)  &vd;
56
57           return(0);
58
59         case VDUNLOAD:
60           if ((i = findmod(vd.Drv_name)) == -1)
61             return(-1);
62
63           fmodsw[i].f_name[0] = '\0';
64           fmodsw[i].f_str = 0;
65
66           return(0);
67      
68         case VDSTAT:
69           return(0);
70
71         default:
72           return(EIO);
73      }
74 }