diff --git a/TESTS/mbed_hal/flash/functional_tests/main.cpp b/TESTS/mbed_hal/flash/functional_tests/main.cpp index 498e666f35..06c876dfdd 100644 --- a/TESTS/mbed_hal/flash/functional_tests/main.cpp +++ b/TESTS/mbed_hal/flash/functional_tests/main.cpp @@ -252,8 +252,8 @@ Case cases[] = { utest::v1::status_t greentea_test_setup(const size_t number_of_cases) { - mbed_mpu_manager_lock_ram_xn(); - mbed_mpu_manager_lock_rom_wn(); + mbed_mpu_manager_lock_ram_execution(); + mbed_mpu_manager_lock_rom_write(); GREENTEA_SETUP(20, "default_auto"); return greentea_test_setup_handler(number_of_cases); @@ -261,8 +261,8 @@ utest::v1::status_t greentea_test_setup(const size_t number_of_cases) void greentea_test_teardown(const size_t passed, const size_t failed, const failure_t failure) { - mbed_mpu_manager_unlock_ram_xn(); - mbed_mpu_manager_unlock_rom_wn(); + mbed_mpu_manager_unlock_ram_execution(); + mbed_mpu_manager_unlock_rom_write(); greentea_test_teardown_handler(passed, failed, failure); } diff --git a/drivers/FlashIAP.cpp b/drivers/FlashIAP.cpp index dcac66caae..8ef6f6e1b0 100644 --- a/drivers/FlashIAP.cpp +++ b/drivers/FlashIAP.cpp @@ -25,8 +25,8 @@ #include #include "FlashIAP.h" #include "platform/mbed_assert.h" -#include "platform/ScopedMpuXnLock.h" -#include "platform/ScopedMpuWnLock.h" +#include "platform/ScopedRamExecutionLock.h" +#include "platform/ScopedRomWriteLock.h" #ifdef DEVICE_FLASH @@ -59,8 +59,8 @@ int FlashIAP::init() int ret = 0; _mutex->lock(); { - ScopedMpuXnLock make_ram_executable; - ScopedMpuWnLock make_rom_writable; + ScopedRamExecutionLock make_ram_executable; + ScopedRomWriteLock make_rom_writable; if (flash_init(&_flash)) { ret = -1; } @@ -77,8 +77,8 @@ int FlashIAP::deinit() int ret = 0; _mutex->lock(); { - ScopedMpuXnLock make_ram_executable; - ScopedMpuWnLock make_rom_writable; + ScopedRamExecutionLock make_ram_executable; + ScopedRomWriteLock make_rom_writable; if (flash_free(&_flash)) { ret = -1; } @@ -94,8 +94,8 @@ int FlashIAP::read(void *buffer, uint32_t addr, uint32_t size) int32_t ret = -1; _mutex->lock(); { - ScopedMpuXnLock make_ram_executable; - ScopedMpuWnLock make_rom_writable; + ScopedRamExecutionLock make_ram_executable; + ScopedRomWriteLock make_rom_writable; ret = flash_read(&_flash, addr, (uint8_t *) buffer, size); } _mutex->unlock(); @@ -141,8 +141,8 @@ int FlashIAP::program(const void *buffer, uint32_t addr, uint32_t size) prog_size = chunk; } { - ScopedMpuXnLock make_ram_executable; - ScopedMpuWnLock make_rom_writable; + ScopedRamExecutionLock make_ram_executable; + ScopedRomWriteLock make_rom_writable; if (flash_program_page(&_flash, addr, prog_buf, prog_size)) { ret = -1; break; @@ -189,8 +189,8 @@ int FlashIAP::erase(uint32_t addr, uint32_t size) _mutex->lock(); while (size) { { - ScopedMpuXnLock make_ram_executable; - ScopedMpuWnLock make_rom_writable; + ScopedRamExecutionLock make_ram_executable; + ScopedRomWriteLock make_rom_writable; ret = flash_erase_sector(&_flash, addr); } if (ret != 0) { diff --git a/mbed.h b/mbed.h index acdc548511..e247e1dfd3 100644 --- a/mbed.h +++ b/mbed.h @@ -95,8 +95,8 @@ #include "platform/DirHandle.h" #include "platform/CriticalSectionLock.h" #include "platform/DeepSleepLock.h" -#include "platform/ScopedMpuWnLock.h" -#include "platform/ScopedMpuXnLock.h" +#include "platform/ScopedRomWriteLock.h" +#include "platform/ScopedRamExecutionLock.h" #include "platform/mbed_stats.h" // mbed Non-hardware components diff --git a/platform/ScopedMpuXnLock.h b/platform/ScopedRamExecutionLock.h similarity index 80% rename from platform/ScopedMpuXnLock.h rename to platform/ScopedRamExecutionLock.h index 2b286fbb60..d45b3f9066 100644 --- a/platform/ScopedMpuXnLock.h +++ b/platform/ScopedRamExecutionLock.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MBED_SCOPEDMPUXNLOCK_H -#define MBED_SCOPEDMPUXNLOCK_H +#ifndef MBED_SCOPEDRAMEXECUTIONLOCK_H +#define MBED_SCOPEDRAMEXECUTIONLOCK_H #include "platform/mbed_mpu_mgmt.h" #include "platform/NonCopyable.h" @@ -31,14 +31,14 @@ namespace mbed { * void f() { * // some code here * { - * ScopedMpuXnLock xn; + * ScopedRamExecutionLock make_ram_executable; * // Code in this block is allowed to call functions in RAM * } * // Execution from RAM is no longer allowed * } * @endcode */ -class ScopedMpuXnLock : private mbed::NonCopyable { +class ScopedRamExecutionLock : private mbed::NonCopyable { public: /** @@ -48,9 +48,9 @@ public: * be executed from RAM. This class uses RAII to allow * execution from ram while it is in scope. */ - ScopedMpuXnLock() + ScopedRamExecutionLock() { - mbed_mpu_manager_lock_ram_xn(); + mbed_mpu_manager_lock_ram_execution(); } /** @@ -59,9 +59,9 @@ public: * Decrement the execute never lock to return execute from RAM * to its prior state. */ - ~ScopedMpuXnLock() + ~ScopedRamExecutionLock() { - mbed_mpu_manager_unlock_ram_xn(); + mbed_mpu_manager_unlock_ram_execution(); } }; diff --git a/platform/ScopedMpuWnLock.h b/platform/ScopedRomWriteLock.h similarity index 59% rename from platform/ScopedMpuWnLock.h rename to platform/ScopedRomWriteLock.h index 33309ac7bf..7cd6d5f355 100644 --- a/platform/ScopedMpuWnLock.h +++ b/platform/ScopedRomWriteLock.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef MBED_SCOPEDMPUWNLOCK_H -#define MBED_SCOPEDMPUWNLOCK_H +#ifndef MBED_SCOPEDROMWRITELOCK_H +#define MBED_SCOPEDROMWRITELOCK_H #include "platform/mbed_mpu_mgmt.h" #include "platform/NonCopyable.h" @@ -31,37 +31,37 @@ namespace mbed { * void f() { * // some code here * { - * ScopedMpuXnLock xn; - * // Code in this block is allowed to call functions in RAM + * ScopedRomWriteLock make_ram_executable; + * // Code in this block is allowed to write to ROM * } - * // Execution from RAM is no longer allowed + * // Writing to ROM is no longer allowed * } * @endcode */ -class ScopedMpuWnLock : private mbed::NonCopyable { +class ScopedRomWriteLock : private mbed::NonCopyable { public: /** - * Allow execution from RAM + * Allow writing to ROM * - * Increment the execute never lock to ensure code can - * be executed from RAM. This class uses RAII to allow - * execution from ram while it is in scope. + * Increment the ROM write lock to ensure code can + * write to ROM. This class uses RAII to allow + * writing to ROM while it is in scope. */ - ScopedMpuWnLock() + ScopedRomWriteLock() { - mbed_mpu_manager_lock_rom_wn(); + mbed_mpu_manager_lock_rom_write(); } /** - * Restore previous execution from RAM settings + * Restore previous write to ROM settings * - * Decrement the execute never lock to return execute from RAM + * Decrement the ROM write lock to return ROM write * to its prior state. */ - ~ScopedMpuWnLock() + ~ScopedRomWriteLock() { - mbed_mpu_manager_unlock_rom_wn(); + mbed_mpu_manager_unlock_rom_write(); } }; diff --git a/platform/mbed_mpu_mgmt.c b/platform/mbed_mpu_mgmt.c index 39369b7542..fa8bc545cc 100644 --- a/platform/mbed_mpu_mgmt.c +++ b/platform/mbed_mpu_mgmt.c @@ -23,7 +23,7 @@ static uint16_t mem_xn_lock; static uint16_t mem_wn_lock; -void mbed_mpu_manager_lock_ram_xn() +void mbed_mpu_manager_lock_ram_execution() { core_util_critical_section_enter(); if (mem_xn_lock == USHRT_MAX) { @@ -37,7 +37,7 @@ void mbed_mpu_manager_lock_ram_xn() core_util_critical_section_exit(); } -void mbed_mpu_manager_unlock_ram_xn() +void mbed_mpu_manager_unlock_ram_execution() { core_util_critical_section_enter(); if (mem_xn_lock == 0) { @@ -51,7 +51,7 @@ void mbed_mpu_manager_unlock_ram_xn() core_util_critical_section_exit(); } -void mbed_mpu_manager_lock_rom_wn() +void mbed_mpu_manager_lock_rom_write() { core_util_critical_section_enter(); if (mem_wn_lock == USHRT_MAX) { @@ -65,7 +65,7 @@ void mbed_mpu_manager_lock_rom_wn() core_util_critical_section_exit(); } -void mbed_mpu_manager_unlock_rom_wn() +void mbed_mpu_manager_unlock_rom_write() { core_util_critical_section_enter(); if (mem_wn_lock == 0) { diff --git a/platform/mbed_mpu_mgmt.h b/platform/mbed_mpu_mgmt.h index 071cfefc80..7af043f586 100644 --- a/platform/mbed_mpu_mgmt.h +++ b/platform/mbed_mpu_mgmt.h @@ -36,7 +36,7 @@ extern "C" { * * This disables the MPU's execute never ram protection and allows * functions to run from RAM. Execution directly from ram will be - * allowed if this function is invoked at least once(the internal + * allowed if this function is invoked at least once (the internal * counter is non-zero). * * Use this locking mechanism for code which needs to execute from @@ -45,22 +45,22 @@ extern "C" { * The lock is a counter, can be locked up to USHRT_MAX * This function is IRQ and thread safe */ -void mbed_mpu_manager_lock_ram_xn(void); +void mbed_mpu_manager_lock_ram_execution(void); /** Unlock ram execute never mode * - * Use unlocking in pair with mbed_mpu_manager_lock_ram_xn(). + * Use unlocking in pair with mbed_mpu_manager_lock_ram_execution(). * * The lock is a counter, should be equally unlocked as locked * This function is IRQ and thread safe */ -void mbed_mpu_manager_unlock_ram_xn(void); +void mbed_mpu_manager_unlock_ram_execution(void); /** Lock rom write never mode off * - * This disables the MPU's write never ROM protection and allows + * This disables the MPU's read only ROM protection and allows * ROM to be written to. Writing to ROM will not result in an MPU - * fault if this function is invoked at least once(the internal + * fault if this function is invoked at least once (the internal * counter is non-zero). * * Use this locking mechanism for code which needs to write to @@ -69,16 +69,16 @@ void mbed_mpu_manager_unlock_ram_xn(void); * The lock is a counter, can be locked up to USHRT_MAX * This function is IRQ and thread safe */ -void mbed_mpu_manager_lock_rom_wn(void); +void mbed_mpu_manager_lock_rom_write(void); /** Unlock rom write never mode * - * Use unlocking in pair with mbed_mpu_manager_lock_rom_wn(). + * Use unlocking in pair with mbed_mpu_manager_lock_rom_write(). * * The lock is a counter, should be equally unlocked as locked * This function is IRQ and thread safe */ -void mbed_mpu_manager_unlock_rom_wn(void); +void mbed_mpu_manager_unlock_rom_write(void); #ifdef __cplusplus }