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:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
124:2241e3a39974
Child:
136:ef9c61f8c49f
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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