Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
error.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2014 Wind River Systems, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
15#ifndef ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_ERROR_H_
16#define ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_ERROR_H_
17
20#include <stdbool.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
27/* ARMv6 will hard-fault if SVC is called with interrupts locked. Just
28 * force them unlocked, the thread is in an undefined state anyway
29 *
30 * On ARMv7m we won't get a HardFault, but if interrupts were locked the
31 * thread will continue executing after the exception and forbid PendSV to
32 * schedule a new thread until they are unlocked which is not what we want.
33 * Force them unlocked as well.
34 */
35#define ARCH_EXCEPT(reason_p) \
36register uint32_t r0 __asm__("r0") = reason_p; \
37do { \
38 __asm__ volatile ( \
39 "cpsie i\n\t" \
40 "svc %[id]\n\t" \
41 : \
42 : "r" (r0), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
43 : "memory"); \
44} while (false)
45#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
46#define ARCH_EXCEPT(reason_p) do { \
47 __asm__ volatile ( \
48 "eors.n r0, r0\n\t" \
49 "msr BASEPRI, r0\n\t" \
50 "mov r0, %[reason]\n\t" \
51 "svc %[id]\n\t" \
52 : \
53 : [reason] "i" (reason_p), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
54 : "memory"); \
55} while (false)
56#elif defined(CONFIG_ARMV7_R)
57/*
58 * In order to support using svc for an exception while running in an
59 * isr, stack $lr_svc before calling svc. While exiting the isr,
60 * z_check_stack_sentinel is called. $lr_svc contains the return address.
61 * If the sentinel is wrong, it calls svc to cause an oops. This svc
62 * call will overwrite $lr_svc, losing the return address from the
63 * z_check_stack_sentinel call if it is not stacked before the svc.
64 */
65#define ARCH_EXCEPT(reason_p) \
66register uint32_t r0 __asm__("r0") = reason_p; \
67do { \
68 __asm__ volatile ( \
69 "push {lr}\n\t" \
70 "cpsie i\n\t" \
71 "svc %[id]\n\t" \
72 "pop {lr}\n\t" \
73 : \
74 : "r" (r0), [id] "i" (_SVC_CALL_RUNTIME_EXCEPT) \
75 : "memory"); \
76} while (false)
77#else
78#error Unknown ARM architecture
79#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif /* ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_ERROR_H_ */
ARM AArch32 specific syscall header.
ARM AArch32 public exception handling.