Rename MpuXnLock

Rename MpuXnLock  to ScopedMpuXnLock so it has the same naming
convention as ScopedMutexLock. Also make this class inherit from
NonCopyable to prevent misuse.
pull/8871/head
Russ Butler 2018-11-06 15:57:28 -06:00 committed by Martin Kojtal
parent 7283f9b0ee
commit d27566c955
3 changed files with 14 additions and 13 deletions

View File

@ -25,7 +25,7 @@
#include <algorithm>
#include "FlashIAP.h"
#include "platform/mbed_assert.h"
#include "platform/MpuXnLock.h"
#include "platform/ScopedMpuXnLock.h"
#ifdef DEVICE_FLASH
@ -58,7 +58,7 @@ int FlashIAP::init()
int ret = 0;
_mutex->lock();
{
MpuXnLock xn;
ScopedMpuXnLock xn;
if (flash_init(&_flash)) {
ret = -1;
}
@ -75,7 +75,7 @@ int FlashIAP::deinit()
int ret = 0;
_mutex->lock();
{
MpuXnLock xn;
ScopedMpuXnLock xn;
if (flash_free(&_flash)) {
ret = -1;
}
@ -91,7 +91,7 @@ int FlashIAP::read(void *buffer, uint32_t addr, uint32_t size)
int32_t ret = -1;
_mutex->lock();
{
MpuXnLock xn;
ScopedMpuXnLock xn;
ret = flash_read(&_flash, addr, (uint8_t *) buffer, size);
}
_mutex->unlock();
@ -137,7 +137,7 @@ int FlashIAP::program(const void *buffer, uint32_t addr, uint32_t size)
prog_size = chunk;
}
{
MpuXnLock xn;
ScopedMpuXnLock xn;
if (flash_program_page(&_flash, addr, prog_buf, prog_size)) {
ret = -1;
break;
@ -184,7 +184,7 @@ int FlashIAP::erase(uint32_t addr, uint32_t size)
_mutex->lock();
while (size) {
{
MpuXnLock xn;
ScopedMpuXnLock xn;
ret = flash_erase_sector(&_flash, addr);
}
if (ret != 0) {

2
mbed.h
View File

@ -95,7 +95,7 @@
#include "platform/DirHandle.h"
#include "platform/CriticalSectionLock.h"
#include "platform/DeepSleepLock.h"
#include "platform/MpuXnLock.h"
#include "platform/ScopedMpuXnLock.h"
#include "platform/mbed_stats.h"
// mbed Non-hardware components

View File

@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_MPUXNLOCK_H
#define MBED_MPUXNLOCK_H
#ifndef MBED_SCOPEDMPUXNLOCK_H
#define MBED_SCOPEDMPUXNLOCK_H
#include "platform/mbed_mpu_mgmt.h"
#include "platform/NonCopyable.h"
namespace mbed {
@ -30,14 +31,14 @@ namespace mbed {
* void f() {
* // some code here
* {
* MpuXnLock xn;
* ScopedMpuXnLock xn;
* // Code in this block is allowed to call functions in RAM
* }
* // Execution from RAM is no longer allowed
* }
* @endcode
*/
class MpuXnLock {
class ScopedMpuXnLock : private mbed::NonCopyable<ScopedMpuXnLock> {
public:
/**
@ -47,7 +48,7 @@ public:
* be executed from RAM. This class uses RAII to allow
* execution from ram while it is in scope.
*/
MpuXnLock()
ScopedMpuXnLock()
{
mbed_mpu_manager_lock_mem_xn();
}
@ -58,7 +59,7 @@ public:
* Decrement the execute never lock to return execute from RAM
* to its prior state.
*/
~MpuXnLock()
~ScopedMpuXnLock()
{
mbed_mpu_manager_unlock_mem_xn();
}