Annotation of wikisrc/how_netbsd_boots_on_x86.mdwn, revision 1.2

1.2     ! schmonz     1: **Contents**
        !             2: 
        !             3: [[!toc]]
        !             4: 
        !             5: ##  Stage 0: Master Boot Record
        !             6: 
        !             7:   * MBR source: `sys/arch/i386/stand/mbr/mbr.S`
        !             8:   * MBR binaries: `/usr/mdec/mbr_*`
        !             9:   * Error messages: 
        !            10: 
        !            11:     * "Error x" 
        !            12:     * "No active partition" - self-explanatory 
        !            13:     * "Disk read error" 
        !            14:     * "No operating system" - PBR magic number was wrong 
        !            15:     * "Invalid CHS read" - CHS vs LBA check selected LBA reads, but BIOS does not support them 
        !            16: 
        !            17: MBR is read by the BIOS and then validated (checked for magic number 0xaa55 at
        !            18: the end). If validation fails, BIOS may print evil error message and/or try
        !            19: next boot device; otherwise, BIOS passes control to MBR.
        !            20: 
        !            21: Unless it was compiled with `NO_BANNER`, MBR displays its banner: "NetBSD MBR
        !            22: Boot". Next, it checks if CHS or LBA addressing must be used in further BIOS
        !            23: I/O calls. Since partition table entry stores both linear and CHS address,
        !            24: linear address is computed from CHS address, and if it matches stored linear
        !            25: address - MBR will use CHS addressing. LBA addressing will be tried otherwise,
        !            26: even if it is not supported by BIOS.
        !            27: 
        !            28: PBR is then loaded from 1st sector of active partition (or, if boot selector
        !            29: was compiled into this MBR, it may be loaded from another partition or disk).
        !            30: 
        !            31: ##  Stage 1: Partition Boot Record, bootxx
        !            32: 
        !            33:   * PBR source: `sys/arch/i386/stand/bootxx/pbr.S`
        !            34:   * bootxx source: `sys/arch/i386/stand/bootxx/bootxx.S`
        !            35:   * combined PBR+bootxx binaries: `/usr/mdec/bootxx_*`
        !            36:   * Error messages: 
        !            37: 
        !            38:     * '2' or "Disk read" 
        !            39:     * 'B' or "Not a bootxx image" - phase 1 bootstrap's magic number was wrong 
        !            40:     * 'P' or "No NetBSD partition" 
        !            41:     * 'L' or "Invalid CHS read" - see above 
        !            42: 
        !            43: PBR loads phase 1 bootstrap (bootxx) from next 15 sectors on disk, validates
        !            44: and runs it.
        !            45: 
        !            46: bootxx displays its banner: `NetBSD/(machine) (filesystem) Primary Bootstrap`
        !            47: and tries to load phase 2 bootstrap (boot2) from several locations:
        !            48: 
        !            49:   * start of MBR partition; or 
        !            50:   * start of MBR partition + RAIDframe offset; or 
        !            51:   * start of partition 'a' in disklabel. 
        !            52: 
        !            53:   * bootxx error messages: 
        !            54: 
        !            55:     * "Boot failed (errno <...>): <...>" 
        !            56:     * All further messages are printed by boot2. For example, a single "0" and no other messages on PC console means that boot2 has autodetected and is using serial console. 
        !            57: 
        !            58: ##  Stage 2
        !            59: 
        !            60:   * boot2 source: `sys/arch/i386/stand/boot/`
        !            61:   * boot2 binary: `/boot`
        !            62: 
        !            63: ##  Glossary
        !            64: 
        !            65: BIOS
        !            66: 
        !            67:      Basic Input-Output System 
        !            68: MBR
        !            69: 
        !            70:      Main Boot Record, stored at LBA 0 
        !            71: PBR
        !            72: 
        !            73:      Partition Boot Record, stored in first sector of bootable partition 
        !            74: CHS
        !            75: 
        !            76:      Cylinder, Head, Sector addressing 
        !            77: LBA
        !            78: 
        !            79:      Linear Block Address[ing] 
        !            80: 
        !            81: ##  See also
        !            82: 
        !            83:   * [Making NetBSD Multiboot-Compatible](http://onlamp.com/pub/a/bsd/2007/03/01/inside-multiboot.html)
        !            84: 
        !            85: ##  References
        !            86: 
        !            87:   * [boot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?boot+8+NetBSD-current)
        !            88:   * [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)
        !            89:   * [installboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8+NetBSD-current)
        !            90:   * [mbr(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mbr+8+NetBSD-current)
        !            91: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb