Skip to content

Commit bd69c3b

Browse files
author
Andrew Boie
committed
riscv32: enable gen_isr_tables mechanism
Change-Id: Ia09d9a4d3412424dcbb25db829059a0714d81214 Signed-off-by: Andrew Boie <[email protected]>
1 parent b2e136c commit bd69c3b

File tree

7 files changed

+36
-104
lines changed

7 files changed

+36
-104
lines changed

arch/common/Makefile.gen_isr_tables

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ GEN_ISR_TABLE := $(srctree)/arch/common/gen_isr_tables.py
22
OUTPUT_SRC := isr_tables.c
33
OUTPUT_OBJ := isr_tables.o
44

5-
ifeq ($(ARCH),arm)
6-
OUTPUT_FORMAT := elf32-littlearm
7-
OUTPUT_ARCH := arm
8-
else ifeq ($(ARCH),nios2)
9-
OUTPUT_FORMAT := elf32-littlenios2
10-
OUTPUT_ARCH := nios2
5+
ifeq ($(ARCH),riscv32)
6+
OUTPUT_FORMAT := elf32-littleriscv
117
else
12-
$(error Output formats not defined for this architecture)
8+
OUTPUT_FORMAT := elf32-little$(ARCH)
139
endif
1410

1511
GEN_ISR_TABLE_EXTRA_ARGS :=

arch/riscv32/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ config RISCV_HAS_CPU_IDLE
6363
default n
6464
help
6565
Does SOC has CPU IDLE instruction
66+
67+
config GEN_ISR_TABLES
68+
default y
69+
70+
config GEN_IRQ_VECTOR_TABLE
71+
default n
72+
6673
endmenu
6774

6875
source "arch/riscv32/soc/*/Kconfig"

arch/riscv32/core/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ccflags-y += -I$(srctree)/kernel/unified/include
22
ccflags-y +=-I$(srctree)/arch/$(ARCH)/include
33

4-
obj-y += isr.o reset.o sw_isr_table.o fatal.o irq_manage.o \
4+
obj-y += isr.o reset.o fatal.o irq_manage.o \
55
prep_c.o cpu_idle.o swap.o thread.o irq_offload.o

arch/riscv32/core/sw_isr_table.S

Lines changed: 0 additions & 49 deletions
This file was deleted.

include/arch/riscv32/arch.h

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,14 @@ extern uint32_t __soc_get_irq(void);
5656
void _arch_irq_enable(unsigned int irq);
5757
void _arch_irq_disable(unsigned int irq);
5858
int _arch_irq_is_enabled(unsigned int irq);
59+
void _irq_spurious(void *unused);
5960

6061

6162
/**
6263
* Configure a static interrupt.
6364
*
6465
* All arguments must be computable by the compiler at build time.
6566
*
66-
* Internally this function does a few things:
67-
*
68-
* 1. The enum statement has no effect but forces the compiler to only
69-
* accept constant values for the irq_p parameter, very important as the
70-
* numerical IRQ line is used to create a named section.
71-
*
72-
* 2. An instance of struct _isr_table_entry is created containing the ISR and
73-
* its parameter. If you look at how _sw_isr_table is created, each entry in
74-
* the array is in its own section named by the IRQ line number. What we are
75-
* doing here is to override one of the default entries (which points to the
76-
* spurious IRQ handler) with what was supplied here.
77-
*
78-
* 3. interrupt priority is not supported by pulpino core
79-
*
8067
* @param irq_p IRQ line number
8168
* @param priority_p Interrupt priority
8269
* @param isr_p Interrupt service routine
@@ -87,11 +74,7 @@ int _arch_irq_is_enabled(unsigned int irq);
8774
*/
8875
#define _ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
8976
({ \
90-
enum { IRQ = irq_p }; \
91-
static struct _isr_table_entry _CONCAT(_isr_irq, irq_p) \
92-
__attribute__ ((used)) \
93-
__attribute__ ((section(STRINGIFY(_CONCAT(.gnu.linkonce.isr_irq, irq_p))))) = \
94-
{isr_param_p, isr_p}; \
77+
_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
9578
irq_p; \
9679
})
9780

include/arch/riscv32/common/linker.ld

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ MEMORY
3737
{
3838
ROM (rx) : ORIGIN = CONFIG_RISCV_ROM_BASE_ADDR, LENGTH = CONFIG_RISCV_ROM_SIZE
3939
RAM (rwx) : ORIGIN = CONFIG_RISCV_RAM_BASE_ADDR, LENGTH = RISCV_RAM_SIZE
40+
/* Used by and documented in include/linker/intlist.ld */
41+
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
4042
}
4143

4244
SECTIONS
@@ -69,20 +71,11 @@ SECTIONS
6971
SECTION_PROLOGUE(_TEXT_SECTION_NAME,,)
7072
{
7173
. = ALIGN(4);
72-
73-
KEEP(*(.isr_irq*))
74-
75-
/* sections for IRQ0-9 */
76-
KEEP(*(SORT(.gnu.linkonce.isr_irq[0-9])))
77-
78-
/* sections for IRQ10-99 */
79-
KEEP(*(SORT(.gnu.linkonce.isr_irq[0-9][0-9])))
80-
81-
/* sections for IRQ100-999 */
82-
KEEP(*(SORT(.gnu.linkonce.isr_irq[0-9][0-9][0-9])))
83-
84-
KEEP(*(.openocd_debug))
85-
KEEP(*(".openocd_debug.*"))
74+
#ifdef CONFIG_GEN_SW_ISR_TABLE
75+
KEEP(*(SW_ISR_TABLE))
76+
#endif
77+
KEEP(*(.openocd_debug))
78+
KEEP(*(".openocd_debug.*"))
8679

8780
_image_text_start = .;
8881
*(.text)
@@ -160,5 +153,9 @@ SECTIONS
160153
_image_ram_end = .;
161154
_end = .; /* end of image */
162155

156+
#ifdef CONFIG_GEN_ISR_TABLES
157+
#include <linker/intlist.ld>
158+
#endif
159+
163160
GROUP_END(RAMABLE_REGION)
164161
}

include/arch/riscv32/pulpino/linker.ld

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ MEMORY
3333
{
3434
INSTRRAM (wx) : ORIGIN = CONFIG_ITCM_BASE_ADDRESS, LENGTH = CONFIG_ITCM_SIZE
3535
DATARAM (rw) : ORIGIN = CONFIG_DTCM_BASE_ADDRESS, LENGTH = CONFIG_DTCM_SIZE
36+
/* Used by and documented in include/linker/intlist.ld */
37+
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
3638
}
3739

3840
SECTIONS
@@ -80,9 +82,12 @@ SECTIONS
8082
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,)
8183
{
8284
. = ALIGN(4);
83-
*(.rodata)
84-
*(".rodata.*")
85-
*(.gnu.linkonce.r.*)
85+
#ifdef CONFIG_GEN_SW_ISR_TABLE
86+
KEEP(*(SW_ISR_TABLE))
87+
#endif
88+
*(.rodata)
89+
*(".rodata.*")
90+
*(.gnu.linkonce.r.*)
8691
} GROUP_LINK_IN(RAMABLE_REGION)
8792

8893
#include <linker/common-ram.ld>
@@ -91,17 +96,6 @@ SECTIONS
9196
{
9297

9398
. = ALIGN(4);
94-
KEEP(*(.isr_irq*))
95-
96-
/* sections for IRQ0-9 */
97-
KEEP(*(SORT(.gnu.linkonce.isr_irq[0-9])))
98-
99-
/* sections for IRQ10-99 */
100-
KEEP(*(SORT(.gnu.linkonce.isr_irq[0-9][0-9])))
101-
102-
/* sections for IRQ100-999 */
103-
KEEP(*(SORT(.gnu.linkonce.isr_irq[0-9][0-9][0-9])))
104-
10599
*(.data)
106100
*(".data.*")
107101

@@ -142,5 +136,9 @@ SECTIONS
142136

143137
_end = .; /* end of image */
144138

139+
#ifdef CONFIG_GEN_ISR_TABLES
140+
#include <linker/intlist.ld>
141+
#endif
142+
145143
GROUP_END(RAMABLE_REGION)
146144
}

0 commit comments

Comments
 (0)