]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[fdtmem] Record size of accessible physical address space
authorMichael Brown <mcb30@ipxe.org>
Wed, 14 May 2025 21:09:51 +0000 (22:09 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 14 May 2025 21:09:51 +0000 (22:09 +0100)
The size of accessible physical address space will be required for the
runtime memory map, not just at relocation time.  Make this size an
additional parameter to fdt_register() (matching the prototype for
fdt_relocate()), and record the value for future reference.

Note that we cannot simply store the limit in fdt_relocate() since it
is called before .data is writable and before .bss is zeroed.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/riscv/prefix/libprefix.S
src/core/fdtmem.c
src/include/ipxe/fdtmem.h

index b011616da7662be8b7cc3daf5f0835423486b83c..834a48655853edd670086e54ca87ef473f9062eb 100644 (file)
@@ -1088,6 +1088,7 @@ install:
 
        /* Copy and register system device tree */
        phys_to_virt a0, s1
+       mv      a1, s4
        call    fdtmem_register
 
        /* Return to a virtual address in the relocated copy */
index 9e8ab2406fe6b952fe7de1cecc7d200e5d7b3c20..18ae5ce96aa13941e9352aaf34672afbc3828881 100644 (file)
@@ -66,6 +66,9 @@ struct fdtmem_region {
 /** Region is usable as RAM */
 #define FDTMEM_RAM 0x0001
 
+/** Size of accessible physical address space (or zero for no limit) */
+static size_t fdtmem_limit;
+
 /**
  * Update memory region descriptor
  *
@@ -360,13 +363,17 @@ physaddr_t fdtmem_relocate ( struct fdt_header *hdr, size_t limit ) {
  * Copy and register system device tree
  *
  * @v hdr              FDT header
+ * @v limit            Size of accessible physical address space (or zero)
  * @ret rc             Return status code
  */
-int fdtmem_register ( struct fdt_header *hdr ) {
+int fdtmem_register ( struct fdt_header *hdr, size_t limit ) {
        struct fdt_header *copy;
        struct fdt fdt;
        int rc;
 
+       /* Record size of accessible physical address space */
+       fdtmem_limit = limit;
+
        /* Parse FDT to obtain length */
        if ( ( rc = fdt_parse ( &fdt, hdr, -1UL ) ) != 0 ) {
                DBGC ( colour, "FDTMEM could not parse FDT: %s\n",
index a5777f6a21a194f6838c3fdef0dcdee2ba954b8a..1bf0015b48d772858e38e9df0306ed8e6d2cf7ec 100644 (file)
@@ -13,6 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/fdt.h>
 
 extern physaddr_t fdtmem_relocate ( struct fdt_header *hdr, size_t limit );
-extern int fdtmem_register ( struct fdt_header *hdr );
+extern int fdtmem_register ( struct fdt_header *hdr, size_t limit );
 
 #endif /* _IPXE_FDTMEM_H */