Subject: Re: Dumping autoconf info from DDB
To: None <mouse@Rodents.Montreal.QC.CA,>
From: Chris Torek <torek@BSDI.COM>
List: tech-kern
Date: 02/08/2000 00:17:40
>As for boot.default, the big problem with it, it seems to me, is how
>and when it's loaded.  For it to be useful for this it has to be done
>before device configuration, and at that point, how can we get at the
>device it's stored on?

The file is in /etc: /etc/boot.default, and it goes with
/etc/boot.define, which defines that, for instance, "pci_burst_size"
is parameter #9 on the "ncr" devices.  Thus, if you say:

	-parm ncr0 pci_burst_size=4

in /etc/boot.default (or type this command at the boot: prompt),
the boot program knows to add a "parameter adjustment" that says
"on ncr0, set parameter 9's value to 4".  The driver then calls
getbootparam(), passing in the "struct device *" (which identifies
this as ncr0) and the "token" 9 (NCR_PCI_BURST_SIZE, #define'd
in the driver to the same value as appears in the MD boot.define
file).  If there is a value, getbootparam() returns the boot
parameter, else it returns NULL.

A convenience function called getparm() does the getbootparam and
returns either its value, or a default value:

	if (getparm(sc->sc_xname, PARM4_ESP_SLOWCABLE, 0)) {
		... set ESP scsi "slow cable" mode
	spia.spia_disconnect = getparm(sc->sc_xname, PARM4_ESP_DISCONNECT, ~0)
		/* by default all targets are allowed to disconnect */
	if (ESP_IS_FAS(sc->sc_esptype))
		spia.spia_fast = getparm(sc->sc_xname, PARM4_ESP_FAST, ~0);
			/* by default all targets are fast SCSI */
	if (sc->sc_esptype != ESP100)
		spia.spia_sync = getparm(sc->sc_xname, PARM4_ESP_SYNC, ~0);
			/* by default all targets are synchronous */
	if (ESP_DOESTAGS(sc->sc_esptype))
		spia.spia_tags = getparm(sc->sc_xname, PARM4_ESP_TAGS, 0);
			/* by default all targets have tag q OFF (broken!) */
	... etc

Given that /boot already has to open and read /bsd (or whatever the
kernel is named), it is easy enough for it to open and read a few
files in /etc.  This stuff even "just works" over NFS.

For dynamically-added drivers, you would probably want user programs
to read /etc/boot.define and /etc/boot.default, and supply "modified"
locator values as needed.