Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

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