Mingtao Huang dd8e74ef0d
feat(driver/acpi_pm): Implement ACPI PM Timer (#772)
* feat: Implement ACPI PM Timer
2024-04-28 13:25:12 +08:00

35 lines
1.2 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use super::smp::SMP_BOOT_DATA;
use crate::{driver::acpi::acpi_manager, kinfo, mm::percpu::PerCpu, smp::cpu::ProcessorId};
use system_error::SystemError;
pub(super) fn early_acpi_boot_init() -> Result<(), SystemError> {
// 在这里解析madt初始化smp boot data
let platform_info = acpi_manager().platform_info().ok_or(SystemError::ENODEV)?;
let processor_info = platform_info.processor_info.ok_or(SystemError::ENODEV)?;
unsafe {
SMP_BOOT_DATA.set_phys_id(
ProcessorId::new(0),
processor_info.boot_processor.local_apic_id as usize,
);
let mut cnt = ProcessorId::new(1);
for ap in processor_info.application_processors.iter() {
if cnt.data() >= PerCpu::MAX_CPU_NUM {
break;
}
SMP_BOOT_DATA.set_phys_id(cnt, ap.local_apic_id as usize);
cnt = ProcessorId::new(cnt.data() + 1);
}
SMP_BOOT_DATA.set_cpu_count(cnt.data());
SMP_BOOT_DATA.mark_initialized();
}
kinfo!(
"early_acpi_boot_init: cpu_count: {}\n",
SMP_BOOT_DATA.cpu_count()
);
// todo!("early_acpi_boot_init")
return Ok(());
}