Skip to content

Commit 513e6ed

Browse files
keith-packardkartben
authored andcommitted
arch/common: Mark interrupt tables const when !DYNAMIC_INTERRUPTS
When not using dynamic interrupt mapping, various interrupt tables are configured to be stored in read-only memory in the linker script.. Mark them const so that the linker doesn't complain. This affects _sw_isr_table, _irq_vector_table, and z_shared_sw_isr_table in arch/common along with _VectorTable in arch/arc. Signed-off-by: Keith Packard <keithp@keithp.com>
1 parent 5890c73 commit 513e6ed

File tree

21 files changed

+94
-56
lines changed

21 files changed

+94
-56
lines changed

arch/arc/core/vector_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct vector_table {
4747
uintptr_t unused_2;
4848
};
4949

50-
struct vector_table _VectorTable Z_GENERIC_SECTION(.exc_vector_table) = {
50+
const struct vector_table _VectorTable Z_GENERIC_SECTION(.exc_vector_table) = {
5151
(uintptr_t)__reset,
5252
(uintptr_t)__memory_error,
5353
(uintptr_t)__instruction_error,

arch/arm/core/cortex_a_r/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static inline void z_arm_irq_dynamic_direct_isr_dispatch(void)
132132
uint32_t irq = __get_IPSR() - 16;
133133

134134
if (irq < IRQ_TABLE_SIZE) {
135-
struct _isr_table_entry *isr_entry = &_sw_isr_table[irq];
135+
const struct _isr_table_entry *isr_entry = &_sw_isr_table[irq];
136136

137137
isr_entry->isr(isr_entry->arg);
138138
}

arch/arm/core/cortex_m/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static inline void z_arm_irq_dynamic_direct_isr_dispatch(void)
256256
uint32_t irq = __get_IPSR() - 16;
257257

258258
if (irq < IRQ_TABLE_SIZE) {
259-
struct _isr_table_entry *isr_entry = &_sw_isr_table[irq];
259+
const struct _isr_table_entry *isr_entry = &_sw_isr_table[irq];
260260

261261
isr_entry->isr(isr_entry->arg);
262262
}

arch/arm/core/cortex_m/isr_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void _isr_wrapper(void)
7676
*/
7777
irq_number -= 16;
7878

79-
struct _isr_table_entry *entry = &_sw_isr_table[irq_number];
79+
const struct _isr_table_entry *entry = &_sw_isr_table[irq_number];
8080
(entry->isr)(entry->arg);
8181

8282
#if defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER)

arch/common/isr_tables.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void __irq_vector_table __attribute__((naked)) _irq_vector_table(void) {
7878
#else
7979

8080
/* The IRQ vector table is an array of vector addresses */
81-
uintptr_t __irq_vector_table _irq_vector_table[IRQ_TABLE_SIZE] = {
81+
const uintptr_t __irq_vector_table _irq_vector_table[IRQ_TABLE_SIZE] = {
8282
[0 ...(IRQ_TABLE_SIZE - 1)] = (uintptr_t)&IRQ_VECTOR_TABLE_DEFAULT_ISR,
8383
};
8484
#endif /* CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_CODE */
@@ -88,13 +88,19 @@ uintptr_t __irq_vector_table _irq_vector_table[IRQ_TABLE_SIZE] = {
8888
* type and bypass the _sw_isr_table, then do not generate one.
8989
*/
9090
#ifdef CONFIG_GEN_SW_ISR_TABLE
91+
#ifndef CONFIG_DYNAMIC_INTERRUPTS
92+
const
93+
#endif
9194
struct _isr_table_entry __sw_isr_table _sw_isr_table[IRQ_TABLE_SIZE] = {
9295
[0 ...(IRQ_TABLE_SIZE - 1)] = {(const void *)0x42,
9396
&z_irq_spurious},
9497
};
9598
#endif
9699

97100
#ifdef CONFIG_SHARED_INTERRUPTS
101+
#ifndef CONFIG_DYNAMIC_INTERRUPTS
102+
const
103+
#endif
98104
struct z_shared_isr_table_entry __shared_sw_isr_table z_shared_sw_isr_table[IRQ_TABLE_SIZE] = {
99105
};
100106
#endif

arch/common/isr_tables_shell.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#include <zephyr/shell/shell.h>
99
#include <zephyr/sw_isr_table.h>
1010

11-
static void dump_isr_table_entry(const struct shell *sh, int idx, struct _isr_table_entry *entry)
11+
static void dump_isr_table_entry(const struct shell *sh, int idx,
12+
const struct _isr_table_entry *entry)
1213
{
1314

1415
if ((entry->isr == z_irq_spurious) || (entry->isr == NULL)) {

arch/mips/core/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void z_mips_enter_irq(uint32_t ipending)
7070

7171
while (ipending) {
7272
int index;
73-
struct _isr_table_entry *ite;
73+
const struct _isr_table_entry *ite;
7474

7575
if (IS_ENABLED(CONFIG_TRACING_ISR)) {
7676
sys_trace_isr_enter();

drivers/interrupt_controller/intc_dw_ace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static void dwint_isr(const void *arg)
150150
while (fs) {
151151
uint32_t bit = find_lsb_set(fs) - 1;
152152
uint32_t offset = CONFIG_2ND_LVL_ISR_TBL_OFFSET + bit;
153-
struct _isr_table_entry *ent = &_sw_isr_table[offset];
153+
const struct _isr_table_entry *ent = &_sw_isr_table[offset];
154154

155155
fs &= ~BIT(bit);
156156
ent->isr(ent->arg);

drivers/interrupt_controller/intc_plic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct plic_config {
9393
uint32_t nr_irqs;
9494
uint32_t irq;
9595
riscv_plic_irq_config_func_t irq_config_func;
96-
struct _isr_table_entry *isr_table;
96+
const struct _isr_table_entry *isr_table;
9797
const uint32_t *const hart_context;
9898
};
9999

@@ -490,7 +490,7 @@ static void plic_irq_handler(const struct device *dev)
490490
{
491491
const struct plic_config *config = dev->config;
492492
mem_addr_t claim_complete_addr = get_claim_complete_addr(dev);
493-
struct _isr_table_entry *ite;
493+
const struct _isr_table_entry *ite;
494494
uint32_t cpu_id = arch_curr_cpu()->id;
495495
/* Get the IRQ number generating the interrupt */
496496
const uint32_t local_irq = sys_read32(claim_complete_addr);

drivers/interrupt_controller/intc_rv32m1_intmux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct rv32m1_intmux_config {
4343
INTMUX_Type *regs;
4444
const struct device *clock_dev;
4545
clock_control_subsys_t clock_subsys;
46-
struct _isr_table_entry *isr_base;
46+
const struct _isr_table_entry *isr_base;
4747
};
4848

4949
#define DEV_REGS(dev) (((const struct rv32m1_intmux_config *)(dev->config))->regs)
@@ -112,8 +112,8 @@ static void rv32m1_intmux_isr(const void *arg)
112112
INTMUX_Type *regs = DEV_REGS(dev);
113113
uint32_t channel = POINTER_TO_UINT(arg);
114114
uint32_t line = (regs->CHANNEL[channel].CHn_VEC >> 2);
115-
struct _isr_table_entry *isr_base = config->isr_base;
116-
struct _isr_table_entry *entry;
115+
const struct _isr_table_entry *isr_base = config->isr_base;
116+
const struct _isr_table_entry *entry;
117117

118118
/*
119119
* Make sure the vector is valid, there is a note of page 1243~1244

0 commit comments

Comments
 (0)