upcoming change to boot0.S (mostly documentation)
Luigi Rizzo
rizzo at iet.unipi.it
Mon Dec 1 07:19:23 PST 2008
Hi,
in the past few days I have been looking at the boot0.S code (the
512 byte version, i386) and found at least a couple of bugs or
"features" worth fixing: one of them is the bogus %si value
passed to the next stage loader, already fixed in head and RELENG_7.
Another bug, already mentioned on the -developers list a few days
ago, is related to the fact that the code might write back the boot
sector on a different disk than the one it was loaded from, thus
trashing the master boot record. A fix for this is upcoming, and
among other things it involves changing the default mode from
'update' to 'noupdate'.
Part of the problem with these bugs was/is that the existing boot0.S
code is extremely difficult to follow, because it employs all sort
of clever tricks to save memory.
So, I have tried to annotate it as much as possible to make
it easier to change or reconfigure it in the future, and
reduce the risk of introducing bugs because of side effects of
the changes. A preview of what will be committed is at
http://info.iet.unipi.it/~luigi/FreeBSD/20081201-boot0.S
While the diff is very large, it is 95% comments.
The functional changes are extremely limited, as follows
(all can be easily reverted if there is demand):
+ make 'noupdate' the default mode of operation (this is
forced in the Makefile). It can be reverted back to 'update'
using boot0cfg.
+ never overwrite the boot sector if the BIOS-supplied drive
number is overridden by the 'setdrv' option. This was a
potential source of trouble because we might write (and trash
the MBR) on a different driver.
+ do not check for a valid drive number, allowing boot0 to be used
even when the BIOS does 'floppy emulation' on a flash drive.
Adding the check back requires 4 bytes.
+ force CHS mode ('nopacket') when loaded from a floppy unit.
Removing the change saves 4 bytes.
Because of some minor code rearrangements, I also managed to make
room for a 'WIN' string (3 extra bytes) to be printed for certain
FAT32 partitions, and for recognising an additional FAT16 partition
as DOS (2 extra bytes).
Right now the code uses the full 512 bytes (the SIO version
is slightly shorter) so the changes need to fit in the memory
budget -- this is why i mention the cost of each of the options above.
cheers
luigi
More information about the freebsd-current
mailing list