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:
<>
Date:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
138:093f2bd7b9eb
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

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