Skip to content

Commit 581e537

Browse files
Jordan Yatescarlescufi
authored andcommitted
fatal: move enum definition to dedicated header
This allows enum values to be referenced in architecture `arch.h` files without circular dependencies. Signed-off-by: Jordan Yates <[email protected]>
1 parent d363781 commit 581e537

File tree

2 files changed

+52
-21
lines changed

2 files changed

+52
-21
lines changed

include/zephyr/fatal.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <zephyr/arch/cpu.h>
1515
#include <zephyr/toolchain.h>
16+
#include <zephyr/fatal_types.h>
1617

1718
#ifdef __cplusplus
1819
extern "C" {
@@ -24,27 +25,6 @@ extern "C" {
2425
* @{
2526
*/
2627

27-
enum k_fatal_error_reason {
28-
/** Generic CPU exception, not covered by other codes */
29-
K_ERR_CPU_EXCEPTION,
30-
31-
/** Unhandled hardware interrupt */
32-
K_ERR_SPURIOUS_IRQ,
33-
34-
/** Faulting context overflowed its stack buffer */
35-
K_ERR_STACK_CHK_FAIL,
36-
37-
/** Moderate severity software error */
38-
K_ERR_KERNEL_OOPS,
39-
40-
/** High severity software error */
41-
K_ERR_KERNEL_PANIC
42-
43-
/* TODO: add more codes for exception types that are common across
44-
* architectures
45-
*/
46-
};
47-
4828
/**
4929
* @brief Halt the system on a fatal error
5030
*

include/zephyr/fatal_types.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2023 CSIRO.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/** @file
8+
* @brief Fatal base type definitions
9+
*/
10+
11+
#ifndef ZEPHYR_INCLUDE_FATAL_TYPES_H
12+
#define ZEPHYR_INCLUDE_FATAL_TYPES_H
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
/**
19+
* @defgroup fatal_types Fatal error base types
20+
* @ingroup fatal_apis
21+
* @{
22+
*/
23+
24+
enum k_fatal_error_reason {
25+
/** Generic CPU exception, not covered by other codes */
26+
K_ERR_CPU_EXCEPTION,
27+
28+
/** Unhandled hardware interrupt */
29+
K_ERR_SPURIOUS_IRQ,
30+
31+
/** Faulting context overflowed its stack buffer */
32+
K_ERR_STACK_CHK_FAIL,
33+
34+
/** Moderate severity software error */
35+
K_ERR_KERNEL_OOPS,
36+
37+
/** High severity software error */
38+
K_ERR_KERNEL_PANIC,
39+
40+
/* TODO: add more codes for exception types that are common across
41+
* architectures
42+
*/
43+
};
44+
45+
/** @} */
46+
47+
#ifdef __cplusplus
48+
}
49+
#endif
50+
51+
#endif /* ZEPHYR_INCLUDE_FATAL_TYPES_H */

0 commit comments

Comments
 (0)