8#ifndef ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_
9#define ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_
13#if defined(CONFIG_EXCEPTION_DUMP_HOOK)
28typedef void (*arch_exception_dump_hook_t)(
const char *format, va_list args);
38typedef void (*arch_exception_drain_hook_t)(
bool flush);
40extern arch_exception_dump_hook_t arch_exception_dump_hook;
41extern arch_exception_drain_hook_t arch_exception_drain_hook;
51static inline void arch_exception_set_dump_hook(arch_exception_dump_hook_t dump,
52 arch_exception_drain_hook_t drain)
54 arch_exception_dump_hook = dump;
55 arch_exception_drain_hook = drain;
65static inline void arch_exception_call_drain_hook(
bool flush)
67 if (arch_exception_drain_hook) {
68 arch_exception_drain_hook(flush);
81static inline void arch_exception_call_dump_hook(
const char *format, ...)
85 if (arch_exception_dump_hook) {
86 va_start(args, format);
87 arch_exception_dump_hook(format, args);
92#if defined(CONFIG_EXCEPTION_DUMP_HOOK_ONLY)
93#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__)
94#elif defined(CONFIG_LOG)
95#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
96 LOG_ERR(format, ##__VA_ARGS__)
98#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
99 printk(format "\n", ##__VA_ARGS__)
104#if defined(CONFIG_LOG)
105#define EXCEPTION_DUMP(...) LOG_ERR(__VA_ARGS__)
107#define EXCEPTION_DUMP(format, ...) printk(format "\n", ##__VA_ARGS__)
113#if defined(CONFIG_X86_64)
114#include <zephyr/arch/x86/intel64/exception.h>
115#elif defined(CONFIG_X86)
116#include <zephyr/arch/x86/ia32/exception.h>
117#elif defined(CONFIG_ARM64)
118#include <zephyr/arch/arm64/exception.h>
119#elif defined(CONFIG_ARM)
120#include <zephyr/arch/arm/exception.h>
121#elif defined(CONFIG_ARC)
122#include <zephyr/arch/arc/v2/exception.h>
123#elif defined(CONFIG_RISCV)
124#include <zephyr/arch/riscv/exception.h>
125#elif defined(CONFIG_XTENSA)
126#include <zephyr/arch/xtensa/exception.h>
127#elif defined(CONFIG_MIPS)
128#include <zephyr/arch/mips/exception.h>
129#elif defined(CONFIG_ARCH_POSIX)
130#include <zephyr/arch/posix/exception.h>
131#elif defined(CONFIG_SPARC)
132#include <zephyr/arch/sparc/exception.h>
133#elif defined(CONFIG_RX)
134#include <zephyr/arch/rx/exception.h>