From 87f6c6625d5a4889540cb77c8296e456b7d1390b Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Fri, 8 Dec 1995 11:19:42 +0000 Subject: Pass 3 of the great devsw changes most devsw referenced functions are now static, as they are in the same file as their devsw structure. I've also added DEVFS support for nearly every device in the system, however many of the devices have 'incorrect' names under DEVFS because I couldn't quickly work out the correct naming conventions. (but devfs won't be coming on line for a month or so anyhow so that doesn't matter) If you "OWN" a device which would normally have an entry in /dev then search for the devfs_add_devsw() entries and munge to make them right.. check out similar devices to see what I might have done in them in you can't see what's going on.. for a laugh compare conf.c conf.h defore and after... :) I have not doen DEVFS entries for any DISKSLICE devices yet as that will be a much more complicated job.. (pass 5 :) pass 4 will be to make the devsw tables of type (cdevsw * ) rather than (cdevsw) seems to work here.. complaints to the usual places.. :) --- sys/dev/fdc/fdc.c | 75 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'sys/dev/fdc') diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 1af2cbf0d48e..e1b34366080a 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.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 #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 -- cgit v1.3