path: root/stand/efi
Commit message (Collapse)AuthorAgeFilesLines
* loader.efi: to preserve heap space, use AllocatePages() for shadow_fbToomas Soome2021-12-221-2/+11
| | | | | | | | | shadow FB size could be rather large and depends on resolution, instead of using heap, allocate dedicated space outside of heap. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D33600 MFC after: 2 weeks
* Don't sync the I/D caches when they are coherentAndrew Turner2021-12-201-1/+1
| | | | | | | | | | | | In the arm64 loader we need to syncronise the I and D caches. On some newer CPUs the I and D caches are coherent so we don't need to perform these operations. While here remove the arguments to cpu_inval_icache as they are unneeded. Reported by: cperciva Tested by: cperciva Sponsored by: Innovate UK
* loader.efi: Do not use as frame buffer BLT-only GOPs.Alexander Motin2021-12-161-4/+16
| | | | | | | | | | | | Kernel needs physical frame buffer address and size, which Block Transfer-only Graphics Output Protocol instances do not have. Some recent ASUS boards like PRIME Z690M-PLUS D4 and PRIME H570-Plus report two GOPs, out of which the second one support ConOut protocol, that made it preferable, but is BLT-only, that made console unusable. Discussed with: tsoome (previous version) MFC after: 1 week
* loader: framebuffer should only be written intoToomas Soome2021-12-111-0/+3
| | | | | | | | Reading from Write Combining memory can be very-very slow. Try to use shadow buffer to avoid such reads. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D33305
* loader: abstract boot services exiting to libefi functionWarner Losh2021-11-212-4/+14
| | | | | | | | | Move direct call of ExitBootServices to efi_exit_boot_services. This function sets boot_services_active to false so callers don't have to do it everywhere (though currently only loader/bootinfo.c is affected). Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32226
* loader: Do not force comconsole for arm and arm64Emmanuel Vadot2021-11-161-1/+1
| | | | | | | | | This makes GOP not probed on some situation (AMD Card on PCIe slot with EDK2 as we have a SERIAL_IO_PROTOCOL compatible uart). Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D32992 Sponsored by: Beckhoff Automation GmbH & Co. KG
* loader: lsefi: Print more informationEmmanuel Vadot2021-11-161-1/+25
| | | | | | | | | | | Printing the EFI_HANDLE pointer isn't very useful. If the handle have a IMAGE_DEVICE_PATH or a DEVICE_PATH protocol print it. This makes it easier to see which devices are present and what protocol they expose. Reviewed by: imp, tsoome Differential Revision: https://reviews.freebsd.org/D32991 Sponsored by: Beckhoff Automation GmbH & Co. KG
* efi(8): Fix a typo in a source code commentGordon Bergling2021-11-071-1/+1
| | | | | | - s/writting/writing/ MFC after: 3 days
* efi: switch boot_services_gone to boot_services_activeWarner Losh2021-11-044-18/+15
| | | | | | | | | | | Turn the presence or absence of boot services into a positive bool (and change its type to bool). Move declaration to efi.h in the global variables section. Sponsored by: Netflix Reviewed by: tsoome, kib Differential Revision: https://reviews.freebsd.org/D31814
* EFI loader: Don't free bcache for DEVT_DISK devsColin Percival2021-09-301-2/+4
| | | | | | | | | | | | | | | | Booting on an EC2 c5.xlarge instance, this reduces the number of I/Os performed from 609 to 432, reduces the total number of blocks read from 61963 to 60797, and reduces the time spent in the loader by 39 ms. Note that b4cb3fe0e39a allowed the bcache to be retained for most of the boot process, but relies on mounting filesystems; this commit allows the bcache to be retained at the start of the boot process, before the root filesystem has been located. Reviewed by: imp, tsoome MFC after: 1 week Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D32239
* loader.efi: remove extra extern STWarner Losh2021-09-301-2/+0
| | | | | | | | The definition for 'ST' is in efilib.h, so we don't need extern ST here. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D32225
* efi loader: Call tslog_init from efi_mainColin Percival2021-09-252-2/+4
| | | | | | | We were calling tslog_init from main; no reason to wait that long. Fixes: f49381ccb6bc efi/loader: Call tslog_init Sponsored by: https://www.patreon.com/cperciva
* efi loader: TypoMark Johnston2021-09-211-1/+1
| | | | MFC after: 3 days
* loader: implement mount/unmount rootfsToomas Soome2021-09-083-11/+10
| | | | | | | | | We want to keep our root file system open to preserve bcache segment between file accesses, thus reducing physical disk IO. Reviewed by: imp, allanjude, kevans (previous version) Differential Revision: https://reviews.freebsd.org/D30848 MFC after: 1 month
* loader.efi: fix console output after BS offToomas Soome2021-09-021-1/+21
| | | | | | | | | | | | | When Boot Services (BS) are switched off, we can not use BS functions any more. Since drawn console does implement our own Blt(), we can use it to draw the console. However, SimpleTextOutput protocol based console output must be blocked. Tested by inserting printf() after ExitBootServices() call. MFC after: 1 week
* efi loader: disallow user to configure staging area size less than defaultKonstantin Belousov2021-08-271-4/+9
| | | | | | | | | | We need to round it up to 2M, for instance. Having staging area too small might cause the first resize to use negative size for memmove()/memcpy(), which kills loader. Tested by: Harry Schmalzbauer <freebsd@omnilan.de> Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Restore the definition of EFI_STAGING_SIZEKonstantin Belousov2021-08-271-3/+3
| | | | | | | | | | The definition can be overridden by users, and before f75caed644a5c it was in MBs. Make the symbol' unit MB, to be compatible with users customizations. Reported and tested by: Harry Schmalzbauer <freebsd@omnilan.de> Sponsored by: The FreeBSD Foundation MFC after: 1 week
* amd64 UEFI loader: enable automatic disable of staging area copyingKonstantin Belousov2021-08-251-1/+1
| | | | | | Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 month
* amd64 UEFI loader: stop copying staging area to 2M physicalKonstantin Belousov2021-08-084-60/+330
| | | | | | | | | | | | | | | | | | | | | On amd64, add a possibility to activate kernel with staging area in place. Add 'copy_staging' command to control this. For now, by default the old mode of copying kernel to 2M phys is retained. It is going to be changed in several weeks. On amd64, add some slop to the staging area to satisfy both requirements of the kernel startup allocator, and to have space for minor staging data increase after the final size is calculated. Add a new command 'staging_slop' to control its size. Improve staging area resizing, in particular, reallocate it anew if we cannot grow it neither down nor up. Reviewed by: kevans, markj Discussed with: emaste (the delivery plan) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31121
* loader: Use tslog to instrument some functionsColin Percival2021-06-211-0/+3
| | | | | | | | | | | | | | | | | | | | In my initial testing, these are the functions which showed up as being worth instrumenting. More may be added later. common/console.c: cons_probe common/gfx_fb.c: read_list, insert_font, autoload_font common/interp.c: interact common/interp_lua.c: interp_init, interp_run efi/libefi/efipart.c: efipart_readwrite i386/libi386/biosdisk.c: bd_init, bd_open, bd_edd_io, bd_chs_io, bd_io libsa/open.c: open libsa/read.c: read libsa/twiddle.c: twiddle Note that profiling interp_run may be of questionable utility as it may depend on user behaviour (e.g. pressing keys). Reviewed by: kevans (earlier version)
* efi/loader: Call tslog_initColin Percival2021-06-211-0/+2
| | | | This allows the EFI loader to start recording timestamps.
* Use the arm virtual counter in the arm64 loaderAndrew Turner2021-06-022-2/+75
| | | | | | | | It exist on all ARMv8+ CPUs, and other boot loaders rely on it being present. Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D30410
* Update the EFI timer to be called once a secondAndrew Turner2021-05-121-4/+4
| | | | | | | | | There is no need to call it evert 10ms when we need 1s granularity. Update to update the time every second. Reviewed by: imp, manu, tsoome Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D30227
* EFI secure boot VECTX related changesEric van Gyzen2021-04-303-0/+6
| | | | | | | | | | | | | | When VECTX is enabled as a kernel option and non-EFI loaders are built, many reads will fail due to the mis-match of whether LOADER_VERIEXEC_VECTX or not in readin.h. Source that includes bootstrap.h must ensure the kernel option agrees with the compile time CFLAGS in the various make related files. Submitted by: bret_ketchum@dell.com (original revision) Reviewed by: sjg, bdrewery, dab, bret_ketchum@dell.com MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29993
* Loader: support booting OS from memory disk (MD)Yongbo Yao2021-04-072-0/+31
| | | | | | | | | | | | | Until now, the boot image can be embedded into the loader with /sys/tools/embed_mfs.sh, and memory disk (MD) is already supported in loader source. But due to memory disk (MD) driver isn't registered to the loader yet, the boot image can't be boot from embedded memory disk. Reviewed by: dab, tsoome MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29512
* gptboot.efi: Add man pageWarner Losh2021-04-062-0/+283
| | | | | | | | | | | | | | | | | | | | | | Add a man page for gptboot.efi. Describe when and how to use this as it differs from the BIOS cases. Include cross reference for the preferred method described in efibootmgr(8) as well as cross links in both gptboot(8) and gptboot.efi(8) to the other. This man page was heavily copied from the gptboot.8 man page by Warren Block. They are different enough to need separate man pages for clarity, but there's enough similarity that I worry about the duplication. In the really long term, gptboot(8) will disappear, so having the same info here will help when that day comes. In the short to medium term, the information is likely to not change in gptboot(8) and any changes to gptboot.efi(8) will be easier to make in a separate copy. loader.efi(8) needs a complete rewrite from scratch, otherwise I'd have referenced gptboot.efi(8) from there. Suggetions from: cress@, mhorne@ Reviewed by: rpokala@ Differential Revision: https://reviews.freebsd.org/D29591
* Fix some common typos in commentsGordon Bergling2021-03-131-1/+1
| | | | | | | | | | | - occured -> occurred - normaly -> normally - controling -> controlling - fileds -> fields - insterted -> inserted - outputing -> outputting MFC after: 1 week
* Revert "Split out the loader efifb setup to a new function"Andrew Turner2021-03-031-22/+0
| | | | | | It was broken by a rebase. Revert until it can be fixed. This reverts commit c8db60c0673d4bb7a3a3e2c043804e1ed1108c2f.
* Split out the loader efifb setup to a new functionAndrew Turner2021-03-031-0/+22
| | | | | | | | This makes bi_load_efi_data cleaner to add common acpi setup code. Reviewed by: imp, tsoome Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D28936
* loader: use display pixel density for font autoselectionToomas Soome2021-02-272-10/+109
| | | | | | | | | | | Calculate font size from 16 density independent pixels (dp) by using: size = 16 * ppi/160 * display_factor We are specifying font size 16dp, and assuming 1dp = 160ppi. Also apply scaling factor 2 (display_factor). MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28849
* stand/multiboot2: fix header length checkRoger Pau Monné2021-02-231-1/+1
| | | | | | | | | | | | | Check whether we have reached the end of the buffer using search_size instead of MULTIBOOT_SEARCH, which is the maximum defined by the specification, but the file can be shorter than that. This prevents printing a harmless error message when loading a file that is smaller than MULTIBOOT_SEARCH. Sponsored by: Citrix Systems R&D MFC after: 3 days Fixes: adda2797eb2a ('stand/multiboot2: add support for booting a Xen dom0 in UEFI mode')
* stand/multiboot2: fix error message formatRoger Pau Monné2021-02-231-2/+2
| | | | | | | | Add a missing space in one error message. Sponsored by: Citrix Systems R&D MFC after: 3 days Fixes: adda2797eb2a ('stand/multiboot2: add support for booting a Xen dom0 in UEFI mode')
* loader: autoload_font will hung loader when there is no local consoleToomas Soome2021-02-211-0/+3
| | | | | | | | | If we start with console set to comconsole, the local console (vidconsole, efi) is never initialized and attempt to use the data can render the loader hung. Reported by: Kamigishi Rei MFC after: 3 days
* bi_load: only add MODULEP on arches that have it definedRoger Pau Monné2021-02-161-0/+2
| | | | | | | | | | | Do not attempt to add MODINFOMD_MODULEP to the kernel medatada on arches that don't have it defined. This fixes the build for arches different than amd64 after 7d3259775cb69f250df3e7fe51d6fff2283c6f20. Sponsored by: Citrix Systems R&D Reported by: lwhsu, arichardson
* stand/multiboot2: add support for booting a Xen dom0 in UEFI modeRoger Pau Monné2021-02-165-0/+1001
| | | | | | | | | | | | | | | | | | | | Add some basic multiboot2 infrastructure to the EFI loader in order to be capable of booting a FreeBSD/Xen dom0 when booted from UEFI. Only a very limited subset of the multiboot2 protocol is implemented in order to support enough to boot into Xen, the implementation doesn't intend to be a full multiboot2 capable implementation. Such multiboot2 functionality is hooked up into the amd64 EFI loader, which is the only architecture that supports Xen dom0 on FreeBSD. The options to boot a FreeBSD/Xen dom0 system are exactly the same as on BIOS, and requires setting the xen_kernel and xen_cmdline options in loader.conf. Sponsored by: Citrix Systems R&D Reviewed by: tsoome, imp Differential revision: https://reviews.freebsd.org/D28497
* stand/efi: add modulep to kernel metadataRoger Pau Monné2021-02-161-3/+6
| | | | | | | | | | | | | | This mirrors the functionality of the BIOS amd64 bi_load function, that stashes the absolute address of the module metadata. This is required for booting as a Xen dom0 that does relocate the modulep and the loaded modules, and thus requires adjusting the offset. No functional change introduced, further patches will make use of this functionality for Xen dom0 loading. Sponsored by: Citrix Systems R&D Reviewed by: imp Differential revision: https://reviews.freebsd.org/D28496
* stand/efi: allow not exiting boot servicesRoger Pau Monné2021-02-166-14/+20
| | | | | | | | | | | | | | | | | | Xen requires that UEFI BootServices are enabled in order to boot, so introduce a new parameter to bi_load in order to select whether BS should be exited. No functional change introduced in this patch, as all current users of bi_load request BS to be exited. Further changes will make use of this functionality. Note the memory map is still appended to the kernel metadata, even when it could be modified by further calls to the Boot Services, as it will be used to detect if the kernel has been booted from UEFI. Sponsored by: Citrix Systems R&D Reviewed by: tsoome, imp Differential revision: https://reviews.freebsd.org/D28495
* loader.efi: There are systems without ConOut, also use ConOutDevToomas Soome2021-02-041-0/+2
| | | | | | | | Conout does contian the default output device name. ConOutDev does contain all possible output device names, so we can use it as fallback, when there is no ConOut. PR: 253253
* loader: create built in font from bold font faceToomas Soome2021-01-231-1/+1
| | | | | We did replace full version of default font 8x16v with bold, also use bold version for built in font.
* loader: Use TERM_EMU for arm and arm64Emmanuel Vadot2021-01-171-3/+0
| | | | | | | | | | Even if it didn't behave well previously this is fixed. Tested on: OrangePi One (armv7 u-boot) (serial only and serial + HDMI) Tested on: Pine64-LTS (aarch64 u-boot) (serial only and serial + HDMI) Tested on: Honeycomb (aarch64 EDK2) (serial only) Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D28153
* loader.efi: commands gop, uga and autoresize should use cached dataToomas Soome2021-01-171-30/+17
| | | | | We are setting up pointers for gop or uga protocol in efi_find_framebuffer(), reuse those pointers.
* loader.efi: variable 'hlist' is uninitializedToomas Soome2021-01-171-0/+1
| | | | framebuffer.c:481:65: error: variable 'hlist' is uninitialized
* loader.efi: unused variable 'mode'Toomas Soome2021-01-171-1/+0
| | | | | framebuffer.c:707:8: error: unused variable 'mode' [-Wunused-variable] u_int mode;
* loader.efi: handle multiple gop instancesToomas Soome2021-01-161-1/+36
| | | | | | | | Some systems may provide multiple GOP instances and not all are bound to hardware. The current loader is picking up the first GOP, which may not be usable. Instead we load the GOP handle array, and test every handle to have registered ConOut protocol. If ConOut is present, we can use this GOP handle to open GOP protocol.
* Revert "loader.efi: disable workaround for serial console on non-x86"Toomas Soome2021-01-131-4/+0
| | | | | | This patch is creating some issues, reverting it. This reverts commit 8b18395487506d3602205e5844e0b67ba0c0dc80.
* loader.efi: initial terminal size should base on UEFI terminal sizeToomas Soome2021-01-131-6/+6
| | | | | | We do select font based on desired terminal size, we do query UEFI terminal size with conout->QueryMode(), but by mistake, the fallback values are used.
* loader.efi: disable workaround for serial console on non-x86Toomas Soome2021-01-121-0/+4
| | | | | As efi console is drawn and with functional comconsole driver, we can use proper terminal emulator on efi framebuffer console.
* loader.efi: reworked framebuffer setupToomas Soome2021-01-126-63/+90
| | | | | | | | | | | | | | Pass gfx_state to efi_find_framebuffer(), so we can pick between GOP and UGA in efi_find_framebuffer(), also we can then set up struct gen_fb in gfx_state from efifb and isolate efi fb data processing into framebuffer.c. This change does allow us to clean up efi_cons_init() and reduce BS->LocateProtocol() calls. A little downside is that we now need to translate gen_fb back to efifb in bootinfo.c (for passing to kernel), and we need to add few -I options to CFLAGS.
* loader.efi: efifb_mask_from_pixfmt is missing PixelBltOnlyToomas Soome2021-01-111-0/+1
| | | | We are missing way to set RGB masks for BLT only framebuffer.
* loader: term_image_display() should test screen_bufferToomas Soome2021-01-101-0/+3
| | | | Make sure screen_buffer is not NULL.