History log of /openbsd-current/sys/arch/i386/stand/pxeboot/conf.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.50 22-Jul-2023 jsg

BOOTARG_UCODE for AMD
ok deraadt@


# 1.49 25-Apr-2023 kn

Do not attempt to write to read-only softraid

Bootloaders have no write support for softraid volumes, which manifests in,
e.g. /bsd.upgrade not being stripped of its 'x' permission bit to prevent
sysupgrade loops in case of upgrade failure.

Set a no-write flag handled by libsa to bail out early in write calls.
There should be no real behaviour change, writes just fail earlier now.

i386 BIOS. Crank minor.
Tested inside amd64 vmm.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.48 09-Dec-2020 krw

Use daddr_t and not daddr32_t in boot media.

At a minimum, amd64/i386 should now boot from 4TB GPT formatted disks.

More daddr32_t terminations with extreme prejudice to follow.

Tested by various, in snaps for a few days.

ok deraadt@


Revision tags: OPENBSD_6_8_BASE
# 1.47 14-Jun-2020 deraadt

crank version number


# 1.46 26-May-2020 deraadt

increment version numbers, due to recent RB_GOODSEED and fchmod +T changes


Revision tags: OPENBSD_6_7_BASE
# 1.45 21-Mar-2020 otto

Teach i386 boot98) and friends about ffs2. fdboot(8) is the exception:
ffs2 support does not fit there. But the the kernel loaded by the
floppy ramdisk does support ffs2.


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.49 25-Apr-2023 kn

Do not attempt to write to read-only softraid

Bootloaders have no write support for softraid volumes, which manifests in,
e.g. /bsd.upgrade not being stripped of its 'x' permission bit to prevent
sysupgrade loops in case of upgrade failure.

Set a no-write flag handled by libsa to bail out early in write calls.
There should be no real behaviour change, writes just fail earlier now.

i386 BIOS. Crank minor.
Tested inside amd64 vmm.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.48 09-Dec-2020 krw

Use daddr_t and not daddr32_t in boot media.

At a minimum, amd64/i386 should now boot from 4TB GPT formatted disks.

More daddr32_t terminations with extreme prejudice to follow.

Tested by various, in snaps for a few days.

ok deraadt@


Revision tags: OPENBSD_6_8_BASE
# 1.47 14-Jun-2020 deraadt

crank version number


# 1.46 26-May-2020 deraadt

increment version numbers, due to recent RB_GOODSEED and fchmod +T changes


Revision tags: OPENBSD_6_7_BASE
# 1.45 21-Mar-2020 otto

Teach i386 boot98) and friends about ffs2. fdboot(8) is the exception:
ffs2 support does not fit there. But the the kernel loaded by the
floppy ramdisk does support ffs2.


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.48 09-Dec-2020 krw

Use daddr_t and not daddr32_t in boot media.

At a minimum, amd64/i386 should now boot from 4TB GPT formatted disks.

More daddr32_t terminations with extreme prejudice to follow.

Tested by various, in snaps for a few days.

ok deraadt@


Revision tags: OPENBSD_6_8_BASE
# 1.47 14-Jun-2020 deraadt

crank version number


# 1.46 26-May-2020 deraadt

increment version numbers, due to recent RB_GOODSEED and fchmod +T changes


Revision tags: OPENBSD_6_7_BASE
# 1.45 21-Mar-2020 otto

Teach i386 boot98) and friends about ffs2. fdboot(8) is the exception:
ffs2 support does not fit there. But the the kernel loaded by the
floppy ramdisk does support ffs2.


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.47 14-Jun-2020 deraadt

crank version number


# 1.46 26-May-2020 deraadt

increment version numbers, due to recent RB_GOODSEED and fchmod +T changes


Revision tags: OPENBSD_6_7_BASE
# 1.45 21-Mar-2020 otto

Teach i386 boot98) and friends about ffs2. fdboot(8) is the exception:
ffs2 support does not fit there. But the the kernel loaded by the
floppy ramdisk does support ffs2.


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.46 26-May-2020 deraadt

increment version numbers, due to recent RB_GOODSEED and fchmod +T changes


Revision tags: OPENBSD_6_7_BASE
# 1.45 21-Mar-2020 otto

Teach i386 boot98) and friends about ffs2. fdboot(8) is the exception:
ffs2 support does not fit there. But the the kernel loaded by the
floppy ramdisk does support ffs2.


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.45 21-Mar-2020 otto

Teach i386 boot98) and friends about ffs2. fdboot(8) is the exception:
ffs2 support does not fit there. But the the kernel loaded by the
floppy ramdisk does support ffs2.


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.44 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
section, which has grown a fair bit with the introduction of retguard.
Mortimer discovered the repeated 512-byte sequence as retguard keys, and
this resolves the issue. (Chacha does not fit on the media, so 1.5K early
drop RC4 is hopefully sufficient in our KARL link universe)
Version crank the bootblocks. sysupgrade -s will install new bootblocks.
ok djm mortimer


Revision tags: OPENBSD_6_6_BASE
# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.43 04-Aug-2019 deraadt

crank version, following fchmod change


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
so the file cannot be re-executed upon the next boot. This provides a
stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade.
Now various forms of upgrade failure will reboot into /bsd, which is probably
more recoverable. Performing fchmod -x depends on (1) use of MI boot.c
(not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality
in the IO layer. Most architectures have this support now.

Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will
remain in the tree while refinements happen for some of the laggard
architectures.

based upon a discussion florian
tested in snapshots for more than a week without any complaints


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


Revision tags: OPENBSD_6_5_BASE
# 1.41 10-Apr-2019 deraadt

crank versions


# 1.40 08-Apr-2019 florian

crank version; looks good deraadt


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.39 07-Mar-2019 jsg

Return early in ucode loading if cpuid is not available. Should fix
booting on 486s without cpuid. Reported by Falk Richter and diagnosed
by guenther@


Revision tags: OPENBSD_6_4_BASE
# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.38 23-Aug-2018 jsg

port the amd64 code for loading intel microcode on boot to i386
ok deraadt@ mlarkin@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


# 1.37 11-Jul-2018 mlarkin

Detect vmm(4) in the bootloader and automatically switch to the serial
console at 115200 baud.

ok deraadt


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.36 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_6_1_BASE
# 1.35 18-Sep-2016 jsing

Bump boot loader versions due to bcrypt pbkdf support.


# 1.34 13-Sep-2016 jasper

crank bootloader version after .SUNW_ctf change

as discussed with jsing@ it's easier this way to ensure people have
bootblocks capable of loading the section


Revision tags: OPENBSD_6_0_BASE
# 1.33 28-May-2016 sthen

crank version numbers of those bootloaders that have been changed by
the com_init fix. ok beck deraadt


Revision tags: OPENBSD_5_9_BASE
# 1.32 19-Feb-2016 naddy

belatedly bump bootstrap version after mdrandom() changes; ok deraadt@


# 1.31 18-Sep-2015 miod

Remove support for building the boot blocks with DEBUGFLAGS=-D_TEST, which is
supposed to create a userland binary in order to test non-boot related
functionality. This feature has been bitrotting in a non-compiling state
for years, and causes a too-many-ifdefs disease now that there are intrusive
EFI changes.

No functional change.


# 1.30 02-Sep-2015 yasuoka

Bring the boot changes on amd64 to i386. alloca is deleted.
Also fix the boot from BIOS and bump the version.

input and ok deraadt


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 18-Feb-2014 jsing

Bump version numbers.


# 1.28 02-Jan-2014 deraadt

crank version after random instruction fix from jsing


# 1.27 28-Dec-2013 deraadt

crank the version


# 1.26 20-Oct-2013 stsp

Add i386/amd64 boot(8) support for keydisk-based softraid crypto volumes.

So far, only passphrase-based crypto volumes were bootable. Full disk
encryption with keydisks required a non-crypto partition to load the kernel.

The bootloader now scans all BIOS-visible disks for RAID partitions and
automatically associates keydisk partitions with their crypto volume.
Attempting to boot from a volume without its keydisk currently results
in a passphrase prompt (this might be changed in the future).

There is no need to re-create existing volumes. Moving the root partition
onto the crypto disk and running installboot(8) is all that's needed.

help & ok jsing


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.25 31-Oct-2012 jsing

Bump version numbers.


# 1.24 09-Oct-2012 jsing

Bump boot versions due to recent changes.


Revision tags: OPENBSD_5_2_BASE
# 1.23 03-Jun-2012 kettenis

Add support for serial consoles at non-standard addresses. This implements
a new "machine comaddr" command that makes it possible to configure the
io port used to access the serial port. This can be used to use serial ports
on a puc(4) device as serial console.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.22 08-Mar-2011 krw

Fix extended partition searching so we don't get lost. The offset
of the next EBR is relative to the start of the extended partition
described in the first MBR, not relative to the EBR specifying the
offset in its extended partition entry.

Clean up installboot -v output. Use daddr64_t for all sector numbers.

Not a complete fix, but better than what we had. More tweaks to
come.

Inspired by a diff and cluebat from uscav on tech@ a few weeks
ago.

Feedback from matthew@, weingart@.

ok deraadt@


Revision tags: OPENBSD_4_9_BASE
# 1.21 06-Dec-2010 jasper

- properly remove NENTS now after fixing the fallout.

ok deraadt@


# 1.20 06-Dec-2010 jasper

- partially revert previous NENTS removal for arches which got busted.


# 1.19 06-Dec-2010 jasper

- drop NENTS(), which was yet another copy of nitems().
no binary change


ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.18 11-Aug-2010 deraadt

crank version


# 1.17 02-Jul-2010 weingart

Add ability to limit memory presented to kernel with
'machine memory =128M' style commands. Thanks to
phessler for finding a small man page niggle. Bumped
version strings to a nice round fraction, and make them
the same across the board. Easier to identify boot
binary versions that way.

ok thib@, tedu@, phessler@


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.16 19-Apr-2008 weingart

Change ELF loader to use the LMA as the load address for the
various segments. Hopefully this will help remove various
hacks in the boot loader in the future. This should have no
effect on most architectures (as we tend to have LMA == VMA).

ok drahn@, soft ok's various others.


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.15 27-Jul-2007 tom

We don't want to pass the PXE MAC address to the kernel when booting
from a local disk, since the MAC address causes the kernel to look for
root on NFS. Do this by remembering (not adding to boot arguments) the
MAC address when opening the PXE device, and clearing this if we happen
to load a file off a non-network disk.

"works as advertised for me" todd@;
"stop sitting on this/no objections" deraadt@


# 1.14 31-May-2007 tom

Forgot to commit the changes to this file with the rest of the ELF32+64
pieces. Since this is where the "boot both ELF32 and ELF64" behaviour
is turned on for i386, it is quite important.

Bump version numbers too.

Found by ckuethe@; thanks.


# 1.13 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


# 1.12 27-Apr-2007 tom

Check for Control key held down when starting, and don't read boot.conf
if it is. This gives a way to recover from "switching to com0" when
there's no serial cable handy.

Bump version numbers.

A similar change will be made to amd64 boot soon.

ok toby@ deraadt@


Revision tags: OPENBSD_4_1_BASE
# 1.11 02-Jan-2007 tom

Fix the keyboard problem seen on Intel Macs, where only the first
keypress is seen by boot.

It appears that on the Intel Mac, we have to issue the "check for
keystroke" BIOS call before the "get keystroke" call will get it
(unlike any other BIOS I have seen in over 20 years).

It would not have been possible to fix this problem without the
donation from Steven N. Fettig (steve (at) anywheretechnology.com);
many thanks.

Bump versions of boot, cdboot and pxeboot accordingly.

Testing kettenis@, otto@, and others; ok weingart@.


# 1.10 12-Oct-2006 krw

Bump versions to note behaviour change of no longer trying
to boot from NetBSD partitions. Requested by tom@.


Revision tags: OPENBSD_4_0_BASE
# 1.9 20-May-2006 deraadt

push a BOOTARG_BOOTMAC (what PXE says is the MAC address of the interface
we are booting from) out towards the kernel; tested by reyk
crank the version too


Revision tags: OPENBSD_3_9_BASE
# 1.8 02-Jan-2006 tom

Correctly set the %di register on PXENV calls. This should help
older PXE clients get a bit further. Prompted by Rolf Sommerhalder's
comments on misc@.

ok krw@ (thanks) "no objection" mbalmer@ "go for it" fgsch@
"fine" deraadt@


Revision tags: OPENBSD_3_8_BASE
# 1.7 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


# 1.6 03-May-2005 tom

Convert the size of a memory chunk from bytes to megabytes before
casting to a 32-bit value, not after. Corrects the display of large
memory chunks in the probing: line (mem[615K 3518M 0M a20=on] becomes
mem[615K 3518M 12288M a20=on]).

Bump version on boot, cdboot and pxeboot accordingly.

"looks ok to me" weingart@


# 1.5 30-Apr-2005 tom

Ensure we save the %ebx register returned from the BIOS call, not just
%bx. Fixes problem introduced in gidt.S r1.29, which could lead to an
incomplete memory map, and "too little memory available; running in
degraded mode", as found by Roy Morris rmorris (at) internetsecure (dot)
com. (Thanks for the report, and for testing the fix.)

Bump version on boot, cdboot and pxeboot accordingly.

ok weingart@


# 1.4 25-Apr-2005 tom

[OpenBSD]

Make boot code use real mode with 64K segments instead of 1M
segments. Improves stability with some disk controller cards.
Also explicitly state operand size on some moves.

Bump version on boot, cdboot and pxeboot accordingly.

"just get them in" beck@ ok weingart@


Revision tags: OPENBSD_3_7_BASE
# 1.3 13-Mar-2005 tom

Only use bangpxe calling on PXE 2.1 and above. Makes no difference on
current-spec PXE systems, but allows some older ones (I tested 0.98 and
0.99) to get a bit further.

ok weingart@; "please get it in" deraadt@.


# 1.2 12-Mar-2005 tom

On return from real mode, reload the GDT using a 16-bit pointer rather
than a 32-bit value. Found by Tim Fletcher <tim (at) parrswood (dot)
manchester (dot) sch (dot) uk> using Etherboot; thanks to Tim and the
Etherboot developers who narrowed this down.

Also bump the pxeboot version to 1.01.

ok weingart@, "go ahead" deraadt@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 19-Mar-2004 tom

branches: 1.1.4;
Enter pxeboot, derived from the NetBSD implementation. Initially
intended to support network installs using bsd.rd over TFTP.

Thanks to the many who tested, including Diana Eichert.

ok deraadt@