# Questions Gsoc ## Documentation 1. [ biv->devname[len] - '0' == device_unit(dv)](https://nxr.netbsd.org/xref/src/sys/arch/x86/x86/x86_autoconf.c#371) can you elaborate it a litlle bit. @baduck: the `- '0'` "trick" converts from a character code for a digit to the value of a digit. In C `char` is actually an integer type, in fact the smallest interger a cpu can represent. So you can do artimethic on it. Character constants are effectively integer contants. In ASCII the digits are consecutive '0', '1', '2', ... '9' with character code '48' for '0' through '58' for '9'. So you could write the above expression as `biv->devname[len] - 48 == device_unit(dev)` but then people would wonder what the magic number `48` stands for. So the idiom of using the character constant `0` was adopted. That code fragment is a bit fishy, however. It assumes that the devname field only ever has a single trailing digit. I.e. that we never boot from, say, `sd10` or higher. This is related to the device naming protocol defined in the Torek paper. Device names are of the form *\<driver-name>\<unit-number>.* Device driver names consist of letters only. E.g. `sd0` is the first unit attached to the `sd` driver, `sd10` is the 11th unit attached to the `sd` driver. Three lines below it does the same conversion from partition letter `a`-`z` to partition number by substracting the character constant `'a'`. Note: this code fragment make the assumption that `biv->devname` has the format *\<driver-name>\<unit-digit>\<partition-letter>*. This is something that we should document and base test cases on. XXXdoc, XXXtestcase This is an excellent catch! I would likely have missed this detail if you hadn't asked! 2. is this correct wording [link](https://nxr.netbsd.org/xref/src/sys/arch/x86/x86/x86_autoconf.c#isaboot)` 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.` for ` * No booted device found; check CD-ROM boot at last. 497 * 498 * Our bootloader assumes CD-ROM boot if biosdev is larger 499 * or equal than the number of hard drives recognized by the 500 * BIOS. The number of drives can be found in BTINFO_BIOSGEOM 501 * here. For example, if we have wd0, wd1, and cd0: 502 * 503 * big->num = 2 (for wd0 and wd1) 504 * bid->biosdev = 0x80 (wd0) 505 * bid->biosdev = 0x81 (wd1) 506 * bid->biosdev = 0x82 (cd0)` @baduck: yes, this is correct. i.e. cd device will always be assigned the last BIOS "disk" number. Note that code assumes that we always boot from the first CD device. And that the first autoconfigured CD device is the first CD device that the BIOS found. 3. does this part of [device_isa_register](https://nxr.netbsd.org/xref/src/sys/arch/x86/isa/isa_machdep.c#341) needs to be documented looks short but is confusing. @baduck: Let's not look into device_register(). I will write a paragraph documenting what goes on. 4. does this code is in good direction this produces output for bootpath ,console only I didn;t write print for many because I thought info for those cases were not relevant , I also couldn't understand structure of boot info being passed why there are type repeating in boot info. also boot disk didn't produce any output. `void aprint_bootinfo(void) { int i; struct btinfo_common \*bic; aprint_normal("bootinfo:"); bic = (struct btinfo_common *)(bootinfo.bi_data); for (i = 0; i < bootinfo.bi_nentries; i++) { // if (bic->type >= 0 && bic->type < __arraycount(btinfo_str)) // aprint_normal(" %s, %d ", btinfo_str[bic->type],bic->type); // else // aprint_normal(" %d", bic->type); switch (bic->type) { case BTINFO_BOOTPATH: ; struct btinfo_bootpath *bip = lookup_bootinfo(BTINFO_BOOTPATH); aprint_normal("bootpath %s ",bip->bootpath); break; case BTINFO_ROOTDEVICE: ; struct btinfo_rootdevice *bird = lookup_bootinfo(BTINFO_ROOTDEVICE); aprint_normal("rootdevice %s ",bird->devname); break; case BTINFO_BOOTDISK : ; struct btinfo_bootdisk *bibd = lookup_bootinfo(BTINFO_BOOTDISK); aprint_normal("bootdisk %s ",bibd->label.packname); break; case BTINFO_NETIF: ; struct btinfo_netif *binetif = lookup_bootinfo(BTINFO_NETIF); aprint_normal("network interface \n %s ",binetif->ifname); break; case BTINFO_CONSOLE: ; struct btinfo_console *bicon = lookup_bootinfo(BTINFO_CONSOLE); aprint_normal("console %s ",bicon->devname); break; case BTINFO_BIOSGEOM: ; // struct btinfo_bootgeom *bigeom = lookup_bootinfo(BTINFO_BIOSGEOM); aprint_normal("geomet "); break; case BTINFO_SYMTAB: ; // struct btinfo_symtab *bisystab = lookup_bootinfo(BTINFO_SYMTAB); aprint_normal("symbol tab "); break; case BTINFO_MEMMAP: ; // struct btinfo_memmap *bimemmap = lookup_bootinfo(BTINFO_MEMMAP); aprint_normal("mem map "); break; case BTINFO_BOOTWEDGE: ; // struct btinfo_bootwedge *bibw = lookup_bootinfo(BTINFO_BOOTWEDGE); aprint_normal("bootwedge "); break; default: aprint_normal("no case "); break; } bic = (struct btinfo_common *) ((uint8_t *)bic + bic->len); } aprint_normal("\n"); } `