Mbed OS Reference
Loading...
Searching...
No Matches
mbed_mpu_mgmt.h
1/*
2 * Copyright (c) 2018-2020, Arm Limited and affiliates.
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
18#ifndef MBED_MPU_MGMT_H
19#define MBED_MPU_MGMT_H
20
21#include "hal/mpu_api.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/** \addtogroup platform-public-api */
28/** @{*/
29
30/**
31 * \defgroup platform_mpu_mgmt MPU management functions
32 * @{
33 */
34
35#if (DEVICE_MPU && MBED_CONF_PLATFORM_USE_MPU) || defined(DOXYGEN_ONLY)
36
37#define mbed_mpu_manager_init() mbed_mpu_init()
38
39#define mbed_mpu_manager_deinit() mbed_mpu_free()
40
41/** Lock ram execute never mode off
42 *
43 * This disables the MPU's execute never ram protection and allows
44 * functions to run from RAM. Execution directly from ram will be
45 * allowed if this function is invoked at least once (the internal
46 * counter is non-zero).
47 *
48 * Use this locking mechanism for code which needs to execute from
49 * ram such as flash programming algorithms and ram thunks.
50 *
51 * The lock is a counter, can be locked up to USHRT_MAX
52 * This function is IRQ and thread safe
53 */
55
56/** Unlock ram execute never mode
57 *
58 * Use unlocking in pair with mbed_mpu_manager_lock_ram_execution().
59 *
60 * The lock is a counter, should be equally unlocked as locked
61 * This function is IRQ and thread safe
62 */
64
65/** Lock rom write never mode off
66 *
67 * This disables the MPU's read only ROM protection and allows
68 * ROM to be written to. Writing to ROM will not result in an MPU
69 * fault if this function is invoked at least once (the internal
70 * counter is non-zero).
71 *
72 * Use this locking mechanism for code which needs to write to
73 * ROM such as flash programming algorithms.
74 *
75 * The lock is a counter, can be locked up to USHRT_MAX
76 * This function is IRQ and thread safe
77 */
79
80/** Unlock rom write never mode
81 *
82 * Use unlocking in pair with mbed_mpu_manager_lock_rom_write().
83 *
84 * The lock is a counter, should be equally unlocked as locked
85 * This function is IRQ and thread safe
86 */
88
89#else
90
91#define mbed_mpu_manager_init() (void)0
92
93#define mbed_mpu_manager_deinit() (void)0
94
95#define mbed_mpu_manager_lock_ram_execution() (void)0
96
97#define mbed_mpu_manager_unlock_ram_execution() (void)0
98
99#define mbed_mpu_manager_lock_rom_write() (void)0
100
101#define mbed_mpu_manager_unlock_rom_write() (void)0
102
103#endif
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif
110
111/** @}*/
112/** @}*/
void mbed_mpu_manager_unlock_ram_execution(void)
Unlock ram execute never mode.
void mbed_mpu_manager_unlock_rom_write(void)
Unlock rom write never mode.
void mbed_mpu_manager_lock_ram_execution(void)
Lock ram execute never mode off.
void mbed_mpu_manager_lock_rom_write(void)
Lock rom write never mode off.