|
SimpleKernel 1.17.0
|
FDT(Flattened Device Tree)解析器 More...
#include <kernel_fdt.hpp>

Public Member Functions | |
| auto | GetCoreCount () const -> Expected< size_t > |
| 获取 CPU 核心数量 | |
| auto | CheckPSCI () const -> Expected< void > |
| 判断 PSCI 信息 | |
| auto | GetMemory () const -> Expected< std::pair< uint64_t, size_t > > |
| 获取内存信息 | |
| auto | GetSerial () const -> Expected< std::tuple< uint64_t, size_t, uint32_t > > |
| 获取串口信息 | |
| auto | GetTimebaseFrequency () const -> Expected< uint32_t > |
| 获取 CPU 时钟频率 | |
| auto | GetGIC () const -> Expected< std::tuple< uint64_t, size_t, uint64_t, size_t > > |
| 获取 GIC 信息 | |
| auto | GetGicDist () const -> Expected< std::pair< uint64_t, size_t > > |
| 获取 GIC Distributor 信息 | |
| auto | GetGicCpu () const -> Expected< std::pair< uint64_t, size_t > > |
| 获取 GIC CPU Interface (Redistributor) 信息 | |
| auto | GetAarch64Intid (const char *compatible) const -> Expected< uint64_t > |
| 获取 aarch64 中断号 | |
| auto | GetPlic () const -> Expected< std::tuple< uint64_t, uint64_t, uint32_t, uint32_t > > |
| 获取 PLIC 信息 | |
| template<typename Callback > | |
| auto | ForEachNode (Callback &&callback) const -> Expected< void > |
| 遍历 FDT 中所有设备节点 | |
| template<typename Callback > | |
| auto | ForEachCompatibleNode (const char *compatible, Callback &&callback) const -> Expected< void > |
| 遍历所有匹配指定 compatible 的 FDT 节点 | |
| template<typename Callback > | |
| auto | ForEachDeviceNode (Callback &&callback) const -> Expected< void > |
| 遍历 FDT 中所有"叶设备"节点,自动跳过基础设施节点。 | |
构造/析构函数 | |
| KernelFdt (uint64_t header) | |
| 构造函数 | |
| KernelFdt ()=default | |
| KernelFdt (const KernelFdt &)=default | |
| KernelFdt (KernelFdt &&)=default | |
| auto | operator= (const KernelFdt &) -> KernelFdt &=default |
| auto | operator= (KernelFdt &&) -> KernelFdt &=default |
| ~KernelFdt ()=default | |
Private Member Functions | |
| auto | ValidateFdtHeader () const -> Expected< void > |
| 验证 FDT header | |
| auto | FindNode (const char *path) const -> Expected< int > |
| 按路径查找节点 | |
| auto | FindCompatibleNode (const char *compatible) const -> Expected< int > |
| 按 compatible 查找第一个匹配的节点 | |
| auto | FindEnabledCompatibleNode (const char *compatible) const -> Expected< int > |
| 根据 compatible 查找已启用的节点(跳过 status="disabled") | |
| auto | GetRegProperty (int offset) const -> Expected< std::pair< uint64_t, size_t > > |
| 获取 reg 属性(返回第一个 reg 条目) | |
| auto | CountNodesByDeviceType (const char *device_type) const -> Expected< size_t > |
| 按 device_type 统计节点数量 | |
| auto | GetPsciMethod (int offset) const -> Expected< const char * > |
| 获取 PSCI method 属性 | |
| auto | ValidatePsciFunctionIds (int offset) const -> Expected< void > |
| 验证 PSCI 函数 ID | |
Private Attributes | |
| fdt_header * | fdt_header_ {nullptr} |
| FDT header 指针 | |
Static Private Attributes | |
| static constexpr uint64_t | kPsciCpuOnFuncId = 0xC4000003 |
| static constexpr uint64_t | kPsciCpuOffFuncId = 0x84000002 |
| static constexpr uint64_t | kPsciCpuSuspendFuncId = 0xC4000001 |
FDT(Flattened Device Tree)解析器
提供对 FDT 的解析功能,包括节点查找、属性读取、设备枚举等。
Definition at line 47 of file kernel_fdt.hpp.
|
inlineexplicit |
构造函数
| header | fdt 数据地址 |
Definition at line 626 of file kernel_fdt.hpp.

|
default |
|
default |
|
default |
|
default |
|
inline |
判断 PSCI 信息
Definition at line 71 of file kernel_fdt.hpp.

|
inlineprivate |
按 device_type 统计节点数量
| device_type | 设备类型 |
Definition at line 757 of file kernel_fdt.hpp.

|
inlineprivate |
按 compatible 查找第一个匹配的节点
| compatible | 要查找的 compatible 字符串 |
Definition at line 690 of file kernel_fdt.hpp.

|
inlineprivate |
根据 compatible 查找已启用的节点(跳过 status="disabled")
| compatible | 要查找的 compatible 字符串 |
Definition at line 704 of file kernel_fdt.hpp.

|
inlineprivate |
按路径查找节点
| path | 节点路径(如 "/memory") |
Definition at line 677 of file kernel_fdt.hpp.

|
inline |
遍历所有匹配指定 compatible 的 FDT 节点
| Callback | 回调类型,签名: bool(int offset, const char* node_name, uint64_t mmio_base, size_t mmio_size, uint32_t irq) 返回 true 继续遍历,false 停止 |
| compatible | 要匹配的 compatible 字符串 |
| callback | 节点处理函数 |
Definition at line 451 of file kernel_fdt.hpp.

|
inline |
遍历 FDT 中所有"叶设备"节点,自动跳过基础设施节点。
在 ForEachNode 的基础上,额外过滤掉以下节点:
interrupt-controller 属性(中断控制器)#clock-cells 属性(时钟提供者)device_type = "cpu" 或 device_type = "memory"| Callback | 签名与 ForEachNode 完全相同: bool(const char* node_name, const char* compatible_data, size_t compatible_len, uint64_t mmio_base, size_t mmio_size, uint32_t irq) |
| callback | 节点处理函数,返回 false 停止遍历 |
Definition at line 519 of file kernel_fdt.hpp.

|
inline |
遍历 FDT 中所有设备节点
| Callback | 回调类型,签名: bool(const char* node_name, const char* compatible_data, size_t compatible_len, uint64_t mmio_base, size_t mmio_size, uint32_t irq) 返回 true 继续遍历,false 停止 |
| callback | 节点处理函数 |
Definition at line 365 of file kernel_fdt.hpp.

|
inline |
获取 aarch64 中断号
| compatible | 要查找的 compatible 字符串 |
Definition at line 262 of file kernel_fdt.hpp.

|
inline |
获取 CPU 核心数量
Definition at line 54 of file kernel_fdt.hpp.


|
inline |
获取 GIC 信息
Definition at line 198 of file kernel_fdt.hpp.


|
inline |
获取 GIC CPU Interface (Redistributor) 信息
Definition at line 248 of file kernel_fdt.hpp.

|
inline |
获取 GIC Distributor 信息
Definition at line 236 of file kernel_fdt.hpp.

|
inline |
获取内存信息
Definition at line 92 of file kernel_fdt.hpp.


|
inline |
获取 PLIC 信息
Definition at line 310 of file kernel_fdt.hpp.

|
inlineprivate |
获取 PSCI method 属性
| offset | 节点偏移 |
Definition at line 789 of file kernel_fdt.hpp.

|
inlineprivate |
获取 reg 属性(返回第一个 reg 条目)
| offset | 节点偏移量 |
Definition at line 734 of file kernel_fdt.hpp.

|
inline |
获取串口信息
Definition at line 109 of file kernel_fdt.hpp.


|
inline |
获取 CPU 时钟频率
Definition at line 173 of file kernel_fdt.hpp.


|
inlineprivate |
验证 FDT header
Definition at line 664 of file kernel_fdt.hpp.

|
inlineprivate |
验证 PSCI 函数 ID
| offset | 节点偏移 |
Definition at line 803 of file kernel_fdt.hpp.


|
private |
|
staticconstexprprivate |
Definition at line 657 of file kernel_fdt.hpp.
|
staticconstexprprivate |
PSCI 标准函数 ID(SMC64 调用约定)
Definition at line 656 of file kernel_fdt.hpp.
|
staticconstexprprivate |
Definition at line 658 of file kernel_fdt.hpp.