Home | History | Annotate | only in /src/sys/arch/i386/stand/bootxx
History log of /src/sys/arch/i386/stand/bootxx
RevisionDateAuthorComments
 1.14 29-Dec-2010  jakllsch bootxx_cd9660 (cdboot), like bootxx_fat16 (fatboot), is not a traditional
libsa-based program. As such, build bootxx_cd9660 where its source lives.
This has been done by moving bootxx/bootxx_cd9660/Makefile to cdboot/Makefile
and adjusting the relative paths appropriately, so as to minimize binary change.
 1.13 11-Sep-2010  tsutsui Build and install bootxx_ext2fs, primary boot for ext2fs.

Ext2fs doesn't have enough free space (it has only 1KB)
to store this primary loader, but we can put it into
an independent small 'boot' partition as NetBSD/hp300 does
if it's really necessary.

It could be a fun project to add smaller pre-primary loader
that loads ~8KB primary loader for ext2fs, but probably it's unlikely
because there is a functional wheel named GRUB for ext2fs.
 1.12 27-May-2010  dholland Introduce .WAIT into the cleandir rule for blasting the libsa/libkern/etc.
trees, because it can race with the libsa/libkern/etc. makefiles' own
cleandir rules. I think I've found all of the uses of the offending idiom...
Closes PR 43360.
 1.11 14-Nov-2006  drochner branches: 1.11.56; 1.11.70; 1.11.76; 1.11.78;
use "=" instead of ":=" where .OBJDIR is used because it might change
later in <bsd.obj.mk>, thanks to Alan Barrett for the hint
 1.10 11-Dec-2005  christos branches: 1.10.20; 1.10.22;
merge ktrace-lwp.
 1.9 06-Oct-2005  dyoung Ensure we don't build the libraries twice: move the .WAIT after
the first subdirectory that uses the libraries. That subdirectory
is bootxx_ffsv1, not bootxx_cd9660.
 1.8 06-Oct-2005  dyoung Build and install /usr/mdec/bootxx_cd9660, a primary boot loader
for ISO9660 filesystems.
 1.7 23-Aug-2004  dsl branches: 1.7.12;
Need to use := when evaluating ${.OBJDIR}, then the correct value
is passed into the subdir builds and the 'lib' objects are correctly shared.
Fixes PR/26554
 1.6 20-Nov-2003  dsl Add .WAIT after first subdirectory to ensure we don't build the libraries
twice.
 1.5 13-Oct-2003  dsl Add bsd.obj.mk so these directories get their own obj directory (for the
library objects shared by their subdirectories).
Needed when the obj directory isn't a parent of the subdirectories obj directory
 1.4 08-Oct-2003  dsl Change the way the shared lib directory is handled.
Should now work if ${.OBJDIR} = ${.CURDIR}/obj.
 1.3 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.2 24-Jun-2003  tron branches: 1.2.2;
Remove "lib" directory in "cleandir" target.
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.2.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.3 18-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.7.12.2 30-Dec-2006  yamt sync with head.
 1.7.12.1 21-Jun-2006  yamt sync with head.
 1.10.22.1 10-Dec-2006  yamt sync with head.
 1.10.20.1 18-Nov-2006  ad Sync with head.
 1.11.78.2 05-Mar-2011  rmind sync with head
 1.11.78.1 30-May-2010  rmind sync with head
 1.11.76.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.11.76.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.11.70.2 10-Jan-2011  jym Sync with HEAD
 1.11.70.1 24-Oct-2010  jym Sync with HEAD
 1.11.56.2 09-Oct-2010  yamt sync with head
 1.11.56.1 11-Aug-2010  yamt sync with head.
 1.53 03-Jun-2023  lukem bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER

Provide a single variable
CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
CLANG_NO_ADDR_OF_PACKED_MEMBER
CC_NO_ADDR_OF_PACKED_MEMBER
GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.52 06-Sep-2020  mrg add support for new GCC 9 warnings that may be too much to fix
right now. new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree. mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it. (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.) clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
 1.51 25-Jul-2018  kamil Specify NOLIBCSANITIZER in x86 bootloader-like code under sys/arch/

Set NOLIBCSANITIZER for i386 and amd64 specific bootloader-like code.
 1.50 02-Jun-2018  christos branches: 1.50.2;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.49 20-Aug-2015  uebayasi branches: 1.49.16;
${PROG} depends on ${LDSCRIPT}.
 1.48 15-Jan-2014  joerg branches: 1.48.6;
Reduce amount of -no-integrated-as on x86 as .code16 is now supported by
LLVM.
 1.47 12-Jan-2014  tsutsui Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.

XXX: probabry we should have bsd.saprog.mk or something.
 1.46 01-Nov-2013  christos provide an ldscript to strip the unwind sections
XXX: untested
 1.45 22-Aug-2013  matt Add a missing KLINK_MACHINE= i386
 1.44 21-Aug-2013  matt Use <bsd.klinks.mk>
 1.43 10-Aug-2012  joerg branches: 1.43.2; 1.43.4;
Don't depend on HAVE_GCC being always present.
 1.42 20-Jun-2011  mrg branches: 1.42.2;
remove all the code that supported HAVE_GCC=3. mostly from chuq.
 1.41 16-Jun-2011  joerg Refactor compiler-specific optimizer flags. Mark bootxx as supported
with clang.
 1.40 20-May-2011  joerg branches: 1.40.2;
Disable integrated assembler for files that use .code16 or .code32 for
now. Disable Clang completely for bootxx and netboot for now until the
size issue has been sorted out.
 1.39 27-May-2010  dholland branches: 1.39.2;
Introduce .WAIT into the cleandir rule for blasting the libsa/libkern/etc.
trees, because it can race with the libsa/libkern/etc. makefiles' own
cleandir rules. I think I've found all of the uses of the offending idiom...
Closes PR 43360.
 1.38 30-Nov-2009  dsl branches: 1.38.2; 1.38.4;
Move relocation address to lower memory (0x1000) further away from the
BIOS 40:0 segment than previously but giving more room for heap that 0x8800.
 1.37 20-Nov-2009  dsl Change relay address for mbr and bootxx code to be 0x8800.
I'm not sure why I used 0x600, but I have a feeling that might
sometimes corrupt bios data.
0x8800 is far enough above 0x7e00 for a sector read to the latter address.
 1.36 03-Apr-2009  tsutsui Remove obsolete LIBSA_USE_MEMCPY and LIBSA_USE_MEMSET.
They were removed from <lib/libsa/stand.h> on December 2007.
 1.35 30-Mar-2009  tsutsui Remove extra trailing slash in ${S} path.
 1.34 12-Mar-2009  abs Prefer MACHINE_ARCH to MACHINE in some tests
 1.33 20-Oct-2008  christos branches: 1.33.2; 1.33.8;
disable PIE for boot code.
 1.32 29-Aug-2008  gmcgarry Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.31 15-Mar-2008  dsl branches: 1.31.4; 1.31.6; 1.31.10;
Add -momit-leaf-frame-pointer, saves a few bytes.
 1.30 31-Jan-2008  sborrill branches: 1.30.2; 1.30.6;
Add EPIA_HACK so that boot loaders work on EDEN 5000 processors.
This worked in NetBSD 3, but broke by NetBSD 4.

My offer of a development machine to fix this one and for all is still open!
 1.29 17-Oct-2007  garbled branches: 1.29.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.28 27-Sep-2007  ad Remove -DBOOT_ELF64 to make build on amd64.
 1.27 27-Jan-2007  cbiere branches: 1.27.6; 1.27.14; 1.27.22; 1.27.24; 1.27.26;
Don't define UNALIGNED_ACCESS, it's not used anymore.
 1.26 03-Dec-2006  dsl Add -DUNALIGNED_ACCESS here, libsa/dosfs.c seems to need it.
Probably it ought to come from some generic .h file, but I've no idea
which - nor if any existing define has the same effect.
In any case this saves oodles of bytes in bootxx_msdos.
 1.25 23-Oct-2006  christos branches: 1.25.2; 1.25.4;
nuke $DBG, since it contains -O2; suggested by uwe.
 1.24 25-Jun-2006  lukem branches: 1.24.4; 1.24.6;
Use ${TOOL_STAT} to get the size, instead of ls | tr | cut.
 1.23 25-Jun-2006  lukem Use -Wl,-Ttext,foo instead of -Ttext foo when using $(CC)
 1.22 13-May-2006  lukem branches: 1.22.4;
Convert to using CC instead of LD, as LDFLAGS is for CC not LD.
 1.21 13-May-2006  lukem support MAKEVERBOSE
 1.20 12-May-2006  mrg - -mcpu=i386 is gone in GCC4
- we need -Wno-attributes (to avoid __packed__ warnings)
- use -Wno-pointer-sign
- remove some redundancy from pxeboot/Makefile
 1.19 11-Dec-2005  christos branches: 1.19.4; 1.19.6; 1.19.8; 1.19.12;
merge ktrace-lwp.
 1.18 17-Sep-2005  chs use a .BEGIN target to make the various symlinks,
the previous way had problems with parallel make.
 1.17 05-May-2005  christos branches: 1.17.2;
add dependall and realdepend to the targets that we need to call in the
beginning. XXX: The real fix (handle dependencies in .BEGIN) is forthcoming.
 1.16 01-May-2005  christos More .BEGIN lossage.
 1.15 03-Sep-2004  thorpej branches: 1.15.10;
More complete fix for overriding CPUFLAGS and also apply fix to bootxx,
from Valeriy Ushakov.
 1.14 21-Jun-2004  jmc Ignore errors on some rm -rf's for platforms that aren't quite
POSIX compliant
and return errors on r/o source (FreeBSD) for -rf. Fixes PR#25022
 1.13 15-Oct-2003  gson branches: 1.13.2;
If a bootxx program already happened to be a multiple of 512 bytes in
length before padding, the shell command to conditionally pad it to
a multiple of 512 bytes returned a nonzero exit status, causing the
build to fail.
 1.12 13-Oct-2003  lukem Instead of defining TERSE_ERROR by default (due to space constraints),
define NO_LBA_CHECK. bootxx_msdos still needs TERSE_ERROR because its
BPB is larger than the default.
 1.11 09-Oct-2003  dsl Pick up X86_BOOT_MAGIC_* from bootblock.h
Move boot_params.S to lib (seems useful to use it in pxeboot).
 1.10 08-Oct-2003  dsl Change the way the shared lib directory is handled.
Should now work if ${.OBJDIR} = ${.CURDIR}/obj.
 1.9 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.8 30-Aug-2003  fvdl Add -DBOOT_ELF64 for amd64.
 1.7 30-Aug-2003  fvdl Add -m elf_i386 to ${LD}, not ${LDFLAGS}, since bsd.lib.mk doesn't
include ${LDFLAGS} when using ld -x on an object file.

XXX what's the point of these ld -x rules anyway?
 1.6 25-Jul-2003  dsl Report actual $MACHINE (so it will be amd64, not i386)
and filesystem type (could be useful)
in primary bootstrap banner message.
 1.5 01-Jul-2003  simonb branches: 1.5.2;
Make this work without a populated destdir:
machine and x86 symlinks.
Include from right places.
Don't depend on LIBCRT0,etc.

Also for the bootxx programs, keep the ELF object during the build
process.
 1.4 12-May-2003  dsl Install into /usr/mdec
 1.3 26-Apr-2003  fvdl x86_64 -> amd64
 1.2 16-Apr-2003  dsl Uncomment line that deletes tempory file
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.5.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.13.2.1 22-Jun-2004  tron Pull up revision 1.14 (requested by jmc in ticket #531):
Ignore errors on some rm -rf's for platforms that aren't quite
POSIX compliant
and return errors on r/o source (FreeBSD) for -rf. Fixes PR#25022
 1.15.10.1 27-Sep-2005  tron Pull up following revision(s) (requested by chs in ticket #814):
sys/arch/i386/stand/Makefile.booters: revision 1.61 via patch
sys/arch/i386/stand/bootxx/Makefile.bootxx: revision 1.18 via patch
sys/arch/i386/stand/boot/Makefile.boot: revision 1.24 via patch
use a .BEGIN target to make the various symlinks,
the previous way had problems with parallel make.
 1.17.2.6 17-Mar-2008  yamt sync with head.
 1.17.2.5 04-Feb-2008  yamt sync with head.
 1.17.2.4 27-Oct-2007  yamt sync with head.
 1.17.2.3 26-Feb-2007  yamt sync with head.
 1.17.2.2 30-Dec-2006  yamt sync with head.
 1.17.2.1 21-Jun-2006  yamt sync with head.
 1.19.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.19.8.2 26-Jun-2006  yamt sync with head.
 1.19.8.1 24-May-2006  yamt sync with head.
 1.19.6.1 01-Jun-2006  kardel Sync with head.
 1.19.4.1 09-Sep-2006  rpaulo sync with head
 1.22.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.24.6.1 10-Dec-2006  yamt sync with head.
 1.24.4.3 01-Feb-2007  ad Sync with head.
 1.24.4.2 12-Jan-2007  ad Sync with head.
 1.24.4.1 18-Nov-2006  ad Sync with head.
 1.25.4.1 03-Jun-2008  skrll Sync with netbsd-4.
 1.25.2.4 19-Mar-2008  bouyer Pull up following revision(s) (requested by dsl in ticket #1101):
sys/arch/i386/stand/bootxx/Makefile.bootxx: revision 1.31
Add -momit-leaf-frame-pointer, saves a few bytes.
 1.25.2.3 19-Mar-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1064):
sys/arch/i386/stand/bootxx/Makefile.bootxx: revision 1.30
Add EPIA_HACK so that boot loaders work on EDEN 5000 processors.
This worked in NetBSD 3, but broke by NetBSD 4.
My offer of a development machine to fix this one and for all is still open!
Add EPIA_HACK so that boot loaders work on EDEN 5000 processors.
This worked in NetBSD 3, but broke by NetBSD 4.
pulled up to netbsd-4:
Pull up following revision(s) (requested by sborrill in ticket #1064):
sys/arch/i386/stand/bootxx/Makefile.bootxx: revision 1.30
Add EPIA_HACK so that boot loaders work on EDEN 5000 processors.
This worked in NetBSD 3, but broke by NetBSD 4.
thanks !
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
 1.25.2.2 28-Feb-2008  bouyer Revert ticket #1064, it breaks the i386 build:
### bootxx_msdos size 7688 is larger than 7680
--- bootxx_msdos ---
*** [bootxx_msdos] Error code 1
1 error
 1.25.2.1 22-Feb-2008  bouyer Pull up following revision(s) (requested by sborrill in ticket #1064):
sys/arch/i386/stand/bootxx/Makefile.bootxx: revision 1.30
Add EPIA_HACK so that boot loaders work on EDEN 5000 processors.
This worked in NetBSD 3, but broke by NetBSD 4.
 1.27.26.1 06-Oct-2007  yamt sync with head.
 1.27.24.2 23-Mar-2008  matt sync with HEAD
 1.27.24.1 06-Nov-2007  matt sync with HEAD
 1.27.22.1 02-Oct-2007  joerg Sync with HEAD.
 1.27.14.1 03-Oct-2007  garbled Sync with HEAD
 1.27.6.1 09-Oct-2007  ad Sync with head.
 1.29.2.1 18-Feb-2008  mjf Sync with HEAD.
 1.30.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.30.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.30.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.30.2.1 24-Mar-2008  keiichi sync with head.
 1.31.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.31.10.1 19-Oct-2008  haad Sync with HEAD.
 1.31.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.31.4.3 11-Aug-2010  yamt sync with head.
 1.31.4.2 11-Mar-2010  yamt sync with head
 1.31.4.1 04-May-2009  yamt sync with head.
 1.33.8.4 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.33.8.3 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.33.8.2 01-Nov-2009  jym Sync with HEAD.
 1.33.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.38.4.2 31-May-2011  rmind sync with head
 1.38.4.1 30-May-2010  rmind sync with head
 1.38.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.39.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.40.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.42.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.42.2.1 30-Oct-2012  yamt sync with head
 1.43.4.2 18-May-2014  rmind sync with head
 1.43.4.1 28-Aug-2013  rmind sync with head
 1.43.2.2 03-Dec-2017  jdolecek update from HEAD
 1.43.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.6.1 22-Sep-2015  skrll Sync with HEAD
 1.49.16.2 28-Jul-2018  pgoyette Sync with HEAD
 1.49.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.50.2.1 10-Jun-2019  christos Sync with HEAD
 1.22 29-Jun-2023  manu Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT
 1.21 24-Jun-2021  gutteridge branches: 1.21.10;
boot1.c: remove a comment that's no longer relevant/correct

In r. 1.13, a check of the return value in fd was removed, and a comment
about this ("...so keep going") added. Then in r. 1.19, the fd return
value check was reinstated (as the true underlying errno could be masked
by the fstat() call), so there is no "keep going" happening anymore.
 1.20 06-Jan-2011  jakllsch branches: 1.20.64; 1.20.76;
Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.
 1.19 01-Jan-2010  christos branches: 1.19.4;
If the open fails, don't call fstat, because this changes the errno to EINVAL
from eg. ENOENT.
 1.18 18-Nov-2009  dsl Reinstate the 'banner'.
It is a useful diagnostic that the boot sequence is proceeding.
 1.17 30-Apr-2008  ad branches: 1.17.14;
Tidy up console output slightly.
 1.16 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.15 17-Oct-2007  garbled branches: 1.15.16; 1.15.18; 1.15.20;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.14 27-Sep-2007  ad - Make i386 bootblocks boot amd64 kernels, and change to say "NetBSD/x86..."
- Don't bother booting a.out kernels any more.
 1.13 24-Oct-2006  christos branches: 1.13.8; 1.13.16; 1.13.26; 1.13.28; 1.13.30;
remove a bit of code and a label and explain why in a comment; no code size
change.
 1.12 24-Oct-2006  oster Fix a logic bug in the bootblock code.

OK'ed by christos@
 1.11 23-Oct-2006  christos shrink further.
 1.10 22-Oct-2006  christos shave 32 bytes.
 1.9 11-Dec-2005  christos branches: 1.9.20; 1.9.22;
merge ktrace-lwp.
 1.8 23-Jun-2005  junyoung branches: 1.8.2;
Define BIOSDISK_DEFAULT_SECSIZE in biosdisk_ll.h and replace BIOSDISK_SECSIZE
with it.
 1.7 22-Jun-2005  junyoung Fix build breakage.
 1.6 27-Jun-2004  dsl Change interface between bootxx.S and boot1() - always linked together.
This allows boot1() to change the sector number (of the boot partition)
that bootxx.S passes through to boot2().
This means that boot2() will find the correct partition when boot1()
reads /boot from the 'a' partition instead of the mbr boot partition.
This all happens when you update a system that used a small 'wd0h' partition
to boot a raid1 set to the new bootcode. Deleting /boot from the 'wd0h'
partition will make the new bootcode find /boot and the root filesystem
inside the raid set.
 1.5 28-Feb-2004  dsl Look for /boot in the 'a' partition (from the label in the mbr partition)
if it can't be found in a filesystem (or raid set) at the start of the
mbr partition.
 1.4 07-Dec-2003  dsl Fix speling mistake in commennt.
 1.3 12-Aug-2003  dsl Try looking RF_PROTECTED_SECTORS further down the partition if /boot
cannot be found.
Lets the system boot directly from a rad set.
 1.2 25-Jul-2003  dsl Report actual $MACHINE (so it will be amd64, not i386)
and filesystem type (could be useful)
in primary bootstrap banner message.
 1.1 16-Apr-2003  dsl branches: 1.1.2;
bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.2.2 27-Oct-2007  yamt sync with head.
 1.8.2.1 30-Dec-2006  yamt sync with head.
 1.9.22.1 10-Dec-2006  yamt sync with head.
 1.9.20.1 18-Nov-2006  ad Sync with head.
 1.13.30.1 06-Oct-2007  yamt sync with head.
 1.13.28.1 06-Nov-2007  matt sync with HEAD
 1.13.26.1 02-Oct-2007  joerg Sync with HEAD.
 1.13.16.1 03-Oct-2007  garbled Sync with HEAD
 1.13.8.1 09-Oct-2007  ad Sync with head.
 1.15.20.2 11-Mar-2010  yamt sync with head
 1.15.20.1 16-May-2008  yamt sync with head.
 1.15.18.1 18-May-2008  yamt sync with head.
 1.15.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.17.14.2 10-Jan-2011  jym Sync with HEAD
 1.17.14.1 24-Oct-2010  jym Sync with HEAD
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.20.76.1 01-Aug-2021  thorpej Sync with HEAD.
 1.20.64.1 30-Jun-2023  martin Pull up following revision(s) (requested by manu in ticket #1658):

sys/arch/i386/stand/bootxx/boot1.c: revision 1.22

Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT
 1.21.10.1 30-Jun-2023  martin Pull up following revision(s) (requested by manu in ticket #222):

sys/arch/i386/stand/bootxx/boot1.c: revision 1.22

Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT
 1.2 09-Oct-2003  dsl Pick up X86_BOOT_MAGIC_* from bootblock.h
Move boot_params.S to lib (seems useful to use it in pxeboot).
 1.1 16-Apr-2003  dsl branches: 1.1.2;
bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12 06-Mar-2022  mlelstv pass errno through switch to protected mode.
 1.11 11-Jul-2019  msaitoh Fix typo (s/supress/suppress/).
 1.10 06-Jan-2011  jakllsch branches: 1.10.60;
Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.
 1.9 28-Apr-2008  martin branches: 1.9.14; 1.9.22;
Remove clause 3 and 4 from TNF licenses
 1.8 11-Dec-2005  christos branches: 1.8.74; 1.8.76; 1.8.78;
merge ktrace-lwp.
 1.7 23-Aug-2004  dsl Increase space for boot parameters - needed for specifying serial port
IO address and long keyboard translation map.
 1.6 19-Aug-2004  junyoung Rename bootparams to boot_params for consistency.
 1.5 27-Jun-2004  dsl Change interface between bootxx.S and boot1() - always linked together.
This allows boot1() to change the sector number (of the boot partition)
that bootxx.S passes through to boot2().
This means that boot2() will find the correct partition when boot1()
reads /boot from the 'a' partition instead of the mbr boot partition.
This all happens when you update a system that used a small 'wd0h' partition
to boot a raid1 set to the new bootcode. Deleting /boot from the 'wd0h'
partition will make the new bootcode find /boot and the root filesystem
inside the raid set.
 1.4 28-Feb-2004  dsl Report errno value from boot1() - even though the standalone FS code
seems to translate everything into ENOENT.
 1.3 09-Oct-2003  dsl Pick up X86_BOOT_MAGIC_* from bootblock.h
Move boot_params.S to lib (seems useful to use it in pxeboot).
 1.2 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.1 16-Apr-2003  dsl branches: 1.1.2;
bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.78.1 16-May-2008  yamt sync with head.
 1.8.76.1 18-May-2008  yamt sync with head.
 1.8.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.9.22.1 05-Mar-2011  rmind sync with head
 1.9.14.1 10-Jan-2011  jym Sync with HEAD
 1.10.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 28-Feb-2004  dsl Look for /boot in the 'a' partition (from the label in the mbr partition)
if it can't be found in a filesystem (or raid set) at the start of the
mbr partition.
 1.1 16-Apr-2003  dsl branches: 1.1.2;
bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.24 08-Dec-2023  tsutsui Replace several magic numbers with macro to describe GPT's hybrid MBR boot.
 1.23 11-May-2022  andvar fix various typos in comments.
 1.22 04-Jan-2016  christos revert, this has to do with the bootloader protocol version and should
stay the same until there is a reason for it to change.
 1.21 03-Jan-2016  christos change 60 to 70 which is the current release. Noticed by Rares Aioanei.
 1.20 17-Aug-2011  jakllsch branches: 1.20.30;
Remove home grown GPT MBR handoff support in favor of T13 EDD-4 annex A,
which does the same thing in a more interoperable way.
 1.19 06-Jan-2011  jakllsch Support booting from GPT-partioned disks on PC-BIOS-compatible systems.

Much of the work in this commit was done by Mike Volokhov during GSoC 2009.
 1.18 02-Jan-2011  jakllsch Correct comments referencing PRIMARY_LOAD_ADDRESS to match current reality.
 1.17 30-Nov-2009  dsl branches: 1.17.4;
Update 'oemname' to NetBSD60.
 1.16 28-Apr-2008  martin branches: 1.16.14;
Remove clause 3 and 4 from TNF licenses
 1.15 10-Apr-2007  dsl branches: 1.15.34; 1.15.36; 1.15.38;
Change the default 'oemname' from NetBSD20 to NetBSD40
 1.14 24-Nov-2006  wiz branches: 1.14.4; 1.14.8; 1.14.10;
s/apparant/apparent/, from Zafer.
 1.13 11-Dec-2005  christos branches: 1.13.20; 1.13.22;
merge ktrace-lwp.
 1.12 17-Jan-2005  dsl branches: 1.12.8;
Fix comment, code is requesting CHS geometry, not max LBA sector
 1.11 22-Mar-2004  lukem branches: 1.11.8;
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.10 21-Dec-2003  dsl Fix problems booting disks with extended partition from grub (and other
non-netbsd mbr code) - thanks to Joe Thiemann for finding this...
 1.9 13-Oct-2003  lukem The reserved space for the BIOS Parameter Block (BPB) only needs to be for
FAT16 (11+51) except when booting from FAT{12,16,32}, which needs FAT32 (11+79).
We still reserve the BPB for non-bootxx_msdos PBR bootblocks because
they may be installed as a floppy boot record (and those need a BPB).

Remove some redundant wording in an error messsage, saving 6 bytes.
 1.8 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.7 30-Aug-2003  dsl Placate people who insist on using non-standard disk layouts by adding
a valid MBR entry for partition 3 (covering the first 15 sectors) into the
end of the partition boot code.
 1.6 09-Aug-2003  dsl Some systems (esp. those with a Promise IDE controller card) seem to
destroy %dl (drive number) across the 'disk reset' command.
Preserve %dl across that call and all registers across the disk reads.
Reorder the code to remove some long conditional jumps to save space.
 1.5 05-Aug-2003  dsl Dont need jmpl, ljmp or jmp is fine.
 1.4 05-Aug-2003  dsl Some bios manage to load the mbr code to 7c0:0 (instead of 0:7c00) especially
when loading from CDROM. Change so we don't care what %cs is.
Adjust code layout so that anyone who feels so inclinded can use this for
the mbr code. Note that mbr slot 0 overlays a data area that must be zero
when this is read from the pbr.
 1.3 15-May-2003  dsl branches: 1.3.2;
Incorrect sector number passed to boot1 in floppy (no mbr) case
 1.2 24-Apr-2003  dsl Fix code that scans extended partition list
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.3.2.4 24-Jan-2005  skrll Sync with HEAD.
 1.3.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.2.1 03-Aug-2004  skrll Sync with HEAD
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.12.8.2 03-Sep-2007  yamt sync with head.
 1.12.8.1 30-Dec-2006  yamt sync with head.
 1.13.22.1 10-Dec-2006  yamt sync with head.
 1.13.20.1 12-Jan-2007  ad Sync with head.
 1.14.10.1 11-Jul-2007  mjf Sync with head.
 1.14.8.1 27-May-2007  ad Sync with head.
 1.14.4.1 15-Apr-2007  yamt sync with head.
 1.15.38.2 11-Mar-2010  yamt sync with head
 1.15.38.1 16-May-2008  yamt sync with head.
 1.15.36.1 18-May-2008  yamt sync with head.
 1.15.34.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.14.3 27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.16.14.2 10-Jan-2011  jym Sync with HEAD
 1.16.14.1 24-Oct-2010  jym Sync with HEAD
 1.17.4.1 05-Mar-2011  rmind sync with head
 1.20.30.1 19-Mar-2016  skrll Sync with HEAD
 1.1 11-Sep-2010  tsutsui branches: 1.1.2; 1.1.4; 1.1.6; 1.1.12;
Build and install bootxx_ext2fs, primary boot for ext2fs.

Ext2fs doesn't have enough free space (it has only 1KB)
to store this primary loader, but we can put it into
an independent small 'boot' partition as NetBSD/hp300 does
if it's really necessary.

It could be a fun project to add smaller pre-primary loader
that loads ~8KB primary loader for ext2fs, but probably it's unlikely
because there is a functional wheel named GRUB for ext2fs.
 1.1.12.2 05-Mar-2011  rmind sync with head
 1.1.12.1 11-Sep-2010  rmind file Makefile was added on branch rmind-uvmplock on 2011-03-05 20:50:44 +0000
 1.1.6.2 11-Sep-2010  tsutsui Build and install bootxx_ext2fs, primary boot for ext2fs.

Ext2fs doesn't have enough free space (it has only 1KB)
to store this primary loader, but we can put it into
an independent small 'boot' partition as NetBSD/hp300 does
if it's really necessary.

It could be a fun project to add smaller pre-primary loader
that loads ~8KB primary loader for ext2fs, but probably it's unlikely
because there is a functional wheel named GRUB for ext2fs.
 1.1.6.1 11-Sep-2010  tsutsui file Makefile was added on branch uebayasi-xip on 2010-09-11 13:06:38 +0000
 1.1.4.2 24-Oct-2010  jym Sync with HEAD
 1.1.4.1 11-Sep-2010  jym file Makefile was added on branch jym-xensuspend on 2010-10-24 22:48:05 +0000
 1.1.2.2 09-Oct-2010  yamt sync with head
 1.1.2.1 11-Sep-2010  yamt file Makefile was added on branch yamt-nfs-mp on 2010-10-09 03:31:48 +0000
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1 16-Apr-2003  dsl bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.5 30-Aug-2023  christos Override these two booters with -Oz for clang since it produces smaller code
here.
 1.4 22-Jan-2020  martin branches: 1.4.24;
Clamp FAT partition size to 32 bit byte offsets to make the code small
enough to fit.
 1.3 11-Dec-2005  christos branches: 1.3.166; 1.3.172;
merge ktrace-lwp.
 1.2 13-Oct-2003  lukem branches: 1.2.4;
Instead of defining TERSE_ERROR by default (due to space constraints),
define NO_LBA_CHECK. bootxx_msdos still needs TERSE_ERROR because its
BPB is larger than the default.
 1.1 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.2.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 13-Oct-2003  skrll file Makefile was added on branch ktrace-lwp on 2004-08-03 10:36:19 +0000
 1.3.172.1 25-Jan-2020  ad Sync with head.
 1.3.166.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4.24.1 14-Dec-2023  martin Pull up following revision(s) (requested by rin in ticket #498):

sys/arch/i386/stand/dosboot/Makefile: revision 1.35
sys/arch/i386/stand/Makefile.booters: revision 1.95
sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile: revision 1.5
sys/arch/i386/stand/Makefile.inc: revision 1.19
sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile: revision 1.4
sys/arch/i386/stand/dosboot/Makefile: revision 1.34

Fix the clang build by setting -z noseparate-code

Merge the OPT_SIZE flags. -Oz is not always producing smaller code that -Os,
so default to -Os for both, and we'll override where needed.

Override these two booters with -Oz for clang since it produces smaller code
here.

x86/dosboot: Allow NULL dereference to fetch command line arguments
DOS command line arguments are provided as struct psp at 0x0000;
see doscommain.c.

Recent versions of gcc and clang are clever enough to optimize code
block involving NULL dereference into ud2 insn.

Sprinkle -fno-delete-null-pointer-checks to doscommain.c to
prevent this behavior.

Note that dosboot.com for netbsd-9 and later was broken due to
this ``over optimization''. gcc 5.5.0 and clang 4.0.0 in netbsd-8
generate correct codes without this workaround.

XXX
Are there still use cases for dosboot.com? Does anyone want to
boot NetBSD from real-mode DOS in 2023?

x86/dosboot: Do not page-align data segment
4K alignment is too heavy burden for COM executable with 64K limit :)
Fix binary size overflow for clang/amd64.
 1.4 30-Aug-2023  christos Override these two booters with -Oz for clang since it produces smaller code
here.
 1.3 18-Nov-2009  dsl branches: 1.3.94;
Reinstate the 'banner'.
It is a useful diagnostic that the boot sequence is proceeding.
 1.2 30-Apr-2008  ad branches: 1.2.14;
Tidy up console output slightly.
 1.1 16-Apr-2003  dsl branches: 1.1.104; 1.1.106; 1.1.108;
bootxx: bootstrap code - installable by MI installboot.
Loads /boot using filesystem accesses (rather than a list of block numbers)
 1.1.108.2 11-Mar-2010  yamt sync with head
 1.1.108.1 16-May-2008  yamt sync with head.
 1.1.106.1 18-May-2008  yamt sync with head.
 1.1.104.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.14.1 24-Oct-2010  jym Sync with HEAD
 1.3.94.1 14-Dec-2023  martin Pull up following revision(s) (requested by rin in ticket #498):

sys/arch/i386/stand/dosboot/Makefile: revision 1.35
sys/arch/i386/stand/Makefile.booters: revision 1.95
sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile: revision 1.5
sys/arch/i386/stand/Makefile.inc: revision 1.19
sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile: revision 1.4
sys/arch/i386/stand/dosboot/Makefile: revision 1.34

Fix the clang build by setting -z noseparate-code

Merge the OPT_SIZE flags. -Oz is not always producing smaller code that -Os,
so default to -Os for both, and we'll override where needed.

Override these two booters with -Oz for clang since it produces smaller code
here.

x86/dosboot: Allow NULL dereference to fetch command line arguments
DOS command line arguments are provided as struct psp at 0x0000;
see doscommain.c.

Recent versions of gcc and clang are clever enough to optimize code
block involving NULL dereference into ud2 insn.

Sprinkle -fno-delete-null-pointer-checks to doscommain.c to
prevent this behavior.

Note that dosboot.com for netbsd-9 and later was broken due to
this ``over optimization''. gcc 5.5.0 and clang 4.0.0 in netbsd-8
generate correct codes without this workaround.

XXX
Are there still use cases for dosboot.com? Does anyone want to
boot NetBSD from real-mode DOS in 2023?

x86/dosboot: Do not page-align data segment
4K alignment is too heavy burden for COM executable with 64K limit :)
Fix binary size overflow for clang/amd64.

RSS XML Feed