15 size_t no_driver_count = 0;
16 for (
size_t i = 0; i < device_count_; ++i) {
17 auto& node = devices_[i];
19 const auto* drv = registry_.FindDriver(node);
25 if (!drv->match(node)) {
34 drv->probe(node).or_else([&](
auto&& err) {
35 klog::Err(
"DeviceManager: probe '{}' failed: {}", node.name,
44 klog::Info(
"DeviceManager: probed {} device(s), {} skipped (no driver)",
45 probed, no_driver_count);
50 assert(name !=
nullptr &&
"FindDevice: name must not be null");
52 const auto it = name_index_.find(name);
53 if (it != name_index_.end()) {
54 return &devices_[it->second];
60 size_t max) ->
size_t {
61 assert((out !=
nullptr || max == 0) &&
62 "FindDevicesByType: out must not be null when max > 0");
65 for (
size_t i = 0; i < device_count_ && found < max; ++i) {
66 if (devices_[i].type == type) {
67 out[found++] = &devices_[i];
auto FindDevicesByType(DeviceType type, DeviceNode **out, size_t max) -> size_t
按类型枚举设备。
auto FindDevice(const char *name) -> Expected< DeviceNode * >
根据名称查找设备。
auto ProbeAll() -> Expected< void >
匹配已注册的驱动程序并探测所有未绑定的设备。
std::expected< T, Error > Expected
std::expected 别名模板
auto Err(etl::format_string< Args... > fmt, Args &&... args) -> void
以 ERROR 级别记录日志
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志