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
box_config.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_BOX_CONFIG_H__ 00018 #define __UVISOR_API_BOX_CONFIG_H__ 00019 00020 #include "api/inc/uvisor_exports.h" 00021 #include "api/inc/page_allocator_exports.h" 00022 #include "api/inc/rpc_exports.h" 00023 #include <stddef.h> 00024 #include <stdint.h> 00025 00026 UVISOR_EXTERN const uint32_t __uvisor_mode; 00027 UVISOR_EXTERN void const * const main_cfg_ptr; 00028 00029 #define UVISOR_DISABLED 0 00030 #define UVISOR_PERMISSIVE 1 00031 #define UVISOR_ENABLED 2 00032 00033 #define UVISOR_SET_MODE(mode) \ 00034 UVISOR_SET_MODE_ACL_COUNT(mode, NULL, 0) 00035 00036 #define UVISOR_SET_MODE_ACL(mode, acl_list) \ 00037 UVISOR_SET_MODE_ACL_COUNT(mode, acl_list, UVISOR_ARRAY_COUNT(acl_list)) 00038 00039 #define UVISOR_SET_MODE_ACL_COUNT(mode, acl_list, acl_list_count) \ 00040 uint8_t __attribute__((section(".keep.uvisor.bss.boxes"), aligned(32))) __reserved_stack[UVISOR_STACK_BAND_SIZE]; \ 00041 \ 00042 UVISOR_EXTERN const uint32_t __uvisor_mode = (mode); \ 00043 \ 00044 static const __attribute__((section(".keep.uvisor.cfgtbl"), aligned(4))) UvisorBoxConfig main_cfg = { \ 00045 UVISOR_BOX_MAGIC, \ 00046 UVISOR_BOX_VERSION, \ 00047 0, \ 00048 0, \ 00049 sizeof(RtxBoxIndex), \ 00050 { \ 00051 0, \ 00052 sizeof(uvisor_rpc_outgoing_message_queue_t), \ 00053 sizeof(uvisor_rpc_incoming_message_queue_t), \ 00054 sizeof(uvisor_rpc_fn_group_queue_t), \ 00055 }, \ 00056 NULL, \ 00057 NULL, \ 00058 acl_list, \ 00059 acl_list_count \ 00060 }; \ 00061 \ 00062 UVISOR_EXTERN const __attribute__((section(".keep.uvisor.cfgtbl_ptr_first"), aligned(4))) void * const main_cfg_ptr = &main_cfg; 00063 00064 /* Creates a global page heap with at least `minimum_number_of_pages` each of size `page_size` in bytes. 00065 * The total page heap size is at least `minimum_number_of_pages * page_size`. */ 00066 #define UVISOR_SET_PAGE_HEAP(page_size, minimum_number_of_pages) \ 00067 const uint32_t __uvisor_page_size = (page_size); \ 00068 uint8_t __attribute__((section(".keep.uvisor.page_heap"))) \ 00069 main_page_heap_reserved[ (page_size) * (minimum_number_of_pages) ] 00070 00071 00072 /* this macro selects an overloaded macro (variable number of arguments) */ 00073 #define __UVISOR_BOX_MACRO(_1, _2, _3, _4, NAME, ...) NAME 00074 00075 #define __UVISOR_BOX_CONFIG(box_name, acl_list, acl_list_count, stack_size, context_size) \ 00076 \ 00077 uint8_t __attribute__((section(".keep.uvisor.bss.boxes"), aligned(32))) \ 00078 box_name ## _reserved[ \ 00079 UVISOR_STACK_SIZE_ROUND( \ 00080 ( \ 00081 (UVISOR_MIN_STACK(stack_size) + \ 00082 (context_size) + \ 00083 (__uvisor_box_heapsize) + \ 00084 sizeof(RtxBoxIndex) + \ 00085 sizeof(uvisor_rpc_outgoing_message_queue_t) + \ 00086 sizeof(uvisor_rpc_incoming_message_queue_t) + \ 00087 sizeof(uvisor_rpc_fn_group_queue_t) \ 00088 ) \ 00089 * 8) \ 00090 / 6)]; \ 00091 \ 00092 static const __attribute__((section(".keep.uvisor.cfgtbl"), aligned(4))) UvisorBoxConfig box_name ## _cfg = { \ 00093 UVISOR_BOX_MAGIC, \ 00094 UVISOR_BOX_VERSION, \ 00095 UVISOR_MIN_STACK(stack_size), \ 00096 __uvisor_box_heapsize, \ 00097 sizeof(RtxBoxIndex), \ 00098 { \ 00099 context_size, \ 00100 sizeof(uvisor_rpc_outgoing_message_queue_t), \ 00101 sizeof(uvisor_rpc_incoming_message_queue_t), \ 00102 sizeof(uvisor_rpc_fn_group_queue_t), \ 00103 }, \ 00104 __uvisor_box_lib_config, \ 00105 __uvisor_box_namespace, \ 00106 acl_list, \ 00107 acl_list_count \ 00108 }; \ 00109 \ 00110 UVISOR_EXTERN const __attribute__((section(".keep.uvisor.cfgtbl_ptr"), aligned(4))) void * const box_name ## _cfg_ptr = &box_name ## _cfg; 00111 00112 #define UVISOR_BOX_EXTERN(box_name) \ 00113 UVISOR_EXTERN const __attribute__((section(".keep.uvisor.cfgtbl_ptr"), aligned(4))) void * const box_name ## _cfg_ptr; 00114 00115 #define __UVISOR_BOX_CONFIG_NOCONTEXT(box_name, acl_list, stack_size) \ 00116 __UVISOR_BOX_CONFIG(box_name, acl_list, UVISOR_ARRAY_COUNT(acl_list), stack_size, 0) \ 00117 00118 #define __UVISOR_BOX_CONFIG_CONTEXT(box_name, acl_list, stack_size, context_type) \ 00119 __UVISOR_BOX_CONFIG(box_name, acl_list, UVISOR_ARRAY_COUNT(acl_list), stack_size, sizeof(context_type)) \ 00120 UVISOR_EXTERN context_type *const *const __uvisor_ps; 00121 00122 #define __UVISOR_BOX_CONFIG_NOACL(box_name, stack_size, context_type) \ 00123 __UVISOR_BOX_CONFIG(box_name, NULL, 0, stack_size, sizeof(context_type)) \ 00124 UVISOR_EXTERN context_type *const *const __uvisor_ps; 00125 00126 #define __UVISOR_BOX_CONFIG_NOACL_NOCONTEXT(box_name, stack_size) \ 00127 __UVISOR_BOX_CONFIG(box_name, NULL, 0, stack_size, 0) 00128 00129 #define UVISOR_BOX_CONFIG_ACL(...) \ 00130 __UVISOR_BOX_MACRO(__VA_ARGS__, __UVISOR_BOX_CONFIG_CONTEXT, \ 00131 __UVISOR_BOX_CONFIG_NOCONTEXT, \ 00132 __UVISOR_BOX_CONFIG_NOACL_NOCONTEXT)(__VA_ARGS__) 00133 00134 #define UVISOR_BOX_CONFIG_CTX(...) \ 00135 __UVISOR_BOX_MACRO(__VA_ARGS__, __UVISOR_BOX_CONFIG_CONTEXT, \ 00136 __UVISOR_BOX_CONFIG_NOACL, \ 00137 __UVISOR_BOX_CONFIG_NOACL_NOCONTEXT)(__VA_ARGS__) 00138 00139 #define UVISOR_BOX_CONFIG(...) \ 00140 UVISOR_BOX_CONFIG_ACL(__VA_ARGS__) 00141 00142 /* Use this macro before box defintion (for example, UVISOR_BOX_CONFIG) to 00143 * define the name of your box. If you don't want a name, use this macro with 00144 * box_namespace as NULL. */ 00145 #define UVISOR_BOX_NAMESPACE(box_namespace) \ 00146 static const char *const __uvisor_box_namespace = box_namespace 00147 00148 /* Use this macro before UVISOR_BOX_CONFIG to define the function the main 00149 * thread of your box will use for its body. If you don't want a main thread, 00150 * too bad: you have to have one. */ 00151 #define UVISOR_BOX_MAIN(function, priority, stack_size) \ 00152 static osThreadDef(function, priority, stack_size); \ 00153 static const void * const __uvisor_box_lib_config = osThread(function); 00154 00155 #define UVISOR_BOX_HEAPSIZE(heap_size) \ 00156 static const uint32_t __uvisor_box_heapsize = heap_size; 00157 00158 #define uvisor_ctx (*__uvisor_ps) 00159 00160 #endif /* __UVISOR_API_BOX_CONFIG_H__ */
Generated on Tue Jul 12 2022 11:02:33 by
1.7.2