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