guiguitant théo / Serre_POLYTEC_Lora

Dependencies:   mbed

Committer:
guiguitt
Date:
Thu Mar 28 09:26:33 2019 +0000
Revision:
0:3fc4a1072bca
programme LoRaWan

Who changed what in which revision?

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