Skip to content

Commit caa7b93

Browse files
c1728p90xc0170
authored andcommitted
Rename lock functions and classes
Invert the name of the lock functions and classes so you are not locking a negative.
1 parent a7bf312 commit caa7b93

File tree

7 files changed

+55
-55
lines changed

7 files changed

+55
-55
lines changed

TESTS/mbed_hal/flash/functional_tests/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,17 @@ Case cases[] = {
252252

253253
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
254254
{
255-
mbed_mpu_manager_lock_ram_xn();
256-
mbed_mpu_manager_lock_rom_wn();
255+
mbed_mpu_manager_lock_ram_execution();
256+
mbed_mpu_manager_lock_rom_write();
257257

258258
GREENTEA_SETUP(20, "default_auto");
259259
return greentea_test_setup_handler(number_of_cases);
260260
}
261261

262262
void greentea_test_teardown(const size_t passed, const size_t failed, const failure_t failure)
263263
{
264-
mbed_mpu_manager_unlock_ram_xn();
265-
mbed_mpu_manager_unlock_rom_wn();
264+
mbed_mpu_manager_unlock_ram_execution();
265+
mbed_mpu_manager_unlock_rom_write();
266266

267267
greentea_test_teardown_handler(passed, failed, failure);
268268
}

drivers/FlashIAP.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include <algorithm>
2626
#include "FlashIAP.h"
2727
#include "platform/mbed_assert.h"
28-
#include "platform/ScopedMpuXnLock.h"
29-
#include "platform/ScopedMpuWnLock.h"
28+
#include "platform/ScopedRamExecutionLock.h"
29+
#include "platform/ScopedRomWriteLock.h"
3030

3131

3232
#ifdef DEVICE_FLASH
@@ -59,8 +59,8 @@ int FlashIAP::init()
5959
int ret = 0;
6060
_mutex->lock();
6161
{
62-
ScopedMpuXnLock make_ram_executable;
63-
ScopedMpuWnLock make_rom_writable;
62+
ScopedRamExecutionLock make_ram_executable;
63+
ScopedRomWriteLock make_rom_writable;
6464
if (flash_init(&_flash)) {
6565
ret = -1;
6666
}
@@ -77,8 +77,8 @@ int FlashIAP::deinit()
7777
int ret = 0;
7878
_mutex->lock();
7979
{
80-
ScopedMpuXnLock make_ram_executable;
81-
ScopedMpuWnLock make_rom_writable;
80+
ScopedRamExecutionLock make_ram_executable;
81+
ScopedRomWriteLock make_rom_writable;
8282
if (flash_free(&_flash)) {
8383
ret = -1;
8484
}
@@ -94,8 +94,8 @@ int FlashIAP::read(void *buffer, uint32_t addr, uint32_t size)
9494
int32_t ret = -1;
9595
_mutex->lock();
9696
{
97-
ScopedMpuXnLock make_ram_executable;
98-
ScopedMpuWnLock make_rom_writable;
97+
ScopedRamExecutionLock make_ram_executable;
98+
ScopedRomWriteLock make_rom_writable;
9999
ret = flash_read(&_flash, addr, (uint8_t *) buffer, size);
100100
}
101101
_mutex->unlock();
@@ -141,8 +141,8 @@ int FlashIAP::program(const void *buffer, uint32_t addr, uint32_t size)
141141
prog_size = chunk;
142142
}
143143
{
144-
ScopedMpuXnLock make_ram_executable;
145-
ScopedMpuWnLock make_rom_writable;
144+
ScopedRamExecutionLock make_ram_executable;
145+
ScopedRomWriteLock make_rom_writable;
146146
if (flash_program_page(&_flash, addr, prog_buf, prog_size)) {
147147
ret = -1;
148148
break;
@@ -189,8 +189,8 @@ int FlashIAP::erase(uint32_t addr, uint32_t size)
189189
_mutex->lock();
190190
while (size) {
191191
{
192-
ScopedMpuXnLock make_ram_executable;
193-
ScopedMpuWnLock make_rom_writable;
192+
ScopedRamExecutionLock make_ram_executable;
193+
ScopedRomWriteLock make_rom_writable;
194194
ret = flash_erase_sector(&_flash, addr);
195195
}
196196
if (ret != 0) {

mbed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@
9595
#include "platform/DirHandle.h"
9696
#include "platform/CriticalSectionLock.h"
9797
#include "platform/DeepSleepLock.h"
98-
#include "platform/ScopedMpuWnLock.h"
99-
#include "platform/ScopedMpuXnLock.h"
98+
#include "platform/ScopedRomWriteLock.h"
99+
#include "platform/ScopedRamExecutionLock.h"
100100
#include "platform/mbed_stats.h"
101101

102102
// mbed Non-hardware components

platform/ScopedMpuXnLock.h renamed to platform/ScopedRamExecutionLock.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#ifndef MBED_SCOPEDMPUXNLOCK_H
17-
#define MBED_SCOPEDMPUXNLOCK_H
16+
#ifndef MBED_SCOPEDRAMEXECUTIONLOCK_H
17+
#define MBED_SCOPEDRAMEXECUTIONLOCK_H
1818

1919
#include "platform/mbed_mpu_mgmt.h"
2020
#include "platform/NonCopyable.h"
@@ -31,14 +31,14 @@ namespace mbed {
3131
* void f() {
3232
* // some code here
3333
* {
34-
* ScopedMpuXnLock xn;
34+
* ScopedRamExecutionLock make_ram_executable;
3535
* // Code in this block is allowed to call functions in RAM
3636
* }
3737
* // Execution from RAM is no longer allowed
3838
* }
3939
* @endcode
4040
*/
41-
class ScopedMpuXnLock : private mbed::NonCopyable<ScopedMpuXnLock> {
41+
class ScopedRamExecutionLock : private mbed::NonCopyable<ScopedRamExecutionLock> {
4242
public:
4343

4444
/**
@@ -48,9 +48,9 @@ class ScopedMpuXnLock : private mbed::NonCopyable<ScopedMpuXnLock> {
4848
* be executed from RAM. This class uses RAII to allow
4949
* execution from ram while it is in scope.
5050
*/
51-
ScopedMpuXnLock()
51+
ScopedRamExecutionLock()
5252
{
53-
mbed_mpu_manager_lock_ram_xn();
53+
mbed_mpu_manager_lock_ram_execution();
5454
}
5555

5656
/**
@@ -59,9 +59,9 @@ class ScopedMpuXnLock : private mbed::NonCopyable<ScopedMpuXnLock> {
5959
* Decrement the execute never lock to return execute from RAM
6060
* to its prior state.
6161
*/
62-
~ScopedMpuXnLock()
62+
~ScopedRamExecutionLock()
6363
{
64-
mbed_mpu_manager_unlock_ram_xn();
64+
mbed_mpu_manager_unlock_ram_execution();
6565
}
6666
};
6767

platform/ScopedMpuWnLock.h renamed to platform/ScopedRomWriteLock.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#ifndef MBED_SCOPEDMPUWNLOCK_H
17-
#define MBED_SCOPEDMPUWNLOCK_H
16+
#ifndef MBED_SCOPEDROMWRITELOCK_H
17+
#define MBED_SCOPEDROMWRITELOCK_H
1818

1919
#include "platform/mbed_mpu_mgmt.h"
2020
#include "platform/NonCopyable.h"
@@ -31,37 +31,37 @@ namespace mbed {
3131
* void f() {
3232
* // some code here
3333
* {
34-
* ScopedMpuXnLock xn;
35-
* // Code in this block is allowed to call functions in RAM
34+
* ScopedRomWriteLock make_ram_executable;
35+
* // Code in this block is allowed to write to ROM
3636
* }
37-
* // Execution from RAM is no longer allowed
37+
* // Writing to ROM is no longer allowed
3838
* }
3939
* @endcode
4040
*/
41-
class ScopedMpuWnLock : private mbed::NonCopyable<ScopedMpuWnLock> {
41+
class ScopedRomWriteLock : private mbed::NonCopyable<ScopedRomWriteLock> {
4242
public:
4343

4444
/**
45-
* Allow execution from RAM
45+
* Allow writing to ROM
4646
*
47-
* Increment the execute never lock to ensure code can
48-
* be executed from RAM. This class uses RAII to allow
49-
* execution from ram while it is in scope.
47+
* Increment the ROM write lock to ensure code can
48+
* write to ROM. This class uses RAII to allow
49+
* writing to ROM while it is in scope.
5050
*/
51-
ScopedMpuWnLock()
51+
ScopedRomWriteLock()
5252
{
53-
mbed_mpu_manager_lock_rom_wn();
53+
mbed_mpu_manager_lock_rom_write();
5454
}
5555

5656
/**
57-
* Restore previous execution from RAM settings
57+
* Restore previous write to ROM settings
5858
*
59-
* Decrement the execute never lock to return execute from RAM
59+
* Decrement the ROM write lock to return ROM write
6060
* to its prior state.
6161
*/
62-
~ScopedMpuWnLock()
62+
~ScopedRomWriteLock()
6363
{
64-
mbed_mpu_manager_unlock_rom_wn();
64+
mbed_mpu_manager_unlock_rom_write();
6565
}
6666
};
6767

platform/mbed_mpu_mgmt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
static uint16_t mem_xn_lock;
2424
static uint16_t mem_wn_lock;
2525

26-
void mbed_mpu_manager_lock_ram_xn()
26+
void mbed_mpu_manager_lock_ram_execution()
2727
{
2828
core_util_critical_section_enter();
2929
if (mem_xn_lock == USHRT_MAX) {
@@ -37,7 +37,7 @@ void mbed_mpu_manager_lock_ram_xn()
3737
core_util_critical_section_exit();
3838
}
3939

40-
void mbed_mpu_manager_unlock_ram_xn()
40+
void mbed_mpu_manager_unlock_ram_execution()
4141
{
4242
core_util_critical_section_enter();
4343
if (mem_xn_lock == 0) {
@@ -51,7 +51,7 @@ void mbed_mpu_manager_unlock_ram_xn()
5151
core_util_critical_section_exit();
5252
}
5353

54-
void mbed_mpu_manager_lock_rom_wn()
54+
void mbed_mpu_manager_lock_rom_write()
5555
{
5656
core_util_critical_section_enter();
5757
if (mem_wn_lock == USHRT_MAX) {
@@ -65,7 +65,7 @@ void mbed_mpu_manager_lock_rom_wn()
6565
core_util_critical_section_exit();
6666
}
6767

68-
void mbed_mpu_manager_unlock_rom_wn()
68+
void mbed_mpu_manager_unlock_rom_write()
6969
{
7070
core_util_critical_section_enter();
7171
if (mem_wn_lock == 0) {

platform/mbed_mpu_mgmt.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern "C" {
3636
*
3737
* This disables the MPU's execute never ram protection and allows
3838
* functions to run from RAM. Execution directly from ram will be
39-
* allowed if this function is invoked at least once(the internal
39+
* allowed if this function is invoked at least once (the internal
4040
* counter is non-zero).
4141
*
4242
* Use this locking mechanism for code which needs to execute from
@@ -45,22 +45,22 @@ extern "C" {
4545
* The lock is a counter, can be locked up to USHRT_MAX
4646
* This function is IRQ and thread safe
4747
*/
48-
void mbed_mpu_manager_lock_ram_xn(void);
48+
void mbed_mpu_manager_lock_ram_execution(void);
4949

5050
/** Unlock ram execute never mode
5151
*
52-
* Use unlocking in pair with mbed_mpu_manager_lock_ram_xn().
52+
* Use unlocking in pair with mbed_mpu_manager_lock_ram_execution().
5353
*
5454
* The lock is a counter, should be equally unlocked as locked
5555
* This function is IRQ and thread safe
5656
*/
57-
void mbed_mpu_manager_unlock_ram_xn(void);
57+
void mbed_mpu_manager_unlock_ram_execution(void);
5858

5959
/** Lock rom write never mode off
6060
*
61-
* This disables the MPU's write never ROM protection and allows
61+
* This disables the MPU's read only ROM protection and allows
6262
* ROM to be written to. Writing to ROM will not result in an MPU
63-
* fault if this function is invoked at least once(the internal
63+
* fault if this function is invoked at least once (the internal
6464
* counter is non-zero).
6565
*
6666
* Use this locking mechanism for code which needs to write to
@@ -69,16 +69,16 @@ void mbed_mpu_manager_unlock_ram_xn(void);
6969
* The lock is a counter, can be locked up to USHRT_MAX
7070
* This function is IRQ and thread safe
7171
*/
72-
void mbed_mpu_manager_lock_rom_wn(void);
72+
void mbed_mpu_manager_lock_rom_write(void);
7373

7474
/** Unlock rom write never mode
7575
*
76-
* Use unlocking in pair with mbed_mpu_manager_lock_rom_wn().
76+
* Use unlocking in pair with mbed_mpu_manager_lock_rom_write().
7777
*
7878
* The lock is a counter, should be equally unlocked as locked
7979
* This function is IRQ and thread safe
8080
*/
81-
void mbed_mpu_manager_unlock_rom_wn(void);
81+
void mbed_mpu_manager_unlock_rom_write(void);
8282

8383
#ifdef __cplusplus
8484
}

0 commit comments

Comments
 (0)