7#ifndef INTERRUPT_UTIL_H_
8#define INTERRUPT_UTIL_H_
10#define k_str_out_count(s) k_str_out((s), sizeof(s) - 1);
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)
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)
82 zassert_true(irq <= 15,
"%u is not a valid SGI interrupt ID", irq);
88#if CONFIG_GIC_VER <= 2
98#elif defined(CONFIG_ARC)
99static inline void trigger_irq(
int irq)
102 z_arc_v2_aux_reg_write(_ARC_V2_AUX_IRQ_HINT, irq);
105#elif defined(CONFIG_X86)
109#define VECTOR_MASK 0xFF
112#define LOAPIC_ICR_IPI_TEST 0x00004000U
134static inline void trigger_irq(
int vector)
147 z_loapic_ipi(cpu_id, LOAPIC_ICR_IPI_TEST, vector);
154 for (i = 0; i < 10; i++) {
159#elif defined(CONFIG_ARCH_POSIX)
162static inline void trigger_irq(
int irq)
167#elif defined(CONFIG_RISCV)
168#if defined(CONFIG_CLIC) || defined(CONFIG_NRFX_CLIC)
169void riscv_clic_irq_set_pending(
uint32_t irq);
170static inline void trigger_irq(
int irq)
172 riscv_clic_irq_set_pending(irq);
175static inline void trigger_irq(
int irq)
179 __asm__
volatile(
"csrrs %0, mip, %1\n" :
"=r"(mip) :
"r"(1 << irq));
182#elif defined(CONFIG_XTENSA)
183static inline void trigger_irq(
int irq)
185#if XCHAL_NUM_INTERRUPTS > 32
188 z_xt_set_intset(1 << irq);
191 z_xt_set_intset1(1 << irq);
193#if XCHAL_NUM_INTERRUPTS > 64
195 z_xt_set_intset2(1 << irq);
198#if XCHAL_NUM_INTERRUPTS > 96
200 z_xt_set_intset3(1 << irq);
207 z_xt_set_intset(1 << irq);
211#elif defined(CONFIG_SPARC)
212extern void z_sparc_enter_irq(
int);
214static inline void trigger_irq(
int irq)
216 z_sparc_enter_irq(irq);
219#elif defined(CONFIG_MIPS)
220extern void z_mips_enter_irq(
int);
222static inline void trigger_irq(
int irq)
224 z_mips_enter_irq(irq);
227#elif defined(CONFIG_CPU_CORTEX_R5) && defined(CONFIG_VIM)
229extern void z_vim_arm_enter_irq(
int);
231static inline void trigger_irq(
int irq)
233 z_vim_arm_enter_irq(irq);
236#elif defined(CONFIG_RX)
237#define IR_BASE_ADDRESS DT_REG_ADDR_BY_NAME(DT_NODELABEL(icu), IR)
238static inline void trigger_irq(
int irq)
240 __ASSERT(irq <
CONFIG_NUM_IRQS,
"attempting to trigger invalid IRQ (%u)", irq);
248#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:101
#define GET_MPIDR()
Definition cpu.h:104
#define CONFIG_GEN_IRQ_START_VECTOR
Definition irq.h:14
#define CONFIG_NUM_IRQS
Definition irq.h:183
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:181
#define GICD_SGIR_SGIINTID(x)
Definition gic.h:259
#define GICD_SGIR_TGTFILT_REQONLY
Definition gic.h:251
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
#define k_str_out_count(s)
Definition interrupt_util.h:10
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:118
#define LOAPIC_SELF_IPI
Definition loapic.h:42
void posix_sw_set_pending_IRQ(unsigned int IRQn)
__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