Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arm_mpu.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Linaro Limited.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef ZEPHYR_INCLUDE_ARCH_ARM_MPU_ARM_MPU_H_
7#define ZEPHYR_INCLUDE_ARCH_ARM_MPU_ARM_MPU_H_
8
9#if defined(CONFIG_ARMV8_M_MAINLINE) || defined(CONFIG_ARMV8_M_BASELINE) || \
10 defined(CONFIG_AARCH32_ARMV8_R)
11/* PMSAv8 MPU */
12#define Z_ARM_CPU_HAS_PMSAV8_MPU 1
14#else
15/* PMSAv6 / PMSAv7 (MPU is identical) */
16#define Z_ARM_CPU_HAS_PMSAV8_MPU 0
18#endif
19
20#if defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE) || defined(CONFIG_ARMV8_M_MAINLINE)
21#define Z_ARM_MPU_MAX_REGIONS 16U
22#else
23#define Z_ARM_MPU_MAX_REGIONS 8U
24#endif
25
26
27#ifndef _ASMLANGUAGE
28#include <stdint.h>
29
30/* Region definition data structure */
32 /* Region Base Address */
34 /* Region Name */
35 const char *name;
36#if defined(CONFIG_CPU_AARCH32_CORTEX_R)
37 /* Region Size */
38 uint32_t size;
39#endif
40 /* Region Attributes */
42};
43
44/* MPU configuration data structure */
46 /* Number of regions */
48 /* Regions */
50};
51
52#if defined(CONFIG_ARMV7_R)
53#define MPU_REGION_ENTRY(_name, _base, _size, _attr) \
54 { \
55 .name = _name, \
56 .base = _base, \
57 .size = _size, \
58 .attr = _attr, \
59 }
60#else
61#define MPU_REGION_ENTRY(_name, _base, _attr) \
62 { \
63 .name = _name, \
64 .base = _base, \
65 .attr = _attr, \
66 }
67#endif
68
69/* Reference to the MPU configuration.
70 *
71 * This struct is defined and populated for each SoC (in the SoC definition),
72 * and holds the build-time configuration information for the fixed MPU
73 * regions enabled during kernel initialization. Dynamic MPU regions (e.g.
74 * for Thread Stack, Stack Guards, etc.) are programmed during runtime, thus,
75 * not kept here.
76 */
77extern const struct arm_mpu_config mpu_config;
78
79#if defined(CONFIG_CPU_CORTEX_M)
90struct z_mpu_context_retained {
91 uint32_t rbar[Z_ARM_MPU_MAX_REGIONS];
92 uint32_t rasr_rlar[Z_ARM_MPU_MAX_REGIONS];
93#if Z_ARM_CPU_HAS_PMSAV8_MPU
94 uint32_t mair[2];
95#endif
96 uint32_t ctrl;
97 uint32_t num_valid_regions;
98};
99
105void z_arm_save_mpu_context(struct z_mpu_context_retained *ctx);
106
112void z_arm_restore_mpu_context(const struct z_mpu_context_retained *ctx);
113
114#endif /* CONFIG_CPU_CORTEX_M */
115#endif /* _ASMLANGUAGE */
116
117#endif /* ZEPHYR_INCLUDE_ARCH_ARM_MPU_ARM_MPU_H_ */
struct arc_mpu_config mpu_config
struct arm_mpu_region_attr arm_mpu_region_attr_t
Definition arm_mpu_v7m.h:152
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Definition arm_mpu.h:45
uint32_t num_regions
Definition arm_mpu.h:47
const struct arm_mpu_region * mpu_regions
Definition arm_mpu.h:49
Definition arm_mpu.h:31
uint32_t base
Definition arm_mpu.h:33
const char * name
Definition arm_mpu.h:35
arm_mpu_region_attr_t attr
Definition arm_mpu.h:41