Subject: Re: 32 bit dev_t, Revision 3
To: None <cgd@pa.dec.com, tech-kern@NetBSD.ORG>
From: Chris Torek <torek@BSDI.COM>
List: tech-kern
Date: 01/13/1998 12:51:35
>> Can we change bdevsw/cdevsw to be struct Xdevsw *Xdevsw[]; ...
>... at least some parts of it are good things to do (and have
>precendent in e.g. BSDI if i recall correctly ...
Just FYI, we have:
- a combined "devsw" (no separate b-vs-c; a device can be used
as a block device iff it has a strategy routine)
- 32-bit dev_t split up as {
12 bits major
20 bits minor {
10 bits "unit"
10 bits "subunit"
}
}
(interpretation of minor is left to the device itself; disks and
tapes use the subunit while ttys are generally just sequential);
ls -l shows <major,unit,subunit> (even on ttys).
- new macros (make the obvious changes to the old ones):
#define dv_unit(x) ((int)(((x) >> 10) & 0x3ff))
#define dv_subunit(x) ((int)((x) & 0x3ff))
#define dv_makedev(x,y,z) ((dev_t)(((x)<<20) | ((y) << 10) | (z)))
- the devsw struct looks like this [fn params squished out for space]:
struct devsw {
struct cfdriver *d_cd;
int (*d_open)();
int (*d_close)();
int (*d_read)();
int (*d_write)();
int (*d_ioctl)();
int (*d_select)();
vm_offset_t (*d_mmap)();
void (*d_strategy)();
int (*d_dump)();
int (*d_psize)();
#define D_TAPE 1
#define D_DISK 2
#define D_TTY 3
int d_type;
void (*d_stop)();
};
(The d_cd field can be left NULL and is not used for all that
much; the others are what you get when you combine bdevsw and
cdevsw.)
- Each port has its own devsw[], in a template file in
sys/${MACHINE}/conf/ioconf.c.${MACHINE}. "config" writes
an appropriate ioconf.c for the configuration, per directives
that I am pretty sure I described here before (%CONFIG, %DECLSW,
%DEVSW, %IFSEL).
- The ioconf.c template contains the iskmemdev and iszerodev
routines. (The "securelevel" disk test uses d_cd->cd_class
to test for disks; maybe should use d_type.)
- The ioconf.c template also contains the compat code for translating
old 16-bit dev_t's. All ("both" :-) ) our existing ports had
major 0==console and still have 0==console, so a dev_t is "new" if
(new)major(dev) != 0; the translation from old to new is done
with `switch' (since old disk and tape dev_t's need extra
translation for unit+subunit).
Chris