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:
Kojto
Date:
Wed Jul 19 16:46:19 2017 +0100
Revision:
147:a97add6d7e64
Parent:
145:64910690c574
Release 147 of the mbed library.

Who changed what in which revision?

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