Home | History | Annotate | Download | only in mbr
History log of /src/sys/arch/i386/stand/mbr/mbr.S
RevisionDateAuthorComments
 1.24  01-Aug-2023  andvar fix various typos in comments.
 1.23  08-Dec-2010  jakllsch Remove now-incorrect detail about the link address from comment.
 1.22  19-Nov-2009  dsl branches: 1.22.4;
Move code for outputting directly to the serial port into message.S
Allows it to be enabled for other parts of the boot sequence.
 1.21  18-Nov-2009  dsl Adjust the way references to the unrelocated addresses are done so
that the address doesn't have to be passed in.
Adjust #ifdef so that only one item is checked - at it is the one used.
 1.20  28-Nov-2008  dsl branches: 1.20.4;
#undef ACTIVE (not ENTER) since that is the variable we defined just above.
Noted on port-i386 by Gao Ya'nan.
 1.19  28-Apr-2008  martin branches: 1.19.6; 1.19.8;
Remove clause 3 and 4 from TNF licenses
 1.18  06-Feb-2008  dsl branches: 1.18.6; 1.18.8; 1.18.10;
Load 'default keycode' into correct byte so that 'boot on timeout' works.
Fixes PR/37960.
While here save another byte.
 1.17  25-Jan-2008  dsl Somehow this file won some extra tab characters, nuke them to align the code.
 1.16  19-Jan-2008  dsl Add two new versions of the mbr code that directly access a serial port.
'mbr_com0' assumes the BIOS has initialised the baud rate (etc)
'mbr_com0_9600' initialises the rate to 9600
Both have the functionality from 'mbr_ext' (ie they can boot from an
extended partition).
As compiled, the io_address for the serial port is taken from BIOS data.
(this should keep tls@ happy!)
 1.15  08-Jan-2008  dsl The test for the 0xaa55 at the end of an extended partition pbr has always
been incorrect (and checked the end of the mbr - which always suceeds).
Rather than fixing the text, just delete it (saving 8 bytes from mbr_ext).
 1.14  10-Apr-2007  dsl branches: 1.14.14; 1.14.20; 1.14.26;
Save a byte from the mbr code (by using lret not ljmp).
 1.13  11-Dec-2005  christos branches: 1.13.26; 1.13.30; 1.13.32;
merge ktrace-lwp.
 1.12  12-Sep-2004  dsl branches: 1.12.12;
Need %ah == 0 (not 0xff) in order to find the correct partition table entry
when simulating a key press in the non-interactive mbr code.
Fixes bug introduced in rev 1.10 - older versions worked because %ah
happened to be 0!
Fixes PR bin/26919
 1.11  05-Sep-2004  dsl Save 2 more bytes (by adjusting the ERR_NO_LBA setup).
Use up all the space by adding a short banner message.
'Fn diskn' for bootsel and 'NetBSB MBR boot' for the non-bootsel code.
 1.10  01-Sep-2004  dsl Remove the functionality added in rev 1.7.
With no menu items the mbr_bootsel code will wait for the timeout (default
10 seconds) and then boot the default device - usually the active partition.
Forcing the 'active' partition was wrong - jmmv has a system which needs
to boot from hd1 where hd0 has no mbr partition info.
I suspect the problem I though rev 1.7 fixed was actually caused by
disklabel copying sector zero of the disk to sector zero of the partition!
Gains another 9 bytes of free space, mbr_bootsel now has 20 free bytes.
 1.9  14-Aug-2004  dsl I challenged mycroft to optimise this code - and he found a spare byte...
 1.8  04-Jul-2004  mycroft Change MAXDRV to 0x8f, to fix El Torito booting problems on some machines.
See PR 22647.
 1.7  08-May-2004  dsl Make mbr_bootsel boot active partition if/when no menu items are output.
Stops users sitting in front of a system that is waiting for a keypress.
Just don't ask how I added more functionality AND got an extra 7 free bytes!
 1.6  23-Apr-2004  dsl Put the 'mbr has bootselect table' marker into all versions of the mbr code.
Having the table in the 'standard' mbr allows fdisk to write in bootsel
menu items and only ask about updating the mbr code before exit.
Sysinst validates that the mbr code contains the bootselect table for
all the mbr code variants it reads - because it might want to write the table
and doesn't really want to make the validation dependant on what it is
going to do later.
Fixes install/25235, but sysinst needs some changes (like reporting the
failure to write the mbr) before the pr itself is closed.
 1.5  22-Mar-2004  lukem branches: 1.5.2;
Move mbr_bootsel from offset 404 to offset 400 in struct mbr_sector to
leave 4 bytes for the Windows NT Drive Serial Number (DSN) at 440-443
(as mbr_sector.mbr_dsn).

Ensure that all the MBR & PBR code reserves space for mbr_sector.mbr_dsn.

Leave the bootsel magic number at 444-445 as mbr_sector.mbr_bootsel_magic
(instead of mbr_sector.mbr_bootsel.mbrbs_magic), but use 0xb5e1 (MBR_BS_MAGIC)
instead of 0xaa55 (MBR_MAGIC) to indicate that this change has occurred.

Rework MBR_BS_NEWMBR to mean "mbr_bootsel has moved to 400".

Modify fdisk(8) to automatically relocate the mbr_bootsel from 404 to 400
if mbr_bootsel_magic is the old value (0xaa55), and unset MBR_BS_NEWMBR
to flag that new mbr_bootsel code must be used if updating the MBR.


These changes fixes a problem where Windows 2000 or Windows XP would corrupt
the last 3 bytes + NUL of MBR partition 3's bootsel name if the bootsel name
was 5 characters long, replacing bytes 6-9 with the DSN.
Also, by explicitly reserving the space for the DSN we prevent problems in the
future if non bootsel MBR or PBR code had other information at bytes 440-443.
 1.4  08-Oct-2003  lukem Overhaul MBR handling (part 1):

<sys/bootblock.h>:
* Added definitions for the Master Boot Record (MBR) used by
a variety of systems (primarily i386), including the format
of the BIOS Parameter Block (BPB).
This information was cribbed from a variety of sources
including <sys/disklabel_mbr.h> which this is a superset of.

As part of this, some data structure elements and #defines
were renamed to be more "namespace friendly" and consistent
with other bootblocks and MBR documentation.
Update all uses of the old names to the new names.

<sys/disklabel_mbr.h>:
* Deprecated in favor of <sys/bootblock.h> (the latter is more
"host tool" friendly).

amd64 & i386:
* Renamed /usr/mdec/bootxx_dosfs to /usr/mdec/bootxx_msdos, to
be consistent with the naming convention of the msdosfs tools.

* Removed /usr/mdec/bootxx_ufs, as it's equivalent to bootxx_ffsv1
and it's confusing to have two functionally equivalent bootblocks,
especially given that "ufs" has multiple meanings (it could be
a synonym for "ffs", or the group of ffs/lfs/ext2fs file systems).

* Rework pbr.S (the first sector of bootxx_*):
+ Ensure that BPB (bytes 11..89) and the partition table
(bytes 446..509) do not contain code.
+ Add support for booting from FAT partitions if BOOT_FROM_FAT
is defined. (Only set for bootxx_msdos).
+ Remove "dummy" partition 3; if people want to installboot(8)
these to the start of the disk they can use fdisk(8) to
create a real MBR partition table...
+ Compile with TERSE_ERROR so it fits because of the above.
Whilst this is less user friendly, I feel it's important
to have a valid partition table and BPB in the MBR/PBR.

* Renamed /usr/mdec/biosboot to /usr/mdec/boot, to be consistent
with other platforms.

* Enable SUPPORT_DOSFS in /usr/mdec/boot (stage2), so that
we can boot off FAT partitions.

* Crank version of /usr/mdec/boot to 3.1, and fix some of the other
entries in the version file.

installboot(8) (i386):
* Read the existing MBR of the filesystem and retain the BIOS
Parameter Block (BPB) in bytes 11..89 and the MBR partition
table in bytes 446..509. (Previously installboot(8) would
trash those two sections of the MBR.)

mbrlabel(8):
* Use sys/lib/libkern/xlat_mbr_fstype.c instead of homegrown code
to map the MBR partition type to the NetBSD disklabel type.


Test built "make release" for i386, and new bootblocks verified to work
(even off FAT!).
 1.3  02-Jul-2003  dsl Fix copyright - it got mangled earlier.
Added a mention of Wolfgang Solfrank - there are probably only comments left
from the much older mbr.S that he contributed.
(Wolfgang pointed out the mangled copyright, but doesn't object to the removal
of the Tools GmbH one.)
 1.2  29-Apr-2003  dsl branches: 1.2.2;
Set BFL_NEWMBR flag so that fdisk can differenciate between new and old mbr code.
 1.1  28-Apr-2003  dsl Master Boot Record (mbr) code:
mbr: boots active partition
mbr_bootsel: menu selection for partitions 1 to 4
mbr_ext: menu selection for partitions 1 to 4 and extended partitions
Based on code from sbin/fdisk/mbr_bootsel.
Needs a new fdisk to configure mbr_ext and correctly set default menu selection.(Not yet built by defaulat)
 1.2.2.6  24-Oct-2004  skrll Oops. Backout a change that should not have been committed.
 1.2.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.2.2.3  03-Sep-2004  skrll Sync with HEAD
 1.2.2.2  25-Aug-2004  skrll Sync with HEAD.
 1.2.2.1  03-Aug-2004  skrll Sync with HEAD
 1.5.2.3  04-Jul-2004  he Pull up revision 1.8 (requested by mycroft in ticket #596):
Change MAXDRV to 0x8f, to fix El Torito booting problems
on some machines. Parially fixes PR#22647.
 1.5.2.2  15-May-2004  tron Pull up revision 1.7 (requested by dsl in ticket #342):
Make mbr_bootsel boot active partition if/when no menu items are output.
Stops users sitting in front of a system that is waiting for a keypress.
Just don't ask how I added more functionality AND got an extra 7 free bytes!
 1.5.2.1  26-Apr-2004  jdc Pull up revision 1.6 (requested by dsl in ticket #182)

Put the 'mbr has bootselect table' marker into all versions of the mbr code.
Having the table in the 'standard' mbr allows fdisk to write in bootsel
menu items and only ask about updating the mbr code before exit.
Sysinst validates that the mbr code contains the bootselect table for
all the mbr code variants it reads - because it might want to write the table
and doesn't really want to make the validation dependant on what it is
going to do later.
Fixes install/25235, but sysinst needs some changes (like reporting the
failure to write the mbr) before the pr itself is closed.
 1.12.12.4  11-Feb-2008  yamt sync with head.
 1.12.12.3  04-Feb-2008  yamt sync with head.
 1.12.12.2  21-Jan-2008  yamt sync with head
 1.12.12.1  03-Sep-2007  yamt sync with head.
 1.13.32.1  11-Jul-2007  mjf Sync with head.
 1.13.30.1  27-May-2007  ad Sync with head.
 1.13.26.1  15-Apr-2007  yamt sync with head.
 1.14.26.2  20-Jan-2008  bouyer Sync with HEAD
 1.14.26.1  08-Jan-2008  bouyer Sync with HEAD
 1.14.20.1  18-Feb-2008  mjf Sync with HEAD.
 1.14.14.1  23-Mar-2008  matt sync with HEAD
 1.18.10.3  11-Mar-2010  yamt sync with head
 1.18.10.2  04-May-2009  yamt sync with head.
 1.18.10.1  16-May-2008  yamt sync with head.
 1.18.8.1  18-May-2008  yamt sync with head.
 1.18.6.2  17-Jan-2009  mjf Sync with HEAD.
 1.18.6.1  02-Jun-2008  mjf Sync with HEAD.
 1.19.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.19.6.1  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.20.4.2  10-Jan-2011  jym Sync with HEAD
 1.20.4.1  24-Oct-2010  jym Sync with HEAD
 1.22.4.1  05-Mar-2011  rmind sync with head

RSS XML Feed