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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
unsupported.h
00001 /* 00002 * Copyright (c) 2015-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_UNSUPPORTED_H__ 00018 #define __UVISOR_API_UNSUPPORTED_H__ 00019 00020 #include "uvisor/api/inc/uvisor_exports.h" 00021 #include <stddef.h> 00022 #include <stdint.h> 00023 00024 /* uVisor hook for unsupported platforms */ 00025 UVISOR_EXTERN void uvisor_init(void); 00026 00027 /******************************************************************************* 00028 * Re-definitions from: 00029 ******************************************************************************/ 00030 00031 /* uvisor-lib/box-config.h */ 00032 00033 UVISOR_EXTERN const uint32_t __uvisor_mode; 00034 00035 #define UVISOR_DISABLED 0 00036 00037 #define UVISOR_SET_MODE(mode) \ 00038 UVISOR_SET_MODE_ACL_COUNT(mode, NULL, 0) 00039 00040 #define UVISOR_SET_MODE_ACL(mode, acl_list) \ 00041 UVISOR_SET_MODE_ACL_COUNT(mode, acl_list, UVISOR_ARRAY_COUNT(acl_list)) 00042 00043 #define UVISOR_SET_MODE_ACL_COUNT(mode, acl_list, acl_list_count) \ 00044 UVISOR_EXTERN const uint32_t __uvisor_mode = UVISOR_DISABLED; \ 00045 static const void *main_acl = acl_list; \ 00046 extern const __attribute__((section(".keep.uvisor.cfgtbl_ptr_first"), aligned(4))) void * const main_cfg_ptr = &main_acl; 00047 00048 #define __UVISOR_BOX_CONFIG_NOCONTEXT(box_name, acl_list, stack_size) \ 00049 static const void *box_acl_ ## box_name = acl_list; \ 00050 extern const __attribute__((section(".keep.uvisor.cfgtbl_ptr"), aligned(4))) void * const box_name ## _cfg_ptr = &box_acl_ ## box_name; 00051 00052 #define __UVISOR_BOX_CONFIG_CONTEXT(box_name, acl_list, stack_size, context_type) \ 00053 context_type box_ctx_ ## box_name; \ 00054 context_type * const uvisor_ctx = &box_ctx_ ## box_name; \ 00055 static const void *box_acl_ ## box_name = acl_list; \ 00056 const __attribute__((section(".keep.uvisor.cfgtbl_ptr"), aligned(4))) volatile void *box_name ## _cfg_ptr = \ 00057 &box_acl_ ## box_name; 00058 00059 #define __UVISOR_BOX_MACRO(_1, _2, _3, _4, NAME, ...) NAME 00060 #define UVISOR_BOX_CONFIG(...) \ 00061 __UVISOR_BOX_MACRO(__VA_ARGS__, __UVISOR_BOX_CONFIG_CONTEXT, \ 00062 __UVISOR_BOX_CONFIG_NOCONTEXT)(__VA_ARGS__) 00063 00064 #define UVISOR_BOX_CONFIG_ACL(...) UVISOR_BOX_CONFIG(__VA_ARGS__) 00065 00066 #define UVISOR_BOX_CONFIG_CTX(...) UVISOR_BOX_CONFIG(__VA_ARGS__) 00067 00068 #define UVISOR_BOX_NAMESPACE(...) 00069 00070 #define UVISOR_BOX_HEAPSIZE(...) 00071 00072 /* uvisor-lib/interrupts.h */ 00073 00074 #define vIRQ_SetVector(irqn, vector) NVIC_SetVector((IRQn_Type) (irqn), (uint32_t) (vector)) 00075 #define vIRQ_GetVector(irqn) NVIC_GetVector((IRQn_Type) (irqn)) 00076 #define vIRQ_EnableIRQ(irqn) NVIC_EnableIRQ((IRQn_Type) (irqn)) 00077 #define vIRQ_DisableIRQ(irqn) NVIC_DisableIRQ((IRQn_Type) (irqn)) 00078 #define vIRQ_DisableAll __disable_irq 00079 #define vIRQ_EnableAll __enable_irq 00080 #define vIRQ_ClearPendingIRQ(irqn) NVIC_ClearPendingIRQ((IRQn_Type) (irqn)) 00081 #define vIRQ_SetPendingIRQ(irqn) NVIC_SetPendingIRQ((IRQn_Type) (irqn)) 00082 #define vIRQ_GetPendingIRQ(irqn) NVIC_GetPendingIRQ((IRQn_Type) (irqn)) 00083 #define vIRQ_SetPriority(irqn, priority) NVIC_SetPriority((IRQn_Type) (irqn), (uint32_t) (priority)) 00084 #define vIRQ_GetPriority(irqn) NVIC_GetPriority((IRQn_Type) (irqn)) 00085 00086 /* uvisor-lib/register_gateway.h */ 00087 00088 #define UVISOR_OP_READ(op) (op) 00089 #define UVISOR_OP_WRITE(op) ((1 << 4) | (op)) 00090 #define UVISOR_OP_NOP 0x0 00091 #define UVISOR_OP_AND 0x1 00092 #define UVISOR_OP_OR 0x2 00093 #define UVISOR_OP_XOR 0x3 00094 00095 /* Default mask for whole register operatins */ 00096 #define __UVISOR_OP_DEFAULT_MASK 0x0 00097 00098 static UVISOR_FORCEINLINE uint32_t uvisor_read(uint32_t addr, uint32_t op, uint32_t mask) 00099 { 00100 switch(op) 00101 { 00102 case UVISOR_OP_READ(UVISOR_OP_NOP): 00103 return *((uint32_t *) addr); 00104 case UVISOR_OP_READ(UVISOR_OP_AND): 00105 return *((uint32_t *) addr) & mask; 00106 case UVISOR_OP_READ(UVISOR_OP_OR): 00107 return *((uint32_t *) addr) | mask; 00108 case UVISOR_OP_READ(UVISOR_OP_XOR): 00109 return *((uint32_t *) addr) ^ mask; 00110 default: 00111 /* FIXME */ 00112 return 0; 00113 } 00114 } 00115 00116 #define uvisor_read(addr) uvisor_read((uint32_t) (addr), UVISOR_OP_READ(UVISOR_OP_NOP), __UVISOR_OP_DEFAULT_MASK) 00117 00118 static UVISOR_FORCEINLINE void uvisor_write(uint32_t addr, uint32_t val, uint32_t op, uint32_t mask) 00119 { 00120 switch(op) 00121 { 00122 case UVISOR_OP_WRITE(UVISOR_OP_NOP): 00123 *((uint32_t *) addr) = val; 00124 case UVISOR_OP_WRITE(UVISOR_OP_AND): 00125 *((uint32_t *) addr) &= val | ~mask; 00126 case UVISOR_OP_WRITE(UVISOR_OP_OR): 00127 *((uint32_t *) addr) |= val & mask; 00128 case UVISOR_OP_WRITE(UVISOR_OP_XOR): 00129 *((uint32_t *) addr) ^= val & mask; 00130 default: 00131 /* FIXME */ 00132 return; 00133 } 00134 } 00135 00136 #define uvisor_write(addr, val) uvisor_write((uint32_t) (addr), (uint32_t) (val), \ 00137 UVISOR_OP_WRITE(UVISOR_OP_NOP), __UVISOR_OP_DEFAULT_MASK) 00138 00139 /* uvisor-lib/secure_access.h */ 00140 00141 static UVISOR_FORCEINLINE void uvisor_write32(uint32_t volatile *addr, uint32_t val) 00142 { 00143 *(addr) = val; 00144 } 00145 00146 static UVISOR_FORCEINLINE void uvisor_write16(uint16_t volatile *addr, uint16_t val) 00147 { 00148 *(addr) = val; 00149 } 00150 00151 static UVISOR_FORCEINLINE void uvisor_write8(uint8_t volatile *addr, uint8_t val) 00152 { 00153 *(addr) = val; 00154 } 00155 00156 static UVISOR_FORCEINLINE uint32_t uvisor_read32(uint32_t volatile *addr) 00157 { 00158 return *(addr); 00159 } 00160 00161 static UVISOR_FORCEINLINE uint16_t uvisor_read16(uint16_t volatile *addr) 00162 { 00163 return *(addr); 00164 } 00165 00166 static UVISOR_FORCEINLINE uint8_t uvisor_read8(uint8_t volatile *addr) 00167 { 00168 return *(addr); 00169 } 00170 00171 /* The conditional statement will be optimised away since the compiler already 00172 * knows the sizeof(type). */ 00173 #define ADDRESS_READ(type, addr) \ 00174 (sizeof(type) == 4 ? uvisor_read32((volatile uint32_t *) (addr)) : \ 00175 sizeof(type) == 2 ? uvisor_read16((volatile uint16_t *) (addr)) : \ 00176 sizeof(type) == 1 ? uvisor_read8((volatile uint8_t *) (addr)) : 0) 00177 00178 /* The switch statement will be optimised away since the compiler already knows 00179 * the sizeof_type. */ 00180 static UVISOR_FORCEINLINE void __address_write(size_t sizeof_type, volatile uint32_t *addr, uint32_t val) 00181 { 00182 switch(sizeof_type) { 00183 case 4: 00184 uvisor_write32((volatile uint32_t *) addr, (uint32_t) val); 00185 break; 00186 case 2: 00187 uvisor_write16((volatile uint16_t *) addr, (uint16_t) val); 00188 break; 00189 case 1: 00190 uvisor_write8((volatile uint8_t *) addr, (uint8_t) val); 00191 break; 00192 } 00193 } 00194 00195 #define ADDRESS_WRITE(type, addr, val) __address_write(sizeof(type), (volatile uint32_t *) addr, (uint32_t) val) 00196 00197 #define UNION_READ(type, addr, fieldU, fieldB) ((*((volatile type *) (addr))).fieldB) 00198 00199 /* uvisor-lib/secure_gateway.h */ 00200 00201 #define secure_gateway(dst_box, dst_fn, ...) dst_fn(__VA_ARGS__) 00202 00203 #endif /* __UVISOR_API_UNSUPPORTED_H__ */
Generated on Tue Jul 12 2022 12:28:57 by
