Subject: Re: Two NetBSDs on one (i386) drive
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 12/19/2001 17:14:33
How many layers of bootstrap would you like sir?

As far as I can tell:

1) The BIOS loads disc sector zero (mbr) to address 0x7c00 then jumps to
it.
   Disc number in dl.

2) The mbr code copies itself elsewhere (0x600) locates the active
partition,
   reads its first sector (pbr) to address 0x7c00 then jumps to it.
   Disc number in dl

3) The pbr code locates the first active netbsd partition (which it
assumes
   it was loaded from) and does a multi-sector read of the same area.
   It jumps to an address outside the first sector.

4) The netbsd boot2 code reads a list of disc sectors (generated by
installboot)
   into memory and jumps to the entry point (maybe the start)

5) We are now in the 'boot' program, which prompts the user for the name
of
   the kernel etc.

6) The kernel in entered.

The mbr code is lurking in sbin/fdisk/mdr[_bootsel]/mbr[_bootsel].S
The pbr is in lib/crt/bootsect/start_bootsect.S

There seems to be limited space in the start_bootsect.S pbr code.  More
space
could be made available by removing the code that supports BIOS that
have broken
LBA support.  (The mbr_boolsect code doesn't do this check.)

There is no real reason why filesystems in 'dos extended' partitions
should not
be bootable.  You just need mbr and pbr (and OS) code that will scan
them.

Writing and testing mbr/pbr code is definitely not for the boys, needs a
real man :-)

	David