7#ifndef INTERRUPT_UTIL_H_
8#define INTERRUPT_UTIL_H_
10#define MS_TO_US(ms) (ms * USEC_PER_MSEC)
12#if defined(CONFIG_CPU_CORTEX_M)
13#include <cmsis_core.h>
19 for (i = initial_offset - 1; i >= 0; i--) {
21 if (NVIC_GetEnableIRQ(i) == 0) {
31 NVIC_SetPendingIRQ(i);
33 if (NVIC_GetPendingIRQ(i)) {
39 NVIC_ClearPendingIRQ(i);
41 if (!NVIC_GetPendingIRQ(i)) {
60static inline void trigger_irq(
int irq)
62 printk(
"Triggering irq : %d\n", irq);
63#if defined(CONFIG_SOC_TI_LM3S6965_QEMU) || defined(CONFIG_CPU_CORTEX_M0) \
64 || defined(CONFIG_CPU_CORTEX_M0PLUS) || defined(CONFIG_CPU_CORTEX_M1)\
65 || defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
67 NVIC_SetPendingIRQ(irq);
73#elif defined(CONFIG_GIC)
77static inline void trigger_irq(
int irq)
79 printk(
"Triggering irq : %d\n", irq);
82 zassert_true(irq <= 15,
"%u is not a valid SGI interrupt ID", irq);
88#if CONFIG_GIC_VER <= 2
99#elif defined(CONFIG_ARC)
100static inline void trigger_irq(
int irq)
102 printk(
"Triggering irq : %d\n", irq);
103 z_arc_v2_aux_reg_write(_ARC_V2_AUX_IRQ_HINT, irq);
106#elif defined(CONFIG_X86)
110#define VECTOR_MASK 0xFF
113#define LOAPIC_ICR_IPI_TEST 0x00004000U
135static inline void trigger_irq(
int vector)
148 z_loapic_ipi(cpu_id, LOAPIC_ICR_IPI_TEST, vector);
155 for (i = 0; i < 10; i++) {
160#elif defined(CONFIG_ARCH_POSIX)
163static inline void trigger_irq(
int irq)
168#elif defined(CONFIG_RISCV)
169#if defined(CONFIG_NUCLEI_ECLIC) || defined(CONFIG_NRFX_CLIC)
170void riscv_clic_irq_set_pending(
uint32_t irq);
171static inline void trigger_irq(
int irq)
173 riscv_clic_irq_set_pending(irq);
176static inline void trigger_irq(
int irq)
180 __asm__
volatile (
"csrrs %0, mip, %1\n"
185#elif defined(CONFIG_XTENSA)
186static inline void trigger_irq(
int irq)
188 z_xt_set_intset(
BIT((
unsigned int)irq));
191#elif defined(CONFIG_SPARC)
192extern void z_sparc_enter_irq(
int);
194static inline void trigger_irq(
int irq)
196 z_sparc_enter_irq(irq);
199#elif defined(CONFIG_MIPS)
200extern void z_mips_enter_irq(
int);
202static inline void trigger_irq(
int irq)
204 z_mips_enter_irq(irq);
207#elif defined(CONFIG_CPU_CORTEX_R5) && defined(CONFIG_VIM)
209extern void z_vim_arm_enter_irq(
int);
211static inline void trigger_irq(
int irq)
213 z_vim_arm_enter_irq(irq);
218#define NO_TRIGGER_FROM_SW
static ALWAYS_INLINE _cpu_t * arch_curr_cpu(void)
Definition arch_inlines.h:17
#define MPIDR_AFFLVL(mpidr, aff_level)
Definition cpu.h:94
#define GET_MPIDR()
Definition cpu.h:97
Driver for ARM Generic Interrupt Controller.
void gic_raise_sgi(unsigned int sgi_id, uint64_t target_aff, uint16_t target_list)
raise SGI to target cores
#define GICD_SGIR
Definition gic.h:127
#define GICD_SGIR_SGIINTID(x)
Definition gic.h:207
#define GICD_SGIR_TGTFILT_REQONLY
Definition gic.h:199
static void arch_nop(void)
Do nothing and return.
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define zassert_true(cond,...)
Assert that cond is true.
Definition ztest_assert.h:275
static void x86_write_x2apic(unsigned int reg, uint64_t val)
Write 64-bit value to the local APIC in x2APIC mode.
Definition loapic.h:117
#define LOAPIC_SELF_IPI
Definition loapic.h:42
void posix_sw_set_pending_IRQ(unsigned int IRQn)
static void printk(const char *fmt,...)
Print kernel debugging message.
Definition printk.h:51
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
static ALWAYS_INLINE void sys_write32(uint32_t data, mem_addr_t addr)
Definition sys-io-common.h:70