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  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_SCOPEDROMWRITELOCK_H
18 #define MBED_SCOPEDROMWRITELOCK_H
19 
20 #include "platform/mbed_mpu_mgmt.h"
21 #include "platform/NonCopyable.h"
22 
23 namespace mbed {
24 
25 /** \addtogroup platform-public-api */
26 /** @{*/
27 
28 /** RAII object for disabling, then restoring ROM write never mode
29  * Usage:
30  * @code
31  *
32  * void f() {
33  * // some code here
34  * {
35  * ScopedRomWriteLock make_ram_executable;
36  * // Code in this block is allowed to write to ROM
37  * }
38  * // Writing to ROM is no longer allowed
39  * }
40  * @endcode
41  */
42 class ScopedRomWriteLock : private mbed::NonCopyable<ScopedRomWriteLock> {
43 public:
44 
45  /**
46  * Allow writing to ROM
47  *
48  * Increment the ROM write lock to ensure code can
49  * write to ROM. This class uses RAII to allow
50  * writing to ROM while it is in scope.
51  */
53  {
55  }
56 
57  /**
58  * Restore previous write to ROM settings
59  *
60  * Decrement the ROM write lock to return ROM write
61  * to its prior state.
62  */
64  {
66  }
67 };
68 
69 /**@}*/
70 
71 }
72 
73 #endif
~ScopedRomWriteLock()
Restore previous write to ROM settings.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:162
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.
Definition: ATHandler.h:46
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.