PageRenderTime 34ms CodeModel.GetById 29ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/kernel/chuinit.c

https://bitbucket.org/freebsd/freebsd-head/
C | 74 lines | 49 code | 20 blank | 5 comment | 10 complexity | 211e360752bf8b63df64505060d3afa4 MD5 | raw file
 1/*
 2**	dynamically loadable chu 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
16extern int findmod();		/* os/str_io.c */
17
18extern struct streamtab chuinfo;
19
20struct vdldrv vd = {
21     VDMAGIC_USER,
22     "chu"
23  };
24
25
26int
27xxxinit(function_code, vdp, vdi, vds)
28unsigned int function_code;
29struct vddrv *vdp;
30addr_t vdi;
31struct vdstat *vds;
32{
33     register int i = 0;
34     register int j;
35
36     switch (function_code) {
37	case VDLOAD:
38
39	  if (findmod("chu") >= 0) {
40	       log(LOG_ERR, "chu 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 = &chuinfo;
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}