isr_tables: Simplify how the sw_irq_handler function is used

This is a migration from using code generation to using the C language
which we in the general case we should aways strive towards.

It is equivalent to the simplification that was done with
_irq_spurious here:
https://github.com/zephyrproject-rtos/zephyr/pull/7574

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2018-05-16 14:08:47 +02:00 committed by Anas Nashif
commit aed0b6c4bd
3 changed files with 18 additions and 22 deletions

View file

@ -45,7 +45,6 @@ def read_intlist(intlist_path):
include/linker/intlist.ld:
struct {
void * sw_irq_handler;
u32_t num_isrs;
u32_t num_vectors; <- typically CONFIG_NUM_IRQS
struct _isr_list isrs[]; <- of size num_isrs
@ -70,7 +69,7 @@ def read_intlist(intlist_path):
prefix = endian_prefix()
intlist_header_fmt = prefix + "IIII"
intlist_header_fmt = prefix + "III"
intlist_entry_fmt = prefix + "iiII"
with open(intlist_path, "rb") as fp:
@ -82,10 +81,9 @@ def read_intlist(intlist_path):
debug(str(header))
intlist["sw_irq_handler"] = header[0]
intlist["num_vectors"] = header[1]
intlist["offset"] = header[2]
intlist["num_isrs"] = header[3]
intlist["num_vectors"] = header[0]
intlist["offset"] = header[1]
intlist["num_isrs"] = header[2]
intlist["interrupts"] = [i for i in
struct.iter_unpack(intlist_entry_fmt, intdata)]
@ -133,6 +131,12 @@ source_header = """
#include <sw_isr_table.h>
#include <arch/cpu.h>
#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_GEN_IRQ_VECTOR_TABLE)
#define ISR_WRAPPER ((u32_t)&_isr_wrapper)
#else
#define ISR_WRAPPER NULL
#endif
"""
def write_source_file(fp, vt, swt, intlist):
@ -143,7 +147,7 @@ def write_source_file(fp, vt, swt, intlist):
if vt:
fp.write("u32_t __irq_vector_table _irq_vector_table[%d] = {\n" % nv)
for i in range(nv):
fp.write("\t0x%x,\n" % vt[i])
fp.write("\t{},\n".format(vt[i]))
fp.write("};\n")
if not swt:
@ -212,6 +216,7 @@ def main():
numisrs = intlist["num_isrs"]
spurious_handler = "&_irq_spurious"
sw_irq_handler = "ISR_WRAPPER"
debug('offset is ' + str(offset))
debug('num_vectors is ' + str(nvec))
@ -222,7 +227,7 @@ def main():
# All vectors just jump to the common sw_irq_handler. If some entries
# are used for direct interrupts, they will be replaced later.
if args.vector_table:
vt = [intlist["sw_irq_handler"] for i in range(nvec)]
vt = [sw_irq_handler for i in range(nvec)]
else:
vt = None
# Default to spurious interrupt handler. Configured interrupts

View file

@ -9,17 +9,10 @@
#include <sw_isr_table.h>
#include <arch/cpu.h>
#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_GEN_IRQ_VECTOR_TABLE)
#define ISR_WRAPPER (&_isr_wrapper)
#else
#define ISR_WRAPPER NULL
#endif
/* There is an additional member at the end populated by the linker script
* which indicates the number of interrupts specified
*/
struct int_list_header {
void *handler_ptr;
u32_t table_size;
u32_t offset;
};
@ -29,7 +22,6 @@ struct int_list_header {
* the vector and sw isr tables,
*/
_GENERIC_SECTION(.irq_info) struct int_list_header _iheader = {
.handler_ptr = ISR_WRAPPER,
.table_size = IRQ_TABLE_SIZE,
.offset = CONFIG_GEN_IRQ_START_VECTOR,
};
@ -37,10 +29,10 @@ _GENERIC_SECTION(.irq_info) struct int_list_header _iheader = {
/* These are placeholder tables. They will be replaced by the real tables
* generated by gen_isr_tables.py.
*
* _irq_spurious is used as a placeholder to ensure that _irq_spurious
* is not optimized out in the first link. The first link must contain
* the same symbols as the second one for the isr_tables generation to
* work.
* _irq_spurious and _isr_wrapper are used as placeholder values to
* ensure that they are not optimized out in the first link. The first
* link must contain the same symbols as the second one for the code
* generation to work.
*/
/* Some arches don't use a vector table, they have a common exception entry
@ -48,7 +40,7 @@ _GENERIC_SECTION(.irq_info) struct int_list_header _iheader = {
*/
#ifdef CONFIG_GEN_IRQ_VECTOR_TABLE
u32_t __irq_vector_table _irq_vector_table[IRQ_TABLE_SIZE] = {
[0 ...(IRQ_TABLE_SIZE - 1)] = 0xabababab,
[0 ...(IRQ_TABLE_SIZE - 1)] = (u32_t)&_isr_wrapper,
};
#endif

View file

@ -10,7 +10,6 @@
* What we create here is a data structure:
*
* struct {
* void *sw_irq_handler;
* u32_t num_isrs;
* u32_t num_vectors;
* struct _isr_list isrs[]; <- of size num_isrs