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:
140:97feb9bacc10
Release 147 of the mbed library.

Who changed what in which revision?

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