Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
vmpu_exports.h
00001 /* 00002 * Copyright (c) 2013-2016, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #ifndef __UVISOR_API_VMPU_EXPORTS_H__ 00018 #define __UVISOR_API_VMPU_EXPORTS_H__ 00019 00020 #include "api/inc/uvisor_exports.h" 00021 #include "api/inc/pool_queue_exports.h" 00022 #include "api/inc/rpc_exports.h" 00023 #include <stdint.h> 00024 00025 /* The maximum box namespace length is 37 so that it is exactly big enough for 00026 * a human-readable hex string GUID (as formatted by RFC 4122) followed by a 00027 * terminating NULL. */ 00028 #define UVISOR_MAX_BOX_NAMESPACE_LENGTH 37 00029 00030 /* supervisor user access modes */ 00031 #define UVISOR_TACL_UEXECUTE 0x0001UL 00032 #define UVISOR_TACL_UWRITE 0x0002UL 00033 #define UVISOR_TACL_UREAD 0x0004UL 00034 #define UVISOR_TACL_UACL (UVISOR_TACL_UREAD |\ 00035 UVISOR_TACL_UWRITE |\ 00036 UVISOR_TACL_UEXECUTE) 00037 00038 /* supervisor access modes */ 00039 #define UVISOR_TACL_SEXECUTE 0x0008UL 00040 #define UVISOR_TACL_SWRITE 0x0010UL 00041 #define UVISOR_TACL_SREAD 0x0020UL 00042 #define UVISOR_TACL_SACL (UVISOR_TACL_SREAD |\ 00043 UVISOR_TACL_SWRITE |\ 00044 UVISOR_TACL_SEXECUTE) 00045 00046 #define UVISOR_TACL_EXECUTE (UVISOR_TACL_UEXECUTE |\ 00047 UVISOR_TACL_SEXECUTE) 00048 00049 /* all possible access control flags */ 00050 #define UVISOR_TACL_ACCESS (UVISOR_TACL_UACL |\ 00051 UVISOR_TACL_SACL) 00052 00053 /* various modes */ 00054 #define UVISOR_TACL_STACK 0x0040UL 00055 #define UVISOR_TACL_SIZE_ROUND_UP 0x0080UL 00056 #define UVISOR_TACL_SIZE_ROUND_DOWN 0x0100UL 00057 #define UVISOR_TACL_PERIPHERAL 0x0200UL 00058 #define UVISOR_TACL_SHARED 0x0400UL 00059 #define UVISOR_TACL_USER 0x0800UL 00060 #define UVISOR_TACL_IRQ 0x1000UL 00061 00062 #if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 00063 00064 #endif /* defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 */ 00065 00066 #define UVISOR_TACLDEF_SECURE_BSS (UVISOR_TACL_UREAD |\ 00067 UVISOR_TACL_UWRITE |\ 00068 UVISOR_TACL_SREAD |\ 00069 UVISOR_TACL_SWRITE |\ 00070 UVISOR_TACL_SIZE_ROUND_UP) 00071 00072 #define UVISOR_TACLDEF_SECURE_CONST (UVISOR_TACL_UREAD |\ 00073 UVISOR_TACL_SREAD |\ 00074 UVISOR_TACL_SIZE_ROUND_UP) 00075 00076 #define UVISOR_TACLDEF_DATA UVISOR_TACLDEF_SECURE_BSS 00077 00078 #define UVISOR_TACLDEF_PERIPH (UVISOR_TACL_PERIPHERAL |\ 00079 UVISOR_TACL_UREAD |\ 00080 UVISOR_TACL_UWRITE |\ 00081 UVISOR_TACL_SREAD |\ 00082 UVISOR_TACL_SWRITE |\ 00083 UVISOR_TACL_SIZE_ROUND_UP) 00084 00085 #define UVISOR_TACLDEF_STACK (UVISOR_TACL_STACK |\ 00086 UVISOR_TACL_UREAD |\ 00087 UVISOR_TACL_UWRITE |\ 00088 UVISOR_TACL_SREAD |\ 00089 UVISOR_TACL_SWRITE) 00090 00091 #define UVISOR_PAD32(x) (32 - (sizeof(x) & ~0x1FUL)) 00092 #define UVISOR_BOX_MAGIC 0x42CFB66FUL 00093 #define UVISOR_BOX_VERSION 100 00094 #define UVISOR_STACK_BAND_SIZE 128 00095 #define UVISOR_MEM_SIZE_ROUND(x) UVISOR_REGION_ROUND_UP(x) 00096 00097 #define UVISOR_MIN_STACK_SIZE 1024 00098 #define UVISOR_MIN_STACK(x) (((x) < UVISOR_MIN_STACK_SIZE) ? UVISOR_MIN_STACK_SIZE : (x)) 00099 00100 #if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 00101 00102 /** Round an address down to the closest 32-byte boundary. 00103 * @param address[in] The address to round. 00104 */ 00105 #define UVISOR_ROUND32_DOWN(address) ((address) & ~0x1FUL) 00106 00107 /** Round an address up to the closest 32-byte boundary. 00108 * @param address[in] The address to round. 00109 */ 00110 #define UVISOR_ROUND32_UP(address) UVISOR_ROUND32_DOWN((address) + 31UL) 00111 00112 00113 #if defined(ARCH_MPU_ARMv7M) 00114 #define UVISOR_REGION_ROUND_DOWN(x) ((x) & ~((1UL << UVISOR_REGION_BITS(x)) - 1)) 00115 #define UVISOR_REGION_ROUND_UP(x) (1UL << UVISOR_REGION_BITS(x)) 00116 #define UVISOR_STACK_SIZE_ROUND(x) UVISOR_REGION_ROUND_UP(x) 00117 #elif defined(ARCH_MPU_KINETIS) 00118 #define UVISOR_REGION_ROUND_DOWN(x) UVISOR_ROUND32_DOWN(x) 00119 #define UVISOR_REGION_ROUND_UP(x) UVISOR_ROUND32_UP(x) 00120 #define UVISOR_STACK_SIZE_ROUND(x) UVISOR_REGION_ROUND_UP((x) + (UVISOR_STACK_BAND_SIZE * 2)) 00121 #else 00122 #error "Unknown MPU architecture. uvisor: Check your Makefile. uvisor-lib: Check if uVisor is supported" 00123 #endif 00124 00125 #else /* defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 */ 00126 00127 #define UVISOR_REGION_ROUND_DOWN(x) (x) 00128 #define UVISOR_REGION_ROUND_UP(x) (x) 00129 #define UVISOR_STACK_SIZE_ROUND(x) (x) 00130 00131 #endif 00132 00133 #ifndef UVISOR_BOX_STACK_SIZE 00134 #define UVISOR_BOX_STACK_SIZE UVISOR_MIN_STACK_SIZE 00135 #endif/*UVISOR_BOX_STACK*/ 00136 00137 /* NOPs added for write buffering synchronization (2 are for dsb. 16bits) */ 00138 #define UVISOR_NOP_CNT (2 + 3) 00139 #define UVISOR_NOP_GROUP \ 00140 "dsb\n" \ 00141 "nop\n" \ 00142 "nop\n" \ 00143 "nop\n" 00144 00145 typedef uint32_t UvisorBoxAcl; 00146 00147 typedef struct { 00148 void * param1; 00149 uint32_t param2; 00150 UvisorBoxAcl acl; 00151 } UVISOR_PACKED UvisorBoxAclItem; 00152 00153 typedef struct { 00154 /* Contains user provided size of box context without guards of buffers. */ 00155 uint32_t context_size; 00156 /* Contains total memory used by the RPC queues (incl. management and pool). */ 00157 uint32_t rpc_outgoing_message_size; 00158 uint32_t rpc_incoming_message_size; 00159 uint32_t rpc_fn_group_size; 00160 } UVISOR_PACKED uvisor_sizes_t; 00161 00162 /* The number of additional bss sections per box bss. 00163 * The size of each section is stored in the box config, and uVisor core will 00164 * iterate over the box bss, split it into sections as defined by the size table 00165 * and assign a pointer to beginning of that section into the box index pointer table. 00166 */ 00167 #define UVISOR_BOX_INDEX_SIZE_COUNT (sizeof(uvisor_sizes_t) / sizeof(uint32_t)) 00168 00169 typedef struct { 00170 uint32_t magic; 00171 uint32_t version; 00172 00173 /* Box stack size includes stack guards and rounding buffer. */ 00174 uint32_t stack_size; 00175 /* Contains user provided size of box heap without guards of buffers. */ 00176 uint32_t heap_size; 00177 /* Contains the size of the index (must be at least sizeof(UvisorBoxIndex)). */ 00178 uint32_t index_size; 00179 00180 union { 00181 uint32_t bss_size[UVISOR_BOX_INDEX_SIZE_COUNT]; 00182 uvisor_sizes_t sizes; 00183 }; 00184 00185 /* Opaque-to-uVisor data that potentially contains uvisor-lib-specific or 00186 * OS-specific per-box configuration */ 00187 const void * const lib_config; 00188 00189 const char * box_namespace; 00190 const UvisorBoxAclItem * const acl_list; 00191 uint32_t acl_count; 00192 } UVISOR_PACKED UvisorBoxConfig; 00193 00194 typedef struct { 00195 union { 00196 void * bss_ptr[UVISOR_BOX_INDEX_SIZE_COUNT]; 00197 struct { 00198 /* Pointer to the user context */ 00199 void * ctx; 00200 /* Pointer to the RPC queues */ 00201 uvisor_rpc_outgoing_message_queue_t * rpc_outgoing_message_queue; 00202 uvisor_rpc_incoming_message_queue_t * rpc_incoming_message_queue; 00203 uvisor_rpc_fn_group_queue_t * rpc_fn_group_queue; 00204 }; 00205 }; 00206 /* Pointer to the box heap */ 00207 void * box_heap; 00208 /* Size of the box heap */ 00209 uint32_t box_heap_size; 00210 /* Pointer to the currently active heap. 00211 * This is set to `NULL` by uVisor, signalling to the user lib that the 00212 * box heap needs to be initialized before use! */ 00213 void * active_heap; 00214 00215 /* Counter that helps to avoid waiting on the same RPC message result twice 00216 * by accident. */ 00217 uint32_t rpc_result_counter; 00218 00219 /* Box ID */ 00220 int box_id_self; 00221 00222 /* Pointer to the box config */ 00223 const UvisorBoxConfig * config; 00224 } UVISOR_PACKED UvisorBoxIndex; 00225 00226 /* 00227 * only use this macro for rounding const values during compile time: 00228 * for variables please use uvisor_region_bits(x) instead 00229 */ 00230 #define UVISOR_REGION_BITS(x) (((x)<=32UL)?5:(((x)<=64UL)?\ 00231 6:(((x)<=128UL)?7:(((x)<=256UL)?8:(((x)<=512UL)?9:(((x)<=1024UL)?\ 00232 10:(((x)<=2048UL)?11:(((x)<=4096UL)?12:(((x)<=8192UL)?\ 00233 13:(((x)<=16384UL)?14:(((x)<=32768UL)?15:(((x)<=65536UL)?\ 00234 16:(((x)<=131072UL)?17:(((x)<=262144UL)?18:(((x)<=524288UL)?\ 00235 19:(((x)<=1048576UL)?20:(((x)<=2097152UL)?21:(((x)<=4194304UL)?\ 00236 22:(((x)<=8388608UL)?23:(((x)<=16777216UL)?24:(((x)<=33554432UL)?\ 00237 25:(((x)<=67108864UL)?26:(((x)<=134217728UL)?27:(((x)<=268435456UL)?\ 00238 28:(((x)<=536870912UL)?29:(((x)<=1073741824UL)?30:(((x)<=2147483648UL)?\ 00239 31:32))))))))))))))))))))))))))) 00240 00241 #if defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 00242 static UVISOR_FORCEINLINE int vmpu_bits(uint32_t size) 00243 { 00244 return 32 - __builtin_clz(size); 00245 } 00246 #endif /* defined(UVISOR_PRESENT) && UVISOR_PRESENT == 1 */ 00247 00248 #endif /* __UVISOR_API_VMPU_EXPORTS_H__ */
Generated on Tue Jul 12 2022 11:03:00 by
