Rework MPU layout for future changes

Create a dedicated MPU directory for standard Arm MPU implementations
in preparation for the Arm v8m MPU. Replace MBED_MPU_ENABLED with
DEVICE_MPU to align with the porting layer of other HAL APIs.
pull/8871/head
Russ Butler 2018-11-01 16:37:47 -05:00 committed by Martin Kojtal
parent c0ff98614a
commit d00f59fdc8
3 changed files with 23 additions and 25 deletions

View File

@ -23,8 +23,7 @@
#include "mpu_api.h"
// Define included by mpu_api.h
#if !MBED_MPU_ENABLED
#if !DEVICE_MPU
#error [NOT_SUPPORTED] MPU API not supported for this target
#endif

View File

@ -16,6 +16,13 @@
#include "hal/mpu_api.h"
#include "cmsis.h"
#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_6M__ == 1U)) && \
defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
#if !DEVICE_MPU
#error "Device has v7m MPU but it is not enabled. Add 'MPU' to device_has in targets.json"
#endif
void mbed_mpu_init()
{
mbed_mpu_enable_ram_xn(false);
@ -28,7 +35,6 @@ void mbed_mpu_free()
void mbed_mpu_enable_ram_xn(bool enable)
{
#if MBED_MPU_ENABLED
// Flush memory writes before configuring the MPU.
__DSB();
@ -145,5 +151,6 @@ void mbed_mpu_enable_ram_xn(bool enable)
// Ensure changes take effect
__ISB();
__DSB();
#endif
}
#endif

View File

@ -19,33 +19,15 @@
#ifndef MBED_MPU_API_H
#define MBED_MPU_API_H
#include "device.h"
#include <stdbool.h>
#include "cmsis.h"
#ifndef MBED_MPU_ENABLED
#if ((__ARM_ARCH_7M__ == 1U) || \
(__ARM_ARCH_7EM__ == 1U) || \
(__ARM_ARCH_6M__ == 1U))
#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U)
#define MBED_MPU_ENABLED 1U
#else
#define MBED_MPU_ENABLED 0U
#endif
#elif ((__ARM_ARCH_7A__ == 1U) || \
(__ARM_ARCH_8M_BASE__ == 1U) || \
(__ARM_ARCH_8M_MAIN__ == 1U))
#define MBED_MPU_ENABLED 0U
#else
#error "Unknown architecture for MPU"
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if DEVICE_MPU
/**
* Initialize the MPU
*
@ -71,6 +53,16 @@ void mbed_mpu_enable_ram_xn(bool enable);
*/
void mbed_mpu_free(void);
#else
#define mbed_mpu_init()
#define mbed_mpu_enable_ram_xn(enable) (void)enable
#define mbed_mpu_free()
#endif
#ifdef __cplusplus
}
#endif