From 6df8b3995e05d6348f8de9601379475a5455fedd Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Fri, 10 Jul 2020 14:17:20 +0200 Subject: [PATCH] irq: Change dynamic API to take a constant parameter All ISRs are meant to take a const struct device pointer, but to simplify the change let's just move the parameter to constant and that should be fine. Fixes #27399 Signed-off-by: Tomasz Bursztyka --- arch/common/gen_isr_tables.py | 4 ++-- arch/common/isr_tables.c | 3 ++- include/arch/xtensa/irq.h | 4 ++-- include/irq.h | 4 ++-- include/sw_isr_table.h | 11 ++++++----- include/sys/arch_interface.h | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/common/gen_isr_tables.py b/arch/common/gen_isr_tables.py index 06e692efd74..486b072a192 100755 --- a/arch/common/gen_isr_tables.py +++ b/arch/common/gen_isr_tables.py @@ -61,7 +61,7 @@ def read_intlist(intlist_path, syms): /** ISR to call */ void *func; /** Parameter for non-direct IRQs */ - void *param; + const void *param; }; """ @@ -175,7 +175,7 @@ def write_source_file(fp, vt, swt, intlist, syms): fp.write("\t/* Level 3 interrupts start here (offset: {}) */\n". format(level3_offset)) - fp.write("\t{{(void *){0:#x}, (void *){1}}},\n".format(param, func_as_string)) + fp.write("\t{{(const void *){0:#x}, (void *){1}}},\n".format(param, func_as_string)) fp.write("};\n") def get_symbols(obj): diff --git a/arch/common/isr_tables.c b/arch/common/isr_tables.c index b0cf3cd1fb0..b9a28bbdbb2 100644 --- a/arch/common/isr_tables.c +++ b/arch/common/isr_tables.c @@ -60,6 +60,7 @@ uint32_t __irq_vector_table _irq_vector_table[IRQ_TABLE_SIZE] = { */ #ifdef CONFIG_GEN_SW_ISR_TABLE struct _isr_table_entry __sw_isr_table _sw_isr_table[IRQ_TABLE_SIZE] = { - [0 ...(IRQ_TABLE_SIZE - 1)] = {(void *)0x42, (void *)&z_irq_spurious}, + [0 ...(IRQ_TABLE_SIZE - 1)] = {(const void *)0x42, + (void *)&z_irq_spurious}, }; #endif diff --git a/include/arch/xtensa/irq.h b/include/arch/xtensa/irq.h index 395ba926834..6bf00a31fa9 100644 --- a/include/arch/xtensa/irq.h +++ b/include/arch/xtensa/irq.h @@ -38,8 +38,8 @@ #ifdef CONFIG_DYNAMIC_INTERRUPTS extern int z_soc_irq_connect_dynamic(unsigned int irq, unsigned int priority, - void (*routine)(void *parameter), - void *parameter, uint32_t flags); + void (*routine)(const void *parameter), + const void *parameter, uint32_t flags); #endif #else diff --git a/include/irq.h b/include/irq.h index 083ffa1ca0c..b5616d58529 100644 --- a/include/irq.h +++ b/include/irq.h @@ -63,8 +63,8 @@ extern "C" { */ static inline int irq_connect_dynamic(unsigned int irq, unsigned int priority, - void (*routine)(void *parameter), void *parameter, - uint32_t flags) + void (*routine)(const void *parameter), + const void *parameter, uint32_t flags) { return arch_irq_connect_dynamic(irq, priority, routine, parameter, flags); diff --git a/include/sw_isr_table.h b/include/sw_isr_table.h index e15ca7410ea..8204ffc8722 100644 --- a/include/sw_isr_table.h +++ b/include/sw_isr_table.h @@ -28,8 +28,8 @@ extern "C" { * on ARM Cortex-M (Thumb2). */ struct _isr_table_entry { - void *arg; - void (*isr)(void *); + const void *arg; + void (*isr)(const void *); }; /* The software ISR table itself, an array of these structures indexed by the @@ -52,7 +52,7 @@ struct _isr_list { /** ISR to call */ void *func; /** Parameter for non-direct IRQs */ - void *param; + const void *param; }; /** This interrupt gets put directly in the vector table */ @@ -68,12 +68,13 @@ struct _isr_list { #define Z_ISR_DECLARE(irq, flags, func, param) \ static Z_DECL_ALIGN(struct _isr_list) Z_GENERIC_SECTION(.intList) \ __used _MK_ISR_NAME(func, __COUNTER__) = \ - {irq, flags, (void *)&func, (void *)param} + {irq, flags, (void *)&func, (const void *)param} #define IRQ_TABLE_SIZE (CONFIG_NUM_IRQS - CONFIG_GEN_IRQ_START_VECTOR) #ifdef CONFIG_DYNAMIC_INTERRUPTS -void z_isr_install(unsigned int irq, void (*routine)(void *), void *param); +void z_isr_install(unsigned int irq, void (*routine)(const void *), + const void *param); #endif #ifdef __cplusplus diff --git a/include/sys/arch_interface.h b/include/sys/arch_interface.h index 50ce5c8dc7c..7c323fa1ac2 100644 --- a/include/sys/arch_interface.h +++ b/include/sys/arch_interface.h @@ -280,8 +280,8 @@ int arch_irq_is_enabled(unsigned int irq); * @return The vector assigned to this interrupt */ int arch_irq_connect_dynamic(unsigned int irq, unsigned int priority, - void (*routine)(void *parameter), - void *parameter, uint32_t flags); + void (*routine)(const void *parameter), + const void *parameter, uint32_t flags); /** * @def ARCH_IRQ_CONNECT(irq, pri, isr, arg, flags)