8#ifndef ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_
9#define ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_
23#if defined(CONFIG_EXCEPTION_DUMP_HOOK)
38typedef void (*arch_exception_dump_hook_t)(
const char *format, va_list args);
48typedef void (*arch_exception_drain_hook_t)(
bool flush);
50extern arch_exception_dump_hook_t arch_exception_dump_hook;
51extern arch_exception_drain_hook_t arch_exception_drain_hook;
61static inline void arch_exception_set_dump_hook(arch_exception_dump_hook_t dump,
62 arch_exception_drain_hook_t drain)
64 arch_exception_dump_hook = dump;
65 arch_exception_drain_hook = drain;
75static inline void arch_exception_call_drain_hook(
bool flush)
77 if (arch_exception_drain_hook) {
78 arch_exception_drain_hook(flush);
91static inline void arch_exception_call_dump_hook(
const char *format, ...)
95 if (arch_exception_dump_hook) {
96 va_start(args, format);
97 arch_exception_dump_hook(format, args);
102#if !defined(CONFIG_EXCEPTION_DUMP)
103#define EXCEPTION_DUMP(format, ...) \
106 arch_exception_dump_arg_check(format, ##__VA_ARGS__); \
109#elif defined(CONFIG_EXCEPTION_DUMP_HOOK_ONLY)
110#define EXCEPTION_DUMP(format, ...) \
113 arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
115#elif defined(CONFIG_LOG)
116#define EXCEPTION_DUMP(format, ...) \
119 arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
120 LOG_ERR(format, ##__VA_ARGS__); \
123#define EXCEPTION_DUMP(format, ...) \
126 arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
127 printk(format "\n", ##__VA_ARGS__); \
133#if !defined(CONFIG_EXCEPTION_DUMP)
134#define EXCEPTION_DUMP(format, ...) \
137 arch_exception_dump_arg_check(format, ##__VA_ARGS__); \
140#elif defined(CONFIG_LOG)
141#define EXCEPTION_DUMP(...) \
144 LOG_ERR(__VA_ARGS__); \
147#define EXCEPTION_DUMP(format, ...) \
150 printk(format "\n", ##__VA_ARGS__); \
157#if defined(CONFIG_X86_64)
158#include <zephyr/arch/x86/intel64/exception.h>
159#elif defined(CONFIG_X86)
160#include <zephyr/arch/x86/ia32/exception.h>
161#elif defined(CONFIG_ARM64)
162#include <zephyr/arch/arm64/exception.h>
163#elif defined(CONFIG_ARM)
164#include <zephyr/arch/arm/exception.h>
165#elif defined(CONFIG_ARC)
166#include <zephyr/arch/arc/v2/exception.h>
167#elif defined(CONFIG_RISCV)
168#include <zephyr/arch/riscv/exception.h>
169#elif defined(CONFIG_XTENSA)
170#include <zephyr/arch/xtensa/exception.h>
171#elif defined(CONFIG_MIPS)
172#include <zephyr/arch/mips/exception.h>
173#elif defined(CONFIG_OPENRISC)
174#include <zephyr/arch/openrisc/exception.h>
175#elif defined(CONFIG_ARCH_POSIX)
176#include <zephyr/arch/posix/exception.h>
177#elif defined(CONFIG_SPARC)
178#include <zephyr/arch/sparc/exception.h>
179#elif defined(CONFIG_RX)
180#include <zephyr/arch/rx/exception.h>
181#elif defined(CONFIG_ARCH_IS_SET)
182#error "The selected architecture is missing from this dispatch header"
static void arch_exception_dump_arg_check(const char *fmt,...)
Dummy function to trigger exception dump argument type checking.
Definition exception.h:18