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:
139:856d2700e60b
Updating mbed 2 version number

Who changed what in which revision?

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