mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

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