Skip to content

Commit 35fcb27

Browse files
author
Andrew Boie
committed
arc: enable gen_isr_tables mechanism
Change-Id: I5897e110f554377796bfe38dd5c0f8652c29e5be Signed-off-by: Andrew Boie <[email protected]>
1 parent 3944d83 commit 35fcb27

File tree

10 files changed

+56
-212
lines changed

10 files changed

+56
-212
lines changed

arch/arc/Kconfig

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ config XIP
144144
default n if NSIM
145145
default y
146146

147+
config GEN_ISR_TABLES
148+
default y
149+
150+
config GEN_IRQ_START_VECTOR
151+
default 16
152+
147153
config HARVARD
148154
prompt "Harvard Architecture"
149155
bool
@@ -208,46 +214,6 @@ config FLASH_BASE_ADDRESS
208214
normally set by the board's defconfig file and the user should generally
209215
avoid modifying it via the menu configuration.
210216

211-
config SW_ISR_TABLE
212-
bool
213-
prompt "Enable software interrupt handler table"
214-
default y
215-
help
216-
Enable an interrupt handler table implemented in software. This
217-
table, unlike ISRs connected directly in the vector table, allow
218-
a parameter to be passed to the interrupt handlers. Also, invoking
219-
the exeception/interrupt exit stub is automatically done.
220-
221-
config IRQ_VECTOR_TABLE_CUSTOM
222-
bool
223-
prompt "Projects provide a custom static IRQ part of vector table"
224-
depends on !SW_ISR_TABLE
225-
default n
226-
help
227-
Projects, not the BSP, provide the IRQ part of the vector table.
228-
229-
This is the table of interrupt handlers with the best potential
230-
performance, but is the less flexible.
231-
232-
The ISRs are installed directly in the vector table, thus are
233-
directly called by the CPU when an interrupt is taken. This adds
234-
the least overhead when handling an interrupt.
235-
236-
Downsides:
237-
238-
- ISRs cannot have a parameter
239-
- ISRs cannot be connected at runtime
240-
- ISRs must notify the kernel manually by invoking _ExcExit() when
241-
then are about to return.
242-
243-
config IRQ_VECTOR_TABLE_BSP
244-
bool
245-
# omit prompt to signify a "hidden" option
246-
depends on SW_ISR_TABLE || !IRQ_VECTOR_TABLE_CUSTOM
247-
default y
248-
help
249-
Not user-selectable, helps build system logic.
250-
251217
config CACHE_LINE_SIZE_DETECT
252218
bool
253219
prompt "Detect d-cache line size at runtime"

arch/arc/core/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ obj-$(CONFIG_IRQ_OFFLOAD) += irq_offload.o
1616
# Some ARC cores like the EM4 lack the atomic LLOCK/SCOND and
1717
# can't use these.
1818
obj-$(CONFIG_ATOMIC_OPERATIONS_CUSTOM) += atomic.o
19-
obj-$(CONFIG_IRQ_VECTOR_TABLE_BSP) += irq_vector_table.o
20-
obj-$(CONFIG_SW_ISR_TABLE) += sw_isr_table.o

arch/arc/core/fast_irq.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ SECTION_FUNC(TEXT, _firq_enter)
7272
* If CONFIG_RGF_NUM_BANKS>1, firq uses a 2nd register bank so GPRs do
7373
* not need to be saved.
7474
* If CONFIG_RGF_NUM_BANKS==1, firq must use the stack to save registers.
75-
* This has already been done by _isr_enter.
75+
* This has already been done by _isr_wrapper.
7676
*/
7777

7878
#ifdef CONFIG_ARC_STACK_CHECKING

arch/arc/core/irq_vector_table.c

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

arch/arc/core/isr_wrapper.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <kernel_structs.h>
2121
#include <arch/cpu.h>
2222

23-
GTEXT(_isr_enter)
23+
GTEXT(_isr_wrapper)
2424
GTEXT(_isr_demux)
2525

2626
#if CONFIG_RGF_NUM_BANKS == 1
@@ -41,9 +41,9 @@ _rirq_enter/_firq_enter: they are jump points.
4141

4242
The flow is the following:
4343

44-
ISR -> _isr_enter -- + -> _rirq_enter -> _isr_demux -> ISR -> _rirq_exit
45-
|
46-
+ -> _firq_enter -> _isr_demux -> ISR -> _firq_exit
44+
ISR -> _isr_wrapper -- + -> _rirq_enter -> _isr_demux -> ISR -> _rirq_exit
45+
|
46+
+ -> _firq_enter -> _isr_demux -> ISR -> _firq_exit
4747

4848
Context switch explanation:
4949

@@ -216,7 +216,7 @@ From RIRQ:
216216
interrupt.
217217
*/
218218

219-
SECTION_FUNC(TEXT, _isr_enter)
219+
SECTION_FUNC(TEXT, _isr_wrapper)
220220
#if CONFIG_RGF_NUM_BANKS == 1
221221
st r0,[saved_r0]
222222
#endif

arch/arc/core/sw_isr_table.S

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

doc/porting/arch.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ parameter.
134134
executing. A common interrupt handler demuxer is installed for all entries of
135135
the real interrupt vector table, which then fetches the device's ISR and
136136
parameter from the separate table. This approach is commonly used in the ARC
137-
and ARM architectures via the :option:`CONFIG_SW_ISR_TABLE` implementation.
137+
and ARM architectures via the :option:`CONFIG_GEN_ISR_TABLES` implementation.
138138
You can find examples of the stubs by looking at :code:`_interrupt_enter()` in
139139
x86, :code:`_IntExit()` in ARM, :code:`_isr_wrapper()` in ARM, or the full
140140
implementation description for ARC in :file:`arch/arc/core/isr_wrapper.S`.

include/arch/arc/arch.h

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -43,53 +43,4 @@ extern "C" {
4343
#ifdef __cplusplus
4444
}
4545
#endif
46-
47-
#ifndef _ASMLANGUAGE
48-
#include <irq.h>
49-
50-
/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
51-
extern void _irq_priority_set(unsigned int irq, unsigned int prio,
52-
uint32_t flags);
53-
54-
/**
55-
* Configure a static interrupt.
56-
*
57-
* All arguments must be computable by the compiler at build time.
58-
*
59-
* Internally this function does a few things:
60-
*
61-
* 1. The enum statement has no effect but forces the compiler to only
62-
* accept constant values for the irq_p parameter, very important as the
63-
* numerical IRQ line is used to create a named section.
64-
*
65-
* 2. An instance of struct _isr_table_entry is created containing the ISR and
66-
* its parameter. If you look at how _sw_isr_table is created, each entry in
67-
* the array is in its own section named by the IRQ line number. What we are
68-
* doing here is to override one of the default entries (which points to the
69-
* spurious IRQ handler) with what was supplied here.
70-
*
71-
* 3. The priority level for the interrupt is configured by a call to
72-
* _irq_priority_set()
73-
*
74-
* @param irq_p IRQ line number
75-
* @param priority_p Interrupt priority, in range 0-13
76-
* @param isr_p Interrupt service routine
77-
* @param isr_param_p ISR parameter
78-
* @param flags_p IRQ options (ignored for now)
79-
*
80-
* @return The vector assigned to this interrupt
81-
*/
82-
#define _ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
83-
({ \
84-
enum { IRQ = irq_p }; \
85-
static struct _isr_table_entry _CONCAT(_isr_irq, irq_p) \
86-
__attribute__ ((used)) \
87-
__attribute__ ((section(STRINGIFY(_CONCAT(.gnu.linkonce.isr_irq, irq_p))))) = \
88-
{isr_param_p, isr_p}; \
89-
_irq_priority_set(irq_p, priority_p, flags_p); \
90-
irq_p; \
91-
})
92-
93-
#endif
94-
9546
#endif /* _ARC_ARCH__H_ */

include/arch/arc/v2/irq.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <toolchain/common.h>
1919
#include <irq.h>
2020
#include <misc/util.h>
21+
#include <sw_isr_table.h>
2122

2223
#ifdef __cplusplus
2324
extern "C" {
@@ -33,6 +34,40 @@ extern void _arch_irq_enable(unsigned int irq);
3334
extern void _arch_irq_disable(unsigned int irq);
3435

3536
extern void _irq_exit(void);
37+
extern void _irq_priority_set(unsigned int irq, unsigned int prio,
38+
uint32_t flags);
39+
extern void _isr_wrapper(void);
40+
extern void _irq_spurious(void *unused);
41+
42+
/**
43+
* Configure a static interrupt.
44+
*
45+
* All arguments must be computable by the compiler at build time.
46+
*
47+
* _ISR_DECLARE will populate the .intList section with the interrupt's
48+
* parameters, which will then be used by gen_irq_tables.py to create
49+
* the vector table and the software ISR table. This is all done at
50+
* build-time.
51+
*
52+
* We additionally set the priority in the interrupt controller at
53+
* runtime.
54+
*
55+
* @param irq_p IRQ line number
56+
* @param priority_p Interrupt priority
57+
* @param isr_p Interrupt service routine
58+
* @param isr_param_p ISR parameter
59+
* @param flags_p IRQ options
60+
*
61+
* @return The vector assigned to this interrupt
62+
*/
63+
#define _ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
64+
({ \
65+
_ISR_DECLARE(irq_p, 0, isr_p, isr_param_p); \
66+
_irq_priority_set(irq_p, priority_p, flags_p); \
67+
irq_p; \
68+
})
69+
70+
3671

3772
/**
3873
*

include/arch/arc/v2/linker.ld

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ MEMORY {
5757
#ifdef DCCM_START
5858
DCCM (rw) : ORIGIN = DCCM_START, LENGTH = DCCM_SIZE*1k
5959
#endif
60+
/* Used by and documented in include/linker/intlist.ld */
61+
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
6062
}
6163

6264
SECTIONS {
@@ -72,25 +74,9 @@ SECTIONS {
7274
KEEP(*(".exc_vector_table.*"))
7375
KEEP(*(IRQ_VECTOR_TABLE))
7476

75-
KEEP(*(.isr_irq*))
76-
77-
/*
78-
* The following sections maps the location of the different
79-
* rows for the _sw_isr_table. Each row maps to an IRQ entry
80-
* (handler, argument).
81-
*
82-
* In ARC architecture, IRQ 0-15 are reserved for the system
83-
* and are not * assignable by the user, for that reason the
84-
* linker sections start on IRQ 16
85-
*/
86-
87-
/* sections for IRQ16-19 */
88-
KEEP(*(SORT(.gnu.linkonce.isr_irq[1][6-9])))
89-
/* sections for IRQ20-99 */
90-
KEEP(*(SORT(.gnu.linkonce.isr_irq[2-9][0-9])))
91-
/* sections for IRQ100-999 */
92-
KEEP(*(SORT(.gnu.linkonce.isr_irq[1-9][0-9][0-9])))
93-
77+
#ifdef CONFIG_GEN_SW_ISR_TABLE
78+
KEEP(*(SW_ISR_TABLE))
79+
#endif
9480
*(.text)
9581
*(".text.*")
9682
*(.gnu.linkonce.t.*)
@@ -189,4 +175,7 @@ SECTIONS {
189175
#include <custom-sections.ld>
190176
#endif
191177

178+
#ifdef CONFIG_GEN_ISR_TABLES
179+
#include <linker/intlist.ld>
180+
#endif
192181
}

0 commit comments

Comments
 (0)