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:
AnnaBridge
Date:
Thu Sep 06 13:39:34 2018 +0100
Revision:
170:e95d10626187
Parent:
142:4eea097334d6
mbed library. Release version 163

Who changed what in which revision?

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