arch: common: sw_isr_common: Move table index computing logic to function
Since the shared IRQ code will also use the same logic to compute the _sw_isr_table index, move the computing logic to a separate function: z_get_sw_isr_table_idx(), which can be used by other modules. Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
This commit is contained in:
parent
017cf89a83
commit
30d362dbac
2 changed files with 48 additions and 31 deletions
|
@ -71,24 +71,12 @@ unsigned int get_parent_offset(unsigned int parent_irq,
|
|||
|
||||
#endif /* CONFIG_MULTI_LEVEL_INTERRUPTS */
|
||||
|
||||
void z_isr_install(unsigned int irq, void (*routine)(const void *),
|
||||
const void *param)
|
||||
unsigned int z_get_sw_isr_table_idx(unsigned int irq)
|
||||
{
|
||||
unsigned int table_idx;
|
||||
|
||||
/*
|
||||
* Do not assert on the IRQ enable status for ARM GIC since the SGI
|
||||
* type interrupts are always enabled and attempting to install an ISR
|
||||
* for them will cause the assertion to fail.
|
||||
*/
|
||||
#ifndef CONFIG_GIC
|
||||
__ASSERT(!irq_is_enabled(irq), "IRQ %d is enabled", irq);
|
||||
#endif /* !CONFIG_GIC */
|
||||
|
||||
#ifdef CONFIG_MULTI_LEVEL_INTERRUPTS
|
||||
unsigned int level;
|
||||
unsigned int parent_irq;
|
||||
unsigned int parent_offset;
|
||||
unsigned int level, parent_irq, parent_offset;
|
||||
|
||||
level = irq_get_level(irq);
|
||||
|
||||
|
@ -117,6 +105,25 @@ void z_isr_install(unsigned int irq, void (*routine)(const void *),
|
|||
table_idx = irq - CONFIG_GEN_IRQ_START_VECTOR;
|
||||
#endif /* CONFIG_MULTI_LEVEL_INTERRUPTS */
|
||||
|
||||
return table_idx;
|
||||
}
|
||||
|
||||
void z_isr_install(unsigned int irq, void (*routine)(const void *),
|
||||
const void *param)
|
||||
{
|
||||
unsigned int table_idx;
|
||||
|
||||
/*
|
||||
* Do not assert on the IRQ enable status for ARM GIC since the SGI
|
||||
* type interrupts are always enabled and attempting to install an ISR
|
||||
* for them will cause the assertion to fail.
|
||||
*/
|
||||
#ifndef CONFIG_GIC
|
||||
__ASSERT(!irq_is_enabled(irq), "IRQ %d is enabled", irq);
|
||||
#endif /* !CONFIG_GIC */
|
||||
|
||||
table_idx = z_get_sw_isr_table_idx(irq);
|
||||
|
||||
/* If dynamic IRQs are enabled, then the _sw_isr_table is in RAM and
|
||||
* can be modified
|
||||
*/
|
||||
|
|
|
@ -77,6 +77,16 @@ void z_shared_isr(const void *data);
|
|||
extern struct z_shared_isr_table_entry z_shared_sw_isr_table[];
|
||||
#endif /* CONFIG_SHARED_INTERRUPTS */
|
||||
|
||||
/**
|
||||
* @brief Helper function used to compute the index in _sw_isr_table
|
||||
* based on passed IRQ.
|
||||
*
|
||||
* @param irq IRQ number in its zephyr format
|
||||
*
|
||||
* @return corresponding index in _sw_isr_table
|
||||
*/
|
||||
unsigned int z_get_sw_isr_table_idx(unsigned int irq);
|
||||
|
||||
/** This interrupt gets put directly in the vector table */
|
||||
#define ISR_FLAG_DIRECT BIT(0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue