diff options
Diffstat (limited to 'common/system_common.c')
-rw-r--r-- | common/system_common.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/common/system_common.c b/common/system_common.c index ecf72c0782..55ea35d20d 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -13,6 +13,9 @@ #include "hooks.h" #include "host_command.h" #include "lpc.h" +#ifdef CONFIG_MPU +#include "mpu.h" +#endif #include "panic.h" #include "system.h" #include "task.h" @@ -212,6 +215,24 @@ const uint8_t *system_get_jump_tag(uint16_t tag, int *version, int *size) void system_disable_jump(void) { disable_jump = 1; + +#ifdef CONFIG_MPU + /* + * Lock down memory + * TODO: Lock down other images (RO or RW) not running. + */ + { + int mpu_error = mpu_protect_ram(); + if (mpu_error == EC_SUCCESS) { + mpu_enable(); + CPRINTF("RAM locked. Exclusion %08x-%08x\n", + &__iram_text_start, &__iram_text_end); + } else { + CPRINTF("Failed to lock RAM. mpu_type:%08x. error:%d\n", + mpu_get_type(), mpu_error); + } + } +#endif } test_mockable enum system_image_copy_t system_get_image_copy(void) |