/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. #include <sys/types.h>
  7. #include <sys/conf.h>
  8. #include <sys/errno.h>
  9. #include <sys/stream.h>
  10. #include <sys/syslog.h>
  11. #include <sun/openprom.h>
  12. #include <sun/vddrv.h>
  13. extern int findmod(); /* os/str_io.c */
  14. extern struct streamtab chuinfo;
  15. struct vdldrv vd = {
  16. VDMAGIC_USER,
  17. "chu"
  18. };
  19. int
  20. xxxinit(function_code, vdp, vdi, vds)
  21. unsigned int function_code;
  22. struct vddrv *vdp;
  23. addr_t vdi;
  24. struct vdstat *vds;
  25. {
  26. register int i = 0;
  27. register int j;
  28. switch (function_code) {
  29. case VDLOAD:
  30. if (findmod("chu") >= 0) {
  31. log(LOG_ERR, "chu stream module already loaded\n");
  32. return (EADDRINUSE);
  33. }
  34. i = findmod("\0");
  35. if (i == -1 || fmodsw[i].f_name[0] != '\0')
  36. return(-1);
  37. for (j = 0; vd.Drv_name[j] != '\0'; j++) /* XXX check bounds */
  38. fmodsw[i].f_name[j] = vd.Drv_name[j];
  39. fmodsw[i].f_name[j] = '\0';
  40. fmodsw[i].f_str = &chuinfo;
  41. vdp->vdd_vdtab = (struct vdlinkage *) &vd;
  42. return(0);
  43. case VDUNLOAD:
  44. if ((i = findmod(vd.Drv_name)) == -1)
  45. return(-1);
  46. fmodsw[i].f_name[0] = '\0';
  47. fmodsw[i].f_str = 0;
  48. return(0);
  49. case VDSTAT:
  50. return(0);
  51. default:
  52. return(EIO);
  53. }
  54. }