1 use system_error::SystemError; 2 3 use crate::{ 4 arch::interrupt::ipi::send_ipi, 5 exception::ipi::{IpiKind, IpiTarget}, 6 }; 7 8 use self::{ 9 core::smp_get_processor_id, 10 cpu::{smp_cpu_manager_init, ProcessorId}, 11 }; 12 13 pub mod c_adapter; 14 pub mod core; 15 pub mod cpu; 16 17 pub fn kick_cpu(cpu_id: ProcessorId) -> Result<(), SystemError> { 18 // todo: 增加对cpu_id的有效性检查 19 20 send_ipi(IpiKind::KickCpu, IpiTarget::Specified(cpu_id)); 21 return Ok(()); 22 } 23 24 pub trait SMPArch { 25 /// 准备SMP初始化所需的cpu拓扑数据。 26 /// 27 /// 该函数需要标记为 `#[inline(never)]` 28 fn prepare_cpus() -> Result<(), SystemError>; 29 30 /// 初始化SMP 31 /// 32 /// 该函数需要标记为 `#[inline(never)]` 33 fn init() -> Result<(), SystemError>; 34 } 35 36 /// 早期SMP初始化 37 #[inline(never)] 38 pub fn early_smp_init() -> Result<(), SystemError> { 39 smp_cpu_manager_init(smp_get_processor_id()); 40 41 return Ok(()); 42 } 43