forked
Embed:
(wiki syntax)
Show/hide line numbers
core_cmSecureAccess.h
Go to the documentation of this file.
00001 /**************************************************************************//** 00002 * @file core_cmSecureAccess.h 00003 * @brief CMSIS Cortex-M Core Secure Access Header File 00004 * @version XXX 00005 * @date 10. June 2016 00006 * 00007 * @note 00008 * 00009 ******************************************************************************/ 00010 /* Copyright (c) 2016 ARM LIMITED 00011 00012 All rights reserved. 00013 Redistribution and use in source and binary forms, with or without 00014 modification, are permitted provided that the following conditions are met: 00015 - Redistributions of source code must retain the above copyright 00016 notice, this list of conditions and the following disclaimer. 00017 - Redistributions in binary form must reproduce the above copyright 00018 notice, this list of conditions and the following disclaimer in the 00019 documentation and/or other materials provided with the distribution. 00020 - Neither the name of ARM nor the names of its contributors may be used 00021 to endorse or promote products derived from this software without 00022 specific prior written permission. 00023 * 00024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00027 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE 00028 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00029 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00030 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00031 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00032 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00033 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 POSSIBILITY OF SUCH DAMAGE. 00035 ---------------------------------------------------------------------------*/ 00036 00037 00038 #ifndef __CORE_CM_SECURE_ACCESS_H 00039 #define __CORE_CM_SECURE_ACCESS_H 00040 00041 00042 /* ########################### Core Secure Access ########################### */ 00043 00044 #ifdef FEATURE_UVISOR 00045 #include "uvisor-lib/uvisor-lib.h" 00046 00047 /* Secure uVisor implementation. */ 00048 00049 /** Set the value at the target address. 00050 * 00051 * Equivalent to: `*address = value`. 00052 * @param address[in] Target address 00053 * @param value[in] Value to write at the address location. 00054 */ 00055 #define SECURE_WRITE(address, value) \ 00056 uvisor_write(public_box, UVISOR_RGW_SHARED, address, value, UVISOR_RGW_OP_WRITE, 0xFFFFFFFFUL) 00057 00058 /** Get the value at the target address. 00059 * 00060 * @param address[in] Target address 00061 * @returns The value `*address`. 00062 */ 00063 #define SECURE_READ(address) \ 00064 uvisor_read(public_box, UVISOR_RGW_SHARED, address, UVISOR_RGW_OP_READ, 0xFFFFFFFFUL) 00065 00066 /** Get the selected bits at the target address. 00067 * 00068 * @param address[in] Target address 00069 * @param mask[in] Bits to select out of the target address 00070 * @returns The value `*address & mask`. 00071 */ 00072 #define SECURE_BITS_GET(address, mask) \ 00073 UVISOR_BITS_GET(public_box, UVISOR_RGW_SHARED, address, mask) 00074 00075 /** Check the selected bits at the target address. 00076 * 00077 * @param address[in] Address at which to check the bits 00078 * @param mask[in] Bits to select out of the target address 00079 * @returns The value `((*address & mask) == mask)`. 00080 */ 00081 #define SECURE_BITS_CHECK(address, mask) \ 00082 UVISOR_BITS_CHECK(public_box, UVISOR_RGW_SHARED, address, mask) 00083 00084 /** Set the selected bits to 1 at the target address. 00085 * 00086 * Equivalent to: `*address |= mask`. 00087 * @param address[in] Target address 00088 * @param mask[in] Bits to select out of the target address 00089 */ 00090 #define SECURE_BITS_SET(address, mask) \ 00091 UVISOR_BITS_SET(public_box, UVISOR_RGW_SHARED, address, mask) 00092 00093 /** Clear the selected bits at the target address. 00094 * 00095 * Equivalent to: `*address &= ~mask`. 00096 * @param address[in] Target address 00097 * @param mask[in] Bits to select out of the target address 00098 */ 00099 #define SECURE_BITS_CLEAR(address, mask) \ 00100 UVISOR_BITS_CLEAR(public_box, UVISOR_RGW_SHARED, address, mask) 00101 00102 /** Set the selected bits at the target address to the given value. 00103 * 00104 * Equivalent to: `*address = (*address & ~mask) | (value & mask)`. 00105 * @param address[in] Target address 00106 * @param mask[in] Bits to select out of the target address 00107 * @param value[in] Value to write at the address location. Note: The value 00108 * must be already shifted to the correct bit position 00109 */ 00110 #define SECURE_BITS_SET_VALUE(address, mask, value) \ 00111 UVISOR_BITS_SET_VALUE(public_box, UVISOR_RGW_SHARED, address, mask, value) 00112 00113 /** Toggle the selected bits at the target address. 00114 * 00115 * Equivalent to: `*address ^= mask`. 00116 * @param address[in] Target address 00117 * @param mask[in] Bits to select out of the target address 00118 */ 00119 #define SECURE_BITS_TOGGLE(address, mask) \ 00120 UVISOR_BITS_TOGGLE(public_box, UVISOR_RGW_SHARED, address, mask) 00121 00122 #else 00123 00124 /* Insecure fallback implementation. */ 00125 00126 /** Set the value at the target address. 00127 * 00128 * Equivalent to: `*address = value`. 00129 * @param address[in] Target address 00130 * @param value[in] Value to write at the address location. 00131 */ 00132 #define SECURE_WRITE(address, value) \ 00133 *(address) = (value) 00134 00135 /** Get the value at the target address. 00136 * 00137 * @param address[in] Target address 00138 * @returns The value `*address`. 00139 */ 00140 #define SECURE_READ(address) \ 00141 (*(address)) 00142 00143 /** Get the selected bits at the target address. 00144 * 00145 * @param address[in] Target address 00146 * @param mask[in] Bits to select out of the target address 00147 * @returns The value `*address & mask`. 00148 */ 00149 #define SECURE_BITS_GET(address, mask) \ 00150 (*(address) & (mask)) 00151 00152 /** Check the selected bits at the target address. 00153 * 00154 * @param address[in] Address at which to check the bits 00155 * @param mask[in] Bits to select out of the target address 00156 * @returns The value `((*address & mask) == mask)`. 00157 */ 00158 #define SECURE_BITS_CHECK(address, mask) \ 00159 ((*(address) & (mask)) == (mask)) 00160 00161 /** Set the selected bits to 1 at the target address. 00162 * 00163 * Equivalent to: `*address |= mask`. 00164 * @param address[in] Target address 00165 * @param mask[in] Bits to select out of the target address 00166 */ 00167 #define SECURE_BITS_SET(address, mask) \ 00168 *(address) |= (mask) 00169 00170 /** Clear the selected bits at the target address. 00171 * 00172 * Equivalent to: `*address &= ~mask`. 00173 * @param address[in] Target address 00174 * @param mask[in] Bits to select out of the target address 00175 */ 00176 #define SECURE_BITS_CLEAR(address, mask) \ 00177 *(address) &= ~(mask) 00178 00179 /** Set the selected bits at the target address to the given value. 00180 * 00181 * Equivalent to: `*address = (*address & ~mask) | (value & mask)`. 00182 * @param address[in] Target address 00183 * @param mask[in] Bits to select out of the target address 00184 * @param value[in] Value to write at the address location. Note: The value 00185 * must be already shifted to the correct bit position 00186 */ 00187 #define SECURE_BITS_SET_VALUE(address, mask, value) \ 00188 *(address) = (*(address) & ~(mask)) | ((value) & (mask)) 00189 00190 /** Toggle the selected bits at the target address. 00191 * 00192 * Equivalent to: `*address ^= mask`. 00193 * @param address[in] Target address 00194 * @param mask[in] Bits to select out of the target address 00195 */ 00196 #define SECURE_BITS_TOGGLE(address, mask) \ 00197 *(address) ^= (mask) 00198 00199 #endif 00200 00201 #endif /* __CORE_CM_SECURE_ACCESS_H */
Generated on Tue Jul 12 2022 16:02:32 by 1.7.2