Boot Flow

You might also like

You are on page 1of 1

# FreeBSD boot process

- x86 - 3 stage MBR partitioned - FreeBSD boot0 multi-boot loader


- boot1
- boot2
- loader - loads the FreeBSD Kernel
# BIOS
- power button - sets register to specific values
- Instruction Pointer(PC) - set to 32-bit - 0xfffffff0
- cr0 32-bit control register - at reboot reset to 0 - hence boots in 16-bit real
mode
- to be backward compatible 32-bit protected mode is enabled at later point
- the boot process relies on the services provided by the BIOS, and the BIOS itself
works in legacy, 16-bit code

first 512 bytes has MBR


- int 0x19 loads MBR at memory 0x7c00
- Partition table starts at offset 0x1be - 4 records of 16 bytes each
- 1 byte filesystem type
- 1 byte bootable flag
- 6 byte descriptor in CHS format
- 8 byte descriptor in LBA format
- 0xaa55 signature
- boot0.S is loaded as is. text section loaded at 0x600
- boot0 --> 0x7c00
- boot0.S --> 0x600
- si <-- 0x7c00
- di <-- 0x600
- 512 bytes are copied from si to di as 256-word. 0x600(1536) + 512 = 0x800 and
0x7c00(32,256) + 512 = 0x7e00
- bp <-- di, bp --> 0x800
- cl <-- 8
- stosw is excuted 8 times 8 * 2 bytes -> 16 bytes(8 words)
- di <-- 0x800 + 16 --> 0x810
- 0x800 - 0x80f (2048 - 2063) is cleared and left for fake partition table to write
back updated MBR back to disk
- sector(CHS) is assigned 1 and jump to main code from relocated code
- 0x475 - number of drives present is written to this address

You might also like