Mistake on this page?
Report an issue in GitHub or email us
ScopedRamExecutionLock.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_SCOPEDRAMEXECUTIONLOCK_H
17 #define MBED_SCOPEDRAMEXECUTIONLOCK_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 RAM execute never mode
28  * Usage:
29  * @code
30  *
31  * void f() {
32  * // some code here
33  * {
34  * ScopedRamExecutionLock make_ram_executable;
35  * // Code in this block is allowed to call functions in RAM
36  * }
37  * // Execution from RAM is no longer allowed
38  * }
39  * @endcode
40  */
41 class ScopedRamExecutionLock : private mbed::NonCopyable<ScopedRamExecutionLock> {
42 public:
43 
44  /**
45  * Allow execution from RAM
46  *
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.
50  */
52  {
54  }
55 
56  /**
57  * Restore previous execution from RAM settings
58  *
59  * Decrement the execute never lock to return execute from RAM
60  * to its prior state.
61  */
63  {
65  }
66 };
67 
68 /**@}*/
69 
70 }
71 
72 #endif
~ScopedRamExecutionLock()
Restore previous execution from RAM settings.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:169
ScopedRamExecutionLock()
Allow execution from RAM.
void mbed_mpu_manager_lock_ram_execution(void)
Lock ram execute never mode off.
void mbed_mpu_manager_unlock_ram_execution(void)
Unlock ram execute never mode.
RAII object for disabling, then restoring RAM execute never mode Usage:
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.