Subject: The USERCONFIG saga...
To: None <port-i386@NetBSD.ORG>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 03/05/1996 18:15:31
So, after getting bored at another meeting, I decided to hack
bus-independence into the "userconfig" stuff, like I promised :-)
This was easy to glue into ISA, since isascan() calls the device match
routines ... I still need to nicely glue it into subr_autoconf.c, but
that should be easy. Any bus that calls match routines directly will
need to add the glue, similar to how I did ISA...
Anyhow, the bus-independence is achieved by a table of locator names an
"types" (expressed in decimal or hex, or skip it altogether when
asking...). This is the data structure:
/*
* Locator description table, used by userconfig, filled in by bus drivers.
*/
struct loctbl {
int lt_nentries; /* number of entries in names array */
char **lt_names; /* locator names */
int *lt_types; /* locator types */
};
/* values for lt_types */
#define LT_SKIP 0 /* skip this locator */
#define LT_DECIMAL 1 /* value expressed in decimal */
#define LT_HEX 2 /* value expressed in hex */
...and this is what ISA's looks like:
#ifdef USERCONFIG
/*
* Locator table information.
*/
static char *isa_loctbl_names[] = { "port", "iosize", "iomem", "memsize",
"irq", "drq" };
static int isa_loctbl_types[] = { LT_HEX, LT_SKIP, LT_HEX, LT_SKIP,
LT_DECIMAL, LT_DECIMAL };
static struct loctbl isa_loctbl = { 6, isa_loctbl_names, isa_loctbl_types };
#endif /* USERCONFIG */
The ISA code invokes it like this (snippet from my isascan()):
#ifdef USERCONFIG
if (boothowto & RB_USERCONFIG) {
if (userconfig(parent, cf, &isa_loctbl) == 0) {
free(dev, M_DEVBUF);
return;
}
}
#endif
ia.ia_iobase = cf->cf_loc[0];
ia.ia_iosize = 0x666;
[ . . . ]
Yah, gotta actually make the bootblock understand RB_USERCONFIG :-)
Anyhow, it still doesn't implement mouse menus, etc ( :-), but it works,
and is scalable to N different bus types...
Note, that it can't edit locators for cloned (e.g. sd* ...) devices
because cloned devices share common "cfdata" ... there's not really an
easy way to get around this, so I just chose to be lazy (rather than
restructure the entire autoconfiguration system :-).
Autoconfiguration output attached below...
--------------------------------------------------------------------------
Jason R. Thorpe thorpej@nas.nasa.gov
NASA Ames Research Center Home: 408.866.1912
NAS: M/S 258-6 Work: 415.604.0935
Moffett Field, CA 94035 Pager: 415.428.6939
----- snip -----
NetBSD 1.1A (ANTIE) #437: Tue Mar 5 18:26:06 PST 1996
thorpej@antie:/work/netbsd/src/sys/arch/i386/compile/ANTIE
CPU: i486DX (486-class CPU)
real mem = 16384000
avail mem = 13885440
using 225 buffers containing 921600 bytes of memory
isa0 (root)
userconfig: locators for device `ed0 at isa0':
port=0x280 iomem=0xd0000 irq=9 drq=<wildcarded>
userconfig: probe for device `ed0 at isa0'? y/[n] yes
userconfig: edit locators for device `ed0 at isa0'? y/[n] yes
userconfig: enter new locator values, <return> for no change
userconfig: ed0 at isa0: port=0x280 ? 300
userconfig: ed0 at isa0: iomem=0xd0000 ?
userconfig: ed0 at isa0: irq=9 ? 4
userconfig: ed0 at isa0: drq=<wildcarded> ?
userconfig: locators for device `ed0 at isa0':
port=0x300 iomem=0xd0000 irq=4 drq=<wildcarded>
userconfig: probe for device `ed0 at isa0'? y/[n] yes
userconfig: edit locators for device `ed0 at isa0'? y/[n] yes
userconfig: enter new locator values, <return> for no change
userconfig: ed0 at isa0: port=0x300 ? 280
userconfig: ed0 at isa0: iomem=0xd0000 ?
userconfig: ed0 at isa0: irq=4 ? 9
userconfig: ed0 at isa0: drq=<wildcarded> ?
userconfig: locators for device `ed0 at isa0':
port=0x280 iomem=0xd0000 irq=9 drq=<wildcarded>
userconfig: probe for device `ed0 at isa0'? y/[n] yes
userconfig: edit locators for device `ed0 at isa0'? y/[n] no
ed0 at isa0 port 0x280-0x29f iomem 0xd0000-0xd3fff irq 9: address 00:00:c0:94:f6:72, type WD8013WC (16-bit) aui
userconfig: locators for device `npx0 at isa0':
port=0xf0 iomem=<wildcarded> irq=13 drq=<wildcarded>
userconfig: probe for device `npx0 at isa0'? y/[n] yes
userconfig: edit locators for device `npx0 at isa0'? y/[n] no
npx0 at isa0 port 0xf0-0xff: using exception 16
userconfig: locators for device `vt0 at isa0':
port=0x60 iomem=<wildcarded> irq=1 drq=<wildcarded>
userconfig: probe for device `vt0 at isa0'? y/[n] yes
userconfig: edit locators for device `vt0 at isa0'? y/[n] no
vt0 at isa0 port 0x60-0x6f irq 1: generic, 80 col, color, 8 scr, mf2-kbd, [R3.32]
userconfig: locators for device `lms0 at isa0':
port=0x23c iomem=<wildcarded> irq=5 drq=<wildcarded>
userconfig: probe for device `lms0 at isa0'? y/[n] yes
userconfig: edit locators for device `lms0 at isa0'? y/[n] no
lms0 at isa0 port 0x23c-0x23f irq 5
userconfig: locators for device `fdc0 at isa0':
port=0x3f0 iomem=<wildcarded> irq=6 drq=2
userconfig: probe for device `fdc0 at isa0'? y/[n] yes
userconfig: edit locators for device `fdc0 at isa0'? y/[n] no
fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
eisa0 (root)
ahb0 at eisa0 slot 1 irq 11: Adaptec AHA-1742A
scsibus0 at ahb0
sd0 at scsibus0 targ 0 lun 0: <QUANTUM, PD1225S, 3142> SCSI2 0/direct fixed
sd0: 1169MB, 2448 cyl, 14 head, 69 sec, 512 bytes/sec
sd1 at scsibus0 targ 1 lun 0: <QUANTUM, PD1225S, 3142> SCSI2 0/direct fixed
sd1: 1169MB, 2448 cyl, 14 head, 69 sec, 512 bytes/sec
sd2 at scsibus0 targ 2 lun 0: <TOSHIBA, MK438FB, 5157> SCSI2 0/direct fixed
sd2: 859MB, 1980 cyl, 11 head, 80 sec, 512 bytes/sec
sd3 at scsibus0 targ 3 lun 0: <TOSHIBA, MK438FB, 5157> SCSI2 0/direct fixed
sd3: 859MB, 1980 cyl, 11 head, 80 sec, 512 bytes/sec
biomask 840 netmask a40 ttymask a62
changing root device to sd0a