temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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