Skip to content

Commit bb4cb77

Browse files
kjbraceyCruz Monrreal II
authored andcommitted
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.
1 parent 784c80f commit bb4cb77

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

platform/mbed_mpu_mgmt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "hal/mpu_api.h"
2121
#include <limits.h>
2222

23+
#if DEVICE_MPU
24+
2325
static uint16_t mem_xn_lock;
2426
static uint16_t mem_wn_lock;
2527

@@ -78,3 +80,5 @@ void mbed_mpu_manager_unlock_rom_write()
7880
}
7981
core_util_critical_section_exit();
8082
}
83+
84+
#endif

platform/mbed_mpu_mgmt.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
extern "C" {
3333
#endif
3434

35+
#if DEVICE_MPU
36+
3537
/** Lock ram execute never mode off
3638
*
3739
* This disables the MPU's execute never ram protection and allows
@@ -80,6 +82,18 @@ void mbed_mpu_manager_lock_rom_write(void);
8082
*/
8183
void mbed_mpu_manager_unlock_rom_write(void);
8284

85+
#else
86+
87+
#define mbed_mpu_manager_lock_ram_execution() (void)0
88+
89+
#define mbed_mpu_manager_unlock_ram_execution() (void)0
90+
91+
#define mbed_mpu_manager_lock_rom_write() (void)0
92+
93+
#define mbed_mpu_manager_unlock_rom_write() (void)0
94+
95+
#endif
96+
8397
#ifdef __cplusplus
8498
}
8599
#endif

0 commit comments

Comments
 (0)