aboutsummaryrefslogtreecommitdiff
path: root/stand/efi/loader
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-211-4/+2
| | | | | | | | | 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: switch boot_services_gone to boot_services_activeWarner Losh2021-11-042-6/+2
| | | | | | | | | | | 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
* 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-081-7/+7
| | | | | | | | | 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
* 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
* efi/loader: Call tslog_initColin Percival2021-06-211-0/+2
| | | | This allows the EFI loader to start recording timestamps.
* 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
* 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-271-4/+92
| | | | | | | | | | | 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')
* 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.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.
* loader.efi: reworked framebuffer setupToomas Soome2021-01-124-21/+70
| | | | | | | | | | | | | | 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: implement framebuffer consoleToomas Soome2021-01-024-14/+35
| | | | | | | | | | | | | | | | | | | | | | | Draw console on efi. Add vbe framebuffer for BIOS loader (vbe off, vbe on, vbe list, vbe set xxx). autoload font (/boot/fonts) based on resolution and font size. Add command loadfont (set font by file) and variable screen.font (set font by size). Pass loaded font to kernel. Export variables: screen.height screen.width screen.depth Add gfx primitives to draw the screen and put png image on the screen. Rework menu draw to iterate list of consoles to enamble device specific output. Probably something else I forgot... Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27420
* efi loader: fix typos in a commentEric van Gyzen2021-01-011-4/+4
| | | | | | ...mostly because it's a harmless way to try the shiny new git repo. Sponsored by: Dell EMC Isilon
* Drop EFI_STAGING_SIZE back down to 64MWarner Losh2020-12-171-3/+1
| | | | | | | | | | | vmware can't cope with anything larger than 64MB. Drop this back to 64MB everywhere but arm. PR: 251866 MFC After: 1 week Notes: svn path=/head/; revision=368721
* loader: Ignore the .interp section on RISC-VJessica Clarke2020-12-141-0/+1
| | | | | | | | | | | | | | Without this we risk having the .interp section be placed earlier in the file and mess with section offsets; in particular it has been seen to be placed at the start of the file and cause the PE/COFF header to not be at address 0. This is the same fix as was done for arm64 in r365578. Reviewed by: mhorne, imp Approved by: mhorne, imp Differential Revision: https://reviews.freebsd.org/D27603 Notes: svn path=/head/; revision=368626
* Unobfuscate "KERNLOAD" parameter on amd64. This change lines-up amd64 with theMaxim Sobolev2020-11-251-5/+3
| | | | | | | | | | | | | | | | | i386 and the rest of supported architectures by defining KERNLOAD in the vmparam.h and getting rid of magic constant in the linker script, which albeit documented via comment but isn't programmatically accessible at a compile time. Use KERNLOAD to eliminate another (matching) magic constant 100 lines down inside unremarkable TU "copy.c" 3 levels deep in the EFI loader tree. Reviewed by: markj Approved by: markj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D27355 Notes: svn path=/head/; revision=368041
* Add 'netserver' command to EFI loader.Michal Meloun2020-10-141-0/+35
| | | | | | | | | | | | | | | | | | In some environments is difficult to access bootp/dhcp configuration as "standard user". Add a command that allows to set or display the URI of the network server used as "net:" device. Currently only tftp and nfs protocols are supported. Typical usage pattern is: netserver tftp://192.168.168.1/path_to_obj_dir/arm.armv7/sys/GENERIC/ boot net:kernel Reviewed by: imp, kevans MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D26736 Notes: svn path=/head/; revision=366700
* Use adrp in the arm64 efi loaderAndrew Turner2020-10-131-5/+10
| | | | | | | | | | | | | | | | | On startup the arm64 efi loaders need to know PC-relative addresses. Previously we used the adr instruction to find this address, however this instruction is limited to +/- 1MiB. Switch to adrp to find the 4k page the address is within and an add to set the bottom 12 bits. This lets us address +/- 4GiB which should be large enough for now. Reported by: imp MFC after: 2 weeks Sponsored by: Innovate UK Notes: svn path=/head/; revision=366670
* Link efi programs with -pie rather than -sharedAlex Richardson2020-10-121-1/+1
| | | | | | | | | | | This was causing build failures in CheriBSD where we were passing -pie already by default. Reviewed By: andrew Differential Revision: https://reviews.freebsd.org/D24787 Notes: svn path=/head/; revision=366644
* Fix video on PCI heuristicWarner Losh2020-09-281-2/+4
| | | | | | | | | | | | | | | | | | The video on PCI heuristic was broken. It was supposed to infer a video device when the last element of the path was a PCI DEVICE PATH node. However, the last node in the device path is an END node, so this heuristic never fired. This leads, among other things, to bhyve only producing output in the serial connection once we leave the boot loader. This restores the dual headed boot on bhyve + UEFI (as we did in 11.2), but will favor serial in the absence of other config which may be a change from 11.2. MFC After: 3 days Differential Revision: https://reviews.freebsd.org/D26572 Notes: svn path=/head/; revision=366216
* loader: fix non-zfs buildToomas Soome2020-09-231-0/+2
| | | | | | | | | We can not include zfs headers while building without zfs. Reported by: Oscar Holmlund Notes: svn path=/head/; revision=366087
* loader: zfs should support bootonce an nextbootToomas Soome2020-09-212-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bootonce feature is temporary, one time boot, activated by "bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag. By default, the bootonce setting is reset on attempt to boot and the next boot will use previously active BE. By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will be set permanently active. bootonce dataset name is recorded in boot pool labels, bootenv area. in case of nextboot, the nextboot_enable boolean variable is recorded in freebsd:nvstore nvlist, also stored in boot pool label bootenv area. On boot, the loader will process /boot/nextboot.conf if nextboot_enable is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf processing on next boot. bootonce and nextboot features are usable in both UEFI and BIOS boot. To use bootonce/nextboot features, the boot loader needs to be updated on disk; if loader.efi is stored on ESP, then ESP needs to be updated and for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated (gpart or other tools). At this time, only lua loader is updated. Sponsored by: Netflix, Klara Inc. Differential Revision: https://reviews.freebsd.org/D25512 Notes: svn path=/head/; revision=365938
* Ignore the .interp section in the arm64 EFI loaderAndrew Turner2020-09-101-0/+1
| | | | | | | | | | | | When building the loader an unneeded .interp section may be added. Move this to the unused section region so offsets of used sections don't change. Obtained from: CheriBSD Sponsored by: Innovate UK Notes: svn path=/head/; revision=365578
* Quiet int-to-pointer-cast warnings on i386 with GCC 9.John Baldwin2020-09-041-2/+2
| | | | | | | | Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D26200 Notes: svn path=/head/; revision=365318
* zfs: add an option to the bootloader to rewind the ZFS checkpointMariusz Zaborski2020-08-181-1/+1
| | | | | | | | | | | | | | | | | | The checkpoints are another way of keeping the state of ZFS. During the rewind, the pool has to be exported. This makes checkpoints unusable when using ZFS as root. Add the option to rewind the ZFS checkpoint at the boot time. If checkpoint exists, a new option for rewinding a checkpoint will appear in the bootloader menu. We fully support boot environments. If the rewind option is selected, the boot loader will show a list of boot environments that existed before the checkpoint. Reviewed by: tsoome, allanjude, kevans (ok with high-level overview) Differential Revision: https://reviews.freebsd.org/D24920 Notes: svn path=/head/; revision=364355
* loader: Avoid -Wpointer-to-int cast warnings for Arm and RISC-VJessica Clarke2020-07-262-2/+2
| | | | | | | | | | | | | | | | | On RISC-V, Clang warns with: cast to smaller integer type 'unsigned int' from 'void (*)(void *)' Instead, use %p as the standard format specifier for printing pointers. Whilst Arm's pointer size is the same as unsigned, it's still cleaner to use the right thing there too. Reviewed by: brooks (mentor), emaste Approved by: brooks (mentor), emaste Differential Revision: https://reviews.freebsd.org/D25718 Notes: svn path=/head/; revision=363572