MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / ProbeAll

Method ProbeAll

src/device/device_manager.cpp:11–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "kernel_log.hpp"
10
11auto DeviceManager::ProbeAll() -> Expected<void> {
12 LockGuard guard(lock_);
13
14 size_t probed = 0;
15 size_t no_driver_count = 0;
16 for (size_t i = 0; i < device_count_; ++i) {
17 auto& node = devices_[i];
18
19 const auto* drv = registry_.FindDriver(node);
20 if (drv == nullptr) {
21 ++no_driver_count;
22 continue;
23 }
24
25 if (!drv->match(node)) {
26 continue;
27 }
28
29 if (node.bound) {
30 continue;
31 }
32 node.bound = true;
33
34 drv->probe(node).or_else([&](auto&& err) {
35 klog::Err("DeviceManager: probe '{}' failed: {}", node.name,
36 err.message());
37 node.bound = false;
38 return Expected<void>{};
39 });
40
41 ++probed;
42 }
43
44 klog::Info("DeviceManager: probed {} device(s), {} skipped (no driver)",
45 probed, no_driver_count);
46 return {};
47}
48
49auto DeviceManager::FindDevice(const char* name) -> Expected<DeviceNode*> {
50 assert(name != nullptr && "FindDevice: name must not be null");

Callers 1

DeviceInitFunction · 0.80

Calls 4

ErrFunction · 0.85
InfoFunction · 0.85
FindDriverMethod · 0.80
messageMethod · 0.80

Tested by

no test coverage detected