summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown2025-05-11 18:35:47 +0200
committerMichael Brown2025-05-11 19:23:08 +0200
commit6fe9ce66ae14537290ac9a2eb081a9fed3a16d1f (patch)
tree3ca5b2a0f517262b50a02a9d2ddcaab060776088 /src/include/ipxe
parent[riscv] Ensure that prefix_virt is aligned on an xlen boundary (diff)
downloadipxe-6fe9ce66ae14537290ac9a2eb081a9fed3a16d1f.tar.gz
ipxe-6fe9ce66ae14537290ac9a2eb081a9fed3a16d1f.tar.xz
ipxe-6fe9ce66ae14537290ac9a2eb081a9fed3a16d1f.zip
[fdtmem] Add ability to parse FDT memory map for a relocation address
Add code to parse the devicetree memory nodes, memory reservations block, and reserved memory nodes to construct an ordered and non-overlapping description of the system memory map, and use this to identify a suitable address to which iPXE may be relocated at runtime. We choose to place iPXE on a superpage boundary (as required by the paging code), and to use the highest available address within accessible memory. This mirrors the approach taken for x86 BIOS builds, where we have long assumed that any image format that we might need to support may require specific fixed addresses towards the bottom of the memory map, but is very unlikely to require specific fixed addresses towards the top of the memory map (since those addresses may not exist, depending on the amount of installed RAM). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/fdt.h25
-rw-r--r--src/include/ipxe/fdtmem.h17
2 files changed, 42 insertions, 0 deletions
diff --git a/src/include/ipxe/fdt.h b/src/include/ipxe/fdt.h
index 6c58f5687..45ae0f92b 100644
--- a/src/include/ipxe/fdt.h
+++ b/src/include/ipxe/fdt.h
@@ -76,6 +76,14 @@ struct fdt_prop {
/** Maximum alignment of any block */
#define FDT_MAX_ALIGN 8
+/** A memory reservation */
+struct fdt_reservation {
+ /** Starting address */
+ uint64_t start;
+ /** Length of reservation */
+ uint64_t size;
+} __attribute__ (( packed ));
+
/** A device tree */
struct fdt {
/** Tree data */
@@ -143,6 +151,23 @@ struct fdt_reg_cells {
extern struct image_tag fdt_image __image_tag;
extern struct fdt sysfdt;
+/**
+ * Get memory reservations
+ *
+ * @v fdt Device tree
+ * @ret rsv Memory reservations
+ */
+static inline const struct fdt_reservation *
+fdt_reservations ( struct fdt *fdt ) {
+
+ return ( fdt->raw + fdt->reservations );
+}
+
+/** Iterate over memory reservations */
+#define for_each_fdt_reservation( rsv, fdt ) \
+ for ( rsv = fdt_reservations ( (fdt) ) ; \
+ ( (rsv)->start || (rsv)->size ) ; rsv++ )
+
extern int fdt_describe ( struct fdt *fdt, unsigned int offset,
struct fdt_descriptor *desc );
extern int fdt_path ( struct fdt *fdt, const char *path,
diff --git a/src/include/ipxe/fdtmem.h b/src/include/ipxe/fdtmem.h
new file mode 100644
index 000000000..98395b8e9
--- /dev/null
+++ b/src/include/ipxe/fdtmem.h
@@ -0,0 +1,17 @@
+#ifndef _IPXE_FDTMEM_H
+#define _IPXE_FDTMEM_H
+
+/** @file
+ *
+ * Flattened Device Tree memory map
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <stdint.h>
+#include <ipxe/fdt.h>
+
+extern physaddr_t fdtmem_relocate ( struct fdt_header *hdr, size_t limit );
+
+#endif /* _IPXE_FDTMEM_H */