1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include "los_config.h" 33 #include "los_task.h" 34 #include "los_queue.h" 35 #include "los_memory.h" 36 #include "los_arch_interrupt.h" 37 38 #ifdef __cplusplus 39 #if __cplusplus 40 extern "C" { 41 #endif /* __cplusplus */ 42 #endif /* __cplusplus */ 43 44 #if (LOSCFG_PLATFORM_EXC == 1) 45 #define INFO_TYPE_AND_SIZE 8 46 47 #define MAX_SCENE_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(ExcInfo) + sizeof(EXC_CONTEXT_S)) 48 #define MAX_TSK_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1)) 49 50 #if (LOSCFG_BASE_IPC_QUEUE == 1) 51 #define MAX_QUEUE_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT) 52 #else 53 #define MAX_QUEUE_INFO_SIZE (0) 54 #endif 55 56 #if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1) 57 #define MAX_SWITCH_INFO_SIZE (INFO_TYPE_AND_SIZE + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) \ 58 * OS_TASK_SWITCH_INFO_COUNT) 59 #else 60 #define MAX_SWITCH_INFO_SIZE (0) 61 #endif 62 63 #define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM) 64 #define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE \ 65 + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE) 66 67 typedef enum { 68 OS_EXC_TYPE_CONTEXT = 0, 69 OS_EXC_TYPE_TSK = 1, 70 OS_EXC_TYPE_QUE = 2, 71 OS_EXC_TYPE_NVIC = 3, 72 OS_EXC_TYPE_TSK_SWITCH = 4, 73 OS_EXC_TYPE_MEM = 5, 74 OS_EXC_TYPE_MAX = 6 75 } ExcInfoType; 76 77 typedef struct { 78 ExcInfoType flag; 79 UINT32 length; 80 ExcInfo info; 81 EXC_CONTEXT_S context; 82 } ExcContextInfoArray; 83 84 typedef struct { 85 ExcInfoType flag; 86 UINT32 length; 87 TSK_INFO_S taskInfo[LOSCFG_BASE_CORE_TSK_LIMIT + 1]; 88 } ExcTaskInfoArray; 89 90 typedef struct { 91 ExcInfoType flag; 92 UINT32 length; 93 QUEUE_INFO_S queueInfo[LOSCFG_BASE_CORE_TSK_LIMIT]; 94 } ExcQueueInfoArray; 95 96 typedef struct { 97 UINT32 totalLen; 98 ExcContextInfoArray excInfo; 99 ExcTaskInfoArray taskInfo; 100 ExcQueueInfoArray queueInfo; 101 } ExcMsgArray; 102 103 typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID *); 104 105 typedef struct { 106 ExcInfoType type; 107 UINT32 valid; 108 EXC_INFO_SAVE_CALLBACK fnExcInfoCb; 109 VOID *arg; 110 } ExcInfoArray; 111 112 VOID OsExcMsgDumpInit(VOID); 113 extern UINT8 g_excMsgArray[MAX_EXC_MEM_SIZE]; 114 #endif 115 116 #ifdef __cplusplus 117 #if __cplusplus 118 } 119 #endif /* __cplusplus */ 120 #endif /* __cplusplus */ 121