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  * 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_SCOPEDRAMEXECUTIONLOCK_H
18 #define MBED_SCOPEDRAMEXECUTIONLOCK_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 RAM execute never mode
29  * Usage:
30  * @code
31  *
32  * void f() {
33  * // some code here
34  * {
35  * ScopedRamExecutionLock make_ram_executable;
36  * // Code in this block is allowed to call functions in RAM
37  * }
38  * // Execution from RAM is no longer allowed
39  * }
40  * @endcode
41  */
42 class ScopedRamExecutionLock : private mbed::NonCopyable<ScopedRamExecutionLock> {
43 public:
44 
45  /**
46  * Allow execution from RAM
47  *
48  * Increment the execute never lock to ensure code can
49  * be executed from RAM. This class uses RAII to allow
50  * execution from ram while it is in scope.
51  */
53  {
55  }
56 
57  /**
58  * Restore previous execution from RAM settings
59  *
60  * Decrement the execute never lock to return execute from RAM
61  * to its prior state.
62  */
64  {
66  }
67 };
68 
69 /**@}*/
70 
71 }
72 
73 #endif
~ScopedRamExecutionLock()
Restore previous execution from RAM settings.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:162
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:
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.