Home | History | Annotate | Download | only in efiboot
History log of /src/sys/arch/i386/stand/efiboot/eficons.c
RevisionDateAuthorComments
 1.18  15-Oct-2025  manu Restore keyboard/screen console broken in revision 1.16

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

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

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

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

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

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

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

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

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

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

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

Ugly, but what FreeBSD does, at least.

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

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

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

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

Notes:
- multiboot2 is disabled in dosboot, otherwise the binary
gets too big and build fails.
- in src/sys/arch/i386/stand/efiboot, consinit() is renamed
as efi_consinit() to avoid prototype conflicts in src/sys/sys/systm.h
 1.6  16-May-2018  jakllsch branches: 1.6.2; 1.6.6;
During awaitkey(), move the cursor back to the beginning of the
countdown with '\b' only after waiting.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fix a few bugs related to the framebuffer:
- If a GOP mode wasn't explicitly requested, the bootloader was passing
fb info to the kernel even if the console was in text mode! This
results in garbled console output on at least ThinkPad T420 and
likely many others. If a mode isn't specified, default to 800x600.
- The "gop" command was incorrectly parsing video modes in the form
WxHxD as WxWxD.
- Allow a short form WxH for the "gop" command to select any mode with
the target dimensions.
 1.4.2.3  18-Sep-2019  martin Pull up following revision(s) [adapted, via patch]
(requested by manu in ticket #1382):

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

Add multiboot 2 support to x86 bootloaders

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

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

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

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

Remove debug define.

It remained there unseen because it was misspelled!

Remove obsoeolete BUGS note that UEFI bootloader does not support multiboot

Add new multiboot2.h header.
 1.4.2.2  22-May-2018  martin Pull up following revision(s) (requested by jakllsch in ticket #831):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Add multiboot 2 support to x86 bootloaders

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

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

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

Remove debug define.

It remained there unseen because it was misspelled!

Remove obsoeolete BUGS note that UEFI bootloader does not support multiboot
 1.6.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.6.2.1  08-Apr-2020  martin Merge changes from current as of 20200406
 1.7.2.1  29-Feb-2020  ad Sync with head.
 1.12.4.1  11-Sep-2023  martin Pull up following revision(s) (requested by rin in ticket #361):

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

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

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

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

Ugly, but what FreeBSD does, at least.
Proposed as PR port-amd64/57523
 1.14.6.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed