1 use super::smp::SMP_BOOT_DATA; 2 use crate::{driver::acpi::acpi_manager, kinfo, mm::percpu::PerCpu, smp::cpu::ProcessorId}; 3 use system_error::SystemError; 4 5 pub(super) fn early_acpi_boot_init() -> Result<(), SystemError> { 6 // 在这里解析madt,初始化smp boot data 7 8 let platform_info = acpi_manager().platform_info().ok_or(SystemError::ENODEV)?; 9 let processor_info = platform_info.processor_info.ok_or(SystemError::ENODEV)?; 10 11 unsafe { 12 SMP_BOOT_DATA.set_phys_id( 13 ProcessorId::new(0), 14 processor_info.boot_processor.local_apic_id as usize, 15 ); 16 let mut cnt = ProcessorId::new(1); 17 for ap in processor_info.application_processors.iter() { 18 if cnt.data() >= PerCpu::MAX_CPU_NUM { 19 break; 20 } 21 SMP_BOOT_DATA.set_phys_id(cnt, ap.local_apic_id as usize); 22 cnt = ProcessorId::new(cnt.data() + 1); 23 } 24 SMP_BOOT_DATA.set_cpu_count(cnt.data()); 25 SMP_BOOT_DATA.mark_initialized(); 26 } 27 kinfo!( 28 "early_acpi_boot_init: cpu_count: {}\n", 29 SMP_BOOT_DATA.cpu_count() 30 ); 31 32 // todo!("early_acpi_boot_init") 33 return Ok(()); 34 } 35