xref: /DragonOS/kernel/src/smp/mod.rs (revision 5b59005f930266d0e9c0092373e894826150f862)
1 use system_error::SystemError;
2 
3 use crate::{
4     arch::interrupt::ipi::send_ipi,
5     exception::ipi::{IpiKind, IpiTarget},
6 };
7 
8 pub mod c_adapter;
9 pub mod core;
10 pub mod cpu;
11 
12 pub fn kick_cpu(cpu_id: u32) -> Result<(), SystemError> {
13     // todo: 增加对cpu_id的有效性检查
14 
15     send_ipi(IpiKind::KickCpu, IpiTarget::Specified(cpu_id as usize));
16     return Ok(());
17 }
18 
19 pub trait SMPArch {
20     /// 准备SMP初始化所需的cpu拓扑数据。
21     ///
22     /// 该函数需要标记为 `#[inline(never)]`
23     fn prepare_cpus() -> Result<(), SystemError>;
24 
25     /// 初始化SMP
26     ///
27     /// 该函数需要标记为 `#[inline(never)]`
28     fn init() -> Result<(), SystemError>;
29 }
30