diff options
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.h | 94 |
1 files changed, 84 insertions, 10 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 a12bf994f1..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" { @@ -154,7 +153,7 @@ 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_AP( AARCH32_PMSA_ATTR_AP_EL1_RW_EL0_NO ) | \ AARCH32_PMSA_ATTR_SH( AARCH32_PMSA_ATTR_SH_NO ) | \ AARCH32_PMSA_ATTR_IDX( 0U ) ) @@ -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). * |