From cb7cfa353dfde9bfdd620e17dd3b9eb5ef062042 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 24 Feb 1998 22:08:05 +0000 Subject: [PATCH] Add the smallest and least useful device-driver by a fair margin... --- sys/conf/files.i386 | 3 +- sys/conf/majors | 3 +- sys/i386/conf/files.i386 | 3 +- sys/i386/conf/majors.i386 | 3 +- sys/i386/isa/loran.c | 121 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 sys/i386/isa/loran.c diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 118dfd68d47..0b23d11bd27 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $Id: files.i386,v 1.191 1998/02/18 13:43:42 msmith Exp $ +# $Id: files.i386,v 1.192 1998/02/20 16:35:00 phk Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -130,6 +130,7 @@ i386/isa/joy.c optional joy device-driver i386/isa/kbdio.c optional psm device-driver i386/isa/kbdio.c optional sc device-driver i386/isa/kbdio.c optional vt device-driver +i386/isa/loran.c optional loran device-driver i386/isa/lpt.c optional lpt device-driver i386/isa/labpc.c optional labpc device-driver i386/isa/mcd.c optional mcd device-driver diff --git a/sys/conf/majors b/sys/conf/majors index 7e24fc742d0..8184f09e5f5 100644 --- a/sys/conf/majors +++ b/sys/conf/majors @@ -1,4 +1,4 @@ -$Id: majors.i386,v 1.33 1998/02/20 03:54:45 ahasty Exp $ +$Id: majors.i386,v 1.34 1998/02/20 23:55:32 jkh Exp $ Hopefully, this list will one day be obsoleted by DEVFS, but for now this is the current allocation of device major numbers. @@ -135,3 +135,4 @@ chrdev name comments 91 vinum RAID fs 92 bktr Bt848 video capture driver (hasty@star-gate.com) 93 coda CODA filesystem. +94 loran Loran-C Receiver diff --git a/sys/i386/conf/files.i386 b/sys/i386/conf/files.i386 index 118dfd68d47..0b23d11bd27 100644 --- a/sys/i386/conf/files.i386 +++ b/sys/i386/conf/files.i386 @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $Id: files.i386,v 1.191 1998/02/18 13:43:42 msmith Exp $ +# $Id: files.i386,v 1.192 1998/02/20 16:35:00 phk Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -130,6 +130,7 @@ i386/isa/joy.c optional joy device-driver i386/isa/kbdio.c optional psm device-driver i386/isa/kbdio.c optional sc device-driver i386/isa/kbdio.c optional vt device-driver +i386/isa/loran.c optional loran device-driver i386/isa/lpt.c optional lpt device-driver i386/isa/labpc.c optional labpc device-driver i386/isa/mcd.c optional mcd device-driver diff --git a/sys/i386/conf/majors.i386 b/sys/i386/conf/majors.i386 index 7e24fc742d0..8184f09e5f5 100644 --- a/sys/i386/conf/majors.i386 +++ b/sys/i386/conf/majors.i386 @@ -1,4 +1,4 @@ -$Id: majors.i386,v 1.33 1998/02/20 03:54:45 ahasty Exp $ +$Id: majors.i386,v 1.34 1998/02/20 23:55:32 jkh Exp $ Hopefully, this list will one day be obsoleted by DEVFS, but for now this is the current allocation of device major numbers. @@ -135,3 +135,4 @@ chrdev name comments 91 vinum RAID fs 92 bktr Bt848 video capture driver (hasty@star-gate.com) 93 coda CODA filesystem. +94 loran Loran-C Receiver diff --git a/sys/i386/isa/loran.c b/sys/i386/isa/loran.c new file mode 100644 index 00000000000..7d524e1668f --- /dev/null +++ b/sys/i386/isa/loran.c @@ -0,0 +1,121 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $Id$ + * + * This device-driver helps the userland controlprogram for a LORAN-C + * receiver avoid monopolizing the CPU. + * + * This is clearly a candidate for the "most weird hardware support in + * FreeBSD" prize. At this time only two copies of the receiver are + * known to exist in the entire world. + * + * Details can be found at: + * ftp://ftp.eecis.udel.edu/pub/ntp/loran.tar.Z + * + */ + +#include "loran.h" +#include "opt_devfs.h" + +#include +#include +#include +#include +#include +#include +#include +#ifdef DEVFS +#include +#endif /*DEVFS*/ + +#include +#include + +static int loranprobe (struct isa_device *dvp); +static int loranattach (struct isa_device *isdp); + +struct isa_driver lorandriver = { + loranprobe, loranattach, "loran" +}; + +struct timespec loran_token; + +static d_open_t loranopen; +static d_close_t loranclose; +static d_read_t loranread; + +#define CDEV_MAJOR 94 +static struct cdevsw loran_cdevsw = + { loranopen, loranclose, loranread, nowrite, + noioctl, nullstop, nullreset, nodevtotty, + seltrue, nommap, nostrat, "loran", + NULL, -1 }; + + +int +loranprobe(struct isa_device *dvp) +{ + dvp->id_iobase = 0x300; + return (8); +} + +int +loranattach(struct isa_device *isdp) +{ + printf("loran0: LORAN-C Receiver\n"); + return (1); +} + +static int +loranopen (dev_t dev, int flags, int fmt, struct proc *p) +{ + + return(0); +} + +static int +loranclose(dev_t dev, int flags, int fmt, struct proc *p) +{ + + return(0); +} + +static int +loranread(dev_t dev, struct uio * uio, int ioflag) +{ + int err, c; + + tsleep ((caddr_t)&loran_token, PZERO + 8 |PCATCH, "loranrd", hz*10); + c = imin(uio->uio_resid, (int)sizeof loran_token); + err = uiomove((caddr_t)&loran_token, c, uio); + return(err); +} + +void +loranintr(int unit) +{ + nanotime(&loran_token); + wakeup((caddr_t)&loran_token); +} + +static loran_devsw_installed = 0; + +static void loran_drvinit(void *unused) +{ + dev_t dev; + + if( ! loran_devsw_installed ) { + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&loran_cdevsw, NULL); + loran_devsw_installed = 1; + } +} + +SYSINIT(lorandev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,loran_drvinit,NULL) + -- 2.45.2