summaryrefslogtreecommitdiffstats
path: root/src/core/fdt.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] Mark known reviewed files as permitted for UEFI Secure BootMichael Brown2026-01-141-0/+1
| | | | | | | | | Some past security reviews carried out for UEFI Secure Boot signing submissions have covered specific drivers or functional areas of iPXE. Mark all of the files comprising these areas as permitted for UEFI Secure Boot. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Provide fdt_reg() for unsized single-entry regionsMichael Brown2025-08-071-0/+49
| | | | | | | | Many region types (e.g. I2C bus addresses) can only ever contain a single region with no size cells specified. Provide fdt_reg() to reduce boilerplate in this common use case. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Use phandle as device locationMichael Brown2025-08-041-51/+22Star
| | | | | | | | | | | | | Consumption of phandles will be in the form of locating a functional device (e.g. a GPIO device, or an I2C device, or a reset controller) by phandle, rather than locating the device tree node to which the phandle refers. Repurpose fdt_phandle() to obtain the phandle value (instead of searching by phandle), and record this value as the bus location within the generic device structure. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Add ability to locate node by phandleMichael Brown2025-07-221-0/+51
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Allow paths and aliases to be terminated with separator charactersMichael Brown2025-06-111-9/+30
| | | | | | | | | | | | | | 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>
* [fdt] Provide ability to locate the parent device nodeMichael Brown2025-05-301-1/+95
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Allow an initrd to be specified when creating a device treeMichael Brown2025-05-211-15/+37
| | | | | | | 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>
* [riscv] Hold virtual address offset in the thread pointer registerMichael Brown2025-05-111-2/+4
| | | | | | | | | | | | iPXE does not make use of any thread-local storage. Use the otherwise unused thread pointer register ("tp") to hold the current value of the virtual address offset, rather than using a global variable. This ensures that virt_offset can be made valid even during very early initialisation (when iPXE may be executing directly from read-only memory and so cannot update a global variable). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Generalise access to "reg" propertyMichael Brown2025-05-091-0/+105
| | | | | | | | | | The "reg" property is also used by non-device nodes, such as the nodes describing the system memory map. Provide generalised functionality for parsing the "#address-cells", "#size-cells", and "reg" properties. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [image] Make image data read-only to most consumersMichael Brown2025-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | Almost all image consumers do not need to modify the content of the image. Now that the image data is a pointer type (rather than the opaque userptr_t type), we can rely on the compiler to enforce this at build time. Change the .data field to be a const pointer, so that the compiler can verify that image consumers do not modify the image content. Provide a transparent .rwdata field for consumers who have a legitimate (and now explicit) reason to modify the image content. We do not attempt to impose any runtime restriction on checking whether or not an image is writable. The only existing instances of genuinely read-only images are the various unit test images, and it is acceptable for defective test cases to result in a segfault rather than a runtime error. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uaccess] Remove trivial uses of userptr_tMichael Brown2025-04-241-3/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uaccess] Remove redundant user_to_virt()Michael Brown2025-04-211-4/+3Star
| | | | | | | | | The user_to_virt() function is now a straightforward wrapper around addition, with the addend almost invariably being zero. Remove this redundant wrapper. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Add fdt_cells() to read cell-based properties such as "reg"Michael Brown2025-04-151-14/+70
| | | | | | | | Add fdt_cells() to read scalar values encoded within a cell array, reimplement fdt_u64() as a wrapper around this, and add fdt_u32() for completeness. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Remove concept of a device tree cursorMichael Brown2025-04-141-124/+133
| | | | | | | | Refactor device tree traversal to operate on the basis of describing the token at a given offset, with no separate notion of a device tree cursor. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Avoid temporarily modifying path during path lookupMichael Brown2025-04-141-18/+15Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Provide fdt_strings() to read string list propertiesMichael Brown2025-04-141-5/+34
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Allow for trailing slashes in path lookupsMichael Brown2025-04-141-4/+11
| | | | | | | | | | | Using fdt_path() to find the root node "/" currently fails, since it will attempt to find a child node with the empty name "" within the root node. Fix by changing fdt_path() to ignore any trailing slashes in a device tree path. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Populate boot arguments in constructed device treeMichael Brown2025-04-011-8/+415
| | | | | | | | When creating a device tree to pass to a booted operating system, ensure that the "chosen" node exists, and populate the "bootargs" property with the image command line. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Identify free space (if any) at end of parsed treeMichael Brown2025-04-011-4/+27
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Provide the ability to create a device tree for a booted OSMichael Brown2025-03-281-0/+79
| | | | | | | | Provide fdt_create() to create a device tree to be passed to a booted operating system. The device tree will be created from the FDT image (if present), falling back to the system device tree (if present). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [efi] Create a copy of the system flattened device tree, if presentMichael Brown2025-03-281-2/+1Star
| | | | | | | | | EFI configuration tables may be freed at any time, and there is no way to be notified when the table becomes invalidated. Create a copy of the system flattened device tree (if present), so that we do not risk being left with an invalid pointer. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Allow for parsing device trees where the length is known in advanceMichael Brown2025-03-281-2/+16
| | | | | | | | Allow for parsing device trees where an external factor (such as a downloaded image length) determines the maximum length, which must be validated against the length within the device tree header. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Allow for the existence of multiple device treesMichael Brown2025-03-281-91/+95
| | | | | | | | | | | | | When running on a platform that uses FDT as its hardware description mechanism, we are likely to have multiple device tree structures. At a minimum, there will be the device tree passed to us from the previous boot stage (e.g. OpenSBI), and the device tree that we construct to be passed to the booted operating system. Update the internal FDT API to include an FDT pointer in all function parameter lists. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Add the concept of an FDT imageMichael Brown2025-03-271-0/+6
| | | | | | | | | | | | Define the concept of an "FDT" image, representing a Flattened Device Tree blob that has been downloaded in order to be provided to a kernel or other executable image. FDT images are represented using an image tag (as with other special-purpose images such as the UEFI shim), and are similarly marked as hidden so that they will not be included in a generated magic initrd or show up in a virtual filesystem directory listing. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Add ability to parse unsigned integer propertiesMichael Brown2024-10-281-0/+38
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdt] Add ability to parse a MAC address from a flattened device treeMichael Brown2019-07-191-0/+486
The Raspberry Pi NIC has no EEPROM to hold the MAC address. The platform firmware (e.g. UEFI or U-Boot) will typically obtain the MAC address from the VideoCore firmware and add it to the device tree, which is then made available to subsequent programs such as iPXE or the Linux kernel. Add the ability to parse a flattened device tree and to extract the MAC address. Signed-off-by: Michael Brown <mcb30@ipxe.org>