2 .\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 .\" Copyright (c) 2019-2022 Netflix, Inc
5 .\" Copyright (c) 2022 Mateusz Piotrowski <0mp@FreeBSD.org>
6 .\" Copyright 2022 The FreeBSD Foundation, Inc.
8 .\" Part of this documentation was written by
9 .\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
10 .\" from the FreeBSD Foundation.
12 .\" Redistribution and use in source and binary forms, with or without
13 .\" modification, are permitted provided that the following conditions
15 .\" 1. Redistributions of source code must retain the above copyright
16 .\" notice, this list of conditions and the following disclaimer.
17 .\" 2. Redistributions in binary form must reproduce the above copyright
18 .\" notice, this list of conditions and the following disclaimer in the
19 .\" documentation and/or other materials provided with the distribution.
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 .Nd UEFI kernel loader
49 when it is placed within a UFS or ZFS file system.
52 is used directly when configured with
54 or when placed directly as the default boot program as described in
56 When a system is built using
59 will be used directly.
60 .Ss Console Considerations
61 The EFI BIOS provides a generic console.
64 this is selected by specifying
71 .Dv 8be4df61-93ca-11d2-aa0d-00e098032b8c-ConOut
72 UEFI environment variable to guess what the
76 will output its prompts and menus to all the places specified by ConOut.
79 kernel has a limitation when more than one console is present.
80 The kernel outputs to all configured consoles.
81 Only the primary console will get the log messages from the
83 system, and prompts for things like
88 finds a video device first, then
90 tells the kernel to use the video console as primary.
91 Likewise, if a serial device is first in the
93 list, the serial port will be the primary console.
97 variable, both serial and video are attempted.
101 console for the video (which may or may not work) and
105 at the default baud rate.
106 The kernel will use a dual console, with the video console
107 primary if a UEFI graphics device is detected, or the serial console
110 On x86 platforms, if you wish to redirect the loader's output to a serial port
111 when the EFI BIOS doesn't support it, or to a serial port that isn't the one the
112 EFI BIOS redirects its output to, set
118 with an I/O address of 0x3f8.
120 is used to set this to a different port address.
122 is used to set the of the serial port (the default is 9600).
127 you will get output on both the EFI console and the serial port.
128 If this causes a doubling of characters, set
132 since your EFI BIOS is redirecting to the serial port already.
134 If your EFI BIOS redirects the serial port, you may need to tell the kernel
135 which address to use.
136 EFI uses ACPI's UID to identify the serial port, but
138 does not have an ACPI parser, so it cannot convert that to an I/O port.
141 kernel initializes its consoles before it can decode ACPI resources.
144 kernel will look at the
146 variable to set its serial console.
147 Its format should be described in
151 .Dq io:0x3f8,br:115200
152 with the proper port address.
153 PCI or memory mapped ports are beyond the scope of this man page.
155 The serial ports are assigned as follows on IBM PC compatible systems:
156 .Bl -column -offset indent ".Sy Windows Name" ".Sy I/O Port Address" ".Sy Typical FreeBSD device"
157 .It Sy Windows Name Ta Sy I/O Port Address Ta Sy Typical FreeBSD device
158 .It COM1 Ta 0x3f8 Ta Pa /dev/uart0
159 .It COM2 Ta 0x2f8 Ta Pa /dev/uart1
160 .It COM3 Ta 0x3e8 Ta Pa /dev/uart2
161 .It COM4 Ta 0x2e8 Ta Pa /dev/uart3
170 The primary console is set using the boot flags.
171 These command line arguments set corresponding flags for the kernel.
172 These flags can be controlled by setting loader environment variables
177 Boot flags may be set on the command line to the boot command.
178 Inside the kernel, the RB_ flags are used to control behavior, sometimes
179 in architecturally specific ways and are included to aid in discovery
180 of any behavior not covered in this document.
181 .Bl -column -offset indent ".Sy boot flag" ".Sy loader variable" ".Sy Kernel RB_ flag"
182 .It Sy boot flag Ta Sy loader variable Ta Sy Kernel RB_ flag
183 .It Fl a Ta Dv boot_askme Ta Va RB_ASKNAME
184 .It Fl c Ta Dv boot_cdrom Ta Va RB_CDROM
185 .It Fl d Ta Dv boot_ddb Ta Va RB_KDB
186 .It Fl r Ta Dv boot_dfltroot Ta Va RB_DFLTROOT
187 .It Fl D Ta Dv boot_multiple Ta Va RB_MULTIPLE
188 .It Fl m Ta Dv boot_mute Ta Va RB_MUTE
189 .It Fl g Ta Dv boot_gdb Ta Va RB_GDB
190 .It Fl h Ta Dv boot_serial Ta Va RB_SERIAL
191 .It Fl p Ta Dv boot_pause Ta Va RB_PAUSE
192 .It Fl P Ta Dv boot_probe Ta Va RB_PROBE
193 .It Fl s Ta Dv boot_single Ta Va RB_SINGLE
194 .It Fl v Ta Dv boot_verbose Ta Va RB_VERBOSE
196 And the following flags determine the primary console:
197 .Bl -column -offset indent ".Sy Flags" ".Sy Kernel Flags" ".Sy Kernel Consoles" ".Sy Primary Console"
198 .It Sy Flags Ta Sy Kernel Flags Ta Sy Kernel Consoles Ta Sy Primary Console
199 .It none Ta 0 Ta Video Ta Video
200 .It Fl h Ta RB_SERIAL Ta Serial Ta Serial
201 .It Fl D Ta RB_MULTIPLE Ta Serial, Video Ta Video
202 .It Fl Dh Ta RB_SERIAL | RB_MULTIPLE Ta Serial, Video Ta Serial
206 does not implement the probe
208 functionality where we use the video console if a keyboard is connected and a
209 serial console otherwise.
211 The kernel must parse the firmware memory map tables to know what memory
213 Since it must allocate memory to do this,
215 ensures there's extra memory available, called
217 after everything it loads
219 the kernel, modules and metadata
221 for the kernel to bootstrap the memory allocator.
223 By default, amd64 reserves 8MB.
226 command allows for tuning the slop size.
227 It takes a single argument, the size of the slop in bytes.
230 will load the kernel into memory that is 2MB aligned below 4GB.
231 It cannot load to a fixed address because the UEFI firmware may reserve
232 arbitrary memory for its use at runtime.
235 kernels retained the old BIOS-boot protocol of loading at exactly 2MB.
236 Such kernels must be copied from their loaded location to 2MB prior
240 command is used to enable this copying for older kernels.
241 It takes a single argument
243 .Bl -tag -width disable
245 Force-disable copying staging area to
248 Force-enable copying staging area to
251 Selects the behaviour based on the kernel's capability of boostraping
252 from non-2M physical base.
253 The kernel reports this capability by exporting the symbol
257 Arm64 loaders have operated in the
259 mode from their inception, so there is no
261 command on that platform.
262 Riscv, 32-bit arm and arm64 have always loaded at any
264 aligned location, so do not provide
267 .Bd -ragged -offset indent
269 BIOS loaders on i386 and amd64 put the staging area starting
270 at the physical address
272 then enable paging with identical mapping for the low
276 followed the same scheme for handing control to the kernel,
277 since it avoided modifications for the loader/kernel hand-off protocol,
278 and for the kernel page table bootstrap.
280 This approach is incompatible with the UEFI specification,
281 and as a practical matter, caused troubles on many boards,
282 because UEFI firmware is free to use any memory for its own needs.
285 must only use memory explicitly allocated using boot interfaces.
286 The original way also potentially destroyed UEFI runtime interfaces data.
290 and the kernel were improved to avoid this problem.
293 Because it executes in x86 protected mode, the amd64 version of
295 is susceptible to CPU faults due to programmer mistakes and
297 To make debugging such faults easier, amd64
299 can provide detailed reporting of the CPU state at the time
304 command installs a handler for faults directly in the IDT,
305 avoiding the use of the UEFI debugging interface
306 .Fn EFI_DEBUG_SUPPORT_PROTOCOL.RegisterExceptionCallback .
307 That interface is left available for advanced debuggers in
308 the UEFI environment.
311 command tries to deinstall the fault handler, returning TSS and IDT
312 CPU tables to their pre-installation state.
315 command produces a fault in the
317 environment for testing purposes, by executing the
319 processor instruction.
321 .Bl -tag -width "/boot/loader.efi"
322 .It Pa /boot/loader.efi
323 The location of the UEFI kernel loader within the system.
325 .Ss EFI System Partition
327 is installed on the ESP (EFI System Partition) in one of the following locations:
328 .Bl -tag -width "efi/freebsd/loader.efi"
329 .It Pa efi/boot/bootXXX.efi
330 The default location for any EFI loader
333 for values to replace
337 .It Pa efi/freebsd/loader.efi
338 The location reserved specifically for the
343 The default location for the ESP mount point is documented in
346 .Ss Updating loader.efi on the ESP
347 The following examples shows how to install a new
351 First, find the partition of type
353 .Bd -literal -offset indent
354 # gpart list | grep -Ew '(Name|efi)'
363 The name of the ESP on this system is
366 Second, let's mount the ESP, copy
368 to the special location reserved for
370 EFI loaders, and unmount once finished:
371 .Bd -literal -offset indent
372 # mount_msdosfs /dev/nvd0p1 /boot/efi
373 # cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
380 Systems that do not have a
382 variable set are not conformant with the standard, and likely have unexpected
385 Non-x86 serial console handling is even more confusing and less well documented.
387 Sometimes when the serial port speed isn't set, 9600 is used.
388 Other times the result is typically 115200 since the speed remains unchanged