findroot() sets booted* variables after checking for 4 structs

​​​​these structs maybe represent 4 methods of booting/possible root device candidates

All the struct below are assigned value by this functionlookup_bootinfo(int type) with particular integer value assigned to device category. they are then Checked with Null object

  1. struct btinfo_rootdevice *biv;

    XXXDon't know what device it is maybe bios has recognised root device,can bios even do that
    it has following conditions to assign booted* variables value. Also bootspec is ONLY set in this case after condition that devname field is equal to '/0'.

    • devclass of iterating device should be DV_DISK
    • contents cf_name field of iterating device should be same as contents of devname field of biv for length of cf_name && length of devname field of biv after removing 'a' should be same as unit of device iterating.

    findroot returns if dv is not Null. or if devname field is equal to '/0'.

  2. struct btinfo_bootdisk *bid;

    Scans all disk devices ,if floppy disk device , and not hard drive and bios number matches then it sets booted_device to bid, scans and finds all disk but chooses lower disk number. makes assumption lowest number disk will be boot disk

  3. struct btinfo_bootwedge *biw;

    it scans all the devices and finds all the devices with matching boot info but uses only the first one found.

  4. struct btinfo_biosgeom *big;

    Last case to run checks for CD-ROM boot disk. it assumes biosdev will be larger or equal to maximum number of supported disk drive ie cd device will always be assigned number at last.
    checks all the devices whooses biosdev is greater than 0x80 + number of maximun hard disk supported. first cd device is set as booted_device

device_t booted_device

const char *booted_method;

This is never refferenced in setroot or in x86_autoconf. although set in findroot with booted_device

baduck I believe this is just set for debugging purposes. We can use it for consistency checks in the tests, however.

int booted_partition;

  • btinfo_rootdevice : int value of 'a' is subtracted from devicename+one integer of devname field.
  • btinfo_bootdisk *bid : same as partition value of boot disk
  • btinfo_bootwedge *biw : it is 0 or null
  • btinfo_biosgeom *big: it is 0

daddr_t booted_startblk;

It is only set after booted_nblks, if 0 then it is null(in findroot()).

uint64_t booted_nblks;

set to 0 in all cases except when btinfo_bootwedge *biw is found in that case is set to wedges's field nblks.

char *bootspec;

only set in case of btinfo_rootdevice, contents are same as devname of root device

const char *rootspec;

rootspec is a interface variable betweeen config and the kernel. following lines in the config file puts them in rootspec.

​​​​config netbsd root on ? type ?  
​​​​config netbsd root on sd0a type ?

this tells us that it is set by config file. the protocol between config and kernel sets this variable using directives defined.
it is set by file in compile directory sys/arch/amd64/compile/GENERIC/swapnetbsd.c to NULL

const char *dumpspec;

device_register(device_t dev, void *aux)

called from autoconfig subroutines's config_attach_internal.
it calls one function for isa and one for pci. this function also sets booted_device and booted_method(this is set to "device/register"). First device_isa_register is called and then device_pci_register is called , priority is always given to isa device to be set for booted_device.
device_pci_register returns device_t dev only if the dev is a network interface device all other cases return NULL. Same is with device_isa_register.

device_t rootdv;

rootdv is not a output variable but a intermediatary variable helps with assignment of device to root_device.

dev_t rootdev; /* root device */

it is same as root_devive but for disks

device_t root_device; /* device equivalent to above */

dev_t dumpdev; /* dump device /
dev_t dumpcdev; /
dump device (character equivalent) /
long dumplo; /
offset into dumpdev /
int dumpsize; /
size of dump in pages */