summaryrefslogtreecommitdiff
path: root/na/include
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-05-02 23:35:19 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-05-02 23:35:19 +0800
commit70b0c0f6032abfd820ccee22c23bc66d171bee34 (patch)
tree1ca89104a6f484f7edf8b19523acb1dedb3133a2 /na/include
parentb1b0b1aad65b57900e18539d6f25b38e51801822 (diff)
downloadlume-70b0c0f6032abfd820ccee22c23bc66d171bee34.tar.gz
lume-70b0c0f6032abfd820ccee22c23bc66d171bee34.tar.xz
feat: reorganize includes and improve FdtManager documentation
Co-authored-by: Copilot <copilot@github.com>
Diffstat (limited to 'na/include')
-rw-r--r--na/include/lume/fdt.h55
1 files changed, 29 insertions, 26 deletions
diff --git a/na/include/lume/fdt.h b/na/include/lume/fdt.h
index 783b030..63d185b 100644
--- a/na/include/lume/fdt.h
+++ b/na/include/lume/fdt.h
@@ -18,47 +18,50 @@
* Reference: docs/specs/fdt.md
*/
-#include <lume/types.h>
#include <lume/device_node.h>
+#include <lume/types.h>
class FdtManager {
public:
- // Construct with the physical address of the FDT blob.
- // Called via Placement New in fdt_init().
- FdtManager(uint64 fdt_paddr);
+ // Construct with the physical address of the FDT blob.
+ // Called via Placement New in fdt_init().
+ FdtManager(uint64 fdt_paddr);
+
+ // --- Phase 1: Early scan (static, allocation-free) ---
- // --- Phase 1: Early scan (static, allocation-free) ---
+ // Extract physical memory base and size from the /memory node.
+ // Panics if the FDT is invalid or /memory is missing.
+ static void early_scan_mem(uint64 fdt_paddr, uint64 *base, uint64 *size);
- // Extract physical memory base and size from the /memory node.
- // Panics if the FDT is invalid or /memory is missing.
- static void early_scan_mem(uint64 fdt_paddr, uint64 *base, uint64 *size);
+ // Extract the UART base address and size by matching compatible = "ns16550a".
+ // Falls back to platform default on failure.
+ static void early_scan_uart(uint64 fdt_paddr, uint64 *uart_addr,
+ uint64 *uart_size);
- // Extract the UART base address and size by matching compatible = "ns16550a".
- // Falls back to platform default on failure.
- static void early_scan_uart(uint64 fdt_paddr, uint64 *uart_addr, uint64 *uart_size);
+ static void early_scan_kaslr(uint64 fdt_paddr, uint64 *seed);
- // --- Phase 2: Object tree construction (requires Slab) ---
+ // --- Phase 2: Object tree construction (requires Slab) ---
- // Walk the FDT blob and build the DeviceNode tree.
- void unflatten();
+ // Walk the FDT blob and build the DeviceNode tree.
+ void unflatten();
- // --- Query interface (read-only after unflatten) ---
+ // --- Query interface (read-only after unflatten) ---
- // Find the first node whose "compatible" property contains the string.
- // Returns nullptr if no match.
- DeviceNode *find_compatible(const char *compat_string);
+ // Find the first node whose "compatible" property contains the string.
+ // Returns nullptr if no match.
+ DeviceNode *find_compatible(const char *compat_string);
- // Look up a node by its full path (e.g. "/soc/uart@10000000").
- // Returns nullptr if not found.
- DeviceNode *get_node_by_path(const char *path);
+ // Look up a node by its full path (e.g. "/soc/uart@10000000").
+ // Returns nullptr if not found.
+ DeviceNode *get_node_by_path(const char *path);
- // Return the stored FDT physical address.
- uint64 get_paddr() const { return fdt_paddr_; }
+ // Return the stored FDT physical address.
+ uint64 get_paddr() const { return fdt_paddr_; }
private:
- uint64 fdt_paddr_; // Physical address of the FDT blob
- bool is_unflattened_ = false; // True after unflatten() completes
- DeviceNode *root_ = nullptr; // Root of the unflattened tree
+ uint64 fdt_paddr_; // Physical address of the FDT blob
+ bool is_unflattened_ = false; // True after unflatten() completes
+ DeviceNode *root_ = nullptr; // Root of the unflattened tree
};
/* Global FDT manager singleton (Placement New, see global_init.md ยง3.1) */