Add the smallest and least useful device-driver by a fair margin...

This commit is contained in:
Poul-Henning Kamp 1998-02-24 22:08:05 +00:00
parent ffb7094ed2
commit cb7cfa353d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=33795
5 changed files with 129 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

121
sys/i386/isa/loran.c Normal file
View File

@ -0,0 +1,121 @@
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.org> 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 <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/buf.h>
#include <sys/kernel.h>
#include <sys/uio.h>
#include <sys/syslog.h>
#ifdef DEVFS
#include <sys/devfsext.h>
#endif /*DEVFS*/
#include <i386/isa/isa.h>
#include <i386/isa/isa_device.h>
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)