]> git.ipfire.org Git - thirdparty/ipxe.git/log
thirdparty/ipxe.git
17 hours ago[dwmac] Show core version in debug messages coverity_scan master
Michael Brown [Wed, 30 Jul 2025 14:59:38 +0000 (15:59 +0100)] 
[dwmac] Show core version in debug messages

Read and display the core version immediately after mapping the MMIO
registers, to provide a basic sanity check that the registers have
been correctly mapped and the core is not held in reset.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
18 hours ago[bnxt] Remove unnecessary test_if macro
Michael Brown [Wed, 30 Jul 2025 13:08:25 +0000 (14:08 +0100)] 
[bnxt] Remove unnecessary test_if macro

Signed-off-by: Michael Brown <mcb30@ipxe.org>
19 hours ago[bnxt] Remove unnecessary I/O macros 1507/head
Joseph Wong [Thu, 24 Jul 2025 18:41:16 +0000 (11:41 -0700)] 
[bnxt] Remove unnecessary I/O macros

Remove unnecessary driver specific macros.  Use standard
pci_read_config_xxxx, pci_write_config_xxx, writel/q calls.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
19 hours ago[serial] Explicitly initialise serial console UART to NULL
Michael Brown [Wed, 30 Jul 2025 12:40:36 +0000 (13:40 +0100)] 
[serial] Explicitly initialise serial console UART to NULL

When debugging is enabled for the device tree or memory map parsing
code, the active serial console UART variable will be accessed during
early initialisation, before the .bss section has been zeroed.

Place this variable in the .data section (by providing an explicit
initialiser), so that reading this variable is well defined even
during early initialisation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
19 hours ago[riscv] Place explicitly zero-initialised variables in the .data section
Michael Brown [Wed, 30 Jul 2025 12:14:21 +0000 (13:14 +0100)] 
[riscv] Place explicitly zero-initialised variables in the .data section

Variables in the .bss section cannot be relied upon to have zero
values during early initialisation, before we have relocated ourselves
to somewhere suitable in RAM and zeroed the .bss section.

Place any explicitly zero-initialised variables in the .data section
rather than in .bss, so that we can rely on their values even during
this early initialisation stage.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
20 hours ago[riscv] Allow for poisoning .bss section before early initialisation
Michael Brown [Wed, 30 Jul 2025 10:11:00 +0000 (11:11 +0100)] 
[riscv] Allow for poisoning .bss section before early initialisation

On startup, we may be running from read-only memory, and therefore
cannot zero the .bss section (or write to the .data section) until we
have parsed the system memory map and relocated ourselves to somewhere
suitable in RAM.  The code that runs during this early initialisation
stage must be carefully written to avoid writing to the .data section
and to avoid reading from or writing to the .bss section.

Detecting code that erroneously writes to the .data or .bss sections
is relatively easy since running from read-only memory (e.g. via
QEMU's -pflash option) will immediately reveal the bug.  Detecting
code that erroneously reads from the .bss section is harder, since in
a freshly powered-on machine (or in a virtual machine) there is a high
probability that the contents of the memory will be zero even before
we explicitly zero out the section.

Add the ability to fill the .bss section with an invalid non-zero
value to expose bugs in early initialisation code that erroneously
relies upon variables in .bss before the section has been zeroed.  We
use the value 0xeb55eb55eb55eb55 ("EBSS") since this is immediately
recognisable as a value in a crash dump, and will trigger a page fault
if dereferenced since the address is in a non-canonical form.

Poisoning the .bss can be done only when the image is known to already
reside in writable memory.  It will overwrite the relocation records,
and so can be done only on a system where relocation is known to be
unnecessary (e.g. because paging is supported).  We therefore do not
enable this behaviour by default, but leave it as a configurable
option via the config/fault.h header.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 days ago[undi] Assume that legacy interrupts are broken for any PCIe device
Michael Brown [Thu, 24 Jul 2025 12:59:42 +0000 (13:59 +0100)] 
[undi] Assume that legacy interrupts are broken for any PCIe device

PCI Express devices do not have physical INTx output signals, and on
modern motherboards there is unlikely to be any interrupt controller
with physical interrupt input signals.  There are multiple levels of
abstraction involved in emulating the legacy INTx interrupt mechanism:
the PCIe device sends Assert_INTx and Deassert_INTx messages, PCIe
bridges and switches must collate these virtual wires, and the root
complex must map the virtual wires into messages that can be
understood by the host's emulated 8259 PIC.

This complex chain of emulations is rarely tested on modern hardware,
since operating systems will invariably use MSI-X for PCI devices and
the I/O APIC for non-PCI devices such as the real-time clock.  Since
the legacy interrupt emulation mechanism is rarely tested, it is
frequently unreliable.  We have encountered many issues over the years
in which legacy interrupts are simply not raised as expected, even
when inspection shows that the device believes it is asserting an
interrupt and the controller believes that the interrupt is enabled.

We already maintain a list of devices that are known to fail to
generate legacy interrupts correctly.  This list is based on the PCI
vendor and device IDs, which is not necessarily a fair test since the
root cause may be a board-level misconfiguration rather than a
device-level fault.

Assume that any PCI Express device has a high chance of not being able
to raise legacy interrupts reliably.  This is a relatively intrusive
change since it will affect essentially all modern network devices,
but should hopefully fix all future issues with non-functional legacy
interrupts, without needing to constantly grow the list of known
broken devices.

If some PCI Express devices are found to fail when operated in polling
mode, then this change will need to be revisited.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 days ago[pxeprefix] Display PCI vendor and device ID in PXE startup banner
Michael Brown [Wed, 23 Jul 2025 15:11:09 +0000 (16:11 +0100)] 
[pxeprefix] Display PCI vendor and device ID in PXE startup banner

In the case of a misbehaving PXE stack, it is often useful to know the
PCI vendor and device IDs (e.g. for adding the device to the list of
devices with known broken support for generating interrupts).

The PCI vendor and device ID is already available to the prefix code,
and so can trivially be printed out.  Add this information to the PXE
prefix startup banner.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
8 days ago[fdt] Add ability to locate node by phandle
Michael Brown [Tue, 22 Jul 2025 12:37:05 +0000 (13:37 +0100)] 
[fdt] Add ability to locate node by phandle

Signed-off-by: Michael Brown <mcb30@ipxe.org>
9 days ago[dwusb] Add driver for DesignWare USB3 host controller
Michael Brown [Mon, 21 Jul 2025 12:44:38 +0000 (13:44 +0100)] 
[dwusb] Add driver for DesignWare USB3 host controller

Add a basic driver for the DesignWare USB3 host controller as found in
the Lichee Pi 4A.

This driver covers only the DesignWare host controller hardware.  On
the Lichee Pi 4A, this is sufficient to get the single USB root hub
port (exposed internally via the SODIMM connector) up and running.

The driver does not yet handle the various GPIOs that control power
and signal routing for the Lichee Pi 4A's onboard VL817 USB hub and
the four physical USB-A ports.  This therefore leaves the USB hub and
the USB-A ports unpowered, and the USB2 root hub port routed to the
physical USB-C port.  Devices plugged in to the USB-A ports will not
be powered up, and a device plugged in to the USB-C port will
enumerate as a USB2 device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
9 days ago[xhci] Allow for non-PCI xHCI host controllers
Michael Brown [Mon, 21 Jul 2025 12:43:32 +0000 (13:43 +0100)] 
[xhci] Allow for non-PCI xHCI host controllers

Allow for the existence of xHCI host controllers where the underlying
hardware is not a PCI device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
12 days ago[xhci] Use root hub port number to determine slot type
Michael Brown [Fri, 18 Jul 2025 13:24:23 +0000 (14:24 +0100)] 
[xhci] Use root hub port number to determine slot type

We currently use the downstream hub's port number to determine the
xHCI slot type for a newly connected USB device.  The downstream hub
port number is irrelevant to the xHCI controller's supported protocols
table: the relevant value is the number of the root hub port through
which the device is attached.

Fix by using the root hub port number instead of the immediate parent
hub's port number.

This bug has not previously been detected since the slot type for the
first N root hub ports will invariably be zero to indicate that these
are USB ports.  For any xHCI controller with a sufficiently large
number of root hub ports, the code would therefore end up happening to
calculate the correct slot type value despite using an incorrect port
number.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[efi] Check only the non-extended WaitForKey event
Michael Brown [Tue, 15 Jul 2025 15:56:11 +0000 (16:56 +0100)] 
[efi] Check only the non-extended WaitForKey event

The WaitForKeyEx event in EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is
redundant: by definition it has to signal under exactly the same
conditions as the WaitForKey event in EFI_SIMPLE_TEXT_INPUT_PROTOCOL
and cannot provide any "extended" information since EFI events do not
convey any information beyond their own occurrence.

UEFI keyboard drivers such as Ps2KeyboardDxe and UsbKbDxe invariably
use a single notification function to implement both events.  The
console multiplexer driver ConSplitterDxe uses a single notification
function for both events, which ends up checking only the WaitForKey
event on the underlying console devices.  (Since all console input is
routed through the console multiplexer, this means that in practice
nothing will ever check the underlying devices' WaitForKeyEx events.)

UEFI console consumers such as the UEFI shell tend to use only the
EFI_SIMPLE_TEXT_INPUT_PROTOCOL instance provided as ConIn in the EFI
system table.  With the exception of the UEFI text editor (the "edit"
command in the UEFI shell), almost nothing bothers to open the
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance on the same handle.

The Lenovo ThinkPad T14s Gen 5 has a very peculiar firmware bug.
Enabling the "UEFI Wi-Fi Network Boot" feature in the BIOS setup will
cause the completely unrelated WaitForKeyEx event pointer to be
overwritten with a pointer to a FAT_DIRENT structure representing the
"BOOT" directory in the EFI system partition.  This happens with 100%
repeatability.  It is not necessary to attempt to boot from Wi-Fi: it
is only necessary to have the feature enabled.  The root cause is
unknown, but is presumably an uninitialised pointer or similar
memory-related bug in Lenovo's UEFI Wi-Fi driver.

Work around this Lenovo firmware bug by checking only the WaitForKey
event, ignoring the WaitForKeyEx event even if we will subsequently
use ReadKeyStrokeEx() to read the keypress.  Since almost all other
UEFI console consumers use only WaitForKey, this ensures that we will
be using code paths that the firmware vendor is likely to have tested
at least once.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[efi] Allow compiler to perform type checks on EFI_EVENT
Michael Brown [Tue, 15 Jul 2025 15:51:05 +0000 (16:51 +0100)] 
[efi] Allow compiler to perform type checks on EFI_EVENT

As with EFI_HANDLE, the EFI headers define EFI_EVENT as a void
pointer, rendering EFI_EVENT compatible with a pointer to itself and
hence guaranteeing that pointer type bugs will be introduced.

Redefine EFI_EVENT as a pointer to an anonymous structure (as we
already do for EFI_HANDLE) to allow the compiler to perform type
checking as expected.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[init] Show initialisation function names in debug messages
Michael Brown [Tue, 15 Jul 2025 13:08:15 +0000 (14:08 +0100)] 
[init] Show initialisation function names in debug messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[efi] Assume that vendor wireless drivers are unusable via SNP
Michael Brown [Tue, 15 Jul 2025 08:12:54 +0000 (09:12 +0100)] 
[efi] Assume that vendor wireless drivers are unusable via SNP

The UEFI model for wireless network boot cannot sensibly be described
without cursing.  Commit 758a504 ("[efi] Inhibit calls to Shutdown()
for wireless SNP devices") attempts to work around some of the known
issues.

Experimentation shows that on at least some platforms (observed with a
Lenovo ThinkPad T14s Gen 5) the vendor SNP driver is broken to the
point of being unusable in anything other than the single use case
envisioned by the firwmare authors.  Doing almost anything directly
via the SNP protocol interface has a greater than 50% chance of
locking up the system.

Assume, in the absence of any evidence to the contrary so far, that
vendor SNP drivers for wireless network devices are so badly written
as to be unusable.  Refuse to even attempt to interact with these
drivers via the SNP or NII protocol interfaces.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[efi] Drop to external TPL for calls to ConnectController()
Michael Brown [Mon, 14 Jul 2025 11:17:11 +0000 (12:17 +0100)] 
[efi] Drop to external TPL for calls to ConnectController()

There is nothing in the current versions of the UEFI specification
that limits the TPL at which we may call ConnectController() or
DisconnectController().  However, at least some platforms (observed
with a Lenovo ThinkPad T14s Gen 5) will occasionally and unpredictably
lock up before returning from ConnectController() if called at a TPL
higher than TPL_APPLICATION.

Work around whatever defect is present on these systems by dropping to
the current external TPL for all calls to ConnectController() or
DisconnectController().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[efi] Provide efi_tpl_name() for transcribing TPLs in debug messages
Michael Brown [Mon, 14 Jul 2025 11:15:08 +0000 (12:15 +0100)] 
[efi] Provide efi_tpl_name() for transcribing TPLs in debug messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Ensure coherent DMA allocations do not cross cacheline boundaries
Michael Brown [Fri, 11 Jul 2025 12:50:41 +0000 (13:50 +0100)] 
[riscv] Ensure coherent DMA allocations do not cross cacheline boundaries

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Support the standard Svpbmt extension for page-based memory types
Michael Brown [Fri, 11 Jul 2025 11:24:02 +0000 (12:24 +0100)] 
[riscv] Support the standard Svpbmt extension for page-based memory types

Set the appropriate Svpbmt type bits within page table entries if the
extension is supported.  Tested only in QEMU so far, due to the lack
of availability of real hardware supporting Svpbmt.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Create coherent DMA mapping of 32-bit address space on demand
Michael Brown [Fri, 11 Jul 2025 11:00:10 +0000 (12:00 +0100)] 
[riscv] Create coherent DMA mapping of 32-bit address space on demand

Reuse the code that creates I/O device page mappings to create the
coherent DMA mapping of the 32-bit address space on demand, instead of
constructing this mapping as part of the initial page table.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Use 1GB pages for I/O device mappings
Michael Brown [Fri, 11 Jul 2025 10:30:57 +0000 (11:30 +0100)] 
[riscv] Use 1GB pages for I/O device mappings

All 64-bit paging schemes support at least 1GB "gigapages".  Use these
to map I/O devices instead of 2MB "megapages".  This reduces the
number of consumed page table entries, increases the visual similarity
of I/O remapped addresses to the underlying physical addresses, and
opens up the possibility of reusing the code to create the coherent
DMA map of the 32-bit address space.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[dwmac] Add driver for DesignWare Ethernet MAC
Michael Brown [Thu, 10 Jul 2025 12:44:37 +0000 (13:44 +0100)] 
[dwmac] Add driver for DesignWare Ethernet MAC

Add a basic driver for the DesignWare Ethernet MAC network interface
as found in the Lichee Pi 4A.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Invalidate data cache on completed RX DMA buffers
Michael Brown [Thu, 10 Jul 2025 13:33:34 +0000 (14:33 +0100)] 
[riscv] Invalidate data cache on completed RX DMA buffers

The data cache must be invalidated twice for RX DMA buffers: once
before passing ownership to the DMA device (in case the cache happens
to contain dirty data that will be written back at an undefined future
point), and once after receiving ownership from the DMA device (in
case the CPU happens to have speculatively accessed data in the buffer
while it was owned by the hardware).

Only the used portion of the buffer needs to be invalidated after
completion, since we do not care about data within the unused portion.

Update the DMA API to include the used length as an additional
parameter to dma_unmap(), and add the necessary second cache
invalidation pass to the RISC-V DMA API implementation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 weeks ago[riscv] Add optimised TCP/IP checksumming
Michael Brown [Thu, 10 Jul 2025 11:50:00 +0000 (12:50 +0100)] 
[riscv] Add optimised TCP/IP checksumming

Add a RISC-V assembly language implementation of TCP/IP checksumming,
which is around 50x faster than the generic algorithm.  The main loop
checksums aligned xlen-bit words, using almost entirely compressible
instructions and accumulating carries in a separate register to allow
folding to be deferred until after all loops have completed.

Experimentation on a C910 CPU suggests that this achieves around four
bytes per clock cycle, which is comparable to the x86 implementation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Provide a DMA API implementation for RISC-V bare-metal systems
Michael Brown [Tue, 8 Jul 2025 13:56:47 +0000 (14:56 +0100)] 
[riscv] Provide a DMA API implementation for RISC-V bare-metal systems

Provide an implementation of dma_map() that performs cache clean or
invalidation as required, and an implementation of dma_alloc() that
returns virtual addresses within the coherent mapping of the 32-bit
physical address space.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[dma] Use virtual addresses for dma_map()
Michael Brown [Tue, 8 Jul 2025 11:38:05 +0000 (12:38 +0100)] 
[dma] Use virtual addresses for dma_map()

Cache management operations must generally be performed on virtual
addresses rather than physical addresses.

Change the address parameter in dma_map() to be a virtual address, and
make dma() the API-level primitive instead of dma_phys().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[build] Handle isohybrid with xorrisofs 522/head
Christian Hesse [Tue, 8 Jul 2025 10:49:16 +0000 (11:49 +0100)] 
[build] Handle isohybrid with xorrisofs

Generating an isohybrid image with `xorrisofs` is supposed to happen
with option `-isohybrid-gpt-basdat`, not command `isohybrid`.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Support explicit cache management operations on I/O buffers
Michael Brown [Mon, 7 Jul 2025 12:11:33 +0000 (13:11 +0100)] 
[riscv] Support explicit cache management operations on I/O buffers

On platforms where DMA devices are not in the same coherency domain as
the CPU cache, it is necessary to be able to explicitly clean the
cache (i.e. force data to be written back to main memory) and
invalidate the cache (i.e. discard any cached data and force a
subsequent read from main memory).

Add support for cache management via the standard Zicbom extension or
the T-Head cache management operations extension, with the supported
extension detected on first use.

Support cache management operations only on I/O buffers, since these
are guaranteed to not share cachelines with other data.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Add support for detecting T-Head vendor extensions
Michael Brown [Mon, 7 Jul 2025 12:03:07 +0000 (13:03 +0100)] 
[riscv] Add support for detecting T-Head vendor extensions

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[iobuf] Ensure I/O buffer data sits within unshared cachelines
Michael Brown [Mon, 7 Jul 2025 12:21:24 +0000 (13:21 +0100)] 
[iobuf] Ensure I/O buffer data sits within unshared cachelines

On platforms where DMA devices are not in the same coherency domain as
the CPU cache, we must ensure that DMA I/O buffers do not share
cachelines with other data.

Align the start and end of I/O buffers to IOB_ZLEN, which is larger
than any cacheline size we expect to encounter.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[uaccess] Allow for coherent DMA mapping of the 32-bit address space
Michael Brown [Fri, 4 Jul 2025 12:29:44 +0000 (13:29 +0100)] 
[uaccess] Allow for coherent DMA mapping of the 32-bit address space

On platforms where DMA devices are not in the same coherency domain as
the CPU cache, it is necessary to create page table entries where the
translations are marked as uncacheable.

We choose to place iPXE within the low 4GB of memory (since 32-bit DMA
devices are still reasonably common even on systems with 64-bit CPUs).
We therefore need to cover only the low 4GB of memory with these page
table entries.

Update virt_to_phys() to allow for the existence of such a mapping,
assuming that iPXE itself will always reside within the top 4GB of the
64-bit virtual address space (and therefore that the DMA mapping must
lie somewhere below this in the negative virtual address space).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Create coherent DMA mapping for low 4GB of address space
Michael Brown [Fri, 4 Jul 2025 13:23:37 +0000 (14:23 +0100)] 
[riscv] Create coherent DMA mapping for low 4GB of address space

Use PTEs 256-259 to create a mapping of the 32-bit physical address
space with attributes suitable for coherent DMA mappings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
3 weeks ago[riscv] Construct invariant portions of page table outside the loop
Michael Brown [Fri, 4 Jul 2025 13:37:31 +0000 (14:37 +0100)] 
[riscv] Construct invariant portions of page table outside the loop

The page table entries for the identity map vary according to the
paging level in use, and so must be constructed within the loop used
to detect the maximum supported paging level.  Other page table
entries are invariant between paging levels, and so may be constructed
just once before entering the loop.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
4 weeks ago[bnxt] Update supported devices array 1491/head
Joseph Wong [Wed, 2 Jul 2025 17:29:06 +0000 (10:29 -0700)] 
[bnxt] Update supported devices array

Add support for new device IDs. Remove device IDs which were never
in use.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
4 weeks ago[bnxt] Update device descriptions 1489/head
Joseph Wong [Tue, 1 Jul 2025 07:24:05 +0000 (00:24 -0700)] 
[bnxt] Update device descriptions

Use human readable strings for dev_description in PCI_ROM array.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
4 weeks ago[bnxt] Remove VLAN stripping logic 1484/head
Joseph Wong [Thu, 26 Jun 2025 22:37:05 +0000 (15:37 -0700)] 
[bnxt] Remove VLAN stripping logic

Remove logic that programs the hardware to strip out VLAN from RX
packets.  Do not drop packets due to VLAN mismatch and allow the upper
layer to decide whether to discard the packets.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
4 weeks ago[github] Add sponsorship link
Michael Brown [Thu, 26 Jun 2025 15:24:01 +0000 (16:24 +0100)] 
[github] Add sponsorship link

iPXE is released under the GNU GPL and is 100% open source software.
There are no "premium editions", no in-app advertisements, and no
hidden costs.  The fully public version published to GitHub is and
always will be the definitive and only version of iPXE.

Many large features in iPXE have been commercially funded within this
open source model, with features being published upstream as soon as
they are complete and made available for the whole world to use, not
restricted for use only by the customer funding that particular piece
of development work.

There has not to date been any funding model for smaller pieces of
work, such as occasional code review or guaranteed attention to bug
reports.  The overhead of establishing a commercial relationship is
usually too high to be worthwhile for very small units of work.

The GitHub sponsorship mechanism provides a framework for efficiently
handling small commercial requests (or individual tokens of thanks).
Add a FUNDING.yml file to provide a convenient way for anyone who
wants to support the ongoing open source development of iPXE to do so.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[bnxt] Increase Tx descriptors 1473/head
Joseph Wong [Wed, 25 Jun 2025 13:05:33 +0000 (14:05 +0100)] 
[bnxt] Increase Tx descriptors

Increase TX and CMP descriptor counts.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
5 weeks ago[build] Disable use of common symbols
Michael Brown [Tue, 24 Jun 2025 12:32:49 +0000 (13:32 +0100)] 
[build] Disable use of common symbols

We no longer have any requirement for common symbols.  Disable common
symbols via the -fno-common compiler option, and simplify the test for
support of -fdata-sections (which can return a false negative when
common symbols are enabled).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[build] Allow for the existence of small-data sections
Michael Brown [Tue, 24 Jun 2025 13:40:18 +0000 (14:40 +0100)] 
[build] Allow for the existence of small-data sections

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[legacy] Allocate legacy driver .bss-like segments at probe time
Michael Brown [Tue, 24 Jun 2025 12:17:19 +0000 (13:17 +0100)] 
[legacy] Allocate legacy driver .bss-like segments at probe time

Some legacy drivers use large static allocations for transmit and
receive buffers.  To avoid bloating the .bss segment, we currently
implement these as a single common symbol named "_shared_bss" (which
is permissible since only one legacy driver may be active at any one
time).

Switch to dynamic allocation of these .bss-like segments, to avoid the
requirement for using common symbols.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[legacy] Rename the global legacy NIC to "legacy_nic"
Michael Brown [Tue, 24 Jun 2025 12:10:53 +0000 (13:10 +0100)] 
[legacy] Rename the global legacy NIC to "legacy_nic"

We currently have contexts in which the local variable "nic" is a
pointer to the global variable also called "nic".  This complicates
the creation of macros.

Rename the global variable to "legacy_nic" to reduce pollution of the
global namespace and to allow for the creation of macros referring to
fields within this global variable.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[legacy] Allocate extra padding in receive buffers
Michael Brown [Tue, 24 Jun 2025 12:40:50 +0000 (13:40 +0100)] 
[legacy] Allocate extra padding in receive buffers

Allow for legacy drivers that include VLAN tags or CRCs within their
received packets.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[pxe] Use a weak symbol for isapnp_read_port
Michael Brown [Tue, 24 Jun 2025 12:26:57 +0000 (13:26 +0100)] 
[pxe] Use a weak symbol for isapnp_read_port

Use a weak symbol for isapnp_read_port used in pxe_preboot.c, rather
than relying on a common symbol.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[fdtcon] Add basic support for FDT-based system serial console
Michael Brown [Mon, 23 Jun 2025 15:25:19 +0000 (16:25 +0100)] 
[fdtcon] Add basic support for FDT-based system serial console

Add support for probing a device based on the path or alias found in
the "/chosen/stdout-path" node, and using a consequently instantiated
UART as the default serial console.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[dwuart] Read input clock frequency from the device tree
Michael Brown [Mon, 23 Jun 2025 21:40:04 +0000 (22:40 +0100)] 
[dwuart] Read input clock frequency from the device tree

The 16550 design includes a programmable 16-bit clock divider for an
arbitrary input clock, requiring knowledge of the input clock
frequency in order to calculate the divider value for a given baud
rate.  The 16550 UARTs in an x86 PC will always have a 1.8432 MHz
input clock.  Non-x86 systems may have other input clock frequencies.

Define the input clock frequency as a property of a 16550 UART, and
read the value from the device tree "clock-frequency" property.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[uart] Wait for 16550 UART to become idle before modifying LCR
Michael Brown [Mon, 23 Jun 2025 21:37:32 +0000 (22:37 +0100)] 
[uart] Wait for 16550 UART to become idle before modifying LCR

Some implementations of 16550-compatible UARTs (e.g. the DesignWare
UART) are known to ignore writes to the line control register while
the transmitter is active.

Wait for the transmitter to become empty before attempting to write to
the line control register.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[serial] Allow platform to specify mechanism for identifying console
Michael Brown [Mon, 23 Jun 2025 15:19:07 +0000 (16:19 +0100)] 
[serial] Allow platform to specify mechanism for identifying console

Allow the platform configuration to provide a mechanism for
identifying the serial console UART.  Provide two globally available
mechanisms: "null" (i.e. no serial console), and "fixed" (i.e. use
whatever is specified by COMCONSOLE in config/serial.h).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[dwuart] Add "ns16550a" compatible device ID
Michael Brown [Mon, 23 Jun 2025 14:10:27 +0000 (15:10 +0100)] 
[dwuart] Add "ns16550a" compatible device ID

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Inhibit SBI console when a serial console is active
Michael Brown [Mon, 23 Jun 2025 14:07:07 +0000 (15:07 +0100)] 
[riscv] Inhibit SBI console when a serial console is active

When a native serial driver is enabled for the system console device
specified via "/chosen/stdout-path", it is very likely that this will
correspond to the same physical serial port used for the SBI debug
console.

Inhibit input and output via the SBI console whenever a serial console
is active, to avoid duplicated output characters and unpredictable
input behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[riscv] Serialise MMIO accesses with respect to each other
Michael Brown [Sun, 22 Jun 2025 08:26:36 +0000 (09:26 +0100)] 
[riscv] Serialise MMIO accesses with respect to each other

iPXE drivers have been written with the implicit assumption that MMIO
writes are allowed to be posted but that an MMIO register read or
write after another MMIO register write will always observe the
effects of the first write.

For example: after having written a byte to the transmit holding
register (THR) of a 16550 UART, it is expected that any subsequent
read of the line status register (LSR) will observe a value consistent
with the occurrence of the write.

RISC-V does not seem to provide any ordering guarantees between
accesses to different registers within the same MMIO device.  Add
fences as part of the MMIO accessors to provide the assumed
guarantees.

Use "fence io, io" before each MMIO read or write to enforce full
serialisation of MMIO accesses with respect to each other.  This is
almost certainly more conservative than is strictly necessary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[dwuart] Add a basic driver for the Synopsys DesignWare UART
Michael Brown [Sat, 21 Jun 2025 22:13:58 +0000 (23:13 +0100)] 
[dwuart] Add a basic driver for the Synopsys DesignWare UART

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[uart] Allow for dynamically registered 16550 UARTs
Michael Brown [Sat, 21 Jun 2025 22:11:56 +0000 (23:11 +0100)] 
[uart] Allow for dynamically registered 16550 UARTs

Use the generic UART driver-private data pointer, rather than
embedding the generic UART within the 16550 UART structure.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[uart] Add support for MMIO-accessible 16550 UARTs
Michael Brown [Thu, 19 Jun 2025 11:57:28 +0000 (12:57 +0100)] 
[uart] Add support for MMIO-accessible 16550 UARTs

16550 UARTs exist on non-x86 platforms but will be accessible via MMIO
rather than port I/O.  It is possible to encounter MMIO-mapped 16550
UARTs on x86 platforms, but there is no real requirement to support
them in iPXE since the standard COM1, COM2, etc ports have been
present on every PC-compatible machine since 1981.

Assume for now that accessing 16550 UART registers requires
inb()/outb() on x86 and readb()/writeb() on other architectures.

Allow for the existence of a register shift on MMIO-mapped 16550
UARTs, since modern SoCs tend to treat register addresses as being
aligned to either 32-bit or 64-bit boundaries.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
5 weeks ago[uart] Allow for the existence of non-16550 UARTs
Michael Brown [Tue, 17 Jun 2025 13:28:18 +0000 (14:28 +0100)] 
[uart] Allow for the existence of non-16550 UARTs

Remove the assumption that all platforms use a fixed number of 16550
UARTs identifiable by a simple numeric index.  Create an abstraction
allowing for dynamic instantiation and registration of any number of
arbitrary UART models.

The common case of the serial console on x86 uses a single fixed UART
specified at compile time.  Avoid unnecessarily dragging in the
dynamic instantiation code in this use case by allowing COMCONSOLE to
refer to a single static UART object representing the relevant port.

When selecting a UART by command-line argument (as used in the
"gdbstub serial <port>" command), allow the UART to be specified as
either a numeric index (to retain backwards compatiblity) or a
case-insensitive port name such as "COM2".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[uart] Remove ability to use frame formats other than 8n1
Michael Brown [Tue, 17 Jun 2025 14:44:12 +0000 (15:44 +0100)] 
[uart] Remove ability to use frame formats other than 8n1

In the context of serial consoles, the use of any frame formats other
than the standard 8 data bits, no parity, and one stop bit is so rare
as to be nonexistent.

Remove the almost certainly unused support for custom frame formats.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Write SBI console output to early UART, if enabled
Michael Brown [Thu, 12 Jun 2025 11:57:26 +0000 (12:57 +0100)] 
[riscv] Write SBI console output to early UART, if enabled

The early UART is an optional feature used to obtain debug output from
the prefix before iPXE is able to parse the device tree.

Extend this feature to also cover any console output that iPXE
attempts to send to the SBI console, on the basis that the purpose of
the early UART is to provide an output-only device for situations in
which there is no functional SBI console.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
6 weeks ago[riscv] Maximise barrier effects of memory fences
Michael Brown [Thu, 12 Jun 2025 11:26:11 +0000 (12:26 +0100)] 
[riscv] Maximise barrier effects of memory fences

The RISC-V "fence" instruction encoding includes bits for predecessor
and successor input and output operations, separate from read and
write operations.  It is up to the CPU implementation to decide what
counts as I/O space rather than memory space for the purposes of this
instruction.

Since we do not expect fencing to be performance-critical, keep
everything as simple and reliable as possible by using the unadorned
"fence" instruction (equivalent to "fence iorw, iorw").

Add a memory clobber to ensure that the compiler does not reorder the
barrier.  (The volatile qualifier seems to already prevent reordering
in practice, but this is not guaranteed according to the compiler
documentation.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[fdt] Allow paths and aliases to be terminated with separator characters
Michael Brown [Wed, 11 Jun 2025 15:08:42 +0000 (16:08 +0100)] 
[fdt] Allow paths and aliases to be terminated with separator characters

Non-permitted name characters such as a colon are sometimes used to
separate alias names or paths from additional metadata, such as the
baud rate for a UART in the "/chosen/stdout-path" property.

Support the use of such alias names and paths by allowing any
character not permitted in a property name to terminate a property or
node name match.  (This is a very relaxed matching rule that will
produce false positive matches on invalid input, but this is unlikely
to cause problems in practice.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[bnxt] Remove TX padding
Joseph Wong [Wed, 11 Jun 2025 14:07:16 +0000 (15:07 +0100)] 
[bnxt] Remove TX padding

Remove unnecessary TX padding.

Signed-off-by: Joseph Wong <joseph.wong@broadcom.com>
7 weeks ago[fdtmem] Limit relocation to 32-bit address space
Michael Brown [Wed, 11 Jun 2025 12:48:12 +0000 (13:48 +0100)] 
[fdtmem] Limit relocation to 32-bit address space

Devices with only 32-bit DMA addressing are relatively common even on
systems with 64-bit CPUs.  Limit relocation of iPXE to 32-bit address
space so that I/O buffers and other DMA allocations will be accessible
by 32-bit devices.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[dt] Allow for creation of standalone devices
Michael Brown [Wed, 11 Jun 2025 11:51:56 +0000 (12:51 +0100)] 
[dt] Allow for creation of standalone devices

We will want to be able to create the console device as early as
possible.  Refactor devicetree probing to remove the assumption that a
devicetree device must have a devicetree parent, and expose functions
to allow a standalone device to be created given only the offset of a
node within the tree.

The full device path is no longer trivial to construct with this
assumption removed.  The full path is currently used only for debug
messages.  Remove the stored full path, use just the node name for
debug messages, and ensure that the topology information previously
visible in the full path is reconstructible from the combined debug
output if needed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[ipv4] Add support for classless static routes
Michael Brown [Tue, 10 Jun 2025 15:55:18 +0000 (16:55 +0100)] 
[ipv4] Add support for classless static routes

Add support for RFC 3442 classless static routes provided via DHCP
option 121.

Originally-implemented-by: Hazel Smith <hazel.smith@leicester.ac.uk>
Originally-implemented-by: Raphael Pour <raphael.pour@hetzner.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[ipv4] Extend routing mechanism to handle non-default routes
Michael Brown [Thu, 5 Jun 2025 15:49:42 +0000 (16:49 +0100)] 
[ipv4] Extend routing mechanism to handle non-default routes

Extend the definition of an IPv4 routing table entry to allow for the
expression of non-default gateways for specified off-link subnets, and
of on-link secondary subnets (where we can send directly to the
destination address even though our source address is not within the
subnet).

This more precise definition also allows us to correctly handle
routing in the (uncommon for iPXE) case when multiple network
interfaces are open concurrently and more than one interface has a
default gateway.

The common case of a single IPv4 address/netmask and a default gateway
now results in two routing table entries.  To retain backwards
compatibility with existing documentation (and to avoid on-screen
clutter), the "route" command prints default gateways on the same line
as the locally assigned address.  There is therefore no change in
output from the "route" command unless explicit additional (off-link
or on-link) routes are present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[ipv4] Add self-tests for IPv4 routing
Michael Brown [Tue, 10 Jun 2025 12:37:31 +0000 (13:37 +0100)] 
[ipv4] Add self-tests for IPv4 routing

Signed-off-by: Michael Brown <mcb30@ipxe.org>
7 weeks ago[test] Add infrastructure for test network devices
Michael Brown [Tue, 10 Jun 2025 12:32:10 +0000 (13:32 +0100)] 
[test] Add infrastructure for test network devices

Signed-off-by: Michael Brown <mcb30@ipxe.org>
8 weeks ago[riscv] Support T-Head CPUs using non-standard Memory Attribute Extension
Michael Brown [Mon, 2 Jun 2025 12:57:03 +0000 (13:57 +0100)] 
[riscv] Support T-Head CPUs using non-standard Memory Attribute Extension

Xuantie/T-Head processors such as the C910 (as used in the Sipeed
Lichee Pi 4A) use the high bits of the PTE in a very non-standard way
that is incompatible with the RISC-V specification.

As per the "Memory Attribute Extension (XTheadMae)", bits 62 and 61
represent cacheability and "bufferability" (write-back cacheability)
respectively.  If we do not enable these bits, then the processor gets
incredibly confused at the point that paging is enabled.  The symptom
is that cache lines will occasionally fail to fill, and so reads from
any address may return unrelated data from a previously read cache
line for a different address.

Work around these hardware flaws by detecting T-Head CPUs (via the
"get machine vendor ID" SBI call), then reading the vendor-specific
SXSTATUS register to determine whether or not the vendor-specific
Memory Attribute Extension has been enabled by the M-mode firmware.
If it has, then set bits 61 and 62 in each page table entry that is
used to access normal memory.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
8 weeks ago[riscv] Do not set executable bit in early UART page mapping
Michael Brown [Mon, 2 Jun 2025 07:59:54 +0000 (08:59 +0100)] 
[riscv] Do not set executable bit in early UART page mapping

Signed-off-by: Michael Brown <mcb30@ipxe.org>
8 weeks ago[riscv] Add fences around early UART writes
Michael Brown [Mon, 2 Jun 2025 07:36:22 +0000 (08:36 +0100)] 
[riscv] Add fences around early UART writes

Add a fence between the write to the UART transmit register and the
subsequent read from the transmit status register, to ensure that the
status correctly reflects the occurrence of the write.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
8 weeks ago[riscv] Zero SATP after any failed attempt to enable paging
Michael Brown [Mon, 2 Jun 2025 07:08:02 +0000 (08:08 +0100)] 
[riscv] Zero SATP after any failed attempt to enable paging

The RISC-V specification states that "if SATP is written with an
unsupported mode, the entire write has no effect; no fields in SATP
are modified".  We currently rely on this specified behaviour when
calculating the early UART base address: if SATP has a non-zero value
then we assume that paging must be enabled.

The XuanTie C910 CPU (as used in the Lichee Pi 4A) does not conform to
this specified behaviour.  Writing SATP with an unsupported mode will
leave SATP.MODE as zero (i.e. bare physical addressing) but the write
to SATP.PPN will still take effect, leaving SATP with an illegal
non-zero value.

Work around this misbehaviour by explicitly writing zero to SATP if we
detect that the mode change has not taken effect (e.g. because the CPU
does not support the requested paging mode).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[dt] Locate parent node at point of use in dt_ioremap()
Michael Brown [Fri, 30 May 2025 15:39:10 +0000 (16:39 +0100)] 
[dt] Locate parent node at point of use in dt_ioremap()

We currently rely on the recursive nature of devicetree bus probing to
obtain the region cell size specification from the parent device.
This blocks the possibility of creating a standalone console device
based on /chosen/stdout-path before probing the whole bus.

Fix by using fdt_parent() to locate the parent device at the point of
use within dt_ioremap().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[fdt] Provide ability to locate the parent device node
Michael Brown [Fri, 30 May 2025 15:37:28 +0000 (16:37 +0100)] 
[fdt] Provide ability to locate the parent device node

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[fdt] Add tests for device tree creation
Michael Brown [Fri, 30 May 2025 13:15:43 +0000 (14:15 +0100)] 
[fdt] Add tests for device tree creation

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Add support for a SiFive-compatible early UART
Michael Brown [Tue, 27 May 2025 16:21:01 +0000 (17:21 +0100)] 
[riscv] Add support for a SiFive-compatible early UART

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Support mapping early UARTs outside of the identity map
Michael Brown [Tue, 27 May 2025 15:18:17 +0000 (16:18 +0100)] 
[riscv] Support mapping early UARTs outside of the identity map

Some platforms (such as the Sipeed Lichee Pi 4A) choose to make early
debugging entertainingly cumbersome for the programmer.  These
platforms not only fail to provide a functional SBI debug console, but
also choose to place the UART at a physical address that cannot be
identity-mapped under the only paging model supported by the CPU.

Support such platforms by creating a virtual address mapping for the
early UART (in the 2MB megapage immediately below iPXE itself), and
using this as the UART base address whenever paging is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Add support for writing prefix debug messages direct to a UART
Michael Brown [Tue, 27 May 2025 13:49:06 +0000 (14:49 +0100)] 
[riscv] Add support for writing prefix debug messages direct to a UART

Some platforms (such as the Sipeed Lichee Pi 4A) do not provide a
functional SBI debug console.  We can obtain early debug messages on
these systems by writing directly to the UART used by the vendor
firmware.

There is no viable way to parse the UART address from the device tree,
since the prefix debug messages occur extremely early, before the C
runtime environment is available and therefore before any information
has been parsed from the device tree.  The early UART model and
register addresses must be configured by editing config/serial.h if
needed.  (This is an acceptable limitation, since prefix debugging is
an extremely specialised use case.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Create macros for writing characters to the debug console
Michael Brown [Mon, 26 May 2025 22:33:35 +0000 (23:33 +0100)] 
[riscv] Create macros for writing characters to the debug console

Abstract out the SBI debug console calls into macros that can be
shared between print_message and print_hex_value.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Ignore riscv,isa property in favour of direct CSR testing
Michael Brown [Mon, 26 May 2025 20:12:12 +0000 (21:12 +0100)] 
[riscv] Ignore riscv,isa property in favour of direct CSR testing

The riscv,isa devicetree property appears not to be fully populated on
some real-world systems.  For example, the Sipeed Lichee Pi 4A
(running the vendor U-Boot) reports itself as "rv64imafdcvsu", which
does not include the "zicntr" extension even though the time CSR is
present and functional.

Ignore the riscv,isa property and rely solely on CSR testing to
determine whether or not extensions are present.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[image] Use image name rather than pointer value in all debug messages
Michael Brown [Mon, 26 May 2025 17:22:07 +0000 (18:22 +0100)] 
[image] Use image name rather than pointer value in all debug messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Support mapping I/O devices outside of the identity map
Michael Brown [Mon, 26 May 2025 14:45:27 +0000 (15:45 +0100)] 
[riscv] Support mapping I/O devices outside of the identity map

With the 64-bit paging schemes (Sv39, Sv48, and Sv57), we identity-map
as much of the physical address space as is possible.  Experimentation
shows that this is not sufficient to provide access to all I/O
devices.  For example: the Sipeed Lichee Pi 4A includes a CPU that
supports only Sv39, but places I/O devices at the top of a 40-bit
address space.

Add support for creating I/O page table entries on demand to map I/O
devices, based on the existing design used for x86_64 BIOS.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[fdtmem] Ignore reservation regions with no fixed addresses
Michael Brown [Sun, 25 May 2025 23:22:52 +0000 (00:22 +0100)] 
[fdtmem] Ignore reservation regions with no fixed addresses

Do not print an error message for unused reservation regions that have
no fixed reserved address ranges.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Include carriage returns in libprefix.S debug messages
Michael Brown [Sun, 25 May 2025 23:07:09 +0000 (00:07 +0100)] 
[riscv] Include carriage returns in libprefix.S debug messages

Support debug consoles that do not automatically convert LF to CRLF by
including the CR character within the debug message strings.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[memmap] Allow explicit colour selection for memory map debug messages
Michael Brown [Sun, 25 May 2025 11:06:53 +0000 (12:06 +0100)] 
[memmap] Allow explicit colour selection for memory map debug messages

Provide DBGC_MEMMAP() as a replacement for memmap_dump(), allowing the
colour used to match other messages within the same message group.

Retain a dedicated colour for output from memmap_dump_all(), on the
basis that it is generally most useful to visually compare full memory
dumps against previous full memory dumps.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Support older SBI implementations
Michael Brown [Sun, 25 May 2025 08:28:11 +0000 (09:28 +0100)] 
[riscv] Support older SBI implementations

Fall back to attempting the legacy SBI console and shutdown calls if
the standard calls fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[memmap] Rename addr/last fields to min/max for clarity
Michael Brown [Fri, 23 May 2025 15:55:42 +0000 (16:55 +0100)] 
[memmap] Rename addr/last fields to min/max for clarity

Use the terminology "min" and "max" for addresses covered by a memory
region descriptor, since this is sufficiently intuitive to generally
not require further explanation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[lkrn] Support initrd construction for RISC-V bare-metal kernels
Michael Brown [Fri, 23 May 2025 15:14:45 +0000 (16:14 +0100)] 
[lkrn] Support initrd construction for RISC-V bare-metal kernels

Use the shared initrd reshuffling and CPIO header construction code
for RISC-V bare-metal kernels.  This allows for files to be injected
into the constructed ("magic") initrd image in exactly the same way as
is done for bzImage and UEFI kernels.

We append a dummy image encompassing the FDT to the end of the
reshuffle list, so that it ends up directly following the constructed
initrd in memory (but excluded from the initrd length, which was
recorded before constructing the FDT).

We also temporarily prepend the kernel binary itself to the reshuffle
list.  This is guaranteed to be safe (since reshuffling is designed to
be unable to fail), and avoids the requirement for the kernel segment
to be available before reshuffling.  This is useful since current
RISC-V bare-metal kernels tend to be distributed as EFI zboot images,
which require large temporary allocations from the external heap for
the intermediate images created during archive extraction.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[initrd] Squash and shuffle only initrds within the external heap
Michael Brown [Thu, 22 May 2025 13:57:22 +0000 (14:57 +0100)] 
[initrd] Squash and shuffle only initrds within the external heap

Any initrd images that are not within the external heap (e.g. embedded
images) do not need to be copied to the external heap for reshuffling,
and can just be left in their original locations.

Ignore any images that are not already within the external heap (or,
more precisely, that are wholly outside of the reshuffle region within
the external heap) when squashing and swapping images.

This reduces the maximum additional storage required by squashing and
swapping to zero, and so ensures that the reshuffling step is
guaranteed to succeed under all circumstances.  (This is unrelated to
the post-reshuffle load region check, which is still required.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[initrd] Split out initrd construction from bzimage.c
Michael Brown [Fri, 23 May 2025 11:13:02 +0000 (12:13 +0100)] 
[initrd] Split out initrd construction from bzimage.c

Provide a reusable function initrd_load_all() to load all initrds
(including any constructed CPIO headers) into a contiguous memory
region, and support functions to find the constructed total length and
permissible post-reshuffling load address range.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[initrd] Allow for images straddling the top of the reshuffle region
Michael Brown [Thu, 22 May 2025 13:12:12 +0000 (14:12 +0100)] 
[initrd] Allow for images straddling the top of the reshuffle region

It is hypothetically possible for external heap memory allocated
during driver startup to have been freed before an image was
downloaded, which could therefore leave an image straddling the
address recorded as the top of the reshuffle region.

Allow for this possibility by skipping squashing for any images
already straddling (or touching) the top of the reshuffle region.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[initrd] Rename bzimage_align() to initrd_align()
Michael Brown [Thu, 22 May 2025 12:41:21 +0000 (13:41 +0100)] 
[initrd] Rename bzimage_align() to initrd_align()

Alignment of initrd lengths is applicable to all Linux kernels, not
just those in the x86 bzImage format.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[initrd] Swap initrds entirely in-place via triple reversal
Michael Brown [Thu, 22 May 2025 12:27:03 +0000 (13:27 +0100)] 
[initrd] Swap initrds entirely in-place via triple reversal

Eliminate the requirement for free space when reshuffling initrds by
swapping adjacent initrds using an in-place triple reversal.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[uheap] Expose external heap region directly
Michael Brown [Thu, 22 May 2025 10:58:11 +0000 (11:58 +0100)] 
[uheap] Expose external heap region directly

We currently rely on implicit detection of the external heap region.
The INT 15 memory map mangler relies on examining the corresponding
in-use memory region, and the initrd reshuffler relies on performing a
separate detection of the largest free memory block after startup has
completed.

Replace these with explicit public symbols to describe the external
heap region.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[uheap] Prevent allocation of blocks with zero physical addresses
Michael Brown [Thu, 22 May 2025 15:05:37 +0000 (16:05 +0100)] 
[uheap] Prevent allocation of blocks with zero physical addresses

If the external heap ends up at the top of the system memory map then
leave a gap after the heap to ensure that no block ends up being
allocated with either a start or end address of zero, since this is
frequently confusing to both code and humans.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[fdtmem] Allow iPXE to be relocated to the top of the address space
Michael Brown [Thu, 22 May 2025 15:13:36 +0000 (16:13 +0100)] 
[fdtmem] Allow iPXE to be relocated to the top of the address space

Allow for relocation to a region at the very end of the physical
address space (where the next address wraps to zero).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[riscv] Speed up memmove() when copying in forwards direction
Michael Brown [Wed, 21 May 2025 15:12:56 +0000 (16:12 +0100)] 
[riscv] Speed up memmove() when copying in forwards direction

Use the word-at-a-time variable-length memcpy() implementation when
performing an overlapping copy in the forwards direction, since this
is guaranteed to be safe and likely to be substantially faster than
the existing bytewise copy.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[lkrn] Shut down devices before jumping to kernel entry point
Michael Brown [Wed, 21 May 2025 13:22:36 +0000 (14:22 +0100)] 
[lkrn] Shut down devices before jumping to kernel entry point

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[lkrn] Allow a single initrd to be passed to the booted kernel
Michael Brown [Wed, 21 May 2025 13:28:29 +0000 (14:28 +0100)] 
[lkrn] Allow a single initrd to be passed to the booted kernel

Allow a single initrd image to be passed verbatim to the booted RISC-V
kernel, as a proof of concept.

We do not yet support reshuffling to make optimal use of available
memory, or dynamic construction of CPIO headers, but this is
sufficient to allow iPXE to start up the Fedora 42 kernel with its
matching initrd image.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[fdt] Allow an initrd to be specified when creating a device tree
Michael Brown [Wed, 21 May 2025 13:26:56 +0000 (14:26 +0100)] 
[fdt] Allow an initrd to be specified when creating a device tree

Allow an initrd location to be specified in our constructed device
tree via the "linux,initrd-start" and "linux,initrd-end" properties.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2 months ago[initrd] Move initrd reshuffling to be architecture-independent code
Michael Brown [Wed, 21 May 2025 11:07:24 +0000 (12:07 +0100)] 
[initrd] Move initrd reshuffling to be architecture-independent code

There is nothing x86-specific in initrd.c, and a variant of the
reshuffling logic will be required for executing bare-metal kernels on
RISC-V and AArch64.

Signed-off-by: Michael Brown <mcb30@ipxe.org>