Biomimetics MBED Library w/ Added Support for CAN3

Dependents:   CAN_TEST SPIne_Plus_DYNO_SENSORS SPIne_Plus_v2 SPIne_Plus_Dyno_v2

Committer:
adimmit
Date:
Tue Mar 09 20:33:24 2021 +0000
Revision:
3:993b4d6ff61e
Parent:
0:083111ae2a11
added CAN3

Who changed what in which revision?

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