Home | History | Annotate | only in /src/sys/arch/i386/stand
History log of /src/sys/arch/i386/stand
RevisionDateAuthorComments
 1.29 08-Jul-2018  christos Enable efiboot on i386, for 32 bit bootblocks
 1.28 24-Jan-2017  nonaka branches: 1.28.12; 1.28.14;
Initial commit of native amd64 EFI boot loader.
 1.27 27-Jan-2012  jnemeth branches: 1.27.6; 1.27.24; 1.27.28; 1.27.32;
Stop building boot ROM images for old PC NICs as discussed on tech-kern.
 1.26 29-Dec-2010  jakllsch branches: 1.26.8; 1.26.12;
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.25 06-Jan-2007  dsl branches: 1.25.62; 1.25.70;
Descend into fatboot, regroup slightly
 1.24 12-Nov-2005  dsl branches: 1.24.22;
No need to build pxeboot_com0 any more
 1.23 26-Jul-2003  dsl branches: 1.23.16;
No longer build biosboot*.sym and installboot.
 1.22 12-May-2003  dsl branches: 1.22.2;
Build my new i386 bootcode
 1.21 30-Apr-2003  dsl Build mbr code here (instead of in sbin/fdisk/mbr)
 1.20 14-Jan-2003  thorpej Allow the serial console boot blocks to be built with a specific
console speed, and build some of the more common ones.
 1.19 12-Apr-2002  tv branches: 1.19.2;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.18 20-Feb-2002  thorpej * Rename the pxeboot binary from "pxeboot" to "pxeboot_ia32", since
there are other architectures (e.g. IA64) which also use PXE.
* Get the console right in pxeboot, from Andreas Gustafsson.
* Add a "com0" version of pxeboot, to address the same issue that
biosboot_com0 addresses.
 1.17 19-Feb-2002  thorpej Move the individual NIC ROM Makefiles into a subdirectories of
netboot. Requested by Christos.
 1.16 17-Feb-2002  thorpej Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.15 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.14 02-May-2001  jdolecek branches: 1.14.4;
Nuke biosboot_ps2
 1.13 13-May-2000  jdolecek branches: 1.13.8;
add special bootblocks for IBM PS/2 - those machines need different gate A20
addressing
 1.12 23-Apr-2000  tsarna Addredd port-i386/9897, but differently. Since the effect of resetting
the video mode on machines with ancient or no video cards is not clear,
for safety's sake a I created a new biosboot variant, biosboot_resetvideo
that does the call.

Anyway, now I can boot my i-opener without hitting Tab. Thanks Andrew!
 1.11 15-Jan-2000  christos Build biosboot_com0 too.
 1.10 14-Mar-1999  sommerfe branches: 1.10.8;
Turn off biosboot_ser until makefile issues get worked out..
 1.9 12-Mar-1999  sommerfe Also build serial bootblocks by default, installing into
/usr/mdec/biosboot_ser.sym
Change Makefile.booters to not assume `version' file is in source directory.
 1.8 14-Mar-1997  perry Ressurect (not quite, since this is in fact the new boot code Makefile
now).
 1.7 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.6 01-Feb-1996  mycroft LOCORE -> _LOCORE
 1.5 27-Oct-1994  cgd new RCS ID format.
 1.4 31-Jul-1993  mycroft Add RCS indentifiers.
 1.3 22-May-1993  cgd add rcsids to everything and clean up headers
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.8.4 15-Jan-2003  thorpej Sync with HEAD.
 1.13.8.3 17-Apr-2002  nathanw Catch up to -current.
 1.13.8.2 28-Feb-2002  nathanw Catch up to -current.
 1.13.8.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.14.4.1 16-Mar-2002  jdolecek Catch up with -current.
 1.19.2.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.19.2.1 12-Apr-2002  tv file Makefile was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:11:59 +0000
 1.22.2.4 11-Dec-2005  christos Sync with head.
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.16.2 26-Feb-2007  yamt sync with head.
 1.23.16.1 21-Jun-2006  yamt sync with head.
 1.24.22.1 12-Jan-2007  ad Sync with head.
 1.25.70.1 05-Mar-2011  rmind sync with head
 1.25.62.1 10-Jan-2011  jym Sync with HEAD
 1.26.12.1 18-Feb-2012  mrg merge to -current.
 1.26.8.1 17-Apr-2012  yamt sync with head
 1.27.32.1 21-Apr-2017  bouyer Sync with HEAD
 1.27.28.1 20-Mar-2017  pgoyette Sync with HEAD
 1.27.24.1 05-Feb-2017  skrll Sync with HEAD
 1.27.6.1 03-Dec-2017  jdolecek update from HEAD
 1.28.14.1 10-Jun-2019  christos Sync with HEAD
 1.28.12.1 28-Jul-2018  pgoyette Sync with HEAD
 1.101 29-Jun-2024  rin i386: stand: Tiny clean up for `start_pxeboot.o`, NFC
 1.100 29-Jun-2024  rin i386: stand: Adjust for DOS-routine migration
 1.99 29-Jun-2024  rin i386: stand: Drop `*.rom` support; only used for netboot
 1.98 29-Jun-2024  rin i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.97 29-Jun-2024  rin i386: stand: G/C `genprom`; used only by netboot
 1.96 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.95 18-Jan-2023  christos Fix the clang build by setting -z noseparate-code
 1.94 06-Sep-2020  mrg branches: 1.94.20;
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.93 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.92 02-Jun-2018  christos branches: 1.92.2;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.91 08-Apr-2017  christos branches: 1.91.12;
centralize vers.c building for standalone programs.
 1.90 08-Mar-2015  martin branches: 1.90.2; 1.90.4;
Compile the bootblocks for i386 CPUs, even when the main target architecture
is amd64.
Fixes PR port-i386/49725.
 1.89 12-Jan-2014  tsutsui branches: 1.89.4; 1.89.6;
Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.

XXX: probabry we should have bsd.saprog.mk or something.
 1.88 21-Aug-2013  matt Set KLINK_MACHINE
 1.87 21-Aug-2013  matt Use <bsd.klinks.mk>
 1.86 10-Aug-2012  joerg branches: 1.86.2; 1.86.4;
Don't depend on HAVE_GCC being always present.
 1.85 20-Jun-2011  mrg branches: 1.85.2;
remove all the code that supported HAVE_GCC=3. mostly from chuq.
 1.84 16-Jun-2011  joerg Refactor compiler-specific optimizer flags. Mark bootxx as supported
with clang.
 1.83 09-Apr-2011  joerg branches: 1.83.2;
Do not ignore errors from genprom.
 1.82 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.81 22-Dec-2010  jakllsch branches: 1.81.2; 1.81.4;
It just so happens we don't need -Wno-attributes if we
place __packed in the right place.
 1.80 06-Jul-2010  mrg remove almost all the ability to build netbsd with an a.out target.
we're ELF now, and there are many missing checks against OBJECT_FMT.
if we ever consider switching, the we can figure out what new ones
we need but for now it's just clutter.

this doesn't remove any of the support for exec_aout or any actually
required-for-boot a.out support, only the ability to build a netbsd
release in a.out format. ie, most of this code has been dead for
over a decade.

i've tested builds on vax, amd64, i386, mac68k, macppc, sparc, atari,
amiga, shark, cats, dreamcast, landisk, mmeye and x68k. this covers
the 5 MACHINE_ARCH's affected, and all the other arch code touched.
it also includes some actual run-time testing of sparc, i386 and
shark, and i performed binary comparison upon amiga and x68k as well.


some minor details relevant:
- move shlib.[ch] from ld.aout_so into ldconfig proper, and cut them
down to only the parts ldconfig needs
- remove various unused source files
- switch amiga bootblocks to using elf2bb.h instead of aout2bb.h
 1.79 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.78 30-Mar-2009  tsutsui branches: 1.78.2; 1.78.4;
Remove extra trailing slash in ${S} path.
 1.77 08-Jan-2009  jakllsch branches: 1.77.2;
Use ${VERSIONFILE} instead of ${.ALLSRC} to match Makefile.boot.

This change stops the full path of newvers_stand.sh from showing up in
pxeboot_ia32.bin.
 1.76 29-Aug-2008  gmcgarry branches: 1.76.2; 1.76.4;
Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.75 16-Jul-2008  perry Call newvers_stand.sh with -DM so we don't include the (unused) date
and builder in the data segment.
 1.74 16-Jul-2008  perry make vers.c also depend on the script that builds vers.c
 1.73 17-Oct-2007  garbled branches: 1.73.16; 1.73.20; 1.73.22; 1.73.24; 1.73.26;
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.72 27-Sep-2007  ad Remove -DBOOT_ELF64 to make build on amd64.
 1.71 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.70 12-Jul-2006  yamt branches: 1.70.14; 1.70.22; 1.70.32; 1.70.34; 1.70.36;
revert the previous because it doesn't work without destdir populated.
pointed by Valeriy E. Ushakov.
 1.69 12-Jul-2006  yamt -I${S}/../common/include for libprop.
 1.68 25-Jun-2006  lukem Convert to using CC instead of LD, as LDFLAGS is for CC not LD.
 1.67 25-Jun-2006  lukem whitespace consistency
 1.66 12-Jun-2006  dogcow branches: 1.66.2;
Add -Wno-attributes for amd64, too.
 1.65 13-May-2006  lukem branches: 1.65.2;
When creating BASE.rom, don't use BASE.bin as a temporary filename,
since the latter is a valid target name.
 1.64 13-May-2006  lukem support MAKEVERBOSE
 1.63 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.62 11-Dec-2005  christos branches: 1.62.4; 1.62.6; 1.62.8; 1.62.12;
merge ktrace-lwp.
 1.61 17-Sep-2005  chs use a .BEGIN target to make the various symlinks,
the previous way had problems with parallel make.
 1.60 05-May-2005  christos branches: 1.60.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.59 01-May-2005  christos PR/9567: Arne H. Juul: .BEGIN targets should not use dependencies.
 1.58 06-Sep-2004  thorpej branches: 1.58.10;
Use CPUFLAGS for codegen options.
 1.57 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.56 07-Nov-2003  dsl branches: 1.56.2;
stand/lib/crt/rom is no more, no need for it in .PATH
 1.55 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.54 08-Oct-2003  dsl Need to explicitly create directory behing symlink.
Clean share lib directory.
 1.53 08-Oct-2003  dsl Only build the libraries once,
 1.52 08-Oct-2003  dsl BSSTART was only used for the (now depracated) old stand/biosboot code.
 1.51 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.50 05-May-2003  fvdl branches: 1.50.2;
Use ${MACHINE} when generating the version string, not plain 'i386'.
 1.49 04-May-2003  lukem be consistent with other Makefiles here and invoke "rm -f" separately to ln -s
 1.48 04-May-2003  lukem replace "ln -sf .... $@" with "rm -f $@ && ln -s .... $@"
since the latter works correctly ...
 1.47 03-May-2003  fvdl Clean up machine include dir handling a tad.
 1.46 16-Apr-2003  dsl Remove definition of LIBSA_SUPPORT_UFS2, the source will only build separate
ufsv1 and ufsv2 objects (the merged one was too large for the code that only
supported a single fs type).
 1.45 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.44 11-Mar-2003  drochner create a symlink so that eg <x86/trap.h> is found
 1.43 03-Feb-2003  briggs Revert my last change. While it actually allows a build to finish,
an iso-image created from the resulting release won't boot. I don't
know if this change is the source of that, but one more knowledgable
than I about the x86 booter needs to look at this, and I don't want
the waters muddied any more than necessary.
 1.42 03-Feb-2003  briggs Add CPPFLAGS+= -D__daddr_t=int32_t.
 1.41 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.40 29-Jan-2003  fvdl Make the ld workaround work on x88_64, and add the temporary ld script
to CLEANFILES.
 1.39 28-Jan-2003  dsl Remove the 4k between code and data to increase the stack space.
Support for 64bit disk blocks seems to have exploded the code.
 1.38 14-Jan-2003  thorpej Stub out LIBCRT0, LIBCRTBEGIN, LIBCRTEND, and LIBC.
 1.37 23-Nov-2002  fvdl Some hacks to make this compile on x86_64.
 1.36 02-Sep-2002  jdolecek make vers.c depend on ${SOURCES} and remove .PHONY tag for it, so that it
would only be regenerated if any of the input files changed
 1.35 27-Jun-2002  pooka branches: 1.35.2;
Assign COPTS instead of adding to it, avoids situation where -mi386
is mixed with -march=something_incompatible

suggested by thorpej
 1.34 31-May-2002  thorpej Build with -ffreestanding.
 1.33 19-Mar-2002  thorpej branches: 1.33.6; 1.33.8;
Make sure we override any optimization options specified by the
user; the boot blocks don't work when built with e.g. -mcpu=i486
(probably due to how branches are aligned in that case, causing
segment boundaries to be crossed).
 1.32 17-Feb-2002  thorpej Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.31 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.30 22-Nov-2001  jmc Don't make the symlinks on clean rules as well as obj rules. Breaks r/o source
trees that haven't gotten to the make obj recursion part of make build
otherwise.
 1.29 23-Sep-2001  tls GCC 2.95 generates significantly larger code with -O2 than our old compiler did; this can cause the second-stage bootblock to exceed the number of blocks that fit in the list in the first-stage bootblock. I thought we used to explicitly set -Os in here; anyway, with this change, we do now!
 1.28 22-Sep-2001  tv objcopy -> ${OBJCOPY}; remove redundant definitions of OBJCOPY?= (it is
now in bsd.own.mk).
 1.27 18-Aug-2001  enami branches: 1.27.4;
Include bsd.own.mk a bit earlier so that make cleandir works.
 1.26 12-Jul-2000  jdolecek branches: 1.26.4; 1.26.6;
switch to MI newvers_stand.sh version info generator
 1.25 23-Jan-2000  mycroft Fix the symlink hack.
 1.24 08-Jul-1999  drochner branches: 1.24.2;
fix creation of DOS / ROM images from ELF executables: use "objcopy"
 1.23 11-May-1999  drochner make sure the ./machine link is created early enough for specific targets,
fixes PR port-i386/7553 by David Rankin <drankin@bohemians.lexington.ky.us>
 1.22 28-Apr-1999  christos Use new loadfile.c
 1.21 14-Mar-1999  fvdl branches: 1.21.4;
Hack to make biosboot_ser work.

XXX The makefile structure in src/sys/arch/i386/stand is very bad.
 1.20 13-Mar-1999  tron $(OBJS) -> ${OBJS}
 1.19 12-Mar-1999  sommerfe Also build serial bootblocks by default, installing into
/usr/mdec/biosboot_ser.sym
Change Makefile.booters to not assume `version' file is in source directory.
 1.18 07-Feb-1999  tron Remove "lib" directory only during "make cleandir" so that ".depend"
doesn't get nuked during "make clean".
 1.17 07-Feb-1999  tron Remove "lib" directory created during build process while doing
"make clean" or "make cleandir".
 1.16 30-Jan-1999  christos Remove exec.o, and make necessary changes for elf.
 1.15 29-Jan-1999  christos Both booters need exec.o now.
 1.14 08-Jul-1998  drochner add dependency to get the version number right
 1.13 27-Mar-1998  cgd add -nostdinc to CPPFLAGS, so that /usr/include won't be used
 1.12 22-Feb-1998  mycroft Nuke the override of libkern SRCS from orbit.
 1.11 22-Jan-1998  drochner strchr.c disappeared from libkern, use index.c instead
(we can't control the libkern build as we want, but it works...)
 1.10 18-Oct-1997  hubertf Prevent error if machine-symlink isn't already there (rm -> rm -f)
 1.9 28-Sep-1997  drochner Use the "proginstall" rule from <bsd.prog.mk> to get the UPDATE
behaviour right.
 1.8 20-Aug-1997  drochner Make "genprom" work in objdir.
Minor cleanup to ease bootcode development at non-standard locations.
Closes PR port-i386/4013 by Luke Mewburn.
 1.7 26-Jul-1997  thorpej branches: 1.7.2;
New welcome banner code, modeled after NetBSD/hp300's boot program
welcome banner code. Includes additional build information, and it
generally nicer to look at.
 1.6 15-Jul-1997  drochner Use include files from kernel source, not userland. Create a
"machine" link automatically for this.
 1.5 26-Jun-1997  drochner Define _STANDALONE for standalone programs.
 1.4 13-Jun-1997  drochner Allow to boot from DOS if a XMS manager is installed.
XMS is recognized and used as temporary buffer for the kernel image.
The processor must still be in real mode at program start, so EMM386
or QEMM are not allowed. W*95 is OK.
Written by Martin Husemann (pr port-i386/3336).
Completely separated from other bootloaders for sanity.
 1.3 13-Jun-1997  drochner Force inclusion of "diskbuf" into bootsectors.
This allows to build bootsectors containing netboot code
("make netboot.sym" in the netboot directory).
 1.2 17-Apr-1997  thorpej STRIP -> STRIPFLAG
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.7.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.7.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.21.4.2 02-Aug-1999  thorpej Update from trunk.
 1.21.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.24.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.26.6.5 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.26.6.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.26.6.3 16-Mar-2002  jdolecek Catch up with -current.
 1.26.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.26.6.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.26.4.10 15-Jan-2003  thorpej Sync with HEAD.
 1.26.4.9 11-Dec-2002  thorpej Sync with HEAD.
 1.26.4.8 17-Sep-2002  nathanw Catch up to -current.
 1.26.4.7 01-Aug-2002  nathanw Catch up to -current.
 1.26.4.6 20-Jun-2002  nathanw Catch up to -current.
 1.26.4.5 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.26.4.4 28-Feb-2002  nathanw Catch up to -current.
 1.26.4.3 08-Jan-2002  nathanw Catch up to -current.
 1.26.4.2 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.26.4.1 24-Aug-2001  nathanw Catch up with -current.
 1.27.4.1 01-Oct-2001  fvdl Catch up with -current.
 1.33.8.2 04-Jul-2002  lukem revert accidental and incorrect pullup of rev 1.34 when rev 1.35 was
pulled up. problem noted by enami.
 1.33.8.1 03-Jul-2002  lukem Pull up revision 1.35 (requested by pooka in ticket #424):
Assign COPTS instead of adding to it, avoids situation where -mi386
is mixed with -march=something_incompatible
suggested by thorpej
 1.33.6.2 16-Jul-2002  gehenna catch up with -current.
 1.33.6.1 14-Jul-2002  gehenna catch up with -current.
 1.35.2.2 27-Jun-2002  pooka Assign COPTS instead of adding to it, avoids situation where -mi386
is mixed with -march=something_incompatible

suggested by thorpej
 1.35.2.1 27-Jun-2002  pooka file Makefile.booters was added on branch sommerfeld_i386mp_1 on 2002-06-27 20:44:09 +0000
 1.50.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.50.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.50.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.50.2.1 03-Aug-2004  skrll Sync with HEAD
 1.56.2.1 22-Jun-2004  tron Pull up revision 1.57 (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.58.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.60.2.3 27-Oct-2007  yamt sync with head.
 1.60.2.2 30-Dec-2006  yamt sync with head.
 1.60.2.1 21-Jun-2006  yamt sync with head.
 1.62.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.62.8.2 26-Jun-2006  yamt sync with head.
 1.62.8.1 24-May-2006  yamt sync with head.
 1.62.6.1 01-Jun-2006  kardel Sync with head.
 1.62.4.1 09-Sep-2006  rpaulo sync with head
 1.65.2.1 19-Jun-2006  chap Sync with head.
 1.66.2.1 13-Jul-2006  gdamore Merge from HEAD.
 1.70.36.1 06-Oct-2007  yamt sync with head.
 1.70.34.1 06-Nov-2007  matt sync with HEAD
 1.70.32.1 02-Oct-2007  joerg Sync with HEAD.
 1.70.22.1 03-Oct-2007  garbled Sync with HEAD
 1.70.14.1 09-Oct-2007  ad Sync with head.
 1.73.26.1 19-Oct-2008  haad Sync with HEAD.
 1.73.24.1 18-Jul-2008  simonb Sync with head.
 1.73.22.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.73.20.2 11-Aug-2010  yamt sync with head.
 1.73.20.1 04-May-2009  yamt sync with head.
 1.73.16.2 17-Jan-2009  mjf Sync with HEAD.
 1.73.16.1 28-Sep-2008  mjf Sync with HEAD.
 1.76.4.1 22-Jan-2009  snj Pull up following revision(s) (requested by jakllsch in ticket #281):
sys/arch/i386/stand/Makefile.booters: revision 1.77
Use ${VERSIONFILE} instead of ${.ALLSRC} to match Makefile.boot.
This change stops the full path of newvers_stand.sh from showing up in
pxeboot_ia32.bin.
 1.76.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.76.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.77.2.6 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.77.2.5 02-May-2011  jym Sync with head.
 1.77.2.4 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.77.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.77.2.2 01-Nov-2009  jym Sync with HEAD.
 1.77.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.78.4.3 21-Apr-2011  rmind sync with head
 1.78.4.2 05-Mar-2011  rmind sync with head
 1.78.4.1 30-May-2010  rmind sync with head
 1.78.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.81.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.81.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.83.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.85.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.85.2.1 30-Oct-2012  yamt sync with head
 1.86.4.2 18-May-2014  rmind sync with head
 1.86.4.1 28-Aug-2013  rmind sync with head
 1.86.2.2 03-Dec-2017  jdolecek update from HEAD
 1.86.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.89.6.2 28-Aug-2017  skrll Sync with HEAD
 1.89.6.1 06-Apr-2015  skrll Sync with HEAD
 1.89.4.1 09-Mar-2015  snj Pull up following revision(s) (requested by martin in ticket #579):
sys/arch/i386/stand/Makefile.booters: revision 1.90
Compile the booblocks for i386 CPUs, even when the main target architecture
is amd64.
Fixes PR port-i386/49725.
 1.90.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.90.2.1 26-Apr-2017  pgoyette Sync with HEAD
 1.91.12.2 28-Jul-2018  pgoyette Sync with HEAD
 1.91.12.1 25-Jun-2018  pgoyette Sync with HEAD
 1.92.2.1 10-Jun-2019  christos Sync with HEAD
 1.94.20.2 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.94.20.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.19 30-Aug-2023  christos 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.
 1.18 27-Jan-2019  dholland branches: 1.18.30;
fix duplicated chunk from merge
 1.17 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.16 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.15 02-Jun-2018  christos branches: 1.15.2;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.14 22-Feb-2018  christos branches: 1.14.2;
gcc-6 needs -nosse
 1.13 12-Jan-2017  joerg Remove some manual size tuning that no longer seems to be needed.
 1.12 01-May-2014  dsl branches: 1.12.4; 1.12.8;
Add -fno-asynchronous-unwind-tables -fno-exceptions to gcc builds.
One of these (probably the first) is needed to stop the eh-frame
section being created.
The eh_frame section is loadable and bloats the boot images.
This might be enough to make pxeboot work.
 1.11 01-Jul-2013  joerg branches: 1.11.4;
Explicitly disable unwind table generation.
 1.10 04-Apr-2012  joerg branches: 1.10.2; 1.10.4;
-enable-iv-rewrite is neither supported nor needed with LLVM now.
The one case where it was a big win was partially an inliner bug and
the changes to the inline cost estimate are much smaller over all.
 1.9 11-Dec-2011  joerg Use new -mstack-alignment option to replace the removed internal option.
 1.8 11-Oct-2011  joerg branches: 1.8.2; 1.8.6;
Update LLVM/Clang snapshot to r141658. This primarily fixes a regression
preventing Qt4 from building.
 1.7 16-Jun-2011  joerg Refactor compiler-specific optimizer flags. Mark bootxx as supported
with clang.
 1.6 29-Aug-2008  gmcgarry branches: 1.6.8; 1.6.26;
Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.5 12-May-2006  dogcow branches: 1.5.62; 1.5.66; 1.5.68; 1.5.72;
as mrg@ points out, including <bsd.own.mk> is the proper fix.
 1.4 12-May-2006  dogcow deal sanely(?) with when HAVE_GCC is undefined.
 1.3 12-May-2006  dogcow add more HAVE_GCC == 4 protection
 1.2 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.1 17-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.10; 1.1.38; 1.1.52; 1.1.54; 1.1.56; 1.1.60;
Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.1.60.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.1.56.1 24-May-2006  yamt sync with head.
 1.1.54.1 01-Jun-2006  kardel Sync with head.
 1.1.52.1 09-Sep-2006  rpaulo sync with head
 1.1.38.1 21-Jun-2006  yamt sync with head.
 1.1.10.2 16-Mar-2002  jdolecek Catch up with -current.
 1.1.10.1 17-Feb-2002  jdolecek file Makefile.inc was added on branch kqueue on 2002-03-16 15:58:20 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 17-Feb-2002  nathanw file Makefile.inc was added on branch nathanw_sa on 2002-02-28 04:10:24 +0000
 1.1.2.2 17-Feb-2002  thorpej Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.1.2.1 17-Feb-2002  thorpej file Makefile.inc was added on branch sommerfeld_i386mp_1 on 2002-02-17 20:03:07 +0000
 1.5.72.1 19-Oct-2008  haad Sync with HEAD.
 1.5.68.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.5.66.1 04-May-2009  yamt sync with head.
 1.5.62.1 28-Sep-2008  mjf Sync with HEAD.
 1.6.26.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.8.1 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.8.6.2 05-Apr-2012  mrg sync to latest -current.
 1.8.6.1 18-Feb-2012  mrg merge to -current.
 1.8.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.8.2.1 17-Apr-2012  yamt sync with head
 1.10.4.2 18-May-2014  rmind sync with head
 1.10.4.1 28-Aug-2013  rmind sync with head
 1.10.2.2 03-Dec-2017  jdolecek update from HEAD
 1.10.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.4.1 10-Aug-2014  tls Rebase.
 1.12.8.1 20-Mar-2017  pgoyette Sync with HEAD
 1.12.4.1 05-Feb-2017  skrll Sync with HEAD
 1.14.2.2 28-Jul-2018  pgoyette Sync with HEAD
 1.14.2.1 25-Jun-2018  pgoyette Sync with HEAD
 1.15.2.1 10-Jun-2019  christos Sync with HEAD
 1.18.30.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.3 26-Jan-2000  drochner nuke this, there is no valuable information anymore
 1.2 14-May-1998  drochner branches: 1.2.14;
minor corrections
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.14.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.5 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.4 27-Oct-1994  cgd new RCS ID format.
 1.3 22-May-1993  cgd add rcsids to everything and clean up headers
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.4 27-Oct-1994  cgd new RCS ID format.
 1.3 22-May-1993  cgd add rcsids to everything and clean up headers
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.6 27-Oct-1994  cgd new RCS ID format.
 1.5 01-Aug-1993  mycroft Add RCS identifiers (this time on the correct side of the branch), and
incorporate recent changes in netbsd-0-9 branch.
 1.4 22-May-1993  cgd add rcsids to everything and clean up headers
 1.3 28-Apr-1993  cgd bsd->netbsd
 1.2 28-Apr-1993  cgd 386bsd -> bsd for kernel name, and kill weird binary...
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.6 27-Oct-1994  cgd new RCS ID format.
 1.5 02-Aug-1993  mycroft Nuke remaining patchkit headers.
 1.4 22-May-1993  cgd add rcsids to everything and clean up headers
 1.3 28-Apr-1993  cgd 386bsd -> bsd for kernel name, and kill weird binary...
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.2 12-Jul-2000  jdolecek switch to MI newvers_stand.sh version info generator
 1.1 26-Jul-1997  thorpej branches: 1.1.20; 1.1.28;
New welcome banner code, modeled after NetBSD/hp300's boot program
welcome banner code. Includes additional build information, and it
generally nicer to look at.
 1.1.28.1 23-Jan-2001  thorpej Sync with the trunk.
 1.1.20.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.4 27-Oct-1994  cgd new RCS ID format.
 1.3 22-May-1993  cgd add rcsids to everything and clean up headers
 1.2 21-Mar-1993  cgd after 0.2.2 "stable" patches applied
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4 15-Feb-1997  perry All these files are ancient and haven't been used in years -- the
current boot blocks are in boot/; we need the thing cleaned out so we
can put the new libsa based boot stuff in its place.
 1.3 27-Oct-1994  cgd new RCS ID format.
 1.2 22-May-1993  cgd add rcsids to everything and clean up headers
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 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
 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.
 1.15 02-Jun-2018  christos - Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.14 12-Jan-2014  tsutsui branches: 1.14.28;
Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.

XXX: probabry we should have bsd.saprog.mk or something.
 1.13 12-Sep-2013  joerg Overwrite PIE_*, otherwise bootxx_cd9660 is not recognized by
installboot in MKPIE=yes builds.
 1.12 20-May-2011  joerg branches: 1.12.4; 1.12.14; 1.12.18;
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.11 02-Jan-2011  jakllsch branches: 1.11.2;
Relocate cdboot (aka bootxx_cd9660) to 0x1000 instead of 0x600.
A similar change was made in v1.38 of Makefile.bootxx about 13 months ago,
no reason these shouldn't be consistent with each other, like they were before.
 1.10 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.9 14-Feb-2009  abs branches: 1.9.4;
Convert more MACHINE tests to MACHINE_ARCH
 1.8 25-Oct-2008  apb branches: 1.8.2; 1.8.8;
Use ${TOOL_SED} instead if plain sed in Makefiles.
 1.7 20-Oct-2008  christos disable PIE for boot code.
 1.6 25-Jun-2006  lukem branches: 1.6.58; 1.6.62; 1.6.68;
Use -Wl,-Ttext,foo instead of -Ttext foo when using $(CC)
 1.5 13-May-2006  lukem branches: 1.5.4;
support MAKEVERBOSE
 1.4 13-May-2006  lukem Convert to using CC instead of LD, as LDFLAGS is for CC not LD.
 1.3 12-Nov-2005  simonb branches: 1.3.6; 1.3.8; 1.3.10; 1.3.14;
Adjust the S variable (pointer to top of sys tree) so that it points to
the right place. Fixes build problems in this directory.
 1.2 20-Jul-2005  junyoung branches: 1.2.6;
Add a compile time switch DISABLE_KEYPRESS for those who want unattended boot.
 1.1 15-Jun-2005  junyoung branches: 1.1.2;
Initial commit of cdboot, a primary boot loader that loads a secondary
boot loader directly from CD without performing floppy/hard disk emulation
as described by the El Torito specification.
 1.1.2.2 30-Dec-2006  yamt sync with head.
 1.1.2.1 21-Jun-2006  yamt sync with head.
 1.2.6.3 11-Dec-2005  christos Sync with head.
 1.2.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.6.1 20-Jul-2005  skrll file Makefile was added on branch ktrace-lwp on 2005-11-10 13:56:53 +0000
 1.3.14.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.3.10.2 26-Jun-2006  yamt sync with head.
 1.3.10.1 24-May-2006  yamt sync with head.
 1.3.8.1 01-Jun-2006  kardel Sync with head.
 1.3.6.1 09-Sep-2006  rpaulo sync with head
 1.5.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.6.68.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.6.62.1 04-May-2009  yamt sync with head.
 1.6.58.1 17-Jan-2009  mjf Sync with HEAD.
 1.8.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.8.8.3 10-Jan-2011  jym Sync with HEAD
 1.8.8.2 01-Nov-2009  jym Sync with HEAD.
 1.8.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.9.4.2 31-May-2011  rmind sync with head
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.11.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.12.18.1 18-May-2014  rmind sync with head
 1.12.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.12.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.14.28.1 25-Jun-2018  pgoyette Sync with HEAD
 1.13 05-Dec-2021  msaitoh s/decriptor/descriptor/ in comment.
 1.12 04-Jan-2011  jakllsch Relocate buffers to not coincide with new location of executable text.
 1.11 24-Oct-2009  dsl branches: 1.11.4;
Fix constant in comment
 1.10 24-Oct-2009  dsl Support reading /boot > 64k. Based on the patch from Izumi Tsutsui.
Compiles but not actually tested! Fixes PR/42202
 1.9 24-Oct-2009  dsl Add some illumination ...
 1.8 03-May-2008  ad branches: 1.8.14;
i386 -> x86
 1.7 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 06-Oct-2005  dyoung branches: 1.5.6;
Change the layout of cdboot to meet installboot(8)'s expectations:
MBR+NetBSD disklabel+boot parameters. Invoke the secondary boot
loader with a pointer to the boot parameters.
 1.4 20-Jul-2005  junyoung Add a compile time switch DISABLE_KEYPRESS for those who want unattended boot.
 1.3 06-Jul-2005  junyoung Add another case we can skip boot wait.
 1.2 06-Jul-2005  junyoung If no hard disks are present, do not wait for key press.
 1.1 15-Jun-2005  junyoung branches: 1.1.2;
Initial commit of cdboot, a primary boot loader that loads a secondary
boot loader directly from CD without performing floppy/hard disk emulation
as described by the El Torito specification.
 1.1.2.1 21-Jun-2006  yamt sync with head.
 1.5.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.6.1 06-Oct-2005  skrll file cdboot.S was added on branch ktrace-lwp on 2005-11-10 13:56:53 +0000
 1.6.78.2 11-Mar-2010  yamt sync with head
 1.6.78.1 16-May-2008  yamt sync with head.
 1.6.76.1 18-May-2008  yamt sync with head.
 1.6.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.8.14.2 10-Jan-2011  jym Sync with HEAD
 1.8.14.1 01-Nov-2009  jym Sync with HEAD.
 1.11.4.1 05-Mar-2011  rmind sync with head
 1.39 11-Sep-2024  andvar dosboot(8): remove XMS-specific code. The boot process has been broken for over
a decade, and its relevance has diminished due to the availability of other boot
options.

PR port-i386/58624
 1.38 29-Jun-2024  rin branches: 1.38.2;
i386: stand: Adjust for DOS-routine migration
 1.37 29-Jun-2024  rin i386: stand: Switch to libsa/getopt, NFCI
 1.36 06-Nov-2023  rin x86/dosboot: Drop no-longer-available -DSLOW for libz

It should be lost during merge from upstream.

We may introduce a similar hack again, if it is *really* required;
inflate_fast() may be dropped by using slow path unconditionally.
 1.35 06-Nov-2023  rin 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.34 06-Nov-2023  rin 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?
 1.33 23-Sep-2019  christos branches: 1.33.26;
Consistently use ${RELEASEDIR}/${RELEASEMACHINE} instead of
${RELEASEDIR}/${MACHINE} (Paul Ripke)
 1.32 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.31 02-Jun-2018  christos branches: 1.31.2; 1.31.6;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.30 23-Jan-2016  christos branches: 1.30.10; 1.30.16;
We'll define the kernel types for standalone code.
 1.29 23-Jan-2016  christos Define _KERNTYPES for things that need it.
 1.28 15-Jan-2014  joerg branches: 1.28.6;
Reduce amount of -no-integrated-as on x86 as .code16 is now supported by
LLVM.
 1.27 25-Dec-2011  tsutsui branches: 1.27.6; 1.27.10;
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.26 20-May-2011  joerg branches: 1.26.4; 1.26.8;
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.25 30-Mar-2009  tsutsui branches: 1.25.4; 1.25.6;
Remove extra trailing slash in ${S} path.
 1.24 20-Oct-2008  christos branches: 1.24.2; 1.24.8;
disable PIE for boot code.
 1.23 01-Apr-2003  mycroft branches: 1.23.104; 1.23.108; 1.23.114;
Add -DSLOW to reduce the size of libz a bit.
 1.22 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.21 03-Jan-2003  lukem Install release files under "${RELEASEDIR}/${MACHINE}/..." instead of
"${RELEASEDIR}/...".

${RELEASEDIR} is never cleaned , and ${RELEASEDIR}/${MACHINE} is only
cleaned if UPDATE is not defined.
 1.20 17-Feb-2002  thorpej branches: 1.20.2;
Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.19 12-Dec-2001  tv MKfoo=no -> NOfoo
 1.18 01-Jun-2001  jdolecek branches: 1.18.4;
g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.17 15-Oct-2000  wiz branches: 1.17.4;
Get RELEASEDIR setting from /etc/mk.conf. Fixes misc/11104 by Markus Kurek.
 1.16 05-Sep-2000  enami Fix to work with objdir.
 1.15 23-Aug-2000  jhawk install dosboot.com in the release(7) hierarchy.
 1.14 06-Jul-2000  jhawk Enable "old partition ID" compatibility by default, just as in biosboot.
 1.13 14-Apr-1999  drochner branches: 1.13.2; 1.13.14;
add prototypes, use ufs_ls() from mi libsa,
compile with -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main
 1.12 08-Apr-1999  drochner define VERSIONFILE, from John Darrow <John.P.Darrow@wheaton.edu>
per PR port-i386/7336
 1.11 13-Feb-1999  lukem branches: 1.11.2; 1.11.4;
convert from NOxxx= to MKxxx=no.
include <bsd.own.mk> if testing a MKxxx variable.
 1.10 30-Jan-1999  christos Add exec.c here and bump version for elf.
XXX: This code has not been tested!
 1.9 28-Sep-1997  drochner Use the "proginstall" rule from <bsd.prog.mk> to get the UPDATE
behaviour right.
 1.8 14-Aug-1997  drochner Make new memory detection default.
Introduce a new option, "CONSERVATIVE_MEMDETECT", which disables the
new BIOS calls.
 1.7 14-Aug-1997  drochner Prepare definition for EXTENDED_MEMDETECT.
Not yet default.
 1.6 26-Jul-1997  thorpej branches: 1.6.2;
New welcome banner code, modeled after NetBSD/hp300's boot program
welcome banner code. Includes additional build information, and it
generally nicer to look at.
 1.5 13-Jun-1997  drochner Allow to boot from DOS if a XMS manager is installed.
XMS is recognized and used as temporary buffer for the kernel image.
The processor must still be in real mode at program start, so EMM386
or QEMM are not allowed. W*95 is OK.
Written by Martin Husemann (pr port-i386/3336).
Completely separated from other bootloaders for sanity.
 1.4 13-Jun-1997  drochner Remove some relicts from the time before libsa/Makefile got
"SAMISCCPPFLAGS".
Enable -Wall.
 1.3 07-May-1997  mycroft Override the proginstall target to do our special hackery. (Yuck.)
 1.2 14-Mar-1997  thorpej Make this work with obj* dirs.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.6.2.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.11.2.1 06-Jul-2000  he Pull up revision 1.14 (requested by jhawk):
Enable "old partition ID" compatibility by default, just as in
biosboot.
 1.13.14.4 19-Oct-2000  he Pull up revision 1.17 (requested by wiz):
Get RELEASEDIR setting from /etc/mk.conf. Fixes PR#11104.
 1.13.14.3 06-Sep-2000  enami Pull up rev. 1.16 (approved by jhawk):
date: 2000/09/05 05:05:16; author: enami; state: Exp; lines: +2 -2
Fix to work with objdir.
 1.13.14.2 04-Sep-2000  jhawk Pullup etc/etc.i386/Makefile.inc rev 1.23, arch/i386/stand/dosboot/Makefile
rev 1.15, approved by thorpej:
install dosboot.com in the release(7) hierarchy.
 1.13.14.1 06-Jul-2000  jhawk Pullup revv 1.14, approved by thorpej:

Enable "old partition ID" compatibility by default, just as in biosboot.
 1.13.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.17.4.4 07-Jan-2003  thorpej Sync with HEAD.
 1.17.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.17.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.17.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.18.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.18.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.2.2 17-Feb-2002  thorpej Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.20.2.1 17-Feb-2002  thorpej file Makefile was added on branch sommerfeld_i386mp_1 on 2002-02-17 20:03:10 +0000
 1.23.114.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.23.108.1 04-May-2009  yamt sync with head.
 1.23.104.1 17-Jan-2009  mjf Sync with HEAD.
 1.24.8.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.24.8.2 01-Nov-2009  jym Sync with HEAD.
 1.24.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.25.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.4.1 31-May-2011  rmind sync with head
 1.26.8.1 18-Feb-2012  mrg merge to -current.
 1.26.4.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.26.4.1 17-Apr-2012  yamt sync with head
 1.27.10.1 18-May-2014  rmind sync with head
 1.27.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.6.1 19-Mar-2016  skrll Sync with HEAD
 1.30.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.30.10.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.31.6.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.31.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.33.26.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.38.2.1 02-Aug-2025  perseant Sync with HEAD
 1.12 29-Jun-2024  rin i386: stand: Adjust for DOS-routine migration
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 11-Dec-2005  christos branches: 1.10.78; 1.10.86; 1.10.92;
merge ktrace-lwp.
 1.9 22-Jun-2005  dyoung De-__P().

Consistently pass 'int *' arguments to parsebootfile.
 1.8 22-Jun-2005  junyoung Fix build breakage. Oops.
 1.7 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.6 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.5 01-Jun-2001  jdolecek branches: 1.5.2; 1.5.24;
g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.4 14-Apr-1999  drochner branches: 1.4.16;
add prototypes, use ufs_ls() from mi libsa,
compile with -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main
 1.3 17-Sep-1997  drochner branches: 1.3.12;
Put name of booted file into a "bootinfo" structure.
(not for DOS files for now, we don't know the absolute path)
 1.2 22-Mar-1997  thorpej branches: 1.2.4;
Purely cosmetic whitespace/indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.12.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.16.1 21-Jun-2001  nathanw Catch up to -current.
 1.5.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.24.1 03-Aug-2004  skrll Sync with HEAD
 1.5.2.2 01-Jun-2001  jdolecek g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.5.2.1 01-Jun-2001  jdolecek file devopen.c was added on branch sommerfeld_i386mp_1 on 2001-06-01 23:26:32 +0000
 1.10.92.2 01-Nov-2009  jym Sync with HEAD.
 1.10.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.78.1 04-May-2009  yamt sync with head.
 1.1 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.1 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.2 29-Jun-2024  rin i386: stand: Adjust for DOS-routine migration
 1.1 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.2 29-Jun-2024  rin i386: stand: Adjust for DOS-routine migration
 1.1 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.34 11-Sep-2024  andvar dosboot(8): remove XMS-specific code. The boot process has been broken for over
a decade, and its relevance has diminished due to the availability of other boot
options.

PR port-i386/58624
 1.33 13-May-2019  maxv branches: 1.33.34;
Remove dead code.
 1.32 26-Mar-2014  christos branches: 1.32.30;
kill sprintf.
 1.31 25-Dec-2011  tsutsui branches: 1.31.6; 1.31.10;
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.30 20-Dec-2010  jakllsch branches: 1.30.8; 1.30.12;
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.29 21-Mar-2009  ad branches: 1.29.4;
Fix 'boot -z' bogons.
 1.28 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.27 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.26 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.25 13-Dec-2008  christos branches: 1.25.2;
add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.24 26-Sep-2008  christos branches: 1.24.2;
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.23 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.22 11-Dec-2005  christos branches: 1.22.74; 1.22.78; 1.22.80; 1.22.82; 1.22.84;
merge ktrace-lwp.
 1.21 22-Jun-2005  dyoung De-__P().

Consistently pass 'int *' arguments to parsebootfile.
 1.20 22-Jun-2005  junyoung Fix build breakage. Oops.
 1.19 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.18 05-Jul-2001  itojun branches: 1.18.4; 1.18.24;
sort boot flag to alphabetical order. add -c.
 1.17 01-Jun-2001  jdolecek g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.16 24-Sep-2000  jdolecek branches: 1.16.4;
update usage message (new flags -v, -q)
 1.15 29-Jul-2000  jdolecek g/c RB_DFLTROOT

I've tried hard to find also various usage() messages and remove the
appropriate flag from there as well, hopefully all occurences are covered.
 1.14 13-Mar-2000  martin branches: 1.14.6;
Do the same as biosboot does.
This makes it possible to create serial console dosboot.com's via uncommenting
the appropriate Makefile options.
I needed this when testing the SMP test kernels at work.
 1.13 14-Apr-1999  christos branches: 1.13.2;
remove bogus prototype for getopt
 1.12 14-Apr-1999  drochner add prototypes, use ufs_ls() from mi libsa,
compile with -Wall -Wmissing-prototypes -Wstrict-prototypes -Wno-main
 1.11 12-Feb-1999  cjs branches: 1.11.4;
Don't give exit() a parameter, as libstand version doesn't take one.
 1.10 03-Nov-1997  drochner ../lib/exec_fromdos.c doesn't use the memory size returned by XMS check
anymore if other methods work better. Sync banner output with this.
 1.9 31-Oct-1997  drochner -Don't try to parse the bootfile path in DOS mode.
-Take "dev" command from "biosboot" for consistency.
 1.8 17-Sep-1997  drochner branches: 1.8.2;
The additional linefeed appeared again... kill it.
 1.7 17-Sep-1997  drochner Use common menu / parsing functions.
Adapt to new console / exec_netbsd arguments.
 1.6 14-Aug-1997  drochner Use traditional memory detect function (int15/88) as indication for
a XMS driver.
From Martin Husemann.
 1.5 29-Jul-1997  christos branches: 1.5.2;
If we have xms print the xms memory size, and indicate that this is xms
memory in the banner. It is confusing to show 0 memory...
 1.4 26-Jul-1997  thorpej New welcome banner code, modeled after NetBSD/hp300's boot program
welcome banner code. Includes additional build information, and it
generally nicer to look at.
 1.3 13-Jun-1997  drochner Remove strerror() prototype, it goes into stand.h.
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace/indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.5.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.2.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.8.2.1 01-Nov-1997  mellon Pull rev 1.9 up from trunk (drochner)
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.13.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.14.6.1 13-Aug-2000  jdolecek pullup from trunk (approved by thorpej):
retire RB_DFLTROOT, it's no longer used

revisions pulled up:
arch/i386/stand/lib/netbsd_opts.c 1.3
arch/i386/stand/biosboot/main.c 1.23
arch/i386/stand/dosboot/main.c 1.15
arch/i386/stand/netboot/main.c 1.6
arch/arc/arc/machdep.c 1.42
arch/bebox/stand/boot/boot.c 1.11
arch/hpcmips/hpcmips/machdep.c 1.32
arch/newsmips/newsmips/machdep.c 1.45
arch/pc532/stand/boot/boot.c 1.2
arch/pmax/pmax/machdep.c 1.178
arch/prep/stand/boot/boot.c 1.2
arch/sparc/sparc/autoconf.c 1.141
arch/sparc64/sparc64/autoconf.c 1.38
arch/x68k/stand/loadbsd/loadbsd.c 1.5
arch/mvme68k/stand/libsa/parse_args.c 1.6
compat/osf1/osf1_cvt.c 1.9
sys/reboot.h 1.17
 1.16.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.16.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.18.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.24.1 03-Aug-2004  skrll Sync with HEAD
 1.18.4.2 05-Jul-2001  itojun sort boot flag to alphabetical order. add -c.
 1.18.4.1 05-Jul-2001  itojun file main.c was added on branch sommerfeld_i386mp_1 on 2001-07-05 00:58:46 +0000
 1.22.84.1 19-Oct-2008  haad Sync with HEAD.
 1.22.82.1 18-Jul-2008  simonb Sync with head.
 1.22.80.2 10-Oct-2008  skrll Sync with HEAD.
 1.22.80.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.22.78.1 04-May-2009  yamt sync with head.
 1.22.74.2 17-Jan-2009  mjf Sync with HEAD.
 1.22.74.1 28-Sep-2008  mjf Sync with HEAD.
 1.24.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.24.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.25.2.3 10-Jan-2011  jym Sync with HEAD
 1.25.2.2 01-Nov-2009  jym Sync with HEAD.
 1.25.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.29.4.1 05-Mar-2011  rmind sync with head
 1.30.12.1 18-Feb-2012  mrg merge to -current.
 1.30.8.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.30.8.1 17-Apr-2012  yamt sync with head
 1.31.10.1 18-May-2014  rmind sync with head
 1.31.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.32.30.1 10-Jun-2019  christos Sync with HEAD
 1.33.34.1 02-Aug-2025  perseant Sync with HEAD
 1.2 11-Sep-2024  andvar dosboot(8): remove XMS-specific code. The boot process has been broken for over
a decade, and its relevance has diminished due to the availability of other boot
options.

PR port-i386/58624
 1.1 29-Jun-2024  rin branches: 1.1.2;
i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.1.2.1 02-Aug-2025  perseant Sync with HEAD
 1.13 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.12 11-Sep-2024  andvar dosboot(8): remove XMS-specific code. The boot process has been broken for over
a decade, and its relevance has diminished due to the availability of other boot
options.

PR port-i386/58624
 1.11 15-Jul-2008  perry branches: 1.11.118;
Update the version numbers following commit, and make them all identical.
 1.10 01-Feb-2003  dsl branches: 1.10.104; 1.10.108; 1.10.110; 1.10.112; 1.10.114;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.9 09-Nov-2001  scw branches: 1.9.2;
Bump the version numbers of all bootloaders which use loadfile_elfXX() now
that it tries hard to avoid backwards seeks.
 1.8 02-Aug-2001  bjh21 branches: 1.8.6;
Bump version numbers of all bootloaders that use loadfile/ELF, to account for
my changes to symbol loading. I should probably have done this at the time,
but it's better late than never.
 1.7 24-Sep-2000  jdolecek branches: 1.7.4; 1.7.6;
add new macro BOOT_FLAG() (defined in <sys/boot_flag.h>) - this
maps standard boot flags to corresponding RB_* values
use BOOT_FLAG() in port's MD code as appropriate

as discussed on tech-kern, add new boot flags -v, -q for booting
verbosely or quietly, and corresponding AB_VERBOSE/AB_QUIET
boot flags; also add FreeBSD-compatible bootverbose macro and
NetBSD-specific bootquiet macro

for hpcmips, use new bootverbose instead of it's own hpcmips_verbose

Tested on i386, and to limited extend (compile of affected files) also for
mvme68k, hp300, luna68k, sun3.
 1.6 12-Jul-2000  jdolecek switch to MI newvers_stand.sh version info generator
 1.5 30-Jan-1999  christos branches: 1.5.8;
Add exec.c here and bump version for elf.
XXX: This code has not been tested!
 1.4 27-Oct-1998  ws Update version number and mention int13 extension support
(sorry, forgot this on the recent commit of the above).
 1.3 08-Jul-1998  drochner bump version number to reflect the partition ID change
(should have been done long ago)
 1.2 20-Sep-1997  drochner Note use of common menu functions and new framework for argument passing
to the kernel.
 1.1 26-Jul-1997  thorpej branches: 1.1.2;
New welcome banner code, modeled after NetBSD/hp300's boot program
welcome banner code. Includes additional build information, and it
generally nicer to look at.
 1.1.2.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.7.6.1 03-Aug-2001  lukem update to -current
 1.7.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.7.4.1 24-Aug-2001  nathanw Catch up with -current.
 1.8.6.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.9.2.2 09-Nov-2001  scw Bump the version numbers of all bootloaders which use loadfile_elfXX() now
that it tries hard to avoid backwards seeks.
 1.9.2.1 09-Nov-2001  scw file version was added on branch sommerfeld_i386mp_1 on 2001-11-09 19:53:14 +0000
 1.10.114.1 19-Oct-2008  haad Sync with HEAD.
 1.10.112.1 18-Jul-2008  simonb Sync with head.
 1.10.110.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.10.108.1 04-May-2009  yamt sync with head.
 1.10.104.1 28-Sep-2008  mjf Sync with HEAD.
 1.11.118.1 02-Aug-2025  perseant Sync with HEAD
 1.2 26-Jul-1997  thorpej New welcome banner code, modeled after NetBSD/hp300's boot program
welcome banner code. Includes additional build information, and it
generally nicer to look at.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.5 08-Nov-2018  christos revert previous; does not fix the issue
 1.4 08-Nov-2018  christos Don't build this as a PIE binary, PIE binaries need PHDR and this barfs
under the new binutils: error: PHDR segment not covered by LOAD segment
[including bsd.init.mk includes ../Makefile.inc which disables PIE like
all the other bootloaders do]
 1.3 08-Jul-2018  christos use += :-)
 1.2 08-Jul-2018  christos Enable efiboot on i386, for 32 bit bootblocks
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18; 1.1.20; 1.1.22;
Initial commit of native amd64 EFI boot loader.
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.2 26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.1.20.1 28-Jul-2018  pgoyette Sync with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file Makefile was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file Makefile was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file Makefile was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.23 29-Jun-2024  rin i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.22 24-Jul-2023  rin efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.

``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.

Proposed as PR port-amd64/57523
 1.21 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.20 25-Dec-2022  christos Fix broken flag -nocombreloc, 2.34 did not complain for not understanding it,
but 2.39 wants -z nocombreloc. Is it really needed?
 1.19 18-Nov-2021  manu branches: 1.19.4;
Do not pass BIOS geometry when booting using EFI

Recent Mac return garbage data that will crash the code handling it,
and EFI boot does not need it anyway.
 1.18 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.17 04-Apr-2020  christos Add --noinhibit-exec and --no-dynamic-linker
 1.16 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.15 26-Jul-2019  nonaka branches: 1.15.2;
Added tftp support to x86 efiboot.
 1.14 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.13 02-Jun-2018  christos branches: 1.13.2;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.12 11-Apr-2018  nonaka efiboot: Added network boot support.
 1.11 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.10 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.9 29-Apr-2017  nonaka branches: 1.9.2; 1.9.8; 1.9.10;
efiboot: Boot parameters can be set via installboot(8).
 1.8 08-Apr-2017  christos branches: 1.8.4; 1.8.6;
centralize vers.c building for standalone programs.
 1.7 11-Feb-2017  nonaka branches: 1.7.2;
efiboot: pass memory map after ExitBootService is called to kernel.
 1.6 06-Feb-2017  nonaka Remove unnecessary flag.
 1.5 05-Feb-2017  joerg branches: 1.5.2;
Unbreak clang again.
 1.4 04-Feb-2017  christos Don't error out for set but unused variables for now.
 1.3 04-Feb-2017  roy Mark reboot() and _rtt() as __dead.
Use __builtin_unreachable() to ensure Panic really is marked dead.

Thanks to joerg@
 1.2 03-Feb-2017  roy Fix build with clang.
 1.1 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.5.2.3 28-Aug-2017  skrll Sync with HEAD
 1.5.2.2 05-Feb-2017  skrll Sync with HEAD
 1.5.2.1 05-Feb-2017  skrll file Makefile.efiboot was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.7.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.7.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.7.2.1 11-Feb-2017  pgoyette file Makefile.efiboot was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.8.6.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.8.4.2 08-Apr-2017  christos 1249242
 1.8.4.1 08-Apr-2017  christos file Makefile.efiboot was added on branch bouyer-socketcan on 2017-04-08 19:53:22 +0000
 1.9.10.5 28-Jul-2018  pgoyette Sync with HEAD
 1.9.10.4 25-Jun-2018  pgoyette Sync with HEAD
 1.9.10.3 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.9.10.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.9.10.1 15-Mar-2018  pgoyette Synch with HEAD
 1.9.8.2 03-Dec-2017  jdolecek update from HEAD
 1.9.8.1 29-Apr-2017  jdolecek file Makefile.efiboot was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.9.2.6 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1897):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.9.2.5 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.9.2.4 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.9.2.3 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.9.2.2 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.9.2.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.13.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.13.2.1 10-Jun-2019  christos Sync with HEAD
 1.15.2.2 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1732):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.15.2.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.19.4.2 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.19.4.1 11-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #361):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523
 1.5 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.4 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.3 12-Mar-2017  nonaka branches: 1.3.2; 1.3.6; 1.3.10; 1.3.14; 1.3.18; 1.3.20;
Remove `fix module_init()' entry.

I've been committed.
 1.2 21-Feb-2017  nonaka fix to be able to boot amd64 kernel from 32bit efiboot (booia32.efi).
 1.1 11-Feb-2017  nonaka Added efiboot TODO.
 1.3.20.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.3.20.1 15-Mar-2018  pgoyette Synch with HEAD
 1.3.18.2 03-Dec-2017  jdolecek update from HEAD
 1.3.18.1 12-Mar-2017  jdolecek file TODO.efiboot was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.3.14.2 28-Aug-2017  skrll Sync with HEAD
 1.3.14.1 12-Mar-2017  skrll file TODO.efiboot was added on branch nick-nhusb on 2017-08-28 17:51:41 +0000
 1.3.10.2 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.3.10.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.3.6.2 12-Mar-2017  nonaka 1673508
 1.3.6.1 12-Mar-2017  nonaka file TODO.efiboot was added on branch bouyer-socketcan on 2017-03-12 06:37:42 +0000
 1.3.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.3.2.1 12-Mar-2017  pgoyette file TODO.efiboot was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.34 09-Oct-2025  manu Add support for USB-to-serial adapter in UEFI bootstrap.

This change lets UEFI bootstrap use any UEFI supported serial port.
com0 to com3 remain used for EISA based serial ports. com4 and over
are used for serial ports based on something else (USB, PCI or whatever).

Support for non-EISA serial ports may be provided by UEFI. An open
source UEFI driver exists for FTDI FT232R USB-to-serial adapter.

The change also introduce the kconsdev command, to select the kernel
console device without altering the bootstrap console device. This
useful because the device names can differ in bootstrap and kernel.
For instance an USB-to-serial device could be com4 in boostrap and
ucom0 for the kernel.

An upcoming change will add console suport to ucom(4).
 1.33 31-Jul-2025  pgoyette Reorder the names[] array to put the supported/historical entries
first. Should eliminate some unwanted and confusing messages.
 1.32 20-May-2025  pgoyette branches: 1.32.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.31 20-May-2025  pgoyette Reverrt previous. I will recomit with proper log message.
 1.30 20-May-2025  pgoyette /home/paul/COMMIT.txt
 1.29 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.28 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.27 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.26 29-Apr-2025  martin Backout /filename/kernel changes, this breaks default installs
and needs more testing.
 1.25 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.24 27-Apr-2025  pgoyette Add new paths for kernel code when using KERNEL_DIR
 1.23 14-May-2023  riastradh branches: 1.23.6;
x86/efiboot: Nix trailing whitespace.
 1.22 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.21 08-Jun-2022  wiz branches: 1.21.4;
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.20 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.19 22-Jun-2021  nia efiboot (x86): add ASCII art
 1.18 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.17 26-Sep-2019  nonaka branches: 1.17.12; 1.17.14;
x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.16 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.15 02-Sep-2019  manu Make sure devices names are copied including last byte

Fix from M. Levinson.
 1.14 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.13 29-Jul-2019  nonaka branches: 1.13.2;
Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.
 1.12 26-Jul-2019  nonaka Pre-allocate memory for the kernel space at startup.
 1.11 20-Jun-2019  maxv Add KASLR support in UEFI.
 1.10 11-Apr-2018  nonaka branches: 1.10.2;
efiboot: Added network boot support.
 1.9 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.8 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.7 20-Mar-2018  nonaka efiboot: more pager.
 1.6 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.5 01-May-2017  nonaka branches: 1.5.2; 1.5.8; 1.5.10;
efiboot: implement consdev command.

no support to change console device for efiboot yet.
only pass console parameters to kernel.
 1.4 12-Mar-2017  nonaka branches: 1.4.2; 1.4.6; 1.4.8;
efiboot: Kernel modules are loaded in pre-allocated memory.
 1.3 03-Mar-2017  nonaka efiboot: fix efivar command.
 1.2 03-Feb-2017  roy branches: 1.2.2;
rows is a uint ... it will always be greater than or equal to 0.
 1.1 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.2.2.3 28-Aug-2017  skrll Sync with HEAD
 1.2.2.2 05-Feb-2017  skrll Sync with HEAD
 1.2.2.1 03-Feb-2017  skrll file boot.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.4.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.4.6.2 12-Mar-2017  nonaka 1673328
 1.4.6.1 12-Mar-2017  nonaka file boot.c was added on branch bouyer-socketcan on 2017-03-12 05:33:49 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 12-Mar-2017  pgoyette file boot.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.5.10.5 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.5.10.4 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.5.10.3 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.5.10.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.5.10.1 15-Mar-2018  pgoyette Synch with HEAD
 1.5.8.2 03-Dec-2017  jdolecek update from HEAD
 1.5.8.1 01-May-2017  jdolecek file boot.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.5.2.9 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1392):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.5.2.8 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.5.2.7 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.2.6 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.5.2.5 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.5.2.4 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.5.2.3 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.5.2.2 21-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #648):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.c: revision 1.3
sys/arch/i386/stand/efiboot/boot.c: revision 1.7
sys/arch/i386/stand/lib/biosdisk.c: revision 1.48

efiboot: fix it can't boot from HDD.

efiboot: more pager.

efiboot: boot device is always efi_distlist first element.

efiboot: fix to find boot partition process.
NetBSD related partitions with no bootme flag set are also candidates
for boot partition.
 1.5.2.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.10.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13.2.4 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.13.2.3 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #253):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.13.2.2 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.13.2.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.17.14.1 31-May-2021  cjep sync with head
 1.17.12.2 01-Aug-2021  thorpej Sync with HEAD.
 1.17.12.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.21.4.2 03-Nov-2023  martin Pull up following revision(s) (requested by rin in ticket #452):

sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.23
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.14
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.10

x86/efiboot: Nix trailing whitespace.

whitespace -> tab, blank line, no binary changes.

``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.
 1.21.4.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.23.6.1 02-Aug-2025  perseant Sync with HEAD
 1.32.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.3 26-Sep-2019  nonaka x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.2 11-Apr-2018  nonaka branches: 1.2.2; 1.2.6;
efiboot: Added network boot support.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.1 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file conf.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.2 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1392):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.1.12.1 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file conf.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file conf.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file conf.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.2.6.1 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #253):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.2.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3 26-Sep-2019  nonaka x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.2 26-Jul-2019  nonaka branches: 1.2.2;
Added tftp support to x86 efiboot.
 1.1 11-Apr-2018  nonaka branches: 1.1.2; 1.1.4; 1.1.6;
efiboot: Added network boot support.
 1.1.6.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.4.2 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.4.1 11-Apr-2018  pgoyette file dev_net.c was added on branch pgoyette-compat on 2018-04-16 01:59:54 +0000
 1.1.2.4 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1392):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.1.2.3 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.1.2.2 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.2.1 11-Apr-2018  martin file dev_net.c was added on branch netbsd-8 on 2018-04-11 14:51:43 +0000
 1.2.2.1 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #253):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.14 20-Jun-2023  rin ``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.
 1.13 27-Dec-2021  simonb branches: 1.13.4;
Revert rev 1.12 of devopen.c. This had the unintented side effect
of breaking opens on non-root filesystems (eg trying to open/read
"esp:/EFI/NetBSD/boot.cfg" on the EFI system partition).

Ok manu@. Original problem to be re-addressed.
 1.12 18-Nov-2021  manu Fix crash because of NULL pointer reference
 1.11 18-Jan-2020  nonaka x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded.
 1.10 18-Jan-2020  nonaka fix indent.
 1.9 10-Dec-2019  manu branches: 1.9.2;
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 26-Sep-2019  nonaka x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.7 02-Sep-2019  manu Make sure devices names are copied including last byte

Fix from M. Levinson.
 1.6 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.5 11-Apr-2018  nonaka branches: 1.5.2; 1.5.6;
efiboot: Added network boot support.
 1.4 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.3 20-Mar-2018  nonaka efiboot: fix it can't boot from HDD.
 1.2 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.4 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.20.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.20.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.1.20.1 15-Mar-2018  pgoyette Synch with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file devopen.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.8 21-Jan-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1485):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.11

fix indent.
x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded.
 1.1.12.7 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.1.12.6 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1392):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.1.12.5 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.1.12.4 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.12.3 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1.12.2 21-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #648):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.c: revision 1.3
sys/arch/i386/stand/efiboot/boot.c: revision 1.7
sys/arch/i386/stand/lib/biosdisk.c: revision 1.48

efiboot: fix it can't boot from HDD.

efiboot: more pager.

efiboot: boot device is always efi_distlist first element.

efiboot: fix to find boot partition process.
NetBSD related partitions with no bootme flag set are also candidates
for boot partition.
 1.1.12.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file devopen.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file devopen.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file devopen.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.5.6.4 21-Jan-2020  martin Pull up following revision(s) (requested by nonaka in ticket #631):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.11

fix indent.

x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded.
 1.5.6.3 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.5.6.2 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #253):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.5.6.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.5.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.2.1 25-Jan-2020  ad Sync with head.
 1.13.4.1 03-Nov-2023  martin Pull up following revision(s) (requested by rin in ticket #452):

sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.23
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.14
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.10

x86/efiboot: Nix trailing whitespace.

whitespace -> tab, blank line, no binary changes.

``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.
 1.5 26-Sep-2019  nonaka x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.4 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.3 11-Apr-2018  nonaka branches: 1.3.2; 1.3.6;
efiboot: Added network boot support.
 1.2 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.2 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.20.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file devopen.h was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.4 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1392):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.1.12.3 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.1.12.2 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.12.1 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file devopen.h was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file devopen.h was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file devopen.h was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.3.6.2 27-Sep-2019  martin Pull up following revision(s) (requested by nonaka in ticket #253):

sys/arch/i386/stand/efiboot/conf.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.h: revision 1.5
sys/arch/i386/stand/efiboot/devopen.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.17
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.3

x86 efiboot: pass a filename to BOOTP and parse a DHCP server provided filename.
 1.3.6.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.3.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.12 09-Feb-2020  jmcneill branches: 1.12.24;
Do not clear the screen before exiting boot services as this may cause an
undesired display mode switch. PR# 54615
 1.11 13-Sep-2019  manu branches: 1.11.2;
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.10 29-Jul-2019  nonaka branches: 1.10.2;
Added missing efi_memory_probe() call.
 1.9 29-Jul-2019  nonaka Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.
 1.8 08-Jun-2018  nonaka branches: 1.8.2;
Remove unused include.
 1.7 11-Apr-2018  nonaka efiboot: Added network boot support.
 1.6 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.5 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.4 11-Feb-2017  nonaka branches: 1.4.2; 1.4.6; 1.4.10; 1.4.16; 1.4.18;
PR/51953: fix unable to boot on some AMD machine.

Delayed the timing to copy the kernel to actual address.
copy routine from common/lib/libc/arch/x86_64/string/bcopy.S
 1.3 11-Feb-2017  nonaka efiboot: don't call WaitForSingleEvent after ExitBootServices is called.
 1.2 11-Feb-2017  nonaka efiboot: pass memory map after ExitBootService is called to kernel.
 1.1 24-Jan-2017  nonaka branches: 1.1.2;
Initial commit of native amd64 EFI boot loader.
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efiboot.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.4.18.4 25-Jun-2018  pgoyette Sync with HEAD
 1.4.18.3 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.4.18.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.4.18.1 15-Mar-2018  pgoyette Synch with HEAD
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 11-Feb-2017  jdolecek file efiboot.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.4.10.6 10-Feb-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1499):

sys/arch/i386/stand/efiboot/efiboot.c: revision 1.12

Do not clear the screen before exiting boot services as this may cause an
undesired display mode switch. PR# 54615
 1.4.10.5 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.4.10.4 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.4.10.3 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.4.10.2 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.4.10.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.4.6.2 11-Feb-2017  nonaka 1673251
 1.4.6.1 11-Feb-2017  nonaka file efiboot.c was added on branch bouyer-socketcan on 2017-02-11 10:23:40 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 11-Feb-2017  pgoyette file efiboot.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.8.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.2.3 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.10.2.2 10-Feb-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #686):

sys/arch/i386/stand/efiboot/efiboot.c: revision 1.12

Do not clear the screen before exiting boot services as this may cause an
undesired display mode switch. PR# 54615
 1.10.2.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.11.2.1 29-Feb-2020  ad Sync with head.
 1.12.24.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.13 09-Oct-2025  manu Add support for USB-to-serial adapter in UEFI bootstrap.

This change lets UEFI bootstrap use any UEFI supported serial port.
com0 to com3 remain used for EISA based serial ports. com4 and over
are used for serial ports based on something else (USB, PCI or whatever).

Support for non-EISA serial ports may be provided by UEFI. An open
source UEFI driver exists for FTDI FT232R USB-to-serial adapter.

The change also introduce the kconsdev command, to select the kernel
console device without altering the bootstrap console device. This
useful because the device names can differ in bootstrap and kernel.
For instance an USB-to-serial device could be com4 in boostrap and
ucom0 for the kernel.

An upcoming change will add console suport to ucom(4).
 1.12 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.11 07-Sep-2021  nia branches: 1.11.4;
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.10 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.9 29-Jul-2019  nonaka branches: 1.9.2;
Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.
 1.8 11-Apr-2018  nonaka branches: 1.8.2;
efiboot: Added network boot support.
 1.7 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.6 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.5 01-May-2017  nonaka branches: 1.5.2; 1.5.8; 1.5.10;
efiboot: implement consdev command.

no support to change console device for efiboot yet.
only pass console parameters to kernel.
 1.4 11-Feb-2017  nonaka branches: 1.4.2; 1.4.6; 1.4.8;
PR/51953: fix unable to boot on some AMD machine.

Delayed the timing to copy the kernel to actual address.
copy routine from common/lib/libc/arch/x86_64/string/bcopy.S
 1.3 11-Feb-2017  nonaka efiboot: don't call WaitForSingleEvent after ExitBootServices is called.
 1.2 11-Feb-2017  nonaka efiboot: pass memory map after ExitBootService is called to kernel.
 1.1 24-Jan-2017  nonaka branches: 1.1.2;
Initial commit of native amd64 EFI boot loader.
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efiboot.h was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.4.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.4.6.2 11-Feb-2017  nonaka 1673251
 1.4.6.1 11-Feb-2017  nonaka file efiboot.h was added on branch bouyer-socketcan on 2017-02-11 10:23:40 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 11-Feb-2017  pgoyette file efiboot.h was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.5.10.3 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.5.10.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.5.10.1 15-Mar-2018  pgoyette Synch with HEAD
 1.5.8.2 03-Dec-2017  jdolecek update from HEAD
 1.5.8.1 01-May-2017  jdolecek file efiboot.h was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.5.2.5 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.5.2.4 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.5.2.3 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.5.2.2 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.5.2.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.8.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.2.2 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.9.2.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.11.4.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.1 27-Mar-2018  nonaka branches: 1.1.2; 1.1.4;
efiboot: Added serial console support.
 1.1.4.2 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.1.4.1 27-Mar-2018  martin file efichar.c was added on branch netbsd-8 on 2018-04-02 08:50:33 +0000
 1.1.2.2 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.1.2.1 27-Mar-2018  pgoyette file efichar.c was added on branch pgoyette-compat on 2018-03-30 06:20:11 +0000
 1.18 15-Oct-2025  manu Restore keyboard/screen console broken in revision 1.16

Previous change caused com0 to be set as default console instead of pc,
leading to a confusing black screen on kernel start.
 1.17 14-Oct-2025  skrll Trailing whitespace
 1.16 09-Oct-2025  manu Add support for USB-to-serial adapter in UEFI bootstrap.

This change lets UEFI bootstrap use any UEFI supported serial port.
com0 to com3 remain used for EISA based serial ports. com4 and over
are used for serial ports based on something else (USB, PCI or whatever).

Support for non-EISA serial ports may be provided by UEFI. An open
source UEFI driver exists for FTDI FT232R USB-to-serial adapter.

The change also introduce the kconsdev command, to select the kernel
console device without altering the bootstrap console device. This
useful because the device names can differ in bootstrap and kernel.
For instance an USB-to-serial device could be com4 in boostrap and
ucom0 for the kernel.

An upcoming change will add console suport to ucom(4).
 1.15 19-Jun-2025  manu Make sure sure boot countdown is slow enough

The boot coundown should count seconds. We use internal_waitforinputevent()
that in tueb calls UEFI BootServices->SetTmer(). That functions takes a
timeout in 100ns units, but it seems some implementation can be broken
and return earlier.

Make sure we really wait 1s by checking that system time's ticks one
second before proceeding.
 1.14 14-Sep-2023  rin branches: 1.14.6;
efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.13 24-Jul-2023  rin efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.

``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.

Proposed as PR port-amd64/57523
 1.12 28-Oct-2021  kim branches: 1.12.4;
Make "0 seconds" overwrite the countdown also when enter is pressed

Fixes PR misc/56486.
 1.11 22-Feb-2020  jmcneill Remove check for bestmode==-1 (shouldn't happen)
 1.10 22-Feb-2020  jmcneill If the default GOP mode is unavailable, fallback to the first mode defined.
PR# port-amd64/55000
 1.9 11-Feb-2020  jmcneill Use 1024x768 as the default GOP mode. It is the only option available for
Hyper-V Gen.2 VMs and it seems to be the de facto standard and part of
WHQL requirements.
 1.8 08-Feb-2020  jmcneill Fix a few bugs related to the framebuffer:
- If a GOP mode wasn't explicitly requested, the bootloader was passing
fb info to the kernel even if the console was in text mode! This
results in garbled console output on at least ThinkPad T420 and
likely many others. If a mode isn't specified, default to 800x600.
- The "gop" command was incorrectly parsing video modes in the form
WxHxD as WxWxD.
- Allow a short form WxH for the "gop" command to select any mode with
the target dimensions.
 1.7 13-Sep-2019  manu branches: 1.7.2;
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.6 16-May-2018  jakllsch branches: 1.6.2; 1.6.6;
During awaitkey(), move the cursor back to the beginning of the
countdown with '\b' only after waiting.

Some UEFI implementations have a destructive/erasing backspace,
and will not show the countdown if we move the cursor back before the
wait.

My ThinkPad T430 w/ Lenovo's UEFI exhibited this whiteout-backspace,
while my Gigabyte Brix GB-BXBT-2807 did not.

Should fix PR #53292.
 1.5 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.4 01-May-2017  nonaka branches: 1.4.2; 1.4.8; 1.4.10;
efiboot: implement consdev command.

no support to change console device for efiboot yet.
only pass console parameters to kernel.
 1.3 24-Mar-2017  nonaka branches: 1.3.4; 1.3.6;
Don't maximize the text columns and rows. only use 100x31 or 80x25.
 1.2 24-Mar-2017  nonaka Don't maximize the screen size when gop is not specified.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4;
Initial commit of native amd64 EFI boot loader.
 1.1.4.3 26-Apr-2017  pgoyette Sync with HEAD
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file eficons.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file eficons.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.3.6.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.3.4.2 24-Mar-2017  nonaka 1673576
 1.3.4.1 24-Mar-2017  nonaka file eficons.c was added on branch bouyer-socketcan on 2017-03-24 01:25:37 +0000
 1.4.10.2 21-May-2018  pgoyette Sync with HEAD
 1.4.10.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.4.8.2 03-Dec-2017  jdolecek update from HEAD
 1.4.8.1 01-May-2017  jdolecek file eficons.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.4.2.7 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1897):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.4.2.6 09-Mar-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1519):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.10
sys/arch/i386/stand/efiboot/eficons.c: revision 1.11

If the default GOP mode is unavailable, fallback to the first mode defined.
PR# port-amd64/55000

Remove check for bestmode==-1 (shouldn't happen)
 1.4.2.5 11-Feb-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #1502):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.9

Use 1024x768 as the default GOP mode. It is the only option available for
Hyper-V Gen.2 VMs and it seems to be the de facto standard and part of
WHQL requirements.
 1.4.2.4 10-Feb-2020  martin Pull up following revision(s) (requested by nonaka in ticket #1498):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.8

Fix a few bugs related to the framebuffer:
- If a GOP mode wasn't explicitly requested, the bootloader was passing
fb info to the kernel even if the console was in text mode! This
results in garbled console output on at least ThinkPad T420 and
likely many others. If a mode isn't specified, default to 800x600.
- The "gop" command was incorrectly parsing video modes in the form
WxHxD as WxWxD.
- Allow a short form WxH for the "gop" command to select any mode with
the target dimensions.
 1.4.2.3 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.4.2.2 22-May-2018  martin Pull up following revision(s) (requested by jakllsch in ticket #831):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.6

During awaitkey(), move the cursor back to the beginning of the
countdown with '\b' only after waiting.

Some UEFI implementations have a destructive/erasing backspace,
and will not show the countdown if we move the cursor back before the
wait.

My ThinkPad T430 w/ Lenovo's UEFI exhibited this whiteout-backspace,
while my Gigabyte Brix GB-BXBT-2807 did not.

Should fix PR #53292.
 1.4.2.1 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.6.6.5 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1732):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.6.6.4 25-Feb-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #723):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.10
sys/arch/i386/stand/efiboot/eficons.c: revision 1.11

If the default GOP mode is unavailable, fallback to the first mode defined.
PR# port-amd64/55000

Remove check for bestmode==-1 (shouldn't happen)
 1.6.6.3 11-Feb-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #696):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.9

Use 1024x768 as the default GOP mode. It is the only option available for
Hyper-V Gen.2 VMs and it seems to be the de facto standard and part of
WHQL requirements.
 1.6.6.2 10-Feb-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #685):

sys/arch/i386/stand/efiboot/eficons.c: revision 1.8

Fix a few bugs related to the framebuffer:
- If a GOP mode wasn't explicitly requested, the bootloader was passing
fb info to the kernel even if the console was in text mode! This
results in garbled console output on at least ThinkPad T420 and
likely many others. If a mode isn't specified, default to 800x600.
- The "gop" command was incorrectly parsing video modes in the form
WxHxD as WxWxD.
- Allow a short form WxH for the "gop" command to select any mode with
the target dimensions.
 1.6.6.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.6.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.2.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1 29-Feb-2020  ad Sync with head.
 1.12.4.1 11-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #361):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523
 1.14.6.1 02-Aug-2025  perseant Sync with HEAD
 1.1 24-Jul-2023  rin branches: 1.1.2; 1.1.4; 1.1.6;
efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.

``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.

Proposed as PR port-amd64/57523
 1.1.6.2 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1897):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.1.6.1 24-Jul-2023  martin file eficpufunc.c was added on branch netbsd-8 on 2023-09-15 15:44:20 +0000
 1.1.4.2 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1732):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.1.4.1 24-Jul-2023  martin file eficpufunc.c was added on branch netbsd-9 on 2023-09-15 15:40:22 +0000
 1.1.2.2 11-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #361):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523
 1.1.2.1 24-Jul-2023  martin file eficpufunc.c was added on branch netbsd-10 on 2023-09-11 13:25:42 +0000
 1.1 24-Jul-2023  rin branches: 1.1.2; 1.1.4; 1.1.6;
efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.

``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.

Proposed as PR port-amd64/57523
 1.1.6.2 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1897):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.1.6.1 24-Jul-2023  martin file eficpufunc.h was added on branch netbsd-8 on 2023-09-15 15:44:20 +0000
 1.1.4.2 15-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #1732):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13
sys/arch/i386/stand/efiboot/eficons.c: revision 1.14

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523

efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).
 1.1.4.1 24-Jul-2023  martin file eficpufunc.h was added on branch netbsd-9 on 2023-09-15 15:40:22 +0000
 1.1.2.2 11-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #361):

sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.22
sys/arch/i386/stand/efiboot/eficpufunc.c: revision 1.1
sys/arch/i386/stand/efiboot/eficpufunc.h: revision 1.1
sys/arch/i386/stand/efiboot/eficons.c: revision 1.13

efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.
``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523
 1.1.2.1 24-Jul-2023  martin file eficpufunc.h was added on branch netbsd-10 on 2023-09-11 13:25:42 +0000
 1.2 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efidelay.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.1 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efidelay.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efidelay.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efidelay.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.1 08-Mar-2018  nonaka branches: 1.1.2; 1.1.4;
efiboot: system can boot from CD/DVD-ROM media.
 1.1.4.2 15-Mar-2018  pgoyette Synch with HEAD
 1.1.4.1 08-Mar-2018  pgoyette file efidev.c was added on branch pgoyette-compat on 2018-03-15 09:12:03 +0000
 1.1.2.2 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.1.2.1 08-Mar-2018  martin file efidev.c was added on branch netbsd-8 on 2018-03-13 14:54:52 +0000
 1.11 06-Jan-2024  mlelstv In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.10 14-May-2023  riastradh x86/efiboot: Nix trailing whitespace.
 1.9 17-Dec-2019  manu branches: 1.9.26;
Do not use NAME=label syntax when label are empty

When booting sysinst from UEFI, it defaults to a GPT installation
where partition have no labels. Bootstrap used the NAME=label partition
anyway, with the result that both EFI and FFS root partition had
the same name "NAME=" and could not be distinguished. The first matching
partition for the name was used, and bootstrap looked for the kernel
in the EFI partition.

We fix that by not using NAME=label names for partition when label
is empty. In that case we revert to old syntax such as hd0b
 1.8 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.7 17-Apr-2019  nonaka branches: 1.7.4;
efiboot: Don't panic when BLOCK_IO_PROTOCOL is not found.

It has been reported that there is a machine where BLOCK_IO_PROTOCOL
can not be found when network boot without disk.
 1.6 11-Apr-2018  nonaka branches: 1.6.2;
efiboot: Added network boot support.
 1.5 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.4 27-Mar-2018  nonaka efiboot: Added serial console support.
 1.3 20-Mar-2018  nonaka efiboot: boot device is always efi_distlist first element.
 1.2 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.5 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.20.4 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.20.3 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.1.20.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.1.20.1 15-Mar-2018  pgoyette Synch with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efidisk.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.8 17-Dec-2019  martin Pull up following revision(s) (requested by manu in ticket #1474):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.54
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.9

Do not use NAME=label syntax when label are empty

When booting sysinst from UEFI, it defaults to a GPT installation
where partition have no labels. Bootstrap used the NAME=label partition
anyway, with the result that both EFI and FFS root partition had
the same name "NAME=" and could not be distinguished. The first matching
partition for the name was used, and bootstrap looked for the kernel
in the EFI partition.

We fix that by not using NAME=label names for partition when label
is empty. In that case we revert to old syntax such as hd0b
 1.1.12.7 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.1.12.6 17-Apr-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1231):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.7

efiboot: Don't panic when BLOCK_IO_PROTOCOL is not found.

It has been reported that there is a machine where BLOCK_IO_PROTOCOL
can not be found when network boot without disk.
 1.1.12.5 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.12.4 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1.12.3 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.1.12.2 21-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #648):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.c: revision 1.3
sys/arch/i386/stand/efiboot/boot.c: revision 1.7
sys/arch/i386/stand/lib/biosdisk.c: revision 1.48

efiboot: fix it can't boot from HDD.

efiboot: more pager.

efiboot: boot device is always efi_distlist first element.

efiboot: fix to find boot partition process.
NetBSD related partitions with no bootme flag set are also candidates
for boot partition.
 1.1.12.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efidisk.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efidisk.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efidisk.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.6.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.2.1 10-Jun-2019  christos Sync with HEAD
 1.7.4.2 17-Dec-2019  martin Pull up following revision(s) (requested by manu in ticket #568):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.54
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.9

Do not use NAME=label syntax when label are empty

When booting sysinst from UEFI, it defaults to a GPT installation
where partition have no labels. Bootstrap used the NAME=label partition
anyway, with the result that both EFI and FFS root partition had
the same name "NAME=" and could not be distinguished. The first matching
partition for the name was used, and bootstrap looked for the kernel
in the EFI partition.

We fix that by not using NAME=label names for partition when label
is empty. In that case we revert to old syntax such as hd0b
 1.7.4.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.9.26.2 14-Jan-2024  martin Pull up following revision(s) (requested by mlelstv in ticket #548):

sys/arch/i386/stand/efiboot/efidisk.h: revision 1.4
sys/arch/i386/stand/lib/exec.c: revision 1.80
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.11
sys/arch/i386/stand/lib/biosdisk.c: revision 1.61

In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.9.26.1 03-Nov-2023  martin Pull up following revision(s) (requested by rin in ticket #452):

sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.23
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.14
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.10

x86/efiboot: Nix trailing whitespace.

whitespace -> tab, blank line, no binary changes.

``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.
 1.4 06-Jan-2024  mlelstv In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.3 02-Apr-2018  nonaka branches: 1.3.32;
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.2 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.20.1 15-Mar-2018  pgoyette Synch with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efidisk.h was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.2 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1.12.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efidisk.h was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efidisk.h was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efidisk.h was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.3.32.1 14-Jan-2024  martin Pull up following revision(s) (requested by mlelstv in ticket #548):

sys/arch/i386/stand/efiboot/efidisk.h: revision 1.4
sys/arch/i386/stand/lib/exec.c: revision 1.80
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.11
sys/arch/i386/stand/lib/biosdisk.c: revision 1.61

In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.2 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.20;
Initial commit of native amd64 EFI boot loader.
 1.1.20.1 15-Mar-2018  pgoyette Synch with HEAD
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efidisk_ll.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efidisk_ll.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efidisk_ll.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efidisk_ll.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18;
Initial commit of native amd64 EFI boot loader.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efigetsecs.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efigetsecs.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efigetsecs.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efigetsecs.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.10 14-May-2023  riastradh x86/efiboot: Nix trailing whitespace.
 1.9 13-Sep-2019  manu branches: 1.9.26;
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.8 29-Jul-2019  nonaka branches: 1.8.2;
Sync the output of memmap command to the output of stand/efiboot mem command.
 1.7 29-Jul-2019  nonaka Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.
 1.6 26-Jul-2019  nonaka Pre-allocate memory for the kernel space at startup.
 1.5 27-Mar-2018  nonaka branches: 1.5.2;
efiboot: Added serial console support.
 1.4 14-Feb-2017  nonaka branches: 1.4.2; 1.4.6; 1.4.10; 1.4.16; 1.4.18;
Handle persistent memory. Currently only debug output.
 1.3 11-Feb-2017  nonaka efiboot: pass memory map after ExitBootService is called to kernel.
 1.2 03-Feb-2017  roy branches: 1.2.2;
rows is a uint ... it will always be greater than or equal to 0.
 1.1 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.2.2.3 28-Aug-2017  skrll Sync with HEAD
 1.2.2.2 05-Feb-2017  skrll Sync with HEAD
 1.2.2.1 03-Feb-2017  skrll file efimemory.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.4.18.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 14-Feb-2017  jdolecek file efimemory.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.4.10.3 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.4.10.2 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.4.10.1 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.4.6.2 14-Feb-2017  nonaka 1210367
 1.4.6.1 14-Feb-2017  nonaka file efimemory.c was added on branch bouyer-socketcan on 2017-02-14 13:29:10 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 14-Feb-2017  pgoyette file efimemory.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.5.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.8.2.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.9.26.1 03-Nov-2023  martin Pull up following revision(s) (requested by rin in ticket #452):

sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.23
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.14
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.10

x86/efiboot: Nix trailing whitespace.

whitespace -> tab, blank line, no binary changes.

``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.
 1.3 05-Mar-2019  msaitoh Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.
 1.2 03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.1 11-Apr-2018  nonaka branches: 1.1.2; 1.1.4; 1.1.6;
efiboot: Added network boot support.
 1.1.6.1 10-Jun-2019  christos Sync with HEAD
 1.1.4.3 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.4.2 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.4.1 11-Apr-2018  pgoyette file efinet.c was added on branch pgoyette-compat on 2018-04-16 01:59:54 +0000
 1.1.2.2 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.2.1 11-Apr-2018  martin file efinet.c was added on branch netbsd-8 on 2018-04-11 14:51:43 +0000
 1.1 11-Apr-2018  nonaka branches: 1.1.2; 1.1.4;
efiboot: Added network boot support.
 1.1.4.2 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.4.1 11-Apr-2018  pgoyette file efinet.h was added on branch pgoyette-compat on 2018-04-16 01:59:54 +0000
 1.1.2.2 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.2.1 11-Apr-2018  martin file efinet.h was added on branch netbsd-8 on 2018-04-11 14:51:43 +0000
 1.2 24-Jul-2023  rin MI and x86 efiboot: Fix device path type for PXE boot device.

It should be Messaging, not Media Device Path. Taken from OpenBSD, for
which this code was originally written:

https://cvsweb.openbsd.org/src/sys/arch/amd64/stand/efiboot/efipxe.c#rev1.6

> Network-based device paths use Messaging and not Media types. Thus
> in reality the depth was always -1 which made the compare function
> a No-Op. Properly check the device path depth value and look for
> the Messaging type instead to find the correct NIC. This check
> never worked before and was uncovered by the last change.
>
> Regression noticed by bluhm@
 1.1 11-Apr-2018  nonaka branches: 1.1.2; 1.1.4; 1.1.36;
efiboot: Added network boot support.
 1.1.36.1 11-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #362):

sys/arch/i386/stand/efiboot/efipxe.c: revision 1.2
sys/stand/efiboot/efipxe.c: revision 1.3

MI and x86 efiboot: Fix device path type for PXE boot device.
It should be Messaging, not Media Device Path. Taken from OpenBSD, for
which this code was originally written:
https://cvsweb.openbsd.org/src/sys/arch/amd64/stand/efiboot/efipxe.c#rev1.6

Network-based device paths use Messaging and not Media types. Thus
in reality the depth was always -1 which made the compare function
a No-Op. Properly check the device path depth value and look for
the Messaging type instead to find the correct NIC. This check
never worked before and was uncovered by the last change.

Regression noticed by bluhm@
 1.1.4.2 16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.1.4.1 11-Apr-2018  pgoyette file efipxe.c was added on branch pgoyette-compat on 2018-04-16 01:59:54 +0000
 1.1.2.2 11-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #739):

sys/arch/i386/stand/efiboot/efinet.h: revision 1.1
sys/arch/i386/stand/efiboot/efinet.c: revision 1.1
sys/arch/i386/stand/efiboot/conf.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.5
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.6
sys/arch/i386/stand/efiboot/devopen.h: revision 1.3
sys/arch/i386/stand/efiboot/efipxe.c: revision 1.1
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.7
sys/arch/i386/stand/efiboot/boot.c: revision 1.10
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.8
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.12
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.1

efiboot: Added network boot support.
 1.1.2.1 11-Apr-2018  martin file efipxe.c was added on branch netbsd-8 on 2018-04-11 14:51:43 +0000
 1.5 17-Aug-2018  kre Deal with gnu-efi upgrade - "efilib.h" now provides a prototype
for VPrint() so it is no longer needed here, particularly not a
slightly different prototype. Fixes the amd64 i386 & ia64 builds.
 1.4 11-Feb-2017  nonaka branches: 1.4.2; 1.4.6; 1.4.16; 1.4.18; 1.4.20;
efiboot: don't call WaitForSingleEvent after ExitBootServices is called.
 1.3 05-Feb-2017  joerg branches: 1.3.2;
Be a bit nicer to outdated compilers and use __unreachable().
 1.2 04-Feb-2017  roy Mark reboot() and _rtt() as __dead.
Use __builtin_unreachable() to ensure Panic really is marked dead.

Thanks to joerg@
 1.1 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.3.2.3 28-Aug-2017  skrll Sync with HEAD
 1.3.2.2 05-Feb-2017  skrll Sync with HEAD
 1.3.2.1 05-Feb-2017  skrll file panic.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.4.20.1 10-Jun-2019  christos Sync with HEAD
 1.4.18.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.4.16.2 03-Dec-2017  jdolecek update from HEAD
 1.4.16.1 11-Feb-2017  jdolecek file panic.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.4.6.2 11-Feb-2017  nonaka 1673339
 1.4.6.1 11-Feb-2017  nonaka file panic.c was added on branch bouyer-socketcan on 2017-02-11 10:15:56 +0000
 1.4.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.4.2.1 11-Feb-2017  pgoyette file panic.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18;
Initial commit of native amd64 EFI boot loader.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file self_reloc.c was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file self_reloc.c was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file self_reloc.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file self_reloc.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.5 21-Sep-2024  rin i386/stand: Document NFSv3 support to {efi,pxe}boot/version
 1.4 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.3 10-May-2023  manu branches: 1.3.6;
Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.2 03-Aug-2019  nonaka branches: 1.2.26;
x86 efiboot: version 1.1.
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.22; 1.1.26;
Initial commit of native amd64 EFI boot loader.
 1.1.26.2 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.1.26.1 04-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #12):

sys/arch/i386/stand/efiboot/version: revision 1.2

x86 efiboot: version 1.1.
 1.1.22.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file version was added on branch tls-maxphys on 2017-12-03 11:36:18 +0000
 1.1.12.1 04-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1325):

sys/arch/i386/stand/efiboot/version: revision 1.2

x86 efiboot: version 1.1.
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file version was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file version was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file version was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.2.26.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.3.6.1 02-Aug-2025  perseant Sync with HEAD
 1.3 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.2 21-Feb-2017  nonaka branches: 1.2.2; 1.2.6; 1.2.10; 1.2.16; 1.2.20; 1.2.24;
fix to be able to boot amd64 kernel from 32bit efiboot (booia32.efi).
 1.1 24-Jan-2017  nonaka branches: 1.1.2;
Initial commit of native amd64 EFI boot loader.
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file Makefile was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.2.24.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.2.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.16.2 03-Dec-2017  jdolecek update from HEAD
 1.2.16.1 21-Feb-2017  jdolecek file Makefile was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.2.10.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.2.6.2 21-Feb-2017  nonaka 1673439
 1.2.6.1 21-Feb-2017  nonaka file Makefile was added on branch bouyer-socketcan on 2017-02-21 10:53:38 +0000
 1.2.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.1 21-Feb-2017  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18;
Initial commit of native amd64 EFI boot loader.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efiboot_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efiboot_machdep.h was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efiboot_machdep.h was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efiboot_machdep.h was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.8 19-Jun-2023  rin whitespace -> tab, blank line, no binary changes.
 1.7 14-May-2023  riastradh x86/efiboot: Nix trailing whitespace.
 1.6 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.5 13-Sep-2019  manu branches: 1.5.26;
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.4 27-Mar-2018  nonaka branches: 1.4.2; 1.4.6;
efiboot: Added serial console support.
 1.3 29-Apr-2017  nonaka branches: 1.3.2; 1.3.8; 1.3.10;
efiboot: Boot parameters can be set via installboot(8).
 1.2 21-Feb-2017  nonaka branches: 1.2.2; 1.2.6; 1.2.8;
fix to be able to boot amd64 kernel from 32bit efiboot (booia32.efi).
 1.1 24-Jan-2017  nonaka branches: 1.1.2;
Initial commit of native amd64 EFI boot loader.
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efibootia32.c was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.2.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.2.6.2 21-Feb-2017  nonaka 1673439
 1.2.6.1 21-Feb-2017  nonaka file efibootia32.c was added on branch bouyer-socketcan on 2017-02-21 10:53:38 +0000
 1.2.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.1 21-Feb-2017  pgoyette file efibootia32.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.3.10.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.3.8.2 03-Dec-2017  jdolecek update from HEAD
 1.3.8.1 29-Apr-2017  jdolecek file efibootia32.c was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.3.2.2 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.3.2.1 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.4.6.2 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.4.6.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.4.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.26.2 03-Nov-2023  martin Pull up following revision(s) (requested by rin in ticket #452):

sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.7
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.8
sys/arch/i386/stand/efiboot/boot.c: revision 1.23
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.10
sys/arch/i386/stand/efiboot/devopen.c: revision 1.14
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.10

x86/efiboot: Nix trailing whitespace.

whitespace -> tab, blank line, no binary changes.

``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.
 1.5.26.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.2 24-Dec-2018  christos Avoid error with new binutils:
error: PHDR segment not covered by LOAD segment
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18; 1.1.20; 1.1.22;
Initial commit of native amd64 EFI boot loader.
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file ldscript was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file ldscript was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file ldscript was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file ldscript was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.2 24-Sep-2019  manu branches: 1.2.8;
Fix multiboot32 argument usage
 1.1 13-Sep-2019  manu branches: 1.1.2; 1.1.4;
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.1.4.3 27-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #1391):

sys/arch/i386/stand/efiboot/bootia32/multiboot32.S: revision 1.2

Fix multiboot32 argument usage
 1.1.4.2 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.1.4.1 13-Sep-2019  martin file multiboot32.S was added on branch netbsd-8 on 2019-09-18 17:30:05 +0000
 1.1.2.3 27-Sep-2019  martin Pull up following revision(s) (requested by manu in ticket #251):

sys/arch/i386/stand/efiboot/bootia32/multiboot32.S: revision 1.2

Fix multiboot32 argument usage
 1.1.2.2 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.1.2.1 13-Sep-2019  martin file multiboot32.S was added on branch netbsd-9 on 2019-09-17 19:32:00 +0000
 1.2.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.8.1 24-Sep-2019  martin file multiboot32.S was added on branch phil-wifi on 2020-04-13 08:03:54 +0000
 1.2 29-Apr-2017  nonaka branches: 1.2.8;
efiboot: Boot parameters can be set via installboot(8).
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
Initial commit of native amd64 EFI boot loader.
 1.1.10.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file start.S was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file start.S was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file start.S was added on branch nick-nhusb on 2017-02-05 13:40:12 +0000
 1.2.8.2 03-Dec-2017  jdolecek update from HEAD
 1.2.8.1 29-Apr-2017  jdolecek file start.S was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.3 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.2 24-Feb-2017  nonaka branches: 1.2.2; 1.2.6; 1.2.14; 1.2.18; 1.2.26; 1.2.52;
efiboot: Don't access old stack after copying a kernel.

It's possible that the old stack is overwritten by the kernel.
 1.1 21-Feb-2017  nonaka fix to be able to boot amd64 kernel from 32bit efiboot (booia32.efi).
 1.2.52.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.2.26.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.2.18.2 03-Dec-2017  jdolecek update from HEAD
 1.2.18.1 24-Feb-2017  jdolecek file startprog32.S was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.2.14.2 28-Aug-2017  skrll Sync with HEAD
 1.2.14.1 24-Feb-2017  skrll file startprog32.S was added on branch nick-nhusb on 2017-08-28 17:51:41 +0000
 1.2.6.2 24-Feb-2017  nonaka 1673486
 1.2.6.1 24-Feb-2017  nonaka file startprog32.S was added on branch bouyer-socketcan on 2017-02-24 12:24:26 +0000
 1.2.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.1 24-Feb-2017  pgoyette file startprog32.S was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.6 03-Jun-2023  lukem adapt to ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}

Simplify CWARNFLAGS to use ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
which works for both clang and gcc, and remove compiler-specific
equivalents.
 1.5 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.4 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.3 21-Mar-2020  riastradh Fix clang build after packed lfs64 accessor change.
 1.2 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.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.12; 1.1.18; 1.1.22; 1.1.26;
Initial commit of native amd64 EFI boot loader.
 1.1.26.2 17-Aug-2020  martin Pull up following revision(s) (requested by riastradh in ticket #1050):

sys/ufs/lfs/lfs_subr.c: revision 1.101
sys/ufs/lfs/lfs_subr.c: revision 1.102
sys/ufs/lfs/lfs_inode.c: revision 1.158
sys/ufs/lfs/lfs_inode.h: revision 1.25
sys/ufs/lfs/lfs_balloc.c: revision 1.95
sys/ufs/lfs/lfs_pages.c: revision 1.21
sys/ufs/lfs/lfs_vnops.c: revision 1.330
sys/ufs/lfs/lfs_alloc.c: revision 1.140 (patch)
sys/ufs/lfs/lfs_alloc.c: revision 1.141 (patch)
lib/libp2k/p2k.c: revision 1.72
sys/ufs/lfs/lfs.h: revision 1.205
sys/ufs/lfs/lfs.h: revision 1.206
sys/ufs/lfs/lfs_segment.c: revision 1.284
sys/ufs/lfs/lfs.h: revision 1.207
sys/ufs/lfs/lfs_segment.c: revision 1.285
sys/ufs/lfs/lfs_debug.c: revision 1.55
sys/ufs/lfs/lfs_rename.c: revision 1.23
usr.sbin/dumplfs/dumplfs.c: revision 1.65
sys/ufs/lfs/lfs_vfsops.c: revision 1.371
sys/arch/i386/stand/efiboot/bootx64/Makefile: revision 1.3
sys/ufs/lfs/lfs_vfsops.c: revision 1.372
sys/ufs/lfs/lfs_vfsops.c: revision 1.373
sbin/fsck_lfs/pass1.c: revision 1.46
sys/ufs/lfs/lfs_vnops.c: revision 1.326
sys/ufs/lfs/lfs_vnops.c: revision 1.327
sys/ufs/lfs/lfs_vfsops.c: revision 1.375 (patch)
sys/ufs/lfs/lfs_vnops.c: revision 1.328
sys/ufs/lfs/lfs_subr.c: revision 1.98
sys/ufs/lfs/lfs_extern.h: revision 1.116
sys/ufs/lfs/lfs_vnops.c: revision 1.329
sys/ufs/lfs/lfs_subr.c: revision 1.99
sys/ufs/lfs/lfs_extern.h: revision 1.117
sys/ufs/lfs/lfs_accessors.h: revision 1.49
sys/ufs/lfs/lfs_extern.h: revision 1.118
sys/rump/fs/lib/liblfs/Makefile: revision 1.15
sys/ufs/lfs/lfs_bio.c: revision 1.146 (patch)
sys/ufs/lfs/lfs_bio.c: revision 1.147
sys/ufs/lfs/lfs_subr.c: revision 1.100

Fix kassert in lfs by initializing vp first.

Use a marker node to iterate lfs_dchainhd / i_lfs_dchain.

I believe elements can be removed while the lock is dropped,
including the next node we're hanging on to.

Just use VOP_BWRITE for lfs_bwrite_log.
Hope this doesn't cause trouble with vfs_suspend.

Teach lfs to transition ro<->rw.

Prevent new dirops while we issue lfs_flush_dirops.

lfs_flush_dirops assumes (by KASSERT((ip->i_state & IN_ADIROP) == 0))
that vnodes on the dchain will not become involved in active dirops
even while holding no other locks (lfs_lock, v_interlock), so we must
set lfs_writer here. All other callers already set lfs_writer.

We set fs->lfs_writer++ without explicitly doing lfs_writer_enter
because
(a) we already waited for the dirops to drain, and
(b) we hold lfs_lock and cannot drop it before setting lfs_writer.

Assert lfs_writer where I think we can now prove it.

Serialize access to the splay tree with lfs_lock.

Change some cheap KDASSERT into KASSERT.

Take a reference and fix assertions in lfs_flush_dirops.
Fixes panic:
KASSERT((ip->i_state & IN_ADIROP) == 0) at lfs_vnops.c:1670
lfs_flush_dirops
lfs_check
lfs_setattr
VOP_SETATTR
change_mode
sys_fchmod
syscall

This assertion -- and the assertion that vp->v_uflag has VU_DIROP set
-- is valid only until we release lfs_lock, because we may race with
lfs_unmark_dirop which will remove the nodes and change the flags.

Further, vp itself is valid only as long as it is referenced, which it
is as long as it's on the dchain, but lfs_unmark_dirop drops the
dchain's reference.

Don't lfs_writer_enter while holding v_interlock.

There's no need to lfs_writer_enter at all here, as far as I can see.
lfs_flush_fs will do it for us.

Break deadlock in PR kern/52301.

The lock order is lfs_writer -> lfs_seglock. The problem in 52301 is
that lfs_segwrite violates this lock order by sometimes doing
lfs_seglock -> lfs_writer, either (a) when doing a checkpoint or (b),
opportunistically, when there are no dirops pending. Both cases can
deadlock, because dirops sometimes take the seglock (lfs_truncate,
lfs_valloc, lfs_vfree):
(a) There may be dirops pending, and they may be waiting for the
seglock, so we can't wait for them to complete while holding the
seglock.
(b) The test for fs->lfs_dirops == 0 happens unlocked, and the state
may change by the time lfs_writer_enter acquires lfs_lock.

To resolve this in each case:
(a) Do lfs_writer_enter before lfs_seglock, since we will need it
unconditionally anyway. The worst performance impact of this should
be that some dirops get delayed a little bit.
(b) Create a new lfs_writer_tryenter to use at this point so that the
test for fs->lfs_dirops == 0 and the acquisition of lfs_writer happen
atomically under lfs_lock.

Initialize/destroy lfs_allclean_wakeup in modcmd, not lfs_mountfs.

Fixes reloading lfs.kmod.

In lfs_update, hold lfs_writer around lfs_vflush.

Otherwise, we might do
lfs_vflush
-> lfs_seglock
-> lfs_segwait(SEGM_CKP)
-> lfs_writer_enter
which is the reverse of the lfs_writer -> lfs_seglock ordering.

Call lfs_orphan in lfs_rename while we're still in the dirop.
lfs_writer_enter can't fail; keep it simple and don't pretend it can.

Assert that mtsleep can't fail either -- it doesn't catch signals and
there's no timeout.

Teach LFS_ORPHAN_NEXTFREE about lfs64.

Dust off the orphan detection code and try to make it work.

Fix !DIAGNOSTIC compile

Fix userland references to LFS_ORPHAN_NEXTFREE.

Forgot to grep for these or do a full distribution build, oops!

Fix missing <sys/evcnt.h> by removing the evcnts instead.

Just wanted to confirm that a race might happen, and indeed it did.
These serve little diagnostic value otherwise.

OR into bp->b_cflags; don't overwrite.

CTASSERT lfs on-disk structure sizes.

Avoid misaligned access to lfs64 on-disk records in memory.
lfs64 directory entries are only 32-bit aligned in order to conserve
space in directory blocks, and we had a hack to stuff a 64-bit inode
in them. This replaces the hack by __aligned(4) __packed, and goes
further:

1. It's not clear that all the other lfs64 data structures are 64-bit
aligned on disk to begin with. We can go through these later and
upgrade them from
struct foo64 {
...
} __aligned(4) __packed;
union foo {
struct foo64 f64;
...
};
to
struct foo64 {
...
};
union foo {
struct foo64 f64 __aligned(8);
...
} __aligned(4) __packed;
if we really want to take advantage of 64-bit memory accesses.
However, the __aligned(4) __packed must remain on the union
because:
2. We access even the lfs32 data structures via a union that has
lfs64 members, and it turns out that compilers will assume access
through a union with 64-bit aligned members implies the whole
union has 64-bit alignment, even if we're only accessing a 32-bit
aligned member.

Fix clang build after packed lfs64 accessor change.

Suppress spurious address-of-packed error in rump lfs too.
 1.1.26.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.1.22.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.22.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file Makefile was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.1.12.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.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file Makefile was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file Makefile was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file Makefile was added on branch nick-nhusb on 2017-02-05 13:40:13 +0000
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18;
Initial commit of native amd64 EFI boot loader.
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file efiboot_machdep.h was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file efiboot_machdep.h was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file efiboot_machdep.h was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efiboot_machdep.h was added on branch nick-nhusb on 2017-02-05 13:40:13 +0000
 1.6 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.5 13-Sep-2019  manu branches: 1.5.26;
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.4 27-Mar-2018  nonaka branches: 1.4.2; 1.4.6;
efiboot: Added serial console support.
 1.3 29-Apr-2017  nonaka branches: 1.3.2; 1.3.8; 1.3.10;
efiboot: Boot parameters can be set via installboot(8).
 1.2 11-Feb-2017  nonaka branches: 1.2.2; 1.2.6; 1.2.8;
PR/51953: fix unable to boot on some AMD machine.

Delayed the timing to copy the kernel to actual address.
copy routine from common/lib/libc/arch/x86_64/string/bcopy.S
 1.1 24-Jan-2017  nonaka branches: 1.1.2;
Initial commit of native amd64 EFI boot loader.
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file efibootx64.c was added on branch nick-nhusb on 2017-02-05 13:40:13 +0000
 1.2.8.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.2.6.2 11-Feb-2017  nonaka 1673251
 1.2.6.1 11-Feb-2017  nonaka file efibootx64.c was added on branch bouyer-socketcan on 2017-02-11 10:23:40 +0000
 1.2.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.2.2.1 11-Feb-2017  pgoyette file efibootx64.c was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.3.10.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.3.8.2 03-Dec-2017  jdolecek update from HEAD
 1.3.8.1 29-Apr-2017  jdolecek file efibootx64.c was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.3.2.2 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.3.2.1 02-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #685):

sys/arch/i386/stand/efiboot/efidisk.c: revision 1.4
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.4
sys/arch/i386/stand/efiboot/eficons.c: revision 1.5
sys/arch/i386/stand/efiboot/efichar.c: revision 1.1
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.4
sys/arch/i386/stand/efiboot/boot.c: revision 1.8
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidelay.c: revision 1.2
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.7
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.11

efiboot: Added serial console support.
 1.4.6.2 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.4.6.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.4.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.26.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.2 24-Dec-2018  christos Avoid error with new binutils:
error: PHDR segment not covered by LOAD segment
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.18; 1.1.20; 1.1.22;
Initial commit of native amd64 EFI boot loader.
 1.1.22.1 10-Jun-2019  christos Sync with HEAD
 1.1.20.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 24-Jan-2017  jdolecek file ldscript was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file ldscript was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file ldscript was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file ldscript was added on branch nick-nhusb on 2017-02-05 13:40:13 +0000
 1.1 13-Sep-2019  manu branches: 1.1.2; 1.1.4; 1.1.12;
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.1.12.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.1.12.1 13-Sep-2019  martin file multiboot64.S was added on branch phil-wifi on 2020-04-13 08:03:54 +0000
 1.1.4.2 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.1.4.1 13-Sep-2019  martin file multiboot64.S was added on branch netbsd-8 on 2019-09-18 17:30:05 +0000
 1.1.2.2 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.1.2.1 13-Sep-2019  martin file multiboot64.S was added on branch netbsd-9 on 2019-09-17 19:32:00 +0000
 1.2 29-Apr-2017  nonaka branches: 1.2.8;
efiboot: Boot parameters can be set via installboot(8).
 1.1 24-Jan-2017  nonaka branches: 1.1.2; 1.1.4; 1.1.8; 1.1.10;
Initial commit of native amd64 EFI boot loader.
 1.1.10.1 02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.1.8.2 24-Jan-2017  nonaka 1468398
 1.1.8.1 24-Jan-2017  nonaka file start.S was added on branch bouyer-socketcan on 2017-01-24 11:09:15 +0000
 1.1.4.2 20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1 24-Jan-2017  pgoyette file start.S was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.1.2.3 28-Aug-2017  skrll Sync with HEAD
 1.1.2.2 05-Feb-2017  skrll Sync with HEAD
 1.1.2.1 24-Jan-2017  skrll file start.S was added on branch nick-nhusb on 2017-02-05 13:40:13 +0000
 1.2.8.2 03-Dec-2017  jdolecek update from HEAD
 1.2.8.1 29-Apr-2017  jdolecek file start.S was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.5 24-Jun-2023  msaitoh Fix typo in comment.
 1.4 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.3 11-Feb-2017  nonaka branches: 1.3.2; 1.3.6; 1.3.16; 1.3.24; 1.3.50;
PR/51953: fix unable to boot on some AMD machine.

Delayed the timing to copy the kernel to actual address.
copy routine from common/lib/libc/arch/x86_64/string/bcopy.S
 1.2 04-Feb-2017  christos branches: 1.2.2;
Fix operand width
 1.1 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.2.2.3 28-Aug-2017  skrll Sync with HEAD
 1.2.2.2 05-Feb-2017  skrll Sync with HEAD
 1.2.2.1 04-Feb-2017  skrll file startprog64.S was added on branch nick-nhusb on 2017-02-05 13:40:13 +0000
 1.3.50.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.3.24.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.3.16.2 03-Dec-2017  jdolecek update from HEAD
 1.3.16.1 11-Feb-2017  jdolecek file startprog64.S was added on branch tls-maxphys on 2017-12-03 11:36:19 +0000
 1.3.6.2 11-Feb-2017  nonaka 1673251
 1.3.6.1 11-Feb-2017  nonaka file startprog64.S was added on branch bouyer-socketcan on 2017-02-11 10:23:40 +0000
 1.3.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.3.2.1 11-Feb-2017  pgoyette file startprog64.S was added on branch pgoyette-localcount on 2017-03-20 06:57:15 +0000
 1.3 10-Mar-2012  dsl Add support for directly booting from FAT12 filesystems.
This shouldn't really be needed except that Linux wont
mount a small FAT16 filesystem - it always treats it as FAT12
even when you tell it otherwise.
There was enough free space before the main FS on the USB stick
I've been using for an extra small FAT fs to boot from.
 1.2 06-Jan-2007  dsl branches: 1.2.2; 1.2.6; 1.2.86; 1.2.90;
Change build to allow a fat32 bootstrap to be built from the same sources
(the relevant changes haven't been done though).
Call built binary bootxx_fat16 for consistency.
Use 'push %cs' to push a zero value in places where we had relied on %bx
being zero from much higher up the code.
 1.1 01-Jan-2007  dsl Add a sub-512 byte piece of code that can be written (by a modified installboot)
into the first sector of a FAT16 filesystem and will load 'boot' (and hence)
the netbsd kernel from it.
Unlike bootxx_msdosfs this doesn't need the filesystem to have 8k of 'reserved'
sectors, and may well work on non-512 byte media (as yet untested).
 1.2.90.1 11-Mar-2012  mrg sync to latest -current
 1.2.86.1 17-Apr-2012  yamt sync with head
 1.2.6.2 26-Feb-2007  yamt sync with head.
 1.2.6.1 06-Jan-2007  yamt file Makefile was added on branch yamt-lazymbuf on 2007-02-26 09:07:04 +0000
 1.2.2.2 12-Jan-2007  ad Sync with head.
 1.2.2.1 06-Jan-2007  ad file Makefile was added on branch newlock2 on 2007-01-12 01:00:51 +0000
 1.9 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.8 02-Jun-2018  christos branches: 1.8.2;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.7 12-Jan-2014  tsutsui branches: 1.7.28;
Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.

XXX: probabry we should have bsd.saprog.mk or something.
 1.6 20-May-2011  joerg branches: 1.6.4; 1.6.14; 1.6.18;
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.5 30-Mar-2009  tsutsui branches: 1.5.4; 1.5.6;
Remove extra trailing slash in ${S} path.
 1.4 12-Mar-2009  abs Prefer MACHINE_ARCH to MACHINE in some tests
 1.3 25-Oct-2008  apb branches: 1.3.2; 1.3.8;
Use ${TOOL_SED} instead if plain sed in Makefiles.
 1.2 20-Oct-2008  christos disable PIE for boot code.
 1.1 06-Jan-2007  dsl branches: 1.1.2; 1.1.6; 1.1.48; 1.1.52; 1.1.58;
Change build to allow a fat32 bootstrap to be built from the same sources
(the relevant changes haven't been done though).
Call built binary bootxx_fat16 for consistency.
Use 'push %cs' to push a zero value in places where we had relied on %bx
being zero from much higher up the code.
 1.1.58.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.52.1 04-May-2009  yamt sync with head.
 1.1.48.1 17-Jan-2009  mjf Sync with HEAD.
 1.1.6.2 26-Feb-2007  yamt sync with head.
 1.1.6.1 06-Jan-2007  yamt file Makefile.fat was added on branch yamt-lazymbuf on 2007-02-26 09:07:04 +0000
 1.1.2.2 12-Jan-2007  ad Sync with head.
 1.1.2.1 06-Jan-2007  ad file Makefile.fat was added on branch newlock2 on 2007-01-12 01:00:51 +0000
 1.3.8.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.3.8.2 01-Nov-2009  jym Sync with HEAD.
 1.3.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.5.4.1 31-May-2011  rmind sync with head
 1.6.18.1 18-May-2014  rmind sync with head
 1.6.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.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.7.28.2 28-Jul-2018  pgoyette Sync with HEAD
 1.7.28.1 25-Jun-2018  pgoyette Sync with HEAD
 1.8.2.1 10-Jun-2019  christos Sync with HEAD
 1.5 28-Feb-2025  andvar Fix various typos in comments.
 1.4 10-Mar-2012  dsl branches: 1.4.76;
Add support for directly booting from FAT12 filesystems.
This shouldn't really be needed except that Linux wont
mount a small FAT16 filesystem - it always treats it as FAT12
even when you tell it otherwise.
There was enough free space before the main FS on the USB stick
I've been using for an extra small FAT fs to boot from.
 1.3 29-Apr-2008  martin branches: 1.3.34; 1.3.38;
Convert to new 2 clause license
 1.2 06-Jan-2007  dsl branches: 1.2.2; 1.2.6; 1.2.48; 1.2.50; 1.2.52;
Change build to allow a fat32 bootstrap to be built from the same sources
(the relevant changes haven't been done though).
Call built binary bootxx_fat16 for consistency.
Use 'push %cs' to push a zero value in places where we had relied on %bx
being zero from much higher up the code.
 1.1 01-Jan-2007  dsl Add a sub-512 byte piece of code that can be written (by a modified installboot)
into the first sector of a FAT16 filesystem and will load 'boot' (and hence)
the netbsd kernel from it.
Unlike bootxx_msdosfs this doesn't need the filesystem to have 8k of 'reserved'
sectors, and may well work on non-512 byte media (as yet untested).
 1.2.52.1 16-May-2008  yamt sync with head.
 1.2.50.1 18-May-2008  yamt sync with head.
 1.2.48.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.6.2 26-Feb-2007  yamt sync with head.
 1.2.6.1 06-Jan-2007  yamt file fatboot.S was added on branch yamt-lazymbuf on 2007-02-26 09:07:04 +0000
 1.2.2.2 12-Jan-2007  ad Sync with head.
 1.2.2.1 06-Jan-2007  ad file fatboot.S was added on branch newlock2 on 2007-01-12 01:00:51 +0000
 1.3.38.1 11-Mar-2012  mrg sync to latest -current
 1.3.34.1 17-Apr-2012  yamt sync with head
 1.4.76.1 02-Aug-2025  perseant Sync with HEAD
 1.1 10-Mar-2012  dsl branches: 1.1.2;
Add support for directly booting from FAT12 filesystems.
This shouldn't really be needed except that Linux wont
mount a small FAT16 filesystem - it always treats it as FAT12
even when you tell it otherwise.
There was enough free space before the main FS on the USB stick
I've been using for an extra small FAT fs to boot from.
 1.1.2.2 17-Apr-2012  yamt sync with head
 1.1.2.1 10-Mar-2012  yamt file Makefile was added on branch yamt-pagecache on 2012-04-17 00:06:30 +0000
 1.1 06-Jan-2007  dsl branches: 1.1.2; 1.1.6;
Change build to allow a fat32 bootstrap to be built from the same sources
(the relevant changes haven't been done though).
Call built binary bootxx_fat16 for consistency.
Use 'push %cs' to push a zero value in places where we had relied on %bx
being zero from much higher up the code.
 1.1.6.2 26-Feb-2007  yamt sync with head.
 1.1.6.1 06-Jan-2007  yamt file Makefile was added on branch yamt-lazymbuf on 2007-02-26 09:07:05 +0000
 1.1.2.2 12-Jan-2007  ad Sync with head.
 1.1.2.1 06-Jan-2007  ad file Makefile was added on branch newlock2 on 2007-01-12 01:00:51 +0000
 1.53 01-Jul-2024  rin i386: stand: G/C `I386_INCLUDE_DOS` leftover

Anyway, `I386_INCLUDE_DISK` is enabled for dosboot.
 1.52 29-Jun-2024  rin branches: 1.52.2;
i386: stand: Adjust for DOS-routine migration
 1.51 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.50 29-Jun-2024  rin i386: stand: G/C unused `printmemlist`, NFC
 1.49 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.48 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.47 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.46 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.45 02-Feb-2018  mrg branches: 1.45.4; 1.45.8;
convert HAVE_GCC handling to modern GCC release numbering:
- HAVE_GCC=5 is now the default (vs. HAVE_GCC=53 we've been using for
GCC 5.4 and GCC 5.5.)
- remove some more GCC 4.8 code. we don't support GCC 4 here.
- adjust set lists to gcc=5 from gcc=53.

add some basic HAVE_GCC=6 handling (totally unused so far.)
 1.44 22-Mar-2016  mrg branches: 1.44.10;
remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.43 07-Sep-2015  uebayasi Order library object build.
 1.42 07-Sep-2015  uebayasi Sprinkle more done messages.
 1.41 16-Apr-2015  mrg remove HAVE_GCC=45 fragment.
 1.40 08-Apr-2014  christos branches: 1.40.4;
make this more attractive (to me).
 1.39 08-Apr-2014  joerg Unbreak clang build by restricting -O0 hack to gcc.
 1.38 07-Apr-2014  christos XXX: gcc-4.8 bug. Passes wrong arguments to biosdisk_read(). Turn optimization
off.
 1.37 14-Feb-2014  joerg branches: 1.37.2;
Only realprot.S still needs to be built with GNU as.
 1.36 10-Aug-2012  joerg branches: 1.36.2; 1.36.4;
Don't depend on HAVE_GCC being always present.
 1.35 22-Jun-2011  mrg branches: 1.35.2;
apply some -Wno-error and/or -fno-strict-aliasing.


all of this should be looked at closer, but some of them are not
very trivial.
 1.34 07-Jun-2011  joerg Catch up with addition of putstr32.S.
 1.33 02-Jun-2011  dsl Add C stubs to allow prints early in the boot code.
 1.32 20-May-2011  joerg branches: 1.32.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.31 05-Jan-2011  jakllsch branches: 1.31.2;
Teach BIOS disk driver about GPT partition tables.
Inspired by Mike Volokhov's GPT booting GSoC project.
 1.30 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.29 19-Nov-2009  dsl branches: 1.29.4;
Add 32 bit versions of message and dump_eax that write directly to
the serial port. Useful for debugging - especially real_to_prot!
 1.28 30-Mar-2009  tsutsui Remove extra trailing slash in ${S} path.
 1.27 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.26 25-Nov-2008  ad branches: 1.26.4;
Make pxeboot understand boot.cfg.
 1.25 11-Oct-2008  joerg branches: 1.25.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.24 17-Oct-2007  garbled branches: 1.24.16; 1.24.20; 1.24.26;
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.23 26-Sep-2007  ad - Make it compile again.
- Don't use (very dodgy) inline assembly.
 1.22 16-Apr-2003  dsl branches: 1.22.18; 1.22.60; 1.22.68; 1.22.78; 1.22.80; 1.22.82;
Add functions needed by new boot code
 1.21 23-Jan-2003  jdolecek add another memory size detection routine, using int15, function 0xc7, which
is supported on later IBM PS/2 models; this is necessary to detect memory
over 64MB
thanks go to Pavel Cahyna for testing on his IBM PS/2 machine with 128MB

bump biosboot version to 2.15
 1.20 12-Dec-2001  tv branches: 1.20.2;
MKfoo=no -> NOfoo
 1.19 14-Nov-2001  tv Work around <bsd.lib.mk> used for kernel libs in other places. Clean up
include paths.
 1.18 19-May-2001  jdolecek branches: 1.18.4;
Add biosmca.S if I386_INCLUDE_PS2 variable is "yes" (default, overridable)
 1.17 24-Sep-2000  jdolecek branches: 1.17.4;
netbsd_opts.c was removed as part of bootverbose/bootquiet changes
Pointed out by Lennart Augustsson in private e-mail.
 1.16 13-May-2000  jdolecek remove now redundant comment regarding IBM_L40 define
 1.15 11-May-2000  jdolecek add commented out CPPFLAGS+= -DIBM_L40 - needed for PS/2 bootblocks
 1.14 23-Apr-2000  tsarna Addredd port-i386/9897, but differently. Since the effect of resetting
the video mode on machines with ancient or no video cards is not clear,
for safety's sake a I created a new biosboot variant, biosboot_resetvideo
that does the call.

Anyway, now I can boot my i-opener without hitting Tab. Thanks Andrew!
 1.13 21-Dec-1999  drochner add a function which prints out the memory descriptors (for debugging)
 1.12 28-Apr-1999  christos branches: 1.12.2; 1.12.8;
use new loadfile
 1.11 08-Mar-1999  drochner branches: 1.11.4;
add a function to pass the "memory map" ie the outcome of INT15/0xe820,
to the kernel
 1.10 13-Feb-1999  lukem convert from NOxxx= to MKxxx=no.
include <bsd.own.mk> if testing a MKxxx variable.
 1.9 30-Jan-1999  christos Remove exec.c from here. I want to make it obvious that it has to be built
with different flags from dosboot and biosboot. Although right now this
does not make a difference because we are building the libraries twice,
it can make a difference when we share the builds.
 1.8 29-Jan-1999  thorpej Um, last rev was kind of backwards... actually build exec.o so that
the boot block links.
 1.7 29-Jan-1999  christos exec.c has all the info now.
 1.6 28-Jan-1999  christos Add loadfile.c (stolen from Jason's alpha/stand/common/loadfile.c)
loadfile.h contains macros that are supposed to be MD, but loadfile.c is now MI.
Fixes:
- a.out support
- pass information values via an array not global variables
- don't assume that you can access memory directly.
- remove MD parts
- remove some printfs.
XXX: loadfile.c needs to be moved somewhere where other ports can use it.
XXX2: read() routines on the i386 don't appear to set errno on failure.
 1.5 17-Sep-1997  drochner add new files
 1.4 14-Aug-1997  drochner Build the new memory detection stuff.
 1.3 13-Apr-1997  perry branches: 1.3.4;
1) Make carriage return start boot immediately.
2) Make "quit" reboot machine. This works by adding a reboot assembler
hook that calls INT 19h
 1.2 14-Mar-1997  thorpej Make this work with obj* dirs.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.4.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.17.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.17.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.18.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.20.2.2 12-Dec-2001  tv MKfoo=no -> NOfoo
 1.20.2.1 12-Dec-2001  tv file Makefile was added on branch sommerfeld_i386mp_1 on 2001-12-12 01:49:45 +0000
 1.22.82.1 06-Oct-2007  yamt sync with head.
 1.22.80.1 06-Nov-2007  matt sync with HEAD
 1.22.78.1 02-Oct-2007  joerg Sync with HEAD.
 1.22.68.1 03-Oct-2007  garbled Sync with HEAD
 1.22.60.1 09-Oct-2007  ad Sync with head.
 1.22.18.1 27-Oct-2007  yamt sync with head.
 1.24.26.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.24.26.1 19-Oct-2008  haad Sync with HEAD.
 1.24.20.2 11-Mar-2010  yamt sync with head
 1.24.20.1 04-May-2009  yamt sync with head.
 1.24.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.25.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.25.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.25.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.4.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.26.4.3 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.26.4.2 01-Nov-2009  jym Sync with HEAD.
 1.26.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.29.4.3 12-Jun-2011  rmind sync with head
 1.29.4.2 31-May-2011  rmind sync with head
 1.29.4.1 05-Mar-2011  rmind sync with head
 1.31.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.32.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.35.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.35.2.1 30-Oct-2012  yamt sync with head
 1.36.4.1 18-May-2014  rmind sync with head
 1.36.2.2 03-Dec-2017  jdolecek update from HEAD
 1.36.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.37.2.1 10-Aug-2014  tls Rebase.
 1.40.4.3 22-Apr-2016  skrll Sync with HEAD
 1.40.4.2 22-Sep-2015  skrll Sync with HEAD
 1.40.4.1 06-Jun-2015  skrll Sync with HEAD
 1.44.10.2 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.44.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.45.8.2 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.45.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.45.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.52.2.1 02-Aug-2025  perseant Sync with HEAD
 1.21 25-May-2025  rillig i386/stand: build in parallel mode
 1.20 30-Aug-2023  christos branches: 1.20.6;
Explicitly pass COPTS
 1.19 13-Jun-2018  christos revert previous MAKEOBJDIRPREFIX massaging
 1.18 11-Jun-2018  christos switch CFLAGS from using MAKEOBJDIRPREFIX to MAKEOBJDIR. This whole thing
is disgusting, but fixing it properly. requires restructuring
 1.17 27-May-2018  christos - Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
 1.16 22-Mar-2016  mrg branches: 1.16.10; 1.16.16;
remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.15 06-Sep-2015  uebayasi In kernel lib build, print message when things not only start bug also end.
 1.14 26-May-2011  joerg branches: 1.14.32;
Default to -Wno-sign-compare -Wno-pointer-sign for clang.
Push -Wno-array-bounds down to the cases that depend on it.
Selectively disable warnings for 3rd party software or non-trivial
issues to be reviewed later to get clang -Werror to build most of the
tree.
 1.13 11-Dec-2005  christos branches: 1.13.92; 1.13.100; 1.13.106;
merge ktrace-lwp.
 1.12 07-Nov-2003  dsl Make 'dependall' generate the dependencies
 1.11 22-Nov-2001  dillo branches: 1.11.2; 1.11.18;
Repeat James Chacon's fix from sys/lib/lib{kern,sa,z}:

Don't make clean and cleandir depend on the lib subdir.
Just check for it's existance before running the submake.
This makes it possible to run a make build (which runs
cleandir before make obj) in a r/o source tree.
 1.10 18-Aug-2001  enami Fix white space usage.
 1.9 08-Sep-2000  tron branches: 1.9.4; 1.9.6;
Final fix to make this work without object directories again.
 1.8 08-Sep-2000  tron Readd at signs before commands which were removed for debugging.
 1.7 08-Sep-2000  tron Do last change differently: "(unset MAKEOBJDIRPREFIX || true)" is a NOP,
use "MAKEOBJDIRPREFIX= && unset MAKEOBJDIRPREFIX" instead.
 1.6 08-Sep-2000  tron Use "(unset MAKEOBJDIRPREFIX || true)" because unset return an error code
if the variable was not set before.
 1.5 08-Sep-2000  matt deal properly with MAKEOBJDIRPREFIX (which has priority over MAKEOBJDIR so
the MAKEOBJDIR to ${MAKE} has no effect) so we unset MAKEOBJDIRPREFIX before
invoking ${MAKE}
 1.4 01-Feb-2000  tsutsui branches: 1.4.6;
Revert STRIPPROG -> STRIP
 1.3 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.2 05-Sep-1998  lukem branches: 1.2.12;
distclean is a synonym for cleandir
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.12.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.6.2 11-Sep-2000  tron Pull up from current (approved by thorpej):

Make this work without object directories again.

syssrc/sys/arch/i386/stand/lib/Makefile.inc 1.5 -> 1.9
 1.4.6.1 09-Sep-2000  matt Approved by jhawk
>Make this work with MAKEOBJDIRPREFIX.
 1.9.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.9.6.1 25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.9.4.2 08-Jan-2002  nathanw Catch up to -current.
 1.9.4.1 24-Aug-2001  nathanw Catch up with -current.
 1.11.18.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.18.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.18.1 03-Aug-2004  skrll Sync with HEAD
 1.11.2.2 22-Nov-2001  dillo Repeat James Chacon's fix from sys/lib/lib{kern,sa,z}:

Don't make clean and cleandir depend on the lib subdir.
Just check for it's existance before running the submake.
This makes it possible to run a make build (which runs
cleandir before make obj) in a r/o source tree.
 1.11.2.1 22-Nov-2001  dillo file Makefile.inc was added on branch sommerfeld_i386mp_1 on 2001-11-22 00:04:56 +0000
 1.13.106.1 06-Jun-2011  jruoho Sync with HEAD.
 1.13.100.1 31-May-2011  rmind sync with head
 1.13.92.1 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.14.32.2 22-Apr-2016  skrll Sync with HEAD
 1.14.32.1 22-Sep-2015  skrll Sync with HEAD
 1.16.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.16.10.1 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.20.6.1 02-Aug-2025  perseant Sync with HEAD
 1.23 10-Sep-2022  rillig fix misspellings of 'available' and nearby typos
 1.22 19-Jul-2014  erh Fix bootxx_* and boot on machines where the bios sets high bits of %eax on success.
 1.21 16-Jun-2011  joerg branches: 1.21.12; 1.21.26;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.20 29-Dec-2010  jakllsch branches: 1.20.6;
Utilize movz[bw]l to save a few instrutions and bytes of .text.
 1.19 21-Nov-2009  dsl branches: 1.19.4;
Preserve %ds over bios calls.
Not strickly necessary because real_to_prot doesn't normally rely on in.
However it caused much confusion while debugging, and does no harm.
 1.18 11-Dec-2005  christos branches: 1.18.78; 1.18.92;
merge ktrace-lwp.
 1.17 29-Jun-2005  junyoung Massive renames for consistency:
biosdiskreset -> biosdisk_reset
biosread -> biosdisk_read
get_diskinfo -> biosdisk_getinfo
int13_extension -> biosdisk_int13ext
biosextread -> biosdisk_extread
int13_getextinfo -> biosdisk_getextinfo
struct biosdisk_ext13info -> biosdisk_extinfo
BIOSDISK_EXT13 -> BIOSDISK_INT13EXT
BIOSDISK_EXT13INFO_V{2,3} -> BIOSDISK_EXTINFO_V{2,3}
EXT13_* -> EXTINFO_*
 1.16 29-Jun-2005  junyoung get_diskinfo():
Return status code in bits [31:24] of %eax. 0 for success, otherwise failure.
 1.15 22-Jun-2005  junyoung Do not mix assembly-style comments and C-style comments.
 1.14 13-Jun-2005  junyoung Remove trailing spaces.
 1.13 16-Apr-2003  dsl branches: 1.13.2;
C code now sets length of disk info structure
 1.12 08-Mar-2003  dsl Don't trust %bp to point to same place in real and protected modes.
prot_to_real preserves %ebp but changes %ss and %sp.
(ok if real %ss is offset n*64k from protected %ss - which it has been)
 1.11 05-Feb-2003  dsl Remove unused defines
 1.10 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.9 10-Oct-2002  dyoung Introduce biosdiskreset(), and call it to reset the disk (with Int
0x13 Function 0) after a read error. This is a requirement mentioned
in most BIOS documentation.

This answers PR 18591.

Incidentally, on the Soekris Engineering net45x1 single-board
computer, this fixes a bug where the bootloader corrupts the kernel
while loading it from certain varieties of CompactFlash card
(especially varieties identified by NetBSD as <TOSHIBA THNCF064MBA>).
 1.8 21-May-2000  perry branches: 1.8.6; 1.8.8;
Actually return the BIOS error code (if any) generated by the reads
 1.7 30-Mar-1999  fvdl branches: 1.7.8;
Shifting ecx without explicit prefix in real mode won't work.
 1.6 30-Mar-1999  drochner fix some disk handling problems introduced in the last commits:
-read retries were botched, use the right sector count
-read-ahead buffer was effectively unused
-concentrate the handling of the weird BIOS geometry report at one place
-fallback for old floppies left cylinder count uninitialized
 1.5 08-Mar-1999  fvdl * query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.4 30-Oct-1998  ws Fix a thinko which still prevented this to run on non-int13-ext machines.
Thanks to entropy@zippy.bernstein.com for pointing this out and testing the fix.
 1.3 27-Oct-1998  ws Fix typo which prevented this from working
on disks without int13-extension support.
 1.2 15-Oct-1998  ws Add int13 extension support
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.7.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.8.1 18-Oct-2002  nathanw Catch up to -current.
 1.8.6.2 21-May-2000  perry Actually return the BIOS error code (if any) generated by the reads
 1.8.6.1 21-May-2000  perry file bios_disk.S was added on branch sommerfeld_i386mp_1 on 2000-05-21 16:59:29 +0000
 1.13.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.92.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.18.92.2 10-Jan-2011  jym Sync with HEAD
 1.18.92.1 24-Oct-2010  jym Sync with HEAD
 1.18.78.1 11-Mar-2010  yamt sync with head
 1.19.4.1 05-Mar-2011  rmind sync with head
 1.20.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.21.26.1 10-Aug-2014  tls Rebase.
 1.21.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.7 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.4 01-Feb-2003  dsl branches: 1.4.2;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.3 18-Aug-1997  hannken Change "it's" to "it is" inside assembler comments to
stop "unterminated character constant" messages from `mkdep'.
 1.2 13-Jun-1997  drochner branches: 1.2.4;
Fix operand size confusion in 16-bit code.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 06-Jul-2005  junyoung - Do not mix C-style comments and assembly-style comments.
- Remove unused #define.
 1.2 01-Feb-2003  dsl branches: 1.2.2; 1.2.18;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.18.1 21-Jun-2006  yamt sync with head.
 1.2.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.61 06-Jan-2024  mlelstv In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.60 02-Oct-2023  manu Fix build with -DNO_GPT
 1.59 28-Sep-2023  manu Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.
We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition
 1.58 03-May-2022  jmcneill branches: 1.58.4;
Trailing whitespace
 1.57 28-Dec-2021  simonb In biosdisk_findpartition() check if part_name isn't NULL before
assigning *part_name.

Thanks to manu@ for the pointer.
 1.56 28-Dec-2021  simonb Fix a tyop.
 1.55 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.54 17-Dec-2019  manu branches: 1.54.12; 1.54.14;
Do not use NAME=label syntax when label are empty

When booting sysinst from UEFI, it defaults to a GPT installation
where partition have no labels. Bootstrap used the NAME=label partition
anyway, with the result that both EFI and FFS root partition had
the same name "NAME=" and could not be distinguished. The first matching
partition for the name was used, and bootstrap looked for the kernel
in the EFI partition.

We fix that by not using NAME=label names for partition when label
is empty. In that case we revert to old syntax such as hd0b
 1.53 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.52 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.51 18-Aug-2019  kamil 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.
 1.50 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.49 02-Apr-2018  nonaka branches: 1.49.2; 1.49.6;
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.48 20-Mar-2018  nonaka efiboot: fix to find boot partition process.

NetBSD related partitions with no bootme flag set are also candidates
for boot partition.
 1.47 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.46 24-Jan-2017  nonaka branches: 1.46.6; 1.46.12;
Initial commit of native amd64 EFI boot loader.
 1.45 05-Jun-2016  maxv branches: 1.45.2; 1.45.4;
The bootinfo is refreshed each time the bootloader tries to execute a
kernel, so there's no point in using this global variable. Because of
this variable, only one "boot" command can be issued in the prompt, and
you have to reboot the machine if you mistyped the kernel name.
 1.44 18-Jan-2015  jakllsch While the old gpt.S mbr code looks at both primary and alternate GPT
partition tables, mbrgpt.S and DKWEDGE_METHOD_GPT only look in the
primary. Align the bootxx/boot2 biosdisk code with this so as to avoid
situations where the disk becomes unbootable when it has an undestroyed
secondary GPT.
 1.43 31-Oct-2013  christos branches: 1.43.4; 1.43.6;
avoid pointer aliasing problems.
 1.42 03-Jul-2012  tsutsui branches: 1.42.2; 1.42.4;
Apply patch:
PR/46583: BIOS bootloader problems with partitions that start above 1TB

Should be pulled up to netbsd-6.
 1.41 13-Jun-2012  perseant Sanity check the values coming back from the int13 extensions of the bios,
so we can catch impossible return values. Allows the bootloader to work
again on the Soekris net4501.

Fixes PR kern/46027.
 1.40 16-Jan-2012  christos branches: 1.40.2;
PR/45796: Evgeniy Ivanov minixfs3 support.
 1.39 21-Sep-2011  gsutre branches: 1.39.2; 1.39.6;
Fix btinfo_bootdisk's labelsector and btinfo_bootwedge's startblk for
the non-GPT case.

ok jakllsch@
 1.38 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.37 26-Jan-2011  jakllsch Attempt to correct two regressions.
- avoid Virtualbox's BIOS panicing on 64-bit LBAs
- MBR-without-disklabel was ignored
 1.36 05-Jan-2011  jakllsch branches: 1.36.2; 1.36.4;
Teach BIOS disk driver about GPT partition tables.
Inspired by Mike Volokhov's GPT booting GSoC project.
 1.35 05-Jan-2011  jakllsch Let the compiler determine the correct type for sizeof().
From Mike Volokhov's GPT booting GSoC.
 1.34 30-Dec-2010  jakllsch Fix DISK_DEBUG build.
 1.33 25-Dec-2010  jakllsch Use printf format macros for long longs.
 1.32 24-Dec-2010  jakllsch Sprinkle daddr_t.
Adjust DISK_DEBUG printf formats to match.
 1.31 25-Jun-2010  tsutsui Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
and use it for large delays (in seconds) instead of delay() that uses
INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
precise delays on emulators.
Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
in qemu 0.12).

No particular comments on the PR and port-i386@.
 1.30 20-Oct-2009  jmcneill branches: 1.30.2; 1.30.4;
trim some fat, don't scan disklabels on non-HD disks
 1.29 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.28 05-Jan-2008  dsl branches: 1.28.10; 1.28.24;
Remove #define DISK_DEBUG left in by mistake
 1.27 04-Jan-2008  dsl Allow the boot code to use the disklabel 'faked up' from the mbr.
Should allow bootxx_fat16 (and bootxx_msdos etc) to boot from drives that
don't contain a netbsd disklabel.
 1.26 25-Jan-2006  christos branches: 1.26.48; 1.26.54; 1.26.62;
free -> dealloc
unsigned -> size_t for alloc/dealloc
 1.25 11-Dec-2005  christos branches: 1.25.2;
merge ktrace-lwp.
 1.24 22-Jun-2005  junyoung branches: 1.24.2;
Add support for cd9660 file system to the i386 BIOS bootloader.
 1.23 22-Jun-2005  junyoung Cosmetic changes.
 1.22 13-Jun-2005  junyoung ANSI, KNF, remove trailing spaces, and some other non-functional changes
 1.21 23-Oct-2004  thorpej Add support for passing booted wedge information to the kernel.
 1.20 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.19 31-Oct-2003  hannken Remove memset prototype. Already present in sys/lib/libsa/stand.h.
 1.18 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.17 07-Jul-2003  dsl Support booting from a netbsd partition in the MBR extended partition.
 1.16 01-Feb-2003  dsl branches: 1.16.2;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.15 07-Jul-2001  perry branches: 1.15.4;
b*()->mem*()
 1.14 01-Jun-2001  jdolecek g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.13 30-Oct-2000  lukem branches: 1.13.4;
Add support for booting off RAIDframe RAID1 mirrors. Check the first partition
type in biosdiskopen(), and if it is of type FS_RAID, add 64 to d->b_off.

NOTE: installboot(8) still needs some hacking to DTRT, but at least this way
if you can load "/boot" off another partition (e.g, wd0h), then wd0a can be
of type `RAID' with a raidframe mirror at the start and the kernel
will load OK of wd0a, and with raidctl -A root partitions, it will change
root as well.
 1.12 03-Aug-1999  drochner branches: 1.12.2; 1.12.14;
put biosdiskclose() inside LIBSA_NO_FS_CLOSE
 1.11 08-Mar-1999  fvdl * query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.10 27-Jan-1999  thorpej Use the MI <sys/disklabel_mbr.h>, not our own machine-dependent
definitions.
 1.9 15-May-1998  drochner Allow to use the code in user land test programs.
 1.8 19-Feb-1998  drochner Add compatibility code (#ifdef COMPAT_386BSD_MBRPART): look for 386BSD
partition ID if the NetBSD ID was not found.
 1.7 13-Oct-1997  drochner branches: 1.7.2;
Ignore BIOS partition table and disklabel for floppys and RAW_PART,
for consistency with the kernel.
 1.6 20-Sep-1997  drochner don't forget to save the partition number for the kernel
 1.5 17-Sep-1997  drochner Do the vararg stuff cleanly.
Collect disk information in a "bootinfo" structure.
 1.4 13-Jun-1997  drochner branches: 1.4.4;
Reformat comments. (messed up by "indent")
 1.3 22-Mar-1997  thorpej Purely cosmetic whitespace/indentation changes (mmm, indent(1))
 1.2 22-Mar-1997  thorpej Don't abort if we don't find an MBR or NetBSD MBR partition; simply assume
that the NetBSD portion of the disk begins at sector 0.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.4.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.7.2.2 01-Dec-1998  cgd capitalize the name of the project correctly in the warning message,
and also clean up other caps/spacing in that message. If we're going
to include stuff like punctuation, it really should follow other rules of
English. Not done on trunk because, for whatever reason, the message
is entirely different there!
 1.7.2.1 23-Nov-1998  cgd Add forward-compatibility with new NetBSD MBR partition-id 169 (0xa9).
Warn about old-style 165 partitions with a reference to installboot(8)
for details on when and how to upgrade bootblocks and partition IDs.
Do fresh installs using the new ID. Done via patch because it's a long
list of changes which didn't quite apply cleanly. (jonathan)
 1.12.14.1 03-Feb-2001  he Pull up revision 1.13 (requested by lukem):
Add support for booting off RAIDframe RAID1 mirrors. Done by
checking the first partition type in biosdiskopen(), and if it
is of type FS_RAID, add 64 to d->b_off.

NOTE: installboot(8) still needs some hacking to DTRT, but at
least this way if you can load "/boot" off another partition
(e.g, wd0h), then wd0a can be of type `RAID' with a raidframe
mirror at the start and the kernel will load OK of wd0a, and with
raidctl -A root partitions, it will change root as well.
 1.12.2.1 22-Nov-2000  bouyer Sync with HEAD.
 1.13.4.2 24-Aug-2001  nathanw Catch up with -current.
 1.13.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.15.4.2 07-Jul-2001  perry b*()->mem*()
 1.15.4.1 07-Jul-2001  perry file biosdisk.c was added on branch sommerfeld_i386mp_1 on 2001-07-07 22:57:58 +0000
 1.16.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.16.2.4 02-Nov-2004  skrll Sync with HEAD.
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.24.2.2 21-Jan-2008  yamt sync with head
 1.24.2.1 21-Jun-2006  yamt sync with head.
 1.25.2.1 01-Feb-2006  yamt sync with head.
 1.26.62.1 08-Jan-2008  bouyer Sync with HEAD
 1.26.54.1 18-Feb-2008  mjf Sync with HEAD.
 1.26.48.1 09-Jan-2008  matt sync with HEAD
 1.28.24.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.28.24.3 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.28.24.2 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.28.24.1 01-Nov-2009  jym Sync with HEAD.
 1.28.10.3 11-Aug-2010  yamt sync with head.
 1.28.10.2 11-Mar-2010  yamt sync with head
 1.28.10.1 16-Sep-2009  yamt sync with head
 1.30.4.2 05-Mar-2011  rmind sync with head
 1.30.4.1 03-Jul-2010  rmind sync with head
 1.30.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.36.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.36.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.39.6.1 18-Feb-2012  mrg merge to -current.
 1.39.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.39.2.2 30-Oct-2012  yamt sync with head
 1.39.2.1 17-Apr-2012  yamt sync with head
 1.40.2.2 21-Jul-2012  riz Pull up following revision(s) (requested by tsutsui in ticket #432):
sys/arch/i386/stand/lib/biosdisk.c: revision 1.42
Apply patch:
PR/46583: BIOS bootloader problems with partitions that start above 1TB
Should be pulled up to netbsd-6.
 1.40.2.1 24-Jun-2012  jdc Pull up revision 1.41 (requested by martin in ticket #349).

Sanity check the values coming back from the int13 extensions of the bios,
so we can catch impossible return values. Allows the bootloader to work
again on the Soekris net4501.

Fixes PR kern/46027.
 1.42.4.1 18-May-2014  rmind sync with head
 1.42.2.2 03-Dec-2017  jdolecek update from HEAD
 1.42.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.43.6.3 05-Feb-2017  skrll Sync with HEAD
 1.43.6.2 09-Jul-2016  skrll Sync with HEAD
 1.43.6.1 06-Apr-2015  skrll Sync with HEAD
 1.43.4.1 20-Jan-2015  martin Pull up following revision(s) (requested by jakllsch in ticket #436):
sys/arch/i386/stand/lib/biosdisk.c: revision 1.44
While the old gpt.S mbr code looks at both primary and alternate GPT
partition tables, mbrgpt.S and DKWEDGE_METHOD_GPT only look in the
primary. Align the bootxx/boot2 biosdisk code with this so as to avoid
situations where the disk becomes unbootable when it has an undestroyed
secondary GPT.
 1.45.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.45.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.46.12.3 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.46.12.2 22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.46.12.1 15-Mar-2018  pgoyette Synch with HEAD
 1.46.6.7 17-Dec-2019  martin Pull up following revision(s) (requested by manu in ticket #1474):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.54
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.9

Do not use NAME=label syntax when label are empty

When booting sysinst from UEFI, it defaults to a GPT installation
where partition have no labels. Bootstrap used the NAME=label partition
anyway, with the result that both EFI and FFS root partition had
the same name "NAME=" and could not be distinguished. The first matching
partition for the name was used, and bootstrap looked for the kernel
in the EFI partition.

We fix that by not using NAME=label names for partition when label
is empty. In that case we revert to old syntax such as hd0b
 1.46.6.6 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.46.6.5 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.46.6.4 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.46.6.3 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.46.6.2 21-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #648):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.3
sys/arch/i386/stand/efiboot/devopen.c: revision 1.3
sys/arch/i386/stand/efiboot/boot.c: revision 1.7
sys/arch/i386/stand/lib/biosdisk.c: revision 1.48

efiboot: fix it can't boot from HDD.

efiboot: more pager.

efiboot: boot device is always efi_distlist first element.

efiboot: fix to find boot partition process.
NetBSD related partitions with no bootme flag set are also candidates
for boot partition.
 1.46.6.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.49.6.5 18-Oct-2023  martin Pull up following revision(s) (requested by manu in ticket #1751):

sys/dev/raidframe/rf_netbsdkintf.c: revision 1.383
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.385
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.402
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.403
sys/arch/i386/stand/lib/biosdisk.c: revision 1.59
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.377
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.378
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.379
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.392
sys/rump/librump/rumpkern/emul.c: revision 1.200
sys/arch/i386/stand/lib/biosdisk.c: revision 1.60
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.416
(all via patch)

Get &rsc->sc_dksc only when we know 'rsc' is not NULL. This was actually
harmless because we didn't use the pointer then.

Gcc -Os on landisk is not smart enough to follow the conditional
initialization and warns, unconditionaly initialize dksc at declaration
with a XXX gcc comment.

Improve wording in comments in raid_dumpblock().

in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.

Nix trailing whitespace.

if raidframe sets booted_device, log a debug message about it.
merge two debug lines in auto-root selection.
convert non-config-handled "DEBUG_ROOT" to aprint_debug().
now it's possible to get boot-time info about raidframe root
device selection with simple "boot -x".

Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.

We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition

Fix root search in RAID 1 sets

We use the wedge information given by bootstrap, where the kernel was
found. This requires src/sys/arch/i386/stand/i386/lib/biosdisk.c 1.59
to work in all cases.

Fix build with -DNO_GPT
 1.49.6.4 17-Dec-2019  martin Pull up following revision(s) (requested by manu in ticket #568):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.54
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.9

Do not use NAME=label syntax when label are empty

When booting sysinst from UEFI, it defaults to a GPT installation
where partition have no labels. Bootstrap used the NAME=label partition
anyway, with the result that both EFI and FFS root partition had
the same name "NAME=" and could not be distinguished. The first matching
partition for the name was used, and bootstrap looked for the kernel
in the EFI partition.

We fix that by not using NAME=label names for partition when label
is empty. In that case we revert to old syntax such as hd0b
 1.49.6.3 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.49.6.2 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.49.6.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.49.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.54.14.1 31-May-2021  cjep sync with head
 1.54.12.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.58.4.2 14-Jan-2024  martin Pull up following revision(s) (requested by mlelstv in ticket #548):

sys/arch/i386/stand/efiboot/efidisk.h: revision 1.4
sys/arch/i386/stand/lib/exec.c: revision 1.80
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.11
sys/arch/i386/stand/lib/biosdisk.c: revision 1.61

In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.58.4.1 18-Oct-2023  martin Pull up following revision(s) (requested by manu in ticket #418):

sys/arch/i386/stand/lib/biosdisk.c: revision 1.59
sys/rump/librump/rumpkern/emul.c: revision 1.200
sys/arch/i386/stand/lib/biosdisk.c: revision 1.60
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.416

Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.

We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition

Fix root search in RAID 1 sets

We use the wedge information given by bootstrap, where the kernel was
found. This requires src/sys/arch/i386/stand/i386/lib/biosdisk.c 1.59
to work in all cases.

Fix build with -DNO_GPT
 1.13 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.12 13-Sep-2019  manu branches: 1.12.12; 1.12.14;
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.11 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.10 02-Apr-2018  nonaka branches: 1.10.2; 1.10.6;
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.9 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.8 24-Dec-2010  jakllsch branches: 1.8.52; 1.8.58;
Sprinkle daddr_t.
Adjust DISK_DEBUG printf formats to match.
 1.7 14-Dec-2008  christos branches: 1.7.2; 1.7.6;
ANSI and KNF from Anon Ymous
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.78; 1.6.86;
merge ktrace-lwp.
 1.5 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.4 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.3 01-Feb-2003  dsl branches: 1.3.2;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace/indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.6.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.6.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.6.1 05-Mar-2011  rmind sync with head
 1.7.2.1 10-Jan-2011  jym Sync with HEAD
 1.8.58.2 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.8.58.1 15-Mar-2018  pgoyette Synch with HEAD
 1.8.52.4 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.8.52.3 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.8.52.2 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.8.52.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.10.6.2 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.10.6.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.10.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.12.14.1 31-May-2021  cjep sync with head
 1.12.12.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.31 21-Feb-2011  jakllsch Rework previous commit. Return non-zero instead of turning off
BIOSDISK_INT13EXT. BIOSDISK_INT13EXT also enables LBA access mechanisms
that we really want to be using if at all possible.
 1.30 21-Feb-2011  dyoung biosdisk_getextinfo() can fail. If it does fail in set_geometry(),
clear the flag BIOSDISK_INT13EXT so that a caller such as read_gpt()
will not try to rely on the gibberish in the biosdisk_extinfo.
 1.29 30-Dec-2010  jakllsch branches: 1.29.2; 1.29.4;
Make this actually build with DISK_DEBUG.
 1.28 25-Dec-2010  jakllsch Use printf format macros for long longs.
 1.27 24-Dec-2010  jakllsch Sprinkle daddr_t.
Adjust DISK_DEBUG printf formats to match.
 1.26 28-Apr-2008  martin branches: 1.26.14; 1.26.22;
Remove clause 3 and 4 from TNF licenses
 1.25 18-Nov-2006  erh branches: 1.25.52; 1.25.54; 1.25.56;
Add casts so this works with DISK_DEBUG defined.
 1.24 11-Dec-2005  christos branches: 1.24.20; 1.24.22;
merge ktrace-lwp.
 1.23 29-Jun-2005  junyoung branches: 1.23.2;
Massive renames for consistency:
biosdiskreset -> biosdisk_reset
biosread -> biosdisk_read
get_diskinfo -> biosdisk_getinfo
int13_extension -> biosdisk_int13ext
biosextread -> biosdisk_extread
int13_getextinfo -> biosdisk_getextinfo
struct biosdisk_ext13info -> biosdisk_extinfo
BIOSDISK_EXT13 -> BIOSDISK_INT13EXT
BIOSDISK_EXT13INFO_V{2,3} -> BIOSDISK_EXTINFO_V{2,3}
EXT13_* -> EXTINFO_*
 1.22 29-Jun-2005  junyoung get_diskinfo():
Return status code in bits [31:24] of %eax. 0 for success, otherwise failure.
 1.21 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.20 13-Jun-2005  junyoung ANSI, KNF, kill trailing spaces, and cosmetic changes.
 1.19 23-Aug-2004  junyoung Include libi386.h for function prototypes.
 1.18 25-Jun-2003  thorpej branches: 1.18.2;
Add a way to force (at compile time) use of int13 extensions.
 1.17 16-Apr-2003  dsl Use daddr_t for disk block numbers,
Set size of extended disk info structure in the C code
 1.16 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.15 07-Feb-2003  dsl Use on-stack buffer to check for 2.88MB floppy, malloc() hasn't been
loaded when this is called.
Clearly the information is actually available from the bios.
(Approved by christos)
 1.14 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.13 04-Dec-2002  jdolecek If booting from floppy in 2.88MB drive, actually test if it's possible
to read sector 18, and fallback to 1.44MB drive geometry if that fails.
This allows to boot from 1.44MB floppy disk in 2.88MB drive.
Tested with 2.88MB drive in IBM PS/2 model 95 donated
by 'Yokotashi' <lhc at kanal ucw cz> and Pavel Cahyna
<pavel.cahyna at st ms mff cuni cz>
Bump biosboot version.

Fixes PR kern/3418 by Keith Moore.

Change okayed by Frank van den Linden.
 1.12 10-Oct-2002  dyoung Introduce biosdiskreset(), and call it to reset the disk (with Int
0x13 Function 0) after a read error. This is a requirement mentioned
in most BIOS documentation.

This answers PR 18591.

Incidentally, on the Soekris Engineering net45x1 single-board
computer, this fixes a bug where the bootloader corrupts the kernel
while loading it from certain varieties of CompactFlash card
(especially varieties identified by NetBSD as <TOSHIBA THNCF064MBA>).
 1.11 07-Jul-2001  perry branches: 1.11.4; 1.11.18;
b*()->mem*()
 1.10 02-Nov-1999  drochner branches: 1.10.10;
correct debug printf() to make it compile with DISK_DEBUG again,
closes PR kern/8718 by Takahiro Kambe
 1.9 04-May-1999  fvdl branches: 1.9.2; 1.9.4; 1.9.6;
Restrict "out of CHS range" check to harddisks.
 1.8 28-Apr-1999  fvdl Only use int13 extensions if the sectors can not be read through the
older CHS interface. This works around stupid BIOSs who report that
int13 extensions are present and functional, but fail when you actually
use them. Like Adaptec SCSI BIOSs.
 1.7 30-Mar-1999  drochner branches: 1.7.2;
fix some disk handling problems introduced in the last commits:
-read retries were botched, use the right sector count
-read-ahead buffer was effectively unused
-concentrate the handling of the weird BIOS geometry report at one place
-fallback for old floppies left cylinder count uninitialized
 1.6 08-Mar-1999  fvdl * query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.5 15-Oct-1998  ws Add int13 extension support
 1.4 23-Jul-1998  drochner retry disk accesses (for shaky floppy drives)
 1.3 13-Jun-1997  drochner Reformat comments. (messed up by "indent")
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace/indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.7.2.2 04-May-1999  perry branches: 1.7.2.2.2;
pullup 1.8->1.9 (fvdl)
 1.7.2.1 02-May-1999  perry pullup 1.7->1.8 (fvdl)
 1.7.2.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.4.1 15-Nov-1999  fvdl Sync with -current
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.10.10.3 11-Dec-2002  thorpej Sync with HEAD.
 1.10.10.2 18-Oct-2002  nathanw Catch up to -current.
 1.10.10.1 24-Aug-2001  nathanw Catch up with -current.
 1.11.18.1 12-Jan-2003  jmc Pull up versions 1.12-1.13 (requested by jdolecek in ticket #1067)
If booting from floppy in 2.88MB drive, actually test if it's possible
to read sector 18, and fallback to 1.44MB drive geometry if that fails.
This allows to boot from 1.44MB floppy disk in 2.88MB drive.
Tested with 2.88MB drive in IBM PS/2 model 95 donated
by 'Yokotashi' <lhc at kanal ucw cz> and Pavel Cahyna
<pavel.cahyna at st ms mff cuni cz>
Bump biosboot version.

Fixes PR kern/3418 by Keith Moore.
 1.11.4.2 07-Jul-2001  perry b*()->mem*()
 1.11.4.1 07-Jul-2001  perry file biosdisk_ll.c was added on branch sommerfeld_i386mp_1 on 2001-07-07 22:57:58 +0000
 1.18.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 25-Aug-2004  skrll Sync with HEAD.
 1.23.2.1 30-Dec-2006  yamt sync with head.
 1.24.22.1 10-Dec-2006  yamt sync with head.
 1.24.20.1 12-Jan-2007  ad Sync with head.
 1.25.56.1 16-May-2008  yamt sync with head.
 1.25.54.1 18-May-2008  yamt sync with head.
 1.25.52.1 02-Jun-2008  mjf Sync with HEAD.
 1.26.22.1 05-Mar-2011  rmind sync with head
 1.26.14.2 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.26.14.1 10-Jan-2011  jym Sync with HEAD
 1.29.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.29.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.16 08-Mar-2018  nonaka efiboot: system can boot from CD/DVD-ROM media.
 1.15 25-Dec-2007  perry branches: 1.15.90; 1.15.96;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.14 11-Dec-2005  christos branches: 1.14.50; 1.14.56; 1.14.60; 1.14.64;
merge ktrace-lwp.
 1.13 29-Jun-2005  junyoung branches: 1.13.2;
Massive renames for consistency:
biosdiskreset -> biosdisk_reset
biosread -> biosdisk_read
get_diskinfo -> biosdisk_getinfo
int13_extension -> biosdisk_int13ext
biosextread -> biosdisk_extread
int13_getextinfo -> biosdisk_getextinfo
struct biosdisk_ext13info -> biosdisk_extinfo
BIOSDISK_EXT13 -> BIOSDISK_INT13EXT
BIOSDISK_EXT13INFO_V{2,3} -> BIOSDISK_EXTINFO_V{2,3}
EXT13_* -> EXTINFO_*
 1.12 23-Jun-2005  junyoung Define BIOSDISK_DEFAULT_SECSIZE in biosdisk_ll.h and replace BIOSDISK_SECSIZE
with it.
 1.11 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.10 13-Jun-2005  junyoung Cosmetic changes.
 1.9 13-Jun-2005  junyoung - Remove support for gcc < 2.7.x. Nobody is using such an old version
these days.
- s/u_int/uint/
- De-__P()
 1.8 16-Apr-2003  dsl branches: 1.8.2;
used daddr_t for disk block numbers,
add definitions for v2 and v3 disk info structures
 1.7 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.6 28-Apr-1999  fvdl Only use int13 extensions if the sectors can not be read through the
older CHS interface. This works around stupid BIOSs who report that
int13 extensions are present and functional, but fail when you actually
use them. Like Adaptec SCSI BIOSs.
 1.5 12-Mar-1999  fvdl branches: 1.5.2;
Clean up the BIOS disk matching code a bit (better naming, one structure
and sysctl to export to userland). Also, only use total number of sectors
given in the extended parameters if the physical chs geometry is
marked invalid. Hopefully fixes a problem where BIOSs would not correctly
fill in this field.
 1.4 08-Mar-1999  fvdl * query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.3 15-Oct-1998  ws Add int13 extension support
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace/indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.5.2.1 02-May-1999  perry branches: 1.5.2.1.2;
pullup 1.5->1.6 (fvdl)
 1.5.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.8.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.1 21-Jan-2008  yamt sync with head
 1.14.64.1 02-Jan-2008  bouyer Sync with HEAD
 1.14.60.1 26-Dec-2007  ad Sync with head.
 1.14.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.50.1 09-Jan-2008  matt sync with HEAD
 1.15.96.1 15-Mar-2018  pgoyette Synch with HEAD
 1.15.90.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.7 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.6 11-Dec-2005  christos branches: 1.6.92; 1.6.110;
merge ktrace-lwp.
 1.5 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.4 12-May-2003  dsl branches: 1.4.2;
Remove some unused defines
 1.3 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.2 13-Jun-1997  drochner Add missing datasize prefix.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.92.1 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.3 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.2 28-Apr-2008  martin branches: 1.2.14; 1.2.32;
Remove clause 3 and 4 from TNF licenses
 1.1 16-Apr-2003  dsl branches: 1.1.104; 1.1.106; 1.1.108;
additional support routines for boot code
 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.32.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.2.14.1 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.4 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.3 23-Jan-2003  jdolecek use %e?x instead of %?x as 'xorl' arguments
use %al for 'movb' target, and 'andb' for masking the result with $0x02
since 'and' conveniently sets ZF, use 'and+jnz' instead of 'and+cmp+jne'
 1.2 14-May-2001  jdolecek branches: 1.2.2; 1.2.4;
Change biosmca() to export the model number via biosmca_ps2model
variable, if the machine has a MCA bus according to info returned
by BIOS (i.e. on machines without MCA bus, biosmca_ps2model would be zero).

biosmca() is expected to be called on beginning the initialization,
and biosmca_ps2model is then used for further checks.
 1.1 02-May-2001  jdolecek Add function which uses bios call to get system configuration; this can
be used for presence of MCA bus, if ever needed to be done in bootblocks.
Not used at the moment, but may be in future.
 1.2.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.2.4.1 14-May-2001  nathanw file biosmca.S was added on branch nathanw_sa on 2001-06-21 19:26:15 +0000
 1.2.2.2 14-May-2001  jdolecek Change biosmca() to export the model number via biosmca_ps2model
variable, if the machine has a MCA bus according to info returned
by BIOS (i.e. on machines without MCA bus, biosmca_ps2model would be zero).

biosmca() is expected to be called on beginning the initialization,
and biosmca_ps2model is then used for further checks.
 1.2.2.1 14-May-2001  jdolecek file biosmca.S was added on branch sommerfeld_i386mp_1 on 2001-05-14 22:14:48 +0000
 1.3 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 14-May-2001  jdolecek branches: 1.1.2; 1.1.4; 1.1.128; 1.1.130; 1.1.132;
Change biosmca() to export the model number via biosmca_ps2model
variable, if the machine has a MCA bus according to info returned
by BIOS (i.e. on machines without MCA bus, biosmca_ps2model would be zero).

biosmca() is expected to be called on beginning the initialization,
and biosmca_ps2model is then used for further checks.
 1.1.132.2 04-May-2009  yamt sync with head.
 1.1.132.1 16-May-2008  yamt sync with head.
 1.1.130.1 18-May-2008  yamt sync with head.
 1.1.128.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.128.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.1.4.1 14-May-2001  nathanw file biosmca.h was added on branch nathanw_sa on 2001-06-21 19:26:16 +0000
 1.1.2.2 14-May-2001  jdolecek Change biosmca() to export the model number via biosmca_ps2model
variable, if the machine has a MCA bus according to info returned
by BIOS (i.e. on machines without MCA bus, biosmca_ps2model would be zero).

biosmca() is expected to be called on beginning the initialization,
and biosmca_ps2model is then used for further checks.
 1.1.2.1 14-May-2001  jdolecek file biosmca.h was added on branch sommerfeld_i386mp_1 on 2001-05-14 22:14:48 +0000
 1.2.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.10 04-Dec-2016  maxv KNF and explain a few things
 1.9 16-Jun-2011  joerg branches: 1.9.12; 1.9.30; 1.9.34;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.8 11-Dec-2005  christos branches: 1.8.92; 1.8.110;
merge ktrace-lwp.
 1.7 06-Jul-2005  junyoung Remove unused #define.
 1.6 01-Feb-2003  dsl branches: 1.6.2; 1.6.18;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.5 18-Aug-1997  hannken Change "it's" to "it is" inside assembler comments to
stop "unterminated character constant" messages from `mkdep'.
 1.4 14-Aug-1997  drochner New, optional, method to get size of extended memory.
It will be used for getextmem() if EXTENDED_MEMDETECT is defined.
Worked on all tested machines.
Thanks to all testers, especially Martin Husemann!
 1.3 13-Jun-1997  drochner branches: 1.3.4;
Fix misleading comment.
 1.2 19-Mar-1997  sommerfe In 16-bit mode, mov %ax,%bx is interpreted as mov %eax,%ebx; this
breaks zero-extension of the 16-bit memory size return from the BIOS.
on at least one system, the trash left in the upper half of %eax
causes the kernel to crash during VM system initialization when it
thinks it has on the order of 2**31 bytes of memory to play with.

We now *say* mov %eax,%ebx, but *mean* mov %ax,%bx..
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.6.18.1 21-Jun-2006  yamt sync with head.
 1.6.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.8.92.1 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.9.34.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.30.1 05-Dec-2016  skrll Sync with HEAD
 1.9.12.1 03-Dec-2017  jdolecek update from HEAD
 1.7 04-Dec-2016  maxv KNF and explain a few things
 1.6 16-Jun-2011  joerg branches: 1.6.12; 1.6.30; 1.6.34;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.5 20-Feb-2011  jakllsch branches: 1.5.2;
%bl is part of %bx, %bx contains the address we requested from the BIOS.
Thus, use %cl instead of %bl for return value storage.
 1.4 21-Nov-2009  dsl branches: 1.4.4; 1.4.6; 1.4.8;
Preserve %ds over bios calls.
Not strickly necessary because real_to_prot doesn't normally rely on in.
However it caused much confusion while debugging, and does no harm.
 1.3 28-Apr-2008  martin branches: 1.3.14;
Remove clause 3 and 4 from TNF licenses
 1.2 05-Feb-2003  dsl branches: 1.2.104; 1.2.106; 1.2.108;
Change to use .codw16/32 and ensure buffer address <64k
(approved by christos)
 1.1 23-Jan-2003  jdolecek add another memory size detection routine, using int15, function 0xc7, which
is supported on later IBM PS/2 models; this is necessary to detect memory
over 64MB
thanks go to Pavel Cahyna for testing on his IBM PS/2 machine with 128MB

bump biosboot version to 2.15
 1.2.108.2 11-Mar-2010  yamt sync with head
 1.2.108.1 16-May-2008  yamt sync with head.
 1.2.106.1 18-May-2008  yamt sync with head.
 1.2.104.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.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.3.14.2 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.3.14.1 24-Oct-2010  jym Sync with HEAD
 1.4.8.1 05-Mar-2011  bouyer Sync with HEAD
 1.4.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.4.4.1 05-Mar-2011  rmind sync with head
 1.5.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.34.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.6.30.1 05-Dec-2016  skrll Sync with HEAD
 1.6.12.1 03-Dec-2017  jdolecek update from HEAD
 1.13 24-Aug-2024  riastradh i386/stand/lib: Nix trailing whitespace and tidy comments a bit.

No functional change intended.

PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.12 17-Aug-2024  andvar Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().
This in turn was leading to erroneous caluclations and memory addresses.
This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.

needs-pullups to 9, 10.

PR install/49470
 1.11 02-Aug-2021  andvar branches: 1.11.8; 1.11.14;
fix various typos in comments and log messages.
 1.10 04-Dec-2016  maxv branches: 1.10.20;
KNF and explain a few things
 1.9 14-Oct-2008  ad branches: 1.9.38; 1.9.58; 1.9.62;
PR kern/39726 Soekris 5501-60 boot/bootxx 120 second delay

Try enabling A20 using an extended BIOS call before playing around with
the keyboard controller or system config port.
 1.8 11-Dec-2005  christos branches: 1.8.74; 1.8.78; 1.8.84;
merge ktrace-lwp.
 1.7 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.6 07-Nov-2003  dsl Change getextmem2 to return 'configured' values from cx/dx if ax/bx zero,
make absolutely high the top 16bits of returned values are zero.
Ralf's list says that some BIOS need %eax = 0x0000e820 in getmementry.
Add a few comments.
Might fix problems with memory size detection on some systems.
 1.5 14-Feb-2003  dsl branches: 1.5.2;
Use correct segment register in getmementry
 1.4 05-Feb-2003  dsl A buffer slipped though the net... Ensure offset < 64k.
(approved by christos)
 1.3 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.2 08-Mar-1999  drochner change the interface for getmementry() to hold the iterator in an
argument and to return success or error explicitely.
Now we can "error" and "end of list" cleanly; this should fix the
problem where the last list element was ignored.
 1.1 14-Aug-1997  drochner branches: 1.1.2;
New, optional, method to get size of extended memory.
It will be used for getextmem() if EXTENDED_MEMDETECT is defined.
Worked on all tested machines.
Thanks to all testers, especially Martin Husemann!
 1.1.2.2 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 14-Aug-1997  thorpej file biosmemx.S was added on branch marc-pcmcia on 1997-08-23 07:09:35 +0000
 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.8.84.1 19-Oct-2008  haad Sync with HEAD.
 1.8.78.1 04-May-2009  yamt sync with head.
 1.8.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.9.62.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.9.58.1 05-Dec-2016  skrll Sync with HEAD
 1.9.38.1 03-Dec-2017  jdolecek update from HEAD
 1.10.20.1 03-Sep-2024  martin Pull up following revision(s) (requested by andvar in ticket #1884):

sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.7
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.8
sys/arch/i386/stand/lib/getextmemx.c: revision 1.11
sys/arch/i386/stand/lib/getextmemx.c: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.13

Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().

This in turn was leading to erroneous caluclations and memory addresses.

This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.
PR install/49470

i386/stand/lib: Nix trailing whitespace and tidy comments a bit.
No functional change intended.
PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.11.14.1 02-Aug-2025  perseant Sync with HEAD
 1.11.8.1 03-Sep-2024  martin Pull up following revision(s) (requested by andvar in ticket #815):

sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.7
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.8
sys/arch/i386/stand/lib/getextmemx.c: revision 1.11
sys/arch/i386/stand/lib/getextmemx.c: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.13

Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().

This in turn was leading to erroneous caluclations and memory addresses.

This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.
PR install/49470

i386/stand/lib: Nix trailing whitespace and tidy comments a bit.
No functional change intended.
PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.6 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.5 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.78; 1.4.86;
merge ktrace-lwp.
 1.3 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.2 22-Mar-1997  thorpej branches: 1.2.58;
Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.58.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.58.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.58.1 03-Aug-2004  skrll Sync with HEAD
 1.4.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.78.1 04-May-2009  yamt sync with head.
 1.4.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.5 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.4 11-Dec-2005  christos branches: 1.4.92; 1.4.110;
merge ktrace-lwp.
 1.3 06-Jul-2005  junyoung Remove unused #define and trailing spaces.
 1.2 01-Feb-2003  dsl branches: 1.2.2; 1.2.18;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 13-Apr-1997  perry Provides "reboot" call, which just calles INT 19h to ask the bios to
reboot the machine.
This may be insufficient, but its enough for now.
 1.2.18.1 21-Jun-2006  yamt sync with head.
 1.2.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.110.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.4.92.1 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.3 20-Feb-2011  jakllsch Follow a minor detail in the spec a bit more closely.
 1.2 09-Feb-2011  jmcneill 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.1 16-Feb-2009  jmcneill branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; 1.1.12; 1.1.14;
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.1.14.2 05-Mar-2011  bouyer Sync with HEAD
 1.1.14.1 17-Feb-2011  bouyer Sync with HEAD
 1.1.12.1 06-Jun-2011  jruoho Sync with HEAD.
 1.1.10.1 05-Mar-2011  rmind sync with head
 1.1.6.4 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.1.6.3 01-Nov-2009  jym Sync with HEAD.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 16-Feb-2009  jym file biosvbe.S was added on branch jym-xensuspend on 2009-05-13 17:17:51 +0000
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 16-Feb-2009  yamt file biosvbe.S was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.1.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.1.2.1 16-Feb-2009  skrll file biosvbe.S was added on branch nick-hppapmap on 2009-03-03 18:29:00 +0000
 1.3 16-Apr-2003  dsl Add cvs version, delete unused definition
 1.2 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 23-Apr-2000  tsarna branches: 1.1.2; 1.1.8;
Addredd port-i386/9897, but differently. Since the effect of resetting
the video mode on machines with ancient or no video cards is not clear,
for safety's sake a I created a new biosboot variant, biosboot_resetvideo
that does the call.

Anyway, now I can boot my i-opener without hitting Tab. Thanks Andrew!
 1.1.8.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.8.1 23-Apr-2000  bouyer file biosvideomode.S was added on branch thorpej_scsipi on 2000-11-20 20:09:39 +0000
 1.1.2.2 23-Apr-2000  tsarna Addredd port-i386/9897, but differently. Since the effect of resetting
the video mode on machines with ancient or no video cards is not clear,
for safety's sake a I created a new biosboot variant, biosboot_resetvideo
that does the call.

Anyway, now I can boot my i-opener without hitting Tab. Thanks Andrew!
 1.1.2.1 23-Apr-2000  tsarna file biosvideomode.S was added on branch sommerfeld_i386mp_1 on 2000-04-23 19:57:15 +0000
 1.6 17-Jan-2010  drochner 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.5 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.4 11-Dec-2005  christos branches: 1.4.78; 1.4.92;
merge ktrace-lwp.
 1.3 15-Aug-2004  dsl Allow the com port base address to be specified by the user (via installboot)
rather than taking the value from the bios.
Should allow the system to use a serial console that is also a 'bios serial
console' and isn't in the bios serial port table.
Probably fixes (with a few other changes) PR port-i386/9236
 1.2 13-Mar-2004  dsl branches: 1.2.4;
Translate ascii keycode to help those with azerty keyboard type straight.
 1.1 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.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 13-Mar-2004  skrll file boot_params.S was added on branch ktrace-lwp on 2004-08-03 10:36:19 +0000
 1.4.92.1 24-Oct-2010  jym Sync with HEAD
 1.4.78.1 11-Mar-2010  yamt sync with head
 1.6 05-Jun-2016  maxv Don't use a magic value. Define a limit, and enforce it.
 1.5 14-Dec-2008  christos branches: 1.5.24; 1.5.42;
more KNF and ANSI from Anon-ymous
 1.4 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.78; 1.3.86;
merge ktrace-lwp.
 1.2 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.1 17-Sep-1997  drochner branches: 1.1.2; 1.1.54;
Definitions and helper functions to collect information in the boot
loader (still experimental).
 1.1.54.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.54.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.54.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 17-Sep-1997  thorpej file bootinfo.c was added on branch marc-pcmcia on 1997-09-22 06:31:23 +0000
 1.3.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.3.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.5.42.1 09-Jul-2016  skrll Sync with HEAD
 1.5.24.1 03-Dec-2017  jdolecek update from HEAD
 1.12 27-Jan-2018  pgoyette Recent changes have increased the number of "things" the bootloader
needs to deal with. Increase the table size so we don't overflow.
 1.11 05-Jun-2016  maxv branches: 1.11.10;
Don't use a magic value. Define a limit, and enforce it.
 1.10 18-Nov-2013  jakllsch branches: 1.10.6;
Bring arch/i386/stand bootinfo structure in line with the kernel's
fixed-layout understanding of it.
 1.9 25-Jan-2006  christos branches: 1.9.110; 1.9.120; 1.9.126;
free -> dealloc
unsigned -> size_t for alloc/dealloc
 1.8 11-Dec-2005  christos branches: 1.8.2;
merge ktrace-lwp.
 1.7 06-Jul-2005  junyoung branches: 1.7.2;
De-__P()
 1.6 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.5 10-Mar-1999  fvdl branches: 1.5.44;
Create a list of native disks too, and make it retrievable. It contains
all matching BIOS disks per entry, so that we have complete match info.
Enable the matching code.
 1.4 08-Mar-1999  drochner add a function to pass the "memory map" ie the outcome of INT15/0xe820,
to the kernel
 1.3 08-Mar-1999  fvdl * query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.2 20-Sep-1997  drochner branches: 1.2.2;
Use <machine/bootinfo.h> for definitions shared with the kernel.
 1.1 17-Sep-1997  drochner Definitions and helper functions to collect information in the boot
loader (still experimental).
 1.2.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.2.2.1 20-Sep-1997  thorpej file bootinfo.h was added on branch marc-pcmcia on 1997-09-22 06:31:24 +0000
 1.5.44.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.44.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.44.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.44.1 03-Aug-2004  skrll Sync with HEAD
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.8.2.1 01-Feb-2006  yamt sync with head.
 1.9.126.1 18-May-2014  rmind sync with head
 1.9.120.2 03-Dec-2017  jdolecek update from HEAD
 1.9.120.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.110.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.10.6.1 09-Jul-2016  skrll Sync with HEAD
 1.11.10.1 04-Feb-2018  martin Pull up following revision(s) (requested by pgoyette in ticket #521):
sys/arch/i386/stand/lib/bootinfo.h: revision 1.12
Recent changes have increased the number of "things" the bootloader
needs to deal with. Increase the table size so we don't overflow.
 1.24 01-Aug-2019  manu Fix buffer overflow in BIOS disk geometry collect for bootinfo

This spares a boot-time panic on iMac with fusion drive, which
feature both a hard drive and a solid-state drive.
 1.23 24-Jan-2017  nonaka branches: 1.23.6; 1.23.14; 1.23.18;
Initial commit of native amd64 EFI boot loader.
 1.22 16-May-2013  christos branches: 1.22.10; 1.22.14; 1.22.18;
Complete the dosparts -> mbrparts conversion. Only x86k new uses dosparts
because it also uses struct dos_partition.
 1.21 25-Dec-2010  jakllsch branches: 1.21.8; 1.21.18;
Use printf format macros for long longs.
 1.20 20-Nov-2009  dsl branches: 1.20.4;
EXT13_DEVPATH_SIGNATURE should be EXTINFO_DEVPATH_SIGNATURE
 1.19 11-Dec-2005  christos branches: 1.19.78; 1.19.92;
merge ktrace-lwp.
 1.18 29-Jun-2005  junyoung Massive renames for consistency:
biosdiskreset -> biosdisk_reset
biosread -> biosdisk_read
get_diskinfo -> biosdisk_getinfo
int13_extension -> biosdisk_int13ext
biosextread -> biosdisk_extread
int13_getextinfo -> biosdisk_getextinfo
struct biosdisk_ext13info -> biosdisk_extinfo
BIOSDISK_EXT13 -> BIOSDISK_INT13EXT
BIOSDISK_EXT13INFO_V{2,3} -> BIOSDISK_EXTINFO_V{2,3}
EXT13_* -> EXTINFO_*
 1.17 23-Jun-2005  junyoung Define BIOSDISK_DEFAULT_SECSIZE in biosdisk_ll.h and replace BIOSDISK_SECSIZE
with it.
 1.16 22-Jun-2005  junyoung Use get_harddrives().
 1.15 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.14 21-Jun-2005  junyoung Cosmetic changes.
 1.13 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.12 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.11 16-Apr-2003  dsl branches: 1.11.2;
Add code to parse V3.x bios disk information.
This should let NetBSD guarantee to tie together the bios disk numbers
with the physical hardware.
#defined out because I don't have a system with a bios that supports it.
 1.10 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.9 07-Jul-2001  perry branches: 1.9.4;
b*()->mem*()
 1.8 30-Mar-1999  drochner branches: 1.8.22;
adapt to set_geometry change: we don't have to correct the geometry
anymore
 1.7 28-Mar-1999  fvdl Only use the total number of sectors information field from the EDD if
the bit is set that declares the geometry valid. The spec itself says
that this field isn't covered by the "geometry valid" bit, but at
least one BIOS implements it that way.
 1.6 12-Mar-1999  fvdl Clean up the BIOS disk matching code a bit (better naming, one structure
and sysctl to export to userland). Also, only use total number of sectors
given in the extended parameters if the physical chs geometry is
marked invalid. Hopefully fixes a problem where BIOSs would not correctly
fill in this field.
 1.5 11-Mar-1999  fvdl Declare nhd to be unsigned char, as we're only copying one byte to it.
From Matthias Drochner.
 1.4 08-Mar-1999  fvdl * query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.3 28-Jan-1999  christos Minor changes to prototypes.
 1.2 27-Jan-1999  thorpej Use the MI <sys/disklabel_mbr.h>, not our own machine-dependent
definitions.
 1.1 17-Sep-1997  drochner branches: 1.1.2;
Function to collect geometry and partitioning information about the
BIOS-known disks in a "bootinfo" structure (still experimental).
 1.1.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 17-Sep-1997  thorpej file bootinfo_biosgeom.c was added on branch marc-pcmcia on 1997-09-22 06:31:25 +0000
 1.8.22.1 24-Aug-2001  nathanw Catch up with -current.
 1.9.4.2 07-Jul-2001  perry b*()->mem*()
 1.9.4.1 07-Jul-2001  perry file bootinfo_biosgeom.c was added on branch sommerfeld_i386mp_1 on 2001-07-07 22:57:58 +0000
 1.11.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.92.2 10-Jan-2011  jym Sync with HEAD
 1.19.92.1 24-Oct-2010  jym Sync with HEAD
 1.19.78.1 11-Mar-2010  yamt sync with head
 1.20.4.1 05-Mar-2011  rmind sync with head
 1.21.18.2 03-Dec-2017  jdolecek update from HEAD
 1.21.18.1 23-Jun-2013  tls resync from head
 1.21.8.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.22.18.1 21-Apr-2017  bouyer Sync with HEAD
 1.22.14.1 20-Mar-2017  pgoyette Sync with HEAD
 1.22.10.1 05-Feb-2017  skrll Sync with HEAD
 1.23.18.1 13-Aug-2019  martin Pull up following revision(s) (requested by manu in ticket #51):

sys/arch/i386/stand/lib/bootinfo_biosgeom.c: revision 1.24

Fix buffer overflow in BIOS disk geometry collect for bootinfo

This spares a boot-time panic on iMac with fusion drive, which
feature both a hard drive and a solid-state drive.
 1.23.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.23.6.1 13-Aug-2019  martin Pull up following revision(s) (requested by manu in ticket #1336):

sys/arch/i386/stand/lib/bootinfo_biosgeom.c: revision 1.24

Fix buffer overflow in BIOS disk geometry collect for bootinfo

This spares a boot-time panic on iMac with fusion drive, which
feature both a hard drive and a solid-state drive.
 1.8 24-Aug-2024  riastradh i386/stand/lib: Nix trailing whitespace and tidy comments a bit.

No functional change intended.

PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.7 17-Aug-2024  andvar Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().
This in turn was leading to erroneous caluclations and memory addresses.
This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.

needs-pullups to 9, 10.

PR install/49470
 1.6 13-Sep-2019  manu branches: 1.6.26; 1.6.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
 1.5 14-Dec-2008  christos branches: 1.5.58; 1.5.66; 1.5.70;
ANSI and KNF from Anon Ymous
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.78; 1.4.86;
merge ktrace-lwp.
 1.3 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.2 07-Jul-2001  perry branches: 1.2.4; 1.2.24;
b*()->mem*()
 1.1 08-Mar-1999  drochner branches: 1.1.22;
add a function to pass the "memory map" ie the outcome of INT15/0xe820,
to the kernel
 1.1.22.1 24-Aug-2001  nathanw Catch up with -current.
 1.2.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.24.1 03-Aug-2004  skrll Sync with HEAD
 1.2.4.2 07-Jul-2001  perry b*()->mem*()
 1.2.4.1 07-Jul-2001  perry file bootinfo_memmap.c was added on branch sommerfeld_i386mp_1 on 2001-07-07 22:57:58 +0000
 1.4.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.78.1 04-May-2009  yamt sync with head.
 1.4.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.5.70.2 03-Sep-2024  martin Pull up following revision(s) (requested by andvar in ticket #1884):

sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.7
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.8
sys/arch/i386/stand/lib/getextmemx.c: revision 1.11
sys/arch/i386/stand/lib/getextmemx.c: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.13

Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().

This in turn was leading to erroneous caluclations and memory addresses.

This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.
PR install/49470

i386/stand/lib: Nix trailing whitespace and tidy comments a bit.
No functional change intended.
PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.5.70.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.5.66.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.5.58.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.6.32.1 02-Aug-2025  perseant Sync with HEAD
 1.6.26.1 03-Sep-2024  martin Pull up following revision(s) (requested by andvar in ticket #815):

sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.7
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.8
sys/arch/i386/stand/lib/getextmemx.c: revision 1.11
sys/arch/i386/stand/lib/getextmemx.c: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.13

Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().

This in turn was leading to erroneous caluclations and memory addresses.

This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.
PR install/49470

i386/stand/lib: Nix trailing whitespace and tidy comments a bit.
No functional change intended.
PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.21 06-May-2025  pgoyette Allow the dev= command when processing /boot.cfg file. This
addresses kern/59207
 1.20 27-Nov-2024  martin Do not display the boot menu at all if (1) there is no choice and
(2) the timeout value is set to 0.
 1.19 09-Nov-2024  mlelstv Add 'fs' option for boot.cfg.
 1.18 08-Jun-2022  wiz branches: 1.18.10;
Remove now unused bootdefault() function.

Part of PR 56862.
 1.17 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.16 11-Jun-2016  dholland branches: 1.16.10; 1.16.16;
gets_s -> kgets.

The exact name isn't that important; but it is important not to use
"gets_s" and thereby allow anyone to falsely get the impression we're
implementing Annex K. We aren't.

ok core.
 1.15 05-Jun-2016  maxv Use gets_s instead of gets. The x86 bootloader prompt is easy to
overflow.
 1.14 10-Aug-2014  isaki branches: 1.14.4;
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084
 1.13 28-Jun-2014  rtr 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.12 06-Apr-2014  jakllsch Use __dead.
 1.11 28-Jul-2013  he branches: 1.11.2;
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.10 18-Aug-2011  christos branches: 1.10.2; 1.10.8; 1.10.12; 1.10.16;
PR/43563: Wolfgang Solfrank: boot.cfg doesn't support comments
Fix makes it support # comments and treat spaces and tabs the same way.
 1.9 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.8 14-Sep-2009  jmcneill branches: 1.8.4; 1.8.6;
Don't treat timeouts or the return key as an invalid choice; spotted by
Andreas Gustafsson.
 1.7 13-Sep-2009  jmcneill If the menuformat is not letter, do not allow letter keys to be aliases
for number keys. snj@ often overshoots the spacebar in a panic and
accidentally hits 'b' instead, which makes the loader boot item '2'.
Can't fix snj@, so fix the boot loader instead.
 1.6 10-Apr-2009  perry branches: 1.6.2;
Check the size of the offered boot.cfg file. Bail out if it is larger
than 32k.

A bootconf file is normally only a few hundred bytes long. If it is
much bigger than expected, we can't load it into an 8086 real mode
segment anyway.

Much more to the point, in the pxeboot case, someone may have
configured their dhcpd to return the filename for the kernel, not
realizing that the filename is now for boot.cfg which didn't used to
be the case. If we try to load the kernel here, thinking it is
boot.cfg by accident, the boot loader will die ignominiously and
without much of an error message, so we don't want to do that.

This needs to be pulled up to 5.0 if 5.0 has all this machinery
-- I'm not sure whether it does.
 1.5 18-Mar-2009  cegger bzero -> memset
 1.4 14-Dec-2008  christos branches: 1.4.2; 1.4.4; 1.4.6;
more KNF and ANSI from Anon-ymous
 1.3 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.2 13-Dec-2008  christos add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.1 25-Nov-2008  ad branches: 1.1.4;
Make pxeboot understand boot.cfg.
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 25-Nov-2008  haad file bootmenu.c was added on branch haad-dm on 2008-12-13 01:13:15 +0000
 1.4.6.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.4.6.2 01-Nov-2009  jym Sync with HEAD.
 1.4.6.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.4.4.3 28-Apr-2009  skrll Sync with HEAD.
 1.4.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.4.4.1 14-Dec-2008  skrll file bootmenu.c was added on branch nick-hppapmap on 2009-01-19 13:16:21 +0000
 1.4.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.4.2.1 14-Dec-2008  mjf file bootmenu.c was added on branch mjf-devfs2 on 2009-01-17 13:28:05 +0000
 1.6.2.3 16-Sep-2009  yamt sync with head
 1.6.2.2 04-May-2009  yamt sync with head.
 1.6.2.1 10-Apr-2009  yamt file bootmenu.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.8.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.8.4.1 31-May-2011  rmind sync with head
 1.10.16.2 18-May-2014  rmind sync with head
 1.10.16.1 28-Aug-2013  rmind sync with head
 1.10.12.2 03-Dec-2017  jdolecek update from HEAD
 1.10.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.8.1 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.10.2.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.11.2.1 10-Aug-2014  tls Rebase.
 1.14.4.1 09-Jul-2016  skrll Sync with HEAD
 1.16.16.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.16.10.1 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.18.10.1 02-Aug-2025  perseant Sync with HEAD
 1.7 08-Jun-2022  wiz Remove now unused bootdefault() function.

Part of PR 56862.
 1.6 02-Apr-2018  nonaka efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.5 10-Aug-2014  isaki branches: 1.5.20; 1.5.26;
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084
 1.4 28-Jun-2014  rtr 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.3 28-Jul-2013  he branches: 1.3.2;
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.2 13-Dec-2008  christos branches: 1.2.2; 1.2.4; 1.2.8; 1.2.20; 1.2.26; 1.2.30; 1.2.34;
add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.1 25-Nov-2008  ad branches: 1.1.4;
Make pxeboot understand boot.cfg.
 1.1.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.1.4.1 25-Nov-2008  haad file bootmenu.h was added on branch haad-dm on 2008-12-13 01:13:15 +0000
 1.2.34.1 28-Aug-2013  rmind sync with head
 1.2.30.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.26.1 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.2.20.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.2.8.2 04-May-2009  yamt sync with head.
 1.2.8.1 13-Dec-2008  yamt file bootmenu.h was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.2.4.2 19-Jan-2009  skrll Sync with HEAD.
 1.2.4.1 13-Dec-2008  skrll file bootmenu.h was added on branch nick-hppapmap on 2009-01-19 13:16:21 +0000
 1.2.2.2 17-Jan-2009  mjf Sync with HEAD.
 1.2.2.1 13-Dec-2008  mjf file bootmenu.h was added on branch mjf-devfs2 on 2009-01-17 13:28:05 +0000
 1.3.2.1 10-Aug-2014  tls Rebase.
 1.5.26.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.5.20.1 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.6 30-Aug-2013  jmcneill Add support for using a raw file-system image as memory disk root with
the x86 bootloader.
 1.5 28-Nov-2011  tls branches: 1.5.8; 1.5.12;

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.4 06-Feb-2011  jmcneill branches: 1.4.4;
add support for passing image files to the kernel with the 'splash' keyword:

vesa on;splash /netbsd.jpg;boot -z
 1.3 05-May-2008  jmcneill branches: 1.3.4; 1.3.6; 1.3.8; 1.3.20; 1.3.28; 1.3.34; 1.3.36;
Use 2-clause license.
 1.2 03-May-2008  ad Handle compressed modules.
 1.1 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.
 1.3.36.1 08-Feb-2011  bouyer Sync with HEAD
 1.3.34.1 06-Jun-2011  jruoho Sync with HEAD.
 1.3.28.1 05-Mar-2011  rmind sync with head
 1.3.20.1 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.3.8.2 02-Jun-2008  mjf Sync with HEAD.
 1.3.8.1 05-May-2008  mjf file bootmod.h was added on branch mjf-devfs2 on 2008-06-02 13:22:19 +0000
 1.3.6.2 18-May-2008  yamt sync with head.
 1.3.6.1 05-May-2008  yamt file bootmod.h was added on branch yamt-pf42 on 2008-05-18 12:32:17 +0000
 1.3.4.2 16-May-2008  yamt sync with head.
 1.3.4.1 05-May-2008  yamt file bootmod.h was added on branch yamt-nfs-mp on 2008-05-16 02:22:39 +0000
 1.4.4.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.4.4.1 17-Apr-2012  yamt sync with head
 1.5.12.1 18-May-2014  rmind sync with head
 1.5.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.4 16-Apr-2003  dsl remove unused defines
 1.3 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.2 27-Oct-1997  drochner Pass status byte to caller too.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.8;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.8.1 28-Oct-1997  mellon Pull rev. 1.2 up from trunk (drochner)
 1.12 05-Sep-2022  tsutsui G/C ISSET() macro copies. It has been defined in <sys/types.h> since 2006.
 1.11 05-Jan-2014  jakllsch don't shadow local variable
 1.10 14-Dec-2008  christos branches: 1.10.14; 1.10.24; 1.10.28;
more KNF and ANSI from Anon-ymous
 1.9 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.8 11-Nov-2005  dsl branches: 1.8.76; 1.8.80; 1.8.88;
Make a baud rate of zero cause the baud rate divisor be read and converted
to the current baud rate.
That way we use the same baud rate as the system BIOS (or whatever).
Rather useful for pxeboot.
 1.7 07-Aug-2003  agc branches: 1.7.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 27-Jul-2003  mrg #undef takes just a name, no params
 1.5 16-Apr-2003  dsl branches: 1.5.2;
Modify baud rate handling to make it easier to take it from a variable.
Default to 9600 if the requested baud rate is illegal.
 1.4 20-Jan-2000  drochner like com.c, raise DTR/RTS in console initialisation
 1.3 05-Jan-1998  perry branches: 1.3.8; 1.3.14;
RCSID Police.
 1.2 16-Oct-1997  mycroft dev/isa/comreg.h -> dev/ic/comreg.h
 1.1 17-Sep-1997  drochner branches: 1.1.2;
Console I/O functions for serial lines, accessing the hardware directly.
Allows higher baudrates than 9.6 and software flow control.
From Martin Husemann.
 1.1.2.3 16-Oct-1997  thorpej Sync w/ trunk.
 1.1.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 17-Sep-1997  thorpej file comio_direct.c was added on branch marc-pcmcia on 1997-09-22 06:31:26 +0000
 1.3.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.8.1 24-Jan-2000  he Pull up revision 1.4 (requested by drochner):
Raise the serial carrier lines in console initialization, similar
to sys/dev/ic/com.c revision 1.165.
 1.5.2.4 11-Dec-2005  christos Sync with head.
 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.7.16.1 21-Jun-2006  yamt sync with head.
 1.8.88.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.80.1 04-May-2009  yamt sync with head.
 1.8.76.1 17-Jan-2009  mjf Sync with HEAD.
 1.10.28.1 18-May-2014  rmind sync with head
 1.10.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.14.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.4 11-Nov-2005  dsl Make a baud rate of zero cause the baud rate divisor be read and converted
to the current baud rate.
That way we use the same baud rate as the system BIOS (or whatever).
Rather useful for pxeboot.
 1.3 16-Apr-2003  dsl branches: 1.3.2; 1.3.18;
Add baud_rate arg to cominit_d
 1.2 05-Jan-1998  perry RCSID Police.
 1.1 17-Sep-1997  drochner branches: 1.1.2;
Console I/O functions for serial lines, accessing the hardware directly.
Allows higher baudrates than 9.6 and software flow control.
From Martin Husemann.
 1.1.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 17-Sep-1997  thorpej file comio_direct.h was added on branch marc-pcmcia on 1997-09-22 06:31:28 +0000
 1.3.18.1 21-Jun-2006  yamt sync with head.
 1.3.2.1 11-Dec-2005  christos Sync with head.
 1.7 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.6 21-May-2008  ad branches: 1.6.12; 1.6.30;
- Stop the twiddler going awry.
- Clear screen if on a glass tty (!).
 1.5 11-Dec-2005  christos branches: 1.5.74; 1.5.76; 1.5.78; 1.5.80;
merge ktrace-lwp.
 1.4 06-Jul-2005  junyoung Remove unused #define.
 1.3 27-Jan-2005  mycroft branches: 1.3.6;
Make awaitkey() poll once even if the timeout is 0. This also fixes a problem
where a keypress within the last polling interval would not be noticed.
Add a new function, conisshift(), which is used to detect whether a shift key
is pressed. Use this via awaitkey() to allow interrupting the boot by holding
down shift (similar to LILO).

This allows setting the timeout to 0 and still being able to use the boot
program.
 1.2 01-Feb-2003  dsl branches: 1.2.2; 1.2.10; 1.2.12;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.12.1 12-Feb-2005  yamt sync with head.
 1.2.10.1 29-Apr-2005  kent sync with -current
 1.2.2.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.1 04-Feb-2005  skrll Sync with HEAD.
 1.3.6.1 21-Jun-2006  yamt sync with head.
 1.5.80.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.5.76.1 04-Jun-2008  yamt sync with head
 1.5.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.30.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.6.12.1 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.4 08-Jun-2011  joerg G/C wbinvd
 1.3 22-Oct-2008  ad branches: 1.3.8; 1.3.16; 1.3.26;
+wbinvd
 1.2 28-Apr-2008  martin branches: 1.2.6;
Remove clause 3 and 4 from TNF licenses
 1.1 26-Sep-2007  ad branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; 1.1.14; 1.1.28; 1.1.30; 1.1.32;
- Make it compile again.
- Don't use (very dodgy) inline assembly.
 1.1.32.2 04-May-2009  yamt sync with head.
 1.1.32.1 16-May-2008  yamt sync with head.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.1.28.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.14.2 06-Nov-2007  matt sync with HEAD
 1.1.14.1 26-Sep-2007  matt file cpufunc.S was added on branch matt-armv6 on 2007-11-06 23:17:52 +0000
 1.1.10.2 27-Oct-2007  yamt sync with head.
 1.1.10.1 26-Sep-2007  yamt file cpufunc.S was added on branch yamt-lazymbuf on 2007-10-27 11:26:52 +0000
 1.1.6.2 09-Oct-2007  ad Sync with head.
 1.1.6.1 26-Sep-2007  ad file cpufunc.S was added on branch vmlocking on 2007-10-09 13:38:01 +0000
 1.1.4.2 06-Oct-2007  yamt sync with head.
 1.1.4.1 26-Sep-2007  yamt file cpufunc.S was added on branch yamt-x86pmap on 2007-10-06 15:34:58 +0000
 1.1.2.2 02-Oct-2007  joerg Sync with HEAD.
 1.1.2.1 26-Sep-2007  joerg file cpufunc.S was added on branch jmcneill-pm on 2007-10-02 18:27:29 +0000
 1.2.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.26.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.3.16.1 12-Jun-2011  rmind sync with head
 1.3.8.1 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.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 26-Sep-2007  ad branches: 1.1.2; 1.1.4; 1.1.6; 1.1.10; 1.1.14; 1.1.28; 1.1.30; 1.1.32;
- Make it compile again.
- Don't use (very dodgy) inline assembly.
 1.1.32.1 16-May-2008  yamt sync with head.
 1.1.30.1 18-May-2008  yamt sync with head.
 1.1.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.14.2 06-Nov-2007  matt sync with HEAD
 1.1.14.1 26-Sep-2007  matt file cpufunc.h was added on branch matt-armv6 on 2007-11-06 23:17:52 +0000
 1.1.10.2 27-Oct-2007  yamt sync with head.
 1.1.10.1 26-Sep-2007  yamt file cpufunc.h was added on branch yamt-lazymbuf on 2007-10-27 11:26:52 +0000
 1.1.6.2 09-Oct-2007  ad Sync with head.
 1.1.6.1 26-Sep-2007  ad file cpufunc.h was added on branch vmlocking on 2007-10-09 13:38:01 +0000
 1.1.4.2 06-Oct-2007  yamt sync with head.
 1.1.4.1 26-Sep-2007  yamt file cpufunc.h was added on branch yamt-x86pmap on 2007-10-06 15:34:58 +0000
 1.1.2.2 02-Oct-2007  joerg Sync with HEAD.
 1.1.2.1 26-Sep-2007  joerg file cpufunc.h was added on branch jmcneill-pm on 2007-10-02 18:27:29 +0000
 1.7 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.6 11-Dec-2005  christos branches: 1.6.122; 1.6.142; 1.6.146; 1.6.150;
merge ktrace-lwp.
 1.5 28-Jun-2005  junyoung #include <lib/libsa/stand.h> rather than <stand.h> or "stand.h"
 1.4 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.3 02-Apr-2003  fvdl branches: 1.3.2;
Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.2 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.6.150.1 21-Apr-2017  bouyer Sync with HEAD
 1.6.146.1 20-Mar-2017  pgoyette Sync with HEAD
 1.6.142.1 05-Feb-2017  skrll Sync with HEAD
 1.6.122.1 03-Dec-2017  jdolecek update from HEAD
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.2 01-Feb-2003  dsl branches: 1.2.2;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.6 21-Nov-2009  dsl Preserve %ds over bios calls.
Not strickly necessary because real_to_prot doesn't normally rely on in.
However it caused much confusion while debugging, and does no harm.
 1.5 01-Feb-2003  dsl branches: 1.5.108; 1.5.122;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.4 22-Jan-1999  thorpej Fixup some usage of _C_LABEL().
 1.3 18-Aug-1997  hannken Change "it's" to "it is" inside assembler comments to
stop "unterminated character constant" messages from `mkdep'.
 1.2 13-Jun-1997  drochner branches: 1.2.4;
Fix operand size confusion in 16-bit code.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.122.1 24-Oct-2010  jym Sync with HEAD
 1.5.108.1 11-Mar-2010  yamt sync with head
 1.20 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.19 13-Dec-2015  christos one default is better than two
 1.18 13-Dec-2015  christos better than returning random errors.
 1.17 11-Dec-2015  mlelstv PR 50516 bad switch statement.
Adding some comments.
 1.16 20-Oct-2013  christos branches: 1.16.6;
remove unused variable
 1.15 16-Jun-2011  joerg branches: 1.15.2; 1.15.12; 1.15.16;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.14 14-Dec-2008  christos branches: 1.14.2; 1.14.12;
ANSI and KNF from Anon Ymous
 1.13 10-May-2006  skrll branches: 1.13.62; 1.13.66; 1.13.74;
Fix a bunch of cast lvalues.
 1.12 25-Jan-2006  christos branches: 1.12.2; 1.12.4; 1.12.6; 1.12.8; 1.12.10;
free -> dealloc
unsigned -> size_t for alloc/dealloc
 1.11 11-Dec-2005  christos branches: 1.11.2;
merge ktrace-lwp.
 1.10 24-Mar-2004  drochner branches: 1.10.16;
remove license clauses 3 and 4 from my cpoyright notices
 1.9 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.8 18-Aug-2003  dsl Further fallout from making 'path' arg to 'ufs_open' 'constchar *'.
There may be fallout in other builds....
 1.7 01-Feb-2003  dsl branches: 1.7.2;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.6 07-Jul-2001  perry branches: 1.6.4;
b*()->mem*()
 1.5 14-Apr-1999  drochner branches: 1.5.16;
add prototypes, slight formatting changes
 1.4 17-Sep-1997  drochner branches: 1.4.12;
Convert DOS error numbers into UNIX errno values.
 1.3 13-Jun-1997  drochner branches: 1.3.4;
Reformat comments. (messed up by "indent")
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.12.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.16.1 24-Aug-2001  nathanw Catch up with -current.
 1.6.4.2 07-Jul-2001  perry b*()->mem*()
 1.6.4.1 07-Jul-2001  perry file dosfile.c was added on branch sommerfeld_i386mp_1 on 2001-07-07 22:57:58 +0000
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.10.16.1 21-Jun-2006  yamt sync with head.
 1.11.2.1 01-Feb-2006  yamt sync with head.
 1.12.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.12.8.1 11-May-2006  elad sync with head
 1.12.6.1 24-May-2006  yamt sync with head.
 1.12.4.1 01-Jun-2006  kardel Sync with head.
 1.12.2.1 09-Sep-2006  rpaulo sync with head
 1.13.74.1 19-Jan-2009  skrll Sync with HEAD.
 1.13.66.1 04-May-2009  yamt sync with head.
 1.13.62.1 17-Jan-2009  mjf Sync with HEAD.
 1.14.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.14.2.1 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.15.16.1 18-May-2014  rmind sync with head
 1.15.12.2 03-Dec-2017  jdolecek update from HEAD
 1.15.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.15.2.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.16.6.1 27-Dec-2015  skrll Sync with HEAD (as of 26th Dec)
 1.5 29-Jun-2024  rin i386: stand: Migrate DOS support routines from `lib` to `dosboot`
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.2 18-Aug-2003  dsl Further fallout from making 'path' arg to 'ufs_open' 'constchar *'.
There may be fallout in other builds....
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.58;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.58.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.1.1.58.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.1.1.58.1 03-Aug-2004  skrll Sync with HEAD
 1.4 19-Nov-2009  dsl Shorten slightly
 1.3 11-Feb-2009  jnemeth PR/40608 - Gao Ya'nan -- typo in comment
 1.2 28-Apr-2008  martin branches: 1.2.8; 1.2.14;
Remove clause 3 and 4 from TNF licenses
 1.1 16-Apr-2003  dsl branches: 1.1.104; 1.1.106; 1.1.108;
additional support routines for boot code
 1.1.108.3 11-Mar-2010  yamt sync with head
 1.1.108.2 04-May-2009  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.3 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.2.14.2 01-Nov-2009  jym Sync with HEAD.
 1.2.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.8.1 03-Mar-2009  skrll Sync with HEAD.
 1.81 11-Sep-2024  andvar dosboot(8): remove XMS-specific code. The boot process has been broken for over
a decade, and its relevance has diminished due to the availability of other boot
options.

PR port-i386/58624
 1.80 06-Jan-2024  mlelstv branches: 1.80.2;
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.79 20-Apr-2023  manu Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.
 1.78 21-Sep-2022  riastradh branches: 1.78.4;
i386/stand: Handle 9.99.100 by taking four, not two, digits.

We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00
in almos two decades so we're apparently reclaiming it as MMmmpppp00.
 1.77 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.76 04-Apr-2020  christos branches: 1.76.8; 1.76.10;
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.75 07-Dec-2019  christos loadfile sets errno, return the correct error, not EIO.
 1.74 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.73 26-Jul-2019  nonaka branches: 1.73.2;
Pre-allocate memory for the kernel space at startup.
 1.72 24-Jun-2019  pgoyette Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem. We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change. I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.
 1.71 24-Jun-2019  pgoyette Remove double-include for reboot.h
 1.70 20-Jun-2019  maxv Add KASLR support in UEFI.
 1.69 07-Oct-2017  maxv branches: 1.69.4;
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.68 24-Mar-2017  nonaka branches: 1.68.6;
efiboot: fix calculation of the kernel size when loading modules.
 1.67 12-Mar-2017  nonaka efiboot: Kernel modules are loaded in pre-allocated memory.
 1.66 23-Feb-2017  nonaka no need COUNT_KERNEL hack.
 1.65 11-Feb-2017  nonaka PR/51953: fix unable to boot on some AMD machine.

Delayed the timing to copy the kernel to actual address.
copy routine from common/lib/libc/arch/x86_64/string/bcopy.S
 1.64 11-Feb-2017  nonaka efiboot: Copy bootinfo to safe arena.
 1.63 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.62 04-Dec-2016  maxv branches: 1.62.2;
KNF and explain a few things
 1.61 05-Jun-2016  maxv branches: 1.61.2;
Don't use a magic value. Define a limit, and enforce it.
 1.60 05-Jun-2016  maxv The bootinfo is refreshed each time the bootloader tries to execute a
kernel, so there's no point in using this global variable. Because of
this variable, only one "boot" command can be issued in the prompt, and
you have to reboot the machine if you mistyped the kernel name.
 1.59 06-Apr-2014  jakllsch branches: 1.59.4;
Misc WARNS=4 fixes.
 1.58 10-Jan-2014  jakllsch branches: 1.58.2;
fix style and whitespace nits
 1.57 05-Jan-2014  jakllsch Make name argument to module_add_common const; use this to allow the libsa
fsmod string to soon become const.
 1.56 30-Dec-2013  jakllsch Zero out on-stack 'marks' array before first use.
This is needed so the MARK_DATA index is properly filled in.
 1.55 27-Nov-2013  jakllsch Use the size of what's at the bootinfo_userconf pointer, not the size
of the pointer itself.
 1.54 24-Nov-2013  jakllsch The x86 kernel entry point stack arguments are always 32-bit, even on amd64.
 1.53 24-Nov-2013  jakllsch use <i386/multiboot.h> instead of <machine/multiboot.h> so this can be
compiled for amd64
 1.52 24-Nov-2013  jakllsch cast from 32-bit integer to void * though uintptr_t to avoid warnings
when compiling for x86_64.
 1.51 30-Aug-2013  jmcneill Add support for using a raw file-system image as memory disk root with
the x86 bootloader.
 1.50 21-May-2012  dsl branches: 1.50.2; 1.50.4;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.49 28-Nov-2011  tls branches: 1.49.2; 1.49.4;

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.48 17-Jul-2011  joerg branches: 1.48.2;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.47 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.46 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.45 30-Oct-2010  jnemeth branches: 1.45.2; 1.45.4;
Reduce licence with copyright Perry E. Metzger and Matthias Drochner
to two clauses.

On Thu, 21 Oct 2010 22:42:00 -0700 jnemeth@XXX
(John Nemeth) wrote:
> The file src/sys/arch/i386/stand/lib/exec.c has a licence
> section that starts off saying copyright by each of you. That is
> then followed by a standard four claus UCB licence. Would it be
> okay to reduce that to the two claus licence that is now standard
> for NetBSD?

I have no particular objections.

--
Perry E. Metzger perry@XXX

jnemeth@XXX said:
> Would it be okay to reduce that to the two claus licence

Yes of course, this is OK.

best regards
Matthias
 1.44 25-Aug-2010  christos use LOAD_BACKWARDS instead of LOAD_NOTE for floppy book.
 1.43 25-Jun-2010  tsutsui Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
and use it for large delays (in seconds) instead of delay() that uses
INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
precise delays on emulators.
Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
in qemu 0.12).

No particular comments on the PR and port-i386@.
 1.42 14-Sep-2009  jmcneill branches: 1.42.2; 1.42.4;
Don't commit the selected VBE mode until the loader is past the point of
no return; need to stick in text mode as long as possible since libsa does
not include a rasops library. While here, add the 'vesa' command to pxeboot
to mirror biosboot behaviour.
 1.41 13-Sep-2009  jmcneill kmod improvements
- unless otherwise specified, modules are now loaded from the same device
as the kernel ('load miniroot' now implies 'load tftp:miniroot' if the
boot command is 'boot tftp:netbsd')
- the module name -> path expansion now works when a device prefix: is
specified ('load tftp:miniroot' now works)
- if the module name has been expanded to a path, print that path when
loading the module rather than the symbolic name
- only print an error in module_open if both the expanded path and the
raw path fail to open
 1.40 21-Mar-2009  ad Fix 'boot -z' bogons.
 1.39 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.38 24-Jan-2009  rmind branches: 1.38.2;
Revert path of modules back to "/stand".
 1.37 24-Jan-2009  rmind Change path to kernel modules from "/stand" to "/kernel".
Needs to go in before 5.0. Proposed on <tech-kern>.
 1.36 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.35 25-Nov-2008  ad Make pxeboot understand boot.cfg.
 1.34 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.33 11-Oct-2008  joerg branches: 1.33.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.32 08-Oct-2008  joerg Move functionality for preparing the kernel (including XMS support) into
a new function common_load_kernel.
 1.31 08-Oct-2008  joerg Move initialisation of boot_argv after the full loading of the kernel,
directly before loading modules.
 1.30 08-Oct-2008  joerg Setup module_base in module_init().
 1.29 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.28 25-May-2008  chris branches: 1.28.4;
Fix pxeboot's load tftp:miniroot.i386.kmod to work again.

We now wrapper the open call for a module with module_open. It first
attempts to open the module_path munged path, if this fails it then tries
to open the original path.

This allows tftp files to be located correctly.
 1.27 20-May-2008  ad Take $MACHINE into account when looking for modules.
 1.26 20-May-2008  ad PR kern/38694 module dependencies do not work as expected

If a given module name/path does not start with '/', assume it's a module
name and choose a default path based on the kernel version.
 1.25 04-May-2008  martin branches: 1.25.2;
Remove my personal license, the TNF one is good enough for me.
 1.24 03-May-2008  ad Handle compressed modules.
 1.23 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.22 11-Dec-2005  christos branches: 1.22.74; 1.22.76; 1.22.78;
merge ktrace-lwp.
 1.21 21-Jun-2005  junyoung ANSI, KNF, trailing spaces, and etc.
 1.20 10-Nov-2003  wiz Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.18 27-Feb-2003  hannken branches: 1.18.2;
Change "i386_trunc_page" to "x86_trunc_page".
 1.17 01-Jun-2001  jdolecek branches: 1.17.2;
g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.16 19-May-2001  jdolecek Add some IBM PS/2 support bits:
* recognize PS/2 L40 via biosmca() and biosmca_ps2model in gatea20.c, instead
of being a compile time option
* if the system is PS/2 with MCA bus, map DTYPE_ESDI disks to ed(4) for
COMPAT_OLDBOOT

The new code is conditional on SUPPORT_PS2 define, which is on by default
for biosboot-based bootblocks.
 1.15 22-Feb-2000  dbj branches: 1.15.8;
use bios' idea of the basemem size and create the kernel stack
at the top of it instead of hard coding 0x90000
 1.14 07-Sep-1999  ross branches: 1.14.2;
spelling
 1.13 15-May-1999  drochner don't printf(NULL), not even in the DEBUG case
(It doesn't hurt the bootloader, but the junk output hangs my serial
console.)
 1.12 28-Apr-1999  christos use new loadfile
 1.11 14-Apr-1999  drochner add prototype
 1.10 08-Apr-1999  drochner Call bi_getbiosgeom() after loadfile() returned successfully. This avoids
a memory leak if loadfile() gets an error.
 1.9 08-Mar-1999  fvdl branches: 1.9.2;
* query BIOS geometry information, possibly using the int 13 extensions.
* pass them on to the kernel
* print a message if the 2nd stage bootloader returns (i.e. fails)
instead of just hanging.
 1.8 29-Jan-1999  christos Merge XMS changes from exec_fromdos.c
 1.7 28-Jan-1999  christos Add support for selectively loading sections, and make this compile in
userland with -DINSTALLBOOT
 1.6 28-Jan-1999  christos Remove a.out loading code and use loadfile.c for everything.
Populate the btinfo_symtab structure.
 1.5 28-Sep-1997  drochner Pass new boot information per default.
 1.4 17-Sep-1997  drochner Use the "bootinfo" defined structures to collect information about boot
device/file and console setting, remove the old, limited, "xbootinfo".
Fix a printf() format warning in debug code.
 1.3 22-Mar-1997  thorpej branches: 1.3.4;
Mimmick the old boot block's hdN -> Xd0 (where X is specified by the
disklabel type) unit conversion behavior.
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.4.2 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.2.1 09-Apr-1999  drochner branches: 1.9.2.1.2;
pull up rev. 1.10 - avoid memory leak if loadfile() fails
 1.9.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.15.8.1 21-Jun-2001  nathanw Catch up to -current.
 1.17.2.2 01-Jun-2001  jdolecek g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.17.2.1 01-Jun-2001  jdolecek file exec.c was added on branch sommerfeld_i386mp_1 on 2001-06-01 23:26:32 +0000
 1.18.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.18.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.18.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.18.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.78.5 09-Oct-2010  yamt sync with head
 1.22.78.4 11-Aug-2010  yamt sync with head.
 1.22.78.3 16-Sep-2009  yamt sync with head
 1.22.78.2 04-May-2009  yamt sync with head.
 1.22.78.1 16-May-2008  yamt sync with head.
 1.22.76.2 04-Jun-2008  yamt sync with head
 1.22.76.1 18-May-2008  yamt sync with head.
 1.22.74.3 17-Jan-2009  mjf Sync with HEAD.
 1.22.74.2 28-Sep-2008  mjf Sync with HEAD.
 1.22.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.25.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.25.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.28.4.1 19-Oct-2008  haad Sync with HEAD.
 1.33.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.33.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.33.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.38.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.38.2.4 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.38.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.38.2.2 01-Nov-2009  jym Sync with HEAD.
 1.38.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 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 03-Jul-2010  rmind sync with head
 1.42.2.3 06-Nov-2010  uebayasi 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.45.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.45.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.48.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.48.2.2 23-May-2012  yamt sync with head.
 1.48.2.1 17-Apr-2012  yamt sync with head
 1.49.4.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.49.2.1 02-Jun-2012  mrg sync to latest -current.
 1.50.4.1 18-May-2014  rmind sync with head
 1.50.2.2 03-Dec-2017  jdolecek update from HEAD
 1.50.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.2.1 10-Aug-2014  tls Rebase.
 1.59.4.4 28-Aug-2017  skrll Sync with HEAD
 1.59.4.3 05-Feb-2017  skrll Sync with HEAD
 1.59.4.2 05-Dec-2016  skrll Sync with HEAD
 1.59.4.1 09-Jul-2016  skrll Sync with HEAD
 1.61.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.61.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.61.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.62.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.68.6.2 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.68.6.1 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.69.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.69.4.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.73.2.2 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #1632):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28 (via patch)
share/man/man8/man8.x86/boot.8: revision 1.29 (via patch)
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.

Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.

Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.73.2.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.76.10.1 31-May-2021  cjep sync with head
 1.76.8.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.78.4.2 14-Jan-2024  martin Pull up following revision(s) (requested by mlelstv in ticket #548):

sys/arch/i386/stand/efiboot/efidisk.h: revision 1.4
sys/arch/i386/stand/lib/exec.c: revision 1.80
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.11
sys/arch/i386/stand/lib/biosdisk.c: revision 1.61

In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
hard drives (with geom) and CD-ROM (without).
 1.78.4.1 13-May-2023  martin Pull up following revision(s) (requested by manu in ticket #159):

share/man/man8/man8.x86/boot.8: revision 1.27
sys/arch/i386/stand/efiboot/version: revision 1.3
share/man/man8/man8.x86/boot.8: revision 1.28
share/man/man8/man8.x86/boot.8: revision 1.29
sys/arch/i386/stand/lib/exec.c: revision 1.79
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.13
sys/arch/i386/stand/efiboot/bootx64/efibootx64.c: revision 1.6
sys/arch/i386/stand/efiboot/bootia32/efibootia32.c: revision 1.6
sys/arch/i386/stand/efiboot/boot.c: revision 1.22
sys/arch/amd64/amd64/locore.S: revision 1.219
sys/arch/i386/stand/efiboot/bootia32/startprog32.S: revision 1.3
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.12
sys/arch/amd64/conf/files.amd64: revision 1.121
sys/arch/amd64/conf/std.amd64: revision 1.13
share/man/man8/man8.x86/pxeboot.8: revision 1.6
sys/arch/i386/stand/efiboot/bootx64/startprog64.S: revision 1.4
sys/arch/amd64/amd64/locore.S: revision 1.220
share/man/man8/man8.x86/dosboot.8: revision 1.4
share/man/man4/options.4: revision 1.524

Add reloc keyworkd to let EFI bootstrap load amd64 kernel at any address

EFI bootstrap assumes it can copy the amd64 kernel to its ELF load
address (that is KERNTEXTOFF - KERNBASE = 0x200000), but it can
clash with previous UEFI memory allocation, as described here:
http://mail-index.netbsd.org/tech-kern/2023/04/07/msg028833.html

This change adds a reloc keyword for controling where the EFI
boostrap will copy the kernel image. Possible values are:
default - the default and prior behavior, copy at 0x200000.
none - do not copy and use the kernel image where it was loaded.
address - specify an explicit address where to copy the kernel.

This comes with an amd64 kernel patch that makes it self-relocatable.
It first discover where it was loaded in memory, and if this is
different than the expected 0x200000, hhe the kernel relocates
itself and start over at the right address.


Merge x86 boot options in x86/boot(8) and add undocumented UEFI options

We were supposed to keep the option list in x86/boot(8), x86/dosoot(8)
and x86/pxeboot(8) in sync, but it did not happen, hence it may work
better with all the options in x86/boot(8). Also add the undocumented
UEFI boot options.


Add a SELFRELOC kernel option for the sake of documentation clarity.
Instead of telling that x86/boot(8) reloc command needs a kernel able
to self relocate, we can tell it needs a kernel built with the
SELFRELOC option. This keeps the reader from wondering what could
make a kernel able to self relocate.

Remove XXX todo marker left by mistake

Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH
 1.80.2.1 02-Aug-2025  perseant Sync with HEAD
 1.7 29-Jan-1999  christos exec.c has all the info now.
 1.6 03-Nov-1997  drochner When using XMS, use the XMS size returned by the BIOS only if the other
methods to detect extended memory didn't work well.
(this XMS size is always too small, typically by 68k)
 1.5 28-Sep-1997  drochner Pass new boot information per default.
 1.4 17-Sep-1997  drochner Use the "bootinfo" defined structures to collect information about boot
device/file and console setting, remove the old, limited, "xbootinfo".
Fix a printf() format warning in debug code.
 1.3 14-Aug-1997  drochner Use traditional memory detect function (int15/88) as indication for
a XMS driver.
From Martin Husemann.
 1.2 05-Aug-1997  drochner #if -> #ifdef, fixes XMS support
from Martin Husemann, pr port-i386/3941
 1.1 13-Jun-1997  drochner branches: 1.1.4;
Allow to boot from DOS if a XMS manager is installed.
XMS is recognized and used as temporary buffer for the kernel image.
The processor must still be in real mode at program start, so EMM386
or QEMM are not allowed. W*95 is OK.
Written by Martin Husemann (pr port-i386/3336).
Completely separated from other bootloaders for sanity.
 1.1.4.3 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.4.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3 18-Oct-2019  manu branches: 1.3.8;
Add kernel symbols for multiboot1
 1.2 18-Oct-2019  manu Fix multiboot1 header detection

Specification states it must be must be longword (32-bit) aligned
 1.1 13-Sep-2019  manu branches: 1.1.2; 1.1.4;
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.1.4.2 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.1.4.1 13-Sep-2019  martin file exec_multiboot1.c was added on branch netbsd-8 on 2019-09-18 17:30:05 +0000
 1.1.2.2 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.1.2.1 13-Sep-2019  martin file exec_multiboot1.c was added on branch netbsd-9 on 2019-09-17 19:32:00 +0000
 1.3.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.8.1 18-Oct-2019  martin file exec_multiboot1.c was added on branch phil-wifi on 2020-04-13 08:03:54 +0000
 1.8 28-Jun-2025  joe fix missing break in multiboot header tag
 1.7 23-Jun-2025  joe clear whitespace
 1.6 04-Aug-2023  rin branches: 1.6.6;
x86/multiboot2: Fix short read for 64-bit ELF headers

XXX document this
At the moment, this cannot affect NetBSD/amd64, as we have not
supported multiboot for kernel side.

Found by GCC12.
 1.5 21-Jul-2021  jmcneill Separate MI smbios interface from MD specific code.
 1.4 14-May-2020  msaitoh branches: 1.4.6;
Remove extra semicolon.
 1.3 18-Oct-2019  manu branches: 1.3.8;
Fix kernel symbols for multiboot2

Previous version just provided the ELF section table, which is correct
as far as the multiboot 2 specification is concerned.

But in order to retreive kernel symboles, the NetBSD kernelneeds symbol
table and string table sections to be loaded in memory, and have an
address set in the section table.

Requires change: Add kernel symbols for multiboot1
src/sys/arch/i386/stand/lib/exec_multiboot1.c 1.2 - 1.3
src/sys/arch/i386/stand/lib/libi386.h 1.45 - 1.46
 1.2 15-Sep-2019  manu branches: 1.2.2; 1.2.4;
Remove debug define.

It remained there unseen because it was misspelled!
 1.1 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.2.4.2 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.2.4.1 15-Sep-2019  martin file exec_multiboot2.c was added on branch netbsd-8 on 2019-09-18 17:30:05 +0000
 1.2.2.2 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.2.2.1 15-Sep-2019  martin file exec_multiboot2.c was added on branch netbsd-9 on 2019-09-17 19:32:00 +0000
 1.3.8.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.8.1 18-Oct-2019  martin file exec_multiboot2.c was added on branch phil-wifi on 2020-04-13 08:03:54 +0000
 1.4.6.1 01-Aug-2021  thorpej Sync with HEAD.
 1.6.6.1 02-Aug-2025  perseant Sync with HEAD
 1.12 23-Aug-2009  jmcneill PR# kern/39726: Soekris 5501-60 boot/bootxx 120 second delay
PR# port-i386/41162: A20 gate legacy hook cause long pxeboot delay on Soekris net5501

Remove calls to delay() before polling KBD registers in gateA20().
 1.11 14-Oct-2008  ad branches: 1.11.4; 1.11.8;
PR kern/39726 Soekris 5501-60 boot/bootxx 120 second delay

Try enabling A20 using an extended BIOS call before playing around with
the keyboard controller or system config port.
 1.10 17-Oct-2007  garbled branches: 1.10.16; 1.10.20; 1.10.26;
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.9 26-Sep-2007  ad - Make it compile again.
- Don't use (very dodgy) inline assembly.
 1.8 11-Dec-2005  christos branches: 1.8.30; 1.8.38; 1.8.48; 1.8.50; 1.8.52;
merge ktrace-lwp.
 1.7 29-Jun-2005  junyoung branches: 1.7.2;
KNF.
 1.6 24-Jun-2005  manu Support PC engines WRAP (From OpenBSD)
 1.5 12-Aug-2002  thorpej branches: 1.5.2; 1.5.8; 1.5.22;
There are other systems besides the PS/2 L40 that enable A20
via the Configuration Port, so restructure the code a little
to allow for them, and list at least one other system that does
(anything based on AMD Elan SC520).

XXX We don't actually check for Elan SC520 yet.
 1.4 19-May-2001  jdolecek branches: 1.4.4; 1.4.16; 1.4.18;
Add some IBM PS/2 support bits:
* recognize PS/2 L40 via biosmca() and biosmca_ps2model in gatea20.c, instead
of being a compile time option
* if the system is PS/2 with MCA bus, map DTYPE_ESDI disks to ed(4) for
COMPAT_OLDBOOT

The new code is conditional on SUPPORT_PS2 define, which is on by default
for biosboot-based bootblocks.
 1.3 11-May-2000  jdolecek branches: 1.3.8;
minor adjustment for compiling with IBM_L40
 1.2 29-Oct-1997  fvdl branches: 1.2.14;
Disable interrupts when frobbing the keyboard controller for A20, as
it may generate a reset on some (older) controllers. Introduce a delay
to make some kbd controllers happier.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.8.2 13-Aug-2002  nathanw Catch up to -current.
 1.3.8.1 21-Jun-2001  nathanw Catch up to -current.
 1.4.18.1 18-Nov-2002  he Pull up revision 1.5 (requested by thorpej in ticket #665):
There are other systems besides the PS/2 L40 that enable
A20 via the Configuration Port, so restructure the code a
little to allow for them, and list at least one other system
that does (anything based on the AMD Elan SC520).
 1.4.16.1 31-Aug-2002  gehenna catch up with -current.
 1.4.4.1 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.5.22.1 02-Jul-2005  tron Pull up revision 1.6 (requested by manu in ticket #504):
Support PC engines WRAP (From OpenBSD)
 1.5.8.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.2 12-Aug-2002  thorpej There are other systems besides the PS/2 L40 that enable A20
via the Configuration Port, so restructure the code a little
to allow for them, and list at least one other system that does
(anything based on AMD Elan SC520).

XXX We don't actually check for Elan SC520 yet.
 1.5.2.1 12-Aug-2002  thorpej file gatea20.c was added on branch sommerfeld_i386mp_1 on 2002-08-12 14:27:35 +0000
 1.7.2.1 27-Oct-2007  yamt sync with head.
 1.8.52.1 06-Oct-2007  yamt sync with head.
 1.8.50.1 06-Nov-2007  matt sync with HEAD
 1.8.48.1 02-Oct-2007  joerg Sync with HEAD.
 1.8.38.1 03-Oct-2007  garbled Sync with HEAD
 1.8.30.1 09-Oct-2007  ad Sync with head.
 1.10.26.1 19-Oct-2008  haad Sync with HEAD.
 1.10.20.2 16-Sep-2009  yamt sync with head
 1.10.20.1 04-May-2009  yamt sync with head.
 1.10.16.1 17-Jan-2009  mjf Sync with HEAD.
 1.11.8.1 01-Nov-2009  jym Sync with HEAD.
 1.11.4.1 16-Oct-2011  riz Pull up following revision(s) (requested by jmcneill in ticket #923):
sys/arch/i386/stand/lib/gatea20.c: revision 1.12
PR# kern/39726: Soekris 5501-60 boot/bootxx 120 second delay
PR# port-i386/41162: A20 gate legacy hook cause long pxeboot delay on Soekris
net5501
Remove calls to delay() before polling KBD registers in gateA20().
 1.12 24-Aug-2024  riastradh i386/stand/lib: Nix trailing whitespace and tidy comments a bit.

No functional change intended.

PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.11 17-Aug-2024  andvar Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().
This in turn was leading to erroneous caluclations and memory addresses.
This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.

needs-pullups to 9, 10.

PR install/49470
 1.10 16-Jun-2011  joerg branches: 1.10.58; 1.10.84; 1.10.90;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.9 14-Dec-2008  christos branches: 1.9.2; 1.9.12;
ANSI and KNF from Anon Ymous
 1.8 25-Dec-2007  perry branches: 1.8.6; 1.8.10; 1.8.18;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.7 11-Dec-2005  christos branches: 1.7.50; 1.7.56; 1.7.60; 1.7.64;
merge ktrace-lwp.
 1.6 24-Mar-2004  drochner branches: 1.6.16;
remove license clauses 3 and 4 from my cpoyright notices
 1.5 07-Nov-2003  dsl Adjust location of 'extmem2' diagnostic print.
 1.4 16-Apr-2003  dsl branches: 1.4.2;
Add some debug prints to the memory size code
 1.3 23-Jan-2003  jdolecek add another memory size detection routine, using int15, function 0xc7, which
is supported on later IBM PS/2 models; this is necessary to detect memory
over 64MB
thanks go to Pavel Cahyna for testing on his IBM PS/2 machine with 128MB

bump biosboot version to 2.15
 1.2 08-Mar-1999  drochner change the interface for getmementry() to hold the iterator in an
argument and to return success or error explicitely.
Now we can "error" and "end of list" cleanly; this should fix the
problem where the last list element was ignored.
 1.1 14-Aug-1997  drochner branches: 1.1.2;
New, optional, method to get size of extended memory.
It will be used for getextmem() if EXTENDED_MEMDETECT is defined.
Worked on all tested machines.
Thanks to all testers, especially Martin Husemann!
 1.1.2.2 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 14-Aug-1997  thorpej file getextmemx.c was added on branch marc-pcmcia on 1997-08-23 07:09:40 +0000
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 21-Jan-2008  yamt sync with head
 1.7.64.1 02-Jan-2008  bouyer Sync with HEAD
 1.7.60.1 26-Dec-2007  ad Sync with head.
 1.7.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.7.50.1 09-Jan-2008  matt sync with HEAD
 1.8.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.10.1 04-May-2009  yamt sync with head.
 1.8.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.9.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.9.2.1 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.10.90.1 02-Aug-2025  perseant Sync with HEAD
 1.10.84.1 03-Sep-2024  martin Pull up following revision(s) (requested by andvar in ticket #815):

sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.7
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.8
sys/arch/i386/stand/lib/getextmemx.c: revision 1.11
sys/arch/i386/stand/lib/getextmemx.c: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.13

Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().

This in turn was leading to erroneous caluclations and memory addresses.

This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.
PR install/49470

i386/stand/lib: Nix trailing whitespace and tidy comments a bit.
No functional change intended.
PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.10.58.1 03-Sep-2024  martin Pull up following revision(s) (requested by andvar in ticket #1884):

sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.7
sys/arch/i386/stand/lib/bootinfo_memmap.c: revision 1.8
sys/arch/i386/stand/lib/getextmemx.c: revision 1.11
sys/arch/i386/stand/lib/getextmemx.c: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.12
sys/arch/i386/stand/lib/biosmemx.S: revision 1.13

Allocate buf[6] instead of buf[5] to work around buggy firmware, which may
write mementry to 24 bytes instead 20 requested with ACPI 3.0 enabled,
causing corrupted stack and wrong marks[] values in common_load_kernel().

This in turn was leading to erroneous caluclations and memory addresses.

This eventually may result in null pointer dereference in the kernel and sudden
reboot for VIA based systems.

Commit should fix boot issues for VIA C7-M based HP 2133 Mini-Note,
mentioned in the original bug report. For AMD based HP Compaq 6005 Pro
discussed in a separate thread, the issue may be different.

Tested on my VIA C7-D based Biostar Viotech 3100+ motherboard.
PR install/49470

i386/stand/lib: Nix trailing whitespace and tidy comments a bit.
No functional change intended.
PR port-amd64/49470: NetBSD 7 BETA reboots after bootloader (HP 2133)
 1.4 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.3 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.2 14-Apr-1999  drochner branches: 1.2.140; 1.2.144; 1.2.152;
add prototypes, slight formatting changes
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.18;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.18.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.152.1 19-Jan-2009  skrll Sync with HEAD.
 1.2.144.1 04-May-2009  yamt sync with head.
 1.2.140.1 17-Jan-2009  mjf Sync with HEAD.
 1.3 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.2 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.160; 1.1.1.1.164; 1.1.1.1.172;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.172.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.1.1.164.1 04-May-2009  yamt sync with head.
 1.1.1.1.160.1 17-Jan-2009  mjf Sync with HEAD.
 1.3 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.2 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.160; 1.1.1.1.164; 1.1.1.1.172;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.172.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.1.1.164.1 04-May-2009  yamt sync with head.
 1.1.1.1.160.1 17-Jan-2009  mjf Sync with HEAD.
 1.6 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.5 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.4 11-Dec-2005  christos branches: 1.4.74; 1.4.78; 1.4.86;
merge ktrace-lwp.
 1.3 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.2 22-Mar-1997  thorpej branches: 1.2.58;
Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.58.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.58.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.58.1 03-Aug-2004  skrll Sync with HEAD
 1.4.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.78.1 04-May-2009  yamt sync with head.
 1.4.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.5 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.4 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.78; 1.3.86;
merge ktrace-lwp.
 1.2 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.58;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.58.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.1.1.58.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.1.1.58.1 03-Aug-2004  skrll Sync with HEAD
 1.3.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.3.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.56 09-Oct-2025  manu Add support for USB-to-serial adapter in UEFI bootstrap.

This change lets UEFI bootstrap use any UEFI supported serial port.
com0 to com3 remain used for EISA based serial ports. com4 and over
are used for serial ports based on something else (USB, PCI or whatever).

Support for non-EISA serial ports may be provided by UEFI. An open
source UEFI driver exists for FTDI FT232R USB-to-serial adapter.

The change also introduce the kconsdev command, to select the kernel
console device without altering the bootstrap console device. This
useful because the device names can differ in bootstrap and kernel.
For instance an USB-to-serial device could be com4 in boostrap and
ucom0 for the kernel.

An upcoming change will add console suport to ucom(4).
 1.55 06-May-2025  pgoyette Allow the dev= command when processing /boot.cfg file. This
addresses kern/59207
 1.54 18-Sep-2024  rin i386/stand: Remove XMS leftover from libi386.h, NFC

PR port-i386/58624
 1.53 29-Jun-2024  rin branches: 1.53.2;
i386: stand: Adjust for DOS-routine migration
 1.52 29-Jun-2024  rin libi386.h: Drop `I386_INCLUDE_BUS` support

This is what I intended for this commit:

https://mail-index.netbsd.org/source-changes/2024/06/29/msg151996.html

Instead, I removed libi386.h by mistake :(
 1.51 29-Jun-2024  rin libi386.h: Restore rev 1.48
 1.50 29-Jun-2024  rin i386: stand: Restore libi386.h,v 1.47, which I removed accidentally
 1.49 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.48 29-Jun-2024  rin i386: stand: G/C unused `printmemlist`, NFC
 1.47 18-Oct-2019  manu Remove prototype added twice by mistake
 1.46 18-Oct-2019  manu Add kernel symbols for multiboot1
 1.45 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.44 26-Jul-2019  nonaka branches: 1.44.2;
Pre-allocate memory for the kernel space at startup.
 1.43 24-Jun-2019  pgoyette Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem. We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change. I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.
 1.42 12-Mar-2017  nonaka branches: 1.42.6; 1.42.14;
efiboot: Kernel modules are loaded in pre-allocated memory.
 1.41 24-Jan-2017  nonaka Initial commit of native amd64 EFI boot loader.
 1.40 24-Nov-2013  jakllsch branches: 1.40.6; 1.40.10; 1.40.14;
The x86 kernel entry point stack arguments are always 32-bit, even on amd64.
 1.39 30-Aug-2013  jmcneill Add support for using a raw file-system image as memory disk root with
the x86 bootloader.
 1.38 28-Nov-2011  tls branches: 1.38.8; 1.38.12;

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.37 16-Jun-2011  joerg branches: 1.37.2;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.36 26-May-2011  uebayasi branches: 1.36.2;
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.35 21-Feb-2011  dyoung biosdisk_getextinfo() returns 0 on success, non-zero on failure, so
change its return type from void to int.
 1.34 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.33 25-Jun-2010  tsutsui branches: 1.33.2; 1.33.4;
Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
and use it for large delays (in seconds) instead of delay() that uses
INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
precise delays on emulators.
Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
in qemu 0.12).

No particular comments on the PR and port-i386@.
 1.32 13-Sep-2009  jmcneill branches: 1.32.2; 1.32.4;
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.31 21-Mar-2009  ad Fix 'boot -z' bogons.
 1.30 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.29 12-Jan-2009  tsutsui branches: 1.29.2;
Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.28 13-Dec-2008  christos add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.27 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.26 11-Oct-2008  joerg branches: 1.26.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.25 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.24 21-May-2008  ad branches: 1.24.4;
- Stop the twiddler going awry.
- Clear screen if on a glass tty (!).
 1.23 11-Dec-2005  christos branches: 1.23.74; 1.23.76; 1.23.78; 1.23.80;
merge ktrace-lwp.
 1.22 29-Jun-2005  junyoung Massive renames for consistency:
biosdiskreset -> biosdisk_reset
biosread -> biosdisk_read
get_diskinfo -> biosdisk_getinfo
int13_extension -> biosdisk_int13ext
biosextread -> biosdisk_extread
int13_getextinfo -> biosdisk_getextinfo
struct biosdisk_ext13info -> biosdisk_extinfo
BIOSDISK_EXT13 -> BIOSDISK_INT13EXT
BIOSDISK_EXT13INFO_V{2,3} -> BIOSDISK_EXTINFO_V{2,3}
EXT13_* -> EXTINFO_*
 1.21 22-Jun-2005  dyoung Cosmetic: join line.
 1.20 22-Jun-2005  junyoung Add support for cd9660 file system to the i386 BIOS bootloader.
 1.19 13-Jun-2005  junyoung Cosmetic changes.
 1.18 27-Jan-2005  mycroft Make awaitkey() poll once even if the timeout is 0. This also fixes a problem
where a keypress within the last polling interval would not be noticed.
Add a new function, conisshift(), which is used to detect whether a shift key
is pressed. Use this via awaitkey() to allow interrupting the boot by holding
down shift (similar to LILO).

This allows setting the timeout to 0 and still being able to use the boot
program.
 1.17 23-Aug-2004  junyoung branches: 1.17.4; 1.17.6;
* Nuke __P().
* No need to use 'extern' for function prototypes.
 1.16 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.15 16-Apr-2003  dsl branches: 1.15.2;
Add prototyps for all the asm bios/dos calls
 1.14 01-Jun-2001  jdolecek branches: 1.14.2;
g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.13 24-Sep-2000  jdolecek branches: 1.13.4;
add new macro BOOT_FLAG() (defined in <sys/boot_flag.h>) - this
maps standard boot flags to corresponding RB_* values
use BOOT_FLAG() in port's MD code as appropriate

as discussed on tech-kern, add new boot flags -v, -q for booting
verbosely or quietly, and corresponding AB_VERBOSE/AB_QUIET
boot flags; also add FreeBSD-compatible bootverbose macro and
NetBSD-specific bootquiet macro

for hpcmips, use new bootverbose instead of it's own hpcmips_verbose

Tested on i386, and to limited extend (compile of affected files) also for
mvme68k, hp300, luna68k, sun3.
 1.12 31-Aug-2000  jdolecek constify first arg to parseopts()
 1.11 23-Apr-2000  tsarna Addredd port-i386/9897, but differently. Since the effect of resetting
the video mode on machines with ancient or no video cards is not clear,
for safety's sake a I created a new biosboot variant, biosboot_resetvideo
that does the call.

Anyway, now I can boot my i-opener without hitting Tab. Thanks Andrew!
 1.10 21-Dec-1999  drochner add a function which prints out the memory descriptors (for debugging)
 1.9 14-Apr-1999  christos branches: 1.9.2; 1.9.8;
Add prototype for getsecs
 1.8 28-Jan-1999  christos branches: 1.8.4;
Minor changes to prototypes.
 1.7 13-Aug-1998  rvb Make serial line debugging easier to enable and use
 1.6 17-Sep-1997  drochner Add now common menu / parsing functions.
Adapt to new console I/O functionality.
Update exec() arguments.
 1.5 14-Aug-1997  drochner Make new memory detection default.
Introduce a new option, "CONSERVATIVE_MEMDETECT", which disables the
new BIOS calls.
 1.4 14-Aug-1997  drochner New, optional, method to get size of extended memory.
It will be used for getextmem() if EXTENDED_MEMDETECT is defined.
Worked on all tested machines.
Thanks to all testers, especially Martin Husemann!
 1.3 13-Jun-1997  drochner branches: 1.3.4;
Allow to boot from DOS if a XMS manager is installed.
XMS is recognized and used as temporary buffer for the kernel image.
The processor must still be in real mode at program start, so EMM386
or QEMM are not allowed. W*95 is OK.
Written by Martin Husemann (pr port-i386/3336).
Completely separated from other bootloaders for sanity.
 1.2 13-Apr-1997  perry 1) Make carriage return start boot immediately.
2) Make "quit" reboot machine. This works by adding a reboot assembler
hook that calls INT 19h
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.4.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.4.1 23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.8.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.13.4.1 21-Jun-2001  nathanw Catch up to -current.
 1.14.2.2 01-Jun-2001  jdolecek g/c COMPAT_OLDBOOT from bootblocks, sprinkle some const
bump bootblock version to 2.10
 1.14.2.1 01-Jun-2001  jdolecek file libi386.h was added on branch sommerfeld_i386mp_1 on 2001-06-01 23:26:32 +0000
 1.15.2.6 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.15.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.15.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.6.1 12-Feb-2005  yamt sync with head.
 1.17.4.1 29-Apr-2005  kent sync with -current
 1.23.80.2 10-Oct-2008  skrll Sync with HEAD.
 1.23.80.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23.78.3 11-Aug-2010  yamt sync with head.
 1.23.78.2 16-Sep-2009  yamt sync with head
 1.23.78.1 04-May-2009  yamt sync with head.
 1.23.76.1 04-Jun-2008  yamt sync with head
 1.23.74.3 17-Jan-2009  mjf Sync with HEAD.
 1.23.74.2 28-Sep-2008  mjf Sync with HEAD.
 1.23.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.24.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.24.4.1 19-Oct-2008  haad Sync with HEAD.
 1.26.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.26.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.26.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.29.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.29.2.4 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.29.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.29.2.2 01-Nov-2009  jym Sync with HEAD.
 1.29.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.32.4.3 31-May-2011  rmind sync with head
 1.32.4.2 05-Mar-2011  rmind sync with head
 1.32.4.1 03-Jul-2010  rmind sync with head
 1.32.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.33.4.2 05-Mar-2011  bouyer Sync with HEAD
 1.33.4.1 08-Feb-2011  bouyer Sync with HEAD
 1.33.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.36.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.37.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.37.2.1 17-Apr-2012  yamt sync with head
 1.38.12.1 18-May-2014  rmind sync with head
 1.38.8.2 03-Dec-2017  jdolecek update from HEAD
 1.38.8.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.40.14.1 21-Apr-2017  bouyer Sync with HEAD
 1.40.10.1 20-Mar-2017  pgoyette Sync with HEAD
 1.40.6.2 28-Aug-2017  skrll Sync with HEAD
 1.40.6.1 05-Feb-2017  skrll Sync with HEAD
 1.42.14.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.42.6.2 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.42.6.1 01-Aug-2019  martin Pull up following revision(s) (requested by nonaka in ticket #1309):

sys/arch/i386/stand/lib/exec.c: revision 1.73
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.10
sys/arch/i386/stand/lib/libi386.h: revision 1.44
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.6
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.7
sys/arch/i386/stand/efiboot/efimemory.c: revision 1.8
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.9
sys/arch/i386/stand/efiboot/boot.c: revision 1.12
sys/arch/i386/stand/efiboot/boot.c: revision 1.13
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.9
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.15
sys/arch/i386/stand/efiboot/dev_net.c: revision 1.2

Added tftp support to x86 efiboot.

Pre-allocate memory for the kernel space at startup.

Added BTINFO_EFIMEMMAP compaction support to x86 efiboot.

Sync the output of memmap command to the output of stand/efiboot mem command.

Added missing efi_memory_probe() call.
 1.44.2.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.53.2.1 02-Aug-2025  perseant Sync with HEAD
 1.10 28-Apr-1999  christos use new loadfile
 1.9 17-Apr-1999  drochner another nit in error handling: don't try to print out a NULL filename
(which means "use default" and is dealt with properly by open())
 1.8 09-Apr-1999  drochner fix error handling: almost all errors were ignored
 1.7 07-Mar-1999  he branches: 1.7.2;
Add handling of OMAGIC files, where exec header isn't part of the
text segment. Needed for woring installboot, since biosboot.sym is OMAGIC.
 1.6 05-Mar-1999  fvdl Make bootblocks really work this time. From Christos.
 1.5 04-Mar-1999  christos Fix the symbol reading problem...
 1.4 30-Jan-1999  christos Add my name in the copyright, since the code looks very different now.
 1.3 29-Jan-1999  christos Add the ability to get the size of the loaded image without actually
loading. This is useful for dos loading and installboot.
 1.2 28-Jan-1999  christos Add support for selectively loading sections, and make this compile in
userland with -DINSTALLBOOT
 1.1 28-Jan-1999  christos Add loadfile.c (stolen from Jason's alpha/stand/common/loadfile.c)
loadfile.h contains macros that are supposed to be MD, but loadfile.c is now MI.
Fixes:
- a.out support
- pass information values via an array not global variables
- don't assume that you can access memory directly.
- remove MD parts
- remove some printfs.
XXX: loadfile.c needs to be moved somewhere where other ports can use it.
XXX2: read() routines on the i386 don't appear to set errno on failure.
 1.7.2.1 19-Apr-1999  perry branches: 1.7.2.1.2;
pull up 1.7->1.9 to fix error handling (req. by drochner)
 1.7.2.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4 28-Apr-1999  christos use new loadfile
 1.3 29-Jan-1999  christos branches: 1.3.2; 1.3.4;
Add the ability to get the size of the loaded image without actually
loading. This is useful for dos loading and installboot.
 1.2 28-Jan-1999  christos Add support for selectively loading sections, and make this compile in
userland with -DINSTALLBOOT
 1.1 28-Jan-1999  christos Add loadfile.c (stolen from Jason's alpha/stand/common/loadfile.c)
loadfile.h contains macros that are supposed to be MD, but loadfile.c is now MI.
Fixes:
- a.out support
- pass information values via an array not global variables
- don't assume that you can access memory directly.
- remove MD parts
- remove some printfs.
XXX: loadfile.c needs to be moved somewhere where other ports can use it.
XXX2: read() routines on the i386 don't appear to set errno on failure.
 1.3.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.2.1 20-Dec-1999  he Apply patch (based on rev. 1.3 of loadfile_machdep.h, requested by drochner):
Allow booting of kernels which are larger than 16MB on i386.
 1.6 11-Jun-2016  dholland gets_s -> kgets.

The exact name isn't that important; but it is important not to use
"gets_s" and thereby allow anyone to falsely get the impression we're
implementing Annex K. We aren't.

ok core.
 1.5 05-Jun-2016  maxv Use gets_s instead of gets. The x86 bootloader prompt is easy to
overflow.
 1.4 06-Apr-2014  jakllsch branches: 1.4.4;
Use __dead.
 1.3 14-Dec-2008  christos branches: 1.3.14; 1.3.24; 1.3.28; 1.3.38;
more KNF and ANSI from Anon-ymous
 1.2 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.1 17-Sep-1997  drochner branches: 1.1.2; 1.1.156; 1.1.160; 1.1.168;
Factor out functions for table driven boot menus and command line parsing
usable for different boot programs.
 1.1.168.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.160.1 04-May-2009  yamt sync with head.
 1.1.156.1 17-Jan-2009  mjf Sync with HEAD.
 1.1.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 17-Sep-1997  thorpej file menuutils.c was added on branch marc-pcmcia on 1997-09-22 06:31:33 +0000
 1.3.38.1 10-Aug-2014  tls Rebase.
 1.3.28.1 18-May-2014  rmind sync with head
 1.3.24.2 03-Dec-2017  jdolecek update from HEAD
 1.3.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.14.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.4.4.1 09-Jul-2016  skrll Sync with HEAD
 1.4 19-Nov-2009  dsl Move code for outputting directly to the serial port into message.S
Allows it to be enabled for other parts of the boot sequence.
 1.3 28-Apr-2008  martin branches: 1.3.14;
Remove clause 3 and 4 from TNF licenses
 1.2 24-Apr-2003  dsl branches: 1.2.104; 1.2.106; 1.2.108;
Don't use ENTRY - it aligns the label and we can't afford the space.
Adjust coding to save 2 more bytes (assume 'D' flag clear - it is)
 1.1 16-Apr-2003  dsl additional support routines for boot code
 1.2.108.2 11-Mar-2010  yamt sync with head
 1.2.108.1 16-May-2008  yamt sync with head.
 1.2.106.1 18-May-2008  yamt sync with head.
 1.2.104.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.14.1 24-Oct-2010  jym Sync with HEAD
 1.1 19-Nov-2009  dsl branches: 1.1.4; 1.1.8;
Add 32 bit versions of message and dump_eax that write directly to
the serial port. Useful for debugging - especially real_to_prot!
 1.1.8.2 24-Oct-2010  jym Sync with HEAD
 1.1.8.1 19-Nov-2009  jym file message32.S was added on branch jym-xensuspend on 2010-10-24 22:48:05 +0000
 1.1.4.2 11-Mar-2010  yamt sync with head
 1.1.4.1 19-Nov-2009  yamt file message32.S was added on branch yamt-nfs-mp on 2010-03-11 15:02:31 +0000
 1.3 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.2 04-Dec-2016  maxv branches: 1.2.8; 1.2.16; 1.2.20;
KNF and explain a few things
 1.1 11-Oct-2008  joerg branches: 1.1.2; 1.1.10; 1.1.16; 1.1.44; 1.1.64; 1.1.68;
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.1.68.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.64.1 05-Dec-2016  skrll Sync with HEAD
 1.1.44.1 03-Dec-2017  jdolecek update from HEAD
 1.1.16.2 04-May-2009  yamt sync with head.
 1.1.16.1 11-Oct-2008  yamt file multiboot.S was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.1.10.2 17-Jan-2009  mjf Sync with HEAD.
 1.1.10.1 11-Oct-2008  mjf file multiboot.S was added on branch mjf-devfs2 on 2009-01-17 13:28:05 +0000
 1.1.2.2 19-Oct-2008  haad Sync with HEAD.
 1.1.2.1 11-Oct-2008  haad file multiboot.S was added on branch haad-dm on 2008-10-19 22:15:50 +0000
 1.2.20.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.2.16.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2.8.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.4 24-Sep-2000  jdolecek add new macro BOOT_FLAG() (defined in <sys/boot_flag.h>) - this
maps standard boot flags to corresponding RB_* values
use BOOT_FLAG() in port's MD code as appropriate

as discussed on tech-kern, add new boot flags -v, -q for booting
verbosely or quietly, and corresponding AB_VERBOSE/AB_QUIET
boot flags; also add FreeBSD-compatible bootverbose macro and
NetBSD-specific bootquiet macro

for hpcmips, use new bootverbose instead of it's own hpcmips_verbose

Tested on i386, and to limited extend (compile of affected files) also for
mvme68k, hp300, luna68k, sun3.
 1.3 29-Jul-2000  jdolecek branches: 1.3.2;
g/c RB_DFLTROOT

I've tried hard to find also various usage() messages and remove the
appropriate flag from there as well, hopefully all occurences are covered.
 1.2 14-Mar-1997  thorpej branches: 1.2.22; 1.2.34;
Purely cosmetic whitespace changes.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.2.34.1 13-Aug-2000  jdolecek pullup from trunk (approved by thorpej):
retire RB_DFLTROOT, it's no longer used

revisions pulled up:
arch/i386/stand/lib/netbsd_opts.c 1.3
arch/i386/stand/biosboot/main.c 1.23
arch/i386/stand/dosboot/main.c 1.15
arch/i386/stand/netboot/main.c 1.6
arch/arc/arc/machdep.c 1.42
arch/bebox/stand/boot/boot.c 1.11
arch/hpcmips/hpcmips/machdep.c 1.32
arch/newsmips/newsmips/machdep.c 1.45
arch/pc532/stand/boot/boot.c 1.2
arch/pmax/pmax/machdep.c 1.178
arch/prep/stand/boot/boot.c 1.2
arch/sparc/sparc/autoconf.c 1.141
arch/sparc64/sparc64/autoconf.c 1.38
arch/x68k/stand/loadbsd/loadbsd.c 1.5
arch/mvme68k/stand/libsa/parse_args.c 1.6
compat/osf1/osf1_cvt.c 1.9
sys/reboot.h 1.17
 1.2.22.1 20-Nov-2000  bouyer Remove files that are no longer on the trunck
 1.3.2.2 23-Jan-2001  thorpej Sync with the trunk.
 1.3.2.1 29-Jul-2000  thorpej file netbsd_opts.c was added on branch sommerfeld_i386mp_1 on 2001-01-23 06:34:55 +0000
 1.8 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.7 11-Dec-2005  christos branches: 1.7.92; 1.7.100;
merge ktrace-lwp.
 1.6 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.5 01-Jun-2002  itojun branches: 1.5.2; 1.5.8;
use exit(int), not exit(void), consistently - even if the arg has no meaning.
 1.4 20-Sep-2001  wiz branches: 1.4.12;
When using va_list, use vprintf, not printf.
 1.3 12-Feb-1999  cjs branches: 1.3.22; 1.3.24; 1.3.26;
Don't give exit() a parameter, as libstand version doesn't take one.
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.26.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.24.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.24.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.22.2 20-Jun-2002  nathanw Catch up to -current.
 1.3.22.1 21-Sep-2001  nathanw Catch up to -current.
 1.4.12.1 14-Jul-2002  gehenna catch up with -current.
 1.5.8.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.8.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.8.1 03-Aug-2004  skrll Sync with HEAD
 1.5.2.2 01-Jun-2002  itojun use exit(int), not exit(void), consistently - even if the arg has no meaning.
 1.5.2.1 01-Jun-2002  itojun file panic.c was added on branch sommerfeld_i386mp_1 on 2002-06-01 11:40:34 +0000
 1.7.100.1 05-Mar-2011  rmind sync with head
 1.7.92.1 10-Jan-2011  jym Sync with HEAD
 1.7 05-Jan-2014  jakllsch No need to return a empty string literal of the wrong const-ness when we
already have a empty string of the correct const-ness.
 1.6 18-Aug-2011  christos branches: 1.6.2; 1.6.12; 1.6.16;
PR/43563: Wolfgang Solfrank: boot.cfg doesn't support comments
Fix makes it support # comments and treat spaces and tabs the same way.
 1.5 14-Dec-2008  christos branches: 1.5.2;
ANSI and KNF from Anon Ymous
 1.4 09-Dec-2008  christos Allow parsing more than one command line switch. From anon ymous.
 1.3 24-Sep-2000  jdolecek branches: 1.3.2; 1.3.128; 1.3.132; 1.3.138; 1.3.140;
add new macro BOOT_FLAG() (defined in <sys/boot_flag.h>) - this
maps standard boot flags to corresponding RB_* values
use BOOT_FLAG() in port's MD code as appropriate

as discussed on tech-kern, add new boot flags -v, -q for booting
verbosely or quietly, and corresponding AB_VERBOSE/AB_QUIET
boot flags; also add FreeBSD-compatible bootverbose macro and
NetBSD-specific bootquiet macro

for hpcmips, use new bootverbose instead of it's own hpcmips_verbose

Tested on i386, and to limited extend (compile of affected files) also for
mvme68k, hp300, luna68k, sun3.
 1.2 31-Aug-2000  jdolecek constify first arg to parseopts()
 1.1 17-Sep-1997  drochner branches: 1.1.2; 1.1.18;
Factor out functions for table driven boot menus and command line parsing
usable for different boot programs.
 1.1.18.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.1.2.1 17-Sep-1997  thorpej file parseutils.c was added on branch marc-pcmcia on 1997-09-22 06:31:34 +0000
 1.3.140.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.138.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.132.1 04-May-2009  yamt sync with head.
 1.3.128.1 17-Jan-2009  mjf Sync with HEAD.
 1.3.2.2 24-Sep-2000  jdolecek add new macro BOOT_FLAG() (defined in <sys/boot_flag.h>) - this
maps standard boot flags to corresponding RB_* values
use BOOT_FLAG() in port's MD code as appropriate

as discussed on tech-kern, add new boot flags -v, -q for booting
verbosely or quietly, and corresponding AB_VERBOSE/AB_QUIET
boot flags; also add FreeBSD-compatible bootverbose macro and
NetBSD-specific bootquiet macro

for hpcmips, use new bootverbose instead of it's own hpcmips_verbose

Tested on i386, and to limited extend (compile of affected files) also for
mvme68k, hp300, luna68k, sun3.
 1.3.2.1 24-Sep-2000  jdolecek file parseutils.c was added on branch sommerfeld_i386mp_1 on 2000-09-24 12:32:36 +0000
 1.5.2.1 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.6.16.1 18-May-2014  rmind sync with head
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.2.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.30 08-Jun-2011  joerg Use prototypes from libi386.h.
 1.29 14-Feb-2011  jmcneill branches: 1.29.2;
port-i386/44563: boot loader prompt doesn't read keyboard input on a MacBook1,1

check for keystroke (int 16h, AH=01h) before getting keystroke (int 16h,
AH=00h), fixes bootloader keyboard input with Apple firmware, from Taylor R
Campbell
 1.28 25-Jun-2010  tsutsui branches: 1.28.2; 1.28.4;
Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
and use it for large delays (in seconds) instead of delay() that uses
INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
precise delays on emulators.
Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
in qemu 0.12).

No particular comments on the PR and port-i386@.
 1.27 26-Aug-2009  jmcneill branches: 1.27.2; 1.27.4;
int 15h/AH=86h (WAIT) doesn't work properly on all hardware and emulators, so
for the countdown use the more coarsely grained sleep implementation based
on int 1ah/AH=00h (GET SYSTEM TIME).

ok ad@
 1.26 29-Jun-2009  mbalmer Have the boot countdown on i386 display "starting in N seconds." instead
of "starting in N" and eliminate a use of sprintf. Note that on
some rare machines it can be that the BIOS does not provide the delay
function. On such machines the countdown will almost immediately count down
to zero display "starting in 0 seconds."; apparently the net4801 is such a
machine.
Feedback, ideas, and inspiration from tron, ok tron/tonnerre
 1.25 14-Dec-2008  christos branches: 1.25.2;
more KNF and ANSI from Anon-ymous
 1.24 13-Dec-2008  christos add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.23 21-May-2008  ad branches: 1.23.6; 1.23.8; 1.23.14;
Fix build failure.
 1.22 21-May-2008  ad - Stop the twiddler going awry.
- Clear screen if on a glass tty (!).
 1.21 30-Jan-2006  junyoung branches: 1.21.72; 1.21.74; 1.21.76; 1.21.78;
ANSI & KNF.
 1.20 11-Nov-2005  dsl branches: 1.20.4;
Make a baud rate of zero cause the baud rate divisor be read and converted
to the current baud rate.
That way we use the same baud rate as the system BIOS (or whatever).
Rather useful for pxeboot.
 1.19 27-Jan-2005  mycroft branches: 1.19.6;
Make awaitkey() poll once even if the timeout is 0. This also fixes a problem
where a keypress within the last polling interval would not be noticed.
Add a new function, conisshift(), which is used to detect whether a shift key
is pressed. Use this via awaitkey() to allow interrupting the boot by holding
down shift (similar to LILO).

This allows setting the timeout to 0 and still being able to use the boot
program.
 1.18 15-Aug-2004  dsl branches: 1.18.4; 1.18.6;
Allow the com port base address to be specified by the user (via installboot)
rather than taking the value from the bios.
Should allow the system to use a serial console that is also a 'bios serial
console' and isn't in the bios serial port table.
Probably fixes (with a few other changes) PR port-i386/9236
 1.17 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.16 13-Mar-2004  dsl Translate ascii keycode to help those with azerty keyboard type straight.
 1.15 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.14 16-Apr-2003  dsl branches: 1.14.2;
Modify baud rate handling to make it easier to take it from a variable.
Default to 9600 if the requested baud rate is illegal.
 1.13 08-Mar-2003  dsl Avoid pulling strncpy() into minimal boot code
 1.12 01-Feb-2003  dsl Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.11 19-Feb-2002  thorpej branches: 1.11.2;
Add some comments to make some #if/#else/#endif's more clear.
 1.10 10-Sep-1999  drochner branches: 1.10.16; 1.10.18;
improve awaitkey()'s printout for >9 seconds
 1.9 14-Apr-1999  drochner add prototypes, slight formatting changes
 1.8 12-Mar-1999  sommerfe branches: 1.8.4;
Fix compile warning in getcomaddr()
 1.7 13-Aug-1998  rvb Make serial line debugging easier to enable and use
 1.6 27-Oct-1997  drochner Catch "timeout" return of serial port read BIOS call.
 1.5 17-Sep-1997  drochner branches: 1.5.2;
-extend serial console code to all 4 BIOS known interfaces
-optionally, use Martin's direct hardware access to serial lines
-optionally, new console autoselection method: select serial console
if a character is seen within 1 second
-move awaitkey() here, it can be shared by different bootloaders and
it is used by console autoselection
-collect information about console selection in a "bootinfo" defined
structure, for passing to the kernel
 1.4 13-Jun-1997  drochner branches: 1.4.4;
Reformat comments. (messed up by "indent")
-Wall fixes
 1.3 22-Mar-1997  thorpej Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.2 15-Mar-1997  perry From Matthias Drochner:
fix prototypes
use CONSDEV_* constants for consistency
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.4.4.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.2.1 28-Oct-1997  mellon Pull rev 1.6 up from trunk (drochner)
 1.8.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.10.18.1 16-Mar-2002  jdolecek Catch up with -current.
 1.10.16.1 28-Feb-2002  nathanw Catch up to -current.
 1.11.2.2 19-Feb-2002  thorpej Add some comments to make some #if/#else/#endif's more clear.
 1.11.2.1 19-Feb-2002  thorpej file pcio.c was added on branch sommerfeld_i386mp_1 on 2002-02-19 20:18:37 +0000
 1.14.2.6 11-Dec-2005  christos Sync with head.
 1.14.2.5 04-Feb-2005  skrll Sync with HEAD.
 1.14.2.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.3 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.2 25-Aug-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.6.1 12-Feb-2005  yamt sync with head.
 1.18.4.1 29-Apr-2005  kent sync with -current
 1.19.6.1 21-Jun-2006  yamt sync with head.
 1.20.4.1 01-Feb-2006  yamt sync with head.
 1.21.78.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.21.76.4 11-Aug-2010  yamt sync with head.
 1.21.76.3 16-Sep-2009  yamt sync with head
 1.21.76.2 18-Jul-2009  yamt sync with head.
 1.21.76.1 04-May-2009  yamt sync with head.
 1.21.74.1 04-Jun-2008  yamt sync with head
 1.21.72.2 17-Jan-2009  mjf Sync with HEAD.
 1.21.72.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.14.1 21-Apr-2010  matt sync to netbsd-5
 1.23.8.2 28-Nov-2009  bouyer Pull up following revision(s) (requested by mbalmer in ticket #1143):
sys/arch/i386/stand/lib/pcio.c: revision 1.26
Have the boot countdown on i386 display "starting in N seconds." instead
of "starting in N" and eliminate a use of sprintf. Note that on
some rare machines it can be that the BIOS does not provide the delay
function. On such machines the countdown will almost immediately count down
to zero display "starting in 0 seconds."; apparently the net4801 is such a
machine.
Feedback, ideas, and inspiration from tron, ok tron/tonnerre
 1.23.8.1 26-Sep-2009  snj Pull up following revision(s) (requested by jmcneill in ticket #928):
sys/arch/i386/stand/lib/pcio.c: revision 1.27
int 15h/AH=86h (WAIT) doesn't work properly on all hardware and emulators, so
for the countdown use the more coarsely grained sleep implementation based
on int 1ah/AH=00h (GET SYSTEM TIME).
ok ad@
 1.23.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.25.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.25.2.4 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.25.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.25.2.2 01-Nov-2009  jym Sync with HEAD.
 1.25.2.1 23-Jul-2009  jym Sync with HEAD.
 1.27.4.3 12-Jun-2011  rmind sync with head
 1.27.4.2 05-Mar-2011  rmind sync with head
 1.27.4.1 03-Jul-2010  rmind sync with head
 1.27.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.28.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.28.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.5 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.4 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.78; 1.3.86;
merge ktrace-lwp.
 1.2 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry branches: 1.1.1.1.58;
Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.1.1.1.58.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.1.1.58.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.1.1.58.1 03-Aug-2004  skrll Sync with HEAD
 1.3.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.3.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.8 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.7 14-Dec-2008  christos branches: 1.7.58; 1.7.66; 1.7.70;
ANSI and KNF from Anon Ymous
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.78; 1.6.86;
merge ktrace-lwp.
 1.5 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.4 01-Feb-2003  dsl branches: 1.4.2;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.3 28-Jan-1999  christos Minor changes to prototypes.
 1.2 22-Mar-1997  thorpej Purely cosmetic whitespace and indentation changes (mmm, indent(1))
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.6.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.7.70.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.7.66.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.58.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.3 29-Jun-2024  rin i386: stand: G/C unused `printmemlist`, NFC
 1.2 14-Dec-2008  christos ANSI and KNF from Anon Ymous
 1.1 21-Dec-1999  drochner branches: 1.1.2; 1.1.10; 1.1.136; 1.1.140; 1.1.148;
add a function which prints out the memory descriptors (for debugging)
 1.1.148.1 19-Jan-2009  skrll Sync with HEAD.
 1.1.140.1 04-May-2009  yamt sync with head.
 1.1.136.1 17-Jan-2009  mjf Sync with HEAD.
 1.1.10.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.10.1 21-Dec-1999  bouyer file printmemlist.c was added on branch thorpej_scsipi on 2000-11-20 20:09:40 +0000
 1.1.2.2 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.2.1 21-Dec-1999  wrstuden file printmemlist.c was added on branch wrstuden-devbsize on 1999-12-27 18:32:29 +0000
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 16-Apr-2003  dsl branches: 1.1.104; 1.1.106; 1.1.108;
additional support routines for boot code
 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.1 02-Jun-2011  dsl branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add C stubs to allow prints early in the boot code.
 1.1.8.2 27-Aug-2011  jym Add/remove files, like in HEAD.
 1.1.8.1 02-Jun-2011  jym file putstr32.S was added on branch jym-xensuspend on 2011-08-27 15:59:48 +0000
 1.1.6.2 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.1.6.1 02-Jun-2011  cherry file putstr32.S was added on branch cherry-xenmp on 2011-06-23 14:19:16 +0000
 1.1.4.2 12-Jun-2011  rmind sync with head
 1.1.4.1 02-Jun-2011  rmind file putstr32.S was added on branch rmind-uvmplock on 2011-06-12 00:23:59 +0000
 1.1.2.2 06-Jun-2011  jruoho Sync with HEAD.
 1.1.2.1 02-Jun-2011  jruoho file putstr32.S was added on branch jruoho-x86intr on 2011-06-06 09:05:53 +0000
 1.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.1 16-Apr-2003  dsl branches: 1.1.104; 1.1.106; 1.1.108;
additional support routines for boot code
 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.1 16-Feb-2009  jmcneill branches: 1.1.2; 1.1.4; 1.1.6;
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.1.6.3 01-Nov-2009  jym Sync with HEAD.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 16-Feb-2009  jym file rasops.c was added on branch jym-xensuspend on 2009-05-13 17:17:52 +0000
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 16-Feb-2009  yamt file rasops.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.1.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.1.2.1 16-Feb-2009  skrll file rasops.c was added on branch nick-hppapmap on 2009-03-03 18:29:00 +0000
 1.13 05-Mar-2025  andvar fix couple typos in comments.
 1.12 01-Apr-2022  andvar branches: 1.12.10;
s/potected/protected and s/investication/investigation/ in comments.
 1.11 24-Dec-2013  jakllsch Obtain CR0_PE constant from <x86/specialreg.h> rather than a local #define.
 1.10 19-Dec-2010  jakllsch branches: 1.10.8; 1.10.18; 1.10.22;
Compute real/protected %sp/%esp offset in 'gdt_fixup' using all 32-bits.
Allows the case of %ss being less than %cs to work.
Also, completely save and restore the general-purpose registers we use.
 1.9 21-Nov-2009  dsl branches: 1.9.4;
Replace EPIA_HACK code with a version that 'just' trashes any return
address cache. This seems to be rather more effective!
This seems to be adequate and is more justifyable than the previous hack.
 1.8 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.7 28-Apr-2008  martin branches: 1.7.8; 1.7.14;
Remove clause 3 and 4 from TNF licenses
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.76; 1.6.78;
merge ktrace-lwp.
 1.5 21-Jun-2005  junyoung Remove trailing spaces.
 1.4 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.3 13-Feb-2004  wiz branches: 1.3.6; 1.3.14;
Uppercase CPU, plural is CPUs.
 1.2 24-Apr-2003  dsl branches: 1.2.2;
Missing end of comment
 1.1 16-Apr-2003  dsl Routines to switch between 16bit real and 32bit protected modes
 1.2.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3.14.1 30-May-2005  riz Pull up revision 1.4 (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.3.6.1 30-May-2005  riz Pull up revision 1.4 (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.6.78.3 11-Mar-2010  yamt sync with head
 1.6.78.2 04-May-2009  yamt sync with head.
 1.6.78.1 16-May-2008  yamt sync with head.
 1.6.76.1 18-May-2008  yamt sync with head.
 1.6.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.14.3 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.7.14.2 01-Nov-2009  jym Sync with HEAD.
 1.7.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.8.1 03-Mar-2009  skrll Sync with HEAD.
 1.9.4.1 05-Mar-2011  rmind sync with head
 1.10.22.1 18-May-2014  rmind sync with head
 1.10.18.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.8.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.12.10.1 02-Aug-2025  perseant Sync with HEAD
 1.4 04-Dec-2016  maxv KNF and explain a few things
 1.3 01-Feb-2003  dsl branches: 1.3.152; 1.3.172; 1.3.176;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.2 01-Mar-1999  simonb fix spel.
 1.1 14-Mar-1997  perry branches: 1.1.1;
Initial revision
 1.1.1.1 14-Mar-1997  perry Initial import of new boot code, created by Matthias Drochner with a
little hacking by me. This isn't strictly identical to his 920312
release -- I've hacked it a bit -- but since we are taking over change
control it doesn't matter much.
 1.3.176.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.3.172.1 05-Dec-2016  skrll Sync with HEAD
 1.3.152.1 03-Dec-2017  jdolecek update from HEAD
 1.10 15-Dec-2019  christos PR/54767: elo: fix incorrect test (mlelstv)
Add symbolic constants and reference to the standard.
 1.9 24-Jan-2017  nonaka branches: 1.9.14;
Initial commit of native amd64 EFI boot loader.
 1.8 31-May-2013  tsutsui branches: 1.8.10; 1.8.14; 1.8.18;
The 'vesa' command can take 'list' flag so mention it in an error message.
 1.7 09-Feb-2011  jmcneill branches: 1.7.4; 1.7.10; 1.7.14;
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.6 25-Jun-2010  tsutsui branches: 1.6.2; 1.6.4;
Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
and use it for large delays (in seconds) instead of delay() that uses
INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
precise delays on emulators.
Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
in qemu 0.12).

No particular comments on the PR and port-i386@.
 1.5 20-Oct-2009  jmcneill branches: 1.5.2; 1.5.4;
trim some fat
 1.4 14-Sep-2009  jmcneill Don't commit the selected VBE mode until the loader is past the point of
no return; need to stick in text mode as long as possible since libsa does
not include a rasops library. While here, add the 'vesa' command to pxeboot
to mirror biosboot behaviour.
 1.3 24-Aug-2009  jmcneill Pass the VBE mode number from the bootloader to the kernel, and then
make the ACPI wakecode aware of it. Restore the desired VBE mode on resume
when acpi_vbios_reset=1, so suspend/resume with genfb console will work.
 1.2 17-Feb-2009  jmcneill branches: 1.2.2; 1.2.4; 1.2.6;
Reorder command line parsing logic; previously the code assumed a string
containing the letter 'x' was a mode string (eg. 640x480), which prevented
the parser from picking up a mode number (eg. 0x101).
 1.1 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.2.6.5 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.2.6.4 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.2.6.3 01-Nov-2009  jym Sync with HEAD.
 1.2.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.2.6.1 17-Feb-2009  jym file vbe.c was added on branch jym-xensuspend on 2009-05-13 17:17:52 +0000
 1.2.4.5 11-Aug-2010  yamt sync with head.
 1.2.4.4 11-Mar-2010  yamt sync with head
 1.2.4.3 16-Sep-2009  yamt sync with head
 1.2.4.2 04-May-2009  yamt sync with head.
 1.2.4.1 17-Feb-2009  yamt file vbe.c was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.2.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.2.2.1 17-Feb-2009  skrll file vbe.c was added on branch nick-hppapmap on 2009-03-03 18:29:00 +0000
 1.5.4.2 05-Mar-2011  rmind sync with head
 1.5.4.1 03-Jul-2010  rmind sync with head
 1.5.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.6.4.1 17-Feb-2011  bouyer Sync with HEAD
 1.6.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.7.14.2 03-Dec-2017  jdolecek update from HEAD
 1.7.14.1 23-Jun-2013  tls resync from head
 1.7.10.1 20-Oct-2013  bouyer Pull up following revision(s) (requested by tsutsui in ticket #957):
sys/arch/i386/stand/lib/vbe.c: revision 1.8
The 'vesa' command can take 'list' flag so mention it in an error message.
 1.7.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.8.18.1 21-Apr-2017  bouyer Sync with HEAD
 1.8.14.1 20-Mar-2017  pgoyette Sync with HEAD
 1.8.10.1 05-Feb-2017  skrll Sync with HEAD
 1.9.14.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3 09-Feb-2011  jmcneill 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.2 14-Sep-2009  jmcneill branches: 1.2.4; 1.2.6; 1.2.8;
Don't commit the selected VBE mode until the loader is past the point of
no return; need to stick in text mode as long as possible since libsa does
not include a rasops library. While here, add the 'vesa' command to pxeboot
to mirror biosboot behaviour.
 1.1 16-Feb-2009  jmcneill branches: 1.1.2; 1.1.4; 1.1.6;
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.1.6.4 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.1.6.3 01-Nov-2009  jym Sync with HEAD.
 1.1.6.2 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.6.1 16-Feb-2009  jym file vbe.h was added on branch jym-xensuspend on 2009-05-13 17:17:52 +0000
 1.1.4.3 16-Sep-2009  yamt sync with head
 1.1.4.2 04-May-2009  yamt sync with head.
 1.1.4.1 16-Feb-2009  yamt file vbe.h was added on branch yamt-nfs-mp on 2009-05-04 08:11:19 +0000
 1.1.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.1.2.1 16-Feb-2009  skrll file vbe.h was added on branch nick-hppapmap on 2009-03-03 18:29:00 +0000
 1.2.8.1 17-Feb-2011  bouyer Sync with HEAD
 1.2.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.2.4.1 05-Mar-2011  rmind sync with head
 1.2 19-Feb-1999  drochner redirect the linker's stderr to the protocol file too
 1.1 15-May-1998  drochner Framework to test standalone code in a friedly user environment.
 1.7 14-Dec-2008  christos more KNF and ANSI from Anon-ymous
 1.6 11-Dec-2005  christos branches: 1.6.74; 1.6.78; 1.6.86;
merge ktrace-lwp.
 1.5 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.4 01-Apr-1999  drochner branches: 1.4.44;
sync to changed biosdisk interface again
 1.3 30-Mar-1999  drochner sync to changed geometry handling in the standalone code
 1.2 22-Nov-1998  drochner Update for INT13 support.
XXX We can't easily emulate this here due to the 16-bit-pointer
call interface.
 1.1 15-May-1998  drochner Framework to test standalone code in a friedly user environment.
 1.4.44.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.44.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.44.1 03-Aug-2004  skrll Sync with HEAD
 1.6.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.6.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.2 30-Mar-1999  drochner branches: 1.2.44;
sync to changed geometry handling in the standalone code
 1.1 15-May-1998  drochner Framework to test standalone code in a friedly user environment.
 1.2.44.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.44.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.44.1 03-Aug-2004  skrll Sync with HEAD
 1.11 29-Jun-2024  rin i386: stand: G/C `netif` with its test; only used by netboot
 1.10 14-Dec-2008  christos more KNF and ANSI from Anon-ymous
 1.9 05-Dec-2007  dyoung branches: 1.9.12; 1.9.16; 1.9.24;
Use IFADDR_FIRST(), IFADDR_NEXT(), IFNET_NEXT().
 1.8 05-Dec-2007  dyoung Don't open-code queue(3) macros (x = ifnet.tqh_first; y =
x.if_list.tqe_next). Instead, use the macros themselves.
 1.7 17-Oct-2007  garbled branches: 1.7.2; 1.7.4;
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.6 26-Aug-2007  dyoung branches: 1.6.2;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).

Use sockaddr_dl_setaddr() in a few places.
 1.5 04-Mar-2007  christos branches: 1.5.2; 1.5.10; 1.5.14; 1.5.18;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 11-Dec-2005  christos branches: 1.4.26;
merge ktrace-lwp.
 1.3 24-Mar-2004  drochner branches: 1.3.16;
remove license clauses 3 and 4 from my cpoyright notices
 1.2 07-Jul-2001  perry branches: 1.2.4; 1.2.24;
b*()->mem*()
 1.1 15-May-1998  drochner branches: 1.1.28;
Framework to test standalone code in a friedly user environment.
 1.1.28.1 24-Aug-2001  nathanw Catch up with -current.
 1.2.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.24.1 03-Aug-2004  skrll Sync with HEAD
 1.2.4.2 07-Jul-2001  perry b*()->mem*()
 1.2.4.1 07-Jul-2001  perry file ether_bpf.c was added on branch sommerfeld_i386mp_1 on 2001-07-07 22:57:59 +0000
 1.3.16.2 07-Dec-2007  yamt sync with head
 1.3.16.1 03-Sep-2007  yamt sync with head.
 1.4.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.18.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.5.18.1 03-Sep-2007  jmcneill Sync with HEAD.
 1.5.14.1 03-Sep-2007  skrll Sync with HEAD.
 1.5.10.1 03-Oct-2007  garbled Sync with HEAD
 1.5.2.1 09-Oct-2007  ad Sync with head.
 1.6.2.2 09-Jan-2008  matt sync with HEAD
 1.6.2.1 06-Nov-2007  matt sync with HEAD
 1.7.4.1 08-Dec-2007  ad Sync with head.
 1.7.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.24.1 19-Jan-2009  skrll Sync with HEAD.
 1.9.16.1 04-May-2009  yamt sync with head.
 1.9.12.1 17-Jan-2009  mjf Sync with HEAD.
 1.5 29-Jun-2024  rin i386: stand: G/C `I386_INCLUDE_BUS`; only used by netboot
 1.4 14-Dec-2008  christos more KNF and ANSI from Anon-ymous
 1.3 11-Dec-2005  christos branches: 1.3.74; 1.3.78; 1.3.86;
merge ktrace-lwp.
 1.2 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.1 15-May-1998  drochner branches: 1.1.50;
Framework to test standalone code in a friedly user environment.
 1.1.50.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.50.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.50.1 03-Aug-2004  skrll Sync with HEAD
 1.3.86.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.3.74.1 17-Jan-2009  mjf Sync with HEAD.
 1.2 26-Mar-2014  christos kill sprintf.
 1.1 15-May-1998  drochner branches: 1.1.190; 1.1.200; 1.1.206;
Framework to test standalone code in a friedly user environment.
 1.1.206.1 18-May-2014  rmind sync with head
 1.1.200.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.190.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.6 14-Dec-2008  christos more KNF and ANSI from Anon-ymous
 1.5 04-Mar-2007  christos branches: 1.5.40; 1.5.44; 1.5.52;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.4 11-Dec-2005  christos branches: 1.4.26;
merge ktrace-lwp.
 1.3 24-Mar-2004  drochner branches: 1.3.16;
remove license clauses 3 and 4 from my cpoyright notices
 1.2 22-Nov-1998  drochner branches: 1.2.46;
Update for INT13 support.
XXX We can't easily emulate this here due to the 16-bit-pointer
call interface.
 1.1 15-May-1998  drochner Framework to test standalone code in a friedly user environment.
 1.2.46.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.46.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.46.1 03-Aug-2004  skrll Sync with HEAD
 1.3.16.1 03-Sep-2007  yamt sync with head.
 1.4.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.5.52.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.44.1 04-May-2009  yamt sync with head.
 1.5.40.1 17-Jan-2009  mjf Sync with HEAD.
 1.4 17-Aug-2011  jakllsch Add gptmbr from syslinux 4.04, with some local modifications to fit our mbr
build system and to be self contanined.

Also, unlink the old mbr_gpt from the build.
 1.3 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.2 19-Jan-2008  dsl branches: 1.2.24; 1.2.32;
Add two new versions of the mbr code that directly access a serial port.
'mbr_com0' assumes the BIOS has initialised the baud rate (etc)
'mbr_com0_9600' initialises the rate to 9600
Both have the functionality from 'mbr_ext' (ie they can boot from an
extended partition).
As compiled, the io_address for the serial port is taken from BIOS data.
(this should keep tls@ happy!)
 1.1 28-Apr-2003  dsl branches: 1.1.18; 1.1.80; 1.1.86; 1.1.94;
Master Boot Record (mbr) code:
mbr: boots active partition
mbr_bootsel: menu selection for partitions 1 to 4
mbr_ext: menu selection for partitions 1 to 4 and extended partitions
Based on code from sbin/fdisk/mbr_bootsel.
Needs a new fdisk to configure mbr_ext and correctly set default menu selection.(Not yet built by defaulat)
 1.1.94.1 20-Jan-2008  bouyer Sync with HEAD
 1.1.86.1 18-Feb-2008  mjf Sync with HEAD.
 1.1.80.1 23-Mar-2008  matt sync with HEAD
 1.1.18.1 21-Jan-2008  yamt sync with head
 1.2.32.1 05-Mar-2011  rmind sync with head
 1.2.24.2 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.2.24.1 10-Jan-2011  jym Sync with HEAD
 1.22 29-Jun-2024  rin i386: stand: G/C `mbr_gpt*`; unhooked since 2011 in prefer of `gptmbr`
 1.21 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.20 12-Jun-2018  kamil branches: 1.20.2;
Set NOSANITIZER in i386 mbr files

This is required to build these files and keep then functional with
enabled MKSANITIZER.

Sponsored by <The NetBSD Foundation>
 1.19 12-Jan-2014  tsutsui branches: 1.19.28;
Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.

XXX: probabry we should have bsd.saprog.mk or something.
 1.18 20-May-2011  joerg branches: 1.18.4; 1.18.14; 1.18.18;
mbr.S and gpt.S want to reassign ., so don't use the integrated
assembler for now.
 1.17 20-Nov-2009  dsl branches: 1.17.4; 1.17.6;
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.16 30-Mar-2009  tsutsui Remove extra trailing slash in ${S} path.
 1.15 12-Mar-2009  abs Prefer MACHINE_ARCH to MACHINE in some tests
 1.14 25-Oct-2008  apb branches: 1.14.2; 1.14.8;
Use ${TOOL_SED} instead if plain sed in Makefiles.
 1.13 20-Oct-2008  christos disable PIE for boot code.
 1.12 29-Jun-2006  lukem branches: 1.12.58; 1.12.62; 1.12.68;
support MAKEVERBOSE
 1.11 29-Jun-2006  lukem whitespace cleanup.
 1.10 29-Jun-2006  lukem Use BUILDSYMLINKS & DPSRCS to simplify the creation of includedir symlinks.
 1.9 25-Jun-2006  lukem Use -Wl,-Ttext,foo instead of -Ttext foo when using $(CC)
 1.8 12-May-2006  lukem branches: 1.8.4;
Convert to using CC instead of LD, as LDFLAGS is for CC not LD.
 1.7 11-Dec-2005  christos branches: 1.7.4; 1.7.6; 1.7.8; 1.7.12;
merge ktrace-lwp.
 1.6 01-May-2005  christos branches: 1.6.2;
.BEGIN cannot have dependencies.
 1.5 31-Aug-2004  uwe Force STRIPFLAG to be empty after bsd.own.mk is included, so that
any value set in /etc/mk.conf is overriden.
 1.4 01-Jul-2003  simonb branches: 1.4.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.3 05-May-2003  hubertf use nm(1) to output decimal values immediately, instead of relying on a
(non-working) sh(1) construct.

Reviewed by simonb & bjh21.
 1.2 05-May-2003  dbj force nm addresses in hex and add 0x prefix before handing numerical
expression to the shell.
 1.1 28-Apr-2003  dsl Master Boot Record (mbr) code:
mbr: boots active partition
mbr_bootsel: menu selection for partitions 1 to 4
mbr_ext: menu selection for partitions 1 to 4 and extended partitions
Based on code from sbin/fdisk/mbr_bootsel.
Needs a new fdisk to configure mbr_ext and correctly set default menu selection.(Not yet built by defaulat)
 1.4.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Sep-2004  skrll Sync with HEAD
 1.6.2.2 30-Dec-2006  yamt sync with head.
 1.6.2.1 21-Jun-2006  yamt sync with head.
 1.7.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.7.8.3 11-Aug-2006  yamt sync with head
 1.7.8.2 26-Jun-2006  yamt sync with head.
 1.7.8.1 24-May-2006  yamt sync with head.
 1.7.6.1 01-Jun-2006  kardel Sync with head.
 1.7.4.1 09-Sep-2006  rpaulo sync with head
 1.8.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.12.68.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.12.62.2 11-Mar-2010  yamt sync with head
 1.12.62.1 04-May-2009  yamt sync with head.
 1.12.58.1 17-Jan-2009  mjf Sync with HEAD.
 1.14.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.14.8.3 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.14.8.2 01-Nov-2009  jym Sync with HEAD.
 1.14.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.14.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.17.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.4.1 31-May-2011  rmind sync with head
 1.18.18.1 18-May-2014  rmind sync with head
 1.18.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.18.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.19.28.2 28-Jul-2018  pgoyette Sync with HEAD
 1.19.28.1 25-Jun-2018  pgoyette Sync with HEAD
 1.20.2.1 10-Jun-2019  christos Sync with HEAD
 1.4 29-Jun-2024  rin i386: stand: G/C `mbr_gpt*`; unhooked since 2011 in prefer of `gptmbr`
 1.3 19-May-2018  jakllsch Fix some whitespace style issues.
 1.2 19-May-2018  jakllsch Compact crc32 code by 12 bytes of text.

From dave0 in #NetBSD on Freenode circa December 2017.

Tested in a 32-bit userland harness to produce identical results as old
code for one set of inputs.
 1.1 06-Jan-2011  jakllsch branches: 1.1.6; 1.1.8; 1.1.62;
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.1.62.1 21-May-2018  pgoyette Sync with HEAD
 1.1.8.2 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.1.8.1 06-Jan-2011  jym file gpt.S was added on branch jym-xensuspend on 2011-03-29 20:42:59 +0000
 1.1.6.2 05-Mar-2011  rmind sync with head
 1.1.6.1 06-Jan-2011  rmind file gpt.S was added on branch rmind-uvmplock on 2011-03-05 20:50:46 +0000
 1.2 17-Feb-2018  joerg Drop explicit loop prefix. GAS doesn't care and LLVM doesn't support it.
Drop the need for assembling with GAS. While LLVM is using a suboptimal
encoding of for hard-coded memory writes, it shouldn't affect
functionality. It just wastes three bytes with extra prefixes.
 1.1 17-Aug-2011  jakllsch branches: 1.1.2;
Add gptmbr from syslinux 4.04, with some local modifications to fit our mbr
build system and to be self contanined.

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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


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

Put the 'mbr has bootselect table' marker into all versions of the mbr code.
Having the table in the 'standard' mbr allows fdisk to write in bootsel
menu items and only ask about updating the mbr code before exit.
Sysinst validates that the mbr code contains the bootselect table for
all the mbr code variants it reads - because it might want to write the table
and doesn't really want to make the validation dependant on what it is
going to do later.
Fixes install/25235, but sysinst needs some changes (like reporting the
failure to write the mbr) before the pr itself is closed.
 1.12.12.4 11-Feb-2008  yamt sync with head.
 1.12.12.3 04-Feb-2008  yamt sync with head.
 1.12.12.2 21-Jan-2008  yamt sync with head
 1.12.12.1 03-Sep-2007  yamt sync with head.
 1.13.32.1 11-Jul-2007  mjf Sync with head.
 1.13.30.1 27-May-2007  ad Sync with head.
 1.13.26.1 15-Apr-2007  yamt sync with head.
 1.14.26.2 20-Jan-2008  bouyer Sync with HEAD
 1.14.26.1 08-Jan-2008  bouyer Sync with HEAD
 1.14.20.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.14.1 23-Mar-2008  matt sync with HEAD
 1.18.10.3 11-Mar-2010  yamt sync with head
 1.18.10.2 04-May-2009  yamt sync with head.
 1.18.10.1 16-May-2008  yamt sync with head.
 1.18.8.1 18-May-2008  yamt sync with head.
 1.18.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.18.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.19.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.19.6.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.20.4.2 10-Jan-2011  jym Sync with HEAD
 1.20.4.1 24-Oct-2010  jym Sync with HEAD
 1.22.4.1 05-Mar-2011  rmind sync with head
 1.4 17-Feb-2018  joerg Drop explicit loop prefix. GAS doesn't care and LLVM doesn't support it.
Drop the need for assembling with GAS. While LLVM is using a suboptimal
encoding of for hard-coded memory writes, it shouldn't affect
functionality. It just wastes three bytes with extra prefixes.
 1.3 21-Sep-2011  jakllsch Set LOADADDR to 0x600, matches how gptmbr.bin is compiled upstream.
This should let this actually work.
 1.2 17-Aug-2011  joerg branches: 1.2.2;
.code16 user, so disable integrated assembler with clang for now.
 1.1 17-Aug-2011  jakllsch Add gptmbr from syslinux 4.04, with some local modifications to fit our mbr
build system and to be self contanined.

Also, unlink the old mbr_gpt from the build.
 1.2.2.2 27-Aug-2011  jym Add/remove files, like in HEAD.
 1.2.2.1 17-Aug-2011  jym file Makefile was added on branch jym-xensuspend on 2011-08-27 15:59:49 +0000
 1.3 18-Nov-2009  dsl Reinstate the banner.
This was added to detect problems when the mbr code gets written into the pbr.
(When the code loops reading the pbr!)
It is also a useful diagnosting that the boot it proceeding normally.
 1.2 30-Apr-2008  ad branches: 1.2.14;
Tidy up console output slightly.
 1.1 28-Apr-2003  dsl branches: 1.1.104; 1.1.106; 1.1.108;
Master Boot Record (mbr) code:
mbr: boots active partition
mbr_bootsel: menu selection for partitions 1 to 4
mbr_ext: menu selection for partitions 1 to 4 and extended partitions
Based on code from sbin/fdisk/mbr_bootsel.
Needs a new fdisk to configure mbr_ext and correctly set default menu selection.(Not yet built by defaulat)
 1.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 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 28-Apr-2003  dsl branches: 1.1.2;
Master Boot Record (mbr) code:
mbr: boots active partition
mbr_bootsel: menu selection for partitions 1 to 4
mbr_ext: menu selection for partitions 1 to 4 and extended partitions
Based on code from sbin/fdisk/mbr_bootsel.
Needs a new fdisk to configure mbr_ext and correctly set default menu selection.(Not yet built by defaulat)
 1.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.1 19-Jan-2008  dsl branches: 1.1.2; 1.1.4; 1.1.12;
Add two new versions of the mbr code that directly access a serial port.
'mbr_com0' assumes the BIOS has initialised the baud rate (etc)
'mbr_com0_9600' initialises the rate to 9600
Both have the functionality from 'mbr_ext' (ie they can boot from an
extended partition).
As compiled, the io_address for the serial port is taken from BIOS data.
(this should keep tls@ happy!)
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 19-Jan-2008  matt file Makefile was added on branch matt-armv6 on 2008-03-23 02:04:08 +0000
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 19-Jan-2008  mjf file Makefile was added on branch mjf-devfs on 2008-02-18 21:04:41 +0000
 1.1.2.2 21-Jan-2008  yamt sync with head
 1.1.2.1 19-Jan-2008  yamt file Makefile was added on branch yamt-lazymbuf on 2008-01-21 09:37:16 +0000
 1.1 19-Jan-2008  dsl branches: 1.1.2; 1.1.4; 1.1.12;
Add two new versions of the mbr code that directly access a serial port.
'mbr_com0' assumes the BIOS has initialised the baud rate (etc)
'mbr_com0_9600' initialises the rate to 9600
Both have the functionality from 'mbr_ext' (ie they can boot from an
extended partition).
As compiled, the io_address for the serial port is taken from BIOS data.
(this should keep tls@ happy!)
 1.1.12.2 23-Mar-2008  matt sync with HEAD
 1.1.12.1 19-Jan-2008  matt file Makefile was added on branch matt-armv6 on 2008-03-23 02:04:08 +0000
 1.1.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.1.4.1 19-Jan-2008  mjf file Makefile was added on branch mjf-devfs on 2008-02-18 21:04:41 +0000
 1.1.2.2 21-Jan-2008  yamt sync with head
 1.1.2.1 19-Jan-2008  yamt file Makefile was added on branch yamt-lazymbuf on 2008-01-21 09:37:16 +0000
 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 28-Apr-2003  dsl branches: 1.1.2;
Master Boot Record (mbr) code:
mbr: boots active partition
mbr_bootsel: menu selection for partitions 1 to 4
mbr_ext: menu selection for partitions 1 to 4 and extended partitions
Based on code from sbin/fdisk/mbr_bootsel.
Needs a new fdisk to configure mbr_ext and correctly set default menu selection.(Not yet built by defaulat)
 1.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.12 23-Sep-2019  christos Consistently use ${RELEASEDIR}/${RELEASEMACHINE} instead of
${RELEASEDIR}/${MACHINE} (Paul Ripke)
 1.11 27-Jan-2019  dholland fix duplicated chunk from merge
 1.10 27-Jan-2019  pgoyette Merge the [pgoyette-compat] branch
 1.9 26-Jun-2018  martin branches: 1.9.2;
Remove Rawrite32 installer - no point having an outdated version on
some install media, the windows machine it needs to run on will
have internet and can easily download it.
 1.8 01-May-2018  christos Create a new bsd.hostinit.mk file and put the build definitions for all host
programs there; make all Makefiles that use bsd.hostprog.mk include it.
Namely turn off MKREPRO and don't make lint, man pages, info files etc.
Remove the Makefile.inc files that contained these same settings, and
remove the settings from Makefile.host
 1.7 27-Oct-2010  martin branches: 1.7.34; 1.7.52; 1.7.58;
Update Rawrite32 to the latest version
 1.6 11-Dec-2005  christos branches: 1.6.88; 1.6.92; 1.6.96; 1.6.98; 1.6.100;
merge ktrace-lwp.
 1.5 03-Apr-2004  groo Let's try that again... one comes from .CURDIR, another set of files
comes from .OBJDIR.
 1.4 03-Apr-2004  groo Don't cd ${.CURDIR}, it's not where the uudecoded objects are.
 1.3 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.2 03-Jan-2003  lukem branches: 1.2.2; 1.2.4;
Install release files under "${RELEASEDIR}/${MACHINE}/..." instead of
"${RELEASEDIR}/...".

${RELEASEDIR} is never cleaned , and ${RELEASEDIR}/${MACHINE} is only
cleaned if UPDATE is not defined.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file Makefile was added on branch kqueue on 2002-06-23 17:37:33 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file Makefile was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:00 +0000
 1.1.2.3 07-Jan-2003  thorpej Sync with HEAD.
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file Makefile was added on branch nathanw_sa on 2002-04-17 00:03:25 +0000
 1.2.4.2 05-Apr-2004  tron Pull up revision 1.5 (requested by groo in ticket #58):
Let's try that again... one comes from .CURDIR, another set of files
comes from .OBJDIR.
 1.2.4.1 02-Apr-2004  tron Pull up revision 1.3 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.100.1 05-Mar-2011  rmind sync with head
 1.6.98.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.6.96.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.6.92.1 10-Jan-2011  jym Sync with HEAD
 1.6.88.1 05-Nov-2010  snj Pull up following revision(s) (requested by martin in ticket #1465):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.1
sys/arch/i386/stand/misc/Makefile: revision 1.7
sys/arch/i386/stand/misc/rawr32src.zip.uue: file removal
sys/arch/i386/stand/misc/rawr32.zip.uue: file removal
Update Rawrite32 to the latest version
 1.7.58.2 28-Jul-2018  pgoyette Sync with HEAD
 1.7.58.1 02-May-2018  pgoyette Synch with HEAD
 1.7.52.1 29-Mar-2020  martin Remove outdated Rawrite32 copy
 1.7.34.1 07-Aug-2018  martin Pull up following revision(s) (requested by martin in ticket #1623):

sys/arch/i386/stand/misc/rawr32.exe.uue: file removal
sys/arch/i386/stand/misc/Makefile: revision 1.9

Remove Rawrite32 installer - no point having an outdated version on
some install media, the windows machine it needs to run on will
have internet and can easily download it.
 1.9.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.9.2.1 10-Jun-2019  christos Sync with HEAD
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file pfdisk.doc.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file pfdisk.doc.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file pfdisk.exe.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file pfdisk.exe.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file pfdisk.gze was added on branch kqueue on 2002-06-23 17:37:33 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file pfdisk.gze was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:00 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file pfdisk.gze was added on branch nathanw_sa on 2002-04-17 00:03:26 +0000
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file pfdisk.txt was added on branch kqueue on 2002-06-23 17:37:33 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file pfdisk.txt was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:00 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file pfdisk.txt was added on branch nathanw_sa on 2002-04-17 00:03:26 +0000
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file pfdisktc.zip was added on branch kqueue on 2002-06-23 17:37:34 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file pfdisktc.zip was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:01 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file pfdisktc.zip was added on branch nathanw_sa on 2002-04-17 00:03:26 +0000
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file pfdisktc.zip.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file pfdisktc.zip.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.8 26-Jun-2018  martin Remove Rawrite32 installer - no point having an outdated version on
some install media, the windows machine it needs to run on will
have internet and can easily download it.
 1.7 02-Jun-2017  martin branches: 1.7.2; 1.7.8;
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.6 23-May-2016  martin New Rawrite32 release
 1.5 03-Feb-2016  martin New rawrite32 version out (small bugfixes)
 1.4 27-Nov-2011  martin branches: 1.4.4; 1.4.8; 1.4.10; 1.4.18; 1.4.24; 1.4.26; 1.4.28;
New Rawrite32 release is out.
 1.3 28-Oct-2011  martin branches: 1.3.2;
Update to version 1.0.2.2
 1.2 22-Sep-2011  martin Update Rawrite32 to latests version
 1.1 27-Oct-2010  martin branches: 1.1.2; 1.1.4; 1.1.10; 1.1.12;
Update Rawrite32 to the latest version
 1.1.12.2 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.1.12.1 27-Oct-2010  matt file rawr32.exe.uue was added on branch matt-nb5-mips64 on 2011-05-20 08:11:22 +0000
 1.1.10.2 05-Mar-2011  rmind sync with head
 1.1.10.1 27-Oct-2010  rmind file rawr32.exe.uue was added on branch rmind-uvmplock on 2011-03-05 20:50:47 +0000
 1.1.4.2 06-Nov-2010  uebayasi Sync with HEAD.
 1.1.4.1 27-Oct-2010  uebayasi file rawr32.exe.uue was added on branch uebayasi-xip on 2010-11-06 08:08:19 +0000
 1.1.2.2 05-Nov-2010  snj Pull up following revision(s) (requested by martin in ticket #1465):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.1
sys/arch/i386/stand/misc/Makefile: revision 1.7
sys/arch/i386/stand/misc/rawr32src.zip.uue: file removal
sys/arch/i386/stand/misc/rawr32.zip.uue: file removal
Update Rawrite32 to the latest version
 1.1.2.1 27-Oct-2010  snj file rawr32.exe.uue was added on branch netbsd-5 on 2010-11-05 07:33:46 +0000
 1.3.2.1 17-Apr-2012  yamt sync with head
 1.4.28.2 03-Jun-2017  snj Pull up following revision(s) (requested by matin in ticket #1426):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.4.28.1 22-Jun-2016  snj Pull up following revision(s) (requested by martin in ticket #1172):
sys/arch/i386/stand/misc/rawr32.exe.uue: up to revision 1.6
New Rawrite32 release
 1.4.26.3 28-Aug-2017  skrll Sync with HEAD
 1.4.26.2 29-May-2016  skrll Sync with HEAD
 1.4.26.1 19-Mar-2016  skrll Sync with HEAD
 1.4.24.3 07-Aug-2018  martin Pull up following revision(s) (requested by martin in ticket #1623):

sys/arch/i386/stand/misc/rawr32.exe.uue: file removal
sys/arch/i386/stand/misc/Makefile: revision 1.9

Remove Rawrite32 installer - no point having an outdated version on
some install media, the windows machine it needs to run on will
have internet and can easily download it.
 1.4.24.2 03-Jun-2017  snj Pull up following revision(s) (requested by matin in ticket #1426):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.4.24.1 22-Jun-2016  snj branches: 1.4.24.1.4;
Pull up following revision(s) (requested by martin in ticket #1172):
sys/arch/i386/stand/misc/rawr32.exe.uue: up to revision 1.6
New Rawrite32 release
 1.4.24.1.4.1 03-Jun-2017  snj Pull up following revision(s) (requested by matin in ticket #1426):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.4.18.2 03-Jun-2017  snj Pull up following revision(s) (requested by martin in ticket #1454):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.4.18.1 28-Aug-2016  bouyer Pull up following revision(s) (requested by martin in ticket #1385):
sys/arch/i386/stand/misc/rawr32.exe.uue: sync to revision 1.6
New Rawrite32 release
 1.4.10.2 03-Jun-2017  snj Pull up following revision(s) (requested by martin in ticket #1454):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.4.10.1 28-Aug-2016  bouyer Pull up following revision(s) (requested by martin in ticket #1385):
sys/arch/i386/stand/misc/rawr32.exe.uue: sync to revision 1.6
New Rawrite32 release
 1.4.8.1 03-Dec-2017  jdolecek update from HEAD
 1.4.4.2 03-Jun-2017  snj Pull up following revision(s) (requested by martin in ticket #1454):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.7
Update to rawrite32 1.0.5 (new signatures to avoid scary windows
warnings)
 1.4.4.1 28-Aug-2016  bouyer Pull up following revision(s) (requested by martin in ticket #1385):
sys/arch/i386/stand/misc/rawr32.exe.uue: sync to revision 1.6
New Rawrite32 release
 1.7.8.1 28-Jul-2018  pgoyette Sync with HEAD
 1.7.2.1 29-Mar-2020  martin Remove outdated Rawrite32 copy
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file rawr32.zip was added on branch kqueue on 2002-06-23 17:37:34 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file rawr32.zip was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:01 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file rawr32.zip was added on branch nathanw_sa on 2002-04-17 00:03:26 +0000
 1.2 27-Oct-2010  martin Update Rawrite32 to the latest version
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4; 1.1.114; 1.1.118; 1.1.122; 1.1.124; 1.1.126;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.126.1 05-Mar-2011  rmind sync with head
 1.1.124.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.1.122.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.1.118.1 10-Jan-2011  jym Sync with HEAD
 1.1.114.1 05-Nov-2010  snj Pull up following revision(s) (requested by martin in ticket #1465):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.1
sys/arch/i386/stand/misc/Makefile: revision 1.7
sys/arch/i386/stand/misc/rawr32src.zip.uue: file removal
sys/arch/i386/stand/misc/rawr32.zip.uue: file removal
Update Rawrite32 to the latest version
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file rawr32.zip.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file rawr32.zip.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file rawr32src.zip was added on branch kqueue on 2002-06-23 17:37:34 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file rawr32src.zip was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:01 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file rawr32src.zip was added on branch nathanw_sa on 2002-04-17 00:03:26 +0000
 1.2 27-Oct-2010  martin Update Rawrite32 to the latest version
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4; 1.1.114; 1.1.118; 1.1.122; 1.1.124; 1.1.126;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.126.1 05-Mar-2011  rmind sync with head
 1.1.124.1 06-Nov-2010  uebayasi Sync with HEAD.
 1.1.122.1 20-May-2011  matt bring matt-nb5-mips64 up to date with netbsd-5-1-RELEASE (except compat).
 1.1.118.1 10-Jan-2011  jym Sync with HEAD
 1.1.114.1 05-Nov-2010  snj Pull up following revision(s) (requested by martin in ticket #1465):
sys/arch/i386/stand/misc/rawr32.exe.uue: revision 1.1
sys/arch/i386/stand/misc/Makefile: revision 1.7
sys/arch/i386/stand/misc/rawr32src.zip.uue: file removal
sys/arch/i386/stand/misc/rawr32.zip.uue: file removal
Update Rawrite32 to the latest version
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file rawr32src.zip.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file rawr32src.zip.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.3 07-Mar-2007  thorpej TRUE -> true, FALSE -> false
 1.2 14-Apr-2003  dsl branches: 1.2.18; 1.2.56;
avoid calling toupper with posibly -ve value. fixes PR 21171
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file rawrite.c was added on branch kqueue on 2002-06-23 17:37:34 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file rawrite.c was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:01 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file rawrite.c was added on branch nathanw_sa on 2002-04-17 00:03:27 +0000
 1.2.56.1 12-Mar-2007  rmind Sync with HEAD.
 1.2.18.1 03-Sep-2007  yamt sync with head.
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file rawrite.doc.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file rawrite.doc.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.1 02-Apr-2004  lukem branches: 1.1.2; 1.1.4;
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 02-Apr-2004  skrll file rawrite.exe.uue was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.1.2.2 02-Apr-2004  tron Pull up revision 1.1 (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.2.1 02-Apr-2004  tron file rawrite.exe.uue was added on branch netbsd-2-0 on 2004-04-02 14:03:02 +0000
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file rawrite.gze was added on branch kqueue on 2002-06-23 17:37:34 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file rawrite.gze was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:01 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file rawrite.gze was added on branch nathanw_sa on 2002-04-17 00:03:27 +0000
 1.2 02-Apr-2004  lukem Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1 12-Apr-2002  tv branches: 1.1.2; 1.1.4; 1.1.10; 1.1.16; 1.1.18;
Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.18.1 02-Apr-2004  tron Pull up file removal (requested by lukem in ticket #47):
Convert to using UUDECODE_FILES instead of using -kb in the repository.
 1.1.16.1 03-Aug-2004  skrll Sync with HEAD
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 12-Apr-2002  jdolecek file rawrite.txt was added on branch kqueue on 2002-06-23 17:37:34 +0000
 1.1.4.2 12-Apr-2002  tv Add host-OS tools for i386, which end up in the "installation/misc"
directory of the release tree.
 1.1.4.1 12-Apr-2002  tv file rawrite.txt was added on branch sommerfeld_i386mp_1 on 2002-04-12 23:12:02 +0000
 1.1.2.2 17-Apr-2002  nathanw Catch up to -current.
 1.1.2.1 12-Apr-2002  nathanw file rawrite.txt was added on branch nathanw_sa on 2002-04-17 00:03:27 +0000
 1.30 29-Jun-2024  rin i386: stand: Tiny clean up for `start_pxeboot.o`, NFC
 1.29 29-Jun-2024  rin i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.28 27-Sep-2019  gson branches: 1.28.26;
Incrase pxeboot code size limit from 64k to 128k. Fixes PR kern/54560.
The start_pxe.S part was suggested by mlelstv.
 1.27 23-Sep-2019  christos Consistently use ${RELEASEDIR}/${RELEASEMACHINE} instead of
${RELEASEDIR}/${MACHINE} (Paul Ripke)
 1.26 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.25 02-Jun-2018  christos branches: 1.25.2; 1.25.6;
- Disable MKSANITIZER
- Redo using NOPIE
- Add NORELRO
 1.24 23-Jan-2016  christos branches: 1.24.10; 1.24.16;
We'll define the kernel types for standalone code.
 1.23 23-Jan-2016  christos Define _KERNTYPES for things that need it.
 1.22 15-Jan-2014  joerg branches: 1.22.6;
Reduce amount of -no-integrated-as on x86 as .code16 is now supported by
LLVM.
 1.21 20-May-2011  joerg branches: 1.21.4; 1.21.14; 1.21.18;
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.20 17-Jan-2010  drochner branches: 1.20.4; 1.20.6;
fix tyop in default flag definition
 1.19 17-Jan-2010  drochner 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.18 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.17 30-Mar-2009  tsutsui Remove extra trailing slash in ${S} path.
 1.16 14-Feb-2009  abs Convert more MACHINE tests to MACHINE_ARCH
 1.15 20-Oct-2008  christos branches: 1.15.2; 1.15.8;
disable PIE for boot code.
 1.14 27-Feb-2007  he branches: 1.14.40; 1.14.44; 1.14.50;
Install pxeboot_ia32.bin as part of a "make release" on i386 and amd64.
 1.13 04-Oct-2006  salo branches: 1.13.2; 1.13.4;
Fix ypo. (hi abs!)

Noticed at #NetBSD-code.
 1.12 22-Sep-2006  abs Enable EPIA_HACK here too - http://mail-index.netbsd.org/port-i386/2006/08/18/0002.html
 1.11 25-Jun-2006  lukem branches: 1.11.4; 1.11.6;
Use LDFLAGS (with $(CC) syntax) instead of appending to LD.
 1.10 12-May-2006  mrg branches: 1.10.4;
- -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.9 11-Nov-2005  dsl branches: 1.9.6; 1.9.8; 1.9.10; 1.9.14;
Take the console (etc) parameters from the patchable header, instead of
hard-coded constants.
Now the updated installboot can be used to modify the console and baud rate.
 1.8 21-Aug-2005  chs copy some settings from ../boot/Makefile.boot that let us try to load
64-bit kernels on amd64.
 1.7 05-Aug-2004  dbj branches: 1.7.10; 1.7.12;
fix several related bugs that cause sysctl machdep.diskinfo to
lose when booted from pxeboot.
. make sure that i386_alldisks gets initialized even if
bios geometry information is not available in the bootinfo
. if i386_alldisks is not initialized, have sysctl return EOPNOTSUPP
. compile pxeboot with -DPASS_BIOSGEOM and I386_INCLUDE_DISK=yes
this may increase the size of pxeboot which is required to run
in 64k. However, it seems to be working ok on my system
 1.6 01-Apr-2003  mycroft branches: 1.6.2; 1.6.4;
Add -DSLOW to reduce the size of libz a bit.
 1.5 11-Mar-2003  drochner use our own NFS fs implementation, which is smaller, does a better job
in error reporting and coexists with the TFTP fs
 1.4 24-Nov-2002  lukem use NOMAN instead of MKMAN=no. noted by David Bonnafous on port-i386@
 1.3 20-Feb-2002  thorpej branches: 1.3.2; 1.3.4; 1.3.16;
* Rename the pxeboot binary from "pxeboot" to "pxeboot_ia32", since
there are other architectures (e.g. IA64) which also use PXE.
* Get the console right in pxeboot, from Andreas Gustafsson.
* Add a "com0" version of pxeboot, to address the same issue that
biosboot_com0 addresses.
 1.2 17-Feb-2002  thorpej Cleanup of i386 bootloader building:
* Add separate directories for the individual netboot ROMs and
always build them.
* Each bootloader Makefile explicitly specifies the start file
and link address it wishes to use.
* genprom becomes a proper host program.
* Make sure all generated files get cleaned up.
* Set BINDIR in Makefile.inc
* Add compressed image support to pxeboot.
* Make pxeboot use the default serial console speed (9600).
 1.1 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.3.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.16.1 20-Feb-2002  jdolecek file Makefile was added on branch kqueue on 2002-06-23 17:37:35 +0000
 1.3.4.3 11-Dec-2002  thorpej Sync with HEAD.
 1.3.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.1 20-Feb-2002  nathanw file Makefile was added on branch nathanw_sa on 2002-02-28 04:10:29 +0000
 1.3.2.2 20-Feb-2002  thorpej * Rename the pxeboot binary from "pxeboot" to "pxeboot_ia32", since
there are other architectures (e.g. IA64) which also use PXE.
* Get the console right in pxeboot, from Andreas Gustafsson.
* Add a "com0" version of pxeboot, to address the same issue that
biosboot_com0 addresses.
 1.3.2.1 20-Feb-2002  thorpej file Makefile was added on branch sommerfeld_i386mp_1 on 2002-02-20 03:00:28 +0000
 1.6.4.1 16-Aug-2004  jmc Pullup rev 1.7 (requested by dbj in ticket #767)

Add support to pxeboot for reading the bios disk geometry
as well as fixing several related bugs that occur when the bios
geometry is not read by the boot loader.
 1.6.2.5 11-Dec-2005  christos Sync with head.
 1.6.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.2.1 12-Aug-2004  skrll Sync with HEAD.
 1.7.12.3 03-Sep-2007  yamt 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.7.10.1 15-Sep-2005  tron Pull up following revision(s) (requested by chs in ticket #783):
sys/arch/i386/stand/pxeboot/Makefile: revision 1.8
copy some settings from ../boot/Makefile.boot that let us try to load
64-bit kernels on amd64.
 1.9.14.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.10.2 26-Jun-2006  yamt sync with head.
 1.9.10.1 24-May-2006  yamt sync with head.
 1.9.8.1 01-Jun-2006  kardel Sync with head.
 1.9.6.1 09-Sep-2006  rpaulo sync with head
 1.10.4.1 13-Jul-2006  gdamore Merge from HEAD.
 1.11.6.1 22-Oct-2006  yamt sync with head
 1.11.4.1 18-Nov-2006  ad Sync with head.
 1.13.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.2.1 04-Mar-2007  bouyer Pull up following revision(s) (requested by he in ticket #469):
sys/arch/i386/stand/pxeboot/Makefile: revision 1.14
etc/etc.amd64/Makefile.inc: revision 1.6
etc/etc.i386/Makefile.inc: revision 1.48
Install pxeboot_ia32.bin as part of a "make release" on i386 and amd64.
 1.14.50.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.14.44.2 11-Mar-2010  yamt sync with head
 1.14.44.1 04-May-2009  yamt sync with head.
 1.14.40.1 17-Jan-2009  mjf Sync with HEAD.
 1.15.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.15.8.3 29-Mar-2011  jym More sync fixes. And add the mbr_gpt files.
 1.15.8.2 01-Nov-2009  jym Sync with HEAD.
 1.15.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.2.2 28-Apr-2009  skrll Sync with HEAD.
 1.15.2.1 03-Mar-2009  skrll Sync with HEAD.
 1.20.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.20.4.1 31-May-2011  rmind sync with head
 1.21.18.1 18-May-2014  rmind sync with head
 1.21.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.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.22.6.1 19-Mar-2016  skrll Sync with HEAD
 1.24.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.24.10.2 04-Oct-2019  martin Pull up following revision(s) (requested by manu in ticket #1400):

sys/arch/i386/stand/pxeboot/start_pxe.S: revision 1.7
sys/arch/i386/stand/pxeboot/Makefile: revision 1.28

Incrase pxeboot code size limit from 64k to 128k. Fixes PR kern/54560.
The start_pxe.S part was suggested by mlelstv.
 1.24.10.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.25.6.2 03-Oct-2019  martin Pull up following revision(s) (requested by manu in ticket #277):

sys/arch/i386/stand/pxeboot/start_pxe.S: revision 1.7
sys/arch/i386/stand/pxeboot/Makefile: revision 1.28

Incrase pxeboot code size limit from 64k to 128k. Fixes PR kern/54560.
The start_pxe.S part was suggested by mlelstv.
 1.25.6.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.25.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.28.26.1 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.5 11-Dec-2005  christos merge ktrace-lwp.
 1.4 28-Jun-2005  junyoung #include <lib/libsa/stand.h> rather than <stand.h> or "stand.h"
 1.3 23-Jun-2005  junyoung Use FS_OPS() macro.
 1.2 12-Mar-2003  drochner branches: 1.2.2;
kick out mi libsa/netif.c references
 1.1 16-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.16;
Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Feb-2002  jdolecek file conf.c was added on branch kqueue on 2002-06-23 17:37:35 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file conf.c was added on branch nathanw_sa on 2002-02-28 04:10:29 +0000
 1.1.2.2 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.2.1 16-Feb-2002  thorpej file conf.c was added on branch sommerfeld_i386mp_1 on 2002-02-16 03:37:41 +0000
 1.2.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.11 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.10 13-Dec-2009  jakllsch Shut down the PXE network stack when we are done with it.

This fixes an issue where a CK804 nfe(4) would have a
byte-reversed MAC address after pxeboot(8).
 1.9 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.8 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.7 11-May-2008  chris branches: 1.7.6; 1.7.12;
Add support to pxeboot to allow the loading of modules. Changes to main.c
are taken from boot/boot2.c.

This allows an install to be started by running:
load tftp:miniroot.kmod
boot tftp:netbsd-GENERIC

Note that the change to dev_net.c to comment out the network shutdown,
suggests we need to hook the network shutdown in the the common exec code.
If the network is shutdown, it fails to reinitialise and so fails to load
the module.
 1.6 28-Apr-2008  martin branches: 1.6.2;
Remove clause 3 and 4 from TNF licenses
 1.5 12-Mar-2003  drochner branches: 1.5.104; 1.5.106; 1.5.108;
-use our own netif layer
-call the pxe unload function only on close(), not on open() errors,
so we have a chance to retry
-remove some remaining references to NFS
 1.4 12-Mar-2003  drochner cleanup:
-update comments
-remove remaining references to "bootparam"
-don't try to interpret extra arguments to net_open() - we
get only passed a NULL anyway (see devopen.c)
 1.3 11-Mar-2003  drochner kick out RARP/bootparam - PXE uses BOOTP anyway
 1.2 11-Mar-2003  drochner use our own NFS fs implementation, which is smaller, does a better job
in error reporting and coexists with the TFTP fs
 1.1 16-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.16;
Need private copies of these files for now.
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Feb-2002  jdolecek file dev_net.c was added on branch kqueue on 2002-06-23 17:37:35 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file dev_net.c was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.1.2.2 16-Feb-2002  thorpej Need private copies of these files for now.
 1.1.2.1 16-Feb-2002  thorpej file dev_net.c was added on branch sommerfeld_i386mp_1 on 2002-02-16 16:26:24 +0000
 1.5.108.3 11-Mar-2010  yamt sync with head
 1.5.108.2 04-May-2009  yamt sync with head.
 1.5.108.1 16-May-2008  yamt sync with head.
 1.5.106.1 18-May-2008  yamt sync with head.
 1.5.104.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.7.12.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.7.12.3 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.7.12.2 01-Nov-2009  jym Sync with HEAD.
 1.7.12.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.6.1 28-Apr-2009  skrll Sync with HEAD.
 1.2 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.1 16-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.16; 1.1.128; 1.1.136; 1.1.142;
Need private copies of these files for now.
 1.1.142.2 01-Nov-2009  jym Sync with HEAD.
 1.1.142.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.136.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.128.1 04-May-2009  yamt sync with head.
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Feb-2002  jdolecek file dev_net.h was added on branch kqueue on 2002-06-23 17:37:35 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file dev_net.h was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.1.2.2 16-Feb-2002  thorpej Need private copies of these files for now.
 1.1.2.1 16-Feb-2002  thorpej file dev_net.h was added on branch sommerfeld_i386mp_1 on 2002-02-16 16:26:24 +0000
 1.9 26-Oct-2009  cegger kill extra whitespaces
reviewed by tsutsui@
 1.8 18-Mar-2009  cegger bcopy -> memcpy
 1.7 11-Dec-2005  christos branches: 1.7.78; 1.7.86; 1.7.92;
merge ktrace-lwp.
 1.6 28-Jun-2005  junyoung #include <lib/libsa/stand.h> rather than <stand.h> or "stand.h"
 1.5 12-Nov-2003  drochner Uhm - the last change broke everything but very simple setups.
(it only allowed to boot an nfs /netbsd automatically)
To make it work for people who can't tell the DHCP server to pass
the right kernel file to pxeboot, without losing flexibility for
people who can, do the following:
Use the filename given by the DHCP server if it contains a ":". A ":"
was already used to seperate filesystem and filename, so we don't
lose anything. Otoh, a path to pxeboot usually doesn't contain a ":",
so it should still work if we got the old pxeboot filename again.
 1.4 05-Nov-2003  mycroft So, on other platforms we use the BOOTP/DHCP file name for the boot program
and use a default file name of "netbsd" for the kernel. Do the same thing
here, as it hardly makes sense any other way.
 1.3 11-Mar-2003  drochner branches: 1.3.2;
If we get passed a filename (from the command line or default "netbsd"),
pass it to the BOOTP server in the "filename" field.
(as the "netboot" bootROMs already did)
So the user can easily switch between different kernels/configurations.
 1.2 17-Feb-2002  thorpej branches: 1.2.2; 1.2.4; 1.2.16;
Pay attention to the file name provided by the DHCP server, using
it rather than the default of "netbsd" if it's in the reply.
 1.1 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.2.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.16.1 17-Feb-2002  jdolecek file devopen.c was added on branch kqueue on 2002-06-23 17:37:35 +0000
 1.2.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.2.4.1 17-Feb-2002  nathanw file devopen.c was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.2.2.2 17-Feb-2002  thorpej Pay attention to the file name provided by the DHCP server, using
it rather than the default of "netbsd" if it's in the reply.
 1.2.2.1 17-Feb-2002  thorpej file devopen.c was added on branch sommerfeld_i386mp_1 on 2002-02-17 20:14:09 +0000
 1.3.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 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.7.92.2 01-Nov-2009  jym Sync with HEAD.
 1.7.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.78.2 11-Mar-2010  yamt sync with head
 1.7.78.1 04-May-2009  yamt sync with head.
 1.35 06-May-2025  pgoyette Allow the dev= command when processing /boot.cfg file. This
addresses kern/59207
 1.34 10-Nov-2024  riastradh i386/pxeboot: Nix trailing whitespace.

No functional change intended.
 1.33 09-Nov-2024  mlelstv Support baudrate in consdev command.
 1.32 07-Sep-2021  nia branches: 1.32.10;
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.31 28-Jun-2014  rtr 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.30 06-Mar-2013  yamt branches: 1.30.10;
update help
 1.29 26-May-2011  uebayasi branches: 1.29.4; 1.29.14;
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.28 18-Mar-2011  jakllsch Honor bp_timeout even when X86_BP_FLAGS_NOBOOTCONF is set.
Or, in other words, bring back the 5 second countdown in pxeboot(8).
 1.27 20-Dec-2010  jakllsch branches: 1.27.2;
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.26 06-Nov-2010  jym Bring the help command output from boot and pxeboot on par with their
code.
 1.25 06-Apr-2010  tnn Add multiboot command. This lets us netboot the xen+dom0 kernel combo.
 1.24 17-Jan-2010  drochner branches: 1.24.2; 1.24.4;
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.23 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.22 13-Dec-2009  jakllsch Shut down the PXE network stack when we are done with it.

This fixes an issue where a CK804 nfe(4) would have a
byte-reversed MAC address after pxeboot(8).
 1.21 14-Sep-2009  jmcneill Don't commit the selected VBE mode until the loader is past the point of
no return; need to stick in text mode as long as possible since libsa does
not include a rasops library. While here, add the 'vesa' command to pxeboot
to mirror biosboot behaviour.
 1.20 21-Mar-2009  ad Fix 'boot -z' bogons.
 1.19 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 30-Jan-2009  christos branches: 1.18.2;
don't clear the screen unconditionally. Now controlled by an option.
Thanks enami
 1.17 13-Dec-2008  christos add a boot.cfg option to clear the screen; default off. From Anon Ymous
 1.16 25-Nov-2008  ad Make pxeboot understand boot.cfg.
 1.15 26-Sep-2008  christos branches: 1.15.2;
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.14 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.13 11-May-2008  chris branches: 1.13.2; 1.13.4;
Add support to pxeboot to allow the loading of modules. Changes to main.c
are taken from boot/boot2.c.

This allows an install to be started by running:
load tftp:miniroot.kmod
boot tftp:netbsd-GENERIC

Note that the change to dev_net.c to comment out the network shutdown,
suggests we need to hook the network shutdown in the the common exec code.
If the network is shutdown, it fails to reinitialise and so fails to load
the module.
 1.12 12-Feb-2008  joerg branches: 1.12.6; 1.12.8; 1.12.10; 1.12.12;
Garbage collect the remaining parts of COMPAT_OLDBOOT. The boot loader
support has been removed at least 4 years ago and NetBSD 1.3 is ancient.
 1.11 13-Nov-2005  dsl branches: 1.11.52; 1.11.58;
Pull the boot timeout for the boot_params header.
Allows it to be set to a very large number so the boot on Soekris systems
can be interrupted.
 1.10 11-Nov-2005  dsl Take the console (etc) parameters from the patchable header, instead of
hard-coded constants.
Now the updated installboot can be used to modify the console and baud rate.
 1.9 21-Aug-2005  chs add "consdev" from ../boot.
make "quit" work like it does in ../boot
(ie. let us try again with a bootloader from a different device).
 1.8 22-Jun-2005  dyoung branches: 1.8.2;
De-__P().

Consistently pass 'int *' arguments to parsebootfile.
 1.7 23-Jun-2003  martin branches: 1.7.2; 1.7.16;
Backout previous, this file is not affected by kernel options.
 1.6 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.5 11-Mar-2003  drochner kick out RARP/bootparam - PXE uses BOOTP anyway
 1.4 20-Feb-2002  thorpej branches: 1.4.2; 1.4.4; 1.4.16;
* Rename the pxeboot binary from "pxeboot" to "pxeboot_ia32", since
there are other architectures (e.g. IA64) which also use PXE.
* Get the console right in pxeboot, from Andreas Gustafsson.
* Add a "com0" version of pxeboot, to address the same issue that
biosboot_com0 addresses.
 1.3 17-Feb-2002  thorpej Pay attention to the file name provided by the DHCP server, using
it rather than the default of "netbsd" if it's in the reply.
 1.2 16-Feb-2002  thorpej * Remove a debug-breakpoint that is no longer needed.
* Move the pxe_init() call to when we open the virtual netif.
* Make sure to call pxe_fini() when we close the virtual netif.
 1.1 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.4.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.16.1 20-Feb-2002  jdolecek file main.c was added on branch kqueue on 2002-06-23 17:37:35 +0000
 1.4.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.4.4.1 20-Feb-2002  nathanw file main.c was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.4.2.2 20-Feb-2002  thorpej * Rename the pxeboot binary from "pxeboot" to "pxeboot_ia32", since
there are other architectures (e.g. IA64) which also use PXE.
* Get the console right in pxeboot, from Andreas Gustafsson.
* Add a "com0" version of pxeboot, to address the same issue that
biosboot_com0 addresses.
 1.4.2.1 20-Feb-2002  thorpej file main.c was added on branch sommerfeld_i386mp_1 on 2002-02-20 03:00:28 +0000
 1.7.16.1 15-Sep-2005  tron Pull up following revision(s) (requested by chs in ticket #783):
sys/arch/i386/stand/pxeboot/main.c: revision 1.9
add "consdev" from ../boot.
make "quit" work like it does in ../boot
(ie. let us try again with a bootloader from a different device).
 1.7.2.2 11-Dec-2005  christos Sync with head.
 1.7.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.8.2.2 27-Feb-2008  yamt sync with head.
 1.8.2.1 21-Jun-2006  yamt sync with head.
 1.11.58.1 18-Feb-2008  mjf Sync with HEAD.
 1.11.52.1 23-Mar-2008  matt sync with HEAD
 1.12.12.3 10-Oct-2008  skrll Sync with HEAD.
 1.12.12.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.12.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.12.10.5 11-Aug-2010  yamt sync with head.
 1.12.10.4 11-Mar-2010  yamt sync with head
 1.12.10.3 16-Sep-2009  yamt sync with head
 1.12.10.2 04-May-2009  yamt sync with head.
 1.12.10.1 16-May-2008  yamt sync with head.
 1.12.8.1 18-May-2008  yamt sync with head.
 1.12.6.3 17-Jan-2009  mjf Sync with HEAD.
 1.12.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.12.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.13.4.2 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.13.4.1 19-Oct-2008  haad Sync with HEAD.
 1.13.2.1 18-Jul-2008  simonb Sync with head.
 1.15.2.3 28-Apr-2009  skrll Sync with HEAD.
 1.15.2.2 03-Mar-2009  skrll Sync with HEAD.
 1.15.2.1 19-Jan-2009  skrll Sync with HEAD.
 1.18.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.18.2.4 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.18.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.18.2.2 01-Nov-2009  jym Sync with HEAD.
 1.18.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.24.4.4 31-May-2011  rmind sync with head
 1.24.4.3 21-Apr-2011  rmind sync with head
 1.24.4.2 05-Mar-2011  rmind sync with head
 1.24.4.1 30-May-2010  rmind sync with head
 1.24.2.2 09-Nov-2010  uebayasi Sync with HEAD.
 1.24.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.14.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.14.1 23-Jun-2013  tls resync from head
 1.29.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.30.10.1 10-Aug-2014  tls Rebase.
 1.32.10.1 02-Aug-2025  perseant Sync with HEAD
 1.18 20-Oct-2013  christos Revert previous code move to accommodate relocation that does not fit.
Move pxe_command_buf declaration next to the code so
that it fits on the 16 bit relocation. It is in the text segment, but
it does not matter since it is mapped read-write.
 1.17 13-Dec-2009  jakllsch branches: 1.17.12; 1.17.22; 1.17.26;
Shut down the PXE network stack when we are done with it.

This fixes an issue where a CK804 nfe(4) would have a
byte-reversed MAC address after pxeboot(8).
 1.16 26-Oct-2009  cegger kill extra whitespaces
reviewed by tsutsui@
 1.15 18-Mar-2009  cegger bcopy -> memcpy
 1.14 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.13 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.12 12-Jan-2009  tsutsui branches: 1.12.2;
Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.11 11-Jan-2009  christos merge christos-time_t
 1.10 14-Apr-2006  dyoung branches: 1.10.62; 1.10.64; 1.10.68; 1.10.76;
Remove a call, pxe_call(PXENV_UNLOAD_STACK), that causes Soekris
net45x1 boards to hang at boot---the call never returns. This
fixes PR/25174 for me.
 1.9 26-Dec-2005  perry branches: 1.9.4; 1.9.6; 1.9.8; 1.9.10; 1.9.12;
u_intN_t -> uintN_t
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 14-Jun-2005  tron branches: 1.7.2;
Get rid off the ugly S_SIZE() macro which breaks the build now that
bcmp() is a macro, too.
 1.6 12-Mar-2003  drochner branches: 1.6.2;
Kick out the netif layer from mi libsa and implement an own, smaller, one
(we really don't need to support multiple interfaces)
Also arrange things so that we are able to unload the PXE stacks only
when we are sure that we don't need them anymore. (To make this more
useful, a hook in exec() is needed.
 1.5 11-Mar-2003  drochner Fix bug in readudp(): we have to return the correct length
of the received packet to the caller.
TFTP works now.
 1.4 26-Mar-2002  kanaoka branches: 1.4.2; 1.4.8;
Change scan step from 16 to 2, when pxe_init() check the presence of PXE.
This change improve checking the presence of PXE.
 1.3 18-Feb-2002  thorpej branches: 1.3.4;
Don't ask bootp() to put a "PXEClient" Vendor Class Identifier option
in the DHCP request.
 1.2 16-Feb-2002  thorpej * Remove a debug-breakpoint that is no longer needed.
* Move the pxe_init() call to when we open the virtual netif.
* Make sure to call pxe_fini() when we close the virtual netif.
 1.1 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.3.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.1 18-Feb-2002  nathanw file pxe.c was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.4.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.4.8.1 26-Mar-2002  jdolecek file pxe.c was added on branch kqueue on 2002-06-23 17:37:36 +0000
 1.4.2.2 26-Mar-2002  kanaoka Change scan step from 16 to 2, when pxe_init() check the presence of PXE.
This change improve checking the presence of PXE.
 1.4.2.1 26-Mar-2002  kanaoka file pxe.c was added on branch sommerfeld_i386mp_1 on 2002-03-26 08:02:06 +0000
 1.6.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.2.1 21-Jun-2006  yamt sync with head.
 1.9.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.9.8.1 24-May-2006  yamt sync with head.
 1.9.6.1 22-Apr-2006  simonb Sync with head.
 1.9.4.1 09-Sep-2006  rpaulo sync with head
 1.10.76.2 28-Apr-2009  skrll Sync with HEAD.
 1.10.76.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.68.2 11-Mar-2010  yamt sync with head
 1.10.68.1 04-May-2009  yamt sync with head.
 1.10.64.1 29-Mar-2008  christos Welcome to the time_t=long long dev_t=uint64_t branch.
 1.10.62.1 17-Jan-2009  mjf Sync with HEAD.
 1.12.2.3 28-Mar-2011  jym Cure sync hiccups. Code with compile errors is not really useful, heh.
 1.12.2.2 01-Nov-2009  jym Sync with HEAD.
 1.12.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.26.1 18-May-2014  rmind sync with head
 1.17.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.17.12.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.9 09-Jul-2025  andvar Fix typos in comments:
s/mulicast/multicast/
s/muticast/multicast/
s/muliplicator/multiplicator/
s/muti-precision/multi-precision/
 1.8 18-Oct-2019  msaitoh branches: 1.8.32;
Fix typos.
 1.7 28-May-2019  msaitoh s/recieve/receive/
 1.6 22-Dec-2010  jakllsch branches: 1.6.60;
It just so happens we don't need -Wno-attributes if we
place __packed in the right place.
 1.5 25-Dec-2007  perry branches: 1.5.24; 1.5.32;
Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
 1.4 11-Dec-2005  christos branches: 1.4.50; 1.4.56; 1.4.60; 1.4.64;
merge ktrace-lwp.
 1.3 14-Jun-2005  tron branches: 1.3.2;
Get rid off the ugly S_SIZE() macro which breaks the build now that
bcmp() is a macro, too.
 1.2 10-Nov-2003  wiz Spell address with two d's. Inspired by similar changes in OpenBSD,
originating from Jonathon Gray and forwarded by jmc@openbsd.
 1.1 16-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.16; 1.1.22;
Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.22.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.1.22.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.22.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.22.1 03-Aug-2004  skrll Sync with HEAD
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Feb-2002  jdolecek file pxe.h was added on branch kqueue on 2002-06-23 17:37:36 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file pxe.h was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.1.2.2 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.2.1 16-Feb-2002  thorpej file pxe.h was added on branch sommerfeld_i386mp_1 on 2002-02-16 03:37:41 +0000
 1.3.2.1 21-Jan-2008  yamt sync with head
 1.4.64.1 02-Jan-2008  bouyer Sync with HEAD
 1.4.60.1 26-Dec-2007  ad Sync with head.
 1.4.56.1 18-Feb-2008  mjf Sync with HEAD.
 1.4.50.1 09-Jan-2008  matt sync with HEAD
 1.5.32.1 05-Mar-2011  rmind sync with head
 1.5.24.1 10-Jan-2011  jym Sync with HEAD
 1.6.60.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.60.1 10-Jun-2019  christos Sync with HEAD
 1.8.32.1 02-Aug-2025  perseant Sync with HEAD
 1.5 20-Oct-2013  christos Revert previous code move to accommodate relocation that does not fit.
Move pxe_command_buf declaration next to the code so
that it fits on the 16 bit relocation. It is in the text segment, but
it does not matter since it is mapped read-write.
 1.4 20-Oct-2013  christos Move an instruction above .code16 so that it produces an R_386_32 instead
of an R_386_16 relocation, which is truncated to fit. XXX: untested.
 1.3 01-Feb-2003  dsl branches: 1.3.142; 1.3.152; 1.3.158;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.2 27-Mar-2002  kanaoka branches: 1.2.2; 1.2.8;
Add (missing)pushl/popl for %edi in ENTRY(pxecall_pxenv).
 1.1 16-Feb-2002  thorpej branches: 1.1.4;
Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.4.3 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file pxe_call.S was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.2.8.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.8.1 27-Mar-2002  jdolecek file pxe_call.S was added on branch kqueue on 2002-06-23 17:37:36 +0000
 1.2.2.2 27-Mar-2002  kanaoka Add (missing)pushl/popl for %edi in ENTRY(pxecall_pxenv).
 1.2.2.1 27-Mar-2002  kanaoka file pxe_call.S was added on branch sommerfeld_i386mp_1 on 2002-03-27 17:24:23 +0000
 1.3.158.1 18-May-2014  rmind sync with head
 1.3.152.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.142.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.2 13-Dec-2009  jakllsch Shut down the PXE network stack when we are done with it.

This fixes an issue where a CK804 nfe(4) would have a
byte-reversed MAC address after pxeboot(8).
 1.1 12-Mar-2003  drochner branches: 1.1.108; 1.1.122;
Kick out the netif layer from mi libsa and implement an own, smaller, one
(we really don't need to support multiple interfaces)
Also arrange things so that we are able to unload the PXE stacks only
when we are sure that we don't need them anymore. (To make this more
useful, a hook in exec() is needed.
 1.1.122.1 24-Oct-2010  jym Sync with HEAD
 1.1.108.1 11-Mar-2010  yamt sync with head
 1.1 16-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.16;
Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Feb-2002  jdolecek file pxeboot.h was added on branch kqueue on 2002-06-23 17:37:36 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file pxeboot.h was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.1.2.2 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.2.1 16-Feb-2002  thorpej file pxeboot.h was added on branch sommerfeld_i386mp_1 on 2002-02-16 03:37:41 +0000
 1.7 27-Sep-2019  gson Incrase pxeboot code size limit from 64k to 128k. Fixes PR kern/54560.
The start_pxe.S part was suggested by mlelstv.
 1.6 18-Mar-2011  jakllsch branches: 1.6.48; 1.6.56; 1.6.60;
Automatically adjust pxeboot(8) stack based on the end of .bss, like is already
done in biosboot.S for boot(8).
(The heap location will need to be adjusted if pxeboot expands much more.)
 1.5 20-Dec-2010  jakllsch branches: 1.5.2;
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.4 11-Nov-2005  dsl branches: 1.4.94; 1.4.102;
Take the console (etc) parameters from the patchable header, instead of
hard-coded constants.
Now the updated installboot can be used to modify the console and baud rate.
 1.3 19-Aug-2004  junyoung branches: 1.3.12;
Rename bootparams to boot_params for consistency.
 1.2 09-Oct-2003  dsl branches: 1.2.4;
Use real_to_prot (etc) from stand/lib.
Add a patchable header for boot parameters (eg console type).
 1.1 09-Oct-2003  dsl Move start_pxe.S to a more sensible place
 1.2.4.6 11-Dec-2005  christos Sync with head.
 1.2.4.5 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.4.4 18-Sep-2004  skrll Sync with HEAD.
 1.2.4.3 25-Aug-2004  skrll Sync with HEAD.
 1.2.4.2 03-Aug-2004  skrll Sync with HEAD
 1.2.4.1 09-Oct-2003  skrll file start_pxe.S was added on branch ktrace-lwp on 2004-08-03 10:36:25 +0000
 1.3.12.1 21-Jun-2006  yamt sync with head.
 1.4.102.2 21-Apr-2011  rmind sync with head
 1.4.102.1 05-Mar-2011  rmind sync with head
 1.4.94.2 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.4.94.1 10-Jan-2011  jym Sync with HEAD
 1.5.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.6.60.1 03-Oct-2019  martin Pull up following revision(s) (requested by manu in ticket #277):

sys/arch/i386/stand/pxeboot/start_pxe.S: revision 1.7
sys/arch/i386/stand/pxeboot/Makefile: revision 1.28

Incrase pxeboot code size limit from 64k to 128k. Fixes PR kern/54560.
The start_pxe.S part was suggested by mlelstv.
 1.6.56.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.48.1 04-Oct-2019  martin Pull up following revision(s) (requested by manu in ticket #1400):

sys/arch/i386/stand/pxeboot/start_pxe.S: revision 1.7
sys/arch/i386/stand/pxeboot/Makefile: revision 1.28

Incrase pxeboot code size limit from 64k to 128k. Fixes PR kern/54560.
The start_pxe.S part was suggested by mlelstv.
 1.5 21-Sep-2024  rin i386/stand: Document NFSv3 support to {efi,pxe}boot/version
 1.4 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.3 15-Jul-2008  perry branches: 1.3.118;
Update the version numbers following commit, and make them all identical.
 1.2 01-Feb-2003  dsl branches: 1.2.104; 1.2.108; 1.2.110; 1.2.112; 1.2.114;
Change all .S files to use .code16 and .code32
Support 32bit addresses >64k as valid on bios calls.
Move stack for dosboot and biosboot to >64 so stack doesn't hit data.
Use disk sector number passed by mbr code to select default partition
(the mbr code doesn't do this yet).
NB only biosboot and dosboot have been tested so far.
(changes approved by christos and fvdl)
 1.1 16-Feb-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.16;
Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.16.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 16-Feb-2002  jdolecek file version was added on branch kqueue on 2002-06-23 17:37:36 +0000
 1.1.4.2 28-Feb-2002  nathanw Catch up to -current.
 1.1.4.1 16-Feb-2002  nathanw file version was added on branch nathanw_sa on 2002-02-28 04:10:30 +0000
 1.1.2.2 16-Feb-2002  thorpej Add a PXE boot loader. PXE interface code is derived by code
written by Alfred Perlstein, Paul Saab, John Baldwin for FreeBSD.

Still needs some work, but this will load a kernel on a Soekris net4501.

Many thanks to Frank van der Linden and his simulator wizardry for
helping me debug the low-level startup code.
 1.1.2.1 16-Feb-2002  thorpej file version was added on branch sommerfeld_i386mp_1 on 2002-02-16 03:37:41 +0000
 1.2.114.1 19-Oct-2008  haad Sync with HEAD.
 1.2.112.1 18-Jul-2008  simonb Sync with head.
 1.2.110.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.2.108.1 04-May-2009  yamt sync with head.
 1.2.104.1 28-Sep-2008  mjf Sync with HEAD.
 1.3.118.1 02-Aug-2025  perseant Sync with HEAD

RSS XML Feed