Skip to content

Commit 3944d83

Browse files
author
Andrew Boie
committed
gen_isr_tables: apply offset to irq parameter
The interrupts would be placed at incorrect offsets on systems where some interrupt vectors are reserved for exceptions, such as ARC. Change-Id: I5b1f00eb9e8aecb84ae66e3d0461a734ffb5fbe6 Signed-off-by: Andrew Boie <[email protected]>
1 parent 5c335ce commit 3944d83

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

arch/common/gen_isr_tables.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def read_intlist(intlist_path):
5858

5959
prefix = endian_prefix()
6060

61-
intlist_header_fmt = prefix + "IIII"
61+
intlist_header_fmt = prefix + "IIIII"
6262
intlist_entry_fmt = prefix + "iiII"
6363

6464
with open(intlist_path, "rb") as fp:
@@ -72,8 +72,9 @@ def read_intlist(intlist_path):
7272

7373
intlist["spurious_handler"] = header[0]
7474
intlist["sw_irq_handler"] = header[1]
75-
intlist["num_isrs"] = header[2]
76-
intlist["num_vectors"] = header[3]
75+
intlist["num_vectors"] = header[2]
76+
intlist["offset"] = header[3]
77+
intlist["num_isrs"] = header[4]
7778

7879
debug("spurious handler: %s" % hex(header[0]))
7980

@@ -148,6 +149,7 @@ def main():
148149

149150
intlist = read_intlist(args.intlist)
150151
nvec = intlist["num_vectors"]
152+
offset = intlist["offset"]
151153
prefix = endian_prefix()
152154

153155
# Set default entries in both tables
@@ -173,14 +175,14 @@ def main():
173175
if (param != 0):
174176
error("Direct irq %d declared, but has non-NULL parameter"
175177
% irq)
176-
vt[irq] = func
178+
vt[irq - offset] = func
177179
else:
178180
# Regular interrupt
179181
if not swt:
180182
error("Regular Interrupt %d declared with parameter 0x%x "
181183
"but no SW ISR_TABLE in use"
182184
% (irq, param))
183-
swt[irq] = (param, func)
185+
swt[irq - offset] = (param, func)
184186

185187
with open(args.output_source, "w") as fp:
186188
write_source_file(fp, vt, swt, intlist)

arch/common/isr_tables.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,26 @@
1515
#define ISR_WRAPPER NULL
1616
#endif
1717

18+
/* There is an additional member at the end populated by the linker script
19+
* which indicates the number of interrupts specified
20+
*/
21+
struct int_list_header {
22+
void *spurious_ptr;
23+
void *handler_ptr;
24+
uint32_t table_size;
25+
uint32_t offset;
26+
};
27+
1828
/* These values are not included in the resulting binary, but instead form the
1929
* header of the initList section, which is used by gen_isr_tables.py to create
2030
* the vector and sw isr tables,
2131
*/
22-
_GENERIC_SECTION(.irq.spurious) void *_irq_spurious_ptr = &_irq_spurious;
23-
_GENERIC_SECTION(.irq.handler) void *_irq_handler_ptr = ISR_WRAPPER;
24-
_GENERIC_SECTION(.irq.tablesize) uint32_t _irq_table_size = IRQ_TABLE_SIZE;
32+
_GENERIC_SECTION(.irq_info) struct int_list_header _iheader = {
33+
.spurious_ptr = &_irq_spurious,
34+
.handler_ptr = ISR_WRAPPER,
35+
.table_size = IRQ_TABLE_SIZE,
36+
.offset = CONFIG_GEN_IRQ_START_VECTOR,
37+
};
2538

2639
/* These are placeholder tables. They will be replaced by the real tables
2740
* generated by gen_isr_tables.py.

include/linker/intlist.ld

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@
4242

4343
SECTION_PROLOGUE(.intList,,)
4444
{
45-
KEEP(*(.irq.spurious))
46-
KEEP(*(.irq.handler))
45+
KEEP(*(.irq_info))
4746
LONG((__INT_LIST_END__ - __INT_LIST_START__) / __ISR_LIST_SIZEOF)
48-
KEEP(*(.irq.tablesize))
4947
__INT_LIST_START__ = .;
5048
KEEP(*(.intList))
5149
__INT_LIST_END__ = .;

0 commit comments

Comments
 (0)