191e9d4abSLoGin use system_error::SystemError; 291e9d4abSLoGin 3aa0367d6SLoGin use crate::{ 41496ba7bSLoGin arch::interrupt::ipi::send_ipi, 5aa0367d6SLoGin exception::ipi::{IpiKind, IpiTarget}, 6aa0367d6SLoGin }; 7aa0367d6SLoGin 8*338f6903SLoGin use self::{ 9*338f6903SLoGin core::smp_get_processor_id, 10*338f6903SLoGin cpu::{smp_cpu_manager_init, ProcessorId}, 11*338f6903SLoGin }; 12e2841179SLoGin 1340fe15e0SLoGin pub mod c_adapter; 1466f67c6aSlogin pub mod core; 1570a4e555SLoGin pub mod cpu; 16aa0367d6SLoGin 17e2841179SLoGin pub fn kick_cpu(cpu_id: ProcessorId) -> Result<(), SystemError> { 18aa0367d6SLoGin // todo: 增加对cpu_id的有效性检查 19aa0367d6SLoGin 20e2841179SLoGin send_ipi(IpiKind::KickCpu, IpiTarget::Specified(cpu_id)); 21aa0367d6SLoGin return Ok(()); 22aa0367d6SLoGin } 235b59005fSLoGin 245b59005fSLoGin pub trait SMPArch { 255b59005fSLoGin /// 准备SMP初始化所需的cpu拓扑数据。 265b59005fSLoGin /// 275b59005fSLoGin /// 该函数需要标记为 `#[inline(never)]` 285b59005fSLoGin fn prepare_cpus() -> Result<(), SystemError>; 295b59005fSLoGin 305b59005fSLoGin /// 初始化SMP 315b59005fSLoGin /// 325b59005fSLoGin /// 该函数需要标记为 `#[inline(never)]` 335b59005fSLoGin fn init() -> Result<(), SystemError>; 345b59005fSLoGin } 35*338f6903SLoGin 36*338f6903SLoGin /// 早期SMP初始化 37*338f6903SLoGin #[inline(never)] 38*338f6903SLoGin pub fn early_smp_init() -> Result<(), SystemError> { 39*338f6903SLoGin smp_cpu_manager_init(smp_get_processor_id()); 40*338f6903SLoGin 41*338f6903SLoGin return Ok(()); 42*338f6903SLoGin } 43