arch/xtensa: Automatically generate interrupt handlers (finally)

The script to generate the _soc_inthandlers.h header has been run
manually for years, only because I was a cmake novice at the time and
unsure how to integrate it into the build.  So every new platform has
to find the script and template file and figure out how to generate
the file.  And in a few cases it looks like we've tried to EDIT the
resulting files in the tree.

Let's finally do this right.  The file is now dropped (for every
xtensa platform) as a "xtensa_handlers.h" file, and there is a Kconfig
to control whether the original/manual file or the new one is used by
the platform code.  We can migrate the other platforms slowly as
people have time to validate.

Signed-off-by: Andy Ross <andyross@google.com>
This commit is contained in:
Andy Ross 2023-07-31 08:34:28 -07:00 committed by Anas Nashif
commit 6ab7735774
3 changed files with 35 additions and 1 deletions

View file

@ -22,6 +22,16 @@ config XTENSA_RESET_VECTOR
This is always needed for the simulator. Real boards may already
implement this in boot ROM.
config XTENSA_GEN_HANDLERS
bool "Automatically generate interrupt handlers"
default n
help
When set, an "xtensa_handlers.h" file is generated
containing definitions for the interrupt entry code of the
target Xtensa core, based automatically on the details in
the core-isa.h file. This replaces the previous scheme
where a _soc_inthandlers.h file would be generated offline.
config XTENSA_USE_CORE_CRT1
bool "Use crt1.S from core"
default y

View file

@ -84,3 +84,22 @@ add_custom_target(zsr_h DEPENDS ${ZSR_H})
add_dependencies(zephyr_interface zsr_h)
unset(MAY_NEED_SYSCALL_SCRATCH_REG)
# Similar: auto-generate interrupt handlers
set(HANDLERS ${CMAKE_BINARY_DIR}/zephyr/include/generated/xtensa_handlers)
add_custom_command(
OUTPUT ${HANDLERS}_tmp.c
COMMAND ${CMAKE_C_COMPILER} -E -U__XCC__
-I${ZEPHYR_XTENSA_MODULE_DIR}/zephyr/soc/${CONFIG_SOC}
-o ${HANDLERS}_tmp.c
- < ${CMAKE_CURRENT_SOURCE_DIR}/xtensa_intgen.tmpl)
add_custom_command(
OUTPUT ${HANDLERS}.h
DEPENDS ${HANDLERS}_tmp.c
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/xtensa_intgen.py
${HANDLERS}_tmp.c > ${HANDLERS}.h)
add_custom_target(xtensa_handlers_h DEPENDS ${HANDLERS}.h)
add_dependencies(zephyr_interface xtensa_handlers_h)

View file

@ -10,13 +10,18 @@
#include <zephyr/kernel_structs.h>
#include <kernel_internal.h>
#include <kswap.h>
#include <_soc_inthandlers.h>
#include <zephyr/toolchain.h>
#include <zephyr/logging/log.h>
#include <offsets.h>
#include <zsr.h>
#include <zephyr/arch/common/exc_handle.h>
#ifdef CONFIG_XTENSA_GEN_HANDLERS
#include <xtensa_handlers.h>
#else
#include <_soc_inthandlers.h>
#endif
#include <xtensa_internal.h>
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);