SimpleKernel 1.17.0
Loading...
Searching...
No Matches
device.cpp File Reference
#include "device_manager.hpp"
#include "kernel.h"
#include "kernel_fdt.hpp"
#include "kernel_log.hpp"
#include "ns16550a/ns16550a_driver.hpp"
#include "pl011/pl011_driver.hpp"
#include "platform_bus.hpp"
#include "virtio/virtio_driver.hpp"
Include dependency graph for device.cpp:

Go to the source code of this file.

Functions

auto DeviceInit () -> void
 设备子系统初始化入口
 

Function Documentation

◆ DeviceInit()

auto DeviceInit ( ) -> void

设备子系统初始化入口

设备子系统初始化

Definition at line 28 of file device.cpp.

28 {
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}
平台总线 — 从扁平设备树(FDT)枚举设备
auto Err(etl::format_string< Args... > fmt, Args &&... args) -> void
以 ERROR 级别记录日志
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
Here is the call graph for this function:
Here is the caller graph for this function: