From bb4cb774a24c84b2cfe89b554585321e4099bb71 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Mon, 10 Dec 2018 14:22:56 +0200 Subject: [PATCH] Exclude MPU manager code if MPU disabled Save around 400 bytes from images using FlashIAP by omitting MPU manager reference counting if DEVICE_MPU is 0. --- platform/mbed_mpu_mgmt.c | 4 ++++ platform/mbed_mpu_mgmt.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/platform/mbed_mpu_mgmt.c b/platform/mbed_mpu_mgmt.c index fa8bc545cc..fdc98ab1b2 100644 --- a/platform/mbed_mpu_mgmt.c +++ b/platform/mbed_mpu_mgmt.c @@ -20,6 +20,8 @@ #include "hal/mpu_api.h" #include +#if DEVICE_MPU + static uint16_t mem_xn_lock; static uint16_t mem_wn_lock; @@ -78,3 +80,5 @@ void mbed_mpu_manager_unlock_rom_write() } core_util_critical_section_exit(); } + +#endif diff --git a/platform/mbed_mpu_mgmt.h b/platform/mbed_mpu_mgmt.h index 7af043f586..8b1e422f58 100644 --- a/platform/mbed_mpu_mgmt.h +++ b/platform/mbed_mpu_mgmt.h @@ -32,6 +32,8 @@ extern "C" { #endif +#if DEVICE_MPU + /** Lock ram execute never mode off * * This disables the MPU's execute never ram protection and allows @@ -80,6 +82,18 @@ void mbed_mpu_manager_lock_rom_write(void); */ void mbed_mpu_manager_unlock_rom_write(void); +#else + +#define mbed_mpu_manager_lock_ram_execution() (void)0 + +#define mbed_mpu_manager_unlock_ram_execution() (void)0 + +#define mbed_mpu_manager_lock_rom_write() (void)0 + +#define mbed_mpu_manager_unlock_rom_write() (void)0 + +#endif + #ifdef __cplusplus } #endif