1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 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) * OS_TASK_SWITCH_INFO_COUNT) 58 #else 59 #define MAX_SWITCH_INFO_SIZE (0) 60 #endif 61 62 #define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM) 63 #define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE) 64 65 typedef enum { 66 OS_EXC_TYPE_CONTEXT = 0, 67 OS_EXC_TYPE_TSK = 1, 68 OS_EXC_TYPE_QUE = 2, 69 OS_EXC_TYPE_NVIC = 3, 70 OS_EXC_TYPE_TSK_SWITCH = 4, 71 OS_EXC_TYPE_MEM = 5, 72 OS_EXC_TYPE_MAX = 6 73 } ExcInfoType; 74 75 typedef struct { 76 ExcInfoType flag; 77 UINT32 length; 78 ExcInfo info; 79 EXC_CONTEXT_S context; 80 } ExcContextInfoArray; 81 82 typedef struct { 83 ExcInfoType flag; 84 UINT32 length; 85 TSK_INFO_S taskInfo[LOSCFG_BASE_CORE_TSK_LIMIT + 1]; 86 } ExcTaskInfoArray; 87 88 typedef struct { 89 ExcInfoType flag; 90 UINT32 length; 91 QUEUE_INFO_S queueInfo[LOSCFG_BASE_CORE_TSK_LIMIT]; 92 } ExcQueueInfoArray; 93 94 typedef struct { 95 UINT32 totalLen; 96 ExcContextInfoArray excInfo; 97 ExcTaskInfoArray taskInfo; 98 ExcQueueInfoArray queueInfo; 99 } ExcMsgArray; 100 101 typedef UINT32 (*EXC_INFO_SAVE_CALLBACK)(UINT32, VOID *); 102 103 typedef struct { 104 ExcInfoType type; 105 UINT32 valid; 106 EXC_INFO_SAVE_CALLBACK fnExcInfoCb; 107 VOID *arg; 108 } ExcInfoArray; 109 110 VOID OsExcMsgDumpInit(VOID); 111 extern UINT8 g_excMsgArray[MAX_EXC_MEM_SIZE]; 112 #endif 113 114 #ifdef __cplusplus 115 #if __cplusplus 116 } 117 #endif /* __cplusplus */ 118 #endif /* __cplusplus */ 119