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:
mbed_official
Date:
Thu Dec 21 18:20:02 2017 +0000
Revision:
159:7130f322cb7e
mbed library version 157

Who changed what in which revision?

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