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

Function DeviceInit

src/device/device.cpp:28–59  ·  view source on GitHub ↗

设备子系统初始化入口

Source from the content-addressed store, hash-verified

26
27/// 设备子系统初始化入口
28auto DeviceInit() -> void {
29 DeviceManagerSingleton::create();
30 auto& dm = DeviceManagerSingleton::instance();
31
32 // 创建驱动单例
33 Ns16550aDriverSingleton::create();
34 Pl011DriverSingleton::create();
35 VirtioDriverSingleton::create();
36
37 for (const auto& get_entry : kBuiltinDrivers) {
38 const auto& entry = get_entry();
39 if (auto r = dm.GetRegistry().Register(entry); !r) {
40 klog::Err("DeviceInit: register driver '{}' failed: {}", entry.name,
41 r.error().message());
42 return;
43 }
44 }
45
46 PlatformBus platform_bus(KernelFdtSingleton::instance());
47 if (auto r = dm.RegisterBus(platform_bus); !r) {
48 klog::Err("DeviceInit: PlatformBus enumeration failed: {}",
49 r.error().message());
50 return;
51 }
52
53 if (auto r = dm.ProbeAll(); !r) {
54 klog::Err("DeviceInit: ProbeAll failed: {}", r.error().message());
55 return;
56 }
57
58 klog::Info("DeviceInit: complete");
59}

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 7

ErrFunction · 0.85
InfoFunction · 0.85
RegisterMethod · 0.80
GetRegistryMethod · 0.80
messageMethod · 0.80
RegisterBusMethod · 0.80
ProbeAllMethod · 0.80

Tested by

no test coverage detected