Zephyr API Documentation 4.0.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
24#include <zephyr/arch/arm/irq.h>
29#include <zephyr/arch/arm/nmi.h>
32#if defined(CONFIG_GDBSTUB)
34#endif
35
36#ifdef CONFIG_CPU_CORTEX_M
40#elif defined(CONFIG_CPU_AARCH32_CORTEX_R) || defined(CONFIG_CPU_AARCH32_CORTEX_A)
43#if defined(CONFIG_AARCH32_ARMV8_R)
46#else
48#endif
49#endif
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#ifndef _ASMLANGUAGE
56
57#include <zephyr/fatal_types.h>
58
60 /* Cortex-M MEMFAULT exceptions */
67
68 /* Cortex-M BUSFAULT exceptions */
76
77 /* Cortex-M USAGEFAULT exceptions */
86
87 /* Cortex-M SECURE exceptions */
96
97 /* Cortex-A/R exceptions*/
110
111#endif /* _ASMLANGUAGE */
112
120#ifdef CONFIG_STACK_ALIGN_DOUBLE_WORD
121#define ARCH_STACK_PTR_ALIGN 8
122#else
123#define ARCH_STACK_PTR_ALIGN 4
124#endif
125
135#if defined(CONFIG_USERSPACE)
136#define Z_THREAD_MIN_STACK_ALIGN CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
137#elif defined(CONFIG_ARM_AARCH32_MMU)
138#define Z_THREAD_MIN_STACK_ALIGN CONFIG_ARM_MMU_REGION_MIN_ALIGN_AND_SIZE
139#else
140#define Z_THREAD_MIN_STACK_ALIGN ARCH_STACK_PTR_ALIGN
141#endif
142
190#if defined(CONFIG_MPU_STACK_GUARD)
191/* make sure there's more than enough space for an exception frame */
192#if CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE <= 0x20
193#define MPU_GUARD_ALIGN_AND_SIZE 0x40
194#else
195#define MPU_GUARD_ALIGN_AND_SIZE CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE
196#endif
197#else
198#define MPU_GUARD_ALIGN_AND_SIZE 0
199#endif
200
211#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING) \
212 && defined(CONFIG_MPU_STACK_GUARD)
213#if CONFIG_MPU_STACK_GUARD_MIN_SIZE_FLOAT <= 0x20
214#define MPU_GUARD_ALIGN_AND_SIZE_FLOAT 0x40
215#else
216#define MPU_GUARD_ALIGN_AND_SIZE_FLOAT CONFIG_MPU_STACK_GUARD_MIN_SIZE_FLOAT
217#endif
218#else
219#define MPU_GUARD_ALIGN_AND_SIZE_FLOAT 0
220#endif
221
229#if defined(CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT)
230#define Z_MPU_GUARD_ALIGN (MAX(MPU_GUARD_ALIGN_AND_SIZE, \
231 MPU_GUARD_ALIGN_AND_SIZE_FLOAT))
232#else
233#define Z_MPU_GUARD_ALIGN MPU_GUARD_ALIGN_AND_SIZE
234#endif
235
236#if defined(CONFIG_USERSPACE) && \
237 defined(CONFIG_MPU_REQUIRES_POWER_OF_TWO_ALIGNMENT)
238/* This MPU requires regions to be sized to a power of two, and aligned to
239 * their own size. Since an MPU region must be able to cover the entire
240 * user-accessible stack buffer, we size/align to match. The privilege
241 * mode stack is generated elsewhere in memory.
242 */
243#define ARCH_THREAD_STACK_OBJ_ALIGN(size) Z_POW2_CEIL(size)
244#define ARCH_THREAD_STACK_SIZE_ADJUST(size) Z_POW2_CEIL(size)
245#else
246#define ARCH_THREAD_STACK_OBJ_ALIGN(size) MAX(Z_THREAD_MIN_STACK_ALIGN, \
247 Z_MPU_GUARD_ALIGN)
248#ifdef CONFIG_USERSPACE
249#define ARCH_THREAD_STACK_SIZE_ADJUST(size) \
250 ROUND_UP(size, CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE)
251#endif
252#endif
253
254#ifdef CONFIG_MPU_STACK_GUARD
255/* Kernel-only stacks need an MPU guard region programmed at the beginning of
256 * the stack object, so align the object appropriately.
257 */
258#define ARCH_KERNEL_STACK_RESERVED MPU_GUARD_ALIGN_AND_SIZE
259#define ARCH_KERNEL_STACK_OBJ_ALIGN Z_MPU_GUARD_ALIGN
260#endif
261
262/* On arm, all MPU guards are carve-outs. */
263#define ARCH_THREAD_STACK_RESERVED 0
264
265/* Legacy case: retain containing extern "C" with C++ */
266#ifdef CONFIG_ARM_MPU
267#ifdef CONFIG_CPU_HAS_ARM_MPU
269#endif /* CONFIG_CPU_HAS_ARM_MPU */
270#ifdef CONFIG_CPU_HAS_NXP_MPU
272#endif /* CONFIG_CPU_HAS_NXP_MPU */
273#endif /* CONFIG_ARM_MPU */
274#ifdef CONFIG_ARM_AARCH32_MMU
276#endif /* CONFIG_ARM_AARCH32_MMU */
277
278#ifdef __cplusplus
279}
280#endif
281
282#endif /* ZEPHYR_INCLUDE_ARCH_ARM_ARCH_H_ */
ARM AArch32 public interrupt handling.
Per-arch thread definition.
k_fatal_error_reason_arch
Definition arch.h:59
@ K_ERR_ARM_BUS_FP_LAZY_STATE_PRESERVATION
Definition arch.h:75
@ K_ERR_ARM_MEM_UNSTACKING
Definition arch.h:63
@ K_ERR_ARM_BACKGROUND_FAULT
Definition arch.h:100
@ K_ERR_ARM_UNSUPPORTED_EXCLUSIVE_ACCESS_FAULT
Definition arch.h:108
@ K_ERR_ARM_SYNC_EXTERNAL_ABORT
Definition arch.h:102
@ K_ERR_ARM_SECURE_LAZY_STATE_PRESERVATION
Definition arch.h:94
@ K_ERR_ARM_SECURE_GENERIC
Definition arch.h:88
@ K_ERR_ARM_MEM_STACKING
Definition arch.h:62
@ K_ERR_ARM_SYNC_PARITY_ERROR
Definition arch.h:104
@ K_ERR_ARM_SECURE_ENTRY_POINT
Definition arch.h:89
@ K_ERR_ARM_USAGE_ILLEGAL_EXC_RETURN
Definition arch.h:83
@ K_ERR_ARM_USAGE_NO_COPROCESSOR
Definition arch.h:82
@ K_ERR_ARM_SECURE_INTEGRITY_SIGNATURE
Definition arch.h:90
@ K_ERR_ARM_ASYNC_EXTERNAL_ABORT
Definition arch.h:103
@ K_ERR_ARM_MEM_FP_LAZY_STATE_PRESERVATION
Definition arch.h:66
@ K_ERR_ARM_ALIGNMENT_FAULT
Definition arch.h:99
@ K_ERR_ARM_TRANSLATION_FAULT
Definition arch.h:107
@ K_ERR_ARM_USAGE_UNALIGNED_ACCESS
Definition arch.h:80
@ K_ERR_ARM_USAGE_ILLEGAL_EPSR
Definition arch.h:84
@ K_ERR_ARM_MEM_INSTRUCTION_ACCESS
Definition arch.h:65
@ K_ERR_ARM_SECURE_EXCEPTION_RETURN
Definition arch.h:91
@ K_ERR_ARM_BUS_UNSTACKING
Definition arch.h:71
@ K_ERR_ARM_MEM_GENERIC
Definition arch.h:61
@ K_ERR_ARM_BUS_STACKING
Definition arch.h:70
@ K_ERR_ARM_USAGE_DIV_0
Definition arch.h:79
@ K_ERR_ARM_BUS_GENERIC
Definition arch.h:69
@ K_ERR_ARM_BUS_IMPRECISE_DATA_BUS
Definition arch.h:73
@ K_ERR_ARM_BUS_INSTRUCTION_BUS
Definition arch.h:74
@ K_ERR_ARM_UNDEFINED_INSTRUCTION
Definition arch.h:98
@ K_ERR_ARM_USAGE_UNDEFINED_INSTRUCTION
Definition arch.h:85
@ K_ERR_ARM_ASYNC_PARITY_ERROR
Definition arch.h:105
@ K_ERR_ARM_DEBUG_EVENT
Definition arch.h:106
@ K_ERR_ARM_SECURE_ATTRIBUTION_UNIT
Definition arch.h:92
@ K_ERR_ARM_SECURE_TRANSITION
Definition arch.h:93
@ K_ERR_ARM_SECURE_LAZY_STATE_ERROR
Definition arch.h:95
@ K_ERR_ARM_USAGE_STACK_OVERFLOW
Definition arch.h:81
@ K_ERR_ARM_BUS_PRECISE_DATA_BUS
Definition arch.h:72
@ K_ERR_ARM_MEM_DATA_ACCESS
Definition arch.h:64
@ K_ERR_ARM_PERMISSION_FAULT
Definition arch.h:101
@ K_ERR_ARM_USAGE_GENERIC
Definition arch.h:78
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 AArch32 public error handling.
ARM CORTEX-M memory map.
ARM AArch32 NMI routines.