Home | History | Annotate | only in /src/sys/arch/i386/stand/boot
History log of /src/sys/arch/i386/stand/boot
RevisionDateAuthorComments
 1.8 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.7 14-Nov-2006  drochner branches: 1.7.56; 1.7.70; 1.7.76; 1.7.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.6 11-Dec-2005  christos branches: 1.6.20; 1.6.22;
merge ktrace-lwp.
 1.5 23-Aug-2004  dsl branches: 1.5.12;
Use := when saving ${.OBJDIR) - then we get the correct value!
 1.4 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.3 08-Oct-2003  dsl Change the way the shared lib directory is handled.
Should now work if ${.OBJDIR} = ${.CURDIR}/obj.
 1.2 24-Jun-2003  tron branches: 1.2.2;
Remove "lib" directory in "cleandir" target.
 1.1 16-Apr-2003  dsl Add files for 2nd stage boot loader
 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.5.12.1 30-Dec-2006  yamt sync with head.
 1.6.22.1 10-Dec-2006  yamt sync with head.
 1.6.20.1 18-Nov-2006  ad Sync with head.
 1.7.78.1 30-May-2010  rmind sync with head
 1.7.76.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.7.70.1 24-Oct-2010  jym Sync with HEAD
 1.7.56.1 11-Aug-2010  yamt sync with head.
 1.76 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.75 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.74 04-Apr-2020  christos Infrastructure for putting kernel+modules in /netbsd/kernel and
/netbsd/modules respectively instead of /netbsd and
/stand/<arch>/<version>/modules. This is only supported for x86,
and is turned off by default. To try it, add KERNEL_DIR=yes in your
/mk.conf and install a system from that build.
 1.73 13-Sep-2019  manu Add multiboot 2 support to x86 bootloaders

multiboot 2 is required to boot Xen on an EFI system.
This also require a kernel patch for properly discovering
the ACPI RSDP, which is available after 20190912, in
src/sys/arch/x86/acpi/acpi_machdep.c 1.26-1.28

There are a few missing bit in this multiboot 2 implementation
(which are unused by Xen):
- Header tags Address, Freambuffer, and Relocatable are ignored
- Tags APM and Network are not provided
- Tags ACPI old and ACP new are only provided for ACPI boot
- Tag boot device does not provides the subpart (BSD disklabel partition)

Notes:
- multiboot2 is disabled in dosboot, otherwise the binary
gets too big and build fails.
- in src/sys/arch/i386/stand/efiboot, consinit() is renamed
as efi_consinit() to avoid prototype conflicts in src/sys/sys/systm.h
 1.72 25-Jul-2018  kamil branches: 1.72.4;
Specify NOLIBCSANITIZER in x86 bootloader-like code under sys/arch/

Set NOLIBCSANITIZER for i386 and amd64 specific bootloader-like code.
 1.71 02-Jun-2018  christos branches: 1.71.2;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.70 08-Apr-2017  christos branches: 1.70.6; 1.70.12;
centralize vers.c building for standalone programs.
 1.69 23-Jan-2016  christos branches: 1.69.2; 1.69.4;
We'll define the kernel types for standalone code.
 1.68 23-Jan-2016  christos Define _KERNTYPES for things that need it.
 1.67 20-Aug-2015  uebayasi ${PROG} depends on ${LDSCRIPT}.
 1.66 14-Apr-2014  uebayasi branches: 1.66.4;
Use ldscript. Identical output confirmed.
 1.65 14-Apr-2014  uebayasi Other boot loaders name ELF *.sym, not *.syms. Follow that convention.
 1.64 12-Jan-2014  tsutsui branches: 1.64.2;
Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.

XXX: probabry we should have bsd.saprog.mk or something.
 1.63 04-Jan-2014  christos undo the linker script hack now that the linker scripts do this.
 1.62 01-Jan-2014  christos remove commented out -fno-reorder-functions
 1.61 01-Jan-2014  christos Use a custom ldscript so that we can keep boot_start at 0.
 1.60 21-Aug-2013  matt Add KLINK_MACHINE= i386
 1.59 21-Aug-2013  matt Use <bsd.klinks.mk>
 1.58 10-Aug-2012  joerg branches: 1.58.2; 1.58.4;
Don't depend on HAVE_GCC being always present.
 1.57 16-Jan-2012  christos PR/45796: Evgeniy Ivanov minixfs3 support.
 1.56 25-Dec-2011  tsutsui Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.55 22-Aug-2011  mrg branches: 1.55.2; 1.55.6;
disable mmx/sse here too. hopefully fixes amd64 /boot issues.
certainly changes the output in ways that gcc 4.1 doesn't.
 1.54 01-Jul-2011  mrg remove HAVE_GCC == 4 conditional
 1.53 20-Jun-2011  mrg remove all the code that supported HAVE_GCC=3. mostly from chuq.
 1.52 02-Jun-2011  dsl Put all the 'CFLAGS+= -Dxxx' together.
 1.51 20-May-2011  joerg branches: 1.51.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.50 26-Feb-2011  jakllsch Enable LIBSA_PRINTF_LONGLONG_SUPPORT.
Useful in any of the cases where we already print a (64-bit) daddr_t.
 1.49 22-Jan-2011  joerg Drop bootprog_maker (formerly enabled by -M) and bootprog_date (formerly
disabled by -D) from the output of newvers_stand.sh. Change -D to the
inverted logic, so that it adds the date to bootprog_rev in ().

Change all platforms accordingly. -D is added if MKREPRO is not yes and
wasn't present before. Platforms that didn't use -D don't depend on
MKREPRO now either.
 1.48 05-Jan-2011  jakllsch branches: 1.48.2; 1.48.4;
Pass a 64-bit boot partition base LBA into x86 /boot,
while maintaining compatibility with existing bootxx code.
 1.47 20-Dec-2010  jakllsch Move the bottom of the heap off the top of the stack. Also, increase the heap
size by 64KiB. These changes allows gzipped Xen with gzipped Dom0 kernels
to successfully boot. I also suspect this will cure the amd64 CD boot issue
without disabling ext2fs support.
 1.46 11-Dec-2010  mrg disable ext2fs support in /boot on amd64 for now. it breaks cd booting.

XXX: i don't know why, or plan to figure it out, but at least now amd64
XXX: isos boot again.
 1.45 11-Sep-2010  tsutsui Enable SUPPORT_EXT2FS. Tested on i386 that has root on ext2fs
with 128 byte and 256 byte inode sizes on QEMU.

Note for netbsd-5, this also requires HEAP_START=0x30000
as applied in rev 1.37, and this might also get another limit
on cdboot as described in PR install/42202.
 1.44 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.43 23-May-2010  veego Add ${PROG}.syms to CLEANFILES
 1.42 20-Nov-2009  dsl branches: 1.42.2; 1.42.4;
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.41 18-Nov-2009  dsl Keep the output of 'ld' prior to extracting the image.
Useful for debugging (etc) since it contains the symbols.
 1.40 30-Mar-2009  tsutsui Remove extra trailing slash in ${S} path.
 1.39 12-Mar-2009  abs Prefer MACHINE_ARCH to MACHINE in some tests
 1.38 01-Mar-2009  isaki Remove duplicated definitions.
 1.37 16-Feb-2009  jmcneill Bootloader modifications for generic framebuffer console support on i386
and amd64 where VESA VBE 2.0+ is available.

* Add helper library and stubs to invoke VBE bioscalls.
* Bump HEAP_START as we were already dangerously close to our limits.
* bootdataseg now allows access > 16MB so in the future we can scribble
on the framebuffer.
* Pass BTINFO_FRAMEBUFFER parameters to kernel when configured.
* VBE modes are configured with the new 'vesa' command. Usage, when present:
* vesa {enabled|disabled}
Enable / disable linear framebuffer, default mode is 640x480x8. May
be changed in the future to determine mode based on VBE/DDC where
available.
* vesa list
List modes supported by the firmware that meet the following criteria:
* linear framebuffer
* packed pixel or direct colour mode
* vesa {modenum|modestr}
Enable specific VBE mode. The mode can be specified either as a
VBE mode number (eg. 0x101) or as a string (eg. 800x600x16).
 1.36 20-Oct-2008  christos branches: 1.36.2; 1.36.8;
disable PIE for boot code.
 1.35 19-Oct-2008  snj s/explicitely/explicitly/
 1.34 29-Aug-2008  gmcgarry Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.33 16-Jul-2008  perry Add -DM to the newvers_stand.h invocation.

Why is there a "Makefile.boot" used here, and a "Makefile.booters"
used one level up, with redundant stuff between both of them? This all
used to be so clean...
 1.32 05-Apr-2008  tsutsui branches: 1.32.4; 1.32.6; 1.32.8; 1.32.10;
Add commented out ext2fs definitions.
 1.31 17-Oct-2007  garbled branches: 1.31.16;
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.30 27-Sep-2007  ad Remove -DBOOT_ELF64 to make build on amd64.
 1.29 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.28 25-Jun-2006  lukem branches: 1.28.14; 1.28.22; 1.28.32; 1.28.34; 1.28.36;
Convert to using CC instead of LD, as LDFLAGS is for CC not LD.
 1.27 13-May-2006  lukem branches: 1.27.4;
support MAKEVERBOSE
 1.26 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.25 11-Dec-2005  christos branches: 1.25.4; 1.25.6; 1.25.8; 1.25.12;
merge ktrace-lwp.
 1.24 17-Sep-2005  chs use a .BEGIN target to make the various symlinks,
the previous way had problems with parallel make.
 1.23 22-Jun-2005  junyoung branches: 1.23.2;
Add support for cd9660 file system to the i386 BIOS bootloader.
 1.22 21-Jun-2005  junyoung If any of libraries needed by the "boot" is rebuilt vers.c should be
regenerated so that the build date is updated accordingly.
 1.21 27-May-2005  gavan Workaround for issues seen on VIA C3-based systems. PR port-i386/26007

Tested on ML5000 board. This may not fix the problem on all variations of the
hardware, but it's likely that variations on the theme will. This workaround
is non-intrusive and should not affect any other CPUs.
 1.20 05-May-2005  christos 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.19 01-May-2005  christos More .BEGIN lossage.
 1.18 03-Sep-2004  thorpej branches: 1.18.10;
More complete fix for overriding CPUFLAGS and also apply fix to bootxx,
from Valeriy Ushakov.
 1.17 03-Sep-2004  thorpej Override CPUFLAGS to empty so that a CPUFLAGS setting in the user's
mk.conf don't affect the C options we need to build the boot loader.
 1.16 15-Aug-2004  dsl Define CONSADDR for pcio.c (continuing the same hack use for the other
parameters).
 1.15 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.14 13-Mar-2004  dsl branches: 1.14.2;
Translate ascii keycode to help those with azerty keyboard type straight.
 1.13 08-Nov-2003  dsl Remove depencency of vers.c on ${LIBLIST} - it messes up the depends and
I'm not sure why I added it now!
Default NWEVERSWHAT back to "BIOS Boot" - look better on boot banner page.
 1.12 26-Oct-2003  lukem Use ${HOST_SH} instead of `sh'.

If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
 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 another -DBOOT_ELF64 for amd64.
 1.7 30-Aug-2003  fvdl Add -m elf_i386 (for amd64) to LD.
 1.6 01-Jul-2003  simonb branches: 1.6.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.5 30-Jun-2003  thorpej Allow SOURCES to be overridden.
 1.4 24-May-2003  thorpej Comment out DEBUG_MEMSIZE.
 1.3 12-May-2003  dsl Don't override PROG from subdir Makefile
Install into /usr/mdec
 1.2 26-Apr-2003  fvdl x86_64 -> amd64
 1.1 16-Apr-2003  dsl Add files for 2nd stage boot loader
 1.6.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.6.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.2.1 22-Jun-2004  tron branches: 1.14.2.1.2;
Pull up revision 1.15 (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.14.2.1.2.1 30-May-2005  riz Pull up revision 1.21 (requested by gavan in ticket #1870):
Workaround for issues seen on VIA C3-based systems. PR port-i386/26007
Tested on ML5000 board. This may not fix the problem on all variations
of the
hardware, but it's likely that variations on the theme will. This workaround
is non-intrusive and should not affect any other CPUs.
 1.18.10.2 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.18.10.1 30-May-2005  riz Pull up revision 1.21 (requested by gavan in ticket #356):
Workaround for issues seen on VIA C3-based systems. PR port-i386/26007
Tested on ML5000 board. This may not fix the problem on all variations
of the
hardware, but it's likely that variations on the theme will. This workaround
is non-intrusive and should not affect any other CPUs.
 1.23.2.3 27-Oct-2007  yamt sync with head.
 1.23.2.2 30-Dec-2006  yamt sync with head.
 1.23.2.1 21-Jun-2006  yamt sync with head.
 1.25.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.25.8.2 26-Jun-2006  yamt sync with head.
 1.25.8.1 24-May-2006  yamt sync with head.
 1.25.6.1 01-Jun-2006  kardel Sync with head.
 1.25.4.1 09-Sep-2006  rpaulo sync with head
 1.27.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.28.36.1 06-Oct-2007  yamt sync with head.
 1.28.34.1 06-Nov-2007  matt sync with HEAD
 1.28.32.1 02-Oct-2007  joerg Sync with HEAD.
 1.28.22.1 03-Oct-2007  garbled Sync with HEAD
 1.28.14.1 09-Oct-2007  ad Sync with head.
 1.31.16.3 17-Jan-2009  mjf Sync with HEAD.
 1.31.16.2 28-Sep-2008  mjf Sync with HEAD.
 1.31.16.1 02-Jun-2008  mjf Sync with HEAD.
 1.32.10.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.32.10.1 19-Oct-2008  haad Sync with HEAD.
 1.32.8.1 18-Jul-2008  simonb Sync with head.
 1.32.6.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.4.4 09-Oct-2010  yamt sync with head
 1.32.4.3 11-Aug-2010  yamt sync with head.
 1.32.4.2 11-Mar-2010  yamt sync with head
 1.32.4.1 04-May-2009  yamt sync with head.
 1.36.8.5 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.36.8.4 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.36.8.3 28-Mar-2011  jym Sync with HEAD. TODO before merge:
- shortcut for suspend code in sysmon, when powerd(8) is not running.
Borrow ``xs_watch'' thread context?
- bug hunting in xbd + xennet resume. Rings are currently thrashed upon
resume, so current implementation force flush them on suspend. It's not
really needed.
 1.36.8.2 01-Nov-2009  jym Sync with HEAD.
 1.36.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.36.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.36.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.42.4.4 12-Jun-2011  rmind sync with head
 1.42.4.3 31-May-2011  rmind sync with head
 1.42.4.2 05-Mar-2011  rmind sync with head
 1.42.4.1 30-May-2010  rmind sync with head
 1.42.2.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.42.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.48.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.48.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.48.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.51.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.55.6.1 18-Feb-2012  mrg merge to -current.
 1.55.2.3 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.55.2.2 30-Oct-2012  yamt sync with head
 1.55.2.1 17-Apr-2012  yamt sync with head
 1.58.4.2 18-May-2014  rmind sync with head
 1.58.4.1 28-Aug-2013  rmind sync with head
 1.58.2.2 03-Dec-2017  jdolecek update from HEAD
 1.58.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.64.2.1 10-Aug-2014  tls Rebase.
 1.66.4.2 28-Aug-2017  skrll Sync with HEAD
 1.66.4.1 22-Sep-2015  skrll Sync with HEAD
 1.69.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.69.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.70.12.2 28-Jul-2018  pgoyette Sync with HEAD
 1.70.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.70.6.1 18-Sep-2019  martin Pull up following revision(s) [adapted, via patch]
(requested by manu in ticket #1382):

sys/arch/i386/include/multiboot2.h: revision 1.1
sys/arch/i386/stand/lib/exec.c: revision 1.74
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.11
sys/arch/i386/stand/efiboot/bootia32/multiboot32.S: revision 1.1
sys/arch/i386/stand/lib/biosdisk.c: revision 1.52
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.5
distrib/sets/lists/comp/md.amd64: revision 1.273
sys/arch/i386/stand/efiboot/eficons.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.5
distrib/sets/lists/comp/md.i386: revision 1.191
sys/arch/i386/stand/lib/libi386.h: revision 1.45
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.6
sys/arch/i386/stand/lib/pread.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.10
sys/arch/i386/stand/efiboot/bootia32/Makefile: revision 1.3
sys/arch/i386/stand/lib/Makefile: revision 1.47
sys/arch/i386/stand/efiboot/bootx64/Makefile: revision 1.2
sys/arch/i386/stand/lib/multiboot.S: revision 1.3
sys/arch/i386/stand/efiboot/bootx64/multiboot64.S: revision 1.1
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.16
sys/arch/i386/include/Makefile: revision 1.50
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.20
sys/arch/i386/stand/boot/Makefile.boot: revision 1.73
sys/arch/i386/stand/pxeboot/Makefile: revision 1.26
sys/arch/i386/stand/lib/exec_multiboot1.c: revision 1.1
sys/arch/i386/stand/netboot/Makefile.netboot: revision 1.11
sys/arch/i386/stand/lib/exec_multiboot2.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk.h: revision 1.12
sys/arch/i386/stand/lib/exec_multiboot2.c: revision 1.2
sys/arch/i386/stand/dosboot/Makefile: revision 1.32
sys/external/bsd/gnu-efi/dist/inc/efiapi.h (apply patch)

Add multiboot 2 support to x86 bootloaders

multiboot 2 is required to boot Xen on an EFI system.

This also require a kernel patch for properly discovering
the ACPI RSDP, which is available after 20190912, in
src/sys/arch/x86/acpi/acpi_machdep.c 1.26-1.28

There are a few missing bit in this multiboot 2 implementation
(which are unused by Xen):
- Header tags Address, Freambuffer, and Relocatable are ignored
- Tags APM and Network are not provided
- Tags ACPI old and ACP new are only provided for ACPI boot
- Tag boot device does not provides the subpart (BSD disklabel partition)

Notes:
- multiboot2 is disabled in dosboot, otherwise the binary
gets too big and build fails.
- in src/sys/arch/i386/stand/efiboot, consinit() is renamed
as efi_consinit() to avoid prototype conflicts in src/sys/sys/systm.h

Remove debug define.

It remained there unseen because it was misspelled!

Remove obsoeolete BUGS note that UEFI bootloader does not support multiboot

Add new multiboot2.h header.
 1.71.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.71.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.71.2.1 10-Jun-2019  christos Sync with HEAD
 1.72.4.1 17-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #203):

sys/arch/i386/include/multiboot2.h: revision 1.1
sys/arch/i386/stand/lib/exec.c: revision 1.74
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.11
sys/arch/i386/stand/efiboot/bootia32/multiboot32.S: revision 1.1
sys/arch/i386/stand/lib/biosdisk.c: revision 1.52
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.5
sys/arch/i386/stand/efiboot/eficons.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.5
sys/arch/i386/stand/lib/libi386.h: revision 1.45
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.6
sys/arch/i386/stand/lib/pread.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.10
sys/arch/i386/stand/efiboot/bootia32/Makefile: revision 1.3
sys/arch/i386/stand/lib/Makefile: revision 1.47
sys/arch/i386/stand/efiboot/bootx64/Makefile: revision 1.2
sys/arch/i386/stand/lib/multiboot.S: revision 1.3
sys/arch/i386/stand/efiboot/bootx64/multiboot64.S: revision 1.1
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.16
sys/arch/i386/include/Makefile: revision 1.50
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.20
sys/arch/i386/stand/boot/Makefile.boot: revision 1.73
sys/arch/i386/stand/pxeboot/Makefile: revision 1.26
sys/arch/i386/stand/lib/exec_multiboot1.c: revision 1.1
sys/arch/i386/stand/netboot/Makefile.netboot: revision 1.11
sys/arch/i386/stand/lib/exec_multiboot2.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk.h: revision 1.12
sys/arch/i386/stand/lib/exec_multiboot2.c: revision 1.2
sys/arch/i386/stand/dosboot/Makefile: revision 1.32

Add multiboot 2 support to x86 bootloaders

multiboot 2 is required to boot Xen on an EFI system.

This also require a kernel patch for properly discovering
the ACPI RSDP, which is available after 20190912, in
src/sys/arch/x86/acpi/acpi_machdep.c 1.26-1.28

There are a few missing bit in this multiboot 2 implementation
(which are unused by Xen):
- Header tags Address, Freambuffer, and Relocatable are ignored
- Tags APM and Network are not provided
- Tags ACPI old and ACP new are only provided for ACPI boot
- Tag boot device does not provides the subpart (BSD disklabel partition)
Notes:
- multiboot2 is disabled in dosboot, otherwise the binary
gets too big and build fails.
- in src/sys/arch/i386/stand/efiboot, consinit() is renamed
as efi_consinit() to avoid prototype conflicts in src/sys/sys/systm.h

Remove debug define.

It remained there unseen because it was misspelled!

Remove obsoeolete BUGS note that UEFI bootloader does not support multiboot
 1.8 05-Jan-2011  jakllsch Pass a 64-bit boot partition base LBA into x86 /boot,
while maintaining compatibility with existing bootxx code.
 1.7 20-Dec-2010  jakllsch We want a literal 0x86 in %ah for this int $0x15 delay,
not the value of the byte at 0x86.
 1.6 28-Apr-2008  martin branches: 1.6.14; 1.6.22;
Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78;
merge ktrace-lwp.
 1.4 19-Aug-2004  junyoung Rename bootparams to boot_params for consistency.
 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;
Add files for 2nd stage boot loader
 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.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.1 18-May-2008  yamt sync with head.
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.22.1 05-Mar-2011  rmind sync with head
 1.6.14.1 10-Jan-2011  jym Sync with HEAD
 1.2 04-Jan-2014  christos undo the linker script hack now that the linker scripts do this.
 1.1 01-Jan-2014  christos Provide a boot ldscript that puts the text.unlikely section after the text
section so that boot_start gets placed first. We also set the entry and the
start address, although we still override them from the command line.
This is a copy of elf_i386.xbn
 1.90 31-Jul-2025  pgoyette Reorder the names[] array to put the supported/historical entries
first. Should eliminate some unwanted and confusing messages.
 1.89 20-May-2025  pgoyette branches: 1.89.2;
Historically (prior to supporting the KERNEL_DIR build option), the
boot-commands ``boot file'' and ``boot /file'' were equivalent and
attempted to execute the same set of files. (In the boot-loader,
all path (filename) lookups start at the root directory whether or
not a leading slash is present.)

However, with the recent addition of support for the KERNEL_DIR
option, the leading slash character resulted in skipping the attempt
to load /file/kernel and /file/kernel.gz, and thus the boot loader
will not attempt to boot from a new KERNEL_DIR environment if the
leading slash is present. This commit restores attempting to load
these files, thus making these two boot-commands once again equivalent
in both legacy and KERNEL_DIR environments..

Changes were tested on both i386 (biosboot/qemu) and amd64 (both
biosboot/qemu and efiboot/bare-metal). Correct behavior was observed
using the filenames printed by a preexisting printf(). The output
from ``boot'' commands without arguments was also confirmed to meet
expectations, and commands other than ``boot'' continued to work as
expected.

As discussed on tech-kern, port-i386, and port-amd64 mailing lists.
The more extensive documentation requested by riastradh@ should have
been dealt with more than five years ago with the initial KERNEL_DIR
commit; this commit doesn't pretend to meet that request. As noted
by kre@, the changes being made here are minor/trivial and highly
unlikely to break anything. These changes only affect booting in
new KERNEL_DIR environments; "legacy" environments are not affected.
 1.88 20-May-2025  pgoyette Reverrt previous. I will recomit with proper log message.
 1.87 20-May-2025  pgoyette /home/paul/COMMIT.txt
 1.86 06-May-2025  pgoyette Allow the dev= command when processing /boot.cfg file. This
addresses kern/59207
 1.85 30-Apr-2025  pgoyette Remove conditionals on KERNEL_DIR, and reorder the potential boot
locations to put the legacy ones first. This allows us to use a
single version of the bootstrap code regardless of the use of the
KERNEL_DIR build option, and should avoid spurious error messages
disrupting the automated testbeds.

Tested on i386 (non-KERNEL_DIR) and amd64 (both with and without
KERNEL_DIR). In all cases the anita installations succeeded and
the atf tests were initiated. Any remaining issues are most likely
due to subtle changes in text interaction and will probably need
updates to "expect" processing in anita.

If necessary this commit can be reverted, but please try to avoid
more churn, and update the testbed drivers as appropriate.
cvs: ----------------------------------------------------------------------
 1.84 29-Apr-2025  pgoyette KNF - blank linebetween data and code

Also make sure we leave space in the path[] for a possible '.gz' to
be appended.

Both suggestions from kre@ - thanks
 1.83 29-Apr-2025  pgoyette Update to pathnames for booting under KERNEL_DIR

Tested on i386 (wwithout KERNEL_DIR) and amd64 (both with and without)
 1.82 29-Apr-2025  martin Backout /filename/kernel changes, this breaks default installs
and needs more testing.
 1.81 29-Apr-2025  pgoyette If only a filename is given on the boot command, try /filename/kernel
and /filename/kernel.gz, and then /filename to minimize differences
between old andnew recovery procedures. No change to ``naked'' boot
commands, nor to boot commands with pathname containing `;'
 1.80 26-Apr-2025  christos Instead of faking the kernel path in KERNEL_DIR, use proper entries in
the array. This has the advantage of producing correct error messages.
 1.79 08-Jun-2022  wiz branches: 1.79.10;
Do not use default entry's parameters for for plain "boot" command

Go back to the "menu" instead of you want that.

Patch from RVP in PR 56862, ok uwe@
 1.78 07-Sep-2021  nia Remove banner printing code from bootloaders, add it to libsa.

This harmonizes efiboot and the various x86 bootloaders to use shared
code for printing the banner. By friendly coincidence, it also adds
support for specifying 'banner=' in arm efiboot's boot.cfg, as on x86.
 1.77 21-Jun-2021  nia use a single printf call for readability
 1.76 21-Jun-2021  nia biosboot: Add ASCII art.
 1.75 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.74 15-Jul-2020  kim branches: 1.74.6; 1.74.8;
Let consdev command also set speed

Adapted from PR install/55490 by Sunil Nimmagadda
 1.73 04-Apr-2020  christos Infrastructure for putting kernel+modules in /netbsd/kernel and
/netbsd/modules respectively instead of /netbsd and
/stand/<arch>/<version>/modules. This is only supported for x86,
and is turned off by default. To try it, add KERNEL_DIR=yes in your
/mk.conf and install a system from that build.
 1.72 02-Sep-2019  manu Make sure devices names are copied including last byte

Fix from M. Levinson.
 1.71 18-Aug-2019  manu Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:
boot NAME=root:/netbsd
boot raid0e:/netbsd
 1.70 14-Nov-2017  maxv branches: 1.70.4; 1.70.8;
Add missing ).
 1.69 08-Nov-2017  maxv Add pkboot in "help".
 1.68 11-Oct-2017  maxv Reset has_prekern if pkboot fails. Otherwise here:
pkboot wrong_kernel_path
boot netbsd
the prekern still gets invoked in the second command.
 1.67 07-Oct-2017  maxv Add a new option in libsa, to load dynamic binaries. A separate function
is used, and it does not break in any way the generic static loader. Then,
add a new "pkboot" command in the x86 bootloader, which boots a
GENERIC_KASLR kernel via the prekern. (See thread on tech-kern@.)
 1.66 03-Feb-2016  christos branches: 1.66.10;
PR/50748: David Binderman: check bounds before dereference
 1.65 11-Jun-2015  khorben Also document the "splash" command in boot(8)
 1.64 16-Jan-2015  christos Restore previous behavior: "boot -s" == "boot netbsd -s"
Instead of ignoring the flags and doing the default boot. Merge some
extraneous code.
XXX: Find the PR for this, close it and pullup to -7
 1.63 28-Jun-2014  rtr branches: 1.63.2; 1.63.4;
patch posted to tech-kern@ 2014/06/25 for review with minor changes
resulting from feedback.

move multiple copies of code for parsing boot.cfg file from sparc, i386
and zaurus into libsa/bootcfg.{h,c}. largely retained i386 parsing logic
in addition to keeping sparc dispatch function while remaining consistent
with boot.cfg(5).

previous sparc64 file format has been obsoleted but only used by boot
CDs distrib/sparc64/bootfs/boot.cfg has been updated to compensate.

exported names have been prefixed with either BOOTCFG_ or bootcfg_ as per
feedback from christos@

tested on amd64 & sparc64 but not zaurus.
 1.62 26-Mar-2014  christos branches: 1.62.2;
kill sprintf.
 1.61 20-Mar-2014  christos allow LS to be commented out
 1.60 30-Aug-2013  jmcneill Add support for using a raw file-system image as memory disk root with
the x86 bootloader.
 1.59 28-Jul-2013  he Two changes for the i386 boot loader related to the boot menu which
can be defined in boot.cfg:

* Add a "menu" command which re-displays the menu and initiates
the timed countdown
* Use any default command defined in boot.cfg as default args
if the user runs "boot" with no arguments

This is useful in circumstances where you e.g. need to interrupt
the normal boot process to switch to serial console, and where
simply "boot netbsd" is no longer sufficient (e.g. as with install
media which needs the miniroot kernel module loaded).
 1.58 04-Aug-2012  riastradh branches: 1.58.2; 1.58.4;
Fix i386 `boot' command to try the usual set of kernel names.

Without this, the `boot' command will try only `netbsd', not
`netbsd.gz', `netbsd.old', &c.

Patch from PR port-i386/44562.
 1.57 25-Dec-2011  tsutsui branches: 1.57.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.56 28-Nov-2011  tls branches: 1.56.2;

Add support for passing saved entropy (random seed file) to the kernel
from the bootloader. This can fix the problem of poor quality keys
for other kernel modules which call arc4random() early in kernel startup
(NFS startup, in particular, causes this).

We continue to rely on the etc/rc.d/random_seed script to save entropy
to the seed file at shutdown and erase the seed file at startup.

Boot loader support implemented only for i386 and amd64 ports for now but
it should be easy for other ports to do the same or similar.
 1.55 23-Jun-2011  mrg branches: 1.55.2;
cast a uint8_t * to a char * for a function that takes char *.
 1.54 26-May-2011  uebayasi Support userconf(4) command in boot(8)/boot.cfg(5) on i386/amd64.

From jmmv@, no objections seen in the proposed thread:

http://mail-index.netbsd.org/tech-kern/2009/01/22/msg004081.html
 1.53 18-Mar-2011  jakllsch Honor bp_timeout even if someone sets X86_BP_FLAGS_NOBOOTCONF.
 1.52 06-Feb-2011  jmcneill add support for passing image files to the kernel with the 'splash' keyword:

vesa on;splash /netbsd.jpg;boot -z
 1.51 05-Jan-2011  jakllsch branches: 1.51.2; 1.51.4;
Pass a 64-bit boot partition base LBA into x86 /boot,
while maintaining compatibility with existing bootxx code.
 1.50 20-Dec-2010  jakllsch MI libsa provides panic() and exit() functions, no need to provide our own.
As MI libsa exit() calls panic() with a "exit" message, don't use it if we
print our own farewell or have already panic()ed.
 1.49 06-Nov-2010  jym Bring the help command output from boot and pxeboot on par with their
code.
 1.48 08-Feb-2010  hubertf branches: 1.48.2;
When a password is set for the bootloader ("installboot -o password=..."),
it currently complains about an unknown command and prints a usage if the
password is entered wrong:

...
Choose an option; RETURN for default; SPACE to stop countdown.
Option 1 will be chosen in 0 seconds.
Password: *
Password: *
Password: *
unknown command
commands are:
boot [xdNx:][filename] [-12acdqsvxz]
(ex. "hd0a:netbsd.old -s"
ls [path]
dev xd[N[x]]:
consdev {pc|com[0123]|com[0123]kbd|auto}
modules {enabled|disabled}
load {path_to_module}
multiboot [xdNx:][filename] [<args>]
help|?
quit

Choose an option; RETURN for default; SPACE to stop countdown.
Option 1 will be chosen in 0 seconds.
...

This is confusing, plus someone may use it to determine bits of
information about the system. What should happen instead is that the user
is informed that the password is wrong:

...
Choose an option; RETURN for default; SPACE to stop countdown.
Option 1 will be chosen in 0 seconds.
Password: ****
Password: ****
Password: ****
Wrong password.

Choose an option; RETURN for default; SPACE to stop countdown.
...

Implement the latter behaviour.
 1.47 17-Jan-2010  drochner branches: 1.47.2;
Invert the flag bits to control module loading: rename
LOADMODULES->NOMODULES and READBOOTCONF->NOBOOTCONF.
This way, the default value (0) wired into old bootxx_* and installed
to file systems remains valid and we avoid problems on partial updates.
 1.46 14-Jan-2010  drochner On i386/amd64, define two flag bits in the boot parameters which control
whether modules are loaded and whether boot.cfg is evaluated, and
set both to "off" per default in the PXE bootloader.
Extend "installboot" to toggle the bits.
This way, pxeboot works with existing dhcp server setups (and as
described in the manpage) out of the box. Also, boot.cfg reading
involves a stat() call which is horribly inefficient with the
TFTP pseudo file system.
 1.45 13-Sep-2009  jmcneill Make the 'dev' command print out a list of known boot devices based on
information from the BIOS in addition to the currently selected default
partition. Handy when you don't know where to boot from. Here's a demo:

type "?" or "help" for help.
> dev
disk hd0 size 3815 MB
hd0a(4.2BSD) hd0b(swap)
disk cd0
cd0a(unknown)
default hd0a
>
 1.44 21-Mar-2009  ad Fix 'boot -z' bogons.
 1.43 16-Feb-2009  jmcneill Bootloader modifications for generic framebuffer console support on i386
and amd64 where VESA VBE 2.0+ is available.

* Add helper library and stubs to invoke VBE bioscalls.
* Bump HEAP_START as we were already dangerously close to our limits.
* bootdataseg now allows access > 16MB so in the future we can scribble
on the framebuffer.
* Pass BTINFO_FRAMEBUFFER parameters to kernel when configured.
* VBE modes are configured with the new 'vesa' command. Usage, when present:
* vesa {enabled|disabled}
Enable / disable linear framebuffer, default mode is 640x480x8. May
be changed in the future to determine mode based on VBE/DDC where
available.
* vesa list
List modes supported by the firmware that meet the following criteria:
* linear framebuffer
* packed pixel or direct colour mode
* vesa {modenum|modestr}
Enable specific VBE mode. The mode can be specified either as a
VBE mode number (eg. 0x101) or as a string (eg. 800x600x16).
 1.42 11-Jan-2009  christos branches: 1.42.2;
merge christos-time_t
 1.41 13-Dec-2008  christos add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.40 25-Nov-2008  ad Make pxeboot understand boot.cfg.
 1.39 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.38 11-Oct-2008  joerg branches: 1.38.2; 1.38.4; 1.38.8;
Add "multiboot" command to boot multiboot compliant kernels like Xen.
Patch provided by Robert Swindell with fixes for the command line
parsing and addition of passing module options from me. The kernel now
always gets the full string for modules like for the command line,
everything before the first space/tab is the path name of the module.
 1.37 26-Sep-2008  tsutsui Remove a hack which disables loading boot.cfg from ustarfs.
Now all bootfloppies have a proper boot.cfg file in ustarfs.

Tested on qemu.
(though qemu doesn't emulate timeout on the boot prompt properly)
 1.36 26-Sep-2008  christos The structure of our elf kernel is:

elf header/program headers/text/data/note/
section headers/symbol table/string table

We need to read the section headers first to find the offset of the note
and thus we requite backwards seek. The only reason we need to read the
note is to find the version of the kernel, and this seems not to be used
anywhere. We could potentially change the kernel ldscript to add the note
information in the program headers, but dealing with ldscripts is painful
and producing a more complex binary could break some dumb standalone loader.
So the simple solution is to just disable the note loading for floppies
which is what this patch does. If someone wants to fix it in a better way,
be my guest.
 1.35 20-Aug-2008  sborrill Fix display of "Option X will be chosen in" banner. The letter version of it
was always displayed even if number format was selected.
 1.34 12-Aug-2008  sborrill Increase number of menu options to 20.
Add support for switching menu format between numbers and letters. Will
prefer numbers, but will automatically switch to letters if > 9 options
and timeout > 0 (i.e. need a single key press to choose).
Menu format can be explicitly set in boot.cfg file.
Add support for reading numeric choices of more than 1 digit.
 1.33 08-Aug-2008  simonb Don't run off the end of the bootconf.desc[] array when printing out
the boot menu choices. Fixes problems with funny display when MAXMENU
or more "menu" items are in /boot.cfg.
 1.32 15-Jul-2008  perry Change the x86 boot blocks so they don't include builder login and date.

For now, we include kernel revision as a way of allowing users to
notice that boot blocks have gotten very old, so the first line of the
printout looks like this (depending on the particular block):

>> NetBSD/x86 BIOS Boot, Revision 3.4 (from NetBSD 5.0)

This may be changed a bit pending feedback. (Some people think that
the kernel revision shouldn't be there at all, for example.)

Part of the project to assure that bit-identical sources produce
bit-identical release binaries.
 1.31 21-May-2008  ad branches: 1.31.2; 1.31.4;
- Stop the twiddler going awry.
- Clear screen if on a glass tty (!).
 1.30 06-May-2008  lukem branches: 1.30.2;
Add a missing semicolon.
(mmm, compile before commit :)
 1.29 06-May-2008  apb Change the wording of a message, to make it clear that pressing SPACE
will stop the countdown timer. The message now reads "Choose an option;
RETURN for default; SPACE to stop countdown." It no longer says what
the default choice actually is, because the message printed on the
following line will do that.
 1.28 05-May-2008  chris Increase banner entries from 10 to 12. This allows all 12 lines of the cd
boot.cfg banner to be displayed.
 1.27 03-May-2008  ad Handle compressed modules.
 1.26 03-May-2008  sborrill Add support for multiple commands separated by semi-colons on menu lines
in boot.cfg.
e.g.
menu=Boot with module foo:load=/foo.kmod;boot
 1.25 02-May-2008  ad - Give x86 BIOS boot the ability to load new style modules and pass them
into the kernel. Based on a patch by jmcneill@, with many fixes and
improvements by me.

- Put MEMORY_DISK_DYNAMIC and MODULAR into the GENERIC kernels, so that
you can load miniroot.kmod from the boot blocks and boot into the
installer!
 1.24 30-Apr-2008  ad Tidy up console output slightly.
 1.23 29-Apr-2008  ad Adjust the help string for new options.
 1.22 23-Feb-2008  sborrill branches: 1.22.2; 1.22.4; 1.22.6;
Only attempt to output up to MAXBANNER banner lines
 1.21 05-Jan-2008  apb branches: 1.21.2; 1.21.6;
If a menu line in boot.cfg has an empty description, then re-use the
command as the description. For example,

menu=:boot netbsd -s

now works like

menu=boot netbsd -s:boot netbsd -s
 1.20 02-Jan-2008  sborrill Configuration file is boot.cfg, not boot.cnf, so fix comments
 1.19 29-Dec-2007  jmcneill Add -z to usage strings.
 1.18 29-Dec-2007  jmcneill Mention -x in command_help
 1.17 13-Dec-2007  sborrill Check whether we are loading from ustarfs and if so, do not attempt to
read boot.cfg.

Fixes PR install/37521. Heavily based on patch by Izumi Tsutsui.
 1.16 23-Nov-2007  sborrill branches: 1.16.2; 1.16.6;
Print a newline above the menu, but not below the custom banner.
This means that there is a consistent empty line above the menu both with
and without a custom banner.
 1.15 20-Nov-2007  sborrill Add support for /boot.cfg configuration file in x86 boot loader.
This allows easy configuration of banner text, console device and timeout
as well as allowing menus of commands to be displayed. If /boot.cfg
is not present, then the existing behaviour does not change.

The sections in the boot loader source are surrounded by #ifdef SMALL
allowing this functionality to be removed if space is at a premium.
 1.14 17-Oct-2007  garbled branches: 1.14.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.13 08-Jul-2007  ws branches: 1.13.8; 1.13.10; 1.13.14;
Fix "Fix a garbage in previous commit." in 1.10.

Hi, junyoung!
 1.12 11-Dec-2005  christos branches: 1.12.30; 1.12.32; 1.12.38;
merge ktrace-lwp.
 1.11 22-Jun-2005  junyoung branches: 1.11.2;
Add support for cd9660 file system to the i386 BIOS bootloader.
 1.10 21-Jun-2005  junyoung - It is worthless to endlessly try to boot unbootable images. If all predefined
boot images are failed to boot, fall into the prompt.
- Fix a garbage in previous commit.
 1.9 21-Jun-2005  junyoung More cosmetic changes.
 1.8 21-Jun-2005  junyoung - KNF & cosmetic changes
- Remove #if 0'ed netbsd.el{,.gz} from bootfile list. I have no idea what
those files are (emacs lisp source??? :-).
 1.7 15-Jun-2005  junyoung Cosmetic changes.
 1.6 15-Jun-2005  junyoung KNF & notably, use u_int rather than unsigned int for now for consistency.
This should be reversed eventually...
 1.5 25-Nov-2004  christos include sys/types.h to make this compile again.
 1.4 08-Oct-2003  lukem branches: 1.4.4;
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 06-Oct-2003  lukem Replace BP_* with I386_BP_FLAGS_*, for consistency with other stuff in
<sys/bootblock.h>
(CONSDEV_ should be converted as well, but that's more intrusive...)
 1.2 27-Jul-2003  mrg rewrite an undefined assignment
 1.1 16-Apr-2003  dsl branches: 1.1.2;
Add files for 2nd stage boot loader
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 29-Nov-2004  skrll Sync with HEAD.
 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.4.4.1 07-Apr-2005  jwise Pull up revision 1.5, requested by tron in [pullup-2-0 #1408]:

include sys/types.h to make this compile again.
 1.11.2.4 27-Feb-2008  yamt sync with head.
 1.11.2.3 21-Jan-2008  yamt sync with head
 1.11.2.2 07-Dec-2007  yamt sync with head
 1.11.2.1 03-Sep-2007  yamt sync with head.
 1.12.38.1 03-Oct-2007  garbled Sync with HEAD
 1.12.32.1 11-Jul-2007  mjf Sync with head.
 1.12.30.3 03-Dec-2007  ad Sync with HEAD.
 1.12.30.2 03-Dec-2007  ad Sync with HEAD.
 1.12.30.1 15-Jul-2007  ad Sync with head.
 1.13.14.1 21-Nov-2007  bouyer Sync with HEAD
 1.13.10.3 23-Mar-2008  matt sync with HEAD
 1.13.10.2 09-Jan-2008  matt sync with HEAD
 1.13.10.1 06-Nov-2007  matt sync with HEAD
 1.13.8.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.13.8.1 21-Nov-2007  joerg Sync with HEAD.
 1.14.2.3 18-Feb-2008  mjf Sync with HEAD.
 1.14.2.2 27-Dec-2007  mjf Sync with HEAD.
 1.14.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.6.3 08-Jan-2008  bouyer Sync with HEAD
 1.16.6.2 02-Jan-2008  bouyer Sync with HEAD
 1.16.6.1 13-Dec-2007  bouyer Sync with HEAD
 1.16.2.1 26-Dec-2007  ad Sync with head.
 1.21.6.4 17-Jan-2009  mjf Sync with HEAD.
 1.21.6.3 28-Sep-2008  mjf Sync with HEAD.
 1.21.6.2 02-Jun-2008  mjf Sync with HEAD.
 1.21.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.2.1 24-Mar-2008  keiichi sync with head.
 1.22.6.4 11-Mar-2010  yamt sync with head
 1.22.6.3 16-Sep-2009  yamt sync with head
 1.22.6.2 04-May-2009  yamt sync with head.
 1.22.6.1 16-May-2008  yamt sync with head.
 1.22.4.2 04-Jun-2008  yamt sync with head
 1.22.4.1 18-May-2008  yamt sync with head.
 1.22.2.4 27-Dec-2008  christos merge with head.
 1.22.2.3 20-Nov-2008  christos merge with head.
 1.22.2.2 01-Nov-2008  christos Sync with head.
 1.22.2.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.30.2.3 10-Oct-2008  skrll Sync with HEAD.
 1.30.2.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.30.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.31.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.31.4.1 19-Oct-2008  haad Sync with HEAD.
 1.31.2.1 18-Jul-2008  simonb Sync with head.
 1.38.8.1 21-Apr-2010  matt sync to netbsd-5
 1.38.4.3 07-Sep-2013  bouyer Pull up following revision(s) (requested by he in ticket #1872):
sys/arch/i386/stand/lib/bootmenu.c: revision 1.11 via patch
sys/arch/i386/stand/lib/bootmenu.h: revision 1.3 via patch
sys/arch/i386/stand/boot/boot2.c: revision 1.59 via patch
Two changes for the i386 boot loader related to the boot menu which
can be defined in boot.cfg:
* Add a "menu" command which re-displays the menu and initiates
the timed countdown
* Use any default command defined in boot.cfg as default args
if the user runs "boot" with no arguments
This is useful in circumstances where you e.g. need to interrupt
the normal boot process to switch to serial console, and where
simply "boot netbsd" is no longer sufficient (e.g. as with install
media which needs the miniroot kernel module loaded).
 1.38.4.2 14-Feb-2010  bouyer Pull up following revision(s) (requested by hubertf in ticket #1304):
sys/arch/i386/stand/boot/boot2.c: revision 1.48
When a password is set for the bootloader ("installboot -o password=..."),
it currently complains about an unknown command and prints a usage if the
password is entered wrong:
...
Choose an option; RETURN for default; SPACE to stop countdown.
Option 1 will be chosen in 0 seconds.
Password: *
Password: *
Password: *
unknown command
commands are:
boot [xdNx:][filename] [-12acdqsvxz]
(ex. "hd0a:netbsd.old -s"
ls [path]
dev xd[N[x]]:
consdev {pc|com[0123]|com[0123]kbd|auto}
modules {enabled|disabled}
load {path_to_module}
multiboot [xdNx:][filename] [<args>]
help|?
quit
Choose an option; RETURN for default; SPACE to stop countdown.
Option 1 will be chosen in 0 seconds.
...
This is confusing, plus someone may use it to determine bits of
information about the system. What should happen instead is that the user
is informed that the password is wrong:
...
Choose an option; RETURN for default; SPACE to stop countdown.
Option 1 will be chosen in 0 seconds.
Password: ****
Password: ****
Password: ****
Wrong password.
Choose an option; RETURN for default; SPACE to stop countdown.
...
Implement the latter behaviour.
 1.38.4.1 18-Oct-2009  bouyer Apply patch, requested by snj in ticket 1080:
sys/arch/i386/stand/boot/boot2.c: patch

- If the menuformat is not letter, do not allow letter keys to be
aliases for number keys.
- Don't treat timeouts or the return key as an invalid choice.
 1.38.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.38.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.38.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.42.2.5 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.42.2.4 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.42.2.3 28-Mar-2011  jym Sync with HEAD. TODO before merge:
- shortcut for suspend code in sysmon, when powerd(8) is not running.
Borrow ``xs_watch'' thread context?
- bug hunting in xbd + xennet resume. Rings are currently thrashed upon
resume, so current implementation force flush them on suspend. It's not
really needed.
 1.42.2.2 01-Nov-2009  jym Sync with HEAD.
 1.42.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.47.2.2 09-Nov-2010  uebayasi Sync with HEAD.
 1.47.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.48.2.3 31-May-2011  rmind sync with head
 1.48.2.2 21-Apr-2011  rmind sync with head
 1.48.2.1 05-Mar-2011  rmind sync with head
 1.51.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.51.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.55.2.3 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.55.2.2 30-Oct-2012  yamt sync with head
 1.55.2.1 17-Apr-2012  yamt sync with head
 1.56.2.1 18-Feb-2012  mrg merge to -current.
 1.57.2.2 10-Aug-2013  riz Pull up following revision(s) (requested by he in ticket #925):
sys/arch/i386/stand/lib/bootmenu.c: revision 1.11
sys/arch/i386/stand/lib/bootmenu.h: revision 1.3
sys/arch/i386/stand/boot/boot2.c: revision 1.59
Two changes for the i386 boot loader related to the boot menu which
can be defined in boot.cfg:
* Add a "menu" command which re-displays the menu and initiates
the timed countdown
* Use any default command defined in boot.cfg as default args
if the user runs "boot" with no arguments
This is useful in circumstances where you e.g. need to interrupt
the normal boot process to switch to serial console, and where
simply "boot netbsd" is no longer sufficient (e.g. as with install
media which needs the miniroot kernel module loaded).
 1.57.2.1 12-Aug-2012  martin Pull up following revision(s) (requested by riastradh in ticket #479):
sys/arch/i386/stand/boot/boot2.c: revision 1.58
Fix i386 `boot' command to try the usual set of kernel names.
Without this, the `boot' command will try only `netbsd', not
`netbsd.gz', `netbsd.old', &c.
Patch from PR port-i386/44562.
 1.58.4.2 18-May-2014  rmind sync with head
 1.58.4.1 28-Aug-2013  rmind sync with head
 1.58.2.2 03-Dec-2017  jdolecek update from HEAD
 1.58.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.62.2.1 10-Aug-2014  tls Rebase.
 1.63.4.3 19-Mar-2016  skrll Sync with HEAD
 1.63.4.2 22-Sep-2015  skrll Sync with HEAD
 1.63.4.1 06-Apr-2015  skrll Sync with HEAD
 1.63.2.1 17-Jan-2015  martin Pull up following revision(s) (requested by christos in ticket #426):
sys/arch/i386/stand/boot/boot2.c: revision 1.64
Restore previous behavior: "boot -s" == "boot netbsd -s"
Instead of ignoring the flags and doing the default boot. Merge some
extraneous code.
 1.66.10.2 15-Jul-2020  martin Pull up following revision(s) (requested by kim in ticket #1575):

sys/arch/i386/stand/boot/boot2.c: revision 1.74
share/man/man8/man8.x86/boot.8: revision 1.21

Let consdev command also set speed
Adapted from PR install/55490 by Sunil Nimmagadda

Document optional speed argument to consdev
 1.66.10.1 17-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #1373):

sys/arch/i386/stand/boot/boot2.c: revision 1.72 (patch)
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14 (patch)
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71

Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:

boot NAME=root:/netbsd
boot raid0e:/netbsd

Correct the memset(3)'s third argument in i386 biosdisk.c

The size of allocation is the size of the structure biosdisk, not the size
of a pointer.

Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs

Typo fixes, 'file system'; new sentence, new line; expand IA-32.

Bump date for previous.

Make sure devices names are copied including last byte
Fix from M. Levinson.
 1.70.8.2 15-Jul-2020  martin Pull up following revision(s) (requested by kim in ticket #1013):

sys/arch/i386/stand/boot/boot2.c: revision 1.74
share/man/man8/man8.x86/boot.8: revision 1.21

Let consdev command also set speed
Adapted from PR install/55490 by Sunil Nimmagadda

Document optional speed argument to consdev
 1.70.8.1 13-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #200):

sys/arch/i386/stand/boot/boot2.c: revision 1.72
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71

Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:

boot NAME=root:/netbsd
boot raid0e:/netbsd

Correct the memset(3)'s third argument in i386 biosdisk.c

The size of allocation is the size of the structure biosdisk, not the size
of a pointer.

Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs

Typo fixes, 'file system'; new sentence, new line; expand IA-32.
Bump date for previous.

Make sure devices names are copied including last byte
Fix from M. Levinson.
 1.70.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.70.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.74.8.1 31-May-2021  cjep sync with head
 1.74.6.2 01-Aug-2021  thorpej Sync with HEAD.
 1.74.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.79.10.1 02-Aug-2025  perseant Sync with HEAD
 1.89.2.1 31-Jul-2025  martin Pull up following revision(s) (requested by pgoyette in ticket #3):

sys/arch/i386/stand/boot/boot2.c: revision 1.90
sys/arch/i386/stand/efiboot/boot.c: revision 1.33

Reorder the names[] array to put the supported/historical entries
first. Should eliminate some unwanted and confusing messages.
 1.6 16-Jan-2012  christos PR/45796: Evgeniy Ivanov minixfs3 support.
 1.5 05-Apr-2008  tsutsui branches: 1.5.38; 1.5.42;
Add commented out ext2fs definitions.
 1.4 11-Dec-2005  christos branches: 1.4.74;
merge ktrace-lwp.
 1.3 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.2 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.1 16-Apr-2003  dsl branches: 1.1.2;
Add files for 2nd stage boot loader
 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.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.42.1 18-Feb-2012  mrg merge to -current.
 1.5.38.1 17-Apr-2012  yamt sync with head
 1.10 10-Dec-2019  manu In-RAID partitions with no name can be candidate for booting

The code to select boot partition in RAID assumed thet had a name,
which is true when there is a GPT inside the RAID, but not when there
is a disklabel inside the RAID. This caused a regression from behavior
of NetBSD 8.1.

We fix this by allowing nameless partition to be boot candidates.
This fixes misc/54748

While there, let raid device be used in the boot specification, like
raid0a:/netbsd.
 1.9 18-Aug-2019  manu Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:
boot NAME=root:/netbsd
boot raid0e:/netbsd
 1.8 24-Dec-2010  jakllsch branches: 1.8.52; 1.8.60; 1.8.64;
Sprinkle daddr_t.
 1.7 02-May-2008  ad branches: 1.7.14; 1.7.22;
- Give x86 BIOS boot the ability to load new style modules and pass them
into the kernel. Based on a patch by jmcneill@, with many fixes and
improvements by me.

- Put MEMORY_DISK_DYNAMIC and MODULAR into the GENERIC kernels, so that
you can load miniroot.kmod from the boot blocks and boot into the
installer!
 1.6 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78;
merge ktrace-lwp.
 1.4 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.3 15-Jun-2005  junyoung ANSI, KNF, de-__P, and various cosmetic changes.
 1.2 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.1 16-Apr-2003  dsl branches: 1.1.2;
Add files for 2nd stage boot loader
 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.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.1 18-May-2008  yamt sync with head.
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.22.1 05-Mar-2011  rmind sync with head
 1.7.14.1 10-Jan-2011  jym Sync with HEAD
 1.8.64.2 17-Dec-2019  martin Pull up following revision(s) (requested by manu in ticket #567):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.53
sys/arch/i386/stand/efiboot/devopen.c: revision 1.9
sys/arch/i386/stand/boot/devopen.c: revision 1.10

In-RAID partitions with no name can be candidate for booting

The code to select boot partition in RAID assumed thet had a name,
which is true when there is a GPT inside the RAID, but not when there
is a disklabel inside the RAID. This caused a regression from behavior
of NetBSD 8.1.

We fix this by allowing nameless partition to be boot candidates.
This fixes misc/54748

While there, let raid device be used in the boot specification, like
raid0a:/netbsd.
 1.8.64.1 13-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #200):

sys/arch/i386/stand/boot/boot2.c: revision 1.72
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71

Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:

boot NAME=root:/netbsd
boot raid0e:/netbsd

Correct the memset(3)'s third argument in i386 biosdisk.c

The size of allocation is the size of the structure biosdisk, not the size
of a pointer.

Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs

Typo fixes, 'file system'; new sentence, new line; expand IA-32.
Bump date for previous.

Make sure devices names are copied including last byte
Fix from M. Levinson.
 1.8.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.52.2 17-Dec-2019  martin Pull up following revision(s) (requested by manu in ticket #1473):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.53
sys/arch/i386/stand/efiboot/devopen.c: revision 1.9
sys/arch/i386/stand/boot/devopen.c: revision 1.10

In-RAID partitions with no name can be candidate for booting

The code to select boot partition in RAID assumed thet had a name,
which is true when there is a GPT inside the RAID, but not when there
is a disklabel inside the RAID. This caused a regression from behavior
of NetBSD 8.1.

We fix this by allowing nameless partition to be boot candidates.
This fixes PR misc/54748

While there, let raid device be used in the boot specification, like
raid0a:/netbsd.
 1.8.52.1 17-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #1373):

sys/arch/i386/stand/boot/boot2.c: revision 1.72 (patch)
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14 (patch)
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71

Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:

boot NAME=root:/netbsd
boot raid0e:/netbsd

Correct the memset(3)'s third argument in i386 biosdisk.c

The size of allocation is the size of the structure biosdisk, not the size
of a pointer.

Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs

Typo fixes, 'file system'; new sentence, new line; expand IA-32.

Bump date for previous.

Make sure devices names are copied including last byte
Fix from M. Levinson.
 1.5 18-Aug-2019  manu Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:
boot NAME=root:/netbsd
boot raid0e:/netbsd
 1.4 24-Dec-2010  jakllsch branches: 1.4.52; 1.4.60; 1.4.64;
Sprinkle daddr_t.
 1.3 11-Dec-2005  christos branches: 1.3.92; 1.3.100;
merge ktrace-lwp.
 1.2 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.1 16-Apr-2003  dsl branches: 1.1.2;
Add files for 2nd stage boot loader
 1.1.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.100.1 05-Mar-2011  rmind sync with head
 1.3.92.1 10-Jan-2011  jym Sync with HEAD
 1.4.64.1 13-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #200):

sys/arch/i386/stand/boot/boot2.c: revision 1.72
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71

Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:

boot NAME=root:/netbsd
boot raid0e:/netbsd

Correct the memset(3)'s third argument in i386 biosdisk.c

The size of allocation is the size of the structure biosdisk, not the size
of a pointer.

Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs

Typo fixes, 'file system'; new sentence, new line; expand IA-32.
Bump date for previous.

Make sure devices names are copied including last byte
Fix from M. Levinson.
 1.4.60.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.52.1 17-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #1373):

sys/arch/i386/stand/boot/boot2.c: revision 1.72 (patch)
sys/arch/i386/stand/lib/biosdisk.c: revision 1.50
sys/arch/i386/stand/lib/biosdisk.c: revision 1.51
sys/arch/i386/stand/efiboot/devopen.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.4
sys/arch/i386/stand/efiboot/devopen.c: revision 1.7
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.8
share/man/man8/man8.x86/boot.8: revision 1.16
share/man/man8/man8.x86/boot.8: revision 1.17
sys/arch/i386/stand/lib/Makefile: revision 1.46
sys/arch/i386/stand/boot/devopen.h: revision 1.5
sys/arch/i386/stand/boot/devopen.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.14 (patch)
sys/arch/i386/stand/efiboot/boot.c: revision 1.15
sys/arch/i386/stand/lib/biosdisk.h: revision 1.11
sys/arch/i386/stand/boot/boot2.c: revision 1.71

Add GPT and RAIDframe support to bootloaders

Classic BIOS (/boot) and EFI bootloaders can now name devices
using the NAME=gpt_label syntax, or using raid partitions. Here
are examples:

boot NAME=root:/netbsd
boot raid0e:/netbsd

Correct the memset(3)'s third argument in i386 biosdisk.c

The size of allocation is the size of the structure biosdisk, not the size
of a pointer.

Document new GPT and RAIDframe capacity of bootstrap code
While there, also document EFI setup and some bugs

Typo fixes, 'file system'; new sentence, new line; expand IA-32.

Bump date for previous.

Make sure devices names are copied including last byte
Fix from M. Levinson.
 1.18 20-Sep-2024  mrg x86/boot: fill in a bunch of missed changes and bump some versions.

missed features included:
- support for partition labels
- recursive labels inside RAID partitions
- booting a directory with kernel and modules
- multiBoot 2
- "root" command that changes default root
- "vesa" command to control graphical modes
- bi-endian support in disklabel, RAID and UFS
- fixes for buggy ACPI implementations
- fix PXE device path type
- fixes for buggy ACPI implementations
- serial console support with raw I/O accessors
- ASCII art

XXX: perhaps we could pullup some of these as minor version to release
branches but it seems extreme for a largely cosmetic issue. the
version across releases has a different build ID, so you can
already tell the difference between versions that changed.
 1.17 07-Oct-2017  maxv branches: 1.17.40;
Bump bootloader version, support for booting KASLR amd64 kernels.
 1.16 30-Aug-2013  jmcneill Bump bootloader version for memory disk image changes.
 1.15 09-Feb-2011  jmcneill branches: 1.15.4; 1.15.14; 1.15.18;
Add VESA VBE/DDC EDID support for determining the monitor's preferred
video mode. "vesa on" will now select the preferred mode @ 8bpp if it can
be determined and is supported by the display adapter, otherwise it will
use 640x480 @ 8bpp.
 1.14 06-Feb-2011  jmcneill add support for passing image files to the kernel with the 'splash' keyword:

vesa on;splash /netbsd.jpg;boot -z
 1.13 05-Jan-2011  jakllsch branches: 1.13.2; 1.13.4;
Pass a 64-bit boot partition base LBA into x86 /boot,
while maintaining compatibility with existing bootxx code.
 1.12 05-Jan-2011  jakllsch NetBSD/x86 BIOS Boot 5.6: now with GUID Partition Table support.
 1.11 05-Jan-2011  jakllsch Note stack/heap changes made in revision 1.47 of Makefile.boot with version 5.5.
 1.10 24-Aug-2009  jmcneill branches: 1.10.4;
Bump bootloader version for VBE changes.
 1.9 19-Nov-2008  ad branches: 1.9.4;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.8 11-Oct-2008  joerg branches: 1.8.2;
Add "multiboot" command to boot multiboot compliant kernels like Xen.
Patch provided by Robert Swindell with fixes for the command line
parsing and addition of passing module options from me. The kernel now
always gets the full string for modules like for the command line,
everything before the first space/tab is the path name of the module.
 1.7 15-Jul-2008  perry Update the version numbers following commit, and make them all identical.
 1.6 02-May-2008  ad branches: 1.6.2; 1.6.4; 1.6.6;
- Give x86 BIOS boot the ability to load new style modules and pass them
into the kernel. Based on a patch by jmcneill@, with many fixes and
improvements by me.

- Put MEMORY_DISK_DYNAMIC and MODULAR into the GENERIC kernels, so that
you can load miniroot.kmod from the boot blocks and boot into the
installer!
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78;
merge ktrace-lwp.
 1.4 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.3 23-Oct-2004  thorpej Add support for passing booted wedge information to the kernel.
 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;
Add files for 2nd stage boot loader
 1.1.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.2.4 02-Nov-2004  skrll Sync with HEAD.
 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.5.78.3 16-Sep-2009  yamt sync with head
 1.5.78.2 04-May-2009  yamt sync with head.
 1.5.78.1 16-May-2008  yamt sync with head.
 1.5.76.1 18-May-2008  yamt sync with head.
 1.5.74.3 17-Jan-2009  mjf Sync with HEAD.
 1.5.74.2 28-Sep-2008  mjf Sync with HEAD.
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.6.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.6.1 19-Oct-2008  haad Sync with HEAD.
 1.6.4.1 18-Jul-2008  simonb Sync with head.
 1.6.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.8.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.9.4.3 28-Mar-2011  jym Sync with HEAD. TODO before merge:
- shortcut for suspend code in sysmon, when powerd(8) is not running.
Borrow ``xs_watch'' thread context?
- bug hunting in xbd + xennet resume. Rings are currently thrashed upon
resume, so current implementation force flush them on suspend. It's not
really needed.
 1.9.4.2 10-Jan-2011  jym Sync with HEAD
 1.9.4.1 01-Nov-2009  jym Sync with HEAD.
 1.10.4.1 05-Mar-2011  rmind sync with head
 1.13.4.2 17-Feb-2011  bouyer Sync with HEAD
 1.13.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.13.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.15.18.1 18-May-2014  rmind sync with head
 1.15.14.2 03-Dec-2017  jdolecek update from HEAD
 1.15.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.4.1 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.17.40.1 02-Aug-2025  perseant Sync with HEAD
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 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;
Add files for 2nd stage boot loader
 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

RSS XML Feed