初步编写cpu信息获取的代码 (#406)

1. 启动时从acpi获取所有的cpu信息并存到SMP_BOOT_DATA
2. 注册cpu subsystem/bus到sysfs(暂时未添加内容)

todo:
1. build_cpu_map(在X86_64SmpManager中)
2. 实现cpu mask
3. 把cpu设备注册到sysfs
This commit is contained in:
LoGin
2023-10-23 21:40:39 +08:00
committed by GitHub
parent 7eda31b2f0
commit d7f5742a20
13 changed files with 491 additions and 17 deletions

View File

@ -1,6 +1,6 @@
use core::{fmt::Debug, ptr::NonNull};
use acpi::AcpiHandler;
use acpi::{AcpiHandler, PlatformInfo};
use alloc::{string::ToString, sync::Arc};
use crate::{
@ -87,6 +87,27 @@ impl AcpiManager {
pub fn tables(&self) -> Option<&'static acpi::AcpiTables<AcpiHandlerImpl>> {
unsafe { __ACPI_TABLE.as_ref() }
}
/// 从acpi获取平台的信息
///
/// 包括:
///
/// - PowerProfile
/// - InterruptModel
/// - ProcessorInfo
/// - PmTimer
pub fn platform_info(&self) -> Option<PlatformInfo<'_, alloc::alloc::Global>> {
let r = self.tables()?.platform_info();
if let Err(ref e) = r {
kerror!(
"AcpiManager::platform_info(): failed to get platform info, error: {:?}",
e
);
return None;
}
return Some(r.unwrap());
}
}
#[derive(Debug, Clone, Copy)]