Zephyr API Documentation 4.4.99
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#ifndef _ASMLANGUAGE
12
13#if defined(CONFIG_EXCEPTION_DUMP_HOOK)
14
15#include <stdbool.h>
16#include <stdarg.h>
17
28typedef void (*arch_exception_dump_hook_t)(const char *format, va_list args);
29
38typedef void (*arch_exception_drain_hook_t)(bool flush);
39
40extern arch_exception_dump_hook_t arch_exception_dump_hook;
41extern arch_exception_drain_hook_t arch_exception_drain_hook;
42
51static inline void arch_exception_set_dump_hook(arch_exception_dump_hook_t dump,
52 arch_exception_drain_hook_t drain)
53{
54 arch_exception_dump_hook = dump;
55 arch_exception_drain_hook = drain;
56}
57
65static inline void arch_exception_call_drain_hook(bool flush)
66{
67 if (arch_exception_drain_hook) {
68 arch_exception_drain_hook(flush);
69 }
70}
71
81static inline void arch_exception_call_dump_hook(const char *format, ...)
82{
83 va_list args;
84
85 if (arch_exception_dump_hook) {
86 va_start(args, format);
87 arch_exception_dump_hook(format, args);
88 va_end(args);
89 }
90}
91
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__)
97#else
98#define EXCEPTION_DUMP(format, ...) arch_exception_call_dump_hook(format "\n", ##__VA_ARGS__); \
99 printk(format "\n", ##__VA_ARGS__)
100#endif
101
102#else
103
104#if defined(CONFIG_LOG)
105#define EXCEPTION_DUMP(...) LOG_ERR(__VA_ARGS__)
106#else
107#define EXCEPTION_DUMP(format, ...) printk(format "\n", ##__VA_ARGS__)
108#endif
109#endif
110
111#endif /* _ASMLANGUAGE */
112
113#if defined(CONFIG_X86_64)
115#elif defined(CONFIG_X86)
117#elif defined(CONFIG_ARM64)
119#elif defined(CONFIG_ARM)
121#elif defined(CONFIG_ARC)
123#elif defined(CONFIG_RISCV)
125#elif defined(CONFIG_XTENSA)
127#elif defined(CONFIG_MIPS)
129#elif defined(CONFIG_ARCH_POSIX)
131#elif defined(CONFIG_SPARC)
133#elif defined(CONFIG_RX)
135#endif
136
137#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.