diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-04-14 22:47:15 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-04-14 22:47:15 +0800 |
| commit | ac9741e12222e72bad3414bc6f588e70a3d130cc (patch) | |
| tree | 6aace9f63a2ea54c7c3fd1e49e98ff81b638296f /include/kernel/fdt.h | |
| parent | 1e862099a13266da57ff7c6de11c1a11c42a8112 (diff) | |
| download | lume-ac9741e12222e72bad3414bc6f588e70a3d130cc.tar.gz lume-ac9741e12222e72bad3414bc6f588e70a3d130cc.tar.xz | |
feat: implement FDT-based memory discovery and add comprehensive debug logging to exec syscalls
Diffstat (limited to 'include/kernel/fdt.h')
| -rw-r--r-- | include/kernel/fdt.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/kernel/fdt.h b/include/kernel/fdt.h new file mode 100644 index 0000000..89cbae6 --- /dev/null +++ b/include/kernel/fdt.h @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2026 Richard Qin + * LumeOS - FDT Device Discovery + */ + +#pragma once +#include "common/types.h" + +// Single device descriptor (populated from FDT) +struct FdtDevice { + uint64 base_addr; // MMIO base address + uint64 size; // MMIO region size + uint32 irq; // Interrupt number (0 = none) +}; + +// Device registry — populated by fdt_parse(), consumed by drivers +struct DeviceRegistry { + // Memory + uint64 mem_base; + uint64 mem_size; + + // Core platform devices + FdtDevice uart; + FdtDevice plic; + FdtDevice clint; + + // VirtIO devices (multiple possible) + static constexpr int MAX_VIRTIO = 8; + FdtDevice virtio[MAX_VIRTIO]; + int virtio_count; + + // MMIO ranges for kvminit() to map + static constexpr int MAX_MMIO = 16; + struct MmioRegion { + uint64 base; + uint64 size; + } mmio_regions[MAX_MMIO]; + int mmio_count; +}; + +extern DeviceRegistry g_devices; + +// Parse FDT and populate g_devices +void fdt_parse(uint64 dtb); |
