Commit Graph

177 Commits

Author SHA1 Message Date
riastradh c9c7ef91a2 efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe.
Patch from jakllsch@.  Makes Socionext Synquacer boot considerably
more reliably.

PR kern/58075
2024-03-28 18:24:57 +00:00
kre 3f351f34c6 Compensate for src/common/lib/libc/atomic/atomic_init_cas.c losing
the extern declaration of __libc_atomic_init() and instead using a
new one added to src/lib/libc/include/extern.h

That file is outside src/common and src/sys so is unavailable to
kernel builds, so instead make a new include file in src/common
which the kernel can read which contains the needed extern decl
for __libc_atomic_init()

This seems to fix the evbarm builds (maybe others) - but it is
all MUCH TOO UGLY to keep.   Someone please make a better fix,
even if that just means reverting rev 1.5 of
	src/common/lib/libc/atomic/atomic_init_cas.c
and all of the changes here (the addition to libc/include/extern.h
should be harmless to keep).
2024-01-20 11:04:53 +00:00
rin 71d224f4ab MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE"
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7

Some UEFI implementations pass multiple boot options as boot device path,
and NULL-clearing it results in boot failures.

Thanks skrll@ for pointing it out.
2024-01-01 13:38:57 +00:00
rin 9b625a9615 MI efiboot: efi_net_probe: Examine Messaging Device Path also
Network devices can be found as Hardware or Messaging Device Paths,
see Sec 10.4.4 of UEFI Spec 2.10.

In addition to Hardware Device Path, try Messaging Device Path also.
This fixes PXE boot on implementations with the latter choice, e.g.,
Raspberry Pi 4 UEFI firmware.
2023-12-27 09:40:35 +00:00
rin 9bb7bf1efd MI efiboot: Stop using efi_bootdp after exclusive open for PXE
Once boot device is exclusively opened for Simple Network Protocol,
further access via device path (efi_bootdp) is illegal.

For some implementations, boot device path gets corrupted by
exclusive open, and subsequent access by efi_device_path_depth(),
e.g., causes infinite recursion.

Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions.

Thanks yamaguchi@ for comments and tests.
2023-12-27 09:28:04 +00:00
mrg f8570f8a97 fix simple mis-matched function prototype and definitions.
most of these are like, eg

   void foo(int[2]);

with either of these

   void foo(int*) { ... }
   void foo(int[]) { ... }

in some cases (such as stat or utimes* calls found in our header files),
we now match standard definition from opengroup.

found by GCC 12.
2023-08-01 07:04:14 +00:00
rin 2f98cf5924 MI and x86 efiboot: Fix device path type for PXE boot device.
It should be Messaging, not Media Device Path. Taken from OpenBSD, for
which this code was originally written:

https://cvsweb.openbsd.org/src/sys/arch/amd64/stand/efiboot/efipxe.c#rev1.6

> Network-based device paths use Messaging and not Media types.  Thus
> in reality the depth was always -1 which made the compare function
> a No-Op.  Properly check the device path depth value and look for
> the Messaging type instead to find the correct NIC.  This check
> never worked before and was uncovered by the last change.
>
> Regression noticed by bluhm@
2023-07-24 08:30:42 +00:00
rin 31ea34f610 Add missing include paths for libz. Not used at the moment although. 2023-06-15 03:20:58 +00:00
rin 105d60dd27 Use %zd instead of %ld for ssize_t. 2023-06-14 10:26:45 +00:00
rin fc7406911a Avoid void * pointer arithmetic; cast to UINT8 * explicitly.
No binary changes for aarch64 at least.
2023-06-14 00:52:25 +00:00
rin dea74b4df0 Add missing member for terminating sentinel. 2023-06-14 00:42:21 +00:00
lukem a9a927dd92 adapt to ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
Simplify CWARNFLAGS to use ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
which works for both clang and gcc, and remove compiler-specific
equivalents.
2023-06-03 21:26:27 +00:00
lukem f937c412f3 bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER
Provide a single variable
	CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
	CLANG_NO_ADDR_OF_PACKED_MEMBER
	CC_NO_ADDR_OF_PACKED_MEMBER
	GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 08:52:53 +00:00
riastradh fc9e0a3662 efiboot: Handle 9.99.100 by taking four, not two, digits.
We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00
in almos two decades so we're apparently reclaiming it as MMmmpppp00.
2022-09-21 14:30:01 +00:00
jmcneill 6aa6feb5ce Align output of "version" command. 2022-08-14 11:26:41 +00:00
wiz f2766c1123 Remove now unused bootdefault() function.
Part of PR 56862.
2022-06-08 21:55:51 +00:00
mlelstv 3b509fadef Use physical sector size as unit for disk addresses.
Provide new ioctl to libsa to query for sector size.
2022-04-24 06:49:38 +00:00
skrll e65a0eaa66 Update to support EFI runtime outside the kernel virtual address space
by creating an EFI RT pmap that can be activated / deactivated when
required.

Adds support for EFI RT to ARM_MMU_EXTENDED (ASID) 32-bit Arm machines.

On Arm64 the usage of pmapboot_enter is reduced and the mappings are
created much later in the boot process -- now in cpu_startup_hook.
Backward compatiblity for KVA mapped RT from old bootaa64.efi is
maintained.

Adding support to other platforms should be easier as a result.
2022-04-02 11:16:06 +00:00
jmcneill 97eb8c2aa1 efiboot: Add support for 'userconf' command.
Add support for the 'userconf' command at the boot prompt and in boot.cfg,
and for FDT based booting, pass the commands as a string list property
named "netbsd,userconf" on the /chosen node.
2022-03-25 21:23:00 +00:00
jmcneill eb0b9b2d41 Revert part of previous commit that broke DT booting. 2021-11-06 19:44:22 +00:00
skrll f79dfb09a9 Fix non-ACPI builds. 2021-11-04 07:28:34 +00:00
skrll 3391ae68d7 Provide the ablity to ignore ACPI with an 'acpi' command:
acpi [{on|off}]
2021-11-03 22:02:36 +00:00
jmcneill 0d0005b744 If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work
as expected.
2021-10-30 11:18:51 +00:00
jmcneill cc0e6e64a2 Honour the timeout= entry in boot.cfg 2021-10-17 14:12:54 +00:00
jmcneill 7184e6f5e1 efiboot: add "setup" command
The "setup" command sets the 64-bit "OsIndications" variable to the value of
EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that
supports this, after reboot the user will be presented with the firmware
setup menu.
2021-10-09 13:09:17 +00:00
jmcneill 91912cfdce EFIBOOT_FDT=yes for riscv64 too 2021-10-06 11:26:21 +00:00
jmcneill 8f6a45042c Fix bootarm build. 2021-10-06 10:15:20 +00:00
jmcneill 0e916d8ec6 efiboot: Make FDT support optional on a per-arch basis. 2021-10-06 10:13:19 +00:00
jmcneill 75ee990f93 efiboot: Add efigop.c 2021-09-28 11:38:07 +00:00
jmcneill f719aa4dda efiboot: Add support for changing the video mode.
Add a new "gop" command that can query the list of available video modes.
With a mode number as argument (eg. "gop 16"), the new display mode will
be selected.

The "version" command prints the current display mode.
2021-09-28 11:37:45 +00:00
andvar b58602814f fix typos in word "successful". 2021-09-16 22:19:10 +00:00
nia b7fed38c88 Remove banner printing code from bootloaders, add it to libsa.
This harmonizes efiboot and the various x86 bootloaders to use shared
code for printing the banner. By friendly coincidence, it also adds
support for specifying 'banner=' in arm efiboot's boot.cfg, as on x86.
2021-09-07 11:41:31 +00:00
andvar db383f4739 s/partion/partition/ s/arrray/array/ in comments. 2021-08-08 21:50:10 +00:00
jmcneill 00ae5d3064 efiboot: Allow "fs" as alias for "initrd", for compat with x86 2021-07-24 10:22:28 +00:00
jmcneill a3c7cf62e3 efiboot: Add support for SMBIOS 2.x tables. 2021-07-23 21:33:00 +00:00
jmcneill 1dfd54efe0 When printing memory size, don't promote to next unit size unless it is at
two digits.
2021-06-23 21:43:38 +00:00
jmcneill b005340046 fix typo 2021-06-23 21:42:43 +00:00
jmcneill 4f2753c809 Fix buffer size for alignment adjusted block I/O reads. 2021-06-23 20:55:50 +00:00
jmcneill 71e5700803 print_banner: Print memory size like x86 does 2021-06-23 00:38:12 +00:00
jmcneill 6d43264c7e efiboot: Use EFI_BLOCK_IO_PROTOCOL if EFI_DISK_IO_PROTOCOL is missing
UEFI spec says that firmware should automatically add EFI_DISK_IO_PROTOCOL
for all produced EFI_BLOCK_IO_PROTOCOL interfaces. Unfortunately U-Boot
doesn't do this, so fallback to block I/O if disk I/O is not there.
2021-06-22 21:56:51 +00:00
jmcneill e65029459a efirng: fix va_num arg to uefi_call_wrapper for GetRNG calls
As far as I can tell this param isn't actually used, but it is supposed to
be the number of arguments passed to the called method.
2021-06-22 10:19:35 +00:00
jmcneill 1fb28d9605 efiboot: Add readahead support.
Reading data through libsa file-systems ends up breaking block I/O
accesses into very small (512-byte or 2048-byte) accesses. This can be
very inefficient, and causes Ampere eMAG w/ BMC image direction to take
_minutes_ to load the install image and kernel. So slow in fact that
the default watchdog timeout will fire before it finishes.

So, when loading big files, optimistically read ahead up to 64KB of data.
Brings the time to boot the install ISO down to around 40 seconds -- still
not ideal but way better than before.
2021-06-21 21:18:47 +00:00
nia 7e8c1be744 efiboot: Add ASCII art. 2021-06-21 19:07:30 +00:00
jmcneill 8a389c90b9 efiboot: Use disk I/O protocol for block device access.
EFI_DISK_IO_PROTOCOL is a simplified interface to block devices. Use this
instead of EFI_BLOCK_IO_PROTOCOL for accessing block devices to simplify
the code -- we no longer need to worry about the underlying media's block
I/O size and alignment requirements.
2021-06-21 11:11:33 +00:00
jmcneill 6b551144f4 Add support for the boot services watchdog and pet it on every block I/O
access. For slow media (like ISO image redirection on Lenovo HR330A BMC)
this is needed because otherwise the default watchdog timeout fires before
we can finish loading the kernel from install media.
2021-06-20 19:10:47 +00:00
jmcneill dc5f02b192 Enable the twiddle spinner when loading the kernel, ramdisk images, and
modules.
2021-06-20 19:07:39 +00:00
rin 772d3cdddb Generalize boot.cfg workaround for ISO9660; fallback to default_device
whenever efi_file_path() fails (due to broken firmware), in addition to
the case of ISO9660 (for which efi_file_path() succeeds but does not
work correctly).
2021-05-31 11:12:42 +00:00
mrg 13c625776c add bi-endian support to the libsa ufs reader and enable it in efiboot.
ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.)  these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member.  accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.)  sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up.  (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c.  (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size.  booted several platforms with
new boot code.
2021-05-27 06:54:44 +00:00
mrg 9fe5ff397d add basic raidframe support to efiboot.
if raid disklabel or gpt is found, add this partition with
the offset/size adjusted by RF_PROTECTED_SECTORS.  note

don't le32toh() the disklabel.  if it was wrong-endian, then
getdisklabel() will have swapped it.

ok jmcneill thorpej.
2021-05-26 09:42:36 +00:00
jmcneill 293024b5c6 Disable ACPI support when booting big endian kernels. 2021-05-21 21:53:15 +00:00