Zephyr API Documentation
4.4.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013-2014 Wind River Systems, Inc.
3
* Copyright 2023, 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
4
*
5
* SPDX-License-Identifier: Apache-2.0
6
*/
7
16
#ifndef ZEPHYR_INCLUDE_ARCH_ARM_ERROR_H_
17
#define ZEPHYR_INCLUDE_ARCH_ARM_ERROR_H_
18
19
#include <
zephyr/arch/arm/syscall.h
>
20
#include <
zephyr/arch/exception.h
>
21
#include <
stdbool.h
>
22
23
#ifdef __cplusplus
24
extern
"C"
{
25
#endif
26
27
#if defined(CONFIG_CPU_ARM9)
28
#elif defined(CONFIG_CPU_CORTEX_M)
29
/* ARMv6 will hard-fault if SVC is called with interrupts locked. Just
30
* force them unlocked, the thread is in an undefined state anyway
31
*
32
* On ARMv7m we won't get a HardFault, but if interrupts were locked the
33
* thread will continue executing after the exception and forbid PendSV to
34
* schedule a new thread until they are unlocked which is not what we want.
35
* Force them unlocked as well.
36
*/
37
#define ARCH_EXCEPT(reason_p) \
38
do {\
39
arch_irq_unlock(0); \
40
__asm__ volatile( \
41
"mov r0, %[_reason]\n" \
42
"svc %[id]\n" \
43
IF_ENABLED(CONFIG_ARM_BTI, ("bti\n")) \
44
:: [_reason] "r" (reason_p), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
45
: "r0", "memory"); \
46
} while (false)
47
#elif defined(CONFIG_ARMV7_R) || defined(CONFIG_AARCH32_ARMV8_R) \
48
|| defined(CONFIG_ARMV7_A)
49
/*
50
* In order to support using svc for an exception while running in an
51
* isr, stack $lr_svc before calling svc. While exiting the isr,
52
* z_check_stack_sentinel is called. $lr_svc contains the return address.
53
* If the sentinel is wrong, it calls svc to cause an oops. This svc
54
* call will overwrite $lr_svc, losing the return address from the
55
* z_check_stack_sentinel call if it is not stacked before the svc.
56
*/
57
#define ARCH_EXCEPT(reason_p) \
58
do { \
59
register uint32_t r0 __asm__("r0") = reason_p; \
60
__asm__ volatile ( \
61
"push {lr}\n\t" \
62
"cpsie i\n\t" \
63
"svc %[id]\n\t" \
64
IF_ENABLED(CONFIG_ARM_BTI, ("bti\n\t")) \
65
"pop {lr}\n\t" \
66
: \
67
: "r" (r0), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
68
: "memory"); \
69
} while (false)
70
#else
71
#error Unknown ARM architecture
72
#endif
/* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
73
74
#ifdef __cplusplus
75
}
76
#endif
77
78
#endif
/* ZEPHYR_INCLUDE_ARCH_ARM_ERROR_H_ */
syscall.h
ARM AArch32 specific syscall header.
exception.h
stdbool.h
zephyr
arch
arm
error.h
Generated on Mon Aug 3 2026 10:12:00 for Zephyr API Documentation by
1.9.8