mbed library for slider v2

Dependents:   kl46z_slider_v2

Committer:
mturner5
Date:
Wed Sep 14 07:04:27 2016 +0000
Revision:
0:b7116bd48af6
Tried to use the timer.

Who changed what in which revision?

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