实现unified-init库,支持收集初始化函数到一个数组,并统一初始化 (#474)

* 添加“统一初始化”的过程宏,并把SystemError独立成crate

* 使用unified-init来初始化fbmem

* 更新workflow,增加内核自动化静态测试
This commit is contained in:
LoGin
2023-12-25 23:12:27 +08:00
committed by GitHub
parent f110d330d5
commit 91e9d4ab55
158 changed files with 1102 additions and 610 deletions

View File

@ -7,9 +7,11 @@ use super::{
},
kobject::KObject,
};
use crate::{driver::base::device::device_register, syscall::SystemError};
use crate::driver::base::device::device_register;
use alloc::{collections::BTreeSet, string::ToString, sync::Arc, vec::Vec};
use core::fmt::Debug;
use system_error::SystemError;
use unified_init::{define_unified_initializer_slice, unified_init};
pub mod platform_device;
pub mod platform_driver;
@ -18,6 +20,8 @@ pub mod subsys;
static mut PLATFORM_BUS_DEVICE: Option<Arc<PlatformBusDevice>> = None;
static mut PLATFORM_BUS: Option<Arc<PlatformBus>> = None;
define_unified_initializer_slice!(PLATFORM_DEVICE_INITIALIZER);
#[allow(dead_code)]
#[inline(always)]
pub fn platform_bus_device() -> Arc<PlatformBusDevice> {
@ -92,5 +96,7 @@ pub fn platform_bus_init() -> Result<(), SystemError> {
}
unsafe { PLATFORM_BUS = Some(paltform_bus) };
unified_init!(PLATFORM_DEVICE_INITIALIZER);
return r;
}

View File

@ -21,8 +21,8 @@ use crate::{
rwlock::{RwLockReadGuard, RwLockWriteGuard},
spinlock::SpinLock,
},
syscall::SystemError,
};
use system_error::SystemError;
use super::{super::device::DeviceState, platform_bus, platform_bus_device, CompatibleTable};

View File

@ -1,13 +1,12 @@
use alloc::sync::Arc;
use crate::{
driver::base::device::{
bus::Bus,
driver::{driver_manager, Driver},
},
syscall::SystemError,
use crate::driver::base::device::{
bus::Bus,
driver::{driver_manager, Driver},
};
use system_error::SystemError;
use super::{platform_bus, platform_device::PlatformDevice};
/// @brief: 实现该trait的设备驱动实例应挂载在platform总线上

View File

@ -4,6 +4,7 @@ use alloc::{
};
use intertrait::cast::CastArc;
use super::{platform_device::PlatformDevice, platform_driver::PlatformDriver};
use crate::{
driver::{
acpi::acpi_manager,
@ -17,10 +18,8 @@ use crate::{
sysfs::{Attribute, AttributeGroup},
vfs::syscall::ModeType,
},
syscall::SystemError,
};
use super::{platform_device::PlatformDevice, platform_driver::PlatformDriver};
use system_error::SystemError;
#[derive(Debug)]
pub struct PlatformBus {