27 {
28 size_t count = 0;
29
31 [&out, &count, max](const char* node_name, const char* compatible_data,
32 size_t compatible_len, uint64_t mmio_base,
33 size_t mmio_size, uint32_t irq) -> bool {
34 if (count >= max) return false;
35 if (compatible_data == nullptr || compatible_len == 0) return true;
36
37 auto& node = out[count];
38
39 kstd::strncpy(node.name, node_name, sizeof(node.name) - 1);
40 node.name[sizeof(node.name) - 1] = '\0';
41
44 node.mmio_base = mmio_base;
45 node.mmio_size = mmio_size;
46 node.irq = irq;
47
48 size_t copy_len = compatible_len < sizeof(node.compatible)
49 ? compatible_len
50 : sizeof(node.compatible);
51 if (compatible_len > sizeof(node.compatible)) {
52 klog::Warn(
"PlatformBus: compatible truncated {}\u2192{} for '{}'",
53 compatible_len, sizeof(node.compatible), node_name);
54 }
55 kstd::memcpy(node.compatible, compatible_data, copy_len);
56 node.compatible_len = copy_len;
57
59 "PlatformBus: found '{}' compatible='{}' mmio={:#x} size={:#x} "
60 "irq={}",
61 node_name, compatible_data, mmio_base, mmio_size, irq);
62
63 ++count;
64 return true;
65 });
66
67 if (!result.has_value()) {
68 return std::unexpected(result.error());
69 }
70 return count;
71 }
auto ForEachDeviceNode(Callback &&callback) const -> Expected< void >
遍历 FDT 中所有"叶设备"节点,自动跳过基础设施节点。
@ kPlatform
平台设备(中断控制器、定时器等)
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
auto Warn(etl::format_string< Args... > fmt, Args &&... args) -> void
以 WARN 级别记录日志