Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / kernel / clkinit.c
blob84eb191401f06fedd87db5dfd835af88cf1d307f
1 /* $NetBSD: clkinit.c,v 1.2 2003/12/04 16:23:36 drochner Exp $ */
3 /*
4 ** dynamically loadable clk driver
5 **
6 ** william robertson <rob@agate.berkeley.edu>
7 */
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>
15 #include <sun/openprom.h>
16 #include <sun/vddrv.h>
18 extern int findmod(); /* os/str_io.c */
20 extern struct streamtab clkinfo;
22 struct vdldrv vd = {
23 VDMAGIC_USER,
24 "clk"
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;
35 register int i = 0;
36 register int j;
38 switch (function_code) {
39 case VDLOAD:
41 if (findmod("clk") >= 0) {
42 log(LOG_ERR, "clk stream module already loaded\n");
43 return (EADDRINUSE);
46 i = findmod("\0");
48 if (i == -1 || fmodsw[i].f_name[0] != '\0')
49 return(-1);
51 for (j = 0; vd.Drv_name[j] != '\0'; j++) /* XXX check bounds */
52 fmodsw[i].f_name[j] = vd.Drv_name[j];
54 fmodsw[i].f_name[j] = '\0';
55 fmodsw[i].f_str = &clkinfo;
57 vdp->vdd_vdtab = (struct vdlinkage *) &vd;
59 return(0);
61 case VDUNLOAD:
62 if ((i = findmod(vd.Drv_name)) == -1)
63 return(-1);
65 fmodsw[i].f_name[0] = '\0';
66 fmodsw[i].f_str = 0;
68 return(0);
70 case VDSTAT:
71 return(0);
73 default:
74 return(EIO);