Subject: early results of i386 boot block examination.
To: None <>
From: Todd Whitesel <>
List: tech-install
Date: 10/07/1998 01:50:01
(If this should move to port-i386, just give the word.)

In a former life I spent a fair amount of time developing debug ROMs for
various chips, so I decided to dive into the i386 boot blocks and see if
I could answer some of the questions that were left hanging in tech-install
last month. I'm still snooping, but I can say at least this much:

1. We only support the first floppy, because we blast the drive number to 0
	once we determine that it is not a hard drive. There's a cute XXX
	comment next to the code.

2. The number you give to "boot sd" or "boot wd" is just a BIOS hard drive
	device number. So booting an unwired kernel from drives past the
	first couple definitely puts you at the mercy of the device mapping.

3. When we are inside a DOS partition, we rely on the MBR in block 0 to tell
	us where our partition begins. The BIOS only gives us a device number.
	The phony MBR partition table in our own bootblock enables this same
	code to "just work" when we are not booting from inside a partition.
	(That is, we read block 0 and it is us.)

3a. For large disk support I think we should consider imprinting our boot
	block with the absolute sector we wrote it to, so it does not read
	block 0 just to find its own partition. We will still have problems
	with the bootblock wanting to be in the first 1024 cylinders so that
	the various DOS-compatible boot selectors can find us. A small "boot
	floppy" partition in cylinder 0 or 1 would deal with it, though.

4. After the first stage that loads just enough to get us into protected mode
	and C code, we do all further disk access through a set of routines
	that fetch the geometry of the device and automatically convert from
	absolute sectors into C/H/S. See sys/arch/i386/stand/lib/biosdisk_ll.c
	(This code is even present in 1.3.2 !)

Todd Whitesel
toddpw @