Home | History | Annotate | Download | only in efiboot
History log of /src/sys/arch/i386/stand/efiboot/boot.c
RevisionDateAuthorComments
 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.

RSS XML Feed