diff options
author | phk <phk@FreeBSD.org> | 1999-05-07 10:11:40 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-05-07 10:11:40 +0000 |
commit | 693dd58bb3e5843d252e25a15e2cc8d49323cb82 (patch) | |
tree | a0fbea49edf11184c1bafaed7d5b3cd858742449 /sys/kern | |
parent | cfcd3ae08c30d66088e1ad5ffa68aa05b60e1bfe (diff) | |
download | FreeBSD-src-693dd58bb3e5843d252e25a15e2cc8d49323cb82.zip FreeBSD-src-693dd58bb3e5843d252e25a15e2cc8d49323cb82.tar.gz |
Continue where Julian left off in July 1998:
Virtualize bdevsw[] from cdevsw. bdevsw() is now an (inline)
function.
Join CDEV_MODULE and BDEV_MODULE to DEV_MODULE (please pay attention
to the order of the cmaj/bmaj arguments!)
Join CDEV_DRIVER_MODULE and BDEV_DRIVER_MODULE to DEV_DRIVER_MODULE
(ditto!)
(Next step will be to convert all bdev dev_t's to cdev dev_t's
before they get to do any damage^H^H^H^H^H^Hwork in the kernel.)
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_conf.c | 105 | ||||
-rw-r--r-- | sys/kern/kern_shutdown.c | 8 | ||||
-rw-r--r-- | sys/kern/vfs_export.c | 10 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 10 |
4 files changed, 31 insertions, 102 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 502b78d..2e303b2 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_conf.c,v 1.30 1999/01/27 21:49:55 dillon Exp $ + * $Id: kern_conf.c,v 1.31 1999/03/23 21:11:47 dfr Exp $ */ #include <sys/param.h> @@ -39,16 +39,15 @@ #include <sys/conf.h> #include <sys/vnode.h> -#define NUMBDEV 128 #define NUMCDEV 256 -#define bdevsw_ALLOCSTART (NUMBDEV/2) #define cdevsw_ALLOCSTART (NUMCDEV/2) -struct cdevsw *bdevsw[NUMBDEV]; -int nblkdev = NUMBDEV; struct cdevsw *cdevsw[NUMCDEV]; int nchrdev = NUMCDEV; +int bmaj2cmaj[NUMCDEV]; +int nblkdev = NUMCDEV; + /* * Routine to convert from character to block device number. * @@ -66,50 +65,6 @@ chrtoblk(dev_t dev) return(NODEV); } -/* - * (re)place an entry in the bdevsw or cdevsw table - * return the slot used in major(*descrip) - */ -static int -bdevsw_add(dev_t *descrip, - struct cdevsw *newentry, - struct cdevsw **oldentry) -{ - int i ; - - if ( (int)*descrip == NODEV) { /* auto (0 is valid) */ - /* - * Search the table looking for a slot... - */ - for (i = bdevsw_ALLOCSTART; i < nblkdev; i++) - if (bdevsw[i] == NULL) - break; /* found one! */ - /* out of allocable slots? */ - if (i >= nblkdev) { - return ENFILE; - } - } else { /* assign */ - i = major(*descrip); - if (i < 0 || i >= nblkdev) { - return EINVAL; - } - } - - /* maybe save old */ - if (oldentry) { - *oldentry = bdevsw[i]; - } - if (newentry) { - newentry->d_bmaj = i; - } - /* replace with new */ - bdevsw[i] = newentry; - - /* done! let them know where we put it */ - *descrip = makedev(i,0); - return 0; -} - int cdevsw_add(dev_t *descrip, struct cdevsw *newentry, @@ -155,55 +110,29 @@ cdevsw_add(dev_t *descrip, * note must call cdevsw_add before bdevsw_add due to d_bmaj hack. */ void -cdevsw_add_generic(int bdev, int cdev, struct cdevsw *cdevsw) +cdevsw_add_generic(int bmaj, int cmaj, struct cdevsw *cdevsw) { dev_t dev; - dev = makedev(cdev, 0); + dev = makedev(cmaj, 0); cdevsw_add(&dev, cdevsw, NULL); - dev = makedev(bdev, 0); - bdevsw_add(&dev, cdevsw, NULL); + bmaj2cmaj[bmaj] = cmaj; } int -cdevsw_module_handler(module_t mod, int what, void *arg) +devsw_module_handler(module_t mod, int what, void* arg) { - struct cdevsw_module_data* data = (struct cdevsw_module_data*) arg; - int error; - - switch (what) { - case MOD_LOAD: - error = cdevsw_add(&data->dev, data->cdevsw, NULL); - if (!error && data->chainevh) - error = data->chainevh(mod, what, data->chainarg); - return error; - - case MOD_UNLOAD: - if (data->chainevh) { - error = data->chainevh(mod, what, data->chainarg); - if (error) - return error; - } - return cdevsw_add(&data->dev, NULL, NULL); - } - - if (data->chainevh) - return data->chainevh(mod, what, data->chainarg); - else - return 0; -} - -int -bdevsw_module_handler(module_t mod, int what, void* arg) -{ - struct bdevsw_module_data* data = (struct bdevsw_module_data*) arg; + struct devsw_module_data* data = (struct devsw_module_data*) arg; int error; switch (what) { case MOD_LOAD: error = cdevsw_add(&data->cdev, data->cdevsw, NULL); - if (!error) - error = bdevsw_add(&data->bdev, data->cdevsw, NULL); + if (!error && data->cdevsw->d_strategy != nostrategy) { + if (data->bdev == NODEV) + data->bdev = data->cdev; + bmaj2cmaj[major(data->bdev)] = major(data->cdev); + } if (!error && data->chainevh) error = data->chainevh(mod, what, data->chainarg); return error; @@ -214,9 +143,9 @@ bdevsw_module_handler(module_t mod, int what, void* arg) if (error) return error; } - error = bdevsw_add(&data->bdev, NULL, NULL); - if (!error) - error = cdevsw_add(&data->cdev, NULL, NULL); + if (data->cdevsw->d_strategy != nostrategy) + bmaj2cmaj[major(data->bdev)] = 0; + error = cdevsw_add(&data->cdev, NULL, NULL); return error; } diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 7a8d8ee..2c51ac7 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 - * $Id: kern_shutdown.c,v 1.48 1999/05/03 23:57:22 billf Exp $ + * $Id: kern_shutdown.c,v 1.49 1999/05/06 18:12:44 peter Exp $ */ #include "opt_ddb.h" @@ -377,14 +377,14 @@ dumpsys(void) return; if (dumpdev == NODEV) return; - if (!(bdevsw[major(dumpdev)])) + if (!(bdevsw(major(dumpdev)))) return; - if (!(bdevsw[major(dumpdev)]->d_dump)) + if (!(bdevsw(major(dumpdev))->d_dump)) return; dumpsize = Maxmem; printf("\ndumping to dev %lx, offset %ld\n", (u_long)dumpdev, dumplo); printf("dump "); - switch ((*bdevsw[major(dumpdev)]->d_dump)(dumpdev)) { + switch ((*bdevsw(major(dumpdev))->d_dump)(dumpdev)) { case ENXIO: printf("device bad\n"); diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index abd32e2..258d8e5 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.189 1999/03/12 02:24:56 julian Exp $ + * $Id: vfs_subr.c,v 1.190 1999/05/03 23:57:24 billf Exp $ */ /* @@ -1177,7 +1177,7 @@ bdevvp(dev, vpp) /* XXX 255 is for mfs. */ if (dev == NODEV || (major(dev) != 255 && (major(dev) >= nblkdev || - bdevsw[major(dev)] == NULL))) { + bdevsw(major(dev)) == NULL))) { *vpp = NULLVP; return (ENXIO); } @@ -1275,9 +1275,9 @@ loop: */ if (nvp->v_type == VBLK && rmaj < nblkdev) { - if (bdevsw[rmaj] && bdevsw[rmaj]->d_parms) + if (bdevsw(rmaj) && bdevsw(rmaj)->d_parms) - (*bdevsw[rmaj]->d_parms)(nvp_rdev, sinfo, DPARM_GET); + (*bdevsw(rmaj)->d_parms)(nvp_rdev, sinfo, DPARM_GET); } else if (nvp->v_type == VCHR && rmaj < nchrdev) { if (cdevsw[rmaj] && cdevsw[rmaj]->d_parms) (*cdevsw[rmaj]->d_parms)(nvp_rdev, sinfo, DPARM_GET); @@ -2585,7 +2585,7 @@ retry: goto retn; object = vnode_pager_alloc(vp, vat.va_size, 0, 0); } else if (major(vp->v_rdev) < nblkdev && - bdevsw[major(vp->v_rdev)] != NULL) { + bdevsw(major(vp->v_rdev)) != NULL) { /* * This simply allocates the biggest object possible * for a VBLK vnode. This should be fixed, but doesn't diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index abd32e2..258d8e5 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.189 1999/03/12 02:24:56 julian Exp $ + * $Id: vfs_subr.c,v 1.190 1999/05/03 23:57:24 billf Exp $ */ /* @@ -1177,7 +1177,7 @@ bdevvp(dev, vpp) /* XXX 255 is for mfs. */ if (dev == NODEV || (major(dev) != 255 && (major(dev) >= nblkdev || - bdevsw[major(dev)] == NULL))) { + bdevsw(major(dev)) == NULL))) { *vpp = NULLVP; return (ENXIO); } @@ -1275,9 +1275,9 @@ loop: */ if (nvp->v_type == VBLK && rmaj < nblkdev) { - if (bdevsw[rmaj] && bdevsw[rmaj]->d_parms) + if (bdevsw(rmaj) && bdevsw(rmaj)->d_parms) - (*bdevsw[rmaj]->d_parms)(nvp_rdev, sinfo, DPARM_GET); + (*bdevsw(rmaj)->d_parms)(nvp_rdev, sinfo, DPARM_GET); } else if (nvp->v_type == VCHR && rmaj < nchrdev) { if (cdevsw[rmaj] && cdevsw[rmaj]->d_parms) (*cdevsw[rmaj]->d_parms)(nvp_rdev, sinfo, DPARM_GET); @@ -2585,7 +2585,7 @@ retry: goto retn; object = vnode_pager_alloc(vp, vat.va_size, 0, 0); } else if (major(vp->v_rdev) < nblkdev && - bdevsw[major(vp->v_rdev)] != NULL) { + bdevsw(major(vp->v_rdev)) != NULL) { /* * This simply allocates the biggest object possible * for a VBLK vnode. This should be fixed, but doesn't |