summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_conf.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-05-07 10:11:40 +0000
committerphk <phk@FreeBSD.org>1999-05-07 10:11:40 +0000
commit693dd58bb3e5843d252e25a15e2cc8d49323cb82 (patch)
treea0fbea49edf11184c1bafaed7d5b3cd858742449 /sys/kern/kern_conf.c
parentcfcd3ae08c30d66088e1ad5ffa68aa05b60e1bfe (diff)
downloadFreeBSD-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/kern_conf.c')
-rw-r--r--sys/kern/kern_conf.c105
1 files changed, 17 insertions, 88 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;
}
OpenPOWER on IntegriCloud