Rework MPU use option

Make the option positively named, and as it is a platform config
option make sure it only affects platform code.

HAL functions still remain available even if platform is told not
to use them.
pull/9064/head
Kevin Bracey 2018-12-11 12:46:56 +02:00 committed by Cruz Monrreal II
parent 2463596779
commit 81acc28c3f
7 changed files with 15 additions and 13 deletions

View File

@ -20,7 +20,7 @@
#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_6M__ == 1U)) && \
defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) && \
!defined(MBED_MPU_CUSTOM) && !MBED_CONF_PLATFORM_DISABLE_MPU
!defined(MBED_MPU_CUSTOM)
#if !DEVICE_MPU
#error "Device has v7m MPU but it is not enabled. Add 'MPU' to device_has in targets.json"

View File

@ -20,7 +20,7 @@
#if ((__ARM_ARCH_8M_BASE__ == 1U) || (__ARM_ARCH_8M_MAIN__ == 1U)) && \
defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) && \
!defined(MBED_MPU_CUSTOM) && !MBED_CONF_PLATFORM_DISABLE_MPU
!defined(MBED_MPU_CUSTOM)
#if !DEVICE_MPU
#error "Device has v8m MPU but it is not enabled. Add 'MPU' to device_has in targets.json"

View File

@ -26,7 +26,7 @@
extern "C" {
#endif
#if DEVICE_MPU && !MBED_CONF_PLATFORM_DISABLE_MPU
#if DEVICE_MPU
/**
* \defgroup hal_mpu MPU hal

View File

@ -129,9 +129,9 @@
"help": "Setting this to true enables auto-reboot on a fatal error.",
"value": false
},
"disable-mpu": {
"help": "Disable the MPU to save rom.",
"value": false
"use-mpu": {
"help": "Use the MPU if available to fault execution from RAM and writes to ROM. Can be disabled to reduce image size.",
"value": true
}
},
"target_overrides": {

View File

@ -16,12 +16,11 @@
#include "platform/mbed_mpu_mgmt.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_error.h"
#include "platform/mbed_assert.h"
#include "hal/mpu_api.h"
#include <limits.h>
#if DEVICE_MPU && !MBED_CONF_PLATFORM_DISABLE_MPU
#if DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU
static uint16_t mem_xn_lock;
static uint16_t mem_wn_lock;

View File

@ -23,16 +23,17 @@
#ifndef MBED_MPU_MGMT_H
#define MBED_MPU_MGMT_H
#include "hal/sleep_api.h"
#include "mbed_toolchain.h"
#include "hal/ticker_api.h"
#include "hal/mpu_api.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#if DEVICE_MPU && !MBED_CONF_PLATFORM_DISABLE_MPU
#if (DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU) || defined(DOXYGEN_ONLY)
#define mbed_mpu_manager_init() mbed_mpu_init()
/** Lock ram execute never mode off
*
@ -84,6 +85,8 @@ void mbed_mpu_manager_unlock_rom_write(void);
#else
#define mbed_mpu_manager_init() (void)0
#define mbed_mpu_manager_lock_ram_execution() (void)0
#define mbed_mpu_manager_unlock_ram_execution() (void)0

View File

@ -76,7 +76,7 @@
#include "mbed_toolchain.h"
#include "mbed_boot.h"
#include "mbed_error.h"
#include "mpu_api.h"
#include "mbed_mpu_mgmt.h"
int main(void);
static void mbed_cpy_nvic(void);
@ -87,7 +87,7 @@ uint32_t mbed_stack_isr_size = 0;
void mbed_init(void)
{
mbed_mpu_init();
mbed_mpu_manager_init();
mbed_cpy_nvic();
mbed_sdk_init();
mbed_rtos_init();