Skip to content

Commit db3fa50

Browse files
Enjia Mainashif
authored andcommitted
testsuite: utils: use IPI instead of int instruction for testing on x86
For x86, make the testing purpose trigger_irq() function to send interrupt processor interrupt to CPU by APIC, instead of executing INT instruction. Doing this because: 1. It can be controlled by irq lock, more close to trigger irq. 2. We don't need to hardcode the interrupt vector. Signed-off-by: Enjia Mai <[email protected]>
1 parent 993cb4c commit db3fa50

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

subsys/testsuite/include/interrupt_util.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,31 @@ static inline void trigger_irq(int irq)
101101
}
102102

103103
#elif defined(CONFIG_X86)
104+
#include <drivers/interrupt_controller/loapic.h>
105+
#include <sys/arch_interface.h>
104106

105-
#define trigger_irq(irq) __asm__ volatile("int %0" : : "i" (irq) : "memory")
107+
#define TRIGGER_IRQ_INT(vector) __asm__ volatile("int %0" : : "i" (vector) : "memory")
108+
109+
/*
110+
* Write Local APIC's ICR to trigger IPI for testing
111+
* Delivery Mode: Fixed
112+
* Destination Mode: Physical
113+
* Level: Assert
114+
* Trigger Mode: Edge
115+
* Destination Shorthand: No Shorthand
116+
* Destination: depends on cpu_id
117+
*/
118+
#define LOAPIC_ICR_IPI_TEST 0x00004000U
119+
120+
static inline void trigger_irq(int vector)
121+
{
122+
#ifdef CONFIG_SMP
123+
int cpu_id = arch_curr_cpu()->id;
124+
#else
125+
int cpu_id = 0;
126+
#endif
127+
z_loapic_ipi(cpu_id, LOAPIC_ICR_IPI_TEST, vector);
128+
}
106129

107130
#elif defined(CONFIG_ARCH_POSIX)
108131
#include "irq_ctrl.h"

0 commit comments

Comments
 (0)