cpukit/arm/pmsa: Add ability to find empty MPU regions

This commit is contained in:
Kinsey Moore
2024-11-01 15:12:02 -05:00
parent a506c7f713
commit c4625d8d86

View File

@@ -38,6 +38,7 @@
#define _RTEMS_SCORE_ARMV7_PMSA_H
#include <rtems/score/aarch32-system-registers.h>
#include <rtems/score/assert.h>
#include <rtems/score/cpu.h>
#ifdef __cplusplus
@@ -371,6 +372,32 @@ ARMV7_PMSA_TEXT_SECTION static inline uint32_t _ARMV7_PMSA_Find_region(
return UINT32_MAX;
}
ARMV7_PMSA_TEXT_SECTION
static inline bool _ARMV7_PMSA_Is_region_enabled(uint32_t index)
{
_Assert(index < _ARMV7_PMSA_Get_max_regions());
_ARMV7_Write_rgnr(ARMV7_RGNR_REGION(index));
_ARM_Instruction_synchronization_barrier();
return (_ARMV7_Read_drsr() & ARMV7_RSR_EN) != 0;
}
ARMV7_PMSA_TEXT_SECTION
static inline uint32_t _ARMV7_PMSA_Find_available_region(void)
{
uint32_t region_count = _ARMV7_PMSA_Get_max_regions();
uint32_t index;
for (index = 0; index < region_count; index++) {
if (!_ARMV7_PMSA_Is_region_enabled(index)) {
return index;
}
}
return UINT32_MAX;
}
/** @} */
#ifdef __cplusplus