The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Tue Feb 14 11:24:20 2017 +0000
Revision:
136:ef9c61f8c49f
Parent:
122:f9eeca106725
Child:
138:093f2bd7b9eb
Release 136 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3432: Target STM USBHOST support https://github.com/ARMmbed/mbed-os/pull/3432
3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now https://github.com/ARMmbed/mbed-os/pull/3181
3626: NUCLEO_F412ZG : Add USB Device +Host https://github.com/ARMmbed/mbed-os/pull/3626
3628: Fix warnings https://github.com/ARMmbed/mbed-os/pull/3628
3629: STM32: L0 LL layer https://github.com/ARMmbed/mbed-os/pull/3629
3632: IDE Export support for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3632
3642: Missing IRQ pin fix for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3642
3664: Fix ncs36510 sleep definitions https://github.com/ARMmbed/mbed-os/pull/3664
3655: [STM32F4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3655
3657: [STM32L4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3657
3658: [STM32F3] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3658
3685: STM32: I2C: reset state machine https://github.com/ARMmbed/mbed-os/pull/3685
3692: uVisor: Standardize available legacy heap and stack https://github.com/ARMmbed/mbed-os/pull/3692
3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron https://github.com/ARMmbed/mbed-os/pull/3621
3649: [STM32F7] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3649
3695: Enforce device_name is valid in targets.json https://github.com/ARMmbed/mbed-os/pull/3695
3723: NCS36510: spi_format function bug fix https://github.com/ARMmbed/mbed-os/pull/3723

Who changed what in which revision?

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