Mistake on this page?
Report an issue in GitHub or email us
ScopedRomWriteLock.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2018-2019 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MBED_SCOPEDROMWRITELOCK_H
17 #define MBED_SCOPEDROMWRITELOCK_H
18 
19 #include "platform/mbed_mpu_mgmt.h"
20 #include "platform/NonCopyable.h"
21 
22 namespace mbed {
23 
24 /** \addtogroup platform-public-api */
25 /** @{*/
26 
27 /** RAII object for disabling, then restoring ROM write never mode
28  * Usage:
29  * @code
30  *
31  * void f() {
32  * // some code here
33  * {
34  * ScopedRomWriteLock make_ram_executable;
35  * // Code in this block is allowed to write to ROM
36  * }
37  * // Writing to ROM is no longer allowed
38  * }
39  * @endcode
40  */
41 class ScopedRomWriteLock : private mbed::NonCopyable<ScopedRomWriteLock> {
42 public:
43 
44  /**
45  * Allow writing to ROM
46  *
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.
50  */
52  {
54  }
55 
56  /**
57  * Restore previous write to ROM settings
58  *
59  * Decrement the ROM write lock to return ROM write
60  * to its prior state.
61  */
63  {
65  }
66 };
67 
68 /**@}*/
69 
70 }
71 
72 #endif
~ScopedRomWriteLock()
Restore previous write to ROM settings.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:169
RAII object for disabling, then restoring ROM write never mode Usage:
void mbed_mpu_manager_unlock_rom_write(void)
Unlock rom write never mode.
ScopedRomWriteLock()
Allow writing to ROM.
void mbed_mpu_manager_lock_rom_write(void)
Lock rom write never mode off.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.