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:
Mon Mar 19 15:30:13 2018 +0000
Revision:
162:dbaafcfe0e9d
mbed library. Release version 160

Who changed what in which revision?

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