mirror of https://github.com/ARMmbed/mbed-os.git
Save ROM by specifying initial MPU state
We can omit the need for the "change MPU state" calls from simple images by specifying the initial state at init.pull/9064/head
parent
bb4cb774a2
commit
4d9f218ab2
|
@ -78,7 +78,8 @@ void mbed_mpu_init()
|
|||
(3 << MPU_RBAR_AP_Pos) | // RO allowed by all privilege levels
|
||||
(0 << MPU_RBAR_XN_Pos); // Execute Never disabled
|
||||
MPU->RLAR = (0x1FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x1FFFFFFF
|
||||
(region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number
|
||||
(region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number
|
||||
(1 << MPU_RLAR_EN_Pos); // Region enabled
|
||||
|
||||
region = 1;
|
||||
MPU->RNR = region;
|
||||
|
@ -90,7 +91,8 @@ void mbed_mpu_init()
|
|||
(1 << MPU_RBAR_AP_Pos) | // RW allowed by all privilege levels
|
||||
(1 << MPU_RBAR_XN_Pos); // Execute Never enabled
|
||||
MPU->RLAR = (0x3FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x3FFFFFFF
|
||||
(region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number
|
||||
(region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number
|
||||
(1 << MPU_RLAR_EN_Pos); // Region enabled
|
||||
|
||||
region = 2;
|
||||
MPU->RNR = region;
|
||||
|
@ -102,7 +104,8 @@ void mbed_mpu_init()
|
|||
(1 << MPU_RBAR_AP_Pos) | // RW allowed by all privilege levels
|
||||
(1 << MPU_RBAR_XN_Pos); // Execute Never enabled
|
||||
MPU->RLAR = (0x7FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x7FFFFFFF
|
||||
(region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number
|
||||
(region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number
|
||||
(1 << MPU_RLAR_EN_Pos); // Region enabled
|
||||
|
||||
region = 3;
|
||||
MPU->RNR = region;
|
||||
|
@ -114,7 +117,8 @@ void mbed_mpu_init()
|
|||
(1 << MPU_RBAR_AP_Pos) | // RW allowed by all privilege levels
|
||||
(1 << MPU_RBAR_XN_Pos); // Execute Never enabled
|
||||
MPU->RLAR = (0x9FFFFFFF & MPU_RLAR_LIMIT_Msk) | // Last address is 0x9FFFFFFF
|
||||
(region << MPU_RLAR_AttrIndx_Pos); // Attribute index - configured to be the same as the region number
|
||||
(region << MPU_RLAR_AttrIndx_Pos) | // Attribute index - configured to be the same as the region number
|
||||
(1 << MPU_RLAR_EN_Pos); // Region enabled
|
||||
|
||||
// Enable the MPU
|
||||
MPU->CTRL =
|
||||
|
|
|
@ -64,8 +64,8 @@ extern "C" {
|
|||
* Initialize the MPU
|
||||
*
|
||||
* Initialize or re-initialize the memory protection unit.
|
||||
* It is implementation defined what region are protected
|
||||
* by the MPU after initialization.
|
||||
* After initialization or re-initialization, ROM and RAM protection
|
||||
* are both enabled.
|
||||
*/
|
||||
void mbed_mpu_init(void);
|
||||
|
||||
|
@ -75,7 +75,9 @@ void mbed_mpu_init(void);
|
|||
* This function is used to mark all of ROM as read and execute only.
|
||||
* When enabled writes to ROM cause a fault.
|
||||
*
|
||||
* @param enable true to disable execution in ram, false otherwise
|
||||
* By default writes to ROM are disabled.
|
||||
*
|
||||
* @param enable true to disable writes to ROM, false otherwise
|
||||
*/
|
||||
void mbed_mpu_enable_rom_wn(bool enable);
|
||||
|
||||
|
@ -85,7 +87,9 @@ void mbed_mpu_enable_rom_wn(bool enable);
|
|||
* This function is used to mark all of RAM as execute never.
|
||||
* When enabled code is only allowed to execute from flash.
|
||||
*
|
||||
* @param enable true to disable execution in ram, false otherwise
|
||||
* By default execution from RAM is disabled.
|
||||
*
|
||||
* @param enable true to disable execution from RAM, false otherwise
|
||||
*/
|
||||
void mbed_mpu_enable_ram_xn(bool enable);
|
||||
|
||||
|
|
|
@ -88,8 +88,6 @@ uint32_t mbed_stack_isr_size = 0;
|
|||
void mbed_init(void)
|
||||
{
|
||||
mbed_mpu_init();
|
||||
mbed_mpu_enable_ram_xn(true);
|
||||
mbed_mpu_enable_rom_wn(true);
|
||||
mbed_cpy_nvic();
|
||||
mbed_sdk_init();
|
||||
mbed_rtos_init();
|
||||
|
|
Loading…
Reference in New Issue