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.

Committer:
Anna Bridge
Date:
Fri Apr 20 11:08:29 2018 +0100
Revision:
166:5aab5a7997ee
Parent:
165:d1b4690b3f8b
Updating mbed 2 version number

Who changed what in which revision?

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