Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
exception.h
Go to the documentation of this file.
1/* exception.h - automatically selects the correct exception.h file to include */
2
3/*
4 * Copyright (c) 2024 Meta Platforms
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_
9#define ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_
10
11#if defined(CONFIG_EXCEPTION_DUMP_HOOK)
12
13#include <stdbool.h>
14#include <stdarg.h>
15
26typedef void (*arch_exception_dump_hook_t)(const char *format, va_list args);
27
36typedef void (*arch_exception_drain_hook_t)(bool flush);
37
38extern arch_exception_dump_hook_t arch_exception_dump_hook;
39extern arch_exception_drain_hook_t arch_exception_drain_hook;
40
49static inline void arch_exception_set_dump_hook(arch_exception_dump_hook_t dump,
50 arch_exception_drain_hook_t drain)
51{
52 arch_exception_dump_hook = dump;
53 arch_exception_drain_hook = drain;
54}
55
63static inline void arch_exception_call_drain_hook(bool flush)
64{
65 if (arch_exception_drain_hook) {
66 arch_exception_drain_hook(flush);
67 }
68}
69
79static inline void arch_exception_call_dump_hook(const char *format, ...)
80{
81 va_list args;
82
83 if (arch_exception_dump_hook) {
84 va_start(args, format);
85 arch_exception_dump_hook(format, args);
86 va_end(args);
87 }
88}
89
90#if defined(CONFIG_EXCEPTION_DUMP_HOOK_ONLY)
91#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__)
92#elif defined(CONFIG_LOG)
93#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
94 LOG_ERR(format, ##__VA_ARGS__)
95#else
96#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
97 printk(format "\n", ##__VA_ARGS__)
98#endif
99
100#else
101
102#if defined(CONFIG_LOG)
103#define EXCEPTION_DUMP(...) LOG_ERR(__VA_ARGS__)
104#else
105#define EXCEPTION_DUMP(format, ...) printk(format "\n", ##__VA_ARGS__)
106#endif
107#endif
108
109#if defined(CONFIG_X86_64)
111#elif defined(CONFIG_X86)
113#elif defined(CONFIG_ARM64)
115#elif defined(CONFIG_ARM)
117#elif defined(CONFIG_ARC)
119#elif defined(CONFIG_RISCV)
121#elif defined(CONFIG_XTENSA)
123#elif defined(CONFIG_MIPS)
125#elif defined(CONFIG_ARCH_POSIX)
127#elif defined(CONFIG_SPARC)
129#elif defined(CONFIG_RX)
131#endif
132
133#endif /* ZEPHYR_INCLUDE_ARCH_EXCEPTION_H_ */
ARCv2 public exception handling.
Cortex-A public exception handling.
ARM AArch32 public exception handling.
RISCV public exception handling.
Xtensa public exception handling.