Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed by
TARGET_NUCLEO_F439ZI/core_cmSecureAccess.h@128:9bcdf88f62b0, 2016-10-27 (annotated)
- Committer:
- <>
- Date:
- Thu Oct 27 16:45:56 2016 +0100
- Revision:
- 128:9bcdf88f62b0
- Parent:
- TARGET_NUMAKER_PFM_NUC472/core_cmSecureAccess.h@123:b0220dba8be7
Release 128 of the mbed library
Ports for Upcoming Targets
Fixes and Changes
2966: Add kw24 support https://github.com/ARMmbed/mbed-os/pull/2966
3068: MultiTech mDot - clean up PeripheralPins.c and add new pin names https://github.com/ARMmbed/mbed-os/pull/3068
3089: Kinetis HAL: Remove clock initialization code from serial and ticker https://github.com/ARMmbed/mbed-os/pull/3089
2943: [NRF5] NVIC_SetVector functionality https://github.com/ARMmbed/mbed-os/pull/2943
2938: InterruptIn changes in NCS36510 HAL. https://github.com/ARMmbed/mbed-os/pull/2938
3108: Fix sleep function for NRF52. https://github.com/ARMmbed/mbed-os/pull/3108
3076: STM32F1: Correct timer master value reading https://github.com/ARMmbed/mbed-os/pull/3076
3085: Add LOWPOWERTIMER capability for NUCLEO_F303ZE https://github.com/ARMmbed/mbed-os/pull/3085
3046: [BEETLE] Update BLE stack on Beetle board https://github.com/ARMmbed/mbed-os/pull/3046
3122: [Silicon Labs] Update of Silicon Labs HAL https://github.com/ARMmbed/mbed-os/pull/3122
3022: OnSemi RAM usage fix https://github.com/ARMmbed/mbed-os/pull/3022
3121: STM32F3: Correct UART4 and UART5 defines when using DEVICE_SERIAL_ASYNCH https://github.com/ARMmbed/mbed-os/pull/3121
3142: Targets- NUMAKER_PFM_NUC47216 remove mbed 2 https://github.com/ARMmbed/mbed-os/pull/3142
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Kojto | 122:f9eeca106725 | 1 | /**************************************************************************//** |
| Kojto | 122:f9eeca106725 | 2 | * @file core_cmSecureAccess.h |
| Kojto | 122:f9eeca106725 | 3 | * @brief CMSIS Cortex-M Core Secure Access Header File |
| Kojto | 122:f9eeca106725 | 4 | * @version XXX |
| Kojto | 122:f9eeca106725 | 5 | * @date 10. June 2016 |
| Kojto | 122:f9eeca106725 | 6 | * |
| Kojto | 122:f9eeca106725 | 7 | * @note |
| Kojto | 122:f9eeca106725 | 8 | * |
| Kojto | 122:f9eeca106725 | 9 | ******************************************************************************/ |
| Kojto | 122:f9eeca106725 | 10 | /* Copyright (c) 2016 ARM LIMITED |
| Kojto | 122:f9eeca106725 | 11 | |
| Kojto | 122:f9eeca106725 | 12 | All rights reserved. |
| Kojto | 122:f9eeca106725 | 13 | Redistribution and use in source and binary forms, with or without |
| Kojto | 122:f9eeca106725 | 14 | modification, are permitted provided that the following conditions are met: |
| Kojto | 122:f9eeca106725 | 15 | - Redistributions of source code must retain the above copyright |
| Kojto | 122:f9eeca106725 | 16 | notice, this list of conditions and the following disclaimer. |
| Kojto | 122:f9eeca106725 | 17 | - Redistributions in binary form must reproduce the above copyright |
| Kojto | 122:f9eeca106725 | 18 | notice, this list of conditions and the following disclaimer in the |
| Kojto | 122:f9eeca106725 | 19 | documentation and/or other materials provided with the distribution. |
| Kojto | 122:f9eeca106725 | 20 | - Neither the name of ARM nor the names of its contributors may be used |
| Kojto | 122:f9eeca106725 | 21 | to endorse or promote products derived from this software without |
| Kojto | 122:f9eeca106725 | 22 | specific prior written permission. |
| Kojto | 122:f9eeca106725 | 23 | * |
| Kojto | 122:f9eeca106725 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| Kojto | 122:f9eeca106725 | 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| Kojto | 122:f9eeca106725 | 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| Kojto | 122:f9eeca106725 | 27 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
| Kojto | 122:f9eeca106725 | 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| Kojto | 122:f9eeca106725 | 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| Kojto | 122:f9eeca106725 | 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| Kojto | 122:f9eeca106725 | 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| Kojto | 122:f9eeca106725 | 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| Kojto | 122:f9eeca106725 | 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| Kojto | 122:f9eeca106725 | 34 | POSSIBILITY OF SUCH DAMAGE. |
| Kojto | 122:f9eeca106725 | 35 | ---------------------------------------------------------------------------*/ |
| Kojto | 122:f9eeca106725 | 36 | |
| Kojto | 122:f9eeca106725 | 37 | |
| Kojto | 122:f9eeca106725 | 38 | #ifndef __CORE_CM_SECURE_ACCESS_H |
| Kojto | 122:f9eeca106725 | 39 | #define __CORE_CM_SECURE_ACCESS_H |
| Kojto | 122:f9eeca106725 | 40 | |
| Kojto | 122:f9eeca106725 | 41 | |
| Kojto | 122:f9eeca106725 | 42 | /* ########################### Core Secure Access ########################### */ |
| Kojto | 122:f9eeca106725 | 43 | |
| Kojto | 122:f9eeca106725 | 44 | #ifdef FEATURE_UVISOR |
| Kojto | 122:f9eeca106725 | 45 | #include "uvisor-lib.h" |
| Kojto | 122:f9eeca106725 | 46 | |
| Kojto | 122:f9eeca106725 | 47 | /* Secure uVisor implementation. */ |
| Kojto | 122:f9eeca106725 | 48 | |
| Kojto | 122:f9eeca106725 | 49 | /** Set the value at the target address. |
| Kojto | 122:f9eeca106725 | 50 | * |
| Kojto | 122:f9eeca106725 | 51 | * Equivalent to: `*address = value`. |
| Kojto | 122:f9eeca106725 | 52 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 53 | * @param value[in] Value to write at the address location. |
| Kojto | 122:f9eeca106725 | 54 | */ |
| Kojto | 122:f9eeca106725 | 55 | #define SECURE_WRITE(address, value) \ |
| Kojto | 122:f9eeca106725 | 56 | uvisor_write(main, UVISOR_RGW_SHARED, address, value, UVISOR_RGW_OP_WRITE, 0xFFFFFFFFUL) |
| Kojto | 122:f9eeca106725 | 57 | |
| Kojto | 122:f9eeca106725 | 58 | /** Get the value at the target address. |
| Kojto | 122:f9eeca106725 | 59 | * |
| Kojto | 122:f9eeca106725 | 60 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 61 | * @returns The value `*address`. |
| Kojto | 122:f9eeca106725 | 62 | */ |
| Kojto | 122:f9eeca106725 | 63 | #define SECURE_READ(address) \ |
| Kojto | 122:f9eeca106725 | 64 | uvisor_read(main, UVISOR_RGW_SHARED, address, UVISOR_RGW_OP_READ, 0xFFFFFFFFUL) |
| Kojto | 122:f9eeca106725 | 65 | |
| Kojto | 122:f9eeca106725 | 66 | /** Get the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 67 | * |
| Kojto | 122:f9eeca106725 | 68 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 69 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 70 | * @returns The value `*address & mask`. |
| Kojto | 122:f9eeca106725 | 71 | */ |
| Kojto | 122:f9eeca106725 | 72 | #define SECURE_BITS_GET(address, mask) \ |
| Kojto | 122:f9eeca106725 | 73 | UVISOR_BITS_GET(main, UVISOR_RGW_SHARED, address, mask) |
| Kojto | 122:f9eeca106725 | 74 | |
| Kojto | 122:f9eeca106725 | 75 | /** Check the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 76 | * |
| Kojto | 122:f9eeca106725 | 77 | * @param address[in] Address at which to check the bits |
| Kojto | 122:f9eeca106725 | 78 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 79 | * @returns The value `((*address & mask) == mask)`. |
| Kojto | 122:f9eeca106725 | 80 | */ |
| Kojto | 122:f9eeca106725 | 81 | #define SECURE_BITS_CHECK(address, mask) \ |
| Kojto | 122:f9eeca106725 | 82 | UVISOR_BITS_CHECK(main, UVISOR_RGW_SHARED, address, mask) |
| Kojto | 122:f9eeca106725 | 83 | |
| Kojto | 122:f9eeca106725 | 84 | /** Set the selected bits to 1 at the target address. |
| Kojto | 122:f9eeca106725 | 85 | * |
| Kojto | 122:f9eeca106725 | 86 | * Equivalent to: `*address |= mask`. |
| Kojto | 122:f9eeca106725 | 87 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 88 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 89 | */ |
| Kojto | 122:f9eeca106725 | 90 | #define SECURE_BITS_SET(address, mask) \ |
| Kojto | 122:f9eeca106725 | 91 | UVISOR_BITS_SET(main, UVISOR_RGW_SHARED, address, mask) |
| Kojto | 122:f9eeca106725 | 92 | |
| Kojto | 122:f9eeca106725 | 93 | /** Clear the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 94 | * |
| Kojto | 122:f9eeca106725 | 95 | * Equivalent to: `*address &= ~mask`. |
| Kojto | 122:f9eeca106725 | 96 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 97 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 98 | */ |
| Kojto | 122:f9eeca106725 | 99 | #define SECURE_BITS_CLEAR(address, mask) \ |
| Kojto | 122:f9eeca106725 | 100 | UVISOR_BITS_CLEAR(main, UVISOR_RGW_SHARED, address, mask) |
| Kojto | 122:f9eeca106725 | 101 | |
| Kojto | 122:f9eeca106725 | 102 | /** Set the selected bits at the target address to the given value. |
| Kojto | 122:f9eeca106725 | 103 | * |
| Kojto | 122:f9eeca106725 | 104 | * Equivalent to: `*address = (*address & ~mask) | (value & mask)`. |
| Kojto | 122:f9eeca106725 | 105 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 106 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 107 | * @param value[in] Value to write at the address location. Note: The value |
| Kojto | 122:f9eeca106725 | 108 | * must be already shifted to the correct bit position |
| Kojto | 122:f9eeca106725 | 109 | */ |
| Kojto | 122:f9eeca106725 | 110 | #define SECURE_BITS_SET_VALUE(address, mask, value) \ |
| Kojto | 122:f9eeca106725 | 111 | UVISOR_BITS_SET_VALUE(main, UVISOR_RGW_SHARED, address, mask, value) |
| Kojto | 122:f9eeca106725 | 112 | |
| Kojto | 122:f9eeca106725 | 113 | /** Toggle the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 114 | * |
| Kojto | 122:f9eeca106725 | 115 | * Equivalent to: `*address ^= mask`. |
| Kojto | 122:f9eeca106725 | 116 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 117 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 118 | */ |
| Kojto | 122:f9eeca106725 | 119 | #define SECURE_BITS_TOGGLE(address, mask) \ |
| Kojto | 122:f9eeca106725 | 120 | UVISOR_BITS_TOGGLE(main, UVISOR_RGW_SHARED, address, mask) |
| Kojto | 122:f9eeca106725 | 121 | |
| Kojto | 122:f9eeca106725 | 122 | #else |
| Kojto | 122:f9eeca106725 | 123 | |
| Kojto | 122:f9eeca106725 | 124 | /* Insecure fallback implementation. */ |
| Kojto | 122:f9eeca106725 | 125 | |
| Kojto | 122:f9eeca106725 | 126 | /** Set the value at the target address. |
| Kojto | 122:f9eeca106725 | 127 | * |
| Kojto | 122:f9eeca106725 | 128 | * Equivalent to: `*address = value`. |
| Kojto | 122:f9eeca106725 | 129 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 130 | * @param value[in] Value to write at the address location. |
| Kojto | 122:f9eeca106725 | 131 | */ |
| Kojto | 122:f9eeca106725 | 132 | #define SECURE_WRITE(address, value) \ |
| Kojto | 122:f9eeca106725 | 133 | *(address) = (value) |
| Kojto | 122:f9eeca106725 | 134 | |
| Kojto | 122:f9eeca106725 | 135 | /** Get the value at the target address. |
| Kojto | 122:f9eeca106725 | 136 | * |
| Kojto | 122:f9eeca106725 | 137 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 138 | * @returns The value `*address`. |
| Kojto | 122:f9eeca106725 | 139 | */ |
| Kojto | 122:f9eeca106725 | 140 | #define SECURE_READ(address) \ |
| Kojto | 122:f9eeca106725 | 141 | (*(address)) |
| Kojto | 122:f9eeca106725 | 142 | |
| Kojto | 122:f9eeca106725 | 143 | /** Get the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 144 | * |
| Kojto | 122:f9eeca106725 | 145 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 146 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 147 | * @returns The value `*address & mask`. |
| Kojto | 122:f9eeca106725 | 148 | */ |
| Kojto | 122:f9eeca106725 | 149 | #define SECURE_BITS_GET(address, mask) \ |
| Kojto | 122:f9eeca106725 | 150 | (*(address) & (mask)) |
| Kojto | 122:f9eeca106725 | 151 | |
| Kojto | 122:f9eeca106725 | 152 | /** Check the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 153 | * |
| Kojto | 122:f9eeca106725 | 154 | * @param address[in] Address at which to check the bits |
| Kojto | 122:f9eeca106725 | 155 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 156 | * @returns The value `((*address & mask) == mask)`. |
| Kojto | 122:f9eeca106725 | 157 | */ |
| Kojto | 122:f9eeca106725 | 158 | #define SECURE_BITS_CHECK(address, mask) \ |
| Kojto | 122:f9eeca106725 | 159 | ((*(address) & (mask)) == (mask)) |
| Kojto | 122:f9eeca106725 | 160 | |
| Kojto | 122:f9eeca106725 | 161 | /** Set the selected bits to 1 at the target address. |
| Kojto | 122:f9eeca106725 | 162 | * |
| Kojto | 122:f9eeca106725 | 163 | * Equivalent to: `*address |= mask`. |
| Kojto | 122:f9eeca106725 | 164 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 165 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 166 | */ |
| Kojto | 122:f9eeca106725 | 167 | #define SECURE_BITS_SET(address, mask) \ |
| Kojto | 122:f9eeca106725 | 168 | *(address) |= (mask) |
| Kojto | 122:f9eeca106725 | 169 | |
| Kojto | 122:f9eeca106725 | 170 | /** Clear the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 171 | * |
| Kojto | 122:f9eeca106725 | 172 | * Equivalent to: `*address &= ~mask`. |
| Kojto | 122:f9eeca106725 | 173 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 174 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 175 | */ |
| Kojto | 122:f9eeca106725 | 176 | #define SECURE_BITS_CLEAR(address, mask) \ |
| Kojto | 122:f9eeca106725 | 177 | *(address) &= ~(mask) |
| Kojto | 122:f9eeca106725 | 178 | |
| Kojto | 122:f9eeca106725 | 179 | /** Set the selected bits at the target address to the given value. |
| Kojto | 122:f9eeca106725 | 180 | * |
| Kojto | 122:f9eeca106725 | 181 | * Equivalent to: `*address = (*address & ~mask) | (value & mask)`. |
| Kojto | 122:f9eeca106725 | 182 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 183 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 184 | * @param value[in] Value to write at the address location. Note: The value |
| Kojto | 122:f9eeca106725 | 185 | * must be already shifted to the correct bit position |
| Kojto | 122:f9eeca106725 | 186 | */ |
| Kojto | 122:f9eeca106725 | 187 | #define SECURE_BITS_SET_VALUE(address, mask, value) \ |
| Kojto | 122:f9eeca106725 | 188 | *(address) = (*(address) & ~(mask)) | ((value) & (mask)) |
| Kojto | 122:f9eeca106725 | 189 | |
| Kojto | 122:f9eeca106725 | 190 | /** Toggle the selected bits at the target address. |
| Kojto | 122:f9eeca106725 | 191 | * |
| Kojto | 122:f9eeca106725 | 192 | * Equivalent to: `*address ^= mask`. |
| Kojto | 122:f9eeca106725 | 193 | * @param address[in] Target address |
| Kojto | 122:f9eeca106725 | 194 | * @param mask[in] Bits to select out of the target address |
| Kojto | 122:f9eeca106725 | 195 | */ |
| Kojto | 122:f9eeca106725 | 196 | #define SECURE_BITS_TOGGLE(address, mask) \ |
| Kojto | 122:f9eeca106725 | 197 | *(address) ^= (mask) |
| Kojto | 122:f9eeca106725 | 198 | |
| Kojto | 122:f9eeca106725 | 199 | #endif |
| Kojto | 122:f9eeca106725 | 200 | |
| Kojto | 122:f9eeca106725 | 201 | #endif /* __CORE_CM_SECURE_ACCESS_H */ |
