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