xref: /DragonOS/kernel/src/arch/riscv64/interrupt/ipi.rs (revision 911132c4b8ea0e9c49a4e84b9fa1db114102acbb)
1 use sbi_rt::HartMask;
2 
3 use crate::{
4     arch::mm::RiscV64MMArch,
5     exception::ipi::{IpiKind, IpiTarget},
6     smp::core::smp_get_processor_id,
7 };
8 
9 #[inline(always)]
10 pub fn send_ipi(kind: IpiKind, target: IpiTarget) {
11     let mask = Into::into(target);
12     match kind {
13         IpiKind::KickCpu => todo!(),
14         IpiKind::FlushTLB => RiscV64MMArch::remote_invalidate_all_with_mask(mask).ok(),
15         IpiKind::SpecVector(_) => todo!(),
16     };
17 }
18 
19 impl Into<HartMask> for IpiTarget {
20     fn into(self) -> HartMask {
21         match self {
22             IpiTarget::All => HartMask::from_mask_base(usize::MAX, 0),
23             IpiTarget::Other => {
24                 let data = usize::MAX & (!(1 << smp_get_processor_id().data()));
25                 let mask = HartMask::from_mask_base(data, 0);
26                 mask
27             }
28             IpiTarget::Specified(cpu_id) => {
29                 let mask = Into::into(cpu_id);
30                 mask
31             }
32             IpiTarget::Current => {
33                 let mask = Into::into(smp_get_processor_id());
34                 mask
35             }
36         }
37     }
38 }
39