summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>1998-07-04 22:30:26 +0000
committerJulian Elischer <julian@FreeBSD.org>1998-07-04 22:30:26 +0000
commitf7ea2f55d11712e31e448896b4d1bda81be24e35 (patch)
tree5b1d39937f11bc9995acb310c60d52bc73d652f8 /sys/kern
parent2c5174cba2eb6fd3fd2a06bc9dcff33c44649ed6 (diff)
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_conf.c179
-rw-r--r--sys/kern/kern_physio.c32
-rw-r--r--sys/kern/subr_diskslice.c4
-rw-r--r--sys/kern/vfs_aio.c9
4 files changed, 106 insertions, 118 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index e8df756d0f49..684b36514f8a 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.25 1998/06/25 11:27:34 phk Exp $
+ * $Id: kern_conf.c,v 1.26 1998/06/26 18:14:25 phk Exp $
*/
#include <sys/param.h>
@@ -44,13 +44,11 @@
#define bdevsw_ALLOCSTART (NUMBDEV/2)
#define cdevsw_ALLOCSTART (NUMCDEV/2)
-struct bdevsw *bdevsw[NUMBDEV];
+struct cdevsw *bdevsw[NUMBDEV];
int nblkdev = NUMBDEV;
struct cdevsw *cdevsw[NUMCDEV];
int nchrdev = NUMCDEV;
-static void cdevsw_make __P((struct bdevsw *from));
-
/*
* Routine to convert from character to block device number.
*
@@ -63,8 +61,8 @@ chrtoblk(dev_t dev)
struct cdevsw *cd;
if(cd = cdevsw[major(dev)]) {
- if ( (bd = cd->d_bdev) )
- return(makedev(bd->d_maj,minor(dev)));
+ if (cd->d_bmaj != -1)
+ return(makedev(cd->d_bmaj,minor(dev)));
}
return(NODEV);
}
@@ -73,91 +71,99 @@ chrtoblk(dev_t dev)
* (re)place an entry in the bdevsw or cdevsw table
* return the slot used in major(*descrip)
*/
-#define ADDENTRY(TTYPE,NXXXDEV,ALLOCSTART) \
-int TTYPE##_add(dev_t *descrip, \
- struct TTYPE *newentry, \
- struct TTYPE **oldentry) \
-{ \
- int i ; \
- if ( (int)*descrip == NODEV) { /* auto (0 is valid) */ \
- /* \
- * Search the table looking for a slot... \
- */ \
- for (i = ALLOCSTART; i < NXXXDEV; i++) \
- if (TTYPE[i] == NULL) \
- break; /* found one! */ \
- /* out of allocable slots? */ \
- if (i >= NXXXDEV) { \
- return ENFILE; \
- } \
- } else { /* assign */ \
- i = major(*descrip); \
- if (i < 0 || i >= NXXXDEV) { \
- return EINVAL; \
- } \
- } \
- \
- /* maybe save old */ \
- if (oldentry) { \
- *oldentry = TTYPE[i]; \
- } \
- if (newentry) \
- newentry->d_maj = i; \
- /* replace with new */ \
- TTYPE[i] = newentry; \
- \
- /* done! let them know where we put it */ \
- *descrip = makedev(i,0); \
- return 0; \
-} \
-
-static ADDENTRY(bdevsw, nblkdev,bdevsw_ALLOCSTART)
-ADDENTRY(cdevsw, nchrdev,cdevsw_ALLOCSTART)
+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;
+ }
+ }
-/*
- * Since the bdevsw struct for a disk contains all the information
- * needed to create a cdevsw entry, these two routines do that, rather
- * than specifying it by hand.
- */
+ /* 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;
+}
-static void
-cdevsw_make(struct bdevsw *from)
+int
+cdevsw_add(dev_t *descrip,
+ struct cdevsw *newentry,
+ struct cdevsw **oldentry)
{
- struct cdevsw *to = from->d_cdev;
-
- if (!to)
- panic("No target cdevsw in bdevsw");
- to->d_open = from->d_open;
- to->d_close = from->d_close;
- to->d_read = rawread;
- to->d_write = rawwrite;
- to->d_ioctl = from->d_ioctl;
- to->d_stop = nostop;
- to->d_reset = nullreset;
- to->d_devtotty = nodevtotty;
- to->d_poll = seltrue;
- to->d_mmap = nommap;
- to->d_strategy = from->d_strategy;
- to->d_name = from->d_name;
- to->d_bdev = from;
- to->d_maj = -1;
- to->d_bmaj = from->d_maj;
- to->d_maxio = from->d_maxio;
- to->d_dump = from->d_dump;
- to->d_psize = from->d_psize;
- to->d_flags = from->d_flags;
-}
+ int i ;
+
+ if ( (int)*descrip == NODEV) { /* auto (0 is valid) */
+ /*
+ * Search the table looking for a slot...
+ */
+ for (i = cdevsw_ALLOCSTART; i < nchrdev; i++)
+ if (cdevsw[i] == NULL)
+ break; /* found one! */
+ /* out of allocable slots? */
+ if (i >= nchrdev) {
+ return ENFILE;
+ }
+ } else { /* assign */
+ i = major(*descrip);
+ if (i < 0 || i >= nchrdev) {
+ return EINVAL;
+ }
+ }
+ /* maybe save old */
+ if (oldentry) {
+ *oldentry = cdevsw[i];
+ }
+ if (newentry) {
+ newentry->d_bmaj = -1;
+ newentry->d_maj = i;
+ }
+ /* replace with new */
+ cdevsw[i] = newentry;
+
+ /* done! let them know where we put it */
+ *descrip = makedev(i,0);
+ return 0;
+}
+
+/*
+ * note must call cdevsw_add before bdevsw_add due to d_bmaj hack.
+ */
void
-bdevsw_add_generic(int bdev, int cdev, struct bdevsw *bdevsw)
+cdevsw_add_generic(int bdev, int cdev, struct cdevsw *cdevsw)
{
dev_t dev;
- cdevsw_make(bdevsw);
dev = makedev(cdev, 0);
- cdevsw_add(&dev, bdevsw->d_cdev, NULL);
+ cdevsw_add(&dev, cdevsw, NULL);
dev = makedev(bdev, 0);
- bdevsw_add(&dev, bdevsw , NULL);
+ bdevsw_add(&dev, cdevsw, NULL);
}
int
@@ -192,18 +198,19 @@ bdevsw_module_handler(module_t mod, modeventtype_t what, void* arg)
switch (what) {
case MOD_LOAD:
- cdevsw_make(data->bdevsw);
- if (error = cdevsw_add(&data->cdev, data->bdevsw->d_cdev, NULL))
+ if (error = cdevsw_add(&data->cdev, data->cdevsw, NULL))
return error;
- if (error = bdevsw_add(&data->bdev, data->bdevsw, NULL))
+ if (error = bdevsw_add(&data->bdev, data->cdevsw, NULL)) {
+ cdevsw_add(&data->bdev, NULL, NULL);
return error;
+ }
break;
case MOD_UNLOAD:
- if (error = cdevsw_add(&data->cdev, NULL, NULL))
- return error;
if (error = bdevsw_add(&data->bdev, NULL, NULL))
return error;
+ if (error = cdevsw_add(&data->cdev, NULL, NULL))
+ return error;
break;
}
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 8261bbf370fb..cb29335a3e7a 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
- * $Id: kern_physio.c,v 1.25 1998/03/28 10:33:05 bde Exp $
+ * $Id: kern_physio.c,v 1.26 1998/04/04 05:55:05 dyson Exp $
*/
#include <sys/param.h>
@@ -168,10 +168,10 @@ minphys(bp)
struct buf *bp;
{
u_int maxphys = DFLTPHYS;
- struct bdevsw *bdsw;
+ struct cdevsw *bdsw;
int offset;
- bdsw = cdevsw[major(bp->b_dev)]->d_bdev;
+ bdsw = cdevsw[major(bp->b_dev)];
if (bdsw && bdsw->d_maxio) {
maxphys = bdsw->d_maxio;
@@ -193,11 +193,11 @@ minphys(bp)
struct buf *
phygetvpbuf(dev_t dev, int resid)
{
- struct bdevsw *bdsw;
+ struct cdevsw *bdsw;
int maxio;
- bdsw = cdevsw[major(dev)]->d_bdev;
- if (bdsw == NULL)
+ bdsw = cdevsw[major(dev)];
+ if ((bdsw == NULL) || (bdsw->d_bmaj == -1))
return getpbuf();
maxio = bdsw->d_maxio;
@@ -207,26 +207,6 @@ phygetvpbuf(dev_t dev, int resid)
return getpbuf();
}
-int
-rawread(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
-{
- return (physio(cdevsw[major(dev)]->d_strategy, (struct buf *)NULL,
- dev, 1, minphys, uio));
-}
-
-int
-rawwrite(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
-{
- return (physio(cdevsw[major(dev)]->d_strategy, (struct buf *)NULL,
- dev, 0, minphys, uio));
-}
-
static void
physwakeup(bp)
struct buf *bp;
diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c
index c8bca744b4c7..9cb7ee2d1af7 100644
--- a/sys/kern/subr_diskslice.c
+++ b/sys/kern/subr_diskslice.c
@@ -46,7 +46,7 @@
* from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
* from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
- * $Id: subr_diskslice.c,v 1.45 1998/04/24 11:50:30 obrien Exp $
+ * $Id: subr_diskslice.c,v 1.46 1998/06/06 03:06:55 bde Exp $
*/
#include "opt_devfs.h"
@@ -596,7 +596,7 @@ dsopen(dname, dev, mode, sspp, lp, strat, setgeom, bdevsw, cdevsw)
struct disklabel *lp;
d_strategy_t *strat;
ds_setgeom_t *setgeom;
- struct bdevsw *bdevsw;
+ struct cdevsw *bdevsw;
struct cdevsw *cdevsw;
{
struct dkbad *btp;
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 9c33164e4854..1c98823dd473 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -13,7 +13,7 @@
* bad that happens because of using this software isn't the responsibility
* of the author. This software is distributed AS-IS.
*
- * $Id: vfs_aio.c,v 1.28 1998/04/17 22:36:50 des Exp $
+ * $Id: vfs_aio.c,v 1.29 1998/06/10 10:31:08 dfr Exp $
*/
/*
@@ -973,7 +973,7 @@ aio_qphysio(p, aiocbe)
int rw;
d_strategy_t *fstrategy;
struct cdevsw *cdev;
- struct bdevsw *bdev;
+ struct cdevsw *bdev;
cb = &aiocbe->uaiocb;
fdp = p->p_fd;
@@ -1006,10 +1006,11 @@ aio_qphysio(p, aiocbe)
if (cdev == NULL) {
return -1;
}
- bdev = cdev->d_bdev;
- if (bdev == NULL) {
+
+ if (cdev->d_bmaj == -1) {
return -1;
}
+ bdev = cdev;
ki = p->p_aioinfo;
if (ki->kaio_buffer_count >= ki->kaio_ballowed_count) {