xref: /DragonOS/kernel/src/smp/mod.rs (revision 8d94ea66a3eb3e02039730c8d08e9bead8c344b8)
1 use crate::{
2     arch::{asm::current::current_pcb, interrupt::ipi::send_ipi},
3     exception::ipi::{IpiKind, IpiTarget},
4     mm::INITIAL_PROCESS_ADDRESS_SPACE,
5     syscall::SystemError,
6 };
7 
8 pub mod c_adapter;
9 pub mod core;
10 
11 pub fn kick_cpu(cpu_id: usize) -> Result<(), SystemError> {
12     // todo: 增加对cpu_id的有效性检查
13 
14     send_ipi(IpiKind::KickCpu, IpiTarget::Specified(cpu_id));
15     return Ok(());
16 }
17 
18 /// 初始化AP核的idle进程
19 pub unsafe fn init_smp_idle_process() {
20     current_pcb().set_address_space(INITIAL_PROCESS_ADDRESS_SPACE());
21 }
22