diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-05-03 01:47:15 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-05-03 01:47:15 +0800 |
| commit | 2b237b24c4db5513f8046e15d24501257e7feeaa (patch) | |
| tree | 7b5fcbe3e00d30056064801594b899eb3db5c88b /na/fdt/fdt.cc | |
| parent | 4b1b9912caf41fa52818e5d84130016ce00888cc (diff) | |
| download | lume-2b237b24c4db5513f8046e15d24501257e7feeaa.tar.gz lume-2b237b24c4db5513f8046e15d24501257e7feeaa.tar.xz | |
feat: implement KASLR support and runtime address mapping for RISC-V architecture
Co-authored-by: Copilot <copilot@github.com>
Diffstat (limited to 'na/fdt/fdt.cc')
| -rw-r--r-- | na/fdt/fdt.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/na/fdt/fdt.cc b/na/fdt/fdt.cc index ef614e4..fbec245 100644 --- a/na/fdt/fdt.cc +++ b/na/fdt/fdt.cc @@ -126,7 +126,7 @@ static inline uint64 read_cells(const uint8 *data, uint32 cells) { /* ------------------------------------------------------------------ */ FdtManager::FdtManager(uint64 fdt_paddr) - : fdt_paddr_(pa_to_va(phys_addr(fdt_paddr)).raw) {} + : fdt_paddr_(fdt_paddr) {} /* ------------------------------------------------------------------ */ /* Phase 1: Early scan — memory layout */ @@ -352,14 +352,15 @@ void FdtManager::early_scan_uart(uint64 fdt_paddr, uint64 *uart_addr, /* ------------------------------------------------------------------ */ void FdtManager::unflatten() { - const fdt_header *hdr = reinterpret_cast<const fdt_header *>(fdt_paddr_); + const uint64 fdt_va = pa_to_va(phys_addr(fdt_paddr_)).raw; + const fdt_header *hdr = reinterpret_cast<const fdt_header *>(fdt_va); if (bswap32(hdr->magic) != FDT_MAGIC) kernel_panic("fdt unflatten: invalid magic", nullptr); const uint8 *dt_struct = - reinterpret_cast<const uint8 *>(fdt_paddr_) + bswap32(hdr->off_dt_struct); + reinterpret_cast<const uint8 *>(fdt_va) + bswap32(hdr->off_dt_struct); const char *dt_strings = - reinterpret_cast<const char *>(fdt_paddr_) + bswap32(hdr->off_dt_strings); + reinterpret_cast<const char *>(fdt_va) + bswap32(hdr->off_dt_strings); uint32 offset = 0; |
