mirror of https://github.com/ARMmbed/mbed-os.git
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
parent
c0ff98614a
commit
d00f59fdc8
|
|
@ -23,8 +23,7 @@
|
||||||
|
|
||||||
#include "mpu_api.h"
|
#include "mpu_api.h"
|
||||||
|
|
||||||
// Define included by mpu_api.h
|
#if !DEVICE_MPU
|
||||||
#if !MBED_MPU_ENABLED
|
|
||||||
#error [NOT_SUPPORTED] MPU API not supported for this target
|
#error [NOT_SUPPORTED] MPU API not supported for this target
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,13 @@
|
||||||
#include "hal/mpu_api.h"
|
#include "hal/mpu_api.h"
|
||||||
#include "cmsis.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()
|
void mbed_mpu_init()
|
||||||
{
|
{
|
||||||
mbed_mpu_enable_ram_xn(false);
|
mbed_mpu_enable_ram_xn(false);
|
||||||
|
|
@ -28,7 +35,6 @@ void mbed_mpu_free()
|
||||||
|
|
||||||
void mbed_mpu_enable_ram_xn(bool enable)
|
void mbed_mpu_enable_ram_xn(bool enable)
|
||||||
{
|
{
|
||||||
#if MBED_MPU_ENABLED
|
|
||||||
// Flush memory writes before configuring the MPU.
|
// Flush memory writes before configuring the MPU.
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
||||||
|
|
@ -145,5 +151,6 @@ void mbed_mpu_enable_ram_xn(bool enable)
|
||||||
// Ensure changes take effect
|
// Ensure changes take effect
|
||||||
__ISB();
|
__ISB();
|
||||||
__DSB();
|
__DSB();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -19,33 +19,15 @@
|
||||||
#ifndef MBED_MPU_API_H
|
#ifndef MBED_MPU_API_H
|
||||||
#define MBED_MPU_API_H
|
#define MBED_MPU_API_H
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
#include <stdbool.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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if DEVICE_MPU
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the MPU
|
* Initialize the MPU
|
||||||
*
|
*
|
||||||
|
|
@ -71,6 +53,16 @@ void mbed_mpu_enable_ram_xn(bool enable);
|
||||||
*/
|
*/
|
||||||
void mbed_mpu_free(void);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue