diff options
author | msmith <msmith@FreeBSD.org> | 2002-01-09 04:58:49 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 2002-01-09 04:58:49 +0000 |
commit | c2656ac96b01ac240f679622b1c4064d136439b5 (patch) | |
tree | 7511272f9de296a16a091a2f3b9ff46e52de9b7d /sys | |
parent | c5438df911e5179a4be306274f29768e82e5a7d6 (diff) | |
download | FreeBSD-src-c2656ac96b01ac240f679622b1c4064d136439b5.zip FreeBSD-src-c2656ac96b01ac240f679622b1c4064d136439b5.tar.gz |
Add a new sysinit SI_SUB_DEVFS. Devfs hooks into the kernel at SI_ORDER_FIRST,
and devices can be created anytime after that.
Print a warning if an atttempt is made to create a device too early.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/devfs/devfs_devs.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_conf.c | 20 | ||||
-rw-r--r-- | sys/sys/kernel.h | 1 |
3 files changed, 21 insertions, 2 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 4db217d..ef9827c 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -437,6 +437,6 @@ devfs_init(void *junk) devfs_present = 1; } -SYSINIT(devfs, SI_SUB_DRIVERS, SI_ORDER_FIRST, devfs_init, NULL); +SYSINIT(devfs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_init, NULL); #endif diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 552e67e..a9264a2 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -71,6 +71,8 @@ devfs_create_t *devfs_create_hook; devfs_destroy_t *devfs_destroy_hook; int devfs_present; +static int ready_for_devs; + static int free_devt; SYSCTL_INT(_debug, OID_AUTO, free_devt, CTLFLAG_RW, &free_devt, 0, ""); @@ -288,6 +290,12 @@ make_dev(struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const KASSERT(umajor(makeudev(devsw->d_maj, minor)) == devsw->d_maj, ("Invalid minor (%d) in make_dev", minor)); + if (!ready_for_devs) { + printf("WARNING: Driver mistake: make_dev(%s) called before SI_SUB_DRIVERS\n", + fmt); + /* XXX panic here once drivers are cleaned up */ + } + dev = makedev(devsw->d_maj, minor); if (dev->si_flags & SI_NAMED) { printf( "WARNING: Driver mistake: repeat make_dev(\"%s\")\n", @@ -454,4 +462,14 @@ sysctl_devname(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_kern, OID_AUTO, devname, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY, NULL, 0, sysctl_devname, "", "devname(3) handler"); - + +/* + * Set ready_for_devs; prior to this point, device creation is not allowed. + */ +static void +dev_set_ready(void *junk) +{ + ready_for_devs = 1; +} + +SYSINIT(dev_ready, SI_SUB_DEVFS, SI_ORDER_FIRST, dev_set_ready, NULL); diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index 9943b1f..f86a638 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -130,6 +130,7 @@ enum sysinit_sub_id { SI_SUB_MBUF = 0x2700000, /* mbuf subsystem */ SI_SUB_INTR = 0x2800000, /* interrupt threads */ SI_SUB_SOFTINTR = 0x2800001, /* start soft interrupt thread */ + SI_SUB_DEVFS = 0x2F00000, /* devfs ready for devices */ SI_SUB_INIT_IF = 0x3000000, /* prep for net interfaces */ SI_SUB_DRIVERS = 0x3100000, /* Let Drivers initialize */ SI_SUB_CONFIGURE = 0x3800000, /* Configure devices */ |