The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_VBLUNO52/core_cmSecureAccess.h@157:e7ca05fa8600, 2017-11-09 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 09 11:14:10 2017 +0000
- Revision:
- 157:e7ca05fa8600
- Parent:
- 148:fd96258d940d
Release 155 of the mbed library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 148:fd96258d940d | 1 | /**************************************************************************//** |
Kojto | 148:fd96258d940d | 2 | * @file core_cmSecureAccess.h |
Kojto | 148:fd96258d940d | 3 | * @brief CMSIS Cortex-M Core Secure Access Header File |
Kojto | 148:fd96258d940d | 4 | * @version XXX |
Kojto | 148:fd96258d940d | 5 | * @date 10. June 2016 |
Kojto | 148:fd96258d940d | 6 | * |
Kojto | 148:fd96258d940d | 7 | * @note |
Kojto | 148:fd96258d940d | 8 | * |
Kojto | 148:fd96258d940d | 9 | ******************************************************************************/ |
Kojto | 148:fd96258d940d | 10 | /* Copyright (c) 2016 ARM LIMITED |
Kojto | 148:fd96258d940d | 11 | |
Kojto | 148:fd96258d940d | 12 | All rights reserved. |
Kojto | 148:fd96258d940d | 13 | Redistribution and use in source and binary forms, with or without |
Kojto | 148:fd96258d940d | 14 | modification, are permitted provided that the following conditions are met: |
Kojto | 148:fd96258d940d | 15 | - Redistributions of source code must retain the above copyright |
Kojto | 148:fd96258d940d | 16 | notice, this list of conditions and the following disclaimer. |
Kojto | 148:fd96258d940d | 17 | - Redistributions in binary form must reproduce the above copyright |
Kojto | 148:fd96258d940d | 18 | notice, this list of conditions and the following disclaimer in the |
Kojto | 148:fd96258d940d | 19 | documentation and/or other materials provided with the distribution. |
Kojto | 148:fd96258d940d | 20 | - Neither the name of ARM nor the names of its contributors may be used |
Kojto | 148:fd96258d940d | 21 | to endorse or promote products derived from this software without |
Kojto | 148:fd96258d940d | 22 | specific prior written permission. |
Kojto | 148:fd96258d940d | 23 | * |
Kojto | 148:fd96258d940d | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Kojto | 148:fd96258d940d | 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Kojto | 148:fd96258d940d | 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
Kojto | 148:fd96258d940d | 27 | ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
Kojto | 148:fd96258d940d | 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
Kojto | 148:fd96258d940d | 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
Kojto | 148:fd96258d940d | 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
Kojto | 148:fd96258d940d | 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
Kojto | 148:fd96258d940d | 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
Kojto | 148:fd96258d940d | 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
Kojto | 148:fd96258d940d | 34 | POSSIBILITY OF SUCH DAMAGE. |
Kojto | 148:fd96258d940d | 35 | ---------------------------------------------------------------------------*/ |
Kojto | 148:fd96258d940d | 36 | |
Kojto | 148:fd96258d940d | 37 | |
Kojto | 148:fd96258d940d | 38 | #ifndef __CORE_CM_SECURE_ACCESS_H |
Kojto | 148:fd96258d940d | 39 | #define __CORE_CM_SECURE_ACCESS_H |
Kojto | 148:fd96258d940d | 40 | |
Kojto | 148:fd96258d940d | 41 | |
Kojto | 148:fd96258d940d | 42 | /* ########################### Core Secure Access ########################### */ |
Kojto | 148:fd96258d940d | 43 | |
Kojto | 148:fd96258d940d | 44 | #ifdef FEATURE_UVISOR |
Kojto | 148:fd96258d940d | 45 | #include "uvisor-lib/uvisor-lib.h" |
Kojto | 148:fd96258d940d | 46 | |
Kojto | 148:fd96258d940d | 47 | /* Secure uVisor implementation. */ |
Kojto | 148:fd96258d940d | 48 | |
Kojto | 148:fd96258d940d | 49 | /** Set the value at the target address. |
Kojto | 148:fd96258d940d | 50 | * |
Kojto | 148:fd96258d940d | 51 | * Equivalent to: `*address = value`. |
Kojto | 148:fd96258d940d | 52 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 53 | * @param value[in] Value to write at the address location. |
Kojto | 148:fd96258d940d | 54 | */ |
Kojto | 148:fd96258d940d | 55 | #define SECURE_WRITE(address, value) \ |
Kojto | 148:fd96258d940d | 56 | uvisor_write(public_box, UVISOR_RGW_SHARED, address, value, UVISOR_RGW_OP_WRITE, 0xFFFFFFFFUL) |
Kojto | 148:fd96258d940d | 57 | |
Kojto | 148:fd96258d940d | 58 | /** Get the value at the target address. |
Kojto | 148:fd96258d940d | 59 | * |
Kojto | 148:fd96258d940d | 60 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 61 | * @returns The value `*address`. |
Kojto | 148:fd96258d940d | 62 | */ |
Kojto | 148:fd96258d940d | 63 | #define SECURE_READ(address) \ |
Kojto | 148:fd96258d940d | 64 | uvisor_read(public_box, UVISOR_RGW_SHARED, address, UVISOR_RGW_OP_READ, 0xFFFFFFFFUL) |
Kojto | 148:fd96258d940d | 65 | |
Kojto | 148:fd96258d940d | 66 | /** Get the selected bits at the target address. |
Kojto | 148:fd96258d940d | 67 | * |
Kojto | 148:fd96258d940d | 68 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 69 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 70 | * @returns The value `*address & mask`. |
Kojto | 148:fd96258d940d | 71 | */ |
Kojto | 148:fd96258d940d | 72 | #define SECURE_BITS_GET(address, mask) \ |
Kojto | 148:fd96258d940d | 73 | UVISOR_BITS_GET(public_box, UVISOR_RGW_SHARED, address, mask) |
Kojto | 148:fd96258d940d | 74 | |
Kojto | 148:fd96258d940d | 75 | /** Check the selected bits at the target address. |
Kojto | 148:fd96258d940d | 76 | * |
Kojto | 148:fd96258d940d | 77 | * @param address[in] Address at which to check the bits |
Kojto | 148:fd96258d940d | 78 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 79 | * @returns The value `((*address & mask) == mask)`. |
Kojto | 148:fd96258d940d | 80 | */ |
Kojto | 148:fd96258d940d | 81 | #define SECURE_BITS_CHECK(address, mask) \ |
Kojto | 148:fd96258d940d | 82 | UVISOR_BITS_CHECK(public_box, UVISOR_RGW_SHARED, address, mask) |
Kojto | 148:fd96258d940d | 83 | |
Kojto | 148:fd96258d940d | 84 | /** Set the selected bits to 1 at the target address. |
Kojto | 148:fd96258d940d | 85 | * |
Kojto | 148:fd96258d940d | 86 | * Equivalent to: `*address |= mask`. |
Kojto | 148:fd96258d940d | 87 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 88 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 89 | */ |
Kojto | 148:fd96258d940d | 90 | #define SECURE_BITS_SET(address, mask) \ |
Kojto | 148:fd96258d940d | 91 | UVISOR_BITS_SET(public_box, UVISOR_RGW_SHARED, address, mask) |
Kojto | 148:fd96258d940d | 92 | |
Kojto | 148:fd96258d940d | 93 | /** Clear the selected bits at the target address. |
Kojto | 148:fd96258d940d | 94 | * |
Kojto | 148:fd96258d940d | 95 | * Equivalent to: `*address &= ~mask`. |
Kojto | 148:fd96258d940d | 96 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 97 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 98 | */ |
Kojto | 148:fd96258d940d | 99 | #define SECURE_BITS_CLEAR(address, mask) \ |
Kojto | 148:fd96258d940d | 100 | UVISOR_BITS_CLEAR(public_box, UVISOR_RGW_SHARED, address, mask) |
Kojto | 148:fd96258d940d | 101 | |
Kojto | 148:fd96258d940d | 102 | /** Set the selected bits at the target address to the given value. |
Kojto | 148:fd96258d940d | 103 | * |
Kojto | 148:fd96258d940d | 104 | * Equivalent to: `*address = (*address & ~mask) | (value & mask)`. |
Kojto | 148:fd96258d940d | 105 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 106 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 107 | * @param value[in] Value to write at the address location. Note: The value |
Kojto | 148:fd96258d940d | 108 | * must be already shifted to the correct bit position |
Kojto | 148:fd96258d940d | 109 | */ |
Kojto | 148:fd96258d940d | 110 | #define SECURE_BITS_SET_VALUE(address, mask, value) \ |
Kojto | 148:fd96258d940d | 111 | UVISOR_BITS_SET_VALUE(public_box, UVISOR_RGW_SHARED, address, mask, value) |
Kojto | 148:fd96258d940d | 112 | |
Kojto | 148:fd96258d940d | 113 | /** Toggle the selected bits at the target address. |
Kojto | 148:fd96258d940d | 114 | * |
Kojto | 148:fd96258d940d | 115 | * Equivalent to: `*address ^= mask`. |
Kojto | 148:fd96258d940d | 116 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 117 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 118 | */ |
Kojto | 148:fd96258d940d | 119 | #define SECURE_BITS_TOGGLE(address, mask) \ |
Kojto | 148:fd96258d940d | 120 | UVISOR_BITS_TOGGLE(public_box, UVISOR_RGW_SHARED, address, mask) |
Kojto | 148:fd96258d940d | 121 | |
Kojto | 148:fd96258d940d | 122 | #else |
Kojto | 148:fd96258d940d | 123 | |
Kojto | 148:fd96258d940d | 124 | /* Insecure fallback implementation. */ |
Kojto | 148:fd96258d940d | 125 | |
Kojto | 148:fd96258d940d | 126 | /** Set the value at the target address. |
Kojto | 148:fd96258d940d | 127 | * |
Kojto | 148:fd96258d940d | 128 | * Equivalent to: `*address = value`. |
Kojto | 148:fd96258d940d | 129 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 130 | * @param value[in] Value to write at the address location. |
Kojto | 148:fd96258d940d | 131 | */ |
Kojto | 148:fd96258d940d | 132 | #define SECURE_WRITE(address, value) \ |
Kojto | 148:fd96258d940d | 133 | *(address) = (value) |
Kojto | 148:fd96258d940d | 134 | |
Kojto | 148:fd96258d940d | 135 | /** Get the value at the target address. |
Kojto | 148:fd96258d940d | 136 | * |
Kojto | 148:fd96258d940d | 137 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 138 | * @returns The value `*address`. |
Kojto | 148:fd96258d940d | 139 | */ |
Kojto | 148:fd96258d940d | 140 | #define SECURE_READ(address) \ |
Kojto | 148:fd96258d940d | 141 | (*(address)) |
Kojto | 148:fd96258d940d | 142 | |
Kojto | 148:fd96258d940d | 143 | /** Get the selected bits at the target address. |
Kojto | 148:fd96258d940d | 144 | * |
Kojto | 148:fd96258d940d | 145 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 146 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 147 | * @returns The value `*address & mask`. |
Kojto | 148:fd96258d940d | 148 | */ |
Kojto | 148:fd96258d940d | 149 | #define SECURE_BITS_GET(address, mask) \ |
Kojto | 148:fd96258d940d | 150 | (*(address) & (mask)) |
Kojto | 148:fd96258d940d | 151 | |
Kojto | 148:fd96258d940d | 152 | /** Check the selected bits at the target address. |
Kojto | 148:fd96258d940d | 153 | * |
Kojto | 148:fd96258d940d | 154 | * @param address[in] Address at which to check the bits |
Kojto | 148:fd96258d940d | 155 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 156 | * @returns The value `((*address & mask) == mask)`. |
Kojto | 148:fd96258d940d | 157 | */ |
Kojto | 148:fd96258d940d | 158 | #define SECURE_BITS_CHECK(address, mask) \ |
Kojto | 148:fd96258d940d | 159 | ((*(address) & (mask)) == (mask)) |
Kojto | 148:fd96258d940d | 160 | |
Kojto | 148:fd96258d940d | 161 | /** Set the selected bits to 1 at the target address. |
Kojto | 148:fd96258d940d | 162 | * |
Kojto | 148:fd96258d940d | 163 | * Equivalent to: `*address |= mask`. |
Kojto | 148:fd96258d940d | 164 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 165 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 166 | */ |
Kojto | 148:fd96258d940d | 167 | #define SECURE_BITS_SET(address, mask) \ |
Kojto | 148:fd96258d940d | 168 | *(address) |= (mask) |
Kojto | 148:fd96258d940d | 169 | |
Kojto | 148:fd96258d940d | 170 | /** Clear the selected bits at the target address. |
Kojto | 148:fd96258d940d | 171 | * |
Kojto | 148:fd96258d940d | 172 | * Equivalent to: `*address &= ~mask`. |
Kojto | 148:fd96258d940d | 173 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 174 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 175 | */ |
Kojto | 148:fd96258d940d | 176 | #define SECURE_BITS_CLEAR(address, mask) \ |
Kojto | 148:fd96258d940d | 177 | *(address) &= ~(mask) |
Kojto | 148:fd96258d940d | 178 | |
Kojto | 148:fd96258d940d | 179 | /** Set the selected bits at the target address to the given value. |
Kojto | 148:fd96258d940d | 180 | * |
Kojto | 148:fd96258d940d | 181 | * Equivalent to: `*address = (*address & ~mask) | (value & mask)`. |
Kojto | 148:fd96258d940d | 182 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 183 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 184 | * @param value[in] Value to write at the address location. Note: The value |
Kojto | 148:fd96258d940d | 185 | * must be already shifted to the correct bit position |
Kojto | 148:fd96258d940d | 186 | */ |
Kojto | 148:fd96258d940d | 187 | #define SECURE_BITS_SET_VALUE(address, mask, value) \ |
Kojto | 148:fd96258d940d | 188 | *(address) = (*(address) & ~(mask)) | ((value) & (mask)) |
Kojto | 148:fd96258d940d | 189 | |
Kojto | 148:fd96258d940d | 190 | /** Toggle the selected bits at the target address. |
Kojto | 148:fd96258d940d | 191 | * |
Kojto | 148:fd96258d940d | 192 | * Equivalent to: `*address ^= mask`. |
Kojto | 148:fd96258d940d | 193 | * @param address[in] Target address |
Kojto | 148:fd96258d940d | 194 | * @param mask[in] Bits to select out of the target address |
Kojto | 148:fd96258d940d | 195 | */ |
Kojto | 148:fd96258d940d | 196 | #define SECURE_BITS_TOGGLE(address, mask) \ |
Kojto | 148:fd96258d940d | 197 | *(address) ^= (mask) |
Kojto | 148:fd96258d940d | 198 | |
Kojto | 148:fd96258d940d | 199 | #endif |
Kojto | 148:fd96258d940d | 200 | |
Kojto | 148:fd96258d940d | 201 | #endif /* __CORE_CM_SECURE_ACCESS_H */ |