diff options
Diffstat (limited to 'sys/i386')
38 files changed, 1614 insertions, 2264 deletions
diff --git a/sys/i386/apm/apm.c b/sys/i386/apm/apm.c index eee873d..8b9b862 100644 --- a/sys/i386/apm/apm.c +++ b/sys/i386/apm/apm.c @@ -13,7 +13,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.18 1995/11/29 14:39:17 julian Exp $ + * $Id: apm.c,v 1.19 1995/12/07 12:45:21 davidg Exp $ */ #include "apm.h" @@ -22,14 +22,12 @@ #ifdef __FreeBSD__ #include <sys/param.h> -#include "conf.h" -#ifdef JREMOD +#include <conf.h> #include <sys/conf.h> #include <sys/kernel.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ -#endif /*JREMOD*/ #include <sys/kernel.h> #include <sys/systm.h> #include <sys/malloc.h> @@ -84,6 +82,7 @@ struct apm_softc { int idle_cpu, disabled, disengaged; struct apmhook sc_suspend; struct apmhook sc_resume; + void *sc_devfs_token; }; static struct apm_softc apm_softc[NAPM]; @@ -108,9 +107,16 @@ extern void fix_desc(struct fake_descriptor *, int); #ifdef __FreeBSD__ static timeout_t apm_timeout; -#ifdef JREMOD +static d_open_t apmopen; +static d_close_t apmclose; +static d_ioctl_t apmioctl; + #define CDEV_MAJOR 39 -#endif /* JREMOD */ +static struct cdevsw apm_cdevsw = + { apmopen, apmclose, noread, nowrite, /*39*/ + apmioctl, nostop, nullreset, nodevtotty,/* APM */ + seltrue, nommap, NULL , "apm" ,NULL, -1}; + #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL static void apm_timeout(void *); @@ -644,8 +650,8 @@ apm_not_halt_cpu(struct apm_softc *sc) /* device driver definitions */ #ifdef __FreeBSD__ -int apmprobe (struct isa_device *); -int apmattach(struct isa_device *); +static int apmprobe (struct isa_device *); +static int apmattach(struct isa_device *); struct isa_driver apmdriver = { apmprobe, apmattach, "apm" }; #endif /* __FreeBSD__ */ @@ -669,12 +675,13 @@ struct bus_driver apmdriver = { * to use V86 mode in APM initialization. */ -int #ifdef __FreeBSD__ - apmprobe(struct isa_device *dvp) +static int +apmprobe(struct isa_device *dvp) #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL - apmprobe(vm_offset_t port, struct bus_ctlr *devc) +int +apmprobe(vm_offset_t port, struct bus_ctlr *devc) #endif /* MACH_KERNEL */ { #ifdef __FreeBSD__ @@ -785,7 +792,7 @@ apm_processevent(struct apm_softc *sc) */ #ifdef __FreeBSD__ -int +static int apmattach(struct isa_device *dvp) #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL @@ -795,6 +802,7 @@ apmattach(struct bus_device *dvp) { #ifdef __FreeBSD__ int unit = dvp->id_unit; + char name[32]; #define APM_KERNBASE KERNBASE #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL @@ -908,12 +916,17 @@ apmattach(struct bus_device *dvp) sc->initialized = 1; #ifdef __FreeBSD__ +#ifdef DEVFS + sprintf(name,"apm%d",unit); + sc->sc_devfs_token = devfs_add_devsw( + "/", name, &apm_cdevsw, unit, DV_CHR, 0, 0, 0600); +#endif return 0; #endif /* __FreeBSD__ */ } #ifdef __FreeBSD__ -int +static int apmopen(dev_t dev, int flag, int fmt, struct proc *p) { struct apm_softc *sc = &apm_softc[minor(dev)]; @@ -927,13 +940,13 @@ apmopen(dev_t dev, int flag, int fmt, struct proc *p) return 0; } -int +static int apmclose(dev_t dev, int flag, int fmt, struct proc *p) { return 0; } -int +static int apmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) { struct apm_softc *sc = &apm_softc[minor(dev)]; @@ -983,15 +996,10 @@ apmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) } -#ifdef JREMOD -struct cdevsw apm_cdevsw = - { apmopen, apmclose, noread, nowrite, /*39*/ - apmioctl, nostop, nullreset, nodevtotty,/* APM */ - seltrue, nommap, NULL }; - static apm_devsw_installed = 0; -static void apm_drvinit(void *unused) +static void +apm_drvinit(void *unused) { dev_t dev; @@ -999,21 +1007,11 @@ static void apm_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&apm_cdevsw,NULL); apm_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "apm", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(apmdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,apm_drvinit,NULL) -#endif /* JREMOD */ #endif /* __FreeBSD__ */ diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index eee873d..8b9b862 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -13,7 +13,7 @@ * * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) * - * $Id: apm.c,v 1.18 1995/11/29 14:39:17 julian Exp $ + * $Id: apm.c,v 1.19 1995/12/07 12:45:21 davidg Exp $ */ #include "apm.h" @@ -22,14 +22,12 @@ #ifdef __FreeBSD__ #include <sys/param.h> -#include "conf.h" -#ifdef JREMOD +#include <conf.h> #include <sys/conf.h> #include <sys/kernel.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ -#endif /*JREMOD*/ #include <sys/kernel.h> #include <sys/systm.h> #include <sys/malloc.h> @@ -84,6 +82,7 @@ struct apm_softc { int idle_cpu, disabled, disengaged; struct apmhook sc_suspend; struct apmhook sc_resume; + void *sc_devfs_token; }; static struct apm_softc apm_softc[NAPM]; @@ -108,9 +107,16 @@ extern void fix_desc(struct fake_descriptor *, int); #ifdef __FreeBSD__ static timeout_t apm_timeout; -#ifdef JREMOD +static d_open_t apmopen; +static d_close_t apmclose; +static d_ioctl_t apmioctl; + #define CDEV_MAJOR 39 -#endif /* JREMOD */ +static struct cdevsw apm_cdevsw = + { apmopen, apmclose, noread, nowrite, /*39*/ + apmioctl, nostop, nullreset, nodevtotty,/* APM */ + seltrue, nommap, NULL , "apm" ,NULL, -1}; + #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL static void apm_timeout(void *); @@ -644,8 +650,8 @@ apm_not_halt_cpu(struct apm_softc *sc) /* device driver definitions */ #ifdef __FreeBSD__ -int apmprobe (struct isa_device *); -int apmattach(struct isa_device *); +static int apmprobe (struct isa_device *); +static int apmattach(struct isa_device *); struct isa_driver apmdriver = { apmprobe, apmattach, "apm" }; #endif /* __FreeBSD__ */ @@ -669,12 +675,13 @@ struct bus_driver apmdriver = { * to use V86 mode in APM initialization. */ -int #ifdef __FreeBSD__ - apmprobe(struct isa_device *dvp) +static int +apmprobe(struct isa_device *dvp) #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL - apmprobe(vm_offset_t port, struct bus_ctlr *devc) +int +apmprobe(vm_offset_t port, struct bus_ctlr *devc) #endif /* MACH_KERNEL */ { #ifdef __FreeBSD__ @@ -785,7 +792,7 @@ apm_processevent(struct apm_softc *sc) */ #ifdef __FreeBSD__ -int +static int apmattach(struct isa_device *dvp) #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL @@ -795,6 +802,7 @@ apmattach(struct bus_device *dvp) { #ifdef __FreeBSD__ int unit = dvp->id_unit; + char name[32]; #define APM_KERNBASE KERNBASE #endif /* __FreeBSD__ */ #ifdef MACH_KERNEL @@ -908,12 +916,17 @@ apmattach(struct bus_device *dvp) sc->initialized = 1; #ifdef __FreeBSD__ +#ifdef DEVFS + sprintf(name,"apm%d",unit); + sc->sc_devfs_token = devfs_add_devsw( + "/", name, &apm_cdevsw, unit, DV_CHR, 0, 0, 0600); +#endif return 0; #endif /* __FreeBSD__ */ } #ifdef __FreeBSD__ -int +static int apmopen(dev_t dev, int flag, int fmt, struct proc *p) { struct apm_softc *sc = &apm_softc[minor(dev)]; @@ -927,13 +940,13 @@ apmopen(dev_t dev, int flag, int fmt, struct proc *p) return 0; } -int +static int apmclose(dev_t dev, int flag, int fmt, struct proc *p) { return 0; } -int +static int apmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) { struct apm_softc *sc = &apm_softc[minor(dev)]; @@ -983,15 +996,10 @@ apmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) } -#ifdef JREMOD -struct cdevsw apm_cdevsw = - { apmopen, apmclose, noread, nowrite, /*39*/ - apmioctl, nostop, nullreset, nodevtotty,/* APM */ - seltrue, nommap, NULL }; - static apm_devsw_installed = 0; -static void apm_drvinit(void *unused) +static void +apm_drvinit(void *unused) { dev_t dev; @@ -999,21 +1007,11 @@ static void apm_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&apm_cdevsw,NULL); apm_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "apm", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(apmdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,apm_drvinit,NULL) -#endif /* JREMOD */ #endif /* __FreeBSD__ */ diff --git a/sys/i386/i386/conf.c b/sys/i386/i386/conf.c index e65ce87..faaa9c3 100644 --- a/sys/i386/i386/conf.c +++ b/sys/i386/i386/conf.c @@ -42,7 +42,7 @@ * SUCH DAMAGE. * * from: @(#)conf.c 5.8 (Berkeley) 5/12/91 - * $Id: conf.c,v 1.111 1995/12/06 22:31:54 bde Exp $ + * $Id: conf.c,v 1.112 1995/12/07 12:45:27 davidg Exp $ */ #include <sys/param.h> @@ -58,7 +58,6 @@ #include <vm/vm_param.h> #include <vm/vm_extern.h> -#ifdef JREMOD #define NUMCDEV 96 #define NUMBDEV 32 @@ -68,827 +67,11 @@ int nblkdev = NUMBDEV; struct cdevsw cdevsw[NUMCDEV]; int nchrdev = NUMCDEV; -#else /*JREMOD*/ -/* Bogus defines for compatibility. */ -#define noioc noioctl -#define nostrat nostrategy -#define zerosize nopsize - -/* Lots of bogus defines for shorthand purposes */ -#define lkmopen (d_open_t *)lkmenodev -#define lkmclose (d_close_t *)lkmenodev -#define lkmread (d_rdwr_t *)lkmenodev -#define lkmwrite (d_rdwr_t *)lkmenodev -#define lkmstrategy (d_strategy_t *)lkmenodev -#define lkmioctl (d_ioctl_t *)lkmenodev -#define lkmdump (d_dump_t *)lkmenodev -#define lkmsize zerosize -#define lkmstop (d_stop_t *)lkmenodev -#define lkmreset (d_reset_t *)lkmenodev -#define lkmmmap (d_mmap_t *)lkmenodev -#define lkmselect (d_select_t *)lkmenodev - -#include "wd.h" -#if NWD == 0 -#define wdopen nxopen -#define wdclose nxclose -#define wdstrategy nxstrategy -#define wdioctl nxioctl -#define wddump nxdump -#define wdsize zerosize -#endif - -#include "worm.h" -#if NWORM == 0 -#define wormopen nxopen -#define wormclose nxclose -#define wormstrategy nxstrategy -#define wormioctl nxioctl -#define wormdump nxdump -#define wormsize zerosize -#endif - -#include "sctarg.h" -#if NSCTARG == 0 -#define sctargopen nxopen -#define sctargclose nxclose -#define sctargstrategy nxstrategy -#define sctargioctl nxioctl -#define sctargdump nxdump -#define sctargsize zerosize -#endif - -#include "pt.h" -#if NPT == 0 -#define ptopen nxopen -#define ptclose nxclose -#define ptstrategy nxstrategy -#define ptioctl nxioctl -#define ptdump nxdump -#define ptsize zerosize -#endif - -#include "sd.h" -#if NSD == 0 -#define sdopen nxopen -#define sdclose nxclose -#define sdstrategy nxstrategy -#define sdioctl nxioctl -#define sddump nxdump -#define sdsize zerosize -#endif - -#include "st.h" -#if NST == 0 -#define stopen nxopen -#define stclose nxclose -#define ststrategy nxstrategy -#define stioctl nxioctl -#endif - -#include "od.h" -#if NOD == 0 -#define odopen nxopen -#define odclose nxclose -#define odstrategy nxstrategy -#define odioctl nxioctl -#define odsize zerosize -#endif - -#include "cd.h" -#if NCD == 0 -#define cdopen nxopen -#define cdclose nxclose -#define cdstrategy nxstrategy -#define cdioctl nxioctl -#define cdsize zerosize -#endif - -#include "mcd.h" -#if NMCD == 0 -#define mcdopen nxopen -#define mcdclose nxclose -#define mcdstrategy nxstrategy -#define mcdioctl nxioctl -#define mcdsize zerosize -#endif - -#include "scd.h" -#if NSCD == 0 -#define scdopen nxopen -#define scdclose nxclose -#define scdstrategy nxstrategy -#define scdioctl nxioctl -#define scdsize zerosize -#endif - -#include "matcd.h" -#if NMATCD == 0 -#define matcdopen nxopen -#define matcdclose nxclose -#define matcdstrategy nxstrategy -#define matcdioctl nxioctl -#define matcdsize zerosize -#endif - -#include "ata.h" -#if NATA == 0 -#define ataopen nxopen -#define ataclose nxclose -#define atastrategy nxstrategy -#define ataioctl nxioctl -#define atasize zerosize -#endif - -#include "wcd.h" -#if NWCD == 0 -#define wcdbopen nxopen -#define wcdropen nxopen -#define wcdbclose nxclose -#define wcdrclose nxclose -#define wcdstrategy nxstrategy -#define wcdioctl nxioctl -#endif - -#include "ch.h" -#if NCH == 0 -#define chopen nxopen -#define chclose nxclose -#define chioctl nxioctl -#endif - -#include "wt.h" -#if NWT == 0 -#define wtopen nxopen -#define wtclose nxclose -#define wtstrategy nxstrategy -#define wtioctl nxioctl -#define wtdump nxdump -#define wtsize zerosize -#endif - -#include "fd.h" -#if NFD == 0 -#define Fdopen nxopen -#define fdclose nxclose -#define fdstrategy nxstrategy -#define fdioctl nxioctl -#endif - -#include "vn.h" -#if NVN == 0 -#define vnopen nxopen -#define vnclose nxclose -#define vnstrategy nxstrategy -#define vnioctl nxioctl -#define vndump nxdump -#define vnsize zerosize -#endif - -#include "meteor.h" -#if NMETEOR == 0 -#define meteor_open nxopen -#define meteor_close nxclose -#define meteor_read nxread -#define meteor_write nxwrite -#define meteor_ioctl nxioctl -#define meteor_mmap nxmmap -#endif - -struct bdevsw bdevsw[] = -{ - { wdopen, wdclose, wdstrategy, wdioctl, /*0*/ - wddump, wdsize, 0 }, - { noopen, noclose, swstrategy, noioc, /*1*/ - nodump, zerosize, 0 }, - { Fdopen, fdclose, fdstrategy, fdioctl, /*2*/ - nxdump, zerosize, 0 }, - { wtopen, wtclose, wtstrategy, wtioctl, /*3*/ - wtdump, wtsize, B_TAPE }, - { sdopen, sdclose, sdstrategy, sdioctl, /*4*/ - sddump, sdsize, 0 }, - { stopen, stclose, ststrategy, stioctl, /*5*/ - nxdump, zerosize, 0 }, - { cdopen, cdclose, cdstrategy, cdioctl, /*6*/ - nxdump, cdsize, 0 }, - { mcdopen, mcdclose, mcdstrategy, mcdioctl, /*7*/ - nxdump, mcdsize, 0 }, - { lkmopen, lkmclose, lkmstrategy, lkmioctl, /*8*/ - lkmdump, lkmsize, NULL }, - { lkmopen, lkmclose, lkmstrategy, lkmioctl, /*9*/ - lkmdump, lkmsize, NULL }, - { lkmopen, lkmclose, lkmstrategy, lkmioctl, /*10*/ - lkmdump, lkmsize, NULL }, - { lkmopen, lkmclose, lkmstrategy, lkmioctl, /*11*/ - lkmdump, lkmsize, NULL }, - { lkmopen, lkmclose, lkmstrategy, lkmioctl, /*12*/ - lkmdump, lkmsize, NULL }, - { lkmopen, lkmclose, lkmstrategy, lkmioctl, /*13*/ - lkmdump, lkmsize, NULL }, - /* block device 14 is reserved for local use */ - { nxopen, nxclose, nxstrategy, nxioctl, /*14*/ - nxdump, zerosize, NULL }, - { vnopen, vnclose, vnstrategy, vnioctl, /*15*/ - vndump, vnsize, 0 }, - { scdopen, scdclose, scdstrategy, scdioctl, /*16*/ - nxdump, scdsize, 0 }, - { matcdopen, matcdclose, matcdstrategy, matcdioctl, /*17*/ - nxdump, matcdsize, 0 }, - { ataopen, ataclose, atastrategy, ataioctl, /*18*/ - nxdump, atasize, 0 }, - { wcdbopen, wcdbclose, wcdstrategy, wcdioctl, /*19*/ - nxdump, zerosize, 0 }, - { odopen, odclose, odstrategy, odioctl, /*20*/ - nxdump, odsize, 0 }, - -/* - * If you need a bdev major number for a driver that you intend to donate - * back to the group or release publically, please contact the FreeBSD team - * by sending mail to "FreeBSD-hackers@freefall.cdrom.com". - * If you assign one yourself it may conflict with someone else. - * Otherwise, simply use the one reserved for local use. - */ -}; -int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]); - -/* console */ -#include "machine/cons.h" - -#include "pty.h" -#if NPTY == 0 -#define ptsopen nxopen -#define ptsclose nxclose -#define ptsread nxread -#define ptswrite nxwrite -#define ptcopen nxopen -#define ptcclose nxclose -#define ptcread nxread -#define ptcwrite nxwrite -#define ptyioctl nxioctl -#define ptcselect nxselect -#define ptsstop nullstop -#define ptydevtotty nxdevtotty -#endif - - -#include "snp.h" -#if NSNP == 0 -#define snpopen nxopen -#define snpclose nxclose -#define snpread nxread -#define snpwrite nxwrite -#define snpioctl nxioctl -#define snpselect nxselect -#endif - -#include "bqu.h" -#if NBQU == 0 -#define bquopen nxopen -#define bquclose nxclose -#define bquread nxread -#define bquwrite nxwrite -#define bquselect nxselect -#define bquioctl nxioctl -#endif - -#include "lpt.h" -#if NLPT == 0 -#define lptopen nxopen -#define lptclose nxclose -#define lptwrite nxwrite -#define lptioctl nxioctl -#endif - -#include "tw.h" -#if NTW == 0 -#define twopen nxopen -#define twclose nxclose -#define twread nxread -#define twwrite nxwrite -#define twselect nxselect -#endif - -#include "psm.h" -#if NPSM == 0 -#define psmopen nxopen -#define psmclose nxclose -#define psmread nxread -#define psmselect nxselect -#define psmioctl nxioctl -#endif - -#include "snd.h" -#if NSND == 0 -#define sndopen nxopen -#define sndclose nxclose -#define sndioctl nxioctl -#define sndread nxread -#define sndwrite nxwrite -#define sndselect seltrue -#endif - -#include "bpfilter.h" -#if NBPFILTER == 0 -#define bpfopen nxopen -#define bpfclose nxclose -#define bpfread nxread -#define bpfwrite nxwrite -#define bpfselect nxselect -#define bpfioctl nxioctl -#endif - -#include "speaker.h" -#if NSPEAKER == 0 -#define spkropen nxopen -#define spkrclose nxclose -#define spkrwrite nxwrite -#define spkrioctl nxioctl -#endif - -#include "pca.h" -#if NPCA == 0 -#define pcaopen nxopen -#define pcaclose nxclose -#define pcawrite nxwrite -#define pcaioctl nxioctl -#define pcaselect nxselect -#endif - -#include "mse.h" -#if NMSE == 0 -#define mseopen nxopen -#define mseclose nxclose -#define mseread nxread -#define mseselect nxselect -#endif - -#include "sio.h" -#if NSIO == 0 -#define sioopen nxopen -#define sioclose nxclose -#define sioread nxread -#define siowrite nxwrite -#define sioioctl nxioctl -#define siostop nxstop -#define siodevtotty nxdevtotty -#endif - -#include "su.h" -#if NSU == 0 -#define suopen nxopen -#define suclose nxclose -#define suioctl nxioctl -#define suread nxread -#define suwrite nxwrite -#define suselect nxselect -#define sustrategy nxstrategy -#endif - -#include "scbus.h" -#if NSCBUS == 0 -#define ukopen nxopen -#define ukclose nxclose -#define ukioctl nxioctl -#endif - -#include "apm.h" -#if NAPM == 0 -#define apmopen nxopen -#define apmclose nxclose -#define apmioctl nxioctl -#endif - -#include "ctx.h" -#if NCTX == 0 -#define ctxopen nxopen -#define ctxclose nxclose -#define ctxread nxread -#define ctxwrite nxwrite -#define ctxioctl nxioctl -#endif - -#include "ssc.h" -#if NSSC == 0 -#define sscopen nxopen -#define sscclose nxclose -#define sscioctl nxioctl -#endif - -#include "cx.h" -#if NCX == 0 -#define cxopen nxopen -#define cxclose nxclose -#define cxread nxread -#define cxwrite nxwrite -#define cxioctl nxioctl -#define cxstop nxstop -#define cxselect nxselect -#define cxdevtotty nxdevtotty -#endif - -#include "gp.h" -#if NGP == 0 -#define gpopen nxopen -#define gpclose nxclose -#define gpwrite nxwrite -#define gpioctl nxioctl -#endif - -#include "gsc.h" -#if NGSC == 0 -#define gscopen nxopen -#define gscclose nxclose -#define gscread nxread -#define gscioctl nxioctl -#endif - -#include "crd.h" -#if NCRD == 0 -#define crdopen nxopen -#define crdclose nxclose -#define crdread nxread -#define crdwrite nxwrite -#define crdioctl nxioctl -#define crdselect nxselect - -#endif - -#include "joy.h" -#if NJOY == 0 -#define joyopen nxopen -#define joyclose nxclose -#define joyread nxread -#define joyioctl nxioctl -#endif - -#include "asc.h" -#if NASC == 0 -#define ascopen nxopen -#define ascclose nxclose -#define ascread nxread -#define ascioctl nxioctl -#define ascselect nxselect -#endif - -#include "tun.h" -#if NTUN == 0 -#define tunopen nxopen -#define tunclose nxclose -#define tunread nxread -#define tunwrite nxwrite -#define tunioctl nxioctl -#define tunselect nxselect -#endif - -#include "spigot.h" -#if NSPIGOT == 0 -#define spigot_open nxopen -#define spigot_close nxclose -#define spigot_ioctl nxioctl -#define spigot_read nxread -#define spigot_write nxwrite -#define spigot_select seltrue -#define spigot_mmap nommap -#endif - -#include "cy.h" -#if NCY == 0 -#define cyopen nxopen -#define cyclose nxclose -#define cyread nxread -#define cywrite nxwrite -#define cyioctl nxioctl -#define cystop nxstop -#define cydevtotty nxdevtotty -#endif - -#include "dgb.h" -#if NDGB == 0 -#define dgbopen nxopen -#define dgbclose nxclose -#define dgbread nxread -#define dgbwrite nxwrite -#define dgbioctl nxioctl -#define dgbstop nxstop -#define dgbdevtotty nxdevtotty -#endif - -#include "si.h" -#if NSI == 0 -#define siopen nxopen -#define siclose nxclose -#define siread nxread -#define siwrite nxwrite -#define siioctl nxioctl -#define sistop nxstop -#define sidevtotty nxdevtotty -#endif - -#include "ity.h" -#if NITY == 0 -#define ityopen nxopen -#define ityclose nxclose -#define ityread nxread -#define itywrite nxwrite -#define ityioctl nxioctl -#define itystop nxstop -#define itydevtotty nxdevtotty -#endif - -#include "nic.h" -#if NNIC == 0 -#define nicopen nxopen -#define nicclose nxclose -#define nicioctl nxioctl -#endif - -#include "nnic.h" -#if NNNIC == 0 -#define nnicopen nxopen -#define nnicclose nxclose -#define nnicioctl nxioctl -#endif - -#include "isdn.h" -#if NISDN == 0 -#define isdnopen nxopen -#define isdnclose nxclose -#define isdnread nxread -#define isdnioctl nxioctl -#endif - -#include "itel.h" -#if NITEL == 0 -#define itelopen nxopen -#define itelclose nxclose -#define itelread nxread -#define itelwrite nxwrite -#define itelioctl nxioctl -#endif - -#include "ispy.h" -#if NISPY == 0 -#define ispyopen nxopen -#define ispyclose nxclose -#define ispyread nxread -#define ispywrite nxwrite -#define ispyioctl nxioctl -#endif - -#include "rc.h" -#if NRC == 0 -#define rcopen nxopen -#define rcclose nxclose -#define rcread nxread -#define rcwrite nxwrite -#define rcioctl nxioctl -#define rcstop nxstop -#define rcdevtotty nxdevtotty -#endif - -#include "labpc.h" -#if NLABPC == 0 -#define labpcopen nxopen -#define labpcclose nxclose -#define labpcstrategy nxstrategy -#define labpcioctl nxioctl -#endif - -/* open, close, read, write, ioctl, stop, reset, ttys, select, mmap, strat */ -struct cdevsw cdevsw[] = -{ - { cnopen, cnclose, cnread, cnwrite, /*0*/ - cnioctl, nullstop, nullreset, nodevtotty,/* console */ - cnselect, nommap, NULL }, - { cttyopen, nullclose, cttyread, cttywrite, /*1*/ - cttyioctl, nullstop, nullreset, nodevtotty,/* tty */ - cttyselect, nommap, NULL }, - { mmopen, mmclose, mmrw, mmrw, /*2*/ - mmioctl, nullstop, nullreset, nodevtotty,/* memory */ - seltrue, memmmap, NULL }, - { wdopen, wdclose, rawread, rawwrite, /*3*/ - wdioctl, nostop, nullreset, nodevtotty,/* wd */ - seltrue, nommap, wdstrategy }, - { nullopen, nullclose, rawread, rawwrite, /*4*/ - noioc, nostop, noreset, nodevtotty,/* swap */ - noselect, nommap, swstrategy }, - { ptsopen, ptsclose, ptsread, ptswrite, /*5*/ - ptyioctl, ptsstop, nullreset, ptydevtotty,/* ttyp */ - ttselect, nommap, NULL }, - { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/ - ptyioctl, nullstop, nullreset, ptydevtotty,/* ptyp */ - ptcselect, nommap, NULL }, - { logopen, logclose, logread, nowrite, /*7*/ - logioctl, nostop, nullreset, nodevtotty,/* klog */ - logselect, nommap, NULL }, - { bquopen, bquclose, bquread, bquwrite, /*8*/ - bquioctl, nostop, nullreset, nodevtotty,/* tputer */ - bquselect, nommap, NULL }, - { Fdopen, fdclose, rawread, rawwrite, /*9*/ - fdioctl, nostop, nullreset, nodevtotty,/* Fd (!=fd) */ - seltrue, nommap, fdstrategy }, - { wtopen, wtclose, rawread, rawwrite, /*10*/ - wtioctl, nostop, nullreset, nodevtotty,/* wt */ - seltrue, nommap, wtstrategy }, - { spigot_open, spigot_close, spigot_read, spigot_write, /*11*/ - spigot_ioctl, nostop, nullreset, nodevtotty,/* Spigot */ - spigot_select, spigot_mmap, NULL }, - { nxopen, nxclose, nxread, nxwrite, /*12*/ - nxioctl, nxstop, nxreset, nxdevtotty,/* sc, ... */ - nxselect, nxmmap, NULL }, - { sdopen, sdclose, rawread, rawwrite, /*13*/ - sdioctl, nostop, nullreset, nodevtotty,/* sd */ - seltrue, nommap, sdstrategy }, - { stopen, stclose, rawread, rawwrite, /*14*/ - stioctl, nostop, nullreset, nodevtotty,/* st */ - seltrue, nommap, ststrategy }, - { cdopen, cdclose, rawread, nowrite, /*15*/ - cdioctl, nostop, nullreset, nodevtotty,/* cd */ - seltrue, nommap, cdstrategy }, - { lptopen, lptclose, noread, lptwrite, /*16*/ - lptioctl, nullstop, nullreset, nodevtotty,/* lpt */ - seltrue, nommap, nostrat}, - { chopen, chclose, noread, nowrite, /*17*/ - chioctl, nostop, nullreset, nodevtotty,/* ch */ - noselect, nommap, nostrat }, - { suopen, suclose, suread, suwrite, /*18*/ - suioctl, nostop, nullreset, nodevtotty,/* scsi */ - suselect, nxmmap, sustrategy }, /* 'generic' */ - { twopen, twclose, twread, twwrite, /*19*/ - noioc, nullstop, nullreset, nodevtotty,/* tw */ - twselect, nommap, nostrat }, -/* - * If you need a cdev major number for a driver that you intend to donate - * back to the group or release publically, please contact the FreeBSD team - * by sending mail to "hackers@freebsd.org". - * If you assign one yourself it may conflict with someone else. - * Otherwise, simply use the one reserved for local use. - */ - /* character device 20 is reserved for local use */ - { nxopen, nxclose, nxread, nxwrite, /*20*/ - nxioctl, nxstop, nxreset, nxdevtotty,/* reserved */ - nxselect, nxmmap, NULL }, - { psmopen, psmclose, psmread, nowrite, /*21*/ - psmioctl, nostop, nullreset, nodevtotty,/* psm mice */ - psmselect, nommap, NULL }, - { fdopen, noclose, noread, nowrite, /*22*/ - noioc, nostop, nullreset, nodevtotty,/* fd (!=Fd) */ - noselect, nommap, nostrat }, - { bpfopen, bpfclose, bpfread, bpfwrite, /*23*/ - bpfioctl, nostop, nullreset, nodevtotty,/* bpf */ - bpfselect, nommap, NULL }, - { pcaopen, pcaclose, noread, pcawrite, /*24*/ - pcaioctl, nostop, nullreset, nodevtotty,/* pcaudio */ - pcaselect, nommap, NULL }, - { nxopen, nxclose, nxread, nxwrite, /*25*/ - nxioctl, nxstop, nxreset, nxdevtotty,/* was vat */ - nxselect, nxmmap, NULL }, - { spkropen, spkrclose, noread, spkrwrite, /*26*/ - spkrioctl, nostop, nullreset, nodevtotty,/* spkr */ - seltrue, nommap, NULL }, - { mseopen, mseclose, mseread, nowrite, /*27*/ - noioc, nostop, nullreset, nodevtotty,/* mse */ - mseselect, nommap, NULL }, - { sioopen, sioclose, sioread, siowrite, /*28*/ - sioioctl, siostop, nxreset, siodevtotty,/* sio */ - ttselect, nommap, NULL }, - { mcdopen, mcdclose, rawread, nowrite, /*29*/ - mcdioctl, nostop, nullreset, nodevtotty,/* mitsumi cd */ - seltrue, nommap, mcdstrategy }, - { sndopen, sndclose, sndread, sndwrite, /*30*/ - sndioctl, nostop, nullreset, nodevtotty,/* sound */ - sndselect, nommap, NULL }, - { ukopen, ukclose, noread, nowrite, /*31*/ - ukioctl, nostop, nullreset, nodevtotty,/* unknown */ - seltrue, nommap, NULL }, /* scsi */ - { lkmcopen, lkmcclose, noread, nowrite, /*32*/ - lkmcioctl, nostop, nullreset, nodevtotty, - noselect, nommap, NULL }, - { lkmopen, lkmclose, lkmread, lkmwrite, /*33*/ - lkmioctl, lkmstop, lkmreset, nodevtotty, - lkmselect, lkmmmap, NULL }, - { lkmopen, lkmclose, lkmread, lkmwrite, /*34*/ - lkmioctl, lkmstop, lkmreset, nodevtotty, - lkmselect, lkmmmap, NULL }, - { lkmopen, lkmclose, lkmread, lkmwrite, /*35*/ - lkmioctl, lkmstop, lkmreset, nodevtotty, - lkmselect, lkmmmap, NULL }, - { lkmopen, lkmclose, lkmread, lkmwrite, /*36*/ - lkmioctl, lkmstop, lkmreset, nodevtotty, - lkmselect, lkmmmap, NULL }, - { lkmopen, lkmclose, lkmread, lkmwrite, /*37*/ - lkmioctl, lkmstop, lkmreset, nodevtotty, - lkmselect, lkmmmap, NULL }, - { lkmopen, lkmclose, lkmread, lkmwrite, /*38*/ - lkmioctl, lkmstop, lkmreset, nodevtotty, - lkmselect, lkmmmap, NULL }, - { apmopen, apmclose, noread, nowrite, /*39*/ - apmioctl, nostop, nullreset, nodevtotty,/* APM */ - seltrue, nommap, NULL }, - { ctxopen, ctxclose, ctxread, ctxwrite, /*40*/ - ctxioctl, nostop, nullreset, nodevtotty,/* cortex */ - seltrue, nommap, NULL }, - { nxopen, nxclose, nxread, nxwrite, /*41*/ - nxioctl, nxstop, nullreset, nxdevtotty,/* was socksys */ - seltrue, nommap, NULL }, - { cxopen, cxclose, cxread, cxwrite, /*42*/ - cxioctl, cxstop, nullreset, cxdevtotty,/* cronyx */ - cxselect, nommap, NULL }, - { vnopen, vnclose, rawread, rawwrite, /*43*/ - vnioctl, nostop, nullreset, nodevtotty,/* vn */ - seltrue, nommap, vnstrategy }, - { gpopen, gpclose, noread, gpwrite, /*44*/ - gpioctl, nostop, nullreset, nodevtotty,/* GPIB */ - seltrue, nommap, NULL }, - { scdopen, scdclose, rawread, nowrite, /*45*/ - scdioctl, nostop, nullreset, nodevtotty,/* sony cd */ - seltrue, nommap, scdstrategy }, - { matcdopen, matcdclose, rawread, nowrite, /*46*/ - matcdioctl, nostop, nullreset, nodevtotty,/* SB cd */ - seltrue, nommap, matcdstrategy }, - { gscopen, gscclose, gscread, nowrite, /*47*/ - gscioctl, nostop, nullreset, nodevtotty,/* gsc */ - seltrue, nommap, NULL }, - { cyopen, cyclose, cyread, cywrite, /*48*/ - cyioctl, cystop, nxreset, cydevtotty,/*cyclades*/ - ttselect, nxmmap, NULL }, - { sscopen, sscclose, noread, nowrite, /*49*/ - sscioctl, nostop, nullreset, nodevtotty,/* scsi super */ - noselect, nommap, nostrategy }, - { crdopen, crdclose, crdread, crdwrite, /*50*/ - crdioctl, nostop, nullreset, nodevtotty,/* pcmcia */ - crdselect, nommap, NULL }, - { joyopen, joyclose, joyread, nowrite, /*51*/ - joyioctl, nostop, nullreset, nodevtotty,/*joystick */ - seltrue, nommap, NULL}, - { tunopen, tunclose, tunread, tunwrite, /*52*/ - tunioctl, nostop, nullreset, nodevtotty,/* tunnel */ - tunselect, nommap, NULL }, - { snpopen, snpclose, snpread, snpwrite, /*53*/ - snpioctl, nostop, nullreset, nodevtotty,/* snoop */ - snpselect, nommap, NULL }, - { nicopen, nicclose, noread, nowrite, /*54*/ - nicioctl, nostop, nullreset, nodevtotty,/* nic */ - seltrue, nommap, NULL }, - { isdnopen, isdnclose, isdnread, nowrite, /*55*/ - isdnioctl, nostop, nullreset, nodevtotty,/* isdn */ - seltrue, nommap, NULL }, - { ityopen, ityclose, ityread, itywrite, /*56*/ - ityioctl, itystop, noreset, itydevtotty,/* ity */ - ttselect, nommap, NULL }, - { itelopen, itelclose, itelread, itelwrite, /*57*/ - itelioctl, nostop, nullreset, nodevtotty,/* itel */ - seltrue, nommap, NULL }, - { dgbopen, dgbclose, dgbread, dgbwrite, /*58*/ - dgbioctl, dgbstop, nxreset, dgbdevtotty, /* dgb */ - ttselect, nommap, NULL }, - { ispyopen, ispyclose, ispyread, nowrite, /*59*/ - ispyioctl, nostop, nullreset, nodevtotty,/* ispy */ - seltrue, nommap, NULL }, - { nnicopen, nnicclose, noread, nowrite, /*60*/ - nnicioctl, nostop, nullreset, nodevtotty,/* nnic */ - seltrue, nommap, NULL }, - { ptopen, ptclose, rawread, rawwrite, /*61*/ - ptioctl, nostop, nullreset, nodevtotty,/* pt */ - seltrue, nommap, ptstrategy }, - { wormopen, wormclose, rawread, rawwrite, /*62*/ - wormioctl, nostop, nullreset, nodevtotty,/* worm */ - seltrue, nommap, wormstrategy }, - { rcopen, rcclose, rcread, rcwrite, /*63*/ - rcioctl, rcstop, nxreset, rcdevtotty,/* rc */ - ttselect, nommap, NULL }, - { nxopen, nxclose, nxread, nxwrite, /*64*/ - nxioctl, nxstop, nxreset, nxdevtotty,/* Talisman */ - nxselect, nxmmap, NULL }, - { sctargopen, sctargclose, rawread, rawwrite, /*65*/ - sctargioctl, nostop, nullreset, nodevtotty,/* sctarg */ - seltrue, nommap, sctargstrategy }, - { labpcopen, labpcclose, rawread, rawwrite, /*66*/ - labpcioctl, nostop, nullreset, nodevtotty,/* labpc */ - seltrue, nommap, labpcstrategy }, - { meteor_open, meteor_close, meteor_read, meteor_write, /*67*/ - meteor_ioctl, nostop, nullreset, nodevtotty,/* Meteor */ - seltrue, meteor_mmap, NULL }, - { siopen, siclose, siread, siwrite, /*68*/ - siioctl, sistop, nxreset, sidevtotty,/* slxos */ - ttselect, nxmmap, NULL }, - { wcdropen, wcdrclose, rawread, nowrite, /*69*/ - wcdioctl, nostop, nullreset, nodevtotty,/* atapi */ - seltrue, nommap, wcdstrategy }, - { odopen, odclose, rawread, rawwrite, /*70*/ - odioctl, nostop, nullreset, nodevtotty,/* od */ - seltrue, nommap, odstrategy }, - { ascopen, ascclose, ascread, nowrite, /*71*/ - ascioctl, nostop, nullreset, nodevtotty, /* asc */ - ascselect, nommap, NULL } - -}; -int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]); -#endif /*JREMOD*/ /* * The routines below are total "BULLSHIT" and will be trashed * When I have 'proved' the JREMOD changes above.. */ +#ifndef NEW_STUFF_JRE /* * Swapdev is a fake device implemented @@ -1036,11 +219,7 @@ register_cdev(name, cdp) dst_cdp = getcdevbyname(name); if (dst_cdp == NULL) return (ENXIO); -#ifdef JREMOD if ((dst_cdp->d_open != nxopen) && (dst_cdp->d_open != NULL)) -#else /*JREMOD*/ - if (dst_cdp->d_open != nxopen) -#endif /*JREMOD*/ return (EBUSY); *dst_cdp = *cdp; return (0); @@ -1067,3 +246,170 @@ unregister_cdev(name, cdp) *dst_cdp = nxcdevsw; return (0); } +#else /* NEW_STUFF_JRE *//*===============================================*/ + +dev_t swapdev = makedev(1, 0); + +/* + * Routine that identifies /dev/mem and /dev/kmem. + * + * A minimal stub routine can always return 0. + */ +int +iskmemdev(dev) + dev_t dev; +{ + + return (major(dev) == 2 && (minor(dev) == 0 || minor(dev) == 1)); +} + +int +iszerodev(dev) + dev_t dev; +{ + return (major(dev) == 2 && minor(dev) == 12); +} + +/* + * Routine to determine if a device is a disk. + * + * A minimal stub routine can always return 0. + * XXX will look in the FLAGS (eventually) + */ +int +isdisk(dev, type) + dev_t dev; + int type; +{ + + switch (major(dev)) { + case 15: /* VBLK: vn, VCHR: cd */ + return (1); + case 0: /* wd */ + case 2: /* fd */ + case 4: /* sd */ + case 6: /* cd */ + case 7: /* mcd */ + case 16: /* scd */ + case 17: /* matcd */ + case 18: /* ata */ + case 19: /* wcd */ + case 20: /* od */ + if (type == VBLK) + return (1); + return (0); + case 3: /* wd */ + case 9: /* fd */ + case 13: /* sd */ + case 29: /* mcd */ + case 43: /* vn */ + case 45: /* scd */ + case 46: /* matcd */ + case 69: /* wcd */ + case 70: /* od */ + if (type == VCHR) + return (1); + /* fall through */ + default: + return (0); + } + /* NOTREACHED */ +} + +/* + * Routine to convert from character to block device number. + * + * A minimal stub routine can always return NODEV. + */ +dev_t +chrtoblk(dev) + dev_t dev; +{ + int blkmaj; + struct bdevsw *bd; + + bd = cdevsw[major(dev)].d_bdev; + if ( bd ) + return(makedev(bd->d_maj,minor(dev))); + else + return(NODEV); +} + +/* Only checks cdevs */ +int +getmajorbyname(name) + const char *name; +{ + struct cdevsw *cd; + int maj; + char *dname; + + for( maj = 0; maj <nchrdev ; maj++) { + if ( dname = cdevsw[maj].d_name) { + if ( strcmp(name, dname) == 0 ) { + return maj; + } + } + } + return -1; /* XXX */ /* Was 0 */ +} + + +/* utterly pointless with devfs */ +static struct cdevsw * +getcdevbyname(name) + const char *name; +{ + struct cdevsw *cd; + int maj; + char *dname; + + for( maj = 0; maj <nchrdev ; maj++) { + if ( dname = cdevsw[maj].d_name) { + if ( strcmp(name, dname) == 0 ) { + return &(cdevsw[maj]); + } + } + } + return NULL; +} + +/* Zap these as soon as we find out who calls them */ +int +register_cdev(name, cdp) + const char *name; + const struct cdevsw *cdp; +{ + struct cdevsw *dst_cdp; + + dst_cdp = getcdevbyname(name); + if (dst_cdp == NULL) + return (ENXIO); + if ((dst_cdp->d_open != nxopen) && (dst_cdp->d_open != NULL)) + return (EBUSY); + *dst_cdp = *cdp; + return (0); +} + +static struct cdevsw nxcdevsw = { + nxopen, nxclose, nxread, nxwrite, + nxioctl, nxstop, nxreset, nxdevtotty, + nxselect, nxmmap, NULL, +}; + +int +unregister_cdev(name, cdp) + const char *name; + const struct cdevsw *cdp; +{ + struct cdevsw *dst_cdp; + + dst_cdp = getcdevbyname(name); + if (dst_cdp == NULL) + return (ENXIO); + if (dst_cdp->d_open != cdp->d_open) + return (EBUSY); + *dst_cdp = nxcdevsw; + return (0); +} +#endif /* NEW_STIFF_JRE */ diff --git a/sys/i386/i386/cons.c b/sys/i386/i386/cons.c index 7f2e4d7..4624a28 100644 --- a/sys/i386/i386/cons.c +++ b/sys/i386/i386/cons.c @@ -36,26 +36,22 @@ * SUCH DAMAGE. * * from: @(#)cons.c 7.2 (Berkeley) 5/9/91 - * $Id: cons.c,v 1.35 1995/11/29 10:47:17 julian Exp $ + * $Id: cons.c,v 1.36 1995/11/29 14:39:24 julian Exp $ */ #include <sys/param.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <sys/systm.h> #include <sys/conf.h> +#include <sys/kernel.h> #include <sys/proc.h> #include <sys/tty.h> #include <machine/cons.h> #include <machine/stdarg.h> -#ifdef JREMOD -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 0 -#endif /*JREMOD*/ - /* XXX this should be config(8)ed. */ #include "sc.h" #include "vt.h" @@ -73,6 +69,19 @@ static struct consdev constab[] = { { 0 }, }; +static d_open_t cnopen; +static d_close_t cnclose; +static d_read_t cnread; +static d_write_t cnwrite; +static d_ioctl_t cnioctl; +static d_select_t cnselect; + +#define CDEV_MAJOR 0 +struct cdevsw cn_cdevsw = + { cnopen, cnclose, cnread, cnwrite, /*0*/ + cnioctl, nullstop, nullreset, nodevtotty,/* console */ + cnselect, nommap, NULL, "console", NULL, -1 }; + struct tty *constty = 0; /* virtual console output device */ struct tty *cn_tty; /* XXX: console tty struct for tprintf */ int cons_unavail = 0; /* XXX: @@ -86,6 +95,9 @@ static d_close_t *cn_phys_close; /* physical device close function */ static d_open_t *cn_phys_open; /* physical device open function */ static struct consdev *cn_tab; /* physical console device info */ static struct tty *cn_tp; /* physical console tty struct */ +#ifdef DEVFS +void *cn_devfs_token; /* represents the devfs entry */ +#endif /* DEVFS */ void cninit() @@ -148,7 +160,7 @@ cninit_finish() cn_tty = cn_tp; } -int +static int cnopen(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -171,7 +183,7 @@ cnopen(dev, flag, mode, p) return (retval); } -int +static int cnclose(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -204,7 +216,7 @@ cnclose(dev, flag, mode, p) return ((*cn_phys_close)(dev, flag, mode, p)); } -int +static int cnread(dev, uio, flag) dev_t dev; struct uio *uio; @@ -216,7 +228,7 @@ cnread(dev, uio, flag) return ((*cdevsw[major(dev)].d_read)(dev, uio, flag)); } -int +static int cnwrite(dev, uio, flag) dev_t dev; struct uio *uio; @@ -231,7 +243,7 @@ cnwrite(dev, uio, flag) return ((*cdevsw[major(dev)].d_write)(dev, uio, flag)); } -int +static int cnioctl(dev, cmd, data, flag, p) dev_t dev; int cmd; @@ -258,7 +270,7 @@ cnioctl(dev, cmd, data, flag, p) return ((*cdevsw[major(dev)].d_ioctl)(dev, cmd, data, flag, p)); } -int +static int cnselect(dev, rw, p) dev_t dev; int rw; @@ -312,18 +324,11 @@ pg(const char *p, ...) { return(cngetc()); } - -#ifdef JREMOD -struct cdevsw cn_cdevsw = - { cnopen, cnclose, cnread, cnwrite, /*0*/ - cnioctl, nullstop, nullreset, nodevtotty,/* console */ - cnselect, nommap, NULL }; - static cn_devsw_installed = 0; -static void cn_drvinit(void *unused) +static void +cn_drvinit(void *unused) { - void * x; dev_t dev; if( ! cn_devsw_installed ) { @@ -331,13 +336,19 @@ static void cn_drvinit(void *unused) cdevsw_add(&dev,&cn_cdevsw,NULL); cn_devsw_installed = 1; #ifdef DEVFS - /* path,name,major,minor,type,uid,gid,perm */ - x=devfs_add_devsw("/","console",major(dev),0,DV_CHR,0,0,0640); + cn_devfs_token = devfs_add_devsw( + "/", + "console", + &cn_cdevsw, + 0, + DV_CHR, + 0, + 0, + 0640); #endif } } SYSINIT(cndev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,cn_drvinit,NULL) -#endif /* JREMOD */ diff --git a/sys/i386/i386/cons.h b/sys/i386/i386/cons.h index 8fbd43f..8fa2d90 100644 --- a/sys/i386/i386/cons.h +++ b/sys/i386/i386/cons.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)cons.h 7.2 (Berkeley) 5/9/91 - * $Id: cons.h,v 1.10 1995/09/10 18:57:26 bde Exp $ + * $Id: cons.h,v 1.11 1995/09/10 21:34:50 bde Exp $ */ #ifndef _MACHINE_CONS_H_ @@ -106,14 +106,6 @@ extern int cons_unavail; struct proc; struct uio; -/* cdevsw[] entries */ -extern int cnopen(dev_t, int, int, struct proc *); -extern int cnclose(dev_t, int, int, struct proc *); -extern int cnread(dev_t, struct uio *, int); -extern int cnwrite(dev_t, struct uio *, int); -extern int cnioctl(dev_t, int, caddr_t, int, struct proc *); -extern int cnselect(dev_t, int, struct proc *); - /* other kernel entry points */ extern void cninit(void); extern void cninit_finish(void); diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c index 5fb364e..6d8a94c 100644 --- a/sys/i386/i386/mem.c +++ b/sys/i386/i386/mem.c @@ -38,7 +38,7 @@ * * from: Utah $Hdr: mem.c 1.13 89/10/08$ * from: @(#)mem.c 7.2 (Berkeley) 5/9/91 - * $Id: mem.c,v 1.21 1995/11/29 14:39:26 julian Exp $ + * $Id: mem.c,v 1.22 1995/12/07 12:45:34 davidg Exp $ */ /* @@ -48,6 +48,10 @@ #include <sys/param.h> #include <sys/conf.h> #include <sys/buf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /* DEVFS */ +#include <sys/kernel.h> #include <sys/systm.h> #include <sys/uio.h> #include <sys/malloc.h> @@ -64,33 +68,53 @@ #include <vm/pmap.h> #include <vm/vm_extern.h> -#ifdef JREMOD -#include <sys/kernel.h> + + +static d_open_t mmopen; +static d_close_t mmclose; +static d_rdwr_t mmrw; +static d_ioctl_t mmioctl; +static d_mmap_t memmmap; + #define CDEV_MAJOR 2 -#endif /*JREMOD*/ +struct cdevsw mem_cdevsw = + { mmopen, mmclose, mmrw, mmrw, /*2*/ + mmioctl, nullstop, nullreset, nodevtotty,/* memory */ + seltrue, memmmap, NULL, "mem", NULL, -1 }; #ifdef DEVFS -#include <sys/devfsext.h> - -static void -memdevfs_init(dev_t dev) +static void *mem_devfs_token; +static void *kmem_devfs_token; +static void *null_devfs_token; +static void *random_devfs_token; +static void *urandom_devfs_token; +static void *zero_devfs_token; +static void *io_devfs_token; + +static void +memdevfs_init() { - void * x; - int maj = major(dev); -/* path name major minor type uid gid perm*/ - x=devfs_add_devsw("/misc", "mem", maj, 0, DV_CHR, 0, 2, 0640); - x=devfs_add_devsw("/misc", "kmem", maj, 1, DV_CHR, 0, 2, 0640); - x=devfs_add_devsw("/misc", "null", maj, 2, DV_CHR, 0, 0, 0666); - x=devfs_add_devsw("/misc", "random", maj, 3, DV_CHR, 0, 0, 0666); - x=devfs_add_devsw("/misc", "urandom", maj, 4, DV_CHR, 0, 0, 0666); - x=devfs_add_devsw("/misc", "zero", maj, 12, DV_CHR, 0, 0, 0666); - x=devfs_add_devsw("/misc", "io", maj, 14, DV_CHR, 0, 2, 0640); +/* path name cdevsw minor type uid gid perm*/ + mem_devfs_token = devfs_add_devsw( + "/", "mem", &mem_cdevsw, 0, DV_CHR, 0, 2, 0640); + kmem_devfs_token = devfs_add_devsw( + "/", "kmem", &mem_cdevsw, 1, DV_CHR, 0, 2, 0640); + null_devfs_token = devfs_add_devsw( + "/", "null", &mem_cdevsw, 2, DV_CHR, 0, 0, 0666); + random_devfs_token = devfs_add_devsw( + "/", "random", &mem_cdevsw, 3, DV_CHR, 0, 0, 0666); + urandom_devfs_token = devfs_add_devsw( + "/", "urandom", &mem_cdevsw, 4, DV_CHR, 0, 0, 0666); + zero_devfs_token = devfs_add_devsw( + "/", "zero", &mem_cdevsw, 12, DV_CHR, 0, 0, 0666); + io_devfs_token = devfs_add_devsw( + "/", "io", &mem_cdevsw, 14, DV_CHR, 0, 2, 0640); } #endif /* DEVFS */ extern char *ptvmmap; /* poor name! */ -int +static int mmclose(dev, flags, fmt, p) dev_t dev; int flags; @@ -110,7 +134,7 @@ mmclose(dev, flags, fmt, p) return(0); } -int +static int mmopen(dev, flags, fmt, p) dev_t dev; int flags; @@ -130,7 +154,7 @@ mmopen(dev, flags, fmt, p) return(0); } -int +static int mmrw(dev, uio, flags) dev_t dev; struct uio *uio; @@ -317,7 +341,8 @@ mmrw(dev, uio, flags) * allow user processes to MMAP some memory sections * * instead of going through read/write * \*******************************************************/ -int memmmap(dev_t dev, int offset, int nprot) +static int +memmmap(dev_t dev, int offset, int nprot) { switch (minor(dev)) { @@ -339,7 +364,7 @@ int memmmap(dev_t dev, int offset, int nprot) * Allow userland to select which interrupts will be used in the muck * gathering business. */ -int +static int mmioctl(dev, cmd, cmdarg, flags, p) dev_t dev; int cmd; @@ -383,29 +408,22 @@ mmioctl(dev, cmd, cmdarg, flags, p) -#ifdef JREMOD -struct cdevsw mem_cdevsw = - { mmopen, mmclose, mmrw, mmrw, /*2*/ - mmioctl, nullstop, nullreset, nodevtotty,/* memory */ - seltrue, memmmap, NULL }; - static mem_devsw_installed = 0; -static void mem_drvinit(void *unused) +static void +mem_drvinit(void *unused) { dev_t dev; if( ! mem_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&mem_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&mem_cdevsw, NULL); mem_devsw_installed = 1; #ifdef DEVFS - memdevfs_init(dev); + memdevfs_init(); #endif } } SYSINIT(memdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,mem_drvinit,NULL) -#endif /* JREMOD */ - diff --git a/sys/i386/include/conf.h b/sys/i386/include/conf.h index f109737..ee6b603 100644 --- a/sys/i386/include/conf.h +++ b/sys/i386/include/conf.h @@ -2,383 +2,10 @@ #define _MACHINE_CONF_H_ #ifdef KERNEL - #ifndef ACTUALLY_LKM_NOT_KERNEL -/* - * XXX instead of this, the per-driver declarations should probably be - * put in the "driver.h" headers. Then ioconf.h could include all the - * "driver.h" headers and drivers would automatically include their - * own "driver.h" header, so we wouldn't need to include ioconf.h here. - * Interrupt handlers should probably be static. - */ #include "ioconf.h" #endif -/* - * The following was copied from the bogusly non-machine-generated - * file <i386/i386/conf.c>. Eventually the routines should be static. - */ - -/* bdevs. */ - -d_open_t wdopen; -d_close_t wdclose; -d_strategy_t wdstrategy; -d_ioctl_t wdioctl; -d_dump_t wddump; -d_psize_t wdsize; - -d_open_t wormopen; -d_close_t wormclose; -d_strategy_t wormstrategy; -d_ioctl_t wormioctl; -d_dump_t wormdump; -d_psize_t wormsize; - -d_open_t sctargopen; -d_close_t sctargclose; -d_strategy_t sctargstrategy; -d_ioctl_t sctargioctl; -d_dump_t sctargdump; -d_psize_t sctargsize; - -d_open_t ptopen; -d_close_t ptclose; -d_strategy_t ptstrategy; -d_ioctl_t ptioctl; -d_dump_t ptdump; -d_psize_t ptsize; - -d_open_t sdopen; -d_close_t sdclose; -d_strategy_t sdstrategy; -d_ioctl_t sdioctl; -d_dump_t sddump; -d_psize_t sdsize; - -d_open_t stopen; -d_close_t stclose; -d_strategy_t ststrategy; -d_ioctl_t stioctl; - -d_open_t odopen; -d_close_t odclose; -d_strategy_t odstrategy; -d_ioctl_t odioctl; -d_psize_t odsize; - -d_open_t cdopen; -d_close_t cdclose; -d_strategy_t cdstrategy; -d_ioctl_t cdioctl; -d_psize_t cdsize; - -d_open_t mcdopen; -d_close_t mcdclose; -d_strategy_t mcdstrategy; -d_ioctl_t mcdioctl; -d_psize_t mcdsize; - -d_open_t scdopen; -d_close_t scdclose; -d_strategy_t scdstrategy; -d_ioctl_t scdioctl; -d_psize_t scdsize; - -d_open_t matcdopen; -d_close_t matcdclose; -d_strategy_t matcdstrategy; -d_ioctl_t matcdioctl; -d_dump_t matcddump; -d_psize_t matcdsize; - -d_open_t ataopen; -d_close_t ataclose; -d_strategy_t atastrategy; -d_ioctl_t ataioctl; -d_psize_t atasize; - -d_open_t wcdbopen; -d_open_t wcdropen; -d_close_t wcdbclose; -d_close_t wcdrclose; -d_strategy_t wcdstrategy; -d_ioctl_t wcdioctl; - -d_open_t chopen; -d_close_t chclose; -d_strategy_t chstrategy; /* XXX not used */ -d_ioctl_t chioctl; - -d_open_t wtopen; -d_close_t wtclose; -d_strategy_t wtstrategy; -d_ioctl_t wtioctl; -d_dump_t wtdump; -d_psize_t wtsize; - -d_open_t Fdopen; -d_close_t fdclose; -d_strategy_t fdstrategy; -d_ioctl_t fdioctl; - -d_open_t vnopen; -d_close_t vnclose; -d_strategy_t vnstrategy; -d_ioctl_t vnioctl; -d_dump_t vndump; -d_psize_t vnsize; - -d_open_t meteor_open; -d_close_t meteor_close; -d_read_t meteor_read; -d_write_t meteor_write; -d_ioctl_t meteor_ioctl; -d_mmap_t meteor_mmap; - -d_rdwr_t swread, swwrite; - -/* cdevs. */ - -d_open_t mmopen; -d_close_t mmclose; -d_rdwr_t mmrw; -d_mmap_t memmmap; -d_ioctl_t mmioctl; - -d_open_t ptsopen; -d_close_t ptsclose; -d_rdwr_t ptsread; -d_rdwr_t ptswrite; -d_stop_t ptsstop; -d_open_t ptcopen; -d_close_t ptcclose; -d_rdwr_t ptcread; -d_rdwr_t ptcwrite; -d_select_t ptcselect; -d_ttycv_t ptydevtotty; -d_ioctl_t ptyioctl; - -d_open_t snpopen; -d_close_t snpclose; -d_rdwr_t snpread; -d_rdwr_t snpwrite; -d_select_t snpselect; -d_ioctl_t snpioctl; - -d_open_t logopen; -d_close_t logclose; -d_rdwr_t logread; -d_ioctl_t logioctl; -d_select_t logselect; - -d_open_t bquopen; -d_close_t bquclose; -d_rdwr_t bquread, bquwrite; -d_select_t bquselect; -d_ioctl_t bquioctl; - -d_open_t lptopen; -d_close_t lptclose; -d_rdwr_t lptwrite; -d_ioctl_t lptioctl; - -d_open_t twopen; -d_close_t twclose; -d_rdwr_t twread, twwrite; -d_select_t twselect; - -d_open_t psmopen; -d_close_t psmclose; -d_rdwr_t psmread; -d_select_t psmselect; -d_ioctl_t psmioctl; - -d_open_t sndopen; -d_close_t sndclose; -d_ioctl_t sndioctl; -d_rdwr_t sndread, sndwrite; -d_select_t sndselect; - -d_open_t fdopen; - -d_open_t bpfopen; -d_close_t bpfclose; -d_rdwr_t bpfread, bpfwrite; -d_select_t bpfselect; -d_ioctl_t bpfioctl; - -d_open_t spkropen; -d_close_t spkrclose; -d_rdwr_t spkrwrite; -d_ioctl_t spkrioctl; - -d_open_t pcaopen; -d_close_t pcaclose; -d_rdwr_t pcawrite; -d_ioctl_t pcaioctl; -d_select_t pcaselect; - -d_open_t mseopen; -d_close_t mseclose; -d_rdwr_t mseread; -d_select_t mseselect; - -d_open_t sioopen; -d_close_t sioclose; -d_rdwr_t sioread, siowrite; -d_ioctl_t sioioctl; -d_stop_t siostop; -d_ttycv_t siodevtotty; - -d_open_t suopen; -d_close_t suclose; -d_ioctl_t suioctl; -d_rdwr_t suread, suwrite; -d_select_t suselect; -d_strategy_t sustrategy; - -d_open_t ukopen; -d_close_t ukclose; -d_strategy_t ukstrategy; /* XXX not used */ -d_ioctl_t ukioctl; - -d_open_t lkmcopen; -d_close_t lkmcclose; -d_ioctl_t lkmcioctl; -d_open_t lkmenodev; /* XXX bogus; used for non-opens */ - -d_open_t apmopen; -d_close_t apmclose; -d_ioctl_t apmioctl; - -d_open_t ctxopen; -d_close_t ctxclose; -d_rdwr_t ctxread; -d_rdwr_t ctxwrite; -d_ioctl_t ctxioctl; - -d_open_t sscopen; -d_close_t sscclose; -d_ioctl_t sscioctl; - -d_open_t cxopen; -d_close_t cxclose; -d_rdwr_t cxread, cxwrite; -d_ioctl_t cxioctl; -d_select_t cxselect; -d_stop_t cxstop; -d_ttycv_t cxdevtotty; - -d_open_t gpopen; -d_close_t gpclose; -d_rdwr_t gpwrite; -d_ioctl_t gpioctl; - -d_open_t gscopen; -d_close_t gscclose; -d_rdwr_t gscread; -d_ioctl_t gscioctl; - -d_open_t crdopen; -d_close_t crdclose; -d_rdwr_t crdread, crdwrite; -d_ioctl_t crdioctl; -d_select_t crdselect; - -d_open_t joyopen; -d_close_t joyclose; -d_rdwr_t joyread; -d_ioctl_t joyioctl; - -d_open_t ascopen; -d_close_t ascclose; -d_rdwr_t ascread; -d_ioctl_t ascioctl; -d_select_t ascselect; - -d_open_t tunopen; -d_close_t tunclose; -d_rdwr_t tunread, tunwrite; -d_ioctl_t tunioctl; -d_select_t tunselect; - -d_open_t spigot_open; -d_close_t spigot_close; -d_ioctl_t spigot_ioctl; -d_rdwr_t spigot_read, spigot_write; -d_select_t spigot_select; -d_mmap_t spigot_mmap; - -d_open_t cyopen; -d_close_t cyclose; -d_read_t cyread; -d_write_t cywrite; -d_ioctl_t cyioctl; -d_stop_t cystop; -d_ttycv_t cydevtotty; - -d_open_t dgbopen; -d_close_t dgbclose; -d_rdwr_t dgbread; -d_rdwr_t dgbwrite; -d_ioctl_t dgbioctl; -d_stop_t dgbstop; -d_ttycv_t dgbdevtotty; - -d_open_t siopen; -d_close_t siclose; -d_read_t siread; -d_write_t siwrite; -d_ioctl_t siioctl; -d_stop_t sistop; -d_ttycv_t sidevtotty; - -d_open_t ityopen; -d_close_t ityclose; -d_read_t ityread; -d_write_t itywrite; -d_ioctl_t ityioctl; -d_stop_t itystop; -d_ttycv_t itydevtotty; - -d_open_t nicopen; -d_close_t nicclose; -d_ioctl_t nicioctl; - -d_open_t nnicopen; -d_close_t nnicclose; -d_ioctl_t nnicioctl; - -d_open_t isdnopen; -d_close_t isdnclose; -d_read_t isdnread; -d_ioctl_t isdnioctl; - -d_open_t itelopen; -d_close_t itelclose; -d_read_t itelread; -d_write_t itelwrite; -d_ioctl_t itelioctl; - -d_open_t ispyopen; -d_close_t ispyclose; -d_read_t ispyread; -d_write_t ispywrite; -d_ioctl_t ispyioctl; - -d_open_t rcopen; -d_close_t rcclose; -d_rdwr_t rcread, rcwrite; -d_ioctl_t rcioctl; -d_stop_t rcstop; -d_ttycv_t rcdevtotty; - -d_open_t labpcopen; -d_close_t labpcclose; -d_strategy_t labpcstrategy; -d_ioctl_t labpcioctl; - #endif /* KERNEL */ #endif /* !_MACHINE_CONF_H_ */ diff --git a/sys/i386/isa/asc.c b/sys/i386/isa/asc.c index 2050c76..b072c5f 100644 --- a/sys/i386/isa/asc.c +++ b/sys/i386/isa/asc.c @@ -34,7 +34,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* - * $Id: asc.c,v 1.8 1995/11/29 14:39:31 julian Exp $ + * $Id: asc.c,v 1.9 1995/12/06 23:42:22 bde Exp $ */ #include "asc.h" @@ -68,6 +68,11 @@ #include <sys/tty.h> #include <sys/uio.h> #include <sys/syslog.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/asc_ioctl.h> @@ -76,15 +81,6 @@ #include <i386/isa/isa_device.h> #include <i386/isa/ascreg.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 71 -#endif /*JREMOD*/ - #endif /* FREEBSD_1_X */ /*** @@ -184,6 +180,12 @@ struct asc_unit { #endif int height; /* height, for pnm modes */ size_t bcount; /* bytes to read, for pnm modes */ +#ifdef DEVFS + void *devfs_asc; /* storage for devfs tokens (handles) */ + void *devfs_ascp; + void *devfs_ascd; + void *devfs_ascpd; +#endif } unittab[NASC]; /*** I could not find a reasonable buffer size limit other than by @@ -202,6 +204,20 @@ int ascattach(struct isa_device *isdp); struct isa_driver ascdriver = { ascprobe, ascattach, "asc" }; #ifndef FREEBSD_1_X + +static d_open_t ascopen; +static d_close_t ascclose; +static d_read_t ascread; +static d_ioctl_t ascioctl; +static d_select_t ascselect; + +#define CDEV_MAJOR 71 + +static struct cdevsw asc_cdevsw = + { ascopen, ascclose, ascread, nowrite, /*71*/ + ascioctl, nostop, nullreset, nodevtotty, /* asc */ + ascselect, nommap, NULL, "asc", NULL, -1 }; + struct asc_softc { struct isa_device *dev; } asc_softc[NASC]; @@ -226,6 +242,9 @@ asc_registerdev(struct isa_device *id) kdc_asc[id->id_unit].kdc_isa = id; dev_attach(&kdc_asc[id->id_unit]); } +#define STATIC static +#else +#define STATIC #endif /* ! FREEBSD_1_X */ /*** @@ -447,8 +466,7 @@ ascattach(struct isa_device *isdp) int unit = isdp->id_unit; struct asc_unit *scu = unittab + unit; #ifdef DEVFS - char buf[32]; - void *x; + char name[32]; #endif scu->flags |= DEBUG; @@ -472,18 +490,24 @@ ascattach(struct isa_device *isdp) asc_registerdev(isdp); #endif #ifdef DEVFS - sprintf(buf,"asc%d",unit); +#define ASC_UID 0 +#define ASC_GID 13 + sprintf(name,"asc%d",unit); /* path name devsw minor type uid gid perm*/ - x=dev_add("/misc", buf, ascopen, unit<<6, DV_CHR, 0, 0, 0666); - sprintf(buf,"asc%dp",unit); - x=dev_add("/misc", buf, ascopen, ((unit<<6) + FRMT_PBM), - DV_CHR, 0, 0, 0666); - sprintf(buf,"asc%dd",unit); - x=dev_add("/misc", buf, ascopen, ((unit<<6) + DBUG_MASK), - DV_CHR, 0, 0, 0666); - sprintf(buf,"asc%dpd",unit); - x=dev_add("/misc", buf, ascopen, ((unit<<6) + DBUG_MASK + FRMT_PBM), - DV_CHR, 0, 0, 0666); + scu->devfs_asc = devfs_add_devsw("/", name, &asc_cdevsw, unit<<6, + DV_CHR, ASC_UID, ASC_GID, 0666); + sprintf(name,"asc%dp",unit); + scu->devfs_ascp = devfs_add_devsw("/", name, &asc_cdevsw, + ((unit<<6) + FRMT_PBM), + DV_CHR, ASC_UID, ASC_GID, 0666); + sprintf(name,"asc%dd",unit); + scu->devfs_ascd = devfs_add_devsw("/", name, &asc_cdevsw, + ((unit<<6) + DBUG_MASK), + DV_CHR, ASC_UID, ASC_GID, 0666); + sprintf(name,"asc%dpd",unit); + scu->devfs_ascpd = devfs_add_devsw("/", name, &asc_cdevsw, + ((unit<<6) + DBUG_MASK + FRMT_PBM), + DV_CHR, ASC_UID, ASC_GID, 0666); #endif /*DEVFS*/ return 1; /* attach must not fail */ } @@ -546,7 +570,7 @@ ascintr(int unit) *** don't switch scanner on, wait until first read or ioctls go before ***/ -int +STATIC int ascopen(dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT(minor(dev)) & UNIT_MASK; @@ -620,7 +644,7 @@ asc_startread(struct asc_unit *scu) *** should probably terminate dma ops, release int and dma. lr 12mar95 ***/ -int +STATIC int ascclose(dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT(minor(dev)); @@ -678,7 +702,7 @@ pbm_init(struct asc_unit *scu) *** ascread ***/ -int +STATIC int ascread(dev_t dev, struct uio *uio, int ioflag) { int unit = UNIT(minor(dev)); @@ -766,7 +790,7 @@ ascread(dev_t dev, struct uio *uio, int ioflag) *** ascioctl ***/ -int +STATIC int ascioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) { int unit = UNIT(minor(dev)); @@ -831,7 +855,7 @@ ascioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) return SUCCESS; } -int +STATIC int ascselect(dev_t dev, int rw, struct proc *p) { int unit = UNIT(minor(dev)); @@ -863,42 +887,21 @@ ascselect(dev_t dev, int rw, struct proc *p) } -#ifdef JREMOD -struct cdevsw asc_cdevsw = - { ascopen, ascclose, ascread, nowrite, /*71*/ - ascioctl, nostop, nullreset, nodevtotty, /* asc */ - ascselect, nommap, NULL }; - static asc_devsw_installed = 0; -static void asc_drvinit(void *unused) +static void +asc_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! asc_devsw_installed ) { dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&asc_cdevsw,NULL); - dev_chr = dev; -#if defined(BDEV_MAJOR) - dev = makedev(BDEV_MAJOR,0); - bdevsw_add(&dev,&asc_bdevsw,NULL); -#endif /*BDEV_MAJOR*/ asc_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "asc", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(ascdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,asc_drvinit,NULL) -#endif /* JREMOD */ #endif /* NASC > 0 */ diff --git a/sys/i386/isa/b004.c b/sys/i386/isa/b004.c index 59a25dd..d39231a 100644 --- a/sys/i386/isa/b004.c +++ b/sys/i386/isa/b004.c @@ -53,6 +53,11 @@ #include <sys/proc.h> #include <sys/uio.h> #include <sys/devconf.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> @@ -60,14 +65,6 @@ #include <i386/isa/isa.h> #include <i386/isa/isa_device.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 8 -#endif /*JREMOD*/ static u_char d_inb(u_int port); static void d_outb(u_int port, u_char data); @@ -125,6 +122,19 @@ struct isa_driver bqudriver = { bquprobe, bquattach, "bqu" }; +static d_open_t bquopen; +static d_close_t bquclose; +static d_read_t bquread; +static d_write_t bquwrite; +static d_ioctl_t bquioctl; +static d_select_t bquselect; + +#define CDEV_MAJOR 8 +struct cdevsw bqu_cdevsw = + { bquopen, bquclose, bquread, bquwrite, /*8*/ + bquioctl, nostop, nullreset, nodevtotty,/* tputer */ + bquselect, nommap, NULL, "bqu", NULL, -1 }; + static int b004_sleep; /* wait address */ static struct b004_struct b004_table[NBQU]; @@ -239,7 +249,7 @@ bquanalyse( const int dev_min ) * *****************************************************************************/ -int +static int bquread(dev_t dev, struct uio *uio, int flag) { unsigned int dev_min = minor(dev) & 7; @@ -330,7 +340,7 @@ bquread(dev_t dev, struct uio *uio, int flag) * int bquwrite() - write to the link interface. */ -int +static int bquwrite(dev_t dev, struct uio *uio, int flag) { unsigned int dev_min = minor(dev) & 7; @@ -427,7 +437,7 @@ bquwrite(dev_t dev, struct uio *uio, int flag) * */ -int +static int bquopen(dev_t dev, int flags, int fmt, struct proc *p) { unsigned int dev_min = minor(dev) & 7; @@ -456,7 +466,7 @@ bquopen(dev_t dev, int flags, int fmt, struct proc *p) * int b004close() -- close the link device. */ -int +static int bquclose(dev_t dev, int flags, int fmt, struct proc *p) { unsigned int dev_min = minor(dev) & 7; @@ -471,7 +481,7 @@ bquclose(dev_t dev, int flags, int fmt, struct proc *p) return 0; } -int +static int bquselect(dev_t dev, int rw, struct proc *p) { /* still unimplemented */ @@ -488,7 +498,7 @@ bquselect(dev_t dev, int rw, struct proc *p) * - set timeout */ -int +static int bquioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) { unsigned int dev_min = minor(dev) & 7; @@ -535,17 +545,51 @@ bquioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) static inline void bqu_registerdev(struct isa_device *id) { - if(id->id_unit) - kdc_bqu[id->id_unit] = kdc_bqu[0]; - kdc_bqu[id->id_unit].kdc_unit = id->id_unit; - kdc_bqu[id->id_unit].kdc_parentdata = id; - dev_attach(&kdc_bqu[id->id_unit]); + int unit = id->id_unit; + + kdc_bqu[unit] = kdc_bqu[0]; /* XXX */ /* ??Eh?? */ + kdc_bqu[unit].kdc_unit = unit; + kdc_bqu[unit].kdc_parentdata = id; + dev_attach(&kdc_bqu[unit]); } static int bquattach(struct isa_device *idp) { - kdc_bqu[idp->id_unit].kdc_state = DC_IDLE; + int unit = idp->id_unit; + struct b004_struct *bp; + char name[32]; + int i; + + kdc_bqu[unit].kdc_state = DC_IDLE; + +#ifdef DEVFS +#define BQU_UID 66 +#define BQU_GID 66 +#define BQU_PERM 0600 + bp = &b004_table[unit]; + for ( i = 0; i < 8; i++) { +#ifdef NOTYET + /* if (we've done all the ports found) break; */ +#endif + sprintf(name,"ttyba%d" ,i); + bp->devfs_token[i][0]=devfs_add_devsw( + "/", name, &bqu_cdevsw, i, DV_CHR, + BQU_UID, BQU_GID, BQU_PERM); + sprintf(name,"ttybd%d" ,i); + bp->devfs_token[i][0]=devfs_add_devsw( + "/", name, &bqu_cdevsw, i+64, DV_CHR, + BQU_UID, BQU_GID, BQU_PERM); + sprintf(name,"ttybc%d" ,i); + bp->devfs_token[i][0]=devfs_add_devsw( + "/", name, &bqu_cdevsw, i+128, DV_CHR, + BQU_UID, BQU_GID, BQU_PERM); + sprintf(name,"ttybd%d" ,i); + bp->devfs_token[i][0]=devfs_add_devsw( + "/", name, &bqu_cdevsw, i+192, DV_CHR, + BQU_UID, BQU_GID, BQU_PERM); + } +#endif return 1; } @@ -567,7 +611,10 @@ bquprobe(struct isa_device *idp) register */ #ifdef undef -printf("bquprobe::\nIOBASE 0x%x\nIRQ %d\nDRQ %d\nMSIZE %d\nUNIT %d\nFLAGS x0%x\nALIVE %d\n",idp->id_iobase,idp->id_irq,idp->id_drq,idp->id_msize,idp->id_unit,idp->id_flags,idp->id_alive); + printf( + "bquprobe::\nIOBASE 0x%x\nIRQ %d\nDRQ %d\nMSIZE %d\nUNIT %d\nFLAGS" + "x0%x\nALIVE %d\n",idp->id_iobase,idp->id_irq, + idp->id_drq,idp->id_msize,idp->id_unit,idp->id_flags,idp->id_alive); #endif if(first_time){ for(i=0;i<NBQU;i++) B004_F(i) &= ~B004_EXIST; @@ -636,36 +683,21 @@ printf("bquprobe::\nIOBASE 0x%x\nIRQ %d\nDRQ %d\nMSIZE %d\nUNIT %d\nFLAGS x0%x\n } /* bquprobe() */ -#ifdef JREMOD -struct cdevsw bqu_cdevsw = - { bquopen, bquclose, bquread, bquwrite, /*8*/ - bquioctl, nostop, nullreset, nodevtotty,/* tputer */ - bquselect, nommap, NULL }; - static bqu_devsw_installed = 0; -static void bqu_drvinit(void *unused) +static void +bqu_drvinit(void *unused) { dev_t dev; if( ! bqu_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&bqu_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&bqu_cdevsw, NULL); bqu_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "bqu", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(bqudev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,bqu_drvinit,NULL) -#endif /* JREMOD */ #endif /* NBQU */ diff --git a/sys/i386/isa/b004.h b/sys/i386/isa/b004.h index ee80d46..9c5576c 100644 --- a/sys/i386/isa/b004.h +++ b/sys/i386/isa/b004.h @@ -93,6 +93,7 @@ struct b004_struct { int osr; /* address of the output status register */ unsigned int timeout; /* timeout for writing/reading the link */ int boardtype; /* what kind of board is installed */ + void *devfs_token[8][4]; /* tokens for 4 types for 8 ports */ }; /* diff --git a/sys/i386/isa/ctx.c b/sys/i386/isa/ctx.c index 19b9671..817d539 100644 --- a/sys/i386/isa/ctx.c +++ b/sys/i386/isa/ctx.c @@ -8,7 +8,7 @@ * of this software, nor does the author assume any responsibility * for damages incurred with its use. * - * $Id: ctx.c,v 1.10 1995/11/29 14:39:33 julian Exp $ + * $Id: ctx.c,v 1.11 1995/12/06 23:42:26 bde Exp $ */ /* @@ -120,20 +120,17 @@ #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/devconf.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <i386/isa/isa.h> #include <i386/isa/isa_device.h> #include <i386/isa/ctxreg.h> #include <machine/ioctl_ctx.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 40 -#endif /*JREMOD*/ int waitvb(short); @@ -145,6 +142,19 @@ int waitvb(short); int ctxprobe(), ctxattach(); struct isa_driver ctxdriver = {ctxprobe, ctxattach, "ctx"}; +static d_open_t ctxopen; +static d_close_t ctxclose; +static d_read_t ctxread; +static d_write_t ctxwrite; +static d_ioctl_t ctxioctl; +#define CDEV_MAJOR 40 + +struct cdevsw ctx_cdevsw = + { ctxopen, ctxclose, ctxread, ctxwrite, /*40*/ + ctxioctl, nostop, nullreset, nodevtotty,/* cortex */ + seltrue, nommap, NULL, "ctx", NULL, -1 }; + + #define LUTSIZE 256 /* buffer size for Look Up Table (LUT) */ #define PAGESIZE 65536 /* size of one video page, 1/4 of the screen */ @@ -160,6 +170,7 @@ struct ctx_soft_registers { short iobase; caddr_t maddr; int msize; + void *devfs_token; } ctx_sr[NCTX]; @@ -203,6 +214,7 @@ int ctxattach(struct isa_device * devp) { struct ctx_soft_registers *sr; + char name[32]; sr = &(ctx_sr[devp->id_unit]); sr->cp0 = 0; /* zero out the shadow registers */ @@ -213,9 +225,14 @@ ctxattach(struct isa_device * devp) sr->msize = devp->id_msize; kdc_ctx[devp->id_unit].kdc_state = DC_IDLE; return (1); +#ifdef DEVFS + sprintf(name,"ctx%d",devp->id_unit); + sr->devfs_token = devfs_add_devsw( "/", name, &ctx_cdevsw, 0, + DV_CHR, 0, 0, 0600); +#endif /* DEVFS */ } -int +static int ctxopen(dev_t dev, int flags, int fmt, struct proc *p) { struct ctx_soft_registers *sr; @@ -271,7 +288,7 @@ ctxopen(dev_t dev, int flags, int fmt, struct proc *p) return (0); /* successful open. All ready to go. */ } -int +static int ctxclose(dev_t dev, int flags, int fmt, struct proc *p) { int unit; @@ -284,7 +301,7 @@ ctxclose(dev_t dev, int flags, int fmt, struct proc *p) return (0); } -int +static int ctxwrite(dev_t dev, struct uio * uio, int ioflag) { int unit, status = 0; @@ -329,7 +346,7 @@ ctxwrite(dev_t dev, struct uio * uio, int ioflag) return (status); } -int +static int ctxread(dev_t dev, struct uio * uio, int ioflag) { int unit, status = 0; @@ -372,7 +389,7 @@ ctxread(dev_t dev, struct uio * uio, int ioflag) return (status); } -int +static int ctxioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) { int error; @@ -451,15 +468,10 @@ waitvb(short port) -#ifdef JREMOD -struct cdevsw ctx_cdevsw = - { ctxopen, ctxclose, ctxread, ctxwrite, /*40*/ - ctxioctl, nostop, nullreset, nodevtotty,/* cortex */ - seltrue, nommap, NULL }; - static ctx_devsw_installed = 0; -static void ctx_drvinit(void *unused) +static void +ctx_drvinit(void *unused) { dev_t dev; @@ -467,20 +479,10 @@ static void ctx_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&ctx_cdevsw,NULL); ctx_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "ctx", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(ctxdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,ctx_drvinit,NULL) -#endif /* JREMOD */ #endif /* NCTX > 0 */ diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c index 73ad274..b634db0 100644 --- a/sys/i386/isa/cx.c +++ b/sys/i386/isa/cx.c @@ -39,12 +39,6 @@ # include <machine/pio.h> # define RB_GETC(q) getc(q) # else /* BSD 4.4 Lite */ -# ifdef JREMOD -# define CDEV_MAJOR 42 -# if defined(DEVFS) -# include <sys/devfsext.h> -# endif /*DEVFS*/ -# endif /*JREMOD*/ # include <sys/devconf.h> # endif #endif @@ -83,6 +77,23 @@ extern cx_chan_t *cxchan [NCX*NCHAN]; /* unit to channel struct pointer */ #if __FreeBSD__ >= 2 extern struct kern_devconf kdc_cx [NCX]; struct tty cx_tty [NCX*NCHAN]; /* tty data */ + +static d_open_t cxopen; +static d_close_t cxclose; +static d_read_t cxread; +static d_write_t cxwrite; +static d_ioctl_t cxioctl; +static d_stop_t cxstop; +static d_select_t cxselect; +static d_ttycv_t cxdevtotty; + +# define CDEV_MAJOR 42 + +struct cdevsw cx_cdevsw = + { cxopen, cxclose, cxread, cxwrite, /*42*/ + cxioctl, cxstop, nullreset, cxdevtotty,/* cronyx */ + cxselect, nommap, NULL, "cx", NULL, -1 }; + #else struct tty *cx_tty [NCX*NCHAN]; /* tty data */ #endif @@ -968,14 +979,9 @@ void cxtimeout (void *a) timeout (cxtimeout, 0, hz*5); } -#ifdef JREMOD -struct cdevsw cx_cdevsw = - { cxopen, cxclose, cxread, cxwrite, /*42*/ - cxioctl, cxstop, nullreset, cxdevtotty,/* cronyx */ - cxselect, nommap, NULL }; +#if defined(__FreeBSD__) && (__FreeBSD__ > 1 ) static cx_devsw_installed = 0; - static void cx_drvinit(void *unused) { dev_t dev; @@ -984,20 +990,11 @@ static void cx_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&cx_cdevsw,NULL); cx_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "cx", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(cxdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,cx_drvinit,NULL) -#endif /* JREMOD */ +#endif #endif /* NCX */ diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c index ae025c0..acd4db6 100644 --- a/sys/i386/isa/cy.c +++ b/sys/i386/isa/cy.c @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: cy.c,v 1.22 1995/11/29 14:39:37 julian Exp $ + * $Id: cy.c,v 1.23 1995/12/06 23:42:34 bde Exp $ */ #include "cy.h" @@ -315,6 +315,10 @@ struct com_s { u_char obuf1[256]; u_char obuf2[256]; +#ifdef DEVFS + void *devfs_token; /* one for now */ +#endif + struct kern_devconf kdc; }; @@ -358,6 +362,21 @@ static struct com_s *p_com_addr[NSIO]; static struct timeval intr_timestamp; +static d_open_t cyopen; +static d_close_t cyclose; +static d_read_t cyread; +static d_write_t cywrite; +static d_ioctl_t cyioctl; +static d_stop_t cystop; +static d_ttycv_t cydevtotty; + +#define CDEV_MAJOR 48 +struct cdevsw cy_cdevsw = + { cyopen, cyclose, cyread, cywrite, /*48*/ + cyioctl, cystop, nxreset, cydevtotty,/*cyclades*/ + ttselect, nxmmap, NULL, "cy", NULL, -1 }; + + struct isa_driver siodriver = { sioprobe, sioattach, "cy" }; @@ -396,12 +415,9 @@ static int cy_nr_cd1400s[NCY]; #undef RxFifoThreshold static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2); -#ifdef JREMOD #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ -#define CDEV_MAJOR 48 -#endif /*JREMOD*/ static struct kern_devconf kdc_sio[NCY] = { { 0, 0, 0, /* filled in by dev_attach */ @@ -502,6 +518,7 @@ sioattach(isdp) cy_addr iobase; int ncyu; int unit; + char name [32]; unit = isdp->id_unit; if ((u_int)unit >= NCY) @@ -575,6 +592,13 @@ sioattach(isdp) s = spltty(); com_addr(unit) = com; splx(s); +#ifdef DEVFS +/* XXX */ /* Fix this when you work out what the f*ck it looks like */ + sprintf(name, "cy%d", unit); + com->devfs_token = + devfs_add_devsw( "/", name, &cy_cdevsw, unit, + DV_CHR, 0, 0, 0600); +#endif } } kdc_sio[isdp->id_unit].kdc_state = DC_BUSY; /* XXX */ @@ -585,7 +609,7 @@ sioattach(isdp) return (1); } -int +static int sioopen(dev, flag, mode, p) dev_t dev; int flag; @@ -786,7 +810,7 @@ out: return (error); } -int +static int sioclose(dev, flag, mode, p) dev_t dev; int flag; @@ -887,7 +911,7 @@ comhardclose(com) splx(s); } -int +static int sioread(dev, uio, flag) dev_t dev; struct uio *uio; @@ -903,7 +927,7 @@ sioread(dev, uio, flag) return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } -int +static int siowrite(dev, uio, flag) dev_t dev; struct uio *uio; @@ -1320,7 +1344,7 @@ siointr1(com) { } -int +static int sioioctl(dev, cmd, data, flag, p) dev_t dev; int cmd; @@ -2105,7 +2129,7 @@ comstart(tp) splx(s); } -void +static void siostop(tp, rw) struct tty *tp; int rw; @@ -2520,36 +2544,20 @@ cystatus(unit) -#ifdef JREMOD -struct cdevsw cy_cdevsw = - { cyopen, cyclose, cyread, cywrite, /*48*/ - cyioctl, cystop, nxreset, cydevtotty,/*cyclades*/ - ttselect, nxmmap, NULL }; - static cy_devsw_installed = 0; -static void cy_drvinit(void *unused) +static void +cy_drvinit(void *unused) { dev_t dev; if( ! cy_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&cy_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&cy_cdevsw, NULL); cy_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "cy", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(cydev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,cy_drvinit,NULL) -#endif /* JREMOD */ - #endif /* NCY > 0 */ diff --git a/sys/i386/isa/fd.c b/sys/i386/isa/fd.c index 1af2cbf..e1b3436 100644 --- a/sys/i386/isa/fd.c +++ b/sys/i386/isa/fd.c @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * @@ -43,7 +43,7 @@ * SUCH DAMAGE. * * from: @(#)fd.c 7.4 (Berkeley) 5/25/91 - * $Id: fd.c,v 1.71 1995/11/20 12:41:38 phk Exp $ + * $Id: fd.c,v 1.72 1995/11/28 09:41:00 julian Exp $ * */ @@ -87,11 +87,7 @@ #include <sys/devfsext.h> #endif -#ifdef JREMOD -#define CDEV_MAJOR 9 -#define BDEV_MAJOR 2 -static void fd_devsw_install(); -#endif /*JREMOD */ + static int fd_goaway(struct kern_devconf *, int); static int fdc_goaway(struct kern_devconf *, int); static int fd_externalize(struct kern_devconf *, struct sysctl_req *); @@ -250,6 +246,10 @@ struct fd_data { int track; /* where we think the head is */ int options; /* user configurable options, see ioctl_fd.h */ int dkunit; /* disk stats unit number */ +#ifdef DEVFS + void *rfd_devfs_token; + void *fd_devfs_token; +#endif } fd_data[NFD]; /***********************************************************************\ @@ -342,6 +342,24 @@ struct isa_driver fdcdriver = { fdprobe, fdattach, "fdc", }; +static d_open_t Fdopen; /* NOTE, not fdopen */ +static d_close_t fdclose; +static d_ioctl_t fdioctl; +static d_strategy_t fdstrategy; + +#define CDEV_MAJOR 9 +#define BDEV_MAJOR 2 +extern struct cdevsw fd_cdevsw; +struct bdevsw fd_bdevsw = + { Fdopen, fdclose, fdstrategy, fdioctl, /*2*/ + nxdump, zerosize, 0, "fd", &fd_cdevsw, -1 }; + +struct cdevsw fd_cdevsw = + { Fdopen, fdclose, rawread, rawwrite, /*9*/ + fdioctl, nostop, nullreset, nodevtotty, + seltrue, nommap, fdstrategy, "fd", + &fd_bdevsw, -1 }; + struct isa_device *fdcdevs[NFDC]; /* @@ -518,9 +536,6 @@ fdprobe(struct isa_device *dev) #ifndef DEV_LKM fdc_registerdev(dev); #endif -#ifdef JREMOD - fd_devsw_install(); -#endif /*JREMOD*/ /* First - lets reset the floppy controller */ outb(dev->id_iobase+FDOUT, 0); @@ -554,7 +569,6 @@ fdattach(struct isa_device *dev) int ic_type = 0; #ifdef DEVFS char name[64]; - void *key; #endif /* DEVFS */ fdc->fdcu = fdcu; @@ -750,10 +764,12 @@ fdattach(struct isa_device *dev) } kdc_fd[fdu].kdc_state = DC_IDLE; #ifdef DEVFS - key = dev_add("/disks/rfloppy",name,(caddr_t)Fdopen,fdu * 8, - DV_CHR,0,0,0644); - key = dev_add("/disks/floppy",name,(caddr_t)Fdopen,fdu * 8, - DV_BLK,0,0,0644); + fd->rfd_devfs_token = devfs_add_devsw( + "/",name,&fd_cdevsw, fdu * 8, + DV_CHR,0,0,0644); + fd->fd_devfs_token = devfs_add_devsw( + "/",name, &fd_bdevsw, fdu * 8, + DV_BLK,0,0,0644); #endif /* DEVFS */ if (dk_ndrive < DK_NDRIVE) { sprintf(dk_names[dk_ndrive], "fd%d", fdu); @@ -1893,32 +1909,23 @@ fdioctl(dev, cmd, addr, flag, p) } -#ifdef JREMOD -struct bdevsw fd_bdevsw = - { Fdopen, fdclose, fdstrategy, fdioctl, /*2*/ - nxdump, zerosize, 0 }; - -struct cdevsw fd_cdevsw = - { Fdopen, fdclose, rawread, rawwrite, /*9*/ - fdioctl, nostop, nullreset, nodevtotty,/* Fd (!=fd) */ - seltrue, nommap, fdstrategy }; - static fd_devsw_installed = 0; -static void fd_devsw_install() +static void fd_drvinit(void *notused ) { - dev_t descript; + dev_t dev; + if( ! fd_devsw_installed ) { - descript = makedev(CDEV_MAJOR,0); - cdevsw_add(&descript,&fd_cdevsw,NULL); -#if defined(BDEV_MAJOR) - descript = makedev(BDEV_MAJOR,0); - bdevsw_add(&descript,&fd_bdevsw,NULL); -#endif /*BDEV_MAJOR*/ + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&fd_cdevsw, NULL); + dev = makedev(BDEV_MAJOR, 0); + bdevsw_add(&dev,&fd_bdevsw, NULL); fd_devsw_installed = 1; } } -#endif /* JREMOD */ + +SYSINIT(fddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,fd_drvinit,NULL) + #endif /* * Hello emacs, these are the diff --git a/sys/i386/isa/gpib.c b/sys/i386/isa/gpib.c index 1d0b1ac..76e11d9 100644 --- a/sys/i386/isa/gpib.c +++ b/sys/i386/isa/gpib.c @@ -33,6 +33,11 @@ #include "uio.h" #include "kernel.h" #include "malloc.h" +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> @@ -47,14 +52,6 @@ #define SLEEP_MAX 1000 #define SLEEP_MIN 4 -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 44 -#endif /*JREMOD*/ int initgpib(void); @@ -79,6 +76,17 @@ int gpattach(); struct isa_driver gpdriver = {gpprobe, gpattach, "gp"}; +static d_open_t gpopen; +static d_close_t gpclose; +static d_write_t gpwrite; +static d_ioctl_t gpioctl; + +#define CDEV_MAJOR 44 +struct cdevsw gp_cdevsw = + { gpopen, gpclose, noread, gpwrite, /*44*/ + gpioctl, nostop, nullreset, nodevtotty,/* GPIB */ + seltrue, nommap, NULL, "gp", NULL, -1 }; + #define BUFSIZE 1024 #define ATTACHED 0x08 #define OPEN 0x04 @@ -92,7 +100,10 @@ static struct gpib_softc { u_char sc_flags; /* flags (open and internal) */ char sc_unit; /* gpib device number */ char *sc_inbuf; /* buffer for data */ -} gpib_sc; +#ifdef DEVFS + void *devfs_token; /* handle for devfs entry */ +#endif +} gpib_sc; /* only support one of these? */ static int oldcount; static char oldbytes[2]; /*Probe routine*/ @@ -134,6 +145,10 @@ gpattach(isdp) printf ("gp%d: type AT-GPIB chip NAT4882A\n",sc->sc_unit); sc->sc_flags |=ATTACHED; +#ifdef DEVFS + sc->devfs_token = devfs_add_devsw( "/", "gp", &gp_cdevsw, 0, + DV_CHR, 0, 0, 0600); +#endif return (1); } @@ -144,7 +159,7 @@ gpattach(isdp) * More than 1 open is not allowed on the entire device. * i.e. even if gpib5 is open, we can't open another minor device */ -int +static int gpopen(dev, flags, fmt, p) dev_t dev; int flags; @@ -222,7 +237,7 @@ enableremote(unit); * gpclose() * Close gpib device. */ -int +static int gpclose(dev, flags, fmt, p) dev_t dev; int flags; @@ -325,7 +340,7 @@ while (!(inb(ISR1)&2)&&(status==EWOULDBLOCK)); * Copy from user's buffer, then write to GPIB device referenced * by minor(dev). */ -int +static int gpwrite(dev, uio, ioflag) dev_t dev; struct uio *uio; @@ -378,7 +393,7 @@ gpwrite(dev, uio, ioflag) An exception would be a plotter or printer that you can just write to using a minor device = its GPIB address */ -int +static int gpioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) { struct gpibdata *gd = (struct gpibdata *)data; @@ -1264,36 +1279,21 @@ outb(CDOR,95); /*untalk*/ } -#ifdef JREMOD -struct cdevsw gp_cdevsw = - { gpopen, gpclose, noread, gpwrite, /*44*/ - gpioctl, nostop, nullreset, nodevtotty,/* GPIB */ - seltrue, nommap, NULL }; - static gp_devsw_installed = 0; -static void gp_drvinit(void *unused) +static void +gp_drvinit(void *unused) { dev_t dev; if( ! gp_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&gp_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&gp_cdevsw, NULL); gp_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "gp", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(gpdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,gp_drvinit,NULL) -#endif /* JREMOD */ #endif /* NGPIB > 0 */ diff --git a/sys/i386/isa/gsc.c b/sys/i386/isa/gsc.c index e8dfade..f8369e5 100644 --- a/sys/i386/isa/gsc.c +++ b/sys/i386/isa/gsc.c @@ -45,6 +45,11 @@ #include <sys/ioctl.h> #include <sys/uio.h> #include <sys/syslog.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/gsc.h> @@ -57,14 +62,6 @@ * CONSTANTS & DEFINES * ***********************************************************************/ -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 47 -#endif /*JREMOD*/ #define PROBE_FAIL 0 #define PROBE_SUCCESS 1 @@ -159,6 +156,12 @@ struct gsc_unit { int height; /* height, for pnm modes */ size_t bcount; /* bytes to read, for pnm modes */ struct _sbuf hbuf; /* buffer for pnm header data */ +#ifdef DEVFS + void *devfs_gsc; /* storage for devfs tokens (handles) */ + void *devfs_gscp; + void *devfs_gscd; + void *devfs_gscpd; +#endif } unittab[NGSC]; /* I could not find a reasonable buffer size limit other than by @@ -175,11 +178,23 @@ struct gsc_unit { * ***********************************************************************/ -int gscprobe (struct isa_device *isdp); -int gscattach(struct isa_device *isdp); +static int gscprobe (struct isa_device *isdp); +static int gscattach(struct isa_device *isdp); struct isa_driver gscdriver = { gscprobe, gscattach, "gsc" }; +static d_open_t gscopen; +static d_close_t gscclose; +static d_read_t gscread; +static d_ioctl_t gscioctl; + +#define CDEV_MAJOR 47 +struct cdevsw gsc_cdevsw = + { gscopen, gscclose, gscread, nowrite, /*47*/ + gscioctl, nostop, nullreset, nodevtotty,/* gsc */ + seltrue, nommap, NULL, "gsc", NULL, -1 }; + + /*********************************************************************** * * LOCALLY USED SUBROUTINES @@ -379,7 +394,7 @@ buffer_read(struct gsc_unit *scu) * - if DMA channel matches (status byte has correct value) */ -int +static int gscprobe (struct isa_device *isdp) { int unit = isdp->id_unit; @@ -476,11 +491,12 @@ gscprobe (struct isa_device *isdp) * get geometry value */ -int +static int gscattach(struct isa_device *isdp) { int unit = isdp->id_unit; struct gsc_unit *scu = unittab + unit; + char name[32]; scu->flags |= DEBUG; @@ -507,6 +523,26 @@ gscattach(struct isa_device *isdp) scu->flags |= ATTACHED; lprintf("gsc%d.attach: ok\n", unit); scu->flags &= ~DEBUG; +#ifdef DEVFS +#define GSC_UID 0 +#define GSC_GID 13 + sprintf(name,"gsc%d",unit); +/* path name devsw minor type uid gid perm*/ + scu->devfs_gsc = devfs_add_devsw("/", name, &gsc_cdevsw, unit<<6, + DV_CHR, GSC_UID, GSC_GID, 0666); + sprintf(name,"gsc%dp",unit); + scu->devfs_gscp = devfs_add_devsw("/", name, &gsc_cdevsw, + ((unit<<6) + FRMT_PBM), + DV_CHR, GSC_UID, GSC_GID, 0666); + sprintf(name,"gsc%dd",unit); + scu->devfs_gscd = devfs_add_devsw("/", name, &gsc_cdevsw, + ((unit<<6) + DBUG_MASK), + DV_CHR, GSC_UID, GSC_GID, 0666); + sprintf(name,"gsc%dpd",unit); + scu->devfs_gscpd = devfs_add_devsw("/", name, &gsc_cdevsw, + ((unit<<6) + DBUG_MASK + FRMT_PBM), + DV_CHR, GSC_UID, GSC_GID, 0666); +#endif /*DEVFS*/ return SUCCESS; /* attach must not fail */ } @@ -520,7 +556,8 @@ gscattach(struct isa_device *isdp) * don't switch scanner on, wait until first read ioctls go before */ -int gscopen (dev_t dev, int flags, int fmt, struct proc *p) +static int +gscopen (dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT(minor(dev)) & UNIT_MASK; struct gsc_unit *scu = unittab + unit; @@ -573,7 +610,8 @@ int gscopen (dev_t dev, int flags, int fmt, struct proc *p) * release the buffer */ -int gscclose (dev_t dev, int flags, int fmt, struct proc *p) +static int +gscclose (dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT(minor(dev)); struct gsc_unit *scu = unittab + unit; @@ -606,7 +644,8 @@ int gscclose (dev_t dev, int flags, int fmt, struct proc *p) * gscread */ -int gscread (dev_t dev, struct uio *uio, int ioflag) +static int +gscread (dev_t dev, struct uio *uio, int ioflag) { int unit = UNIT(minor(dev)); struct gsc_unit *scu = unittab + unit; @@ -695,7 +734,8 @@ int gscread (dev_t dev, struct uio *uio, int ioflag) * */ -int gscioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) +static int +gscioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { int unit = UNIT(minor(dev)); struct gsc_unit *scu = unittab + unit; @@ -782,36 +822,21 @@ int gscioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) } -#ifdef JREMOD -struct cdevsw gsc_cdevsw = - { gscopen, gscclose, gscread, nowrite, /*47*/ - gscioctl, nostop, nullreset, nodevtotty,/* gsc */ - seltrue, nommap, NULL }; - static gsc_devsw_installed = 0; -static void gsc_drvinit(void *unused) +static void +gsc_drvinit(void *unused) { dev_t dev; if( ! gsc_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&gsc_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&gsc_cdevsw, NULL); gsc_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "gsc", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(gscdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,gsc_drvinit,NULL) -#endif /* JREMOD */ #endif /* NGSC > 0 */ diff --git a/sys/i386/isa/if_cx.c b/sys/i386/isa/if_cx.c index 1520f95..8ea6810 100644 --- a/sys/i386/isa/if_cx.c +++ b/sys/i386/isa/if_cx.c @@ -45,9 +45,9 @@ # include <machine/pio.h> # else # ifdef DEVFS +extern struct cdevsw cx_cdevsw; # include <sys/devfsext.h> # endif /*DEVFS*/ -# define CDEV_MAJOR 42 /*XXX*/ /* replace with variable ASAP*/ # include <sys/devconf.h> # endif # define watchdog_func_t void(*)(struct ifnet *) @@ -372,11 +372,10 @@ void cxattach (struct device *parent, struct device *self, void *aux) printf ("cx%d: <Cronyx-%s>\n", unit, b->name); #ifdef DEVFS { - int x; -/* default for a simple device with no probe routine (usually delete this) */ + void *x; x=devfs_add_devsw( /* path name devsw minor type uid gid perm*/ - "/", "cx", major(CDEV_MAJOR), 0, DV_CHR, 0, 0, 0600); + "/", "cx", &cx_cdevsw, 0, DV_CHR, 0, 0, 0600); } #endif return (1); diff --git a/sys/i386/isa/joy.c b/sys/i386/isa/joy.c index 25d2311..2955d1c 100644 --- a/sys/i386/isa/joy.c +++ b/sys/i386/isa/joy.c @@ -34,6 +34,11 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/joystick.h> @@ -41,15 +46,6 @@ #include <i386/isa/isa_device.h> #include <i386/isa/timerreg.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 51 -#endif /*JREMOD*/ - /* The game port can manage 4 buttons and 4 variable resistors (usually 2 * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201. * Getting the state of the buttons is done by reading the game port: @@ -77,6 +73,9 @@ static struct { int port; int x_off[2], y_off[2]; int timeout[2]; +#ifdef DEVFS + void *devfs_token; +#endif } joy[NJOY]; @@ -86,6 +85,17 @@ int joyprobe (struct isa_device *), joyattach (struct isa_device *); struct isa_driver joydriver = {joyprobe, joyattach, "joy"}; +#define CDEV_MAJOR 51 +static d_open_t joyopen; +static d_close_t joyclose; +static d_read_t joyread; +static d_ioctl_t joyioctl; + +struct cdevsw joy_cdevsw = + { joyopen, joyclose, joyread, nowrite, /*51*/ + joyioctl, nostop, nullreset, nodevtotty,/*joystick */ + seltrue, nommap, NULL, "joy", NULL, -1 }; + static int get_tick (); @@ -104,14 +114,22 @@ joyprobe (struct isa_device *dev) int joyattach (struct isa_device *dev) { - joy[dev->id_unit].port = dev->id_iobase; - joy[dev->id_unit].timeout[0] = joy[dev->id_unit].timeout[1] = 0; - printf("joy%d: joystick\n", dev->id_unit); - + int unit = dev->id_unit; + char name[32]; + + joy[unit].port = dev->id_iobase; + joy[unit].timeout[0] = joy[unit].timeout[1] = 0; + printf("joy%d: joystick\n", unit); +#ifdef DEVFS + sprintf(name, "joy%d", unit); + joy[dev->id_unit].devfs_token = devfs_add_devsw( "/", "joy", + &joy_cdevsw, 0, + DV_CHR, 0, 0, 0600); +#endif return 1; } -int +static int joyopen (dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT (dev); @@ -123,7 +141,7 @@ joyopen (dev_t dev, int flags, int fmt, struct proc *p) joy[unit].timeout[i] = JOY_TIMEOUT; return 0; } -int +static int joyclose (dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT (dev); @@ -133,7 +151,7 @@ joyclose (dev_t dev, int flags, int fmt, struct proc *p) return 0; } -int +static int joyread (dev_t dev, struct uio *uio, int flag) { int unit = UNIT(dev); @@ -169,7 +187,9 @@ joyread (dev_t dev, struct uio *uio, int flag) c.b2 = ~(state >> 1) & 1; return uiomove ((caddr_t)&c, sizeof(struct joystick), uio); } -int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) + +static int +joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { int unit = UNIT (dev); int i = joypart (dev); @@ -202,6 +222,7 @@ int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) } return 0; } + static int get_tick () { @@ -215,12 +236,6 @@ get_tick () } -#ifdef JREMOD -struct cdevsw joy_cdevsw = - { joyopen, joyclose, joyread, nowrite, /*51*/ - joyioctl, nostop, nullreset, nodevtotty,/*joystick */ - seltrue, nommap, NULL}; - static joy_devsw_installed = 0; static void joy_drvinit(void *unused) @@ -231,20 +246,9 @@ static void joy_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&joy_cdevsw,NULL); joy_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "joy", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(joydev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,joy_drvinit,NULL) -#endif /* JREMOD */ - #endif /* NJOY > 0 */ diff --git a/sys/i386/isa/labpc.c b/sys/i386/isa/labpc.c index 430be96..97984ee 100644 --- a/sys/i386/isa/labpc.c +++ b/sys/i386/isa/labpc.c @@ -53,20 +53,17 @@ #include <sys/errno.h> #include <sys/buf.h> #include <sys/dataacq.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/devconf.h> #include <machine/clock.h> #include <i386/isa/isa_device.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 66 -#endif /*JREMOD*/ /* Miniumum timeout: @@ -151,6 +148,9 @@ struct ctlr /* Device configuration structure: */ struct kern_devconf kdc; +#ifdef DEVFS + void *devfs_token; +#endif }; #ifdef LOUTB @@ -283,6 +283,17 @@ extern int labpcprobe(struct isa_device *dev); struct isa_driver labpcdriver = { labpcprobe, labpcattach, "labpc", 0 /* , labpcdetach */ }; +static d_open_t labpcopen; +static d_close_t labpcclose; +static d_ioctl_t labpcioctl; +static d_strategy_t labpcstrategy; + +#define CDEV_MAJOR 66 +struct cdevsw labpc_cdevsw = + { labpcopen, labpcclose, rawread, rawwrite, /*66*/ + labpcioctl, nostop, nullreset, nodevtotty,/* labpc */ + seltrue, nommap, labpcstrategy, "labpc", NULL, -1 }; + static void start(struct ctlr *ctlr); static void @@ -495,6 +506,8 @@ int labpcprobe(struct isa_device *dev) int labpcattach(struct isa_device *dev) { struct ctlr *ctlr = labpcs[dev->id_unit]; + char name[32]; + ctlr->sample_us = (1000000.0 / (double)LABPC_DEFAULT_HERZ) + .50; reset(ctlr); labpc_registerdev(dev); @@ -505,6 +518,13 @@ int labpcattach(struct isa_device *dev) ctlr->dcr_is = 0x80; loutb(DCR(ctlr), ctlr->dcr_val); +#ifdef DEVFS + sprintf(name, "labpc%d",dev->id_unit); + /* path name devsw minor */ + ctlr->devfs_token = devfs_add_devsw( "/", name, &labpc_cdevsw, 0, + /* what UID GID PERM */ + DV_CHR, 0, 0, 0600); +#endif return 1; } @@ -734,7 +754,7 @@ lockout_multiple_open(dev_t current, dev_t next) return ! (DIGITAL(current) && DIGITAL(next)); } -int +static int labpcopen(dev_t dev, int flags, int fmt, struct proc *p) { u_short unit = UNIT(dev); @@ -772,7 +792,7 @@ labpcopen(dev_t dev, int flags, int fmt, struct proc *p) return 0; } -int +static int labpcclose(dev_t dev, int flags, int fmt, struct proc *p) { struct ctlr *ctlr = labpcs[UNIT(dev)]; @@ -1007,7 +1027,7 @@ digital_in_strategy(struct buf *bp, struct ctlr *ctlr) } -void +static void labpcstrategy(struct buf *bp) { struct ctlr *ctlr = labpcs[UNIT(bp->b_dev)]; @@ -1045,7 +1065,7 @@ labpcstrategy(struct buf *bp) } } -int +static int labpcioctl(dev_t dev, int cmd, caddr_t arg, int mode, struct proc *p) { struct ctlr *ctlr = labpcs[UNIT(dev)]; @@ -1107,12 +1127,6 @@ labpcioctl(dev_t dev, int cmd, caddr_t arg, int mode, struct proc *p) } -#ifdef JREMOD -struct cdevsw labpc_cdevsw = - { labpcopen, labpcclose, rawread, rawwrite, /*66*/ - labpcioctl, nostop, nullreset, nodevtotty,/* labpc */ - seltrue, nommap, labpcstrategy }; - static labpc_devsw_installed = 0; static void labpc_drvinit(void *unused) @@ -1123,19 +1137,9 @@ static void labpc_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&labpc_cdevsw,NULL); labpc_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "labpc", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(labpcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,labpc_drvinit,NULL) -#endif /* JREMOD */ diff --git a/sys/i386/isa/lpt.c b/sys/i386/isa/lpt.c index 3c0b4b4..81d503b 100644 --- a/sys/i386/isa/lpt.c +++ b/sys/i386/isa/lpt.c @@ -46,7 +46,7 @@ * SUCH DAMAGE. * * from: unknown origin, 386BSD 0.1 - * $Id: lpt.c,v 1.44 1995/12/06 23:50:14 bde Exp $ + * $Id: lpt.c,v 1.45 1995/12/07 12:46:03 davidg Exp $ */ /* @@ -113,6 +113,9 @@ #include <sys/uio.h> #include <sys/syslog.h> #include <sys/devconf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> #include <machine/lpt.h> @@ -144,14 +147,6 @@ #endif #endif /* INET */ -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 16 -#endif /*JREMOD*/ #define LPINITRDY 4 /* wait up to 4 seconds for a ready */ #define LPTOUTTIME 4 /* wait up to 4 seconds for a ready */ @@ -232,7 +227,9 @@ struct lpt_softc { u_char *sc_ifbuf; int sc_iferrs; #endif /* ENDIF */ - +#ifdef DEVFS + void *devfs_token; +#endif } lpt_sc[NLPT] ; /* bits for state */ @@ -289,6 +286,18 @@ struct isa_driver lptdriver = { lptprobe, lptattach, "lpt" }; +static d_open_t lptopen; +static d_close_t lptclose; +static d_write_t lptwrite; +static d_ioctl_t lptioctl; + +#define CDEV_MAJOR 16 +struct cdevsw lpt_cdevsw = + { lptopen, lptclose, noread, lptwrite, /*16*/ + lptioctl, nullstop, nullreset, nodevtotty,/* lpt */ + seltrue, nommap, nostrat, "lpt", NULL, -1 }; + + static struct kern_devconf kdc_lpt[NLPT] = { { 0, 0, 0, /* filled in by dev_attach */ "lpt", 0, { MDDT_ISA, 0, "tty" }, @@ -443,8 +452,11 @@ int lptattach(struct isa_device *isdp) { struct lpt_softc *sc; + int unit; + char name[32]; - sc = lpt_sc + isdp->id_unit; + unit = isdp->id_unit; + sc = lpt_sc + unit; sc->sc_port = isdp->id_iobase; sc->sc_primed = 0; /* not primed yet */ outb(sc->sc_port+lpt_control, LPC_NINIT); @@ -453,18 +465,25 @@ lptattach(struct isa_device *isdp) lprintf("oldirq %x\n", sc->sc_irq); if (isdp->id_irq) { sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ; - printf("lpt%d: Interrupt-driven port\n", isdp->id_unit); + printf("lpt%d: Interrupt-driven port\n", unit); #ifdef INET - lpattach(sc, isdp->id_unit); + lpattach(sc, unit); #endif } else { sc->sc_irq = 0; - lprintf("lpt%d: Polled port\n", isdp->id_unit); + lprintf("lpt%d: Polled port\n", unit); } lprintf("irq %x\n", sc->sc_irq); - kdc_lpt[isdp->id_unit].kdc_state = DC_IDLE; + kdc_lpt[unit].kdc_state = DC_IDLE; +#ifdef DEVFS +/* XXX */ /* what to do about the flags in the minor number? */ + sprintf(name,"lpt%d",unit); + /* path name devsw minor type uid gid perm*/ + sc->devfs_token = devfs_add_devsw( "/", name, &lpt_cdevsw, unit, + DV_CHR, 0, 0, 0600); +#endif return (1); } @@ -474,7 +493,7 @@ lptattach(struct isa_device *isdp) * printer -- this is just used for passing ioctls. */ -int +static int lptopen (dev_t dev, int flags, int fmt, struct proc *p) { struct lpt_softc *sc; @@ -608,7 +627,7 @@ lptout (struct lpt_softc * sc) * Check for interrupted write call added. */ -int +static int lptclose(dev_t dev, int flags, int fmt, struct proc *p) { struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev)); @@ -707,7 +726,7 @@ pushbytes(struct lpt_softc * sc) * Flagging of interrupted write added. */ -int +static int lptwrite(dev_t dev, struct uio * uio, int ioflag) { register unsigned n; @@ -805,7 +824,7 @@ lptintr(int unit) lprintf("sts %x ", sts); } -int +static int lptioctl(dev_t dev, int cmd, caddr_t data, int flags, struct proc *p) { int error = 0; @@ -1355,12 +1374,6 @@ lpoutput (struct ifnet *ifp, struct mbuf *m, #endif /* INET */ -#ifdef JREMOD -struct cdevsw lpt_cdevsw = - { lptopen, lptclose, noread, lptwrite, /*16*/ - lptioctl, nullstop, nullreset, nodevtotty,/* lpt */ - seltrue, nommap, nostrat}; - static lpt_devsw_installed = 0; static void lpt_drvinit(void *unused) @@ -1368,21 +1381,11 @@ static void lpt_drvinit(void *unused) dev_t dev; if( ! lpt_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&lpt_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&lpt_cdevsw, NULL); lpt_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "lpt", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(lptdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,lpt_drvinit,NULL) -#endif /* JREMOD */ diff --git a/sys/i386/isa/matcd/matcd.c b/sys/i386/isa/matcd/matcd.c index f4e29fa..20f5116 100644 --- a/sys/i386/isa/matcd/matcd.c +++ b/sys/i386/isa/matcd/matcd.c @@ -323,6 +323,11 @@ Edit number code marking begins here - earlier edits were during development. Also, disable the audio-related ioctls based on the BOOTMFS conditional to help make the boot floppy kernel smaller. 18-Oct-95 Frank Durda IV bsdmail@nemesis.lonestar.org + +<27> Incorporated changes needed to move the cdevsw and bdevsw + entries into the drivers (including this one). Also + include a quick first pass cut at DEVFS suppport. + ---------------------------------------------------------------------------*/ /*Match this format: Version_dc(d)__dd-mmm-yy */ @@ -332,6 +337,7 @@ static char MATCDVERSION[]="Version 1(26) 18-Oct-95"; static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank Durda IV"; /* The proceeding strings may not be changed*/ +/* $Id:$ */ /*--------------------------------------------------------------------------- Include declarations @@ -356,9 +362,14 @@ static char MATCDCOPYRIGHT[] = "Matsushita CD-ROM driver, Copr. 1994,1995 Frank #ifdef FREE2 #include <sys/devconf.h> /*<16>*/ +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #else /*FREE2*/ -#include "i386/isa/isa.h" /*<16>*/ -#include "i386/isa/isa_device.h" /*<16>*/ +#include <i386/isa/isa.h> /*<16>*/ +#include <i386/isa/isa_device.h> /*<16>*/ #endif /*FREE2*/ /*--------------------------------------------------------------------------- @@ -433,6 +444,12 @@ static struct matcd_data { /*<18>*/ struct matcd_mbx mbx; u_char patch[2]; /*<12>Last known audio routing*/ u_char volume[2]; /*<12>Last known volume setting*/ +#ifdef DEVFS + void *ra_devfs_token; /* handle for devfs entry */ + void *rc_devfs_token; + void *a_devfs_token; + void *c_devfs_token; +#endif DEVFS } matcd_data[TOTALDRIVES]; @@ -491,15 +508,6 @@ static struct kern_devconf kdc_matcd[TOTALDRIVES] = { { /*<12>*/ "Matsushita CD-ROM Controller" /*<12>This is the description*/ } }; /*<12>*/ -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 46 -#define BDEV_MAJOR 17 -#endif /*JREMOD */ #endif /*FREE2*/ @@ -535,19 +543,48 @@ static struct kern_devconf kdc_matcd[TOTALDRIVES] = { { /*<12>*/ /*--------------------------------------------------------------------------- Entry points and other connections to/from kernel - see also conf.h + --- not any more :) ---------------------------------------------------------------------------*/ -extern int hz; extern int matcd_probe(struct isa_device *dev); extern int matcd_attach(struct isa_device *dev); struct isa_driver matcddriver={matcd_probe, matcd_attach, /*<16>*/ "matcdc"}; /*<20>*/ +#ifdef FREE2 + +static d_open_t matcdopen; +static d_close_t matcdclose; +static d_ioctl_t matcdioctl; +static d_dump_t matcddump; +static d_psize_t matcdsize; +static d_strategy_t matcdstrategy; + +#define CDEV_MAJOR 46 +#define BDEV_MAJOR 17 + +extern struct cdevsw matcd_cdevsw; +static struct bdevsw matcd_bdevsw = + { matcdopen, matcdclose, matcdstrategy, matcdioctl, /*17*/ + nxdump, matcdsize, 0, "matcd", + &matcd_cdevsw, -1 }; + +static struct cdevsw matcd_cdevsw = + { matcdopen, matcdclose, rawread, nowrite, /*46*/ + matcdioctl, nostop, nullreset, nodevtotty,/* SB cd */ + seltrue, nommap, matcdstrategy, "matcd", + &matcd_bdevsw, -1}; + +#else +extern int hz; +#endif /* FREE2 */ + /*--------------------------------------------------------------------------- Internal function declarations ---------------------------------------------------------------------------*/ +static void matcd_drvinit(void *unused); static void matcd_start(struct buf *dp); static void zero_cmd(char *); static void matcd_pread(int port, int count, unsigned char * data); @@ -1421,6 +1458,9 @@ int matcd_attach(struct isa_device *dev) unsigned char data[12]; struct matcd_data *cd; int port = dev->id_iobase; /*Take port ID selected in probe()*/ +#ifdef DEVFS + char name[32]; +#endif #ifdef DIAGPORT DIAGOUT(DIAGPORT,0x70); /*Show where we are*/ @@ -1471,6 +1511,29 @@ int matcd_attach(struct isa_device *dev) for (i=0; i<MAXPARTITIONS; i++) { cd->partflags[i]=0; } +#ifdef DEVFS +#define MATCD_UID 0 +#define MATCD_GID 13 + sprintf(name, "rmatcd%da",i); + cd->ra_devfs_token = devfs_add_devsw( + "/", name, &matcd_cdevsw, 0, + DV_CHR, MATCD_UID, MATCD_GID, 0600); + + sprintf(name, "rmatcd%dc",i); + cd->rc_devfs_token = devfs_add_devsw( + "/", name, &matcd_cdevsw, RAW_PART, + DV_CHR, MATCD_UID, MATCD_GID, 0600); + + sprintf(name, "matcd%da",i); + cd->a_devfs_token = devfs_add_devsw( + "/", name, &matcd_bdevsw, 0, + DV_BLK, MATCD_UID, MATCD_GID, 0600); + + sprintf(name, "matcd%dc",i); + cd->c_devfs_token = devfs_add_devsw( + "/", name, &matcd_bdevsw, RAW_PART, + DV_BLK, MATCD_UID, MATCD_GID, 0600); +#endif } } nextcontroller++; /*Bump ctlr assign to next number*/ @@ -2749,47 +2812,27 @@ static int matcd_igot(struct ioc_capability * sqp) audio are here*/ #endif /*FULLDRIVER*/ -#ifdef JREMOD -struct bdevsw matcd_bdevsw = - { matcdopen, matcdclose, matcdstrategy, matcdioctl, /*17*/ - nxdump, matcdsize, 0 }; - -struct cdevsw matcd_cdevsw = - { matcdopen, matcdclose, rawread, nowrite, /*46*/ - matcdioctl, nostop, nullreset, nodevtotty,/* SB cd */ - seltrue, nommap, matcdstrategy }; +#ifdef FREE2 static matcd_devsw_installed = 0; -static void matcd_drvinit(void *unused) +static void +matcd_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! matcd_devsw_installed ) { dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&matcd_cdevsw,NULL); - dev_chr = dev; dev = makedev(BDEV_MAJOR,0); bdevsw_add(&dev,&matcd_bdevsw,NULL); matcd_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "rmatcd", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - x=devfs_add_devsw( - "/", "matcd", major(dev), 0, DV_BLK, 0, 0, 0600); - } -#endif } } SYSINIT(matcddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,matcd_drvinit,NULL) -#endif /* JREMOD */ +#endif /* FREE2 */ /*End of matcd.c*/ diff --git a/sys/i386/isa/mcd.c b/sys/i386/isa/mcd.c index 5f7f68b..ee2e03a 100644 --- a/sys/i386/isa/mcd.c +++ b/sys/i386/isa/mcd.c @@ -40,7 +40,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: mcd.c,v 1.50 1995/11/29 10:47:44 julian Exp $ + * $Id: mcd.c,v 1.51 1995/11/29 14:39:46 julian Exp $ */ static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; @@ -61,6 +61,10 @@ static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; #include <sys/dkbad.h> #include <sys/disklabel.h> #include <sys/devconf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> @@ -70,15 +74,6 @@ static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; #include <i386/isa/isa_device.h> #include <i386/isa/mcdreg.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 29 -#define BDEV_MAJOR 7 -#endif /*JREMOD */ #define MCD_TRACE(format, args...) \ { \ @@ -164,6 +159,12 @@ struct mcd_data { short debug; struct buf head; /* head of buf queue */ struct mcd_mbx mbx; +#ifdef DEVFS + void *ra_devfs_token; /* store the devfs handle here */ + void *rc_devfs_token; /* store the devfs handle here */ + void *a_devfs_token; /* store the devfs handle here */ + void *c_devfs_token; /* store the devfs handle here */ +#endif } mcd_data[NMCD]; /* reader state machine */ @@ -208,11 +209,29 @@ static int mcd_resume(int unit); static int mcd_lock_door(int unit, int lock); static int mcd_close_tray(int unit); -extern int hz; static int mcd_probe(struct isa_device *dev); static int mcd_attach(struct isa_device *dev); struct isa_driver mcddriver = { mcd_probe, mcd_attach, "mcd" }; +static d_open_t mcdopen; +static d_close_t mcdclose; +static d_ioctl_t mcdioctl; +static d_psize_t mcdsize; +static d_strategy_t mcdstrategy; + +#define CDEV_MAJOR 29 +#define BDEV_MAJOR 7 +extern struct cdevsw mcd_cdevsw; +struct bdevsw mcd_bdevsw = + { mcdopen, mcdclose, mcdstrategy, mcdioctl, /*7*/ + nxdump, mcdsize, 0, "mcd", &mcd_cdevsw, -1 }; + +struct cdevsw mcd_cdevsw = + { mcdopen, mcdclose, rawread, nowrite, /*29*/ + mcdioctl, nostop, nullreset, nodevtotty, + seltrue, nommap, mcdstrategy, "mcd", + &mcd_bdevsw, -1 }; + #define mcd_put(port,byte) outb(port,byte) #define MCD_RETRYS 5 @@ -253,20 +272,44 @@ mcd_registerdev(struct isa_device *id) int mcd_attach(struct isa_device *dev) { - struct mcd_data *cd = mcd_data + dev->id_unit; + int unit = dev->id_unit; + struct mcd_data *cd = mcd_data + unit; + char name[32]; cd->iobase = dev->id_iobase; cd->flags |= MCDINIT; - mcd_soft_reset(dev->id_unit); + mcd_soft_reset(unit); #ifdef NOTYET /* wire controller for interrupts and dma */ mcd_configure(cd); #endif - kdc_mcd[dev->id_unit].kdc_state = DC_IDLE; + kdc_mcd[unit].kdc_state = DC_IDLE; /* name filled in probe */ - kdc_mcd[dev->id_unit].kdc_description = mcd_data[dev->id_unit].name; - + kdc_mcd[unit].kdc_description = mcd_data[unit].name; +#ifdef DEVFS +#define MCD_UID 0 +#define MCD_GID 13 + sprintf(name, "rmcd%da",unit); + cd->ra_devfs_token = devfs_add_devsw( + "/", name, &mcd_cdevsw, (unit * 8 ) + 0, + DV_CHR, MCD_UID, MCD_GID, 0600); + + sprintf(name, "rmcd%dc",unit); + cd->rc_devfs_token = devfs_add_devsw( + "/", name, &mcd_cdevsw, (unit * 8 ) + RAW_PART, + DV_CHR, MCD_UID, MCD_GID, 0600); + + sprintf(name, "mcd%da",unit); + cd->a_devfs_token = devfs_add_devsw( + "/", name, &mcd_bdevsw, (unit * 8 ) + 0, + DV_BLK, MCD_UID, MCD_GID, 0600); + + sprintf(name, "mcd%dc",unit); + cd->c_devfs_token = devfs_add_devsw( + "/", name, &mcd_bdevsw, (unit * 8 ) + RAW_PART, + DV_BLK, MCD_UID, MCD_GID, 0600); +#endif return 1; } @@ -1670,45 +1713,23 @@ mcd_resume(int unit) return mcd_play(unit, &cd->lastpb); } -#ifdef JREMOD -struct bdevsw mcd_bdevsw = - { mcdopen, mcdclose, mcdstrategy, mcdioctl, /*7*/ - nxdump, mcdsize, 0 }; - -struct cdevsw mcd_cdevsw = - { mcdopen, mcdclose, rawread, nowrite, /*29*/ - mcdioctl, nostop, nullreset, nodevtotty,/* mitsumi cd */ - seltrue, nommap, mcdstrategy }; static mcd_devsw_installed = 0; static void mcd_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! mcd_devsw_installed ) { dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&mcd_cdevsw,NULL); - dev_chr = dev; dev = makedev(BDEV_MAJOR,0); bdevsw_add(&dev,&mcd_bdevsw,NULL); mcd_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ -/* path name devsw minor type uid gid perm*/ - "/", "rmcd", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - x=devfs_add_devsw( - "/", "mcd", major(dev), 0, DV_BLK, 0, 0, 0600); - } -#endif } } SYSINIT(mcddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,mcd_drvinit,NULL) -#endif /* JREMOD */ #endif /* NMCD > 0 */ diff --git a/sys/i386/isa/mse.c b/sys/i386/isa/mse.c index 8e9fa7b..96f62e5 100644 --- a/sys/i386/isa/mse.c +++ b/sys/i386/isa/mse.c @@ -11,7 +11,7 @@ * this software for any purpose. It is provided "as is" * without express or implied warranty. * - * $Id: mse.c,v 1.18 1995/11/29 14:39:47 julian Exp $ + * $Id: mse.c,v 1.19 1995/12/06 23:42:53 bde Exp $ */ /* * Driver for the Logitech and ATI Inport Bus mice for use with 386bsd and @@ -55,20 +55,16 @@ #include <sys/ioctl.h> #include <sys/uio.h> #include <sys/devconf.h> +#include <sys/conf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> #include <i386/isa/isa_device.h> #include <i386/isa/icu.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 27 -#endif /*JREMOD*/ static int mseprobe(struct isa_device *); static int mseattach(struct isa_device *); @@ -77,6 +73,18 @@ struct isa_driver msedriver = { mseprobe, mseattach, "mse" }; +static d_open_t mseopen; +static d_close_t mseclose; +static d_read_t mseread; +static d_select_t mseselect; + +#define CDEV_MAJOR 27 +struct cdevsw mse_cdevsw = + { mseopen, mseclose, mseread, nowrite, /*27*/ + noioc, nostop, nullreset, nodevtotty,/* mse */ + mseselect, nommap, NULL, "mse", NULL, -1 }; + + /* * Software control structure for mouse. The sc_enablemouse(), * sc_disablemouse() and sc_getmouse() routines must be called spl'd(). @@ -96,6 +104,10 @@ struct mse_softc { int sc_buttons; int sc_bytesread; u_char sc_bytes[PROTOBYTES]; +#ifdef DEVFS + void *devfs_token; + void *n_devfs_token; +#endif } mse_sc[NMSE]; /* Flags */ @@ -238,17 +250,31 @@ int mseattach(idp) struct isa_device *idp; { - struct mse_softc *sc = &mse_sc[idp->id_unit]; + char name[32]; + int unit = idp->id_unit; + struct mse_softc *sc = &mse_sc[unit]; sc->sc_port = idp->id_iobase; - kdc_mse[idp->id_unit].kdc_state = DC_IDLE; + kdc_mse[unit].kdc_state = DC_IDLE; +#ifdef DEVFS + sprintf(name,"mse%d", unit); + /* path name devsw minor */ + sc->devfs_token = devfs_add_devsw( "/", name, &mse_cdevsw, unit << 1, + /*type uid gid perm*/ + DV_CHR, 0, 0, 0600); + sprintf(name,"nmse%d", unit); + /* path name devsw minor */ + sc->n_devfs_token = devfs_add_devsw("/", name, &mse_cdevsw, (unit<<1)+1, + /*type uid gid perm*/ + DV_CHR, 0, 0, 0600); +#endif return (1); } /* * Exclusive open the mouse, initialize it and enable interrupts. */ -int +static int mseopen(dev, flags, fmt, p) dev_t dev; int flags; @@ -281,7 +307,7 @@ mseopen(dev, flags, fmt, p) /* * mseclose: just turn off mouse innterrupts. */ -int +static int mseclose(dev, flags, fmt, p) dev_t dev; int flags; @@ -304,7 +330,7 @@ mseclose(dev, flags, fmt, p) * using bytes 4 and 5. * (Yes this is cheesy, but it makes the X386 server happy, so...) */ -int +static int mseread(dev, uio, ioflag) dev_t dev; struct uio *uio; @@ -366,7 +392,7 @@ mseread(dev, uio, ioflag) /* * mseselect: check for mouse input to be processed. */ -int +static int mseselect(dev, rw, p) dev_t dev; int rw; @@ -575,12 +601,6 @@ mse_getati(port, dx, dy, but) outb(port + MSE_PORTB, MSE_INPORT_INTREN); } -#ifdef JREMOD -struct cdevsw mse_cdevsw = - { mseopen, mseclose, mseread, nowrite, /*27*/ - noioc, nostop, nullreset, nodevtotty,/* mse */ - mseselect, nommap, NULL }; - static mse_devsw_installed = 0; static void mse_drvinit(void *unused) @@ -588,23 +608,13 @@ static void mse_drvinit(void *unused) dev_t dev; if( ! mse_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&mse_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&mse_cdevsw, NULL); mse_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "mse", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(msedev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,mse_drvinit,NULL) -#endif /* JREMOD */ #endif /* NMSE */ diff --git a/sys/i386/isa/pcaudio.c b/sys/i386/isa/pcaudio.c index 7a285ea1..d0bb085 100644 --- a/sys/i386/isa/pcaudio.c +++ b/sys/i386/isa/pcaudio.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: pcaudio.c,v 1.20 1995/11/30 05:58:53 julian Exp $ + * $Id: pcaudio.c,v 1.21 1995/12/01 23:09:20 julian Exp $ */ #include "pca.h" @@ -39,6 +39,7 @@ #include <sys/file.h> #include <sys/proc.h> #include <sys/devconf.h> +#include <sys/kernel.h> #include <machine/clock.h> #include <machine/pcaudioio.h> @@ -52,11 +53,6 @@ #ifdef DEVFS #include <sys/devfsext.h> #endif /* DEVFS */ -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#endif /* JREMOD */ -#define CDEV_MAJOR 24 #define BUF_SIZE 8192 #define SAMPLE_RATE 8000 @@ -85,6 +81,8 @@ static char buffer1[BUF_SIZE]; static char buffer2[BUF_SIZE]; static char volume_table[256]; +static void *pca_devfs_token; +static void *pcac_devfs_token; static int pca_sleep = 0; static int pca_initialized = 0; @@ -96,6 +94,18 @@ struct isa_driver pcadriver = { pcaprobe, pcaattach, "pca", }; +static d_open_t pcaopen; +static d_close_t pcaclose; +static d_write_t pcawrite; +static d_ioctl_t pcaioctl; +static d_select_t pcaselect; + +#define CDEV_MAJOR 24 +struct cdevsw pca_cdevsw = + { pcaopen, pcaclose, noread, pcawrite, /*24*/ + pcaioctl, nostop, nullreset, nodevtotty,/* pcaudio */ + pcaselect, nommap, NULL, "pca", NULL, -1 }; + inline void conv(const void *table, void *buff, unsigned long n) { @@ -250,17 +260,6 @@ pca_registerdev(struct isa_device *id) dev_attach(&kdc_pca[id->id_unit]); } -#ifdef DEVFS - -void pcadevfs_init(caddr_t data) /* data not used */ -{ - void * x; -/* path name devsw minor type uid gid perm*/ - x=devfs_add_devsw("/", "pcaudio", CDEV_MAJOR, 0, DV_CHR, 0, 0, 0666); - x=devfs_add_devsw("/", "pcaudioctl", CDEV_MAJOR, 128, DV_CHR, 0, 0, 0666); -} -#endif /*DEVFS*/ - int pcaattach(struct isa_device *dvp) @@ -269,14 +268,18 @@ pcaattach(struct isa_device *dvp) pca_init(); pca_registerdev(dvp); #ifdef DEVFS - pcadevfs_init(NULL); +/* path name devsw minor type uid gid perm*/ + pca_devfs_token = devfs_add_devsw("/", "pcaudio", &pca_cdevsw, 0, + DV_CHR, 0, 0, 0666); + pcac_devfs_token = devfs_add_devsw("/", "pcaudioctl", &pca_cdevsw, 128, + DV_CHR, 0, 0, 0666); #endif /*DEVFS*/ return 1; } -int +static int pcaopen(dev_t dev, int flags, int fmt, struct proc *p) { /* audioctl device can always be opened */ @@ -304,7 +307,7 @@ pcaopen(dev_t dev, int flags, int fmt, struct proc *p) } -int +static int pcaclose(dev_t dev, int flags, int fmt, struct proc *p) { /* audioctl device can always be closed */ @@ -320,7 +323,7 @@ pcaclose(dev_t dev, int flags, int fmt, struct proc *p) } -int +static int pcawrite(dev_t dev, struct uio *uio, int flag) { int count, error, which; @@ -364,7 +367,7 @@ pcawrite(dev_t dev, struct uio *uio, int flag) } -int +static int pcaioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { audio_info_t *auptr; @@ -487,12 +490,6 @@ pcaselect(dev_t dev, int rw, struct proc *p) } } -#ifdef JREMOD -struct cdevsw pca_cdevsw = - { pcaopen, pcaclose, noread, pcawrite, /*24*/ - pcaioctl, nostop, nullreset, nodevtotty,/* pcaudio */ - pcaselect, nommap, NULL }; - static pca_devsw_installed = 0; static void pca_drvinit(void *unused) @@ -500,14 +497,13 @@ static void pca_drvinit(void *unused) dev_t dev; if( ! pca_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&pca_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&pca_cdevsw, NULL); pca_devsw_installed = 1; } } SYSINIT(pcadev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,pca_drvinit,NULL) -#endif /* JREMOD */ #endif diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 4060aaa..dca8922 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -118,7 +118,7 @@ static d_mmap_t pcmmap; static struct cdevsw pcdevsw = { pcopen, pcclose, pcread, pcwrite, pcioctl, nullstop, noreset, pcdevtotty, - ttselect, pcmmap, nostrategy, + ttselect, pcmmap, nostrategy, "vt", NULL, -1 }; #if PCVT_NETBSD > 100 /* NetBSD-current Feb 20 1995 */ diff --git a/sys/i386/isa/psm.c b/sys/i386/isa/psm.c index 0ab8355..010f9db 100644 --- a/sys/i386/isa/psm.c +++ b/sys/i386/isa/psm.c @@ -58,6 +58,10 @@ #include <sys/file.h> #include <sys/proc.h> #include <sys/vnode.h> +#include <sys/conf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #if 0 #include <sys/syslog.h> /* For debugging */ #endif @@ -66,14 +70,6 @@ #include <i386/isa/isa_device.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 21 -#endif /*JREMOD*/ #define DATA 0 /* Offset for data port, read-write */ #define CNTRL 4 /* Offset for control port, write-only */ @@ -125,6 +121,10 @@ static struct psm_softc { /* Driver status information */ unsigned char status; /* Mouse button status */ unsigned char button; /* Previous mouse button status bits */ int x, y; /* accumulated motion in the X,Y axis */ +#ifdef DEVFS + void *devfs_token; + void *n_devfs_token; +#endif } psm_softc[NPSM]; #define OPEN 1 /* Device is open */ @@ -132,6 +132,18 @@ static struct psm_softc { /* Driver status information */ struct isa_driver psmdriver = { psmprobe, psmattach, "psm" }; +static d_open_t psmopen; +static d_close_t psmclose; +static d_read_t psmread; +static d_ioctl_t psmioctl; +static d_select_t psmselect; + +#define CDEV_MAJOR 21 +static struct cdevsw psm_cdevsw = + { psmopen, psmclose, psmread, nowrite, /*21*/ + psmioctl, nostop, nullreset, nodevtotty, + psmselect, nommap, NULL, "psm", NULL, -1 }; + #define AUX_PORT 0x60 /* AUX_PORT base (S.Yuen) */ static void psm_write_dev(int inport, u_char value) @@ -212,11 +224,13 @@ int psmattach(struct isa_device *dvp) return(0); /* XXX eh? usually 1 indicates success */ } -int psmopen(dev_t dev, int flag, int fmt, struct proc *p) +static int +psmopen(dev_t dev, int flag, int fmt, struct proc *p) { int unit = PSMUNIT(dev); struct psm_softc *sc; int ioport; + char name[32]; /* Validate unit number */ @@ -254,11 +268,24 @@ int psmopen(dev_t dev, int flag, int fmt, struct proc *p) /* Enable Bus Mouse interrupts */ psm_write_dev(ioport, PSM_DEV_ENABLE); + psm_poll_status(); outb(ioport+CNTRL, PSM_ENABLE); psm_command(ioport, PSM_INT_ENABLE); /* Successful open */ +#ifdef DEVFS + sprintf(name,"psm%d", unit); + /* path name devsw minor */ + sc->devfs_token = devfs_add_devsw( "/", name, &psm_cdevsw, unit << 1, + /*type uid gid perm*/ + DV_CHR, 0, 0, 0666); + sprintf(name,"npsm%d", unit); + /* path name devsw minor */ + sc->n_devfs_token = devfs_add_devsw("/", name, &psm_cdevsw, (unit<<1)+1, + /*type uid gid perm*/ + DV_CHR, 0, 0, 0666); +#endif return(0); } @@ -273,7 +300,8 @@ void psm_poll_status(void) } -int psmclose(dev_t dev, int flag, int fmt, struct proc *p) +static int +psmclose(dev_t dev, int flag, int fmt, struct proc *p) { int unit, ioport; struct psm_softc *sc; @@ -299,7 +327,8 @@ int psmclose(dev_t dev, int flag, int fmt, struct proc *p) return(0); } -int psmread(dev_t dev, struct uio *uio, int flag) +static int +psmread(dev_t dev, struct uio *uio, int flag) { int s; int error = 0; /* keep compiler quiet, even though initialisation @@ -364,7 +393,8 @@ int psmread(dev_t dev, struct uio *uio, int flag) return(error); } -int psmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) +static int +psmioctl(dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p) { struct psm_softc *sc; struct mouseinfo info; @@ -443,7 +473,8 @@ void psmintr(unit) selwakeup(&sc->rsel); } -int psmselect(dev_t dev, int rw, struct proc *p) +static int +psmselect(dev_t dev, int rw, struct proc *p) { int s, ret; struct psm_softc *sc = &psm_softc[PSMUNIT(dev)]; @@ -467,11 +498,6 @@ int psmselect(dev_t dev, int rw, struct proc *p) return(ret); } -#ifdef JREMOD -struct cdevsw psm_cdevsw = - { psmopen, psmclose, psmread, nowrite, /*21*/ - psmioctl, nostop, nullreset, nodevtotty,/* psm mice */ - psmselect, nommap, NULL }; static psm_devsw_installed = 0; @@ -480,24 +506,14 @@ static void psm_drvinit(void *unused) dev_t dev; if( ! psm_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&psm_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&psm_cdevsw, NULL); psm_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "psm", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(psmdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,psm_drvinit,NULL) -#endif /* JREMOD */ #endif diff --git a/sys/i386/isa/rc.c b/sys/i386/isa/rc.c index e4e3325..83db4c6 100644 --- a/sys/i386/isa/rc.c +++ b/sys/i386/isa/rc.c @@ -47,6 +47,9 @@ #include <sys/kernel.h> #include <sys/syslog.h> #include <sys/devconf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> @@ -57,14 +60,6 @@ #include <i386/isa/ic/cd180.h> #include <i386/isa/rcreg.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 63 -#endif /*JREMOD*/ /* Prototypes */ int rcprobe __P((struct isa_device *)); @@ -105,6 +100,20 @@ struct isa_driver rcdriver = { rcprobe, rcattach, "rc" }; +static d_open_t rcopen; +static d_close_t rcclose; +static d_read_t rcread; +static d_write_t rcwrite; +static d_ioctl_t rcioctl; +static d_stop_t rcstop; +static d_ttycv_t rcdevtotty; + +#define CDEV_MAJOR 63 +struct cdevsw rc_cdevsw = + { rcopen, rcclose, rcread, rcwrite, /*63*/ + rcioctl, rcstop, nxreset, rcdevtotty,/* rc */ + ttselect, nommap, NULL, "rc", NULL, -1 }; + /* Per-board structure */ static struct rc_softc { u_int rcb_probed; /* 1 - probed, 2 - attached */ @@ -134,6 +143,9 @@ static struct rc_chans { u_char *rc_obufend; /* end of output buf */ u_char rc_ibuf[4 * RC_IBUFSIZE]; /* input buffer */ u_char rc_obuf[RC_OBUFSIZE]; /* output buffer */ +#ifdef DEVFS + void *devfs_token; +#endif } rc_chans[NRC * CD180_NCHAN]; static int rc_scheduled_event = 0; @@ -249,6 +261,7 @@ int rcattach(dvp) struct rc_chans *rc = &rc_chans[dvp->id_unit * CD180_NCHAN]; static int rc_wakeup_started = 0; struct tty *tp; + char name[32]; /* Thorooughly test the device */ if (rcb->rcb_probed != RC_PROBED) @@ -279,6 +292,13 @@ int rcattach(dvp) tp->t_lflag = tp->t_iflag = tp->t_oflag = 0; tp->t_cflag = TTYDEF_CFLAG; tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; +#ifdef DEVFS +/* FIX THIS to reflect real devices */ + sprintf(name,"rc%d.%d",dvp->id_unit,chan); + rc->devfs_token = devfs_add_devsw( "/", name, + &rc_cdevsw,(dvp->id_unit * CD180_NCHAN) + chan , + DV_CHR, 0, 0, 0600); +#endif } rcb->rcb_probed = RC_ATTACHED; if (!rc_wakeup_started) { @@ -693,7 +713,8 @@ done1: goto repeat; } -void rcstop(tp, rw) +static void +rcstop(tp, rw) register struct tty *tp; int rw; { @@ -726,7 +747,8 @@ void rcstop(tp, rw) enable_intr(); } -int rcopen(dev, flag, mode, p) +static int +rcopen(dev, flag, mode, p) dev_t dev; int flag, mode; struct proc *p; @@ -817,7 +839,8 @@ out: return error; } -int rcclose(dev, flag, mode, p) +static int +rcclose(dev, flag, mode, p) dev_t dev; int flag, mode; struct proc *p; @@ -874,7 +897,8 @@ register struct rc_chans *rc; } /* Read from line */ -int rcread(dev, uio, flag) +static int +rcread(dev, uio, flag) dev_t dev; struct uio *uio; int flag; @@ -885,7 +909,8 @@ int rcread(dev, uio, flag) } /* Write to line */ -int rcwrite(dev, uio, flag) +static int +rcwrite(dev, uio, flag) dev_t dev; struct uio *uio; int flag; @@ -1091,7 +1116,8 @@ struct rc_softc *rcb; (void) rc_param(rc->rc_tp, &rc->rc_tp->t_termios); } -int rcioctl(dev, cmd, data, flag, p) +static int +rcioctl(dev, cmd, data, flag, p) dev_t dev; int cmd, flag; caddr_t data; @@ -1409,7 +1435,7 @@ char *comment; } #endif /* RCDEBUG */ -struct tty * +static struct tty * rcdevtotty(dev) dev_t dev; { @@ -1501,12 +1527,6 @@ rc_wait0(nec, unit, chan, line) unit, chan, line); } -#ifdef JREMOD -struct cdevsw rc_cdevsw = - { rcopen, rcclose, rcread, rcwrite, /*63*/ - rcioctl, rcstop, nxreset, rcdevtotty,/* rc */ - ttselect, nommap, NULL }; - static rc_devsw_installed = 0; static void rc_drvinit(void *unused) @@ -1514,23 +1534,13 @@ static void rc_drvinit(void *unused) dev_t dev; if( ! rc_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&rc_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&rc_cdevsw, NULL); rc_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "rc", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(rcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,rc_drvinit,NULL) -#endif /* JREMOD */ #endif /* NRC */ diff --git a/sys/i386/isa/scd.c b/sys/i386/isa/scd.c index edffabf..a111bba 100644 --- a/sys/i386/isa/scd.c +++ b/sys/i386/isa/scd.c @@ -41,7 +41,7 @@ */ -/* $Id: scd.c,v 1.11 1995/11/29 10:47:50 julian Exp $ */ +/* $Id: scd.c,v 1.12 1995/11/29 14:39:53 julian Exp $ */ /* Please send any comments to micke@dynas.se */ @@ -64,6 +64,10 @@ #include <sys/dkbad.h> #include <sys/disklabel.h> #include <sys/devconf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> #include <machine/stdarg.h> @@ -72,14 +76,6 @@ #include <i386/isa/isa_device.h> #include <i386/isa/scdreg.h> -#ifdef JREMOD -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 45 -#define BDEV_MAJOR 16 -#endif /*JREMOD */ #define scd_part(dev) ((minor(dev)) & 7) #define scd_unit(dev) (((minor(dev)) & 0x38) >> 3) @@ -148,6 +144,12 @@ static struct scd_data { short audio_status; struct buf head; /* head of buf queue */ struct scd_mbx mbx; +#ifdef DEVFS + void *ra_devfs_token; + void *rc_devfs_token; + void *a_devfs_token; + void *c_devfs_token; +#endif } scd_data[NSCD]; /* prototypes */ @@ -184,12 +186,30 @@ static int scd_toc_header(int unit, struct ioc_toc_header *th); static int scd_toc_entrys(int unit, struct ioc_read_toc_entry *te); #define SCD_LASTPLUS1 170 /* don't ask, xcdplayer passes this in */ -extern int hz; - static int scd_probe(struct isa_device *dev); static int scd_attach(struct isa_device *dev); struct isa_driver scddriver = { scd_probe, scd_attach, "scd" }; +static d_open_t scdopen; +static d_close_t scdclose; +static d_ioctl_t scdioctl; +static d_psize_t scdsize; +static d_strategy_t scdstrategy; + +#define CDEV_MAJOR 45 +#define BDEV_MAJOR 16 +extern struct cdevsw scd_cdevsw; +struct bdevsw scd_bdevsw = + { scdopen, scdclose, scdstrategy, scdioctl, /*16*/ + nxdump, scdsize, 0, "scd", &scd_cdevsw, -1 }; + +struct cdevsw scd_cdevsw = + { scdopen, scdclose, rawread, nowrite, /*45*/ + scdioctl, nostop, nullreset, nodevtotty,/* sony cd */ + seltrue, nommap, scdstrategy, "scd", + &scd_bdevsw, -1 }; + + static struct kern_devconf kdc_scd[NSCD] = { { 0, 0, 0, /* filled in by dev_attach */ "scd", 0, { MDDT_ISA, 0, "bio" }, @@ -213,7 +233,9 @@ scd_registerdev(struct isa_device *id) int scd_attach(struct isa_device *dev) { - struct scd_data *cd = scd_data + dev->id_unit; + int unit = dev->id_unit; + struct scd_data *cd = scd_data + unit; + char name[32]; cd->iobase = dev->id_iobase; /* Already set by probe, but ... */ @@ -227,10 +249,33 @@ int scd_attach(struct isa_device *dev) cd->flags = SCDINIT; cd->audio_status = CD_AS_AUDIO_INVALID; +#ifdef DEVFS +#define SCD_UID 0 +#define SCD_GID 13 + sprintf(name, "rscd%da",unit); + cd->ra_devfs_token = devfs_add_devsw( + "/", name, &scd_cdevsw, (unit * 8 ) + 0, + DV_CHR, SCD_UID, SCD_GID, 0600); + + sprintf(name, "rscd%dc",unit); + cd->rc_devfs_token = devfs_add_devsw( + "/", name, &scd_cdevsw, (unit * 8 ) + RAW_PART, + DV_CHR, SCD_UID, SCD_GID, 0600); + + sprintf(name, "scd%da",unit); + cd->a_devfs_token = devfs_add_devsw( + "/", name, &scd_bdevsw, (unit * 8 ) + 0, + DV_BLK, SCD_UID, SCD_GID, 0600); + + sprintf(name, "scd%dc",unit); + cd->c_devfs_token = devfs_add_devsw( + "/", name, &scd_bdevsw, (unit * 8 ) + RAW_PART, + DV_BLK, SCD_UID, SCD_GID, 0600); +#endif return 1; } -int +static int scdopen(dev_t dev, int flags, int fmt, struct proc *p) { int unit,part,phys; @@ -283,7 +328,7 @@ scdopen(dev_t dev, int flags, int fmt, struct proc *p) return 0; } -int +static int scdclose(dev_t dev, int flags, int fmt, struct proc *p) { int unit,part,phys; @@ -313,7 +358,7 @@ scdclose(dev_t dev, int flags, int fmt, struct proc *p) return 0; } -void +static void scdstrategy(struct buf *bp) { struct scd_data *cd; @@ -416,7 +461,7 @@ scd_start(int unit) return; } -int +static int scdioctl(dev_t dev, int cmd, caddr_t addr, int flags, struct proc *p) { struct scd_data *cd; @@ -492,7 +537,7 @@ scdioctl(dev_t dev, int cmd, caddr_t addr, int flags, struct proc *p) } } -int +static int scdsize(dev_t dev) { return -1; @@ -1529,46 +1574,22 @@ scd_toc_entrys (int unit, struct ioc_read_toc_entry *te) } -#ifdef JREMOD -struct bdevsw scd_bdevsw = - { scdopen, scdclose, scdstrategy, scdioctl, /*16*/ - nxdump, scdsize, 0 }; - -struct cdevsw scd_cdevsw = - { scdopen, scdclose, rawread, nowrite, /*45*/ - scdioctl, nostop, nullreset, nodevtotty,/* sony cd */ - seltrue, nommap, scdstrategy }; - static scd_devsw_installed = 0; static void scd_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! scd_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&scd_cdevsw,NULL); - dev_chr = dev; - dev = makedev(BDEV_MAJOR,0); - bdevsw_add(&dev,&scd_bdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&scd_cdevsw, NULL); + dev = makedev(BDEV_MAJOR, 0); + bdevsw_add(&dev,&scd_bdevsw, NULL); scd_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "rscd", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - x=devfs_add_devsw( - "/", "scd", major(dev), 0, DV_BLK, 0, 0, 0600); - } -#endif } } SYSINIT(scddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,scd_drvinit,NULL) -#endif /* JREMOD */ #endif /* NSCD > 0 */ diff --git a/sys/i386/isa/si.c b/sys/i386/isa/si.c index 1b732d9..cc1d6a7 100644 --- a/sys/i386/isa/si.c +++ b/sys/i386/isa/si.c @@ -30,7 +30,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHORS BE LIABLE. * - * $Id: si.c,v 1.21 1995/12/06 23:50:27 bde Exp $ + * $Id: si.c,v 1.22 1995/12/07 12:46:06 davidg Exp $ */ #ifndef lint @@ -53,6 +53,9 @@ static char si_copyright1[] = "@(#) (C) Specialix International, 1990,1992", #include <sys/syslog.h> #include <sys/malloc.h> #include <sys/devconf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> @@ -84,12 +87,8 @@ static char si_copyright1[] = "@(#) (C) Specialix International, 1990,1992", enum si_mctl { GET, SET, BIS, BIC }; -#ifdef JREMOD -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 68 -#endif /*JREMOD*/ +static const char devchar[] = "ABCDEFGHIJK"; +static const char portchar[] = "0123456789abcdefghijklmnopqrstuvwxyz"; static void si_command __P((struct si_port *, int, int)); @@ -110,6 +109,25 @@ extern int siprobe __P((struct isa_device *id)); extern int siattach __P((struct isa_device *id)); static void si_modem_state __P((struct si_port *pp, struct tty *tp, int hi_ip)); +struct isa_driver sidriver = + { siprobe, siattach, "si" }; + + +static d_open_t siopen; +static d_close_t siclose; +static d_read_t siread; +static d_write_t siwrite; +static d_ioctl_t siioctl; +static d_stop_t sistop; +static d_ttycv_t sidevtotty; + +#define CDEV_MAJOR 68 +struct cdevsw si_cdevsw = + { siopen, siclose, siread, siwrite, /*68*/ + siioctl, sistop, nxreset, sidevtotty,/* si */ + ttselect, nxmmap, NULL, "si", NULL, -1 }; + + #ifdef SI_DEBUG /* use: ``options "SI_DEBUG"'' in your config file */ /* XXX: should be varargs, I know.. but where's vprintf()? */ static void si_dprintf __P((/* struct si_port *pp, int flags, char *str, int a1, int a2, int a3, int a4, int a5, int a6 */)); @@ -142,6 +160,16 @@ struct si_softc { int sc_eisa_iobase; /* EISA io port address */ int sc_eisa_irqbits; struct kern_devconf sc_kdc; +#ifdef DEVFS + struct { + void *ttyd; + void *ttyl; + void *ttyi; + void *cuaa; + void *cual; + void *cuai; + } devfs_token[32]; /* what is the max per card? */ +#endif }; struct si_softc si_softc[NSI]; /* up to 4 elements */ @@ -460,6 +488,7 @@ siattach(id) struct speedtab *spt; int nmodule, nport, x, y; int uart_type; + char name[32]; DPRINT((0, DBG_AUTOBOOT, "si%d: siattach\n", id->id_unit)); @@ -663,14 +692,39 @@ mem_fail: done_chartimes = 1; } +#ifdef DEVFS +/* path name devsw minor type uid gid perm*/ + for ( x = 0; x < nport; x++ ) { + sprintf(name,"tty%c%c",devchar[unit],portchar[x + 1]); + sc->devfs_token[x].ttyd = devfs_add_devsw( + "/", name, &si_cdevsw, unit, + DV_CHR, 0, 0, 0600); + sprintf(name,"ttyi%c%c",devchar[unit],portchar[x + 1]); + sc->devfs_token[x].ttyi = devfs_add_devsw( + "/", name, &si_cdevsw, unit + 32, + DV_CHR, 0, 0, 0600); + sprintf(name,"ttyl%c%c",devchar[unit],portchar[x + 1]); + sc->devfs_token[x].ttyl = devfs_add_devsw( + "/", name, &si_cdevsw, unit + 64, + DV_CHR, 0, 0, 0600); + sprintf(name,"cua%c%c",devchar[unit],portchar[x + 1]); + sc->devfs_token[x].cuaa = devfs_add_devsw( + "/", name, &si_cdevsw, unit + 128, + DV_CHR, 0, 0, 0600); + sprintf(name,"cuai%c%c",devchar[unit],portchar[x + 1]); + sc->devfs_token[x].cuai = devfs_add_devsw( + "/", name, &si_cdevsw, unit + 160, + DV_CHR, 0, 0, 0600); + sprintf(name,"cual%c%c",devchar[unit],portchar[x + 1]); + sc->devfs_token[x].cual = devfs_add_devsw( + "/", name, &si_cdevsw, unit + 192, + DV_CHR, 0, 0, 0600); + } +#endif return (1); } -struct isa_driver sidriver = - { siprobe, siattach, "si" }; - - -int +static int siopen(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -841,7 +895,7 @@ out: return(error); } -int +static int siclose(dev, flag, mode, p) dev_t dev; int flag, mode; @@ -961,7 +1015,7 @@ sidtrwakeup(chan) /* * User level stuff - read and write */ -int +static int siread(dev, uio, flag) register dev_t dev; struct uio *uio; @@ -981,7 +1035,7 @@ siread(dev, uio, flag) } -int +static int siwrite(dev, uio, flag) dev_t dev; struct uio *uio; @@ -1020,7 +1074,7 @@ out: } -struct tty * +static struct tty * sidevtotty(dev_t dev) { struct si_port *pp; @@ -1035,7 +1089,7 @@ sidevtotty(dev_t dev) return (pp->sp_tty); } -int +static int siioctl(dev, cmd, data, flag, p) dev_t dev; int cmd; @@ -2305,40 +2359,19 @@ si_mctl2str(cmd) #endif /* DEBUG */ -#ifdef JREMOD -struct cdevsw si_cdevsw = - { siopen, siclose, siread, siwrite, /*68*/ - siioctl, sistop, nxreset, sidevtotty,/* si */ - ttselect, nxmmap, NULL }; static si_devsw_installed = 0; static void si_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! si_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&si_cdevsw,NULL); - dev_chr = dev; -#if defined(BDEV_MAJOR) - dev = makedev(BDEV_MAJOR,0); - bdevsw_add(&dev,&si_bdevsw,NULL); -#endif /*BDEV_MAJOR*/ + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&si_cdevsw, NULL); si_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "si", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(sidev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,si_drvinit,NULL) -#endif /* JREMOD */ diff --git a/sys/i386/isa/sio.c b/sys/i386/isa/sio.c index b6b090f..d44d7bc 100644 --- a/sys/i386/isa/sio.c +++ b/sys/i386/isa/sio.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)com.c 7.5 (Berkeley) 5/16/91 - * $Id: sio.c,v 1.123 1995/11/29 15:00:07 bde Exp $ + * $Id: sio.c,v 1.124 1995/12/06 23:43:07 bde Exp $ */ #include "sio.h" @@ -59,6 +59,9 @@ #include <sys/malloc.h> #include <sys/syslog.h> #include <sys/devconf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/clock.h> @@ -95,12 +98,6 @@ #define com_scr 7 /* scratch register for 16450-16550 (R/W) */ -#ifdef JREMOD -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 28 -#endif /*JREMOD*/ #include "crd.h" @@ -251,6 +248,14 @@ struct com_s { */ u_char obuf1[256]; u_char obuf2[256]; +#ifdef DEVFS + void *devfs_token_ttyd; + void *devfs_token_ttyl; + void *devfs_token_ttyi; + void *devfs_token_cuaa; + void *devfs_token_cual; + void *devfs_token_cuai; +#endif }; /* @@ -285,6 +290,8 @@ static void disc_optim __P((struct tty *tp, struct termios *t, static int LoadSoftModem __P((int unit,int base_io, u_long size, u_char *ptr)); #endif /* DSI_SOFT_MODEM */ +static char driver_name[] = "sio"; + /* table and macro for fast conversion from a unit number to its com struct */ static struct com_s *p_com_addr[NSIO]; #define com_addr(unit) (p_com_addr[unit]) @@ -292,9 +299,24 @@ static struct com_s *p_com_addr[NSIO]; static struct timeval intr_timestamp; struct isa_driver siodriver = { - sioprobe, sioattach, "sio" + sioprobe, sioattach, driver_name }; +static d_open_t sioopen; +static d_close_t sioclose; +static d_read_t sioread; +static d_write_t siowrite; +static d_ioctl_t sioioctl; +static d_stop_t siostop; +static d_ttycv_t siodevtotty; + +#define CDEV_MAJOR 28 +struct cdevsw sio_cdevsw = + { sioopen, sioclose, sioread, siowrite, /*28*/ + sioioctl, siostop, nxreset, siodevtotty,/* sio */ + ttselect, nommap, NULL, driver_name, NULL, -1 }; + + static int comconsole = -1; static speed_t comdefaultrate = TTYDEF_SPEED; static u_int com_events; /* input chars + weighted output completions */ @@ -338,9 +360,10 @@ static struct speedtab comspeedtab[] = { { -1, -1 } }; +static char chardev[] = "0123456789abcdefghijklmnopqrstuvwxyz"; static struct kern_devconf kdc_sio[NSIO] = { { 0, 0, 0, /* filled in by dev_attach */ - "sio", 0, { MDDT_ISA, 0, "tty" }, + driver_name, 0, { MDDT_ISA, 0, "tty" }, isa_generic_externalize, 0, 0, ISA_EXTERNALLEN, &kdc_isa0, /* parent */ 0, /* parentdata */ @@ -359,7 +382,7 @@ static int sioinit(struct pccard_dev *, int); /* init device */ static struct pccard_drv sio_info = { - "sio", + driver_name, card_intr, siounload, siosuspend, @@ -696,6 +719,7 @@ sioattach(isdp) Port_t iobase; int s; int unit; + char name[32]; isdp->id_ri_flags |= RI_FAST; iobase = isdp->id_iobase; @@ -880,10 +904,37 @@ determined_type: ; com_addr(unit) = com; splx(s); +#ifdef DEVFS +/* path name devsw minor type uid gid perm*/ + sprintf(name,"ttyd%c",chardev[unit]); + com->devfs_token_ttyd = devfs_add_devsw( + "/", name, &sio_cdevsw, unit, + DV_CHR, 0, 0, 0600); + sprintf(name,"ttyid%c",chardev[unit]); + com->devfs_token_ttyi = devfs_add_devsw( + "/", name, &sio_cdevsw, unit+32, + DV_CHR, 0, 0, 0600); + sprintf(name,"ttyld%c",chardev[unit]); + com->devfs_token_ttyl = devfs_add_devsw( + "/", name, &sio_cdevsw, unit+64, + DV_CHR, 0, 0, 0600); + sprintf(name,"cuaa%c",chardev[unit]); + com->devfs_token_cuaa = devfs_add_devsw( + "/", name, &sio_cdevsw, unit+128, + DV_CHR, 0, 0, 0600); + sprintf(name,"cuaia%c",chardev[unit]); + com->devfs_token_cuai = devfs_add_devsw( + "/", name, &sio_cdevsw, unit+160, + DV_CHR, 0, 0, 0600); + sprintf(name,"cuala%c",chardev[unit]); + com->devfs_token_cual = devfs_add_devsw( + "/", name, &sio_cdevsw, unit+192, + DV_CHR, 0, 0, 0600); +#endif return (1); } -int +static int sioopen(dev, flag, mode, p) dev_t dev; int flag; @@ -1055,7 +1106,7 @@ out: return (error); } -int +static int sioclose(dev, flag, mode, p) dev_t dev; int flag; @@ -1150,7 +1201,7 @@ comhardclose(com) splx(s); } -int +static int sioread(dev, uio, flag) dev_t dev; struct uio *uio; @@ -1170,7 +1221,7 @@ sioread(dev, uio, flag) return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } -int +static int siowrite(dev, uio, flag) dev_t dev; struct uio *uio; @@ -1429,7 +1480,7 @@ cont: } } -int +static int sioioctl(dev, cmd, data, flag, p) dev_t dev; int cmd; @@ -2012,7 +2063,7 @@ comstart(tp) splx(s); } -void +static void siostop(tp, rw) struct tty *tp; int rw; @@ -2041,7 +2092,7 @@ siostop(tp, rw) /* XXX should clear h/w fifos too. */ } -struct tty * +static struct tty * siodevtotty(dev) dev_t dev; { @@ -2559,12 +2610,6 @@ error: } #endif /* DSI_SOFT_MODEM */ -#ifdef JREMOD -struct cdevsw sio_cdevsw = - { sioopen, sioclose, sioread, siowrite, /*28*/ - sioioctl, siostop, nxreset, siodevtotty,/* sio */ - ttselect, nommap, NULL }; - static sio_devsw_installed = 0; static void sio_drvinit(void *unused) @@ -2572,23 +2617,12 @@ static void sio_drvinit(void *unused) dev_t dev; if( ! sio_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&sio_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&sio_cdevsw, NULL); sio_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "sio", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(siodev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,sio_drvinit,NULL) -#endif /* JREMOD */ - #endif /* NSIO > 0 */ diff --git a/sys/i386/isa/sound/soundcard.c b/sys/i386/isa/sound/soundcard.c index 1b4ee3b..ad4888f 100644 --- a/sys/i386/isa/sound/soundcard.c +++ b/sys/i386/isa/sound/soundcard.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: soundcard.c,v 1.35 1995/12/01 01:38:49 julian Exp $ + * $Id: soundcard.c,v 1.36 1995/12/06 23:51:21 bde Exp $ */ #include "sound_config.h" @@ -36,15 +36,11 @@ #include "dev_table.h" #include <i386/isa/isa_device.h> - -#ifdef JREMOD #include <sys/conf.h> #include <sys/kernel.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ -#define CDEV_MAJOR 30 -#endif /*JREMOD*/ u_int snd1_imask; @@ -69,12 +65,27 @@ static int soundcards_installed = 0; /* Number of installed static int soundcard_configured = 0; static struct fileinfo files[SND_NDEVS]; +static void * snd_devfs_token[SND_NDEVS]; +static void * sndstat_devfs_token; struct selinfo selinfo[SND_NDEVS >> 4]; int sndprobe (struct isa_device *dev); int sndattach (struct isa_device *dev); static void sound_mem_init(void); +static d_open_t sndopen; +static d_close_t sndclose; +static d_read_t sndread; +static d_write_t sndwrite; +static d_ioctl_t sndioctl; +static d_select_t sndselect; + +#define CDEV_MAJOR 30 +struct cdevsw snd_cdevsw = + { sndopen, sndclose, sndread, sndwrite, /*30*/ + sndioctl, nostop, nullreset, nodevtotty,/* sound */ + sndselect, nommap, NULL, "snd", NULL, -1 }; + struct isa_driver opldriver = {sndprobe, sndattach, "opl"}; struct isa_driver sbdriver = {sndprobe, sndattach, "sb"}; struct isa_driver sbxvidriver = {sndprobe, sndattach, "sbxvi"}; @@ -126,7 +137,7 @@ int x; } -int +static int sndread (dev_t dev, struct uio *buf, int ioflag) { int count = buf->uio_resid; @@ -136,7 +147,7 @@ sndread (dev_t dev, struct uio *buf, int ioflag) FIX_RETURN (sound_read_sw (dev, &files[dev], buf, count)); } -int +static int sndwrite (dev_t dev, struct uio *buf, int ioflag) { int count = buf->uio_resid; @@ -146,7 +157,7 @@ sndwrite (dev_t dev, struct uio *buf, int ioflag) FIX_RETURN (sound_write_sw (dev, &files[dev], buf, count)); } -int +static int sndopen (dev_t dev, int flags, int fmt, struct proc *p) { int retval; @@ -174,7 +185,7 @@ sndopen (dev_t dev, int flags, int fmt, struct proc *p) FIX_RETURN(sound_open_sw (dev, &files[dev])); } -int +static int sndclose (dev_t dev, int flags, int fmt, struct proc *p) { @@ -184,7 +195,7 @@ sndclose (dev_t dev, int flags, int fmt, struct proc *p) FIX_RETURN (0); } -int +static int sndioctl (dev_t dev, int cmd, caddr_t arg, int flags, struct proc *p) { dev = minor (dev); @@ -192,7 +203,7 @@ sndioctl (dev_t dev, int cmd, caddr_t arg, int flags, struct proc *p) FIX_RETURN (sound_ioctl_sw (dev, &files[dev], cmd, (unsigned int) arg)); } -int +static int sndselect (dev_t dev, int rw, struct proc *p) { dev = minor (dev); @@ -302,6 +313,7 @@ sndattach (struct isa_device *dev) static int generic_midi_initialized = 0; unsigned long mem_start = 0xefffffffUL; struct address_info hw_config; + char name[32]; unit = driver_to_voxunit(dev->id_driver); hw_config.io_base = dev->id_iobase; @@ -356,6 +368,62 @@ sndattach (struct isa_device *dev) } #endif +#ifdef DEVFS +/* XXX */ /* find out where to store the tokens.. */ +/* XXX */ /* should only create devices if that card has them */ +#define SND_UID 0 +#define SND_GID 13 + + + sprintf(name,"mixer%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_CTL, + DV_CHR, SND_UID, SND_GID, 0660); + +#ifndef EXCLUDE_SEQUENCER + sprintf(name,"sequencer%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_SEQ, + DV_CHR, SND_UID, SND_GID, 0660); + sprintf(name,"music%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_SEQ2, + DV_CHR, SND_UID, SND_GID, 0660); +#endif + +#ifndef EXCLUDE_MIDI + sprintf(name,"midi%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_MIDIN, + DV_CHR, SND_UID, SND_GID, 0660); +#endif + +#ifndef EXCLUDE_AUDIO + sprintf(name,"dsp%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_DSP, + DV_CHR, SND_UID, SND_GID, 0660); + sprintf(name,"audio%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_AUDIO, + DV_CHR, SND_UID, SND_GID, 0660); + sprintf(name,"dspW%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_DSP16, + DV_CHR, SND_UID, SND_GID, 0660); +#endif + + sprintf(name,"pss%d",unit); + snd_devfs_token[unit]=devfs_add_devsw( + "/", name, &snd_cdevsw, (unit << 4)+SND_DEV_SNDPROC, + DV_CHR, SND_UID, SND_GID, 0660); + + if ( ! sndstat_devfs_token) { + sndstat_devfs_token = devfs_add_devsw( + "/", "sndstat", &snd_cdevsw, 6, + DV_CHR, SND_UID, SND_GID, 0660); + } +#endif /* DEVFS */ return TRUE; } @@ -484,36 +552,21 @@ snd_release_irq(int vect) { } -#endif -#ifdef JREMOD -struct cdevsw snd_cdevsw = - { sndopen, sndclose, sndread, sndwrite, /*30*/ - sndioctl, nostop, nullreset, nodevtotty,/* sound */ - sndselect, nommap, NULL }; - static snd_devsw_installed = 0; -static void snd_drvinit(void *unused) +static void +snd_drvinit(void *unused) { dev_t dev; if( ! snd_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&snd_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&snd_cdevsw, NULL); snd_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "snd", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(snddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,snd_drvinit,NULL) -#endif /* JREMOD */ +#endif diff --git a/sys/i386/isa/spigot.c b/sys/i386/isa/spigot.c index ac74e31..e542887 100644 --- a/sys/i386/isa/spigot.c +++ b/sys/i386/isa/spigot.c @@ -64,6 +64,10 @@ error "Can only have 1 spigot configured." #include <sys/devconf.h> #include <sys/errno.h> #include <sys/mman.h> +#include <sys/conf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /* DEVFS */ #include <machine/frame.h> #include <machine/spigot.h> @@ -72,13 +76,6 @@ error "Can only have 1 spigot configured." #include <i386/isa/isa.h> #include <i386/isa/isa_device.h> -#ifdef JREMOD -#include <sys/conf.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 11 -#endif /*JREMOD*/ struct spigot_softc { u_long flags; @@ -86,6 +83,9 @@ struct spigot_softc { struct proc *p; u_long signal_num; u_short irq; +#ifdef DEVFS + void *devfs_token; +#endif } spigot_softc[NSPIGOT]; /* flags in softc */ @@ -99,6 +99,21 @@ int spigot_attach(struct isa_device *id); struct isa_driver spigotdriver = {spigot_probe, spigot_attach, "spigot"}; +static d_open_t spigot_open; +static d_close_t spigot_close; +static d_rdwr_t spigot_rw; +static d_read_t spigot_read; +static d_write_t spigot_write; +static d_ioctl_t spigot_ioctl; +static d_select_t spigot_select; +static d_mmap_t spigot_mmap; + +#define CDEV_MAJOR 11 +struct cdevsw spigot_cdevsw = + { spigot_open, spigot_close, spigot_read, spigot_write, /*11*/ + spigot_ioctl, nostop, nullreset, nodevtotty,/* Spigot */ + spigot_select, spigot_mmap, NULL, "spigot", NULL, -1 }; + static struct kern_devconf kdc_spigot[NSPIGOT] = { { 0, /* kdc_next -> filled in by dev_attach() */ 0, /* kdc_rlink -> filled in by dev_attach() */ @@ -155,17 +170,26 @@ struct spigot_softc *ss=(struct spigot_softc *)&spigot_softc[devp->id_unit]; int spigot_attach(struct isa_device *devp) { -struct spigot_softc *ss=(struct spigot_softc *)&spigot_softc[devp->id_unit]; + char name[32]; + int unit; + struct spigot_softc *ss= &spigot_softc[unit = devp->id_unit]; - kdc_spigot[devp->id_unit].kdc_state = DC_UNKNOWN; + kdc_spigot[unit].kdc_state = DC_UNKNOWN; ss->maddr = kvtop(devp->id_maddr); ss->irq = devp->id_irq; +#ifdef DEVFS + sprintf(name,"spigot%d",unit); +/* path name devsw minor type uid gid perm*/ + ss->devfs_token = devfs_add_devsw( "/", name, + &spigot_cdevsw, unit, + DV_CHR, 0, 0, 0600); +#endif return 1; } -int +static int spigot_open(dev_t dev, int flags, int fmt, struct proc *p) { struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; @@ -183,7 +207,7 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; return 0; } -int +static int spigot_close(dev_t dev, int flags, int fmt, struct proc *p) { struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; @@ -197,20 +221,20 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[UNIT(dev)]; return 0; } -int +static int spigot_write(dev_t dev, struct uio *uio, int ioflag) { return ENXIO; } -int +static int spigot_read(dev_t dev, struct uio *uio, int ioflag) { return ENXIO; } -int +static int spigot_ioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { int error; @@ -249,7 +273,7 @@ struct spigot_info *info; return 0; } -int +static int spigot_select(dev_t dev, int rw, struct proc *p) { @@ -269,7 +293,7 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[unit]; psignal(ss->p, ss->signal_num); } -int +static int spigot_mmap(dev_t dev, int offset, int nprot) { struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0]; @@ -286,12 +310,6 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0]; } -#ifdef JREMOD -struct cdevsw spigot_cdevsw = - { spigot_open, spigot_close, spigot_read, spigot_write, /*11*/ - spigot_ioctl, nostop, nullreset, nodevtotty,/* Spigot */ - spigot_select, spigot_mmap, NULL }; - static spigot_devsw_installed = 0; static void spigot_drvinit(void *unused) @@ -299,23 +317,13 @@ static void spigot_drvinit(void *unused) dev_t dev; if( ! spigot_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&spigot_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&spigot_cdevsw, NULL); spigot_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "spigot", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(spigotdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,spigot_drvinit,NULL) -#endif /* JREMOD */ #endif /* NSPIGOT */ diff --git a/sys/i386/isa/spkr.c b/sys/i386/isa/spkr.c index 9d45e33..160c18b 100644 --- a/sys/i386/isa/spkr.c +++ b/sys/i386/isa/spkr.c @@ -4,7 +4,7 @@ * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993 * modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su> * - * $Id: spkr.c,v 1.19 1995/11/29 10:47:57 julian Exp $ + * $Id: spkr.c,v 1.20 1995/11/29 14:39:59 julian Exp $ */ #include "speaker.h" @@ -18,21 +18,29 @@ #include <sys/buf.h> #include <sys/proc.h> #include <sys/uio.h> +#include <sys/conf.h> #include <i386/isa/isa.h> #include <i386/isa/timerreg.h> #include <machine/clock.h> #include <machine/speaker.h> -#ifdef JREMOD -#include <sys/conf.h> -#define CDEV_MAJOR 26 -#endif /*JREMOD*/ #ifdef DEVFS #include <sys/devfsext.h> +void *devfs_token; #endif +static d_open_t spkropen; +static d_close_t spkrclose; +static d_write_t spkrwrite; +static d_ioctl_t spkrioctl; + +#define CDEV_MAJOR 26 +struct cdevsw spkr_cdevsw = + { spkropen, spkrclose, noread, spkrwrite, /*26*/ + spkrioctl, nostop, nullreset, nodevtotty,/* spkr */ + seltrue, nommap, NULL, "spkr", NULL, -1 }; /**************** MACHINE DEPENDENT PART STARTS HERE ************************* * @@ -569,11 +577,6 @@ struct proc *p; return(EINVAL); } -#ifdef JREMOD -struct cdevsw spkr_cdevsw = - { spkropen, spkrclose, noread, spkrwrite, /*26*/ - spkrioctl, nostop, nullreset, nodevtotty,/* spkr */ - seltrue, nommap, NULL }; static spkr_devsw_installed = 0; @@ -582,24 +585,19 @@ static void spkr_drvinit(void *unused) dev_t dev; if( ! spkr_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&spkr_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&spkr_cdevsw, NULL); spkr_devsw_installed = 1; #ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "spkr", major(dev), 0, DV_CHR, 0, 0, 0600); - } + devfs_token = devfs_add_devsw("/", "spkr", + &spkr_cdevsw, 0, + DV_CHR, 0, 0, 0600); #endif } } SYSINIT(spkrdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,spkr_drvinit,NULL) -#endif /* JREMOD */ #endif /* NSPEAKER > 0 */ /* spkr.c ends here */ diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c index 6c736ca..db7c92d 100644 --- a/sys/i386/isa/syscons.c +++ b/sys/i386/isa/syscons.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: syscons.c,v 1.133 1995/12/06 23:50:36 bde Exp $ + * $Id: syscons.c,v 1.134 1995/12/07 12:46:08 davidg Exp $ */ #include "sc.h" @@ -45,6 +45,9 @@ #include <sys/errno.h> #include <sys/malloc.h> #include <sys/devconf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif #include <machine/clock.h> #include <machine/cons.h> @@ -69,6 +72,7 @@ #define MAXCONS 16 #endif + /* this may break on older VGA's but is usefull on real 32 bit systems */ #define bcopyw bcopy @@ -84,6 +88,7 @@ static default_attr kernel_default = { static scr_stat main_console; static scr_stat *console[MAXCONS]; +static void *sc_devfs_token[MAXCONS]; scr_stat *cur_console; static scr_stat *new_scp, *old_scp; static term_stat kernel_console; @@ -159,8 +164,7 @@ static d_mmap_t scmmap; static struct cdevsw scdevsw = { scopen, scclose, scread, scwrite, scioctl, nullstop, noreset, scdevtotty, - ttselect, scmmap, nostrategy, -}; + ttselect, scmmap, nostrategy, "sc", NULL, -1 }; /* * Calculate hardware attributes word using logical attributes mask and @@ -283,7 +287,9 @@ scresume(void *dummy) int scattach(struct isa_device *dev) { - scr_stat *scp; + scr_stat *scp; + int vc; + char name[32]; scinit(); configuration = dev->id_flags; @@ -345,6 +351,13 @@ scattach(struct isa_device *dev) apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook); #endif +#ifdef DEVFS + for ( vc = 0 ; vc < MAXCONS; vc++) { + sprintf(name,"ttyv%x", vc); + sc_devfs_token[vc] = devfs_add_devsw("/" ,name, &scdevsw, vc, + DV_CHR, 0, 0, 0600 ); + } +#endif register_cdev("sc", &scdevsw); return 0; diff --git a/sys/i386/isa/tw.c b/sys/i386/isa/tw.c index 7eb75e0..f8406f0 100644 --- a/sys/i386/isa/tw.c +++ b/sys/i386/isa/tw.c @@ -138,23 +138,18 @@ #include "uio.h" #include "syslog.h" #include "select.h" +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #define MIN(a,b) ((a)<(b)?(a):(b)) #ifdef HIRESTIME -#include "time.h" +#include <sys/time.h> #endif /* HIRESTIME */ #include "i386/isa/isa_device.h" -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 19 -#endif /*JREMOD*/ /* @@ -211,6 +206,17 @@ struct isa_driver twdriver = { twprobe, twattach, "tw" }; +static d_open_t twopen; +static d_close_t twclose; +static d_read_t twread; +static d_write_t twwrite; +static d_select_t twselect; + +#define CDEV_MAJOR 19 +struct cdevsw tw_cdevsw = + { twopen, twclose, twread, twwrite, /*19*/ + noioc, nullstop, nullreset, nodevtotty, /* tw */ + twselect, nommap, nostrat, "tw", NULL, -1 }; /* * Software control structure for TW523 */ @@ -240,6 +246,9 @@ struct tw_sc { int sc_xtimes[22]; /* Times for bits in current xmit packet */ int sc_rtimes[22]; /* Times for bits in current rcv packet */ #endif /* HIRESTIME */ +#ifdef DEVFS + void *devfs_token; /* store the devfs handle */ +#endif } tw_sc[NTW]; static void twdelay25(); @@ -348,11 +357,20 @@ int twattach(idp) struct isa_device *idp; { struct tw_sc *sc; + char name[32]; + int unit; - sc = &tw_sc[idp->id_unit]; + sc = &tw_sc[unit = idp->id_unit]; sc->sc_port = idp->id_iobase; sc->sc_state = 0; +#ifdef DEVFS +/* path name devsw minor type uid gid perm*/ + sprintf(name,"tw%d", unit); + sc->devfs_token = devfs_add_devsw( "/", name, &tw_cdevsw, unit, + DV_CHR, 0, 0, 0600); +#endif + return (1); } @@ -992,11 +1010,6 @@ static int twchecktime(int target, int tol) } #endif /* HIRESTIME */ -#ifdef JREMOD -struct cdevsw tw_cdevsw = - { twopen, twclose, twread, twwrite, /*19*/ - noioc, nullstop, nullreset, nodevtotty,/* tw */ - twselect, nommap, nostrat }; static tw_devsw_installed = 0; @@ -1005,23 +1018,13 @@ static void tw_drvinit(void *unused) dev_t dev; if( ! tw_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&tw_cdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&tw_cdevsw, NULL); tw_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "tw", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(twdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,tw_drvinit,NULL) -#endif /* JREMOD */ #endif NTW diff --git a/sys/i386/isa/wcd.c b/sys/i386/isa/wcd.c index f56dc46..2b57f3a 100644 --- a/sys/i386/isa/wcd.c +++ b/sys/i386/isa/wcd.c @@ -29,17 +29,33 @@ #include <sys/devconf.h> #include <sys/disklabel.h> #include <sys/cdio.h> -#include <i386/include/cpufunc.h> -#include <i386/isa/atapi.h> - -#ifdef JREMOD #include <sys/conf.h> #ifdef DEVFS #include <sys/devfsext.h> #endif /*DEVFS*/ +#include <i386/include/cpufunc.h> +#include <i386/isa/atapi.h> + +static d_open_t wcdropen; +static d_open_t wcdbopen; +static d_close_t wcdrclose; +static d_close_t wcdbclose; +static d_ioctl_t wcdioctl; +static d_strategy_t wcdstrategy; + #define CDEV_MAJOR 69 #define BDEV_MAJOR 19 -#endif /*JREMOD */ +extern struct cdevsw wcd_cdevsw; +struct bdevsw wcd_bdevsw = + { wcdbopen, wcdbclose, wcdstrategy, wcdioctl, /*19*/ + nxdump, zerosize, 0, "wcd", &wcd_cdevsw, -1 }; + +struct cdevsw wcd_cdevsw = + { wcdropen, wcdrclose, rawread, nowrite, /*69*/ + wcdioctl, nostop, nullreset, nodevtotty,/* atapi */ + seltrue, nommap, wcdstrategy, "wcd", + &wcd_bdevsw, -1 }; + extern int wcdattach(struct atapi*, int, struct atapi_params*, int, struct kern_devconf*); @@ -205,6 +221,12 @@ struct wcd { struct subchan subchan; /* Subchannel info */ struct kern_devconf cf; /* Driver configuration info */ char description[80]; /* Device description */ +#ifdef DEVFS + void *ra_devfs_token; + void *rc_devfs_token; + void *a_devfs_token; + void *c_devfs_token; +#endif }; struct wcd *wcdtab[NUNIT]; /* Drive info by unit number */ @@ -262,6 +284,8 @@ wcdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug, { struct wcd *t; struct atapires result; + int lun; + char name[32]; if (wcdnlun >= NUNIT) { printf ("wcd: too many units\n"); @@ -281,7 +305,7 @@ wcdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug, bzero (t, sizeof (struct wcd)); t->ata = ata; t->unit = unit; - t->lun = wcdnlun++; + lun = t->lun = wcdnlun++; t->param = ap; t->flags = F_MEDIA_CHANGED; t->refcnt = 0; @@ -325,6 +349,29 @@ wcdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug, ap->model, sizeof(ap->model)); dev_attach (&t->cf); +#ifdef DEVFS +#define WDC_UID 0 +#define WDC_GID 13 + sprintf(name, "rwcd%da",lun); + t->ra_devfs_token = devfs_add_devsw( + "/", name, &wcd_cdevsw, (lun * 8), + DV_CHR, WDC_UID, WDC_GID, 0600); + + sprintf(name, "rwcd%dc",lun); + t->rc_devfs_token = devfs_add_devsw( + "/", name, &wcd_cdevsw, (lun * 8) + RAW_PART, + DV_CHR, WDC_UID, WDC_GID, 0600); + + sprintf(name, "wcd%da",lun); + t->a_devfs_token = devfs_add_devsw( + "/", name, &wcd_bdevsw, (lun * 8), + DV_BLK, WDC_UID, WDC_GID, 0600); + + sprintf(name, "wcd%dc",lun); + t->c_devfs_token = devfs_add_devsw( + "/", name, &wcd_bdevsw, (lun * 8) + RAW_PART, + DV_BLK, WDC_UID, WDC_GID, 0600); +#endif return (1); } @@ -1074,21 +1121,13 @@ static int wcd_eject (struct wcd *t) #include <sys/lkm.h> /* - * Device table entries. - * These get copied at modload time into the kernels - * lkm dummy device driver entries (see sys/i386/i386/conf.c). - */ -struct bdevsw dev_wcd = { wcdbopen, wcdbclose, wcdstrategy, wcdioctl, - nodump, nopsize, 0 }; -struct cdevsw dev_rwcd = { wcdropen, wcdrclose, rawread, nowrite, wcdioctl, - nostop, nullreset, nodevtotty, seltrue, nommap, - wcdstrategy }; -/* * Construct lkm_dev structures (see lkm.h). * Our bdevsw/cdevsw slot numbers are 19/69. */ -MOD_DEV(wcd, LM_DT_BLOCK, 19, &dev_wcd); -MOD_DEV(rwcd, LM_DT_CHAR, 69, &dev_rwcd); + + +MOD_DEV(wcd, LM_DT_BLOCK, BDEV_MAJOR, &wcd_bdevsw); +MOD_DEV(rwcd, LM_DT_CHAR, CDEV_MAJOR, &wcd_cdevsw); /* * Function called when loading the driver. @@ -1169,47 +1208,22 @@ int wcd_mod (struct lkm_table *lkmtp, int cmd, int ver) } #endif /* WCD_MODULE */ -#ifdef JREMOD -struct bdevsw wcd_bdevsw = - { wcdbopen, wcdbclose, wcdstrategy, wcdioctl, /*19*/ - nxdump, zerosize, 0 }; - -struct cdevsw wcd_cdevsw = - { wcdropen, wcdrclose, rawread, nowrite, /*69*/ - wcdioctl, nostop, nullreset, nodevtotty,/* atapi */ - seltrue, nommap, wcdstrategy }; - static wcd_devsw_installed = 0; static void wcd_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! wcd_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&wcd_cdevsw,NULL); - dev_chr = dev; - dev = makedev(BDEV_MAJOR,0); - bdevsw_add(&dev,&wcd_bdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&wcd_cdevsw, NULL); + dev = makedev(BDEV_MAJOR, 0); + bdevsw_add(&dev,&wcd_bdevsw, NULL); wcd_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "rwcd", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "wcd", major(dev), 0, DV_BLK, 0, 0, 0600); - } -#endif } } SYSINIT(wcddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wcd_drvinit,NULL) -#endif /* JREMOD */ #endif /* NWCD && NWDC && ATAPI */ diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c index 354b0bb..1822a8b 100644 --- a/sys/i386/isa/wd.c +++ b/sys/i386/isa/wd.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)wd.c 7.2 (Berkeley) 5/9/91 - * $Id: wd.c,v 1.95 1995/11/29 14:40:08 julian Exp $ + * $Id: wd.c,v 1.96 1995/12/07 12:46:12 davidg Exp $ */ /* TODO: @@ -78,6 +78,9 @@ #include <sys/uio.h> #include <sys/malloc.h> #include <sys/devconf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/bootinfo.h> #include <machine/clock.h> #include <machine/cons.h> @@ -108,13 +111,6 @@ extern void wdstart(int ctrlr); #define WDOPT_SLEEPHACK 0x4000 #define WDOPT_MULTIMASK 0x00ff -#ifdef JREMOD -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 3 -#define BDEV_MAJOR 0 -#endif /*JREMOD */ static int wd_goaway(struct kern_devconf *, int); static int wdc_goaway(struct kern_devconf *, int); @@ -305,6 +301,27 @@ struct isa_driver wdcdriver = { wdprobe, wdattach, "wdc", }; +static d_open_t wdopen; +static d_close_t wdclose; +static d_ioctl_t wdioctl; +static d_dump_t wddump; +static d_size_t wdsize; +static d_strategy_t wdstrategy; + +#define CDEV_MAJOR 3 +#define BDEV_MAJOR 0 +extern struct cdevsw wd_cdevsw; +struct bdevsw wd_bdevsw = + { wdopen, wdclose, wdstrategy, wdioctl, /*0*/ + wddump, wdsize, 0, "wd", &wd_cdevsw, -1 }; + +struct cdevsw wd_cdevsw = + { wdopen, wdclose, rawread, rawwrite, /*3*/ + wdioctl, nostop, nullreset, nodevtotty,/* wd */ + seltrue, nommap, wdstrategy, "wd", + &wd_bdevsw, -1 }; + + /* * Probe for controller. */ @@ -2127,46 +2144,22 @@ wdwait(struct disk *du, u_char bits_wanted, int timeout) return (-1); } -#ifdef JREMOD -struct bdevsw wd_bdevsw = - { wdopen, wdclose, wdstrategy, wdioctl, /*0*/ - wddump, wdsize, 0 }; - -struct cdevsw wd_cdevsw = - { wdopen, wdclose, rawread, rawwrite, /*3*/ - wdioctl, nostop, nullreset, nodevtotty,/* wd */ - seltrue, nommap, wdstrategy }; - static wd_devsw_installed = 0; static void wd_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! wd_devsw_installed ) { dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&wd_cdevsw,NULL); - dev_chr = dev; dev = makedev(BDEV_MAJOR,0); bdevsw_add(&dev,&wd_bdevsw,NULL); wd_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "rwd", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - x=devfs_add_devsw( - "/", "wd", major(dev), 0, DV_BLK, 0, 0, 0600); - } -#endif } } SYSINIT(wddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wd_drvinit,NULL) -#endif /* JREMOD */ #endif /* NWDC > 0 */ diff --git a/sys/i386/isa/wt.c b/sys/i386/isa/wt.c index 7e4a062..6fc75d8 100644 --- a/sys/i386/isa/wt.c +++ b/sys/i386/isa/wt.c @@ -19,7 +19,7 @@ * the original CMU copyright notice. * * Version 1.3, Thu Nov 11 12:09:13 MSK 1993 - * $Id: wt.c,v 1.22 1995/11/29 10:48:03 julian Exp $ + * $Id: wt.c,v 1.23 1995/11/29 14:40:11 julian Exp $ * */ @@ -69,6 +69,10 @@ #include <sys/mtio.h> #include <sys/proc.h> #include <sys/devconf.h> +#include <sys/conf.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <vm/vm_param.h> #include <machine/clock.h> @@ -76,14 +80,6 @@ #include <i386/isa/isa_device.h> #include <i386/isa/wtreg.h> -#ifdef JREMOD -#include <sys/conf.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 10 -#define BDEV_MAJOR 3 -#endif /*JREMOD */ /* * Uncomment this to enable internal device tracing. @@ -167,6 +163,10 @@ typedef struct { unsigned short DATAPORT, CMDPORT, STATPORT, CTLPORT, SDMAPORT, RDMAPORT; unsigned char BUSY, NOEXCEP, RESETMASK, RESETVAL; unsigned char ONLINE, RESET, REQUEST, IEN; +#ifdef DEVFS + void *devfs_token; + void *devfs_token_r; +#endif } wtinfo_t; wtinfo_t wttab[NWT]; /* tape info by unit number */ @@ -196,6 +196,28 @@ static struct kern_devconf kdc_wt[NWT] = { { DC_CLS_TAPE /* class */ } }; +static d_open_t wtopen; +static d_close_t wtclose; +static d_ioctl_t wtioctl; +static d_dump_t wtdump; +static d_psize_t wtsize; +static d_strategy_t wtstrategy; + +#define CDEV_MAJOR 10 +#define BDEV_MAJOR 3 + +extern struct cdevsw wt_cdevsw; +struct bdevsw wt_bdevsw = + { wtopen, wtclose, wtstrategy, wtioctl, /*3*/ + wtdump, wtsize, B_TAPE, "wt", &wt_cdevsw, -1 }; + +struct cdevsw wt_cdevsw = + { wtopen, wtclose, rawread, rawwrite, /*10*/ + wtioctl, nostop, nullreset, nodevtotty,/* wt */ + seltrue, nommap, wtstrategy, "wt", + &wt_bdevsw, -1 }; + + static inline void wt_registerdev(struct isa_device *id) { @@ -261,6 +283,7 @@ static int wtattach (struct isa_device *id) { wtinfo_t *t = wttab + id->id_unit; + char name[32]; if (t->type == ARCHIVE) { printf ("wt%d: type <Archive>\n", t->unit); @@ -271,6 +294,16 @@ wtattach (struct isa_device *id) t->dens = -1; /* unknown density */ kdc_wt[id->id_unit].kdc_state = DC_IDLE; +#ifdef DEVFS + sprintf(name,"rwt%d",id->id_unit); + t->devfs_token_r = devfs_add_devsw( + "/", name, &wt_cdevsw, id->id_unit, + DV_CHR, 0, 0, 0600); + sprintf(name,"wt%d",id->id_unit); + t->devfs_token = devfs_add_devsw( + "/", name, &wt_bdevsw, id->id_unit, + DV_BLK, 0, 0, 0600); +#endif return (1); } @@ -975,46 +1008,22 @@ static int wtstatus (wtinfo_t *t) } -#ifdef JREMOD -struct bdevsw wt_bdevsw = - { wtopen, wtclose, wtstrategy, wtioctl, /*3*/ - wtdump, wtsize, B_TAPE }; - -struct cdevsw wt_cdevsw = - { wtopen, wtclose, rawread, rawwrite, /*10*/ - wtioctl, nostop, nullreset, nodevtotty,/* wt */ - seltrue, nommap, wtstrategy }; - static wt_devsw_installed = 0; static void wt_drvinit(void *unused) { dev_t dev; - dev_t dev_chr; if( ! wt_devsw_installed ) { - dev = makedev(CDEV_MAJOR,0); - cdevsw_add(&dev,&wt_cdevsw,NULL); - dev_chr = dev; - dev = makedev(BDEV_MAJOR,0); - bdevsw_add(&dev,&wt_bdevsw,NULL); + dev = makedev(CDEV_MAJOR, 0); + cdevsw_add(&dev,&wt_cdevsw, NULL); + dev = makedev(BDEV_MAJOR, 0); + bdevsw_add(&dev,&wt_bdevsw, NULL); wt_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "rwt", major(dev_chr), 0, DV_CHR, 0, 0, 0600); - x=devfs_add_devsw( - "/", "wt", major(dev), 0, DV_BLK, 0, 0, 0600); - } -#endif } } SYSINIT(wtdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wt_drvinit,NULL) -#endif /* JREMOD */ #endif /* NWT */ |