summaryrefslogtreecommitdiffstats
path: root/src/arch/riscv/scripts
Commit message (Collapse)AuthorAgeFilesLines
* [build] Allow for the existence of small-data sectionsMichael Brown2025-06-241-0/+6
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [riscv] Relocate to a safe physical address on startupMichael Brown2025-05-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On startup, we may be running from read-only memory. We need to parse the devicetree to obtain the system memory map, and identify a safe location to which we can copy our own binary image along with a stashed copy of the devicetree, and then transfer execution to this new location. Parsing the system memory map realistically requires running C code. This in turn requires a small temporary stack, and some way to ensure that symbol references are valid. We first attempt to enable paging, to make the runtime virtual addresses equal to the link-time virtual addresses. If this fails, then we attempt to apply the compressed relocation records. Assuming that one of these has worked (i.e. that either the CPU supports paging or that our image started execution in writable memory), then we call fdtmem_relocate() to parse the system memory map to find a suitable relocation target address. After the copy we disable paging, jump to the relocated copy, re-enable paging, and reapply relocation records (if needed). At this point, we have a full runtime environment, and can transfer control to normal C code. Provide this functionality as part of libprefix.S, since it is likely to be shared by multiple prefixes. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [fdtmem] Add ability to parse FDT memory map for a relocation addressMichael Brown2025-05-111-0/+6
| | | | | | | | | | | | | | | | | | 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>
* [riscv] Use compressed relocation recordsMichael Brown2025-05-061-17/+6Star
| | | | | | | | Use compressed relocation records instead of raw Elf_Rela records. This saves around 15% of the total binary size for the all-drivers image bin-riscv64/ipxe.sbi. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [riscv] Place .got and .got.plt in .dataMichael Brown2025-05-061-0/+2
| | | | | | | | | | Even though we build with -mno-plt, redundant .got and .got.plt sections are still generated. Include these redundant sections within .data (which has identical section attributes) to simplify the section list. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [riscv] Discard ELF hash tablesMichael Brown2025-05-061-0/+2
| | | | | | | | | | The ELF hash table is generated when building a position-independent executable even though it is not required (since we have no dynamic linker). Explicitly discard these unneeded sections. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [riscv] Allow for a non-zero link-time addressMichael Brown2025-05-011-4/+3Star
| | | | | | | | | | | | | | | | Using paging (rather than relocation records) will be easier on 64-bit RISC-V if we place iPXE within the negative (kernel) virtual address space. Allow the link-time address to be non-zero and to vary between 32-bit and 64-bit builds. Choose addresses that are expected to be amenable to the use of paging. There is no particular need to use a non-zero address in the 32-bit builds, but doing so allows us to validate that the relocation code is handling this case correctly. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [riscv] Split out runtime relocator to libprefix.SMichael Brown2025-05-011-0/+8
| | | | | | | | | | | | Split out the runtime relocation logic from sbiprefix.S to a new library libprefix.S. Since this logically decouples the process of runtime relocation from the _sbi_start symbol (currently used to determine the base address for applying relocations), provide an alternative mechanism for the relocator to determine the base address. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [sbi] Add support for running as a RISC-V SBI payloadMichael Brown2024-10-281-0/+119
Add basic support for running directly on top of SBI, with no UEFI firmware present. Build as e.g.: make CROSS=riscv64-linux-gnu- bin-riscv64/ipxe.sbi The resulting binary can be tested in QEMU using e.g.: qemu-system-riscv64 -M virt -cpu max -serial stdio \ -kernel bin-riscv64/ipxe.sbi No drivers or executable binary formats are supported yet, but the unit test suite may be run successfully. Signed-off-by: Michael Brown <mcb30@ipxe.org>