summaryrefslogtreecommitdiffstats
path: root/cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h')
-rw-r--r--cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h110
1 files changed, 92 insertions, 18 deletions
diff --git a/cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h b/cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h
index ea25828bb6..36541a97aa 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/aarch32-pmsa.h
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ * Copyright (C) 2020 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,8 +37,7 @@
#ifndef _RTEMS_SCORE_AARCH32_PMSA_H
#define _RTEMS_SCORE_AARCH32_PMSA_H
-#include <stddef.h>
-#include <stdint.h>
+#include <rtems/score/basedefs.h>
#ifdef __cplusplus
extern "C" {
@@ -64,7 +63,7 @@ extern "C" {
#define AARCH32_PMSA_ATTR_IDX( _idx ) \
( ( _idx ) << AARCH32_PMSA_ATTR_IDX_SHIFT )
-#define AARCH32_PMSA_ATTR_XN 0x6U
+#define AARCH32_PMSA_ATTR_XN 0x40U
#define AARCH32_PMSA_ATTR_AP_SHIFT 7
#define AARCH32_PMSA_ATTR_AP_MASK 0x18U
@@ -99,16 +98,16 @@ extern "C" {
#define AARCH32_PMSA_MEM_OUTER_WA 0x10U
#define AARCH32_PMSA_MEM_INNER_WTT 0x00U
-#define AARCH32_PMSA_MEM_INNER_NC 0x40U
-#define AARCH32_PMSA_MEM_INNER_WBT 0x40U
-#define AARCH32_PMSA_MEM_INNER_WTNT 0x80U
-#define AARCH32_PMSA_MEM_INNER_WBNT 0xc0U
+#define AARCH32_PMSA_MEM_INNER_NC 0x04U
+#define AARCH32_PMSA_MEM_INNER_WBT 0x04U
+#define AARCH32_PMSA_MEM_INNER_WTNT 0x08U
+#define AARCH32_PMSA_MEM_INNER_WBNT 0x0cU
#define AARCH32_PMSA_MEM_INNER_RA 0x02U
#define AARCH32_PMSA_MEM_INNER_WA 0x01U
#define AARCH32_PMSA_MEM_ATTR( _ma0, _ma1, _ma2, _ma3 ) \
- ( ( _ma0 ) | ( ( _ma1 ) << 8 ) | ( ( _ma1 ) << 16 ) | ( ( _ma1 ) << 24 ) )
+ ( ( _ma0 ) | ( ( _ma1 ) << 8 ) | ( ( _ma2 ) << 16 ) | ( ( _ma3 ) << 24 ) )
#define AARCH32_PMSA_MEM_ATTR_DEFAULT_CACHED \
( AARCH32_PMSA_MEM_OUTER_WBNT | \
@@ -141,7 +140,7 @@ extern "C" {
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RO_EL0_NO ) | \
- AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_OUTER ) | \
+ AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 0U ) )
#define AARCH32_PMSA_DATA_READ_ONLY_UNCACHED \
@@ -154,8 +153,8 @@ extern "C" {
#define AARCH32_PMSA_DATA_READ_WRITE_CACHED \
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
- AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO | \
- AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_OUTER ) | \
+ AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
+ AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 0U ) )
#define AARCH32_PMSA_DATA_READ_WRITE_UNCACHED \
@@ -165,6 +164,13 @@ extern "C" {
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 1U ) )
+#define AARCH32_PMSA_DATA_READ_WRITE_SHARED \
+ ( AARCH32_PMSA_ATTR_EN | \
+ AARCH32_PMSA_ATTR_XN | \
+ AARCH32_PMSA_ATTR_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \
+ AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_OUTER ) | \
+ AARCH32_PMSA_ATTR_IDX( 1U ) )
+
#define AARCH32_PMSA_DEVICE \
( AARCH32_PMSA_ATTR_EN | \
AARCH32_PMSA_ATTR_XN | \
@@ -172,6 +178,20 @@ extern "C" {
AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \
AARCH32_PMSA_ATTR_IDX( 2U ) )
+/*
+ * The Cortex-R52 processor is not coherent and the inner shareability domain
+ * consists of an individual Cortex-R52 core. Thus for an SMP configuration,
+ * the read-write data must be configured as Non-cachable and Shareable. The
+ * outer shareability domain is external to the Cortex-R52 processor.
+ */
+#if defined(RTEMS_SMP)
+#define AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
+ AARCH32_PMSA_DATA_READ_WRITE_SHARED
+#else
+#define AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
+ AARCH32_PMSA_DATA_READ_WRITE_CACHED
+#endif
+
/**
* @brief The default section definitions shall be used by the BSP to define
* ::_AArch32_PMSA_Sections.
@@ -187,7 +207,7 @@ extern "C" {
}, { \
.begin = (uint32_t) bsp_section_fast_data_begin, \
.end = (uint32_t) bsp_section_fast_data_end, \
- .attributes = AARCH32_PMSA_DATA_READ_WRITE_CACHED \
+ .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
}, { \
.begin = (uint32_t) bsp_section_start_begin, \
.end = (uint32_t) bsp_section_start_end, \
@@ -207,23 +227,23 @@ extern "C" {
}, { \
.begin = (uint32_t) bsp_section_data_begin, \
.end = (uint32_t) bsp_section_data_end, \
- .attributes = AARCH32_PMSA_DATA_READ_WRITE_CACHED \
+ .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
}, { \
.begin = (uint32_t) bsp_section_bss_begin, \
.end = (uint32_t) bsp_section_bss_end, \
- .attributes = AARCH32_PMSA_DATA_READ_WRITE_CACHED \
+ .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
}, { \
.begin = (uint32_t) bsp_section_rtemsstack_begin, \
.end = (uint32_t) bsp_section_rtemsstack_end, \
- .attributes = AARCH32_PMSA_DATA_READ_WRITE_CACHED \
+ .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
}, { \
.begin = (uint32_t) bsp_section_work_begin, \
.end = (uint32_t) bsp_section_work_end, \
- .attributes = AARCH32_PMSA_DATA_READ_WRITE_CACHED \
+ .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
}, { \
.begin = (uint32_t) bsp_section_stack_begin, \
.end = (uint32_t) bsp_section_stack_end, \
- .attributes = AARCH32_PMSA_DATA_READ_WRITE_CACHED \
+ .attributes = AARCH32_PMSA_DATA_READ_WRITE_DEFAULT \
}, { \
.begin = (uint32_t) bsp_section_nocache_begin, \
.end = (uint32_t) bsp_section_nocache_end, \
@@ -258,6 +278,33 @@ typedef struct {
} AArch32_PMSA_Section;
/**
+ * @brief The region definition is used to configure the Memory Protection
+ * Unit (MPU).
+ *
+ * A region cannot be empty.
+ */
+typedef struct {
+ /**
+ * @brief This member defines the base address of the region.
+ *
+ * The limit address is this the address of the first byte of the region.
+ */
+ uint32_t base;
+
+ /**
+ * @brief This member defines the limit address of the region.
+ *
+ * The limit address is this the address of the last byte of the region.
+ */
+ uint32_t limit;
+
+ /**
+ * @brief This member defines the attributes of the region.
+ */
+ uint32_t attributes;
+} AArch32_PMSA_Region;
+
+/**
* @brief Initializes the Memory Protection Unit (MPU).
*
* The section definitions are used to define the regions of the MPU. Sections
@@ -265,6 +312,8 @@ typedef struct {
* regions are used, then the MPU is not enabled. Overlapping section
* definitions result in undefined system behaviour.
*
+ * The function shall be called while the MPU is disabled.
+ *
* @param memory_attributes_0 are the memory attributes for MAIR0.
*
* @param memory_attributes_1 are the memory attributes for MAIR1.
@@ -281,6 +330,31 @@ void _AArch32_PMSA_Initialize(
);
/**
+ * @brief Maps the section definitions to region definitions.
+ *
+ * The section definitions are used to define the regions of the MPU. Sections
+ * are merged if possible to reduce the count of used regions. If too many
+ * regions are used, then zero is returned. Overlapping section definitions
+ * result in undefined system behaviour.
+ *
+ * @param sections is the array with section definitions to map to regions.
+ *
+ * @param section_count is the count of section definitions.
+ *
+ * @param regions is the array with usable region definitions.
+ *
+ * @param region_max is the count of usable region definitions.
+ *
+ * @return Returns the count of actually used regions.
+ */
+size_t _AArch32_PMSA_Map_sections_to_regions(
+ const AArch32_PMSA_Section *sections,
+ size_t section_count,
+ AArch32_PMSA_Region *regions,
+ size_t region_max
+);
+
+/**
* @brief This array provides section definitions to initialize the memory
* protection unit (MPU).
*