@@ -14,6 +14,7 @@ pub(super) mod vectors {
1414 pub const APIC_TIMER_VECTOR : u8 = 0xf0 ;
1515 pub const APIC_SPURIOUS_VECTOR : u8 = 0xf1 ;
1616 pub const APIC_ERROR_VECTOR : u8 = 0xf2 ;
17+ pub const APIC_IPI_VECTOR : u8 = 0xf2 ;
1718}
1819
1920/// The maximum number of IRQs.
@@ -22,6 +23,9 @@ pub const MAX_IRQ_COUNT: usize = 256;
2223/// The timer IRQ number.
2324pub const TIMER_IRQ_NUM : usize = APIC_TIMER_VECTOR as usize ;
2425
26+ /// The IPI IRQ number.
27+ pub const IPI_IRQ_NUM : usize = APIC_IPI_VECTOR as usize ;
28+
2529const IO_APIC_BASE : PhysAddr = pa ! ( 0xFEC0_0000 ) ;
2630
2731static mut LOCAL_APIC : Option < LocalApic > = None ;
@@ -52,6 +56,21 @@ pub fn register_handler(vector: usize, handler: crate::irq::IrqHandler) -> bool
5256 crate :: irq:: register_handler_common ( vector, handler)
5357}
5458
59+ /// Sends Software Generated Interrupt (SGI)(s) (usually IPI) to the given dest CPU.
60+ pub fn send_sgi_one ( dest_cpu_id : usize , irq_num : usize ) {
61+ unsafe {
62+ local_apic ( ) . send_ipi ( irq_num as _ , dest_cpu_id as _ ) ;
63+ } ;
64+ }
65+
66+ /// Sends a broadcast IPI to all CPUs.
67+ pub fn send_sgi_all ( irq_num : usize ) {
68+ use x2apic:: lapic:: IpiAllShorthand ;
69+ unsafe {
70+ local_apic ( ) . send_ipi_all ( irq_num as _ , IpiAllShorthand :: AllExcludingSelf ) ;
71+ } ;
72+ }
73+
5574/// Dispatches the IRQ.
5675///
5776/// This function is called by the common interrupt handler. It looks
0 commit comments