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