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