1 /*
2  * Copyright (c) 2018 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "sw_isr_common.h"
8 #include <zephyr/sw_isr_table.h>
9 #include <zephyr/irq.h>
10 #include <zephyr/sys/__assert.h>
11 
z_isr_install(unsigned int irq,void (* routine)(const void *),const void * param)12 void __weak z_isr_install(unsigned int irq, void (*routine)(const void *),
13 			  const void *param)
14 {
15 	unsigned int table_idx;
16 
17 	/*
18 	 * Do not assert on the IRQ enable status for ARM GIC since the SGI
19 	 * type interrupts are always enabled and attempting to install an ISR
20 	 * for them will cause the assertion to fail.
21 	 */
22 #ifndef CONFIG_GIC
23 	__ASSERT(!irq_is_enabled(irq), "IRQ %d is enabled", irq);
24 #endif /* !CONFIG_GIC */
25 
26 	table_idx = z_get_sw_isr_table_idx(irq);
27 
28 	/* If dynamic IRQs are enabled, then the _sw_isr_table is in RAM and
29 	 * can be modified
30 	 */
31 	_sw_isr_table[table_idx].arg = param;
32 	_sw_isr_table[table_idx].isr = routine;
33 }
34 
35 /* Some architectures don't/can't interpret flags or priority and have
36  * no more processing to do than this.  Provide a generic fallback.
37  */
arch_irq_connect_dynamic(unsigned int irq,unsigned int priority,void (* routine)(const void *),const void * parameter,uint32_t flags)38 int __weak arch_irq_connect_dynamic(unsigned int irq,
39 				    unsigned int priority,
40 				    void (*routine)(const void *),
41 				    const void *parameter,
42 				    uint32_t flags)
43 {
44 	ARG_UNUSED(flags);
45 	ARG_UNUSED(priority);
46 
47 	z_isr_install(irq, routine, parameter);
48 	return irq;
49 }
50