Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arch.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
16#ifndef ZEPHYR_INCLUDE_ARCH_ARM_ARCH_H_
17#define ZEPHYR_INCLUDE_ARCH_ARM_ARCH_H_
18
19/* Add include for DTS generated information */
20#include <zephyr/devicetree.h>
21
22/* ARM GPRs are often designated by two different names */
23#define sys_define_gpr_with_alias(name1, name2) union { uint32_t name1, name2; }
24
27#include <zephyr/arch/arm/irq.h>
32#include <zephyr/arch/arm/nmi.h>
35#if defined(CONFIG_GDBSTUB)
37#endif
38
39#ifdef CONFIG_CPU_CORTEX_M
43#elif defined(CONFIG_CPU_AARCH32_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
46#if defined(CONFIG_AARCH32_ARMV8_R)
49#else
51#endif
52#endif
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#ifndef _ASMLANGUAGE
59
60#include <zephyr/fatal_types.h>
61
63 /* Cortex-M MEMFAULT exceptions */
70
71 /* Cortex-M BUSFAULT exceptions */
79
80 /* Cortex-M USAGEFAULT exceptions */
89
90 /* Cortex-M SECURE exceptions */
99
100 /* Cortex-A/R exceptions*/
113
114#endif /* _ASMLANGUAGE */
115
123#ifdef CONFIG_STACK_ALIGN_DOUBLE_WORD
124#define ARCH_STACK_PTR_ALIGN 8
125#else
126#define ARCH_STACK_PTR_ALIGN 4
127#endif
128
138#if defined(CONFIG_USERSPACE)
139#define Z_THREAD_MIN_STACK_ALIGN CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
140#elif defined(CONFIG_ARM_AARCH32_MMU)
141#define Z_THREAD_MIN_STACK_ALIGN CONFIG_ARM_MMU_REGION_MIN_ALIGN_AND_SIZE
142#else
143#define Z_THREAD_MIN_STACK_ALIGN ARCH_STACK_PTR_ALIGN
144#endif
145
193#if defined(CONFIG_MPU_STACK_GUARD)
194/* make sure there's more than enough space for an exception frame */
195#if CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE <= 0x20
196#define MPU_GUARD_ALIGN_AND_SIZE 0x40
197#else
198#define MPU_GUARD_ALIGN_AND_SIZE CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
199#endif
200#else
201#define MPU_GUARD_ALIGN_AND_SIZE 0
202#endif
203
214#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING) \
215 && defined(CONFIG_MPU_STACK_GUARD)
216#if CONFIG_MPU_STACK_GUARD_MIN_SIZE_FLOAT <= 0x20
217#define MPU_GUARD_ALIGN_AND_SIZE_FLOAT 0x40
218#else
219#define MPU_GUARD_ALIGN_AND_SIZE_FLOAT CONFIG_MPU_STACK_GUARD_MIN_SIZE_FLOAT
220#endif
221#else
222#define MPU_GUARD_ALIGN_AND_SIZE_FLOAT 0
223#endif
224
232#if defined(CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT)
233#define Z_MPU_GUARD_ALIGN (MAX(MPU_GUARD_ALIGN_AND_SIZE, \
234 MPU_GUARD_ALIGN_AND_SIZE_FLOAT))
235#else
236#define Z_MPU_GUARD_ALIGN MPU_GUARD_ALIGN_AND_SIZE
237#endif
238
239#if defined(CONFIG_USERSPACE) && \
240 defined(CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT)
241/* This MPU requires regions to be sized to a power of two, and aligned to
242 * their own size. Since an MPU region must be able to cover the entire
243 * user-accessible stack buffer, we size/align to match. The privilege
244 * mode stack is generated elsewhere in memory.
245 */
246#define ARCH_THREAD_STACK_OBJ_ALIGN(size) Z_POW2_CEIL(size)
247#define ARCH_THREAD_STACK_SIZE_ADJUST(size) Z_POW2_CEIL(size)
248#else
249#define ARCH_THREAD_STACK_OBJ_ALIGN(size) MAX(Z_THREAD_MIN_STACK_ALIGN, \
250 Z_MPU_GUARD_ALIGN)
251#ifdef CONFIG_USERSPACE
252#define ARCH_THREAD_STACK_SIZE_ADJUST(size) \
253 ROUND_UP(size, CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE)
254#endif
255#endif
256
257#ifdef CONFIG_MPU_STACK_GUARD
258/* Kernel-only stacks need an MPU guard region programmed at the beginning of
259 * the stack object, so align the object appropriately.
260 */
261#define ARCH_KERNEL_STACK_RESERVED MPU_GUARD_ALIGN_AND_SIZE
262#define ARCH_KERNEL_STACK_OBJ_ALIGN Z_MPU_GUARD_ALIGN
263#endif
264
265/* On arm, all MPU guards are carve-outs. */
266#define ARCH_THREAD_STACK_RESERVED 0
267
268/* Legacy case: retain containing extern "C" with C++ */
269#ifdef CONFIG_ARM_MPU
270#ifdef CONFIG_CPU_HAS_ARM_MPU
272#endif /* CONFIG_CPU_HAS_ARM_MPU */
273#ifdef CONFIG_CPU_HAS_NXP_MPU
275#endif /* CONFIG_CPU_HAS_NXP_MPU */
276#endif /* CONFIG_ARM_MPU */
277#ifdef CONFIG_ARM_AARCH32_MMU
279#endif /* CONFIG_ARM_AARCH32_MMU */
280
281#ifdef __cplusplus
282}
283#endif
284
285#endif /* ZEPHYR_INCLUDE_ARCH_ARM_ARCH_H_ */
ARM AArch32 public interrupt handling.
Per-arch thread definition.
k_fatal_error_reason_arch
Definition: arch.h:62
@ K_ERR_ARM_BUS_FP_LAZY_STATE_PRESERVATION
Definition: arch.h:78
@ K_ERR_ARM_MEM_UNSTACKING
Definition: arch.h:66
@ K_ERR_ARM_BACKGROUND_FAULT
Definition: arch.h:103
@ K_ERR_ARM_UNSUPPORTED_EXCLUSIVE_ACCESS_FAULT
Definition: arch.h:111
@ K_ERR_ARM_SYNC_EXTERNAL_ABORT
Definition: arch.h:105
@ K_ERR_ARM_SECURE_LAZY_STATE_PRESERVATION
Definition: arch.h:97
@ K_ERR_ARM_SECURE_GENERIC
Definition: arch.h:91
@ K_ERR_ARM_MEM_STACKING
Definition: arch.h:65
@ K_ERR_ARM_SYNC_PARITY_ERROR
Definition: arch.h:107
@ K_ERR_ARM_SECURE_ENTRY_POINT
Definition: arch.h:92
@ K_ERR_ARM_USAGE_ILLEGAL_EXC_RETURN
Definition: arch.h:86
@ K_ERR_ARM_USAGE_NO_COPROCESSOR
Definition: arch.h:85
@ K_ERR_ARM_SECURE_INTEGRITY_SIGNATURE
Definition: arch.h:93
@ K_ERR_ARM_ASYNC_EXTERNAL_ABORT
Definition: arch.h:106
@ K_ERR_ARM_MEM_FP_LAZY_STATE_PRESERVATION
Definition: arch.h:69
@ K_ERR_ARM_ALIGNMENT_FAULT
Definition: arch.h:102
@ K_ERR_ARM_TRANSLATION_FAULT
Definition: arch.h:110
@ K_ERR_ARM_USAGE_UNALIGNED_ACCESS
Definition: arch.h:83
@ K_ERR_ARM_USAGE_ILLEGAL_EPSR
Definition: arch.h:87
@ K_ERR_ARM_MEM_INSTRUCTION_ACCESS
Definition: arch.h:68
@ K_ERR_ARM_SECURE_EXCEPTION_RETURN
Definition: arch.h:94
@ K_ERR_ARM_BUS_UNSTACKING
Definition: arch.h:74
@ K_ERR_ARM_MEM_GENERIC
Definition: arch.h:64
@ K_ERR_ARM_BUS_STACKING
Definition: arch.h:73
@ K_ERR_ARM_USAGE_DIV_0
Definition: arch.h:82
@ K_ERR_ARM_BUS_GENERIC
Definition: arch.h:72
@ K_ERR_ARM_BUS_IMPRECISE_DATA_BUS
Definition: arch.h:76
@ K_ERR_ARM_BUS_INSTRUCTION_BUS
Definition: arch.h:77
@ K_ERR_ARM_UNDEFINED_INSTRUCTION
Definition: arch.h:101
@ K_ERR_ARM_USAGE_UNDEFINED_INSTRUCTION
Definition: arch.h:88
@ K_ERR_ARM_ASYNC_PARITY_ERROR
Definition: arch.h:108
@ K_ERR_ARM_DEBUG_EVENT
Definition: arch.h:109
@ K_ERR_ARM_SECURE_ATTRIBUTION_UNIT
Definition: arch.h:95
@ K_ERR_ARM_SECURE_TRANSITION
Definition: arch.h:96
@ K_ERR_ARM_SECURE_LAZY_STATE_ERROR
Definition: arch.h:98
@ K_ERR_ARM_USAGE_STACK_OVERFLOW
Definition: arch.h:84
@ K_ERR_ARM_BUS_PRECISE_DATA_BUS
Definition: arch.h:75
@ K_ERR_ARM_MEM_DATA_ACCESS
Definition: arch.h:67
@ K_ERR_ARM_PERMISSION_FAULT
Definition: arch.h:104
@ K_ERR_ARM_USAGE_GENERIC
Definition: arch.h:81
ARM AArch32 public error handling.
ARM AArch32 public exception handling.
ARM AArch32 public kernel miscellaneous.
Devicetree main header.
Fatal base type definitions.
@ K_ERR_ARCH_START
Arch specific fatal errors.
Definition: fatal_types.h:41
ARM CORTEX-M memory map.
ARM AArch32 NMI routines.