Maxim nexpaq / nexpaq_dev
Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

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