From 53c4bf5ab787c984d0ee08ee3e5df3232f18b473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E8=B1=AA?= <2548632733@qq.com> Date: Mon, 22 Jan 2024 08:17:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debug/los_mux_deadlock.c | 257 -------- debug/los_mux_debug.c | 189 ------ debug/los_queue_debug.c | 206 ------ debug/los_sched_debug.c | 347 ---------- debug/los_sem_debug.c | 299 --------- 文豪-用例描述.docx | Bin 14105 -> 0 bytes 文豪/cppsupport/los_cppsupport.c | 74 --- 文豪/cpup/cpup_shellcmd.c | 134 ---- 文豪/cpup/los_cpup.c | 593 ------------------ 文豪/los_cppsupport_pri.h | 53 -- 文豪/los_cpup_pri.h | 74 --- 文豪/los_trace_pri.h | 150 ----- 文豪/trace/los_trace.c | 424 ------------- .../pipeline/serial/trace_pipeline_serial.c | 98 --- .../pipeline/serial/trace_pipeline_serial.h | 50 -- 文豪/trace/pipeline/trace_pipeline.c | 156 ----- 文豪/trace/pipeline/trace_pipeline.h | 104 --- 文豪/trace/pipeline/trace_tlv.c | 121 ---- 文豪/trace/pipeline/trace_tlv.h | 95 --- 文豪/trace/trace_offline.c | 264 -------- 文豪/trace/trace_online.c | 117 ---- 21 files changed, 3805 deletions(-) delete mode 100644 debug/los_mux_deadlock.c delete mode 100644 debug/los_mux_debug.c delete mode 100644 debug/los_queue_debug.c delete mode 100644 debug/los_sched_debug.c delete mode 100644 debug/los_sem_debug.c delete mode 100644 文豪-用例描述.docx delete mode 100644 文豪/cppsupport/los_cppsupport.c delete mode 100644 文豪/cpup/cpup_shellcmd.c delete mode 100644 文豪/cpup/los_cpup.c delete mode 100644 文豪/los_cppsupport_pri.h delete mode 100644 文豪/los_cpup_pri.h delete mode 100644 文豪/los_trace_pri.h delete mode 100644 文豪/trace/los_trace.c delete mode 100644 文豪/trace/pipeline/serial/trace_pipeline_serial.c delete mode 100644 文豪/trace/pipeline/serial/trace_pipeline_serial.h delete mode 100644 文豪/trace/pipeline/trace_pipeline.c delete mode 100644 文豪/trace/pipeline/trace_pipeline.h delete mode 100644 文豪/trace/pipeline/trace_tlv.c delete mode 100644 文豪/trace/pipeline/trace_tlv.h delete mode 100644 文豪/trace/trace_offline.c delete mode 100644 文豪/trace/trace_online.c diff --git a/debug/los_mux_deadlock.c b/debug/los_mux_deadlock.c deleted file mode 100644 index 6862541..0000000 --- a/debug/los_mux_deadlock.c +++ /dev/null @@ -1,257 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. - * Description: Mutex Deadlock Check - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_mux_debug_pri.h" -#include "los_typedef.h" -#include "los_task.h" -#include "arch/exception.h" -#ifdef LOSCFG_SHELL -#include "shcmd.h" -#endif /* LOSCFG_SHELL */ - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif /* __cplusplus */nbb - -typedef struct { - LOS_DL_LIST muxListHead; /* Task-held mutexs list */ //ڹеĻб// - UINT64 lastAccessTime; /* The last operation time */ //¼һβʱ// -} MuxDLinkCB; - -/*еĻб͸*/ -typedef struct { - LOS_DL_LIST muxList; /* Insert mutex into the owner task CB */ //ڽ뵽Ŀƿ// - VOID *muxCB; /* The Mutex CB pointer */ //ָ򻥳ƿָ// -} MuxDLinkNode; - -STATIC MuxDLinkCB *g_muxDeadlockCBArray = NULL; - -/* - * Mutex deadlock detection time threshold, will print out task information - * that has not been scheduled within this time. - * The unit is tick. - */ -#define OS_MUX_DEADLOCK_CHECK_THRESHOLD 60000 //μ黥֮СʱλΪ// - -UINT32 OsMuxDlockCheckInit(VOID) //ڷڴ沢ʼƿб// -{ - UINT32 index; - UINT32 size = (LOSCFG_BASE_CORE_TSK_LIMIT + 1) * sizeof(MuxDLinkCB); - - /* system resident memory, don't free */ - g_muxDeadlockCBArray = (MuxDLinkCB *)LOS_MemAlloc(m_aucSysMem1, size); - if (g_muxDeadlockCBArray == NULL) { - PRINT_ERR("%s: malloc failed!\n", __FUNCTION__); - return LOS_NOK; - } - - for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT + 1; index++) { - g_muxDeadlockCBArray[index].lastAccessTime = 0; - LOS_ListInit(&g_muxDeadlockCBArray[index].muxListHead); - } - return LOS_OK; -} - -VOID OsMuxDlockNodeInsert(UINT32 taskId, VOID *muxCB) //ָĻвһڵ// -{ - MuxDLinkNode *muxDLNode = NULL; - - if ((taskId > LOSCFG_BASE_CORE_TSK_LIMIT) || (muxCB == NULL)) { - return; - } - - muxDLNode = (MuxDLinkNode *)LOS_MemAlloc(m_aucSysMem1, sizeof(MuxDLinkNode)); - if (muxDLNode == NULL) { - return; - } - (VOID)memset_s(muxDLNode, sizeof(MuxDLinkNode), 0, sizeof(MuxDLinkNode)); - muxDLNode->muxCB = muxCB; - - LOS_ListTailInsert(&g_muxDeadlockCBArray[taskId].muxListHead, &muxDLNode->muxList); -} - -VOID OsMuxDlockNodeDelete(UINT32 taskId, const VOID *muxCB) //ڴָĻɾָĻڵ// -{ - MuxDLinkCB *muxDLCB = NULL; - LOS_DL_LIST *list = NULL; - MuxDLinkNode *muxDLNode = NULL; - - if ((taskId > LOSCFG_BASE_CORE_TSK_LIMIT) || (muxCB == NULL)) { - return; - } - - muxDLCB = &g_muxDeadlockCBArray[taskId]; - LOS_DL_LIST_FOR_EACH(list, &muxDLCB->muxListHead) { - muxDLNode = LOS_DL_LIST_ENTRY(list, MuxDLinkNode, muxList); - if (muxDLNode->muxCB == muxCB) { - LOS_ListDelete(&muxDLNode->muxList); - (VOID)LOS_MemFree(m_aucSysMem1, muxDLNode); - return; - } - } -} - -VOID OsTaskTimeUpdate(UINT32 taskId, UINT64 tickCount) //ڸʱ// -{ - if (taskId > LOSCFG_BASE_CORE_TSK_LIMIT) { - return; - } - - g_muxDeadlockCBArray[taskId].lastAccessTime = tickCount; -} - -STATIC VOID OsDeadlockBackTrace(const LosTaskCB *taskCB) //ڴӡĺջϢ// -{ - TaskContext *context = NULL; - - PRINTK("*******backtrace begin*******\n"); - context = (TaskContext *)taskCB->stackPointer; - ArchBackTraceWithSp(context); - PRINTK("********backtrace end********\n"); - return; -} - -STATIC VOID OsMutexPendTaskList(LOS_DL_LIST *list) //ڴӡȴбϢ// -{ - LOS_DL_LIST *listTmp = NULL; - LosTaskCB *pendedTask = NULL; - CHAR *name = NULL; - UINT32 index = 0; - UINT32 id, intSave; - - SCHEDULER_LOCK(intSave); - if (LOS_ListEmpty(list) == TRUE) { - SCHEDULER_UNLOCK(intSave); - PRINTK("Pended Task: null\n"); - return; - } - - LOS_DL_LIST_FOR_EACH(listTmp, list) { - pendedTask = OS_TCB_FROM_PENDLIST(listTmp); - name = pendedTask->taskName; - id = pendedTask->taskId; - SCHEDULER_UNLOCK(intSave); - if (index == 0) { - PRINTK("Pended task: %u. name:%-15s, id:0x%-5x\n", index, name, id); - } else { - PRINTK(" %u. name:%-15s, id:0x%-5x\n", index, name, id); - } - index++; - SCHEDULER_LOCK(intSave); - } - SCHEDULER_UNLOCK(intSave); -} - -STATIC VOID OsTaskHoldMutexList(MuxDLinkCB *muxDLCB) //ڴӡеĻϢ// -{ - UINT32 index = 0; - MuxDLinkNode *muxDLNode = NULL; - CHAR *ownerName = NULL; - LosMuxCB *muxCB = NULL; - LOS_DL_LIST *list = NULL; - LOS_DL_LIST *listTmp = NULL; - UINT32 count, intSave; - - SCHEDULER_LOCK(intSave); - if (LOS_ListEmpty(&muxDLCB->muxListHead) == TRUE) { - SCHEDULER_UNLOCK(intSave); - PRINTK("null\n"); - } else { - LOS_DL_LIST_FOR_EACH(list, &muxDLCB->muxListHead) { - muxDLNode = LOS_DL_LIST_ENTRY(list, MuxDLinkNode, muxList); - muxCB = (LosMuxCB *)muxDLNode->muxCB; - count = muxCB->muxCount; - ownerName = muxCB->owner->taskName; - SCHEDULER_UNLOCK(intSave); - PRINTK("\n", index); - PRINTK("Ptr handle:%p\n", muxCB); - PRINTK("Owner:%s\n", ownerName); - PRINTK("Count:%u\n", count); - - listTmp = &muxCB->muxList; - OsMutexPendTaskList(listTmp); - - index++; - SCHEDULER_LOCK(intSave); - } - SCHEDULER_UNLOCK(intSave); - } -} - -VOID OsMutexDlockCheck(VOID) //ڼ⻥Ϣ// -{ - UINT32 loop, intSave; - UINT32 taskId; - CHAR *name = NULL; - LosTaskCB *taskCB = NULL; - MuxDLinkCB *muxDLCB = NULL; - - SCHEDULER_LOCK(intSave); - for (loop = 0; loop < g_taskMaxNum; loop++) { - taskCB = (LosTaskCB *)g_taskCBArray + loop; - if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) { - continue; - } - - muxDLCB = &g_muxDeadlockCBArray[taskCB->taskId]; - if ((LOS_TickCountGet() - muxDLCB->lastAccessTime) > OS_MUX_DEADLOCK_CHECK_THRESHOLD) { - name = taskCB->taskName; - taskId = taskCB->taskId; - SCHEDULER_UNLOCK(intSave); - PRINTK("Task_name:%s, ID:0x%x, holds the Mutexs below:\n", name, taskId); - OsTaskHoldMutexList(muxDLCB); - OsDeadlockBackTrace(taskCB); - PRINTK("\n"); - SCHEDULER_LOCK(intSave); - } - } - SCHEDULER_UNLOCK(intSave); -} - -#ifdef LOSCFG_SHELL //ִл鲢Ϣ// -UINT32 OsShellCmdMuxDeadlockCheck(UINT32 argc, const CHAR **argv) -{ - if (argc > 0) { - PRINTK("\nUsage: dlock\n"); - return OS_ERROR; - } - PRINTK("Start mutexs deadlock check: \n"); - OsMutexDlockCheck(); - PRINTK("-----------End-----------\n"); - return LOS_OK; -} -SHELLCMD_ENTRY(deadlock_shellcmd, CMD_TYPE_EX, "dlock", 0, (CmdCallBackFunc)OsShellCmdMuxDeadlockCheck); -#endif /* LOSCFG_SHELL */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif /* __cplusplus */ diff --git a/debug/los_mux_debug.c b/debug/los_mux_debug.c deleted file mode 100644 index 5008bc5..0000000 --- a/debug/los_mux_debug.c +++ /dev/null @@ -1,189 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. - * Description: Mutex Debug - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_mux_debug_pri.h" -#include "los_typedef.h" -#include "los_task.h" -#include "los_misc_pri.h" -#include "arch/exception.h" -#ifdef LOSCFG_SHELL -#include "shcmd.h" -#endif /* LOSCFG_SHELL */ - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif /* __cplusplus */ - -#ifdef LOSCFG_DEBUG_MUTEX //ڱʾĵϢ// -typedef struct { - TSK_ENTRY_FUNC creator; /* The task entry who created this mutex */ - UINT64 lastAccessTime; /* The last access time */ -} MuxDebugCB; -STATIC MuxDebugCB *g_muxDebugArray = NULL; - -//ڱȽϢʱ// -STATIC BOOL MuxCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right) -{ - return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) > - *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right))); -} - -UINT32 OsMuxDbgInit(VOID) //ڳʼϢ// -{ - UINT32 size = LOSCFG_BASE_IPC_MUX_LIMIT * sizeof(MuxDebugCB); - /* system resident memory, don't free */ - g_muxDebugArray = (MuxDebugCB *)LOS_MemAlloc(m_aucSysMem1, size); - if (g_muxDebugArray == NULL) { - PRINT_ERR("%s: malloc failed!\n", __FUNCTION__); - return LOS_NOK; - } - (VOID)memset_s(g_muxDebugArray, size, 0, size); - return LOS_OK; -} - -VOID OsMuxDbgTimeUpdate(UINT32 muxId) //ڸָʱ// -{ - MuxDebugCB *muxDebug = &g_muxDebugArray[GET_MUX_INDEX(muxId)]; - muxDebug->lastAccessTime = LOS_TickCountGet(); -} - -VOID OsMuxDbgUpdate(UINT32 muxId, TSK_ENTRY_FUNC creator) //ڸָĴߺʱ// -{ - MuxDebugCB *muxDebug = &g_muxDebugArray[GET_MUX_INDEX(muxId)]; - muxDebug->creator = creator; - muxDebug->lastAccessTime = LOS_TickCountGet(); -} - -//ڶԻ򣬲ܴڵĻй©// -STATIC VOID SortMuxIndexArray(UINT32 *indexArray, UINT32 count) -{ - LosMuxCB muxNode = {{0, 0}, 0, 0, 0, 0}; - MuxDebugCB muxDebugNode = {0}; - UINT32 index, intSave; - SortParam muxSortParam; - muxSortParam.buf = (CHAR *)g_muxDebugArray; - muxSortParam.ctrlBlockSize = sizeof(MuxDebugCB); - muxSortParam.ctrlBlockCnt = LOSCFG_BASE_IPC_MUX_LIMIT; - muxSortParam.sortElemOff = LOS_OFF_SET_OF(MuxDebugCB, lastAccessTime); - - if (count > 0) { - SCHEDULER_LOCK(intSave); - OsArraySort(indexArray, 0, count - 1, &muxSortParam, MuxCompareValue); - SCHEDULER_UNLOCK(intSave); - for (index = 0; index < count; index++) { - SCHEDULER_LOCK(intSave); - (VOID)memcpy_s(&muxNode, sizeof(LosMuxCB), - GET_MUX(indexArray[index]), sizeof(LosMuxCB)); - (VOID)memcpy_s(&muxDebugNode, sizeof(MuxDebugCB), - &g_muxDebugArray[indexArray[index]], sizeof(MuxDebugCB)); - SCHEDULER_UNLOCK(intSave); - /* - * muxStat may be altered after the g_taskSpin is unlocked in OsMutexCheck. - * We should recheck the muxStat before the print. - */ - if ((muxNode.muxStat != LOS_USED) || - ((muxNode.muxStat == LOS_USED) && ((muxDebugNode.creator == NULL) || (muxNode.owner == NULL)))) { - continue; - } - PRINTK("Mutex ID <0x%x> may leak, TaskID of owner:0x%x, TaskEntry of owner: %p," - "TaskEntry of creator: %p,Latest operation time: 0x%llx\n", - muxNode.muxId, muxNode.owner->taskId, muxNode.owner->taskEntry, muxDebugNode.creator, - muxDebugNode.lastAccessTime); - } - } - (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray); -} - -VOID OsMutexCheck(VOID) //ڼ黥״̬ԿܴڵĻй©д// -{ - LosMuxCB muxNode = {{0, 0}, 0, 0, 0, 0}; - MuxDebugCB muxDebugNode = {0}; - UINT32 index, intSave; - UINT32 count = 0; - - /* - * This return value does not need to be judged immediately, - * and the following code logic has already distinguished the return value from null and non-empty, - * and there is no case of accessing the null pointer. - */ - UINT32 *indexArray = (UINT32 *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, LOSCFG_BASE_IPC_MUX_LIMIT * sizeof(UINT32)); - - for (index = 0; index < LOSCFG_BASE_IPC_MUX_LIMIT; index++) { - SCHEDULER_LOCK(intSave); - (VOID)memcpy_s(&muxNode, sizeof(LosMuxCB), GET_MUX(index), sizeof(LosMuxCB)); - (VOID)memcpy_s(&muxDebugNode, sizeof(MuxDebugCB), &g_muxDebugArray[index], sizeof(MuxDebugCB)); - SCHEDULER_UNLOCK(intSave); - - if ((muxNode.muxStat != LOS_USED) || - ((muxNode.muxStat == LOS_USED) && (muxDebugNode.creator == NULL))) { - continue; - } else if ((muxNode.muxStat == LOS_USED) && (muxNode.owner == NULL)) { - PRINTK("Mutex ID <0x%x> may leak, Owner is null, TaskEntry of creator: %p," - "Latest operation time: 0x%llx\n", - muxNode.muxId, muxDebugNode.creator, muxDebugNode.lastAccessTime); - } else { - if (indexArray != NULL) { - *(indexArray + count) = index; - count++; - } else { - PRINTK("Mutex ID <0x%x> may leak, TaskID of owner:0x%x, TaskEntry of owner: %p," - "TaskEntry of creator: %p,Latest operation time: 0x%llx\n", - muxNode.muxId, muxNode.owner->taskId, muxNode.owner->taskEntry, muxDebugNode.creator, - muxDebugNode.lastAccessTime); - } - } - } - - if (indexArray != NULL) { - SortMuxIndexArray(indexArray, count); - } -} - -#ifdef LOSCFG_SHELL -//ڻȡϢ// -LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMuxInfoGet(UINT32 argc, const CHAR **argv) -{ - if (argc > 0) { - PRINTK("\nUsage: mutex\n"); - return OS_ERROR; - } - PRINTK("used mutexs information: \n"); - OsMutexCheck(); - return LOS_OK; -} -SHELLCMD_ENTRY(mutex_shellcmd, CMD_TYPE_EX, "mutex", 0, (CmdCallBackFunc)OsShellCmdMuxInfoGet); -#endif /* LOSCFG_SHELL */ -#endif /* LOSCFG_DEBUG_MUTEX */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif /* __cplusplus */ diff --git a/debug/los_queue_debug.c b/debug/los_queue_debug.c deleted file mode 100644 index 43ba6ad..0000000 --- a/debug/los_queue_debug.c +++ /dev/null @@ -1,206 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. - * Description: Queue Debug - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_queue_debug_pri.h" -#include "los_misc_pri.h" -#ifdef LOSCFG_SHELL -#include "shcmd.h" -#endif /* LOSCFG_SHELL */ - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif /* __cplusplus */ - -#ifdef LOSCFG_DEBUG_QUEUE //ڱеĵϢ// -typedef struct { - TSK_ENTRY_FUNC creator; /* The task entry who created this queue */ - UINT64 lastAccessTime; /* The last access time */ -} QueueDebugCB; -STATIC QueueDebugCB *g_queueDebugArray = NULL; - -//ڱȽ϶еԪֵ// -STATIC BOOL QueueCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right) -{ - return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) > - *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right))); -} - -UINT32 OsQueueDbgInit(VOID) //ڳʼеĵϢ// -{ - UINT32 size = LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(QueueDebugCB); - - /* system resident memory, don't free */ - g_queueDebugArray = (QueueDebugCB *)LOS_MemAlloc(m_aucSysMem1, size); - if (g_queueDebugArray == NULL) { - PRINT_ERR("%s: malloc failed!\n", __FUNCTION__); - return LOS_NOK; - } - (VOID)memset_s(g_queueDebugArray, size, 0, size); - return LOS_OK; -} - -VOID OsQueueDbgTimeUpdate(UINT32 queueId) //ڸ¶еʱ// -{ - QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueId)]; - queueDebug->lastAccessTime = LOS_TickCountGet(); - return; -} - -VOID OsQueueDbgUpdate(UINT32 queueId, TSK_ENTRY_FUNC entry) //ڸ¶еĵϢ// -{ - QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueId)]; - queueDebug->creator = entry; - queueDebug->lastAccessTime = LOS_TickCountGet(); - return; -} - -STATIC INLINE VOID OsQueueInfoOutPut(const LosQueueCB *node) //еϢ// -{ - PRINTK("Queue ID <0x%x> may leak, queue len is 0x%x, " - "readable cnt:0x%x, writeable cnt:0x%x, ", - node->queueId, - node->queueLen, - node->readWriteableCnt[OS_QUEUE_READ], - node->readWriteableCnt[OS_QUEUE_WRITE]); -} - -STATIC INLINE VOID OsQueueOpsOutput(const QueueDebugCB *node) //вϢ// -{ - PRINTK("TaskEntry of creator:0x%p, Latest operation time: 0x%llx\n", - node->creator, node->lastAccessTime); -} - -STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count) //ڶԶӦĶϢ// -{ - LosQueueCB queueNode = {0}; - QueueDebugCB queueDebugNode = {0}; - UINT32 index, intSave; - SortParam queueSortParam; - queueSortParam.buf = (CHAR *)g_queueDebugArray; - queueSortParam.ctrlBlockSize = sizeof(QueueDebugCB); - queueSortParam.ctrlBlockCnt = LOSCFG_BASE_IPC_QUEUE_LIMIT; - queueSortParam.sortElemOff = LOS_OFF_SET_OF(QueueDebugCB, lastAccessTime); - - if (count > 0) { - SCHEDULER_LOCK(intSave); - OsArraySort(indexArray, 0, count - 1, &queueSortParam, QueueCompareValue); - SCHEDULER_UNLOCK(intSave); - for (index = 0; index < count; index++) { - SCHEDULER_LOCK(intSave); - (VOID)memcpy_s(&queueNode, sizeof(LosQueueCB), - GET_QUEUE_HANDLE(indexArray[index]), sizeof(LosQueueCB)); - (VOID)memcpy_s(&queueDebugNode, sizeof(QueueDebugCB), - &g_queueDebugArray[indexArray[index]], sizeof(QueueDebugCB)); - SCHEDULER_UNLOCK(intSave); - if (queueNode.queueState == LOS_UNUSED) { - continue; - } - OsQueueInfoOutPut(&queueNode); - OsQueueOpsOutput(&queueDebugNode); - } - } - (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray); -} - -VOID OsQueueCheck(VOID) //ڼе״̬ӦϢ// -{ - LosQueueCB queueNode = {0}; - QueueDebugCB queueDebugNode = {0}; - UINT32 index, intSave; - UINT32 count = 0; - - /* - * This return value does not need to be judged immediately, - * and the following code logic has already distinguished the return value from null and non-empty, - * and there is no case of accessing the null pointer. - */ - UINT32 *indexArray = (UINT32 *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(UINT32)); - - for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) { - SCHEDULER_LOCK(intSave); - (VOID)memcpy_s(&queueNode, sizeof(LosQueueCB), - GET_QUEUE_HANDLE(index), sizeof(LosQueueCB)); - (VOID)memcpy_s(&queueDebugNode, sizeof(QueueDebugCB), - &g_queueDebugArray[index], sizeof(QueueDebugCB)); - SCHEDULER_UNLOCK(intSave); - if ((queueNode.queueState == LOS_UNUSED) || - ((queueNode.queueState == LOS_USED) && (queueDebugNode.creator == NULL))) { - continue; - } - if ((queueNode.queueState == LOS_USED) && - (queueNode.queueLen == queueNode.readWriteableCnt[OS_QUEUE_WRITE]) && - LOS_ListEmpty(&queueNode.readWriteList[OS_QUEUE_READ]) && - LOS_ListEmpty(&queueNode.readWriteList[OS_QUEUE_WRITE]) && - LOS_ListEmpty(&queueNode.memList)) { - PRINTK("Queue ID <0x%x> may leak, No task uses it, " - "QueueLen is 0x%x, ", - queueNode.queueId, - queueNode.queueLen); - OsQueueOpsOutput(&queueDebugNode); - } else { - if (indexArray != NULL) { - *(indexArray + count) = index; - count++; - } else { - OsQueueInfoOutPut(&queueNode); - OsQueueOpsOutput(&queueDebugNode); - } - } - } - - if (indexArray != NULL) { - SortQueueIndexArray(indexArray, count); - } - - return; -} - -#ifdef LOSCFG_SHELL -//û "queue" ʱʹöеϢ// -LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdQueueInfoGet(UINT32 argc, const CHAR **argv) -{ - if (argc > 0) { - PRINTK("\nUsage: queue\n"); - return OS_ERROR; - } - PRINTK("used queues information: \n"); - OsQueueCheck(); - return LOS_OK; -} - -SHELLCMD_ENTRY(queue_shellcmd, CMD_TYPE_EX, "queue", 0, (CmdCallBackFunc)OsShellCmdQueueInfoGet); -#endif /* LOSCFG_SHELL */ -#endif /* LOSCFG_DEBUG_QUEUE */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif /* __cplusplus */ diff --git a/debug/los_sched_debug.c b/debug/los_sched_debug.c deleted file mode 100644 index ec4a78b..0000000 --- a/debug/los_sched_debug.c +++ /dev/null @@ -1,347 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved. - * Description: Schedule Statistics - * Author: Huawei LiteOS Team - * Create: 2018-11-16 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_task_pri.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_DEBUG_SCHED_STATISTICS -#define HIGHTASKPRI 16 -#define NS_PER_MS 1000000 -#define DECIMAL_TO_PERCENTAGE 100 - -typedef struct { - UINT64 idleRuntime; //ʱ// - UINT64 idleStarttime; //ʱ// - UINT64 highTaskRuntime; //ȼʱ// - UINT64 highTaskStarttime; //ȼʱ// - UINT64 sumPriority; //ȼ֮// - UINT32 prioritySwitch; //л// - UINT32 highTaskSwitch; //ȼл// - UINT32 contexSwitch; //л// - UINT32 hwiNum; //Ӳжϴ// -#ifdef LOSCFG_KERNEL_SMP - UINT32 ipiIrqNum; //жϴڶ¶壩// -#endif -} StatPercpu; - -STATIC BOOL g_statisticsStartFlag = FALSE; -STATIC UINT64 g_statisticsStartTime; -STATIC StatPercpu g_statPercpu[LOSCFG_KERNEL_CORE_NUM]; - -//ÿ CPU Ͻеͳ// -STATIC VOID OsSchedStatisticsPerCpu(const LosTaskCB *runTask, const LosTaskCB *newTask) -{ - UINT32 cpuId; - UINT32 idleTaskId; - UINT64 now, runtime; - - if (g_statisticsStartFlag != TRUE) { - return; - } - - cpuId = ArchCurrCpuid(); - idleTaskId = OsGetIdleTaskId(); - now = LOS_CurrNanosec(); - - g_statPercpu[cpuId].contexSwitch++; - - if ((runTask->taskId != idleTaskId) && (newTask->taskId == idleTaskId)) { - g_statPercpu[cpuId].idleStarttime = now; - } - - if ((runTask->taskId == idleTaskId) && (newTask->taskId != idleTaskId)) { - runtime = now - g_statPercpu[cpuId].idleStarttime; - g_statPercpu[cpuId].idleRuntime += runtime; - g_statPercpu[cpuId].idleStarttime = 0; - } - - if ((runTask->priority >= HIGHTASKPRI) && (newTask->priority < HIGHTASKPRI)) { - g_statPercpu[cpuId].highTaskStarttime = now; - } - - if ((runTask->priority < HIGHTASKPRI) && (newTask->priority >= HIGHTASKPRI)) { - runtime = now - g_statPercpu[cpuId].highTaskStarttime; - g_statPercpu[cpuId].highTaskRuntime += runtime; - g_statPercpu[cpuId].highTaskStarttime = 0; - } - - if (newTask->priority < HIGHTASKPRI) { - g_statPercpu[cpuId].highTaskSwitch++; - } - - if (newTask->taskId != idleTaskId) { - g_statPercpu[cpuId].sumPriority += newTask->priority; - g_statPercpu[cpuId].prioritySwitch++; - } - - return; -} - -//ڸµͳϢ// -LITE_OS_SEC_TEXT_MINOR VOID OsSchedStatistics(LosTaskCB *runTask, LosTaskCB *newTask) -{ - UINT64 runtime; - UINT32 cpuId = ArchCurrCpuid(); - UINT64 now = LOS_CurrNanosec(); - - SchedStat *schedRun = &runTask->schedStat; - SchedStat *schedNew = &newTask->schedStat; - SchedPercpu *cpuRun = &schedRun->schedPercpu[cpuId]; - SchedPercpu *cpuNew = &schedNew->schedPercpu[cpuId]; - - /* calculate one chance of running time */ - runtime = now - schedRun->startRuntime; - - /* add running timer to running task statistics */ - cpuRun->runtime += runtime; - schedRun->allRuntime += runtime; - - /* add context switch counters and schedule start time */ - cpuNew->contexSwitch++; - schedNew->allContextSwitch++; - schedNew->startRuntime = now; - OsSchedStatisticsPerCpu(runTask, newTask); -} - -LITE_OS_SEC_TEXT_MINOR VOID OsHwiStatistics(size_t intNum) //ڸӲжϵͳϢ// -{ - UINT32 cpuId = ArchCurrCpuid(); - - if ((g_statisticsStartFlag != TRUE) || (intNum == OS_TICK_INT_NUM)) { - return; - } - - g_statPercpu[cpuId].hwiNum++; -#ifdef LOSCFG_KERNEL_SMP - /* 16: 0~15 is ipi interrupts */ - if (intNum < 16) { - g_statPercpu[cpuId].ipiIrqNum++; - } -#endif - return; -} - -LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdDumpSched(VOID) //ڴӡĵͳϢ// -{ - LosTaskCB *taskCB = NULL; - UINT32 loop; - UINT32 cpuId; -#ifdef LOSCFG_KERNEL_SMP - UINT32 affinity; -#endif - - PRINTK("\n"); - PRINTK("Task TID Total Time Total CST " - "CPU Time CST\n"); - PRINTK("---- --- ------------------ ---------- -" - "--- ------------------ ----------\n"); - - for (loop = 0; loop < g_taskMaxNum; loop++) { - taskCB = (((LosTaskCB *)g_taskCBArray) + loop); - if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) { - continue; - } -#ifdef LOSCFG_KERNEL_SMP - affinity = (UINT32)taskCB->cpuAffiMask; -#endif - PRINTK("%-30s0x%-6x%+16lf ms %10u\n", taskCB->taskName, taskCB->taskId, - (DOUBLE)(taskCB->schedStat.allRuntime) / NS_PER_MS, - taskCB->schedStat.allContextSwitch); - - for (cpuId = 0; cpuId < LOSCFG_KERNEL_CORE_NUM; cpuId++) { -#ifdef LOSCFG_KERNEL_SMP - if (!((1U << cpuId) & affinity)) { - continue; - } -#endif - PRINTK(" " - "CPU%u %+16lf ms %12u\n", cpuId, - (DOUBLE)(taskCB->schedStat.schedPercpu[cpuId].runtime) / NS_PER_MS, - taskCB->schedStat.schedPercpu[cpuId].contexSwitch); - } - } - - PRINTK("\n"); -} - -LITE_OS_SEC_TEXT_MINOR VOID OsStatisticsShow(UINT64 statisticsPastTime) //ʾϵͳͳϢ// -{ - UINT32 cpuId; - PRINTK("\n"); - PRINTK("Passed Time: %+16lf ms\n", ((DOUBLE)statisticsPastTime / NS_PER_MS)); - PRINTK("--------------------------------\n"); - PRINTK("CPU Idle(%%) ContexSwitch HwiNum " - "Avg Pri HiTask(%%) HiTask SwiNum HiTask P(ms)" -#ifdef LOSCFG_KERNEL_SMP - " MP Hwi\n"); -#else - "\n"); -#endif - PRINTK("---- --------- ----------- -------- --------- " - "---------- ------------ ----------" -#ifdef LOSCFG_KERNEL_SMP - " ------\n"); -#else - "\n"); -#endif - - for (cpuId = 0; cpuId < LOSCFG_KERNEL_CORE_NUM; cpuId++) { -#ifdef LOSCFG_KERNEL_SMP - PRINTK("CPU%u %+10lf%14u%14u %+11lf %+11lf%14u %+11lf %11u\n", cpuId, -#else - PRINTK("CPU%u %+10lf%14u%14u %+11lf %+11lf%14u %+11lf\n", cpuId, -#endif - ((DOUBLE)(g_statPercpu[cpuId].idleRuntime) / statisticsPastTime) * DECIMAL_TO_PERCENTAGE, - g_statPercpu[cpuId].contexSwitch, - g_statPercpu[cpuId].hwiNum, - (g_statPercpu[cpuId].prioritySwitch == 0) ? OS_TASK_PRIORITY_LOWEST : - ((DOUBLE)(g_statPercpu[cpuId].sumPriority) / (g_statPercpu[cpuId].prioritySwitch)), - ((DOUBLE)(g_statPercpu[cpuId].highTaskRuntime) / statisticsPastTime) * DECIMAL_TO_PERCENTAGE, - g_statPercpu[cpuId].highTaskSwitch, - (g_statPercpu[cpuId].highTaskSwitch == 0) ? 0 : - ((DOUBLE)(g_statPercpu[cpuId].highTaskRuntime) / (g_statPercpu[cpuId].highTaskSwitch)) / NS_PER_MS -#ifdef LOSCFG_KERNEL_SMP - , g_statPercpu[cpuId].ipiIrqNum); -#else - ); -#endif - } - - PRINTK("\n"); -} - -LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStart(VOID) //ڶϵͳͳƹ// -{ - LosTaskCB *taskCB = NULL; - UINT32 loop; - UINT32 cpuId = 0; - UINT32 intSave; - - SCHEDULER_LOCK(intSave); - - if (g_statisticsStartFlag) { - SCHEDULER_UNLOCK(intSave); - PRINT_WARN("mp static has started\n"); - return; - } - - g_statisticsStartTime = LOS_CurrNanosec(); - - for (loop = 0; loop < g_taskMaxNum; loop++) { - taskCB = (((LosTaskCB *)g_taskCBArray) + loop); - if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) { -#ifdef LOSCFG_KERNEL_SMP - cpuId = taskCB->currCpu; -#endif - if ((UINT32)(OS_TASK_INVALID_CPUID) == cpuId) { - continue; - } - if (!strcmp(taskCB->taskName, "IdleCore000")) { - g_statPercpu[cpuId].idleStarttime = g_statisticsStartTime; - } - if (taskCB->priority < HIGHTASKPRI) { - g_statPercpu[cpuId].highTaskStarttime = g_statisticsStartTime; - g_statPercpu[cpuId].highTaskSwitch++; - } - if (strcmp(taskCB->taskName, "IdleCore000")) { - g_statPercpu[cpuId].sumPriority += taskCB->priority; - g_statPercpu[cpuId].prioritySwitch++; - } - } - } - g_statisticsStartFlag = TRUE; - SCHEDULER_UNLOCK(intSave); - - PRINTK("mp static start\n"); - - return; -} - -//ڶϵͳֹͣͳƹܣͳݵĴչʾ// -LITE_OS_SEC_TEXT_MINOR VOID OsShellStatisticsStop(VOID) -{ - LosTaskCB *taskCB = NULL; - UINT32 loop; - UINT32 cpuId = 0; - UINT64 statisticsStopTime; - UINT64 statisticsPastTime; - UINT64 runtime; - UINT32 intSave; - - SCHEDULER_LOCK(intSave); - - if (g_statisticsStartFlag != TRUE) { - SCHEDULER_UNLOCK(intSave); - PRINT_WARN("Please set mp static start\n"); - return; - } - - g_statisticsStartFlag = FALSE; - statisticsStopTime = LOS_CurrNanosec(); - statisticsPastTime = statisticsStopTime - g_statisticsStartTime; - - for (loop = 0; loop < g_taskMaxNum; loop++) { - taskCB = (((LosTaskCB *)g_taskCBArray) + loop); - if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) { -#ifdef LOSCFG_KERNEL_SMP - cpuId = taskCB->currCpu; -#endif - if (cpuId == (UINT32)(OS_TASK_INVALID_CPUID)) { - continue; - } - if (!strcmp(taskCB->taskName, "IdleCore000")) { - runtime = statisticsStopTime - g_statPercpu[cpuId].idleStarttime; - g_statPercpu[cpuId].idleRuntime += runtime; - g_statPercpu[cpuId].idleStarttime = 0; - } - if (taskCB->priority < HIGHTASKPRI) { - runtime = statisticsStopTime - g_statPercpu[cpuId].highTaskStarttime; - g_statPercpu[cpuId].highTaskRuntime += runtime; - g_statPercpu[cpuId].highTaskStarttime = 0; - } - } - } - SCHEDULER_UNLOCK(intSave); - OsStatisticsShow(statisticsPastTime); - - (VOID)memset_s(g_statPercpu, sizeof(g_statPercpu), 0, sizeof(g_statPercpu)); - g_statisticsStartTime = 0; - return; -} -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/debug/los_sem_debug.c b/debug/los_sem_debug.c deleted file mode 100644 index 8f1774b..0000000 --- a/debug/los_sem_debug.c +++ /dev/null @@ -1,299 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. - * Description: Sem Debug - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_sem_debug_pri.h" -#include "stdlib.h" -#include "los_typedef.h" -#include "los_task_pri.h" -#include "los_misc_pri.h" -#ifdef LOSCFG_SHELL -#include "shcmd.h" -#endif /* LOSCFG_SHELL */ - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif -#endif /* __cplusplus */ - -#ifdef LOSCFG_DEBUG_SEMAPHORE -#define OS_ALL_SEM_MASK 0xffffffff - -STATIC VOID OsSemPendedTaskNamePrint(LosSemCB *semNode) //ڴӡȴijźб// -{ - LosTaskCB *tskCB = NULL; - CHAR *nameArr[LOSCFG_BASE_CORE_TSK_LIMIT] = {0}; - UINT32 i, intSave; - UINT32 num = 0; - - SCHEDULER_LOCK(intSave); - if ((semNode->semStat == LOS_UNUSED) || (LOS_ListEmpty(&semNode->semList))) { - SCHEDULER_UNLOCK(intSave); - return; - } - - LOS_DL_LIST_FOR_EACH_ENTRY(tskCB, &semNode->semList, LosTaskCB, pendList) { - nameArr[num++] = tskCB->taskName; - if (num == LOSCFG_BASE_CORE_TSK_LIMIT) { - break; - } - } - SCHEDULER_UNLOCK(intSave); - - PRINTK("Pended task list : "); - for (i = 0; i < num; i++) { - if (i == 0) { - PRINTK("%s\n", nameArr[i]); - } else { - PRINTK(", %s", nameArr[i]); - } - } - PRINTK("\n"); -} - -typedef struct { //ڼ¼źĵϢ// - UINT16 origSemCount; /* Number of original available semaphores */ - UINT64 lastAccessTime; /* The last operation time */ - TSK_ENTRY_FUNC creator; /* The task entry who created this sem */ -} SemDebugCB; -STATIC SemDebugCB *g_semDebugArray = NULL; //ڴ洢źĵϢ// - -//ڱȽԪصֵ// -STATIC BOOL SemCompareValue(const SortParam *sortParam, UINT32 left, UINT32 right) -{ - return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) > - *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right))); -} - -UINT32 OsSemDbgInit(VOID) //ڳʼźĵϢ// -{ - UINT32 size = LOSCFG_BASE_IPC_SEM_LIMIT * sizeof(SemDebugCB); - /* system resident memory, don't free */ - g_semDebugArray = (SemDebugCB *)LOS_MemAlloc(m_aucSysMem1, size); - if (g_semDebugArray == NULL) { - PRINT_ERR("%s: malloc failed!\n", __FUNCTION__); - return LOS_NOK; - } - (VOID)memset_s(g_semDebugArray, size, 0, size); - return LOS_OK; -} - -VOID OsSemDbgTimeUpdate(UINT32 semId) //ڸָźһηʱ// -{ - SemDebugCB *semDebug = &g_semDebugArray[GET_SEM_INDEX(semId)]; - semDebug->lastAccessTime = LOS_TickCountGet(); - return; -} - -VOID OsSemDbgUpdate(UINT32 semId, TSK_ENTRY_FUNC creator, UINT16 count) //ڸָźĵϢ// -{ - SemDebugCB *semDebug = &g_semDebugArray[GET_SEM_INDEX(semId)]; - semDebug->creator = creator; - semDebug->lastAccessTime = LOS_TickCountGet(); - semDebug->origSemCount = count; - return; -} - -/*ڰźʱԵǰʹõź*/ -/*ӡÿźĵϢ͵ȴź*/ -STATIC VOID OsSemSort(UINT32 *semIndexArray, UINT32 usedCount) -{ - UINT32 i, intSave; - LosSemCB *semCB = NULL; - LosSemCB semNode = {0}; - SemDebugCB semDebug = {0}; - SortParam semSortParam; - semSortParam.buf = (CHAR *)g_semDebugArray; - semSortParam.ctrlBlockSize = sizeof(SemDebugCB); - semSortParam.ctrlBlockCnt = LOSCFG_BASE_IPC_SEM_LIMIT; - semSortParam.sortElemOff = LOS_OFF_SET_OF(SemDebugCB, lastAccessTime); - - /* It will Print out ALL the Used Semaphore List. */ - PRINTK("Used Semaphore List: \n"); - PRINTK("\r\n SemID Count OriginalCount Creater(TaskEntry) LastAccessTime\n"); - PRINTK(" ------ ------ ------------- ------------------ -------------- \n"); - - SCHEDULER_LOCK(intSave); - OsArraySort(semIndexArray, 0, usedCount - 1, &semSortParam, SemCompareValue); - SCHEDULER_UNLOCK(intSave); - for (i = 0; i < usedCount; i++) { - semCB = GET_SEM(semIndexArray[i]); - SCHEDULER_LOCK(intSave); - (VOID)memcpy_s(&semNode, sizeof(LosSemCB), semCB, sizeof(LosSemCB)); - (VOID)memcpy_s(&semDebug, sizeof(SemDebugCB), &g_semDebugArray[semIndexArray[i]], sizeof(SemDebugCB)); - SCHEDULER_UNLOCK(intSave); - if ((semNode.semStat != LOS_USED) || (semDebug.creator == NULL)) { - continue; - } - PRINTK(" 0x%-07x0x%-07u0x%-14u%-22p0x%llx\n", semNode.semId, semDebug.origSemCount, - semNode.semCount, semDebug.creator, semDebug.lastAccessTime); - if (!LOS_ListEmpty(&semNode.semList)) { - OsSemPendedTaskNamePrint(semCB); - } - } -} -/*ڻȡǰʹõźϢźʱź*/ -UINT32 OsSemInfoGetFullData(VOID) -{ - UINT32 usedSemCnt = 0; - LosSemCB *semNode = NULL; - SemDebugCB *semDebug = NULL; - UINT32 i; - UINT32 *semIndexArray = NULL; - UINT32 count, intSave; - - SCHEDULER_LOCK(intSave); - /* Get the used semaphore count. */ - for (i = 0; i < LOSCFG_BASE_IPC_SEM_LIMIT; i++) { - semNode = GET_SEM(i); - semDebug = &g_semDebugArray[i]; - if ((semNode->semStat == LOS_USED) && (semDebug->creator != NULL)) { - usedSemCnt++; - } - } - SCHEDULER_UNLOCK(intSave); - - if (usedSemCnt > 0) { - semIndexArray = (UINT32 *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, usedSemCnt * sizeof(UINT32)); - if (semIndexArray == NULL) { - PRINTK("LOS_MemAlloc failed in %s \n", __func__); - return LOS_NOK; - } - - /* Fill the semIndexArray with the real index. */ - count = 0; - - SCHEDULER_LOCK(intSave); - for (i = 0; i < LOSCFG_BASE_IPC_SEM_LIMIT; i++) { - semNode = GET_SEM(i); - semDebug = &g_semDebugArray[i]; - if ((semNode->semStat != LOS_USED) || (semDebug->creator == NULL)) { - continue; - } - *(semIndexArray + count) = i; - count++; - /* if the count is touched usedSemCnt break. */ - if (count >= usedSemCnt) { - break; - } - } - SCHEDULER_UNLOCK(intSave); - OsSemSort(semIndexArray, count); - - /* free the index array. */ - (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, semIndexArray); - } - return LOS_OK; -} - -#ifdef LOSCFG_SHELL -STATIC UINT32 OsSemInfoOutput(size_t semId) //źϢ// -{ - UINT32 loop, semCnt, intSave; - LosSemCB *semCB = NULL; - LosSemCB semNode = {0}; - - if (semId == OS_ALL_SEM_MASK) { - for (loop = 0, semCnt = 0; loop < LOSCFG_BASE_IPC_SEM_LIMIT; loop++) { - semCB = GET_SEM(loop); - SCHEDULER_LOCK(intSave); - if (semCB->semStat == LOS_USED) { - (VOID)memcpy_s(&semNode, sizeof(LosSemCB), semCB, sizeof(LosSemCB)); - SCHEDULER_UNLOCK(intSave); - semCnt++; - PRINTK("\r\n SemID Count\n ---------- -----\n"); - PRINTK(" 0x%08x %u\n", semNode.semId, semNode.semCount); - continue; - } - SCHEDULER_UNLOCK(intSave); - } - PRINTK(" SemUsingNum : %u\n\n", semCnt); - return LOS_OK; - } else { - semCB = GET_SEM(semId); - SCHEDULER_LOCK(intSave); - (VOID)memcpy_s(&semNode, sizeof(LosSemCB), semCB, sizeof(LosSemCB)); - SCHEDULER_UNLOCK(intSave); - if ((semNode.semId != semId) || (semNode.semStat != LOS_USED)) { - PRINTK("\nThe semaphore is not in use!\n"); - return LOS_OK; - } - - PRINTK("\r\n SemID Count\n ---------- -----\n"); - PRINTK(" 0x%08x 0x%u\n", semNode.semId, semNode.semCount); - - if (LOS_ListEmpty(&semNode.semList)) { - PRINTK("No task is pended on this semaphore!\n"); - return LOS_OK; - } else { - OsSemPendedTaskNamePrint(semCB); - } - } - return LOS_OK; -} - -//ڻȡźϢ// -LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSemInfoGet(UINT32 argc, const CHAR **argv) -{ - size_t semId; - CHAR *endPtr = NULL; - UINT32 ret; - - if (argc > 1) { - PRINTK("\nUsage: sem [fulldata|ID]\n"); - return OS_ERROR; - } - - if (argc == 0) { - semId = OS_ALL_SEM_MASK; - } else { - if (strcmp(argv[0], "fulldata") == 0) { - ret = OsSemInfoGetFullData(); - return ret; - } - - semId = strtoul(argv[0], &endPtr, 0); - if ((*endPtr != 0) || (GET_SEM_INDEX(semId) >= LOSCFG_BASE_IPC_SEM_LIMIT)) { - PRINTK("\nsem ID can't access %s.\n", argv[0]); - return OS_ERROR; - } - } - - ret = OsSemInfoOutput(semId); - return ret; -} - -SHELLCMD_ENTRY(sem_shellcmd, CMD_TYPE_EX, "sem", 1, (CmdCallBackFunc)OsShellCmdSemInfoGet); -#endif /* LOSCFG_SHELL */ -#endif /* LOSCFG_DEBUG_SEMAPHORE */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif -#endif /* __cplusplus */ diff --git a/文豪-用例描述.docx b/文豪-用例描述.docx deleted file mode 100644 index a5be5e412a48256759719611f03b383b2d93be84..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14105 zcma)jWmsLwvNrDS8rZmNa0wFJ-QC??gFC_9-QC@tpdq-s2ltQ6o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(2?m ze~5dxpkH#NS(pn$Bo&`;fDf)o}Ze~%*e$iX)n8(NJild?ZNDY7#`n! z3ZG;HTnXHC`o(}5PR33ytl9yJ9aoH1L0N`HO zTi#MoiJR#_H1hN|PLX?3d`GjN&r2(#?{lQf7PFq*g=TMWwb9p1X?hluyBQCLw^KYF3AgHX73goMjk z`F0uYpB^y)N*zjE?s$E03gN!vvK~WpU}o*p8Z_qIdqUD9Z1zB*kPWwdgb~WEg^vkx zhcYbSZp+83V))!&iqccz81cCIEA|p=_ep)U(@3f*YKLz6gOp&<^H|i8(?$cUoGBiH zWG_aY5hf-3ala$|B+S8nz^+!i8=NOm;Ad41)lM*gR|Dsf2ILy%Y`KmCPslC^gPM%v ztH|=z?ZT9D+mnzmRXg#Heh2hCTvX;6-z@fX$lLBSyReooC+qZf36!RGE@){jImHdK zSn%y^pIX*PIgj3-72}n5+!Q}BNY4eo2%dA{pM+ZG$%qpo)o^P+6Wrpp?##l}*Ip2S zSe=P+U*dz-dfn1n=R_WUt?if%T9=go20;V*-;MHa7a(9D!uQW?#{X)fKRfu}JPxF5U{ddXA@9^KNE&hU2zK2AA!T(cx@qbPFS5d*A?boFJ z-}AfvRbudK!vEbUzns>e?H5Fu;UAvqcV&NfV!wcYGUfA6;Qw%GzxVX}nc81HapL?- zg}?XlJN);M@h^BP^}pc%2q1sQ|DOK#7arlg>f(PS!~G8by-MRRc;UY}|Ep%>Pw@W_ y`*ZJp?~k$nox<|Z=k)g^mcK@Q`6uwNlonYD@L%uu_ewS-psDxgiJAG=fBz4WYiCse diff --git a/文豪/cppsupport/los_cppsupport.c b/文豪/cppsupport/los_cppsupport.c deleted file mode 100644 index e6239ab..0000000 --- a/文豪/cppsupport/los_cppsupport.c +++ /dev/null @@ -1,74 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. - * Description: LiteOS Cpp Support Implementation - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_cppsupport_pri.h" -#include "los_printf.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -typedef VOID (*InitFunc)(VOID); - -/*------------------------------------------- -*`LITE_OS_SEC_TEXT_MINOR``UINTPTR`ȡ -*`LOS_CppSystemInit`Уһʼ飬 -*εЩʼݴ`flag` -*ضλִгʼ -*--------------------------------------------*/ -LITE_OS_SEC_TEXT_MINOR INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd, INT32 flag) -{ - UINTPTR fastEnd = (UINTPTR)&__fast_end; - UINTPTR *start = (UINTPTR *)initArrayStart; - InitFunc initFunc = NULL; - -#ifdef LOSCFG_AARCH64 - __register_frame(__EH_FRAME_BEGIN__); -#endif - - for (; start != (UINTPTR *)initArrayEnd; ++start) { - if ((flag == BEFORE_SCATTER) && ((UINTPTR)*start > fastEnd)) { - continue; - } else if ((flag == AFTER_SCATTER) && ((UINTPTR)*start <= fastEnd)) { - continue; - } - - initFunc = (InitFunc)(*start); - initFunc(); - } - - return 0; -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/文豪/cpup/cpup_shellcmd.c b/文豪/cpup/cpup_shellcmd.c deleted file mode 100644 index 8e4160b..0000000 --- a/文豪/cpup/cpup_shellcmd.c +++ /dev/null @@ -1,134 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. - * Description: ShellCmd Cpup - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_config.h" -#ifdef LOSCFG_SHELL -#include "stdio.h" -#include "stdlib.h" -#include "los_cpup_pri.h" -#include "los_task_pri.h" -#include "shcmd.h" -#include "shell.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -VOID OsCmdCpupOperateOneParam(UINT32 mode) //ݲmodeȡϵͳCPUʹʵʷ// -{ - UINT32 ret; - - if (mode == CPUP_LAST_TEN_SECONDS) { //ȥ10s// - PRINTK("\nSysCpuUsage in 10s: "); - } else if (mode == CPUP_LAST_ONE_SECONDS) { //ȥ1s// - PRINTK("\nSysCpuUsage in 1s: "); - } else { //ʷƽCPUʹ// - PRINTK("\nSysCpuUsage in all time: "); - } - ret = LOS_HistorySysCpuUsage(mode); //ȡCPUʹʵֵ// - PRINTK("%u.%u", ret / LOS_CPUP_PRECISION_MULT, ret % LOS_CPUP_PRECISION_MULT); -} - -VOID OsCmdCpupOperateTwoParam(UINT32 mode, UINT32 taskId) //ݲmodeȡtaskIdָ// -{ //CPUʹʵʷ// - UINT32 ret; - - if (mode == CPUP_LAST_TEN_SECONDS) { //ȥ10s// - PRINTK("\nTaskId %u CpuUsage in 10s: ", taskId); - } else if (mode == CPUP_LAST_ONE_SECONDS) { //ȥ1s// - PRINTK("\nTaskId %u CpuUsage in 1s: ", taskId); - } else { //ʷƽCPUʹ// - PRINTK("\nTaskId %u CpuUsage in all time: ", taskId); - } - ret = LOS_HistoryTaskCpuUsage(taskId, mode); //ȡCPUʹʵֵ// - PRINTK("%u.%u", ret / LOS_CPUP_PRECISION_MULT, ret % LOS_CPUP_PRECISION_MULT); -} - -LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdCpup(INT32 argc, const CHAR **argv) //IJȡϵͳָCPUʹ// -{ - size_t mode, taskId; - CHAR *bufMode = NULL; - CHAR *bufId = NULL; - LosTaskCB *taskCB = NULL; - UINT32 ret; - - if (argc <= 0) { //ûвȡϵͳȥ10CPUʹʲӡ// - ret = LOS_HistorySysCpuUsage(CPUP_LAST_TEN_SECONDS); - PRINTK("\nSysCpuUsage in 10s: %u.%u", ret / LOS_CPUP_PRECISION_MULT, ret % LOS_CPUP_PRECISION_MULT); - return 0; - } - - mode = strtoul(argv[0], &bufMode, 0); //һתΪ޷modeʾCPUʹʵĻȡģʽ// -/*------------------------------------------------------------------*/ - //жmodeǷЧ// - if ((bufMode == NULL) || (*bufMode != 0)) { - PRINTK("\nThe input mode is invalid. Please try again.\n"); - return 0; - } - - if (mode > CPUP_ALL_TIME) { - mode = CPUP_ALL_TIME; - } -/*------------------------------------------------------------------*/ -//ֻһOsCmdCpupOperateOneParamȡϵͳCPUʹ// - if (argc == 1) { - OsCmdCpupOperateOneParam((UINT32)mode); - return 0; - } -/*------------------------------------------------------------------*/ -//жtaskIdǷЧ// - taskId = strtoul(argv[1], &bufId, 0); - if ((taskId >= g_taskMaxNum) || (*bufId != 0)) { - PRINTK("\nThe input taskId is invalid. Please try again.\n"); - return 0; - } - taskCB = OS_TCB_FROM_TID(taskId); - if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) { - PRINTK("\nThe task is unused. Please try again.\n"); - return 0; - } -/*-----------------------------------------------------------------*/ -//ڶΪIDȻOsCmdCpupOperateTwoParamȡָCPUʹ// - if (argc == 2) { - OsCmdCpupOperateTwoParam((UINT32)mode, (UINT32)taskId); - return 0; - } - - PRINTK("cpup [MODE] \ncpup [MODE] [TASKID] \n"); - return 0; -} -//ͨShellնcpupӦIJȡCPUʹʵʷ// -SHELLCMD_ENTRY(cpup_shellcmd, CMD_TYPE_EX, "cpup", XARGS, (CmdCallBackFunc)OsShellCmdCpup); -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ -#endif /* LOSCFG_SHELL */ diff --git a/文豪/cpup/los_cpup.c b/文豪/cpup/los_cpup.c deleted file mode 100644 index 688ff34..0000000 --- a/文豪/cpup/los_cpup.c +++ /dev/null @@ -1,593 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. - * Description : LiteOS Cpu Usage Calculation Module Implementation - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_cpup_pri.h" -#include "los_task_pri.h" -#include "los_base.h" -#include "los_swtmr.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_KERNEL_CPUP - -LITE_OS_SEC_BSS STATIC UINT16 g_cpupSwtmrId; //ڼ¼CPUʹͳƶʱID// -LITE_OS_SEC_BSS STATIC UINT16 g_cpupInitFlg = 0; //ڱCPUʹģǷѾʼ// -LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL; //ڱCPUʹصϢ// -LITE_OS_SEC_BSS STATIC UINT16 g_cpupMaxNum; //ʾCPUʹͳϢ// -LITE_OS_SEC_BSS STATIC UINT16 g_cpupTaskMaxNum; //ʾCPUʹͳϢ// -LITE_OS_SEC_BSS STATIC UINT16 g_hisPos = 0; /* current Sampling point of historyTime */ -LITE_OS_SEC_DATA_INIT STATIC UINT32 runningTasks[LOSCFG_KERNEL_CORE_NUM] = { - [0 ... (LOSCFG_KERNEL_CORE_NUM - 1)] = (UINT32)-1 -}; //ڼ¼ÿеID// -LITE_OS_SEC_BSS STATIC UINT64 cpuHistoryTime[OS_CPUP_HISTORY_RECORD_NUM + 1]; - //ڱCPUʷʱ¼// -LITE_OS_SEC_BSS STATIC UINT64 g_startCycles = 0; //ڼ¼лǰʱ// -#ifdef LOSCFG_CPUP_INCLUDE_IRQ //жǷжصĹ// -//// -LITE_OS_SEC_BSS UINT64 g_timeInIrqPerTskSwitch[LOSCFG_KERNEL_CORE_NUM]; //ڼ¼ÿлڼ䷢жϵʱ// -LITE_OS_SEC_BSS STATIC UINT64 g_intTimeStart[LOSCFG_KERNEL_CORE_NUM]; //ڼ¼ÿжϿʼʱ// -#endif - -#define HIGH_BITS 32 - -#define CPUP_PRE_POS(pos) (((pos) == 0) ? (OS_CPUP_HISTORY_RECORD_NUM - 1) : ((pos) - 1)) -#define CPUP_POST_POS(pos) (((pos) == (OS_CPUP_HISTORY_RECORD_NUM - 1)) ? 0 : ((pos) + 1)) - -LITE_OS_SEC_TEXT_INIT OsCpupCB *OsCpupCBGet(UINT32 index) -{ - return &g_cpup[index]; -} - -/*ڸʷʱʷʱ䣬ԱCPUʹ*/ -LITE_OS_SEC_TEXT_INIT VOID OsCpupGuard(VOID) -{ - UINT16 prevPos = g_hisPos; - UINT16 loop; - UINT16 runTaskId; - UINT64 curCycle; - UINT32 intSave; - - if (g_cpupInitFlg == 0) { //ʾCPUʹģδʼֱӷ// - return; - } - //ѳʼֹжϣȡǰʱ// - intSave = LOS_IntLock(); - curCycle = OsCpupGetCycle(); - - g_hisPos = CPUP_POST_POS(g_hisPos); //ʷʱλ// - cpuHistoryTime[prevPos] = curCycle; //¼βʱ// - -/*ÿCPUĵʷʱ*/ - for (loop = 0; loop < g_cpupMaxNum; loop++) { - g_cpup[loop].historyTime[prevPos] = g_cpup[loop].allTime; - } - - for (loop = 0; loop < LOSCFG_KERNEL_CORE_NUM; loop++) { - runTaskId = runningTasks[loop]; //ȡڵǰϵID// - /* reacquire the cycle to prevent flip */ - curCycle = OsCpupGetCycle(); - /*ӿʼǰʱõʱʷʱϵʷʱ*/ - g_cpup[runTaskId].historyTime[prevPos] += curCycle - g_cpup[runTaskId].startTime; -#ifdef LOSCFG_CPUP_INCLUDE_IRQ //жжϹǷ񱻰// - /*Ӹʷʱмȥлڼ䷢жõʱ*/ - g_cpup[runTaskId].historyTime[prevPos] -= g_timeInIrqPerTskSwitch[loop]; -#endif - } - - LOS_IntRestore(intSave); //ָж״̬// -} - -/*һʱԱ㶨ڸʷʱʷʱ䣬ӶʵCPUʹʵͳ*/ -LITE_OS_SEC_TEXT_INIT VOID OsCpupGuardCreator(VOID) -{ - /*溯IJֱΪ*/ - //趨ʱÿӵĻʱӵδ// - //ģʽΪģʽ// - //ص// - //ʱIDg_cpupSwtmrId// - //һΪ0ʾЯ// - (VOID)LOS_SwtmrCreate(LOSCFG_BASE_CORE_TICK_PER_SECOND, LOS_SWTMR_MODE_PERIOD, - (SWTMR_PROC_FUNC)OsCpupGuard, &g_cpupSwtmrId, 0); - - (VOID)LOS_SwtmrStart(g_cpupSwtmrId); //ʱ// -} - -/*ʼCPUʹͳģ飬аһȼ -ںΪOsCpupGuardCreator -ڴԵOsCpupGuard()ʱ*/ -LITE_OS_SEC_TEXT_INIT VOID OsCpupGuardInit(VOID) -{ - TSK_INIT_PARAM_S taskInitParam; - UINT32 tempId; - //ʼtaskInitParam// - (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); - taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsCpupGuardCreator; //ָںΪOsCpupGuardCreatorʱĺ// - taskInitParam.uwStackSize = LOS_TASK_MIN_STACK_SIZE; //ָջĴСΪСջС// - taskInitParam.pcName = "CpupGuardCreator"; //ָΪ"CpupGuardCreator"// - taskInitParam.usTaskPrio = OS_TASK_PRIORITY_HIGHEST; //ָȼΪȼ// - taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED; //ָ״̬ΪLOS_TASK_STATUS_DETACHED// -#ifdef LOSCFG_KERNEL_SMP //жϲϵͳǷֶ֧// - taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid()); //CPU׺// -#endif - /*ʼõIJtaskInitParamIDtempId*/ - (VOID)LOS_TaskCreate(&tempId, &taskInitParam); -} - -/* - * Description: initialization of CPUP - * Return : LOS_OK or Error Information - */ -LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit(VOID) -{ - UINT32 size; - - g_cpupTaskMaxNum = g_taskMaxNum; - g_cpupMaxNum = g_cpupTaskMaxNum; -/*˰жϵCPUʹͳƣLOSCFG_CPUP_INCLUDE_IRQ -g_cpupMaxNumLOSCFG_PLATFORM_HWI_LIMIT*/ -#ifdef LOSCFG_CPUP_INCLUDE_IRQ - g_cpupMaxNum += LOSCFG_PLATFORM_HWI_LIMIT; -#endif - - /* every task has only one record, and it won't operated at the same time */ - size = g_cpupMaxNum * sizeof(OsCpupCB); //ҪڴռС// - g_cpup = (OsCpupCB *)LOS_MemAlloc(m_aucSysMem0, size); //ڴ棬ڴ洢OsCpupCBṹ// - if (g_cpup == NULL) { //ڴʧ// - return LOS_ERRNO_CPUP_NO_MEMORY; - } - - OsCpupGuardInit(); //ʼCPUʹͳģ// - - (VOID)memset_s(g_cpup, size, 0, size); //ڴռ// - g_cpupInitFlg = 1; //ʾCPUʹͳģѾʼ// - - return LOS_OK; //ʼɹ// -} - -LITE_OS_SEC_TEXT_INIT VOID LOS_CpupReset(VOID) //CPUʹͳģ// -{ - UINT32 cpupIndex; - UINT32 maxNum = g_cpupMaxNum; - UINT64 curCycle; - UINT16 loop; - UINT32 intSave; - - /*ȫֱg_cpupǷΪNULLǣֱӷأִκβ*/ - if (g_cpup == NULL) { - return; - } - - g_cpupInitFlg = 0; //ʾCPUʹͳģδʼ// - intSave = LOS_IntLock(); //жϣֹùзж// - (VOID)LOS_SwtmrStop(g_cpupSwtmrId); //ֹͣCPUʹͳƶʱ// - curCycle = OsCpupGetCycle(); //ȡǰCPU// - - /*cpuHistoryTimeеԪضΪcurCycleʷʱ¼*/ - for (loop = 0; loop < (OS_CPUP_HISTORY_RECORD_NUM + 1); loop++) { - cpuHistoryTime[loop] = curCycle; - } - - /*ÿCPUʹͳƽṹ壬 - ʼʱʱ䶼ΪcurCycle - ͬʱÿṹеʷʱ¼*/ - for (cpupIndex = 0; cpupIndex < maxNum; cpupIndex++) { - g_cpup[cpupIndex].startTime = curCycle; - g_cpup[cpupIndex].allTime = curCycle; - for (loop = 0; loop < (OS_CPUP_HISTORY_RECORD_NUM + 1); loop++) { - g_cpup[cpupIndex].historyTime[loop] = curCycle; - } - } - -/*˰жϵCPUʹͳƣ -g_timeInIrqPerTskSwitchеԪضΪ0 -ڼ¼лڼжʱ*/ -#ifdef LOSCFG_CPUP_INCLUDE_IRQ - for (loop = 0; loop < LOSCFG_KERNEL_CORE_NUM; loop++) { - g_timeInIrqPerTskSwitch[loop] = 0; - } -#endif - - (VOID)LOS_SwtmrStart(g_cpupSwtmrId); //CPUʹͳƶʱ// - LOS_IntRestore(intSave); //ָж״̬// - g_cpupInitFlg = 1; //ʾCPUʹͳģѾ³ʼ// - - return; -} - -/*CPUʼֵԱ¼ʱʱ -ܹȷCPUIJֵӶõʱ*/ -LITE_OS_SEC_TEXT_MINOR VOID OsCpupSetCycle(UINT64 startCycles) -{ - g_startCycles = startCycles; - return; -} - -/* - * Description: get current cycles count - * Return : current cycles count - */ -LITE_OS_SEC_TEXT_MINOR UINT64 OsCpupGetCycle(VOID) -{ - UINT32 high; - UINT32 low; - UINT64 cycles; - - LOS_GetCpuCycle(&high, &low); - cycles = ((UINT64)high << HIGH_BITS) + low; //λ͵λļֵϲһ64λֵ// - if (g_startCycles == 0) { - g_startCycles = cycles; - } - - /* - * The cycles should keep growing, if the checking failed, - * it mean LOS_GetCpuCycle has the problem which should be fixed. - */ - LOS_ASSERT(cycles >= g_startCycles); - - return (cycles - g_startCycles); -} - -/* - * Description: start task to get cycles count in current task beginning - */ -LITE_OS_SEC_TEXT_MINOR VOID OsTaskCycleStart(VOID) //ʼʱȡCPUڼ// -{ - UINT32 taskId; - LosTaskCB *runTask = NULL; - - if (g_cpupInitFlg == 0) { //Ϊ0ʾδCPUڼijʼֱӷ// - return; - } - - runTask = OsCurrTaskGet(); //ȡǰе// - taskId = runTask->taskId; //ȡǰID// - - g_cpup[taskId].id = taskId; - g_cpup[taskId].startTime = OsCpupGetCycle(); - - return; -} - -/* - * Description: quit task and get cycle count - */ -LITE_OS_SEC_TEXT_MINOR VOID OsTaskCycleEnd(VOID) -{ - UINT32 taskId; - UINT64 cpuCycle; - LosTaskCB *runTask = NULL; - - if (g_cpupInitFlg == 0) { - return; - } - - runTask = OsCurrTaskGet(); - taskId = runTask->taskId; - - if (g_cpup[taskId].startTime == 0) { //жǷѾ¼Ŀʼʱ䣬// - return; //Ϊ0ʾδ¼ʼʱ䣬ֱӷ// - } - - cpuCycle = OsCpupGetCycle(); - g_cpup[taskId].allTime += cpuCycle - g_cpup[taskId].startTime; //ȡӿʼCPU// - -#ifdef LOSCFG_CPUP_INCLUDE_IRQ //˰жϴʱͳƣҪʱ// - UINT32 cpuId = ArchCurrCpuid(); - g_cpup[taskId].allTime -= g_timeInIrqPerTskSwitch[cpuId]; //ȥǰCPUжϴռõʱ - g_timeInIrqPerTskSwitch[cpuId] = 0; -#endif - g_cpup[taskId].startTime = 0; //ʾʱͳƽ// - - return; -} - -/* - * Description: start task to get cycles count in current task ending - */ -LITE_OS_SEC_TEXT_MINOR VOID OsTaskCycleEndStart(const LosTaskCB *newTask) -{ - UINT64 cpuCycle; - LosTaskCB *runTask = NULL; - OsCpupCB *cpup = NULL; - UINT32 cpuId = ArchCurrCpuid(); - - if ((g_cpupInitFlg == 0) || (newTask == NULL)) { - return; - } - - runTask = OsCurrTaskGet(); - cpuCycle = OsCpupGetCycle(); - - cpup = &g_cpup[runTask->taskId]; - if (cpup->startTime != 0) { - cpup->allTime += cpuCycle - cpup->startTime; //ʾ֮ǰѾʼCPUڼҪʱи// -#ifdef LOSCFG_CPUP_INCLUDE_IRQ //Ƿãʱ// - cpup->allTime -= g_timeInIrqPerTskSwitch[cpuId]; - g_timeInIrqPerTskSwitch[cpuId] = 0; -#endif - } - - cpup = &g_cpup[newTask->taskId]; - /*ID͵ǰCPUڼֵ棬ʾCPUڼʼ*/ - cpup->id = newTask->taskId; - cpup->startTime = cpuCycle; - runningTasks[cpuId] = newTask->taskId; //µǰCPUеID// - - return; -} - -/*ڻȡCPUڼеλ*/ -LITE_OS_SEC_TEXT_MINOR STATIC VOID OsCpupGetPos(UINT32 mode, UINT16 *curPosPointer, UINT16 *prePosPointer) -{ - UINT16 curPos; - UINT16 tmpPos; - UINT16 prePos; - - tmpPos = g_hisPos; //ȡǰλ// - curPos = CPUP_PRE_POS(tmpPos); //ȡǰһλ// - - /* - * The current position has nothing to do with the CPUP modes, - * however, the previous position differs. - */ - switch (mode) { - /*ʾҪȡһڵCPUڼݣ - ʱǰһλΪǰλõǰһλ*/ - case CPUP_LAST_ONE_SECONDS: - prePos = CPUP_PRE_POS(curPos); - break; - /*ʾҪȡʮڵCPUڼݣ - ʱǰһλΪǰλ*/ - case CPUP_LAST_TEN_SECONDS: - prePos = tmpPos; - break; - /*ʾҪȡʱڵCPUڼݣ - ʱǰһλΪһλ*/ - case CPUP_ALL_TIME: - /* fall-through */ - default: - prePos = OS_CPUP_HISTORY_RECORD_NUM; - break; - } - - *curPosPointer = curPos; //浱ǰλ// - *prePosPointer = prePos; //ǰһλ// - - return; -} - -/*ڼCPUʹͳƲĺϷ*/ -LITE_OS_SEC_TEXT_MINOR STATIC INLINE UINT32 OsCpuUsageParaCheck(UINT32 taskId) -{ - if (g_cpupInitFlg == 0) { - return LOS_ERRNO_CPUP_NO_INIT; - } - - if (OS_TSK_GET_INDEX(taskId) >= g_taskMaxNum) { //IDֵ// - return LOS_ERRNO_CPUP_TSK_ID_INVALID; //ʾIDЧش// - } - - /* weather the task is created */ - if (g_cpup[taskId].id != taskId) { - return LOS_ERRNO_CPUP_THREAD_NO_CREATED; //ʾδش// - } - - if ((g_cpup[taskId].status & OS_TASK_STATUS_UNUSED) || (g_cpup[taskId].status == 0)) { - return LOS_ERRNO_CPUP_THREAD_NO_CREATED; //ʾδش// - } - - return LOS_OK; //ʾͨ// -} - -LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT32 mode) //ڻȡʷϵͳCPUʹ// -{ - UINT64 cpuCycleAll; - UINT64 idleCycleAll = 0; - UINT32 cpup = 0; - UINT16 pos; - UINT16 prePos; - UINT32 intSave; - UINT32 idleTaskId; -#ifdef LOSCFG_KERNEL_SMP - UINT32 cpuId = 0; -#endif - - if (g_cpupInitFlg == 0) { - return LOS_ERRNO_CPUP_NO_INIT; - } - - /* get end time of current task */ - intSave = LOS_IntLock(); //ж״̬// - OsTaskCycleEnd(); //ȡǰĽʱ// - - OsCpupGetPos(mode, &pos, &prePos); //ȡʷCPUʹݵλϢ// - cpuCycleAll = cpuHistoryTime[pos] - cpuHistoryTime[prePos]; //CPU// - -#ifdef LOSCFG_KERNEL_SMP //жǷΪSMPϵͳ// - /* For SMP system, each idle task needs to be accounted */ - while (cpuId < LOSCFG_KERNEL_CORE_NUM) { - idleTaskId = g_percpu[cpuId].idleTaskId; - //ۼӸĵĿidleCycleAll// - idleCycleAll += g_cpup[idleTaskId].historyTime[pos] - g_cpup[idleTaskId].historyTime[prePos]; - cpuId++; - } - cpuCycleAll *= LOSCFG_KERNEL_CORE_NUM; -#else - idleTaskId = OsGetIdleTaskId(); //ֱӻȡ// - idleCycleAll = g_cpup[idleTaskId].historyTime[pos] - g_cpup[idleTaskId].historyTime[prePos]; -#endif - - if (cpuCycleAll) { - cpup = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuCycleAll)); - } //óCPUʹ// - - OsTaskCycleStart(); //¿ʼʱͳ// - LOS_IntRestore(intSave); //ָж״̬// - - return cpup; -} - -LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskId, UINT32 mode) -{ - UINT64 cpuCycleAll; - UINT64 cpuCycleCurTask; - UINT16 pos; - UINT16 prePos; - UINT32 intSave; - UINT32 cpup = 0; - UINT32 ret; - - if (g_cpupInitFlg == 0) { - return LOS_ERRNO_CPUP_NO_INIT; - } - - //ԴIDв飬LOS_OK򷵻ӦĴ// - ret = OsCpuUsageParaCheck(taskId); - if (ret != LOS_OK) { - return ret; - } - OsCpupCB *taskCpup = &g_cpup[taskId]; - - intSave = LOS_IntLock(); - OsTaskCycleEnd(); - - OsCpupGetPos(mode, &pos, &prePos); //ȡʷCPUʹݵλϢ// - cpuCycleAll = cpuHistoryTime[pos] - cpuHistoryTime[prePos]; //CPU// - cpuCycleCurTask = taskCpup->historyTime[pos] - taskCpup->historyTime[prePos]; //㵱ǰCPU// - if (cpuCycleAll) { - cpup = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTask) / cpuCycleAll); - } //óCPUʹ// - - OsTaskCycleStart(); - LOS_IntRestore(intSave); - - return cpup; -} - -//ڻȡʷCPUʹ// -LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllCpuUsage(UINT16 maxNum, CPUP_INFO_S *cpupInfo, UINT32 mode, UINT16 flag) -{ - UINT16 loop; - UINT16 pos; - UINT16 prePos; - UINT32 intSave; - UINT64 cpuCycleAll; - UINT64 cpuCycleCurTask; - UINT16 numTmpMax = maxNum; - UINT16 numTmpMin = 0; - UINT16 numMax = g_cpupTaskMaxNum; - - if (g_cpupInitFlg == 0) { - return LOS_ERRNO_CPUP_NO_INIT; - } - - if (cpupInfo == NULL) { //鴫ָcpupInfoǷΪգΪգش// - return LOS_ERRNO_CPUP_TASK_PTR_NULL; - } - - if (maxNum == 0) { //鴫maxNumǷ00ش// - return LOS_ERRNO_CPUP_MAXNUM_INVALID; - } - -#ifdef LOSCFG_CPUP_INCLUDE_IRQ //걻// - if (flag == 0) { - numTmpMax += g_cpupTaskMaxNum; - numTmpMin += g_cpupTaskMaxNum; - numMax = g_cpupMaxNum; - } -#endif - - if (numTmpMax > numMax) { - numTmpMax = numMax; - } - - intSave = LOS_IntLock(); - OsTaskCycleEnd(); - - OsCpupGetPos(mode, &pos, &prePos); //ȡʷCPUʹݵλϢ// - cpuCycleAll = cpuHistoryTime[pos] - cpuHistoryTime[prePos]; //CPU// - - /*ͨѭCPUʹݣ㵱ǰCPU*/ - for (loop = numTmpMin; loop < numTmpMax; loop++) { - if ((g_cpup[loop].status & OS_TASK_STATUS_UNUSED) || (g_cpup[loop].status == 0)) { - continue; - } - - cpuCycleCurTask = g_cpup[loop].historyTime[pos] - g_cpup[loop].historyTime[prePos]; - cpupInfo[loop - numTmpMin].usStatus = g_cpup[loop].status; - - if (cpuCycleAll) { - cpupInfo[loop - numTmpMin].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTask) / cpuCycleAll); - } - } - - OsTaskCycleStart(); - LOS_IntRestore(intSave); - - return LOS_OK; -} - -#ifdef LOSCFG_CPUP_INCLUDE_IRQ -/*жϿʼʱ¼ǰʱԱںжϴʱͳƺͷ*/ -LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(VOID) -{ - g_intTimeStart[ArchCurrCpuid()] = OsCpupGetCycle(); - return; -} - -/*жϽʱͳƲ -¼жϺšжڼлʱԼۼжڼʱ*/ -LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum) -{ - UINT64 intTimeEnd = OsCpupGetCycle(); //ȡǰʱ// - UINT32 cpuId = ArchCurrCpuid(); //ȡǰCPUID// - - if (g_cpupInitFlg == 0) { - return; - } - - g_cpup[g_taskMaxNum + intNum].id = intNum; - g_cpup[g_taskMaxNum + intNum].status = OS_TASK_STATUS_RUNNING; //ж״̬Ϊ// - g_timeInIrqPerTskSwitch[cpuId] += (intTimeEnd - g_intTimeStart[cpuId]); //жڼлĵʱ// - g_cpup[g_taskMaxNum + intNum].allTime += (intTimeEnd - g_intTimeStart[cpuId]); - - return; -} -#endif - -#endif /* LOSCFG_KERNEL_CPUP */ -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - diff --git a/文豪/los_cppsupport_pri.h b/文豪/los_cppsupport_pri.h deleted file mode 100644 index 5e3fcb9..0000000 --- a/文豪/los_cppsupport_pri.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. - * Description: Cpp Support HeadFile - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#ifndef _LOS_CPPSUPPORT_PRI_H -#define _LOS_CPPSUPPORT_PRI_H //ֹΰͬһͷļ// - -#include "los_cppsupport.h" - -#ifdef __cplusplus //ݱǷΪC++// -#if __cplusplus //ʹáextern 'C'// -extern "C" { //´ݽ// -#endif /* __cplusplus */ //ȷ// -#endif /* __cplusplus */ - -extern CHAR __fast_end; //һ_fast_endCHARͱ// - -#ifdef LOSCFG_AARCH64 //// -extern UINT8 __EH_FRAME_BEGIN__[]; //һUINT8͵// -VOID __register_frame(VOID *begin); -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ //رextern'C'// -#endif /* __cplusplus */ - -#endif /* _LOS_CPPSUPPORT_PRI_H */ diff --git a/文豪/los_cpup_pri.h b/文豪/los_cpup_pri.h deleted file mode 100644 index f8da73e..0000000 --- a/文豪/los_cpup_pri.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2013-2020. All rights reserved. - * Description: Cpup HeadFile - * Author: Huawei LiteOS Team - * Create: 2013-01-01 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#ifndef _LOS_CPUP_PRI_H -#define _LOS_CPUP_PRI_H //ֹΰͬһͷļ// - -#include "los_cpup.h" //ܰһЩCPUʹ// -#include "los_task_pri.h" //ͳصĹͶ// - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define OS_CPUP_HISTORY_RECORD_NUM 11 //ʷ¼Ϊ11// -#define LOS_CPUP_PRECISION 1000 //CPUʹʵľΪ1000// -#define LOS_CPUP_PRECISION_MULT (LOS_CPUP_PRECISION / 100) //ڼCPUʹ// - -typedef struct { - UINT32 id; /* Task ID */ - UINT16 status; /* Task status */ - UINT64 allTime; /* Total running time */ - UINT64 startTime; /* Time before a task is invoked */ - UINT64 historyTime[OS_CPUP_HISTORY_RECORD_NUM + 1]; /* Historical running time, the last one saves zero */ -} OsCpupCB; - -extern OsCpupCB *OsCpupCBGet(UINT32 index); //ȡ `OsCpupCB` ṹָ// -extern UINT32 OsCpupInit(VOID); //CPUʹͳģijʼ// -extern VOID OsCpupSetCycle(UINT64 startCycles); //CPUڼ// -extern UINT64 OsCpupGetCycle(VOID); //ȡCPUڼ// -extern VOID OsTaskCycleStart(VOID); //ڵʼ// -extern VOID OsTaskCycleEnd(VOID); //ڵĽ// -extern VOID OsTaskCycleEndStart(const LosTaskCB *newTask); //ڣʼµ// -#ifdef LOSCFG_CPUP_INCLUDE_IRQ -VOID OsCpupIrqStart(VOID); //ǰһ£ڴ// -VOID OsCpupIrqEnd(UINT32); //жϵCPUʹͳƺ// -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_CPUP_PRI_H */ - -/*δ붨һЩCPUʹͳƵݽṹͺ -ڲϵͳʵֶжϵCPUʽмغͳơ*/ \ No newline at end of file diff --git a/文豪/los_trace_pri.h b/文豪/los_trace_pri.h deleted file mode 100644 index 762fd9f..0000000 --- a/文豪/los_trace_pri.h +++ /dev/null @@ -1,150 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: LiteOS Trace Module Private HeadFile - * Author: Huawei LiteOS Team - * Create: 2019-08-30 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#ifndef _LOS_TRACE_PRI_H -#define _LOS_TRACE_PRI_H - -#include "los_trace.h" -#include "los_task_pri.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_TRACE_CONTROL_AGENT -#define TRACE_CMD_END_CHAR 0xD -#endif - -#define TRACE_ERROR PRINT_ERR -#define TRACE_MODE_OFFLINE 0 -#define TRACE_MODE_ONLINE 1 - -/* just task and hwi were traced */ -#define TRACE_DEFAULT_MASK (TRACE_HWI_FLAG | TRACE_TASK_FLAG) -#define TRACE_CTL_MAGIC_NUM 0xDEADBEEF -#define TRACE_BIGLITTLE_WORD 0x12345678 -#define TRACE_VERSION(MODE) (0xFFFFFFFF & (MODE)) -#define TRACE_MASK_COMBINE(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4)) - -#define TRACE_GET_MODE_FLAG(type) ((type) & 0xFFFFFFF0) - -extern SPIN_LOCK_S g_traceSpin; -#define TRACE_LOCK(state) LOS_SpinLockSave(&g_traceSpin, &(state)) -#define TRACE_UNLOCK(state) LOS_SpinUnlockRestore(&g_traceSpin, (state)) - -typedef VOID (*TRACE_DUMP_HOOK)(BOOL toClient); -extern TRACE_DUMP_HOOK g_traceDumpHook; - -enum TraceCmd { - TRACE_CMD_START = 1, - TRACE_CMD_STOP, - TRACE_CMD_SET_EVENT_MASK, - TRACE_CMD_RECODE_DUMP, - TRACE_CMD_MAX_CODE, -}; - -/** - * @ingroup los_trace - * struct to store the trace cmd from traceClient. - */ -typedef struct { - UINT8 cmd; - UINT8 param1; - UINT8 param2; - UINT8 param3; - UINT8 param4; - UINT8 param5; - UINT8 end; -} TraceClientCmd; - -/** - * @ingroup los_trace - * struct to store the event infomation - */ -typedef struct { - UINT32 cmd; /* trace start or stop cmd */ - UINT32 param; /* magic numb stand for notify msg */ -} TraceNotifyFrame; - -/** - * @ingroup los_trace - * struct to store the trace config information. - */ -typedef struct { - struct WriteCtrl { - UINT16 curIndex; /* The current record index */ - UINT16 maxRecordCount; /* The max num of track items */ - UINT16 curObjIndex; /* The current obj index */ - UINT16 maxObjCount; /* The max num of obj index */ - ObjData *objBuf; /* Pointer to obj info data */ - TraceEventFrame *frameBuf; /* Pointer to the track items */ - } ctrl; - OfflineHead *head; -} TraceOfflineHeaderInfo; - -extern UINT32 OsTraceGetMaskTid(UINT32 taskId); -extern VOID OsTraceSetObj(ObjData *obj, const LosTaskCB *tcb); -extern VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame); -extern UINT32 OsTraceBufInit(VOID *buf, UINT32 size); -extern VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId); -extern BOOL OsTraceIsEnable(VOID); -extern OfflineHead *OsTraceRecordGet(VOID); - -#ifdef LOSCFG_RECORDER_MODE_ONLINE -extern VOID OsTraceSendHead(VOID); -extern VOID OsTraceSendObjTable(VOID); -extern VOID OsTraceSendNotify(UINT32 type, UINT32 value); - -#define OsTraceNotifyStart() do { \ - OsTraceSendNotify(SYS_START, TRACE_CTL_MAGIC_NUM); \ - OsTraceSendHead(); \ - OsTraceSendObjTable(); \ - } while (0) - -#define OsTraceNotifyStop() do { \ - OsTraceSendNotify(SYS_STOP, TRACE_CTL_MAGIC_NUM); \ - } while (0) - -#define OsTraceReset() -#define OsTraceRecordDump(toClient) -#else -extern VOID OsTraceReset(VOID); -extern VOID OsTraceRecordDump(BOOL toClient); -#define OsTraceNotifyStart() -#define OsTraceNotifyStop() -#endif - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _LOS_TRACE_PRI_H */ diff --git a/文豪/trace/los_trace.c b/文豪/trace/los_trace.c deleted file mode 100644 index 1f19ec2..0000000 --- a/文豪/trace/los_trace.c +++ /dev/null @@ -1,424 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: LiteOS Trace Implementation - * Author: Huawei LiteOS Team - * Create: 2019-08-31 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ -#include "uart.h" -#include "los_trace_pri.h" -#include "trace_pipeline.h" - -#ifdef LOSCFG_KERNEL_SMP -#include "los_mp_pri.h" -#endif - -#ifdef LOSCFG_SHELL -#include "shcmd.h" -#include "shell.h" -#endif - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_KERNEL_TRACE -LITE_OS_SEC_BSS STATIC UINT32 g_traceEventCount; //׷¼// -LITE_OS_SEC_BSS STATIC volatile enum TraceState g_traceState = TRACE_UNINIT; //׷״̬// -LITE_OS_SEC_DATA_INIT STATIC volatile BOOL g_enableTrace = FALSE; //Ƿ׷ٹ// -LITE_OS_SEC_BSS STATIC UINT32 g_traceMask = TRACE_DEFAULT_MASK; //׷룬ڹ׷¼// - -#ifdef LOSCFG_TRACE_CONTROL_AGENT -LITE_OS_SEC_BSS STATIC UINT32 g_traceTaskId; //׷ID// -#endif - -#define EVENT_MASK 0xFFFFFFF0 -#define MIN(x, y) ((x) < (y) ? (x) : (y)) - -LITE_OS_SEC_BSS STATIC TRACE_HWI_FILTER_HOOK g_traceHwiFliterHook = NULL; - -LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_traceSpin); - -STATIC_INLINE BOOL OsTraceHwiFilter(UINT32 hwiNum) //жǷҪijӲж// -{ - BOOL ret = ((hwiNum == NUM_HAL_INTERRUPT_UART) || (hwiNum == OS_TICK_INT_NUM)); -#ifdef LOSCFG_KERNEL_SMP - ret |= (hwiNum == LOS_MP_IPI_SCHEDULE); -#endif - if (g_traceHwiFliterHook != NULL) { - ret |= g_traceHwiFliterHook(hwiNum); - } - return ret; -} - -//׷¼֡Ϣ// -STATIC VOID OsTraceSetFrame(TraceEventFrame *frame, UINT32 eventType, UINTPTR identity, const UINTPTR *params, - UINT16 paramCount) -{ - INT32 i; - UINT32 intSave; - - (VOID)memset_s(frame, sizeof(TraceEventFrame), 0, sizeof(TraceEventFrame)); - - if (paramCount > LOSCFG_TRACE_FRAME_MAX_PARAMS) { - paramCount = LOSCFG_TRACE_FRAME_MAX_PARAMS; - } - - TRACE_LOCK(intSave); - frame->curTask = OsTraceGetMaskTid(OsCurrTaskGet()->taskId); - frame->identity = identity; - frame->curTime = HalClockGetCycles(); - frame->eventType = eventType; - -#ifdef LOSCFG_TRACE_FRAME_CORE_MSG - frame->core.cpuId = ArchCurrCpuid(); //CPUID// - frame->core.hwiActive = OS_INT_ACTIVE ? TRUE : FALSE; //Ӳжϻ״̬// - frame->core.taskLockCnt = MIN(OsPercpuGet()->taskLockCnt, 0xF); /* taskLockCnt is 4 bits, max vaule = 0xF */ //// - frame->core.paramCount = paramCount; //Ŀ// -#endif - -#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT - frame->eventCount = g_traceEventCount; //׷¼ļ// - g_traceEventCount++; -#endif - TRACE_UNLOCK(intSave); - - for (i = 0; i < paramCount; i++) { - frame->params[i] = params[i]; - } -} - -VOID OsTraceSetObj(ObjData *obj, const LosTaskCB *tcb) //ö׷Ϣ// -{ - errno_t ret; - (VOID)memset_s(obj, sizeof(ObjData), 0, sizeof(ObjData)); - - obj->id = OsTraceGetMaskTid(tcb->taskId); //ȡID// - obj->prio = tcb->priority; //ȡȼ// - - ret = strncpy_s(obj->name, LOSCFG_TRACE_OBJ_MAX_NAME_SIZE, tcb->taskName, LOSCFG_TRACE_OBJ_MAX_NAME_SIZE - 1); - if (ret != EOK) { - TRACE_ERROR("Task name copy failed!\n"); - } -} - -//׷¼// -VOID OsTraceHook(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount) -{ - if ((eventType == TASK_CREATE) || (eventType == TASK_PRIOSET)) { - OsTraceObjAdd(eventType, identity); /* handle important obj info, these can not be filtered */ - } - - if ((g_enableTrace == TRUE) && (eventType & g_traceMask)) { - UINTPTR id = identity; - if (TRACE_GET_MODE_FLAG(eventType) == TRACE_HWI_FLAG) { - if (OsTraceHwiFilter(identity)) { - return; - } - } else if (TRACE_GET_MODE_FLAG(eventType) == TRACE_TASK_FLAG) { - id = OsTraceGetMaskTid(identity); - } else if (eventType == MEM_INFO_REQ) { - LOS_MEM_POOL_STATUS status; - LOS_MemInfoGet((VOID *)identity, &status); - LOS_TRACE(MEM_INFO, identity, status.uwTotalUsedSize, status.uwTotalFreeSize); - return; - } - - TraceEventFrame frame; - OsTraceSetFrame(&frame, eventType, id, params, paramCount); - - OsTraceWriteOrSendEvent(&frame); //׷¼Ϣдͳȥ// - } -} - -BOOL OsTraceIsEnable(VOID) //ж׷Ƿ״̬// -{ - return g_enableTrace == TRUE; -} - -STATIC VOID OsTraceHookInstall(VOID) //װ׷ٹ// -{ - g_traceEventHook = OsTraceHook; -#ifdef LOSCFG_RECORDER_MODE_OFFLINE - g_traceDumpHook = OsTraceRecordDump; //߼¼ģʽ׷ת// -#endif -} - -#ifdef LOSCFG_TRACE_CONTROL_AGENT -STATIC BOOL OsTraceCmdIsValid(const TraceClientCmd *msg) //жϴTraceClientCmdṹǷЧ// -{ - return ((msg->end == TRACE_CMD_END_CHAR) && (msg->cmd < TRACE_CMD_MAX_CODE)); -} - -STATIC VOID OsTraceCmdHandle(const TraceClientCmd *msg) //TraceClientCmdṹ// -{ - if (!OsTraceCmdIsValid(msg)) { - return; - } - - switch (msg->cmd) { - case TRACE_CMD_START: //׷// - LOS_TraceStart(); - break; - case TRACE_CMD_STOP: //ֹͣ׷// - LOS_TraceStop(); - break; - case TRACE_CMD_SET_EVENT_MASK: //¼// - /* 4 params(UINT8) composition the mask(UINT32) */ - LOS_TraceEventMaskSet(TRACE_MASK_COMBINE(msg->param1, msg->param2, msg->param3, msg->param4)); - break; - case TRACE_CMD_RECODE_DUMP: //׷ټ¼ת// - LOS_TraceRecordDump(TRUE); - break; - default: - break; - } -} - -VOID TraceAgent(VOID) //ϵȴ׷ݵĵյ׷// -{ - UINT32 ret; - TraceClientCmd msg; - - while (1) { - (VOID)memset_s(&msg, sizeof(TraceClientCmd), 0, sizeof(TraceClientCmd)); - ret = OsTraceDataWait(); - if (ret == LOS_OK) { - OsTraceDataRecv((UINT8 *)&msg, sizeof(TraceClientCmd), 0); - OsTraceCmdHandle(&msg); - } - } -} - -STATIC UINT32 OsCreateTraceAgentTask(VOID) //һ׷ٴִ׷߼// -{ - UINT32 ret; - TSK_INIT_PARAM_S taskInitParam; - - (VOID)memset_s((VOID *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); - taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TraceAgent; - taskInitParam.usTaskPrio = LOSCFG_TRACE_TASK_PRIORITY; - taskInitParam.pcName = "TraceAgent"; - taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; -#ifdef LOSCFG_KERNEL_SMP - taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid()); -#endif - ret = LOS_TaskCreate(&g_traceTaskId, &taskInitParam); - return ret; -} -#endif - -UINT32 LOS_TraceInit(VOID *buf, UINT32 size) //ʼ׷ٹ// -{ - UINT32 intSave; - UINT32 ret; - - TRACE_LOCK(intSave); - if (g_traceState != TRACE_UNINIT) { - TRACE_ERROR("trace has been initialized already, the current state is :%d\n", g_traceState); - ret = LOS_ERRNO_TRACE_ERROR_STATUS; - goto LOS_ERREND; - } - -#ifdef LOSCFG_TRACE_CLIENT_INTERACT //жǷҪʼ׷ٹܵ// - ret = OsTracePipelineInit(); - if (ret != LOS_OK) { - goto LOS_ERREND; - } -#endif - -#ifdef LOSCFG_TRACE_CONTROL_AGENT //жǷҪ׷ٴ// - ret = OsCreateTraceAgentTask(); - if (ret != LOS_OK) { - TRACE_ERROR("trace init create agentTask error :0x%x\n", ret); - goto LOS_ERREND; - } -#endif - - ret = OsTraceBufInit(buf, size); //ʼ׷ٻ// - if (ret != LOS_OK) { - goto LOS_RELEASE; - } - - OsTraceHookInstall(); //װ׷ٹ// - - g_traceEventCount = 0; - - /*жǷҪȴ׷ٿͻ׷*/ -#ifdef LOSCFG_RECORDER_MODE_ONLINE /* Wait trace client to start trace */ - g_enableTrace = FALSE; - g_traceState = TRACE_INITED; -#else - g_enableTrace = TRUE; - g_traceState = TRACE_STARTED; -#endif - TRACE_UNLOCK(intSave); - return LOS_OK; -LOS_RELEASE: -#ifdef LOSCFG_TRACE_CONTROL_AGENT //жǷҪɾ׷ٴ// - LOS_TaskDelete(g_traceTaskId); -#endif -LOS_ERREND: - TRACE_UNLOCK(intSave); - return ret; -} - -UINT32 LOS_TraceStart(VOID) //׷ٹ// -{ - UINT32 intSave; - UINT32 ret = LOS_OK; - - TRACE_LOCK(intSave); - if (g_traceState == TRACE_STARTED) { - goto START_END; - } - - if (g_traceState == TRACE_UNINIT) { - TRACE_ERROR("trace not inited, be sure LOS_TraceInit excute success\n"); - ret = LOS_ERRNO_TRACE_ERROR_STATUS; - goto START_END; - } - - OsTraceNotifyStart(); //֪ͨ׷ٹܿʼ// - - g_enableTrace = TRUE; - g_traceState = TRACE_STARTED; - - TRACE_UNLOCK(intSave); - LOS_TRACE(MEM_INFO_REQ, m_aucSysMem0); //׷Ϣ// - return ret; -START_END: - TRACE_UNLOCK(intSave); - return ret; -} - -VOID LOS_TraceStop(VOID) //ֹͣ׷ٹ// -{ - UINT32 intSave; - - TRACE_LOCK(intSave); - if (g_traceState != TRACE_STARTED) { - goto STOP_END; - } - - g_enableTrace = FALSE; - g_traceState = TRACE_STOPED; - OsTraceNotifyStop(); //֪ͨ׷ٹֹͣ// -STOP_END: - TRACE_UNLOCK(intSave); -} - -VOID LOS_TraceEventMaskSet(UINT32 mask) //׷¼// -{ - g_traceMask = mask & EVENT_MASK; -} - -VOID LOS_TraceRecordDump(BOOL toClient) //ת׷ټ¼// -{ - if (g_traceState != TRACE_STOPED) { - TRACE_ERROR("trace dump must after trace stopped , the current state is : %d\n", g_traceState); - return; - } - OsTraceRecordDump(toClient); -} - -OfflineHead *LOS_TraceRecordGet(VOID) //ȡ׷ټ¼// -{ - return OsTraceRecordGet(); -} - -VOID LOS_TraceReset(VOID) //׷ٹ// -{ - if (g_traceState == TRACE_UNINIT) { - TRACE_ERROR("trace not inited, be sure LOS_TraceInit excute success\n"); - return; - } - - OsTraceReset(); -} - -VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook) //עжϹ˹// -{ - UINT32 intSave; - - TRACE_LOCK(intSave); - g_traceHwiFliterHook = hook; - TRACE_UNLOCK(intSave); -} - -#ifdef LOSCFG_SHELL -LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTraceSetMask(INT32 argc, const CHAR **argv) //׷¼// -{ - size_t mask; - CHAR *endPtr = NULL; - - if (argc >= 2) { /* 2:Just as number of parameters */ - PRINTK("\nUsage: trace_mask or trace_mask ID\n"); - return OS_ERROR; - } - - if (argc == 0) { - mask = TRACE_DEFAULT_MASK; - } else { - mask = strtoul(argv[0], &endPtr, 0); - } - LOS_TraceEventMaskSet((UINT32)mask); - return LOS_OK; -} - -LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv) //׷ټ¼ת// -{ - BOOL toClient; - CHAR *endPtr = NULL; - - if (argc >= 2) { /* 2:Just as number of parameters */ - PRINTK("\nUsage: trace_dump or trace_dump [1/0]\n"); - return OS_ERROR; - } - - if (argc == 0) { - toClient = FALSE; - } else { - toClient = strtoul(argv[0], &endPtr, 0) != 0 ? TRUE : FALSE; - } - LOS_TraceRecordDump(toClient); - return LOS_OK; -} - -/*кע*/ -SHELLCMD_ENTRY(tracestart_shellcmd, CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart); //׷ٹܵ// -SHELLCMD_ENTRY(tracestop_shellcmd, CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop); //׷ٹֹܵͣ// -SHELLCMD_ENTRY(tracesetmask_shellcmd, CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask); //׷¼// -SHELLCMD_ENTRY(tracereset_shellcmd, CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset); //׷ټ¼// -SHELLCMD_ENTRY(tracedump_shellcmd, CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump); //ת׷ټ¼// -#endif - -#endif /* LOSCFG_KERNEL_TRACE */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/文豪/trace/pipeline/serial/trace_pipeline_serial.c b/文豪/trace/pipeline/serial/trace_pipeline_serial.c deleted file mode 100644 index e61300b..0000000 --- a/文豪/trace/pipeline/serial/trace_pipeline_serial.c +++ /dev/null @@ -1,98 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Pipeline of Serial Implementation - * Author: Huawei LiteOS Team - * Create: 2020-03-31 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "trace_pipeline_serial.h" -#include "trace_pipeline.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_TRACE_CONTROL_AGENT -UINT32 SerialPipelineInit(VOID) //ڳʼйܵ// -{ - return uart_hwiCreate(); -} - -UINT32 SerialDataReceive(UINT8 *data, UINT32 size, UINT32 timeout) //ڴӴйܵ// -{ - return uart_read(data, size, timeout); -} - -UINT32 SerialWait(VOID) //ڵȴйܵ׼// -{ - return uart_wait_adapt(); -} - -#else//4ų2930 - -UINT32 SerialPipelineInit(VOID) //ʾʼɹ// -{ - return LOS_OK; -} - -UINT32 SerialDataReceive(UINT8 *data, UINT32 size, UINT32 timeout) //ʾյ// -{ - return LOS_OK; -} - -UINT32 SerialWait(VOID) //ʾѾ׼// -{ - return LOS_OK; -} -#endif - -VOID SerialDataSend(UINT16 len, UINT8 *data) //йܵ// -{ - UINT32 i; - - for (i = 0; i < len; i++) { - UART_PUTC(data[i]); - } -} - -STATIC const TracePipelineOps g_serialOps = { - .init = SerialPipelineInit, - .dataSend = SerialDataSend, - .dataRecv = SerialDataReceive, - .wait = SerialWait, -}; - -UINT32 OsTracePipelineInit(VOID) //ڳʼ׷ٹܵע֮صIJӿ// -{ - OsTracePipelineReg(&g_serialOps); - return g_serialOps.init(); -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/文豪/trace/pipeline/serial/trace_pipeline_serial.h b/文豪/trace/pipeline/serial/trace_pipeline_serial.h deleted file mode 100644 index a3cf977..0000000 --- a/文豪/trace/pipeline/serial/trace_pipeline_serial.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Pipeline of Serial Implementation HeadFile - * Author: Huawei LiteOS Team - * Create: 2020-03-16 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#ifndef _TRACE_PIPELINE_SERIAL_H -#define _TRACE_PIPELINE_SERIAL_H - -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -extern INT32 uart_putc(CHAR c); //򴮿ڷһַ// - -#define UART_PUTC(c) uart_putc((c)) //uart_putc// - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _TRACE_PIPELINE_SERIAL_H */ diff --git a/文豪/trace/pipeline/trace_pipeline.c b/文豪/trace/pipeline/trace_pipeline.c deleted file mode 100644 index 33e5f63..0000000 --- a/文豪/trace/pipeline/trace_pipeline.c +++ /dev/null @@ -1,156 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Pipeline Implementation - * Author: Huawei LiteOS Team - * Create: 2020-03-31 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "trace_pipeline.h" -#include "trace_tlv.h" -#include "los_trace_pri.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -//ֹ// -LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_pipeSpin); //ʼһ// -#define PIPE_LOCK(state) LOS_SpinLockSave(&g_pipeSpin, &(state)) //// -#define PIPE_UNLOCK(state) LOS_SpinUnlockRestore(&g_pipeSpin, (state)) //// - -STATIC TlvTable g_traceTlvTblNotify[] = { //ṹijԱͺʹС// - { CMD, LOS_OFF_SET_OF(TraceNotifyFrame, cmd), sizeof(UINT32) }, - { PARAMS, LOS_OFF_SET_OF(TraceNotifyFrame, param), sizeof(UINT32) }, - { TRACE_TLV_TYPE_NULL, 0, 0 }, -}; - -STATIC TlvTable g_traceTlvTblHead[] = { //ṹijԱͺʹС// - { ENDIAN, LOS_OFF_SET_OF(TraceBaseHeaderInfo, bigLittleEndian), sizeof(UINT32) }, - { VERSION, LOS_OFF_SET_OF(TraceBaseHeaderInfo, version), sizeof(UINT32) }, - { CLOCK_FREQ, LOS_OFF_SET_OF(TraceBaseHeaderInfo, clockFreq), sizeof(UINT32) }, - { TRACE_TLV_TYPE_NULL, 0, 0 }, -}; - -STATIC TlvTable g_traceTlvTblObj[] = { //ṹijԱ͡ƫλúʹС// - { ADDR, LOS_OFF_SET_OF(ObjData, id), sizeof(UINT32) }, - { PRIO, LOS_OFF_SET_OF(ObjData, prio), sizeof(UINT32) }, - { NAME, LOS_OFF_SET_OF(ObjData, name), sizeof(CHAR) * LOSCFG_TRACE_OBJ_MAX_NAME_SIZE }, - { TRACE_TLV_TYPE_NULL, 0, 0 }, -}; - -STATIC TlvTable g_traceTlvTblEvent[] = { //ṹijԱͺʹС// -#ifdef LOSCFG_TRACE_FRAME_CORE_MSG - { CORE, LOS_OFF_SET_OF(TraceEventFrame, core), sizeof(UINT32) }, -#endif - { EVENT_CODE, LOS_OFF_SET_OF(TraceEventFrame, eventType), sizeof(UINT32) }, - { CUR_TIME, LOS_OFF_SET_OF(TraceEventFrame, curTime), sizeof(UINT64) }, - -#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT - { EVENT_COUNT, LOS_OFF_SET_OF(TraceEventFrame, eventCount), sizeof(UINT32) }, -#endif - { CUR_TASK, LOS_OFF_SET_OF(TraceEventFrame, curTask), sizeof(UINT32) }, - { IDENTITY, LOS_OFF_SET_OF(TraceEventFrame, identity), sizeof(UINTPTR) }, - { EVENT_PARAMS, LOS_OFF_SET_OF(TraceEventFrame, params), sizeof(UINTPTR) * LOSCFG_TRACE_FRAME_MAX_PARAMS }, - { TRACE_TLV_TYPE_NULL, 0, 0 }, -}; - -STATIC TlvTable *g_traceTlvTbl[] = { - g_traceTlvTblNotify, - g_traceTlvTblHead, - g_traceTlvTblObj, - g_traceTlvTblEvent -}; - -STATIC UINT32 DefaultPipelineInit(VOID) -{ - return LOS_OK; -} - -STATIC VOID DefaultDataSend(UINT16 len, UINT8 *data) -{ //lendataΪ"δʹ"// - (VOID)len; //// - (VOID)data; -} - -STATIC UINT32 DefaultDataReceive(UINT8 *data, UINT32 size, UINT32 timeout) -{ - (VOID)data; //datasizetimeoutΪ"δʹ"// - (VOID)size; - (VOID)timeout; - return LOS_OK; -} - -STATIC UINT32 DefaultWait(VOID) -{ - return LOS_OK; -} - -STATIC TracePipelineOps g_defaultOps = { - .init = DefaultPipelineInit, - .dataSend = DefaultDataSend, - .dataRecv = DefaultDataReceive, - .wait = DefaultWait, -}; - -STATIC const TracePipelineOps *g_tracePipelineOps = &g_defaultOps; - -VOID OsTracePipelineReg(const TracePipelineOps *ops) -{ - g_tracePipelineOps = ops; //עһTracePipelineOpsṹָ// -} - -VOID OsTraceDataSend(UINT8 type, UINT16 len, UINT8 *data) //ڷ׷// -{ - UINT32 intSave; - UINT8 outBuf[LOSCFG_TRACE_TLV_BUF_SIZE] = {0}; - - if ((type > TRACE_MSG_MAX) || (len > LOSCFG_TRACE_TLV_BUF_SIZE)) { //ĺϷԼ// - return; - } - - //ݽб// - len = OsTraceDataEncode(type, g_traceTlvTbl[type], data, &outBuf[0], sizeof(outBuf)); - - PIPE_LOCK(intSave); //ȡֹ̲ܵ߳// - g_tracePipelineOps->dataSend(len, &outBuf[0]); //ͱ// - PIPE_UNLOCK(intSave); //ͷŹܵ// -} - -UINT32 OsTraceDataRecv(UINT8 *data, UINT32 size, UINT32 timeout) //ڽ׷// -{ - return g_tracePipelineOps->dataRecv(data, size, timeout); -} - -UINT32 OsTraceDataWait(VOID) //ڵȴ׷// -{ - return g_tracePipelineOps->wait(); -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/文豪/trace/pipeline/trace_pipeline.h b/文豪/trace/pipeline/trace_pipeline.h deleted file mode 100644 index 49e292b..0000000 --- a/文豪/trace/pipeline/trace_pipeline.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Pipeline Implementation HeadFile - * Author: Huawei LiteOS Team - * Create: 2020-03-16 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#ifndef _TRACE_PIPELINE_H -#define _TRACE_PIPELINE_H - -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -/*ʵ׷ˮߵĹ*/ -typedef struct { - UINT32 (*init)(VOID); //ڳʼ// - VOID (*dataSend)(UINT16 len, UINT8 *data); //ڷ// - UINT32 (*dataRecv)(UINT8 *data, UINT32 size, UINT32 timeout); //ڽ// - UINT32 (*wait)(VOID); //ڵȴ// -} TracePipelineOps; - -/* used as tlv's tag */ -enum TraceMsgType { //ڱʾ׷Ϣ// - //// - NOTIFY, //֪ͨ// - HEAD, //ͷ// - OBJ, //// - EVENT, //¼// - - TRACE_MSG_MAX, //ֵ// -}; - -enum TraceNotifySubType { //ڱʾ֪ͨϢ// - CMD = 0x1, - PARAMS, -}; - -enum TraceHeadSubType { //ڱʾ׷ͷϢ// - ENDIAN = 0x1, //ֽ// - VERSION, //汾// - OBJ_SIZE, //С// - OBJ_COUNT, //// - CUR_INDEX, //ǰ// - MAX_RECODE, - CUR_OBJ_INDEX, - CLOCK_FREQ, -}; - -enum TraceObjSubType { //ڱʾ׷ٶ// - ADDR = 0x1, //ַ// - PRIO, //ȼ/ - NAME, //// -}; - -enum TraceEvtSubType { //ڱʾ׷¼// - CORE = 0x1, //ı// - EVENT_CODE, //¼// - CUR_TIME, //ǰʱ// - EVENT_COUNT, //¼// - CUR_TASK, //ǰ// - IDENTITY, //Ϣ// - EVENT_PARAMS, //¼// -}; - -extern VOID OsTracePipelineReg(const TracePipelineOps *ops); //ע׷ٹܵ// -extern UINT32 OsTracePipelineInit(VOID); //ڳʼ׷ٹܵ// - -extern VOID OsTraceDataSend(UINT8 type, UINT16 len, UINT8 *data); //ڷ׷// -extern UINT32 OsTraceDataRecv(UINT8 *data, UINT32 size, UINT32 timeout); //ڽ׷// -extern UINT32 OsTraceDataWait(VOID); //ڵȴ׷// - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _TRACE_PIPELINE_H */ diff --git a/文豪/trace/pipeline/trace_tlv.c b/文豪/trace/pipeline/trace_tlv.c deleted file mode 100644 index 4545766..0000000 --- a/文豪/trace/pipeline/trace_tlv.c +++ /dev/null @@ -1,121 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Tlv Implementation - * Author: Huawei LiteOS Team - * Create: 2020-03-31 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "trace_tlv.h" -#include "securec.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define CRC_WIDTH 8 //CRCλ// -#define CRC_POLY 0x1021 //CRCʽ// -#define CRC_TOPBIT 0x8000 //CRCеλ// - -STATIC UINT16 CalcCrc16(const UINT8 *buf, UINT32 len) //ڼ16λCRCУֵ// -{ - UINT32 i; - UINT16 crc = 0; - - for (; len > 0; len--) { - crc = crc ^ (*buf++ << CRC_WIDTH); - for (i = 0; i < CRC_WIDTH; i++) { - if (crc & CRC_TOPBIT) { - crc = (crc << 1) ^ CRC_POLY; - } else { - crc <<= 1; - } - } - } - return crc; -} - -STATIC UINT32 OsWriteTlv(UINT8 *tlvBuf, UINT8 type, UINT8 len, UINT8 *value) //TLVдTLV// -{ - TraceMsgTlvBody *body = (TraceMsgTlvBody *)tlvBuf; - - if (len == 0) { - return 0; - } - - body->type = type; - body->len = len; - /* Do not check return value for performance, if copy failed, only this package will be discarded */ - (VOID)memcpy_s(body->value, len, value, len); - return len + sizeof(body->type) + sizeof(body->len); //ʵдֽ// -} - -/*TLVеĶ壬ԴݱTLVʽдTLV*/ -STATIC UINT32 OsTlvEncode(const TlvTable *table, UINT8 *srcBuf, UINT8 *tlvBuf, INT32 tlvBufLen) -{ - UINT32 len = 0; - const TlvTable *tlvTableItem = table; - - while (tlvTableItem->tag != TRACE_TLV_TYPE_NULL) { - if ((len + tlvTableItem->elemSize + sizeof(UINT8) + sizeof(UINT8)) > tlvBufLen) { - break; - } - len += OsWriteTlv(tlvBuf + len, tlvTableItem->tag, tlvTableItem->elemSize, srcBuf + tlvTableItem->elemOffset); - tlvTableItem++; - } - return len; -} - -/*ԴݰTLVĶ룬дĿ껺*/ -UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen) -{ - UINT16 crc; - INT32 len; - INT32 tlvBufLen; - UINT8 *tlvBuf = NULL; - - TraceMsgTlvHead *head = (TraceMsgTlvHead *)dest; - tlvBufLen = destLen - sizeof(TraceMsgTlvHead); - - if ((tlvBufLen <= 0) || (table == NULL)) { - return 0; - } - - tlvBuf = dest + sizeof(TraceMsgTlvHead); - len = OsTlvEncode(table, src, tlvBuf, tlvBufLen); - crc = CalcCrc16(tlvBuf, len); - - head->magicNum = TRACE_TLV_MSG_HEAD; - head->msgType = type; - head->len = len; - head->crc = crc; - return len + sizeof(TraceMsgTlvHead); -} - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/文豪/trace/pipeline/trace_tlv.h b/文豪/trace/pipeline/trace_tlv.h deleted file mode 100644 index 1871012..0000000 --- a/文豪/trace/pipeline/trace_tlv.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Tlv Implementation HeadFile - * Author: Huawei LiteOS Team - * Create: 2020-03-16 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#ifndef _TRACE_TLV_H -#define _TRACE_TLV_H - -#include "los_typedef.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#define TRACE_TLV_MSG_HEAD 0xFF -#define TRACE_TLV_TYPE_NULL 0xFF - -typedef struct { - UINT8 magicNum; //ħ// - UINT8 msgType; //Ϣ// - UINT16 len; //Ϣ// - UINT16 crc; //CRCУ// -} TraceMsgTlvHead; //TLVϢͷ// - -typedef struct { - UINT8 type; //Ϣ/// - UINT8 len; //Ϣ// - UINT8 value[]; //// -} TraceMsgTlvBody; //TLVϢϢ// - -typedef struct { - UINT8 tag; //ǩ// - UINT8 elemOffset; //Ԫƫ// - UINT8 elemSize; //ԪشС// -} TlvTable; //TLV// - -/** - * @ingroup los_trace - * @brief Encode trace raw data. - * - * @par Description: - * This API is used to encode trace raw data to tlv data. - * @attention - *
    - *
  • Encade trace data
  • - *
- * - * @param type [IN] Type #UINT8. The type stands for different struct of src data. - * @param src [IN] Type #UINT8 *. The raw trace data. - * @param table [IN] Type #const TlvTable *. The tlv table descript elemOffset and elemSize. - * @param dest [OUT] Type #UINT8 *. The tlv data. - * @param destLen [IN] Type #UINT8 *. The tlv buf max len. - - * @retval #0 convert failed. - * @retval #UINT32 convert success bytes. - * - * @par Dependency: - *
  • trace_tlv.h: the header file that contains the API declaration.
- * @see LOS_TraceDataEncode - * @since Huawei LiteOS V200R005C00 - */ -extern UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen); -/*TLVϢԭʼ׷ݽб룬ӦTLV*/ -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif /* _TRACE_TLV_H */ \ No newline at end of file diff --git a/文豪/trace/trace_offline.c b/文豪/trace/trace_offline.c deleted file mode 100644 index f23a43f..0000000 --- a/文豪/trace/trace_offline.c +++ /dev/null @@ -1,264 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Offline Mode Implementation - * Author: Huawei LiteOS Team - * Create: 2020-03-31 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_trace_pri.h" -#include "trace_pipeline.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_RECORDER_MODE_OFFLINE -#define BITS_NUM_FOR_TASK_ID 16 //ָIDλ// - -LITE_OS_SEC_BSS STATIC TraceOfflineHeaderInfo g_traceRecoder; //¼߸ټ¼Ϣ// -LITE_OS_SEC_BSS STATIC UINT32 g_tidMask[LOSCFG_BASE_CORE_TSK_LIMIT] = {0}; //ڴ洢ID// - -UINT32 OsTraceGetMaskTid(UINT32 tid) //ڻȡID// -{ - return tid | ((tid < LOSCFG_BASE_CORE_TSK_LIMIT) ? g_tidMask[tid] << BITS_NUM_FOR_TASK_ID : 0); /* tid < 65535 */ -} - -UINT32 OsTraceBufInit(VOID *buf, UINT32 size) //ڳʼ߸ٻ// -{ - UINT32 headSize; - - headSize = sizeof(OfflineHead) + sizeof(ObjData) * LOSCFG_TRACE_OBJ_MAX_NUM; //ڴ洢߸ټ¼ͷϢ// - if (size <= headSize) { - TRACE_ERROR("trace buf size not enough than 0x%x\n", headSize); - return LOS_ERRNO_TRACE_BUF_TOO_SMALL; - } - - if (buf == NULL) { - buf = LOS_MemAlloc(m_aucSysMem1, size); - if (buf == NULL) { - return LOS_ERRNO_TRACE_NO_MEMORY; - } - } - - (VOID)memset_s(buf, size, 0, size); - g_traceRecoder.head = (OfflineHead *)buf; - g_traceRecoder.head->baseInfo.bigLittleEndian = TRACE_BIGLITTLE_WORD; - g_traceRecoder.head->baseInfo.version = TRACE_VERSION(TRACE_MODE_OFFLINE); - g_traceRecoder.head->baseInfo.clockFreq = GET_SYS_CLOCK(); - g_traceRecoder.head->objSize = sizeof(ObjData); - g_traceRecoder.head->frameSize = sizeof(TraceEventFrame); - g_traceRecoder.head->objOffset = sizeof(OfflineHead); - g_traceRecoder.head->frameOffset = headSize; - g_traceRecoder.head->totalLen = size; - - g_traceRecoder.ctrl.curIndex = 0; - g_traceRecoder.ctrl.curObjIndex = 0; - g_traceRecoder.ctrl.maxObjCount = LOSCFG_TRACE_OBJ_MAX_NUM; - g_traceRecoder.ctrl.maxRecordCount = (size - headSize) / sizeof(TraceEventFrame); - g_traceRecoder.ctrl.objBuf = (ObjData *)((UINTPTR)buf + g_traceRecoder.head->objOffset); - g_traceRecoder.ctrl.frameBuf = (TraceEventFrame *)((UINTPTR)buf + g_traceRecoder.head->frameOffset); - - return LOS_OK; -} - -VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId) //߸ٻӶ// -{ - UINT32 intSave; - UINT32 index; - ObjData *obj = NULL; - - TRACE_LOCK(intSave); - /* add obj begin */ - index = g_traceRecoder.ctrl.curObjIndex; - if (index >= LOSCFG_TRACE_OBJ_MAX_NUM) { /* do nothing when config LOSCFG_TRACE_OBJ_MAX_NUM = 0 */ - TRACE_UNLOCK(intSave); - return; - } - obj = &g_traceRecoder.ctrl.objBuf[index]; - - if (taskId < LOSCFG_BASE_CORE_TSK_LIMIT) { - g_tidMask[taskId]++; - } - - OsTraceSetObj(obj, OS_TCB_FROM_TID(taskId)); - - g_traceRecoder.ctrl.curObjIndex++; - if (g_traceRecoder.ctrl.curObjIndex >= g_traceRecoder.ctrl.maxObjCount) { - g_traceRecoder.ctrl.curObjIndex = 0; /* turn around */ - } - /* add obj end */ - TRACE_UNLOCK(intSave); -} - -VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame) //߸ٻд¼֡// -{ - UINT16 index; - UINT32 intSave; - - TRACE_LOCK(intSave); - index = g_traceRecoder.ctrl.curIndex; - (VOID)memcpy_s(&g_traceRecoder.ctrl.frameBuf[index], sizeof(TraceEventFrame), frame, sizeof(TraceEventFrame)); - - g_traceRecoder.ctrl.curIndex++; - if (g_traceRecoder.ctrl.curIndex >= g_traceRecoder.ctrl.maxRecordCount) { - g_traceRecoder.ctrl.curIndex = 0; - } - TRACE_UNLOCK(intSave); -} - -VOID OsTraceReset(VOID) //߸ٻ// -{ - UINT32 intSave; - UINT32 bufLen; - - TRACE_LOCK(intSave); - bufLen = sizeof(TraceEventFrame) * g_traceRecoder.ctrl.maxRecordCount; - (VOID)memset_s(g_traceRecoder.ctrl.frameBuf, bufLen, 0, bufLen); - g_traceRecoder.ctrl.curIndex = 0; - TRACE_UNLOCK(intSave); -} - -STATIC VOID OsTraceInfoObj(VOID) //ڴӡ߸ٶϢ// -{ - UINT32 i; - ObjData *obj = &g_traceRecoder.ctrl.objBuf[0]; - - if (g_traceRecoder.ctrl.maxObjCount > 0) { - PRINTK("CurObjIndex = %u\n", g_traceRecoder.ctrl.curObjIndex); - PRINTK("Index TaskID TaskPrio TaskName \n"); - for (i = 0; i < g_traceRecoder.ctrl.maxObjCount; i++, obj++) { - PRINTK("%-7u 0x%-6x %-10u %s\n", i, obj->id, obj->prio, obj->name); - } - PRINTK("\n"); - } -} - -STATIC VOID OsTraceInfoEventTitle(VOID) //ڴӡ߸¼// -{ - PRINTK("CurEvtIndex = %u\n", g_traceRecoder.ctrl.curIndex); - - PRINTK("Index Time(cycles) EventType CurTask Identity "); -#ifdef LOSCFG_TRACE_FRAME_CORE_MSG - PRINTK("cpuId hwiActive taskLockCnt "); -#endif -#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT - PRINTK("eventCount "); -#endif - if (LOSCFG_TRACE_FRAME_MAX_PARAMS > 0) { - PRINTK("params "); - } - PRINTK("\n"); -} - -STATIC VOID OsTraceInfoEventData(VOID) //ڴӡ߸¼// -{ - UINT32 i, j; - TraceEventFrame *frame = &g_traceRecoder.ctrl.frameBuf[0]; - - for (i = 0; i < g_traceRecoder.ctrl.maxRecordCount; i++, frame++) { - PRINTK("%-7u 0x%-15llx 0x%-12x 0x%-7x 0x%-11x ", i, frame->curTime, frame->eventType, - frame->curTask, frame->identity); -#ifdef LOSCFG_TRACE_FRAME_CORE_MSG - UINT32 taskLockCnt = frame->core.taskLockCnt; -#ifdef LOSCFG_KERNEL_SMP - /* - * For smp systems, TRACE_LOCK will requst taskLock, and this counter - * will increase by 1 in that case. - */ - taskLockCnt -= 1; -#endif - PRINTK("%-11u %-11u %-11u", frame->core.cpuId, frame->core.hwiActive, taskLockCnt); -#endif -#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT - PRINTK("%-11u", frame->eventCount); -#endif - for (j = 0; j < LOSCFG_TRACE_FRAME_MAX_PARAMS; j++) { - PRINTK("0x%-11x", frame->params[j]); - } - PRINTK("\n"); - } -} - -STATIC VOID OsTraceInfoDisplay(VOID) //ʾ߸Ϣ// -{ - OfflineHead *head = g_traceRecoder.head; - - PRINTK("*******TraceInfo begin*******\n"); - PRINTK("clockFreq = %u\n", head->baseInfo.clockFreq); - - OsTraceInfoObj(); - - OsTraceInfoEventTitle(); - OsTraceInfoEventData(); - - PRINTK("*******TraceInfo end*******\n"); -} - -#ifdef LOSCFG_TRACE_CLIENT_INTERACT -STATIC VOID OsTraceSendInfo(VOID) //ڷ߸Ϣ// -{ - UINT32 i; - ObjData *obj = NULL; - TraceEventFrame *frame = NULL; - - OsTraceDataSend(HEAD, sizeof(OfflineHead), (UINT8 *)g_traceRecoder.head); - - obj = &g_traceRecoder.ctrl.objBuf[0]; - for (i = 0; i < g_traceRecoder.ctrl.maxObjCount; i++) { - OsTraceDataSend(OBJ, sizeof(ObjData), (UINT8 *)(obj + i)); - } - - frame = &g_traceRecoder.ctrl.frameBuf[0]; - for (i = 0; i < g_traceRecoder.ctrl.maxRecordCount; i++) { - OsTraceDataSend(EVENT, sizeof(TraceEventFrame), (UINT8 *)(frame + i)); - } -} -#endif - -VOID OsTraceRecordDump(BOOL toClient) //߸Ϣ// -{ - if (!toClient) { //ָʾǷ߸Ϣ// - OsTraceInfoDisplay(); - return; - } - -#ifdef LOSCFG_TRACE_CLIENT_INTERACT - OsTraceSendInfo(); -#endif -} - -OfflineHead *OsTraceRecordGet(VOID) //ڻȡ߸ټ¼ͷϢ// -{ - return g_traceRecoder.head; -} - -#endif /* LOSCFG_RECORDER_MODE_OFFLINE */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ diff --git a/文豪/trace/trace_online.c b/文豪/trace/trace_online.c deleted file mode 100644 index 6faba44..0000000 --- a/文豪/trace/trace_online.c +++ /dev/null @@ -1,117 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: LiteOS Trace Online Mode Implementation - * Author: Huawei LiteOS Team - * Create: 2020-03-31 - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior written - * permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * --------------------------------------------------------------------------- */ - -#include "los_trace_pri.h" -#include "trace_pipeline.h" - -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#ifdef LOSCFG_RECORDER_MODE_ONLINE -UINT32 OsTraceGetMaskTid(UINT32 taskId) //ڻȡID// -{ - return taskId; -} - -UINT32 OsTraceBufInit(VOID *buf, UINT32 size) //ʼٻ// -{ - (VOID)buf; - (VOID)size; - return LOS_OK; -} - -VOID OsTraceSendHead(VOID) //͸ݵͷϢ// -{ - TraceBaseHeaderInfo head = { - .bigLittleEndian = TRACE_BIGLITTLE_WORD, - .version = TRACE_VERSION(TRACE_MODE_ONLINE), - .clockFreq = GET_SYS_CLOCK(), - }; - - OsTraceDataSend(HEAD, sizeof(TraceBaseHeaderInfo), (UINT8 *)&head); -} - -VOID OsTraceSendNotify(UINT32 type, UINT32 value) //֪ͨ͵ĸ// -{ - TraceNotifyFrame frame = { - .cmd = type, - .param = value, - }; - - OsTraceDataSend(NOTIFY, sizeof(TraceNotifyFrame), (UINT8 *)&frame); -} - -STATIC VOID OsTraceSendObj(const LosTaskCB *tcb) //ͶΪobjĸ// -{ - ObjData obj; - - OsTraceSetObj(&obj, tcb); - OsTraceDataSend(OBJ, sizeof(ObjData), (UINT8 *)&obj); -} - -VOID OsTraceSendObjTable(VOID) //Ͷ͵ĸ// -{ - UINT32 loop; - LosTaskCB *tcb = NULL; - - for (loop = 0; loop < g_taskMaxNum; ++loop) { - tcb = g_taskCBArray + loop; - if (tcb->taskStatus & OS_TASK_STATUS_UNUSED) { - continue; - } - OsTraceSendObj(tcb); - } -} - -VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId) //ټ¼Ӷ// -{ - if (OsTraceIsEnable()) { - OsTraceSendObj(OS_TCB_FROM_TID(taskId)); - } -} - -VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame) //¼// -{ - OsTraceDataSend(EVENT, sizeof(TraceEventFrame), (UINT8 *)frame); -} - -OfflineHead *OsTraceRecordGet(VOID) //ȡ߸ټ¼ͷ// -{ - return NULL; //ʾû߸ټ¼// -} - -#endif /* LOSCFG_RECORDER_MODE_ONLINE */ - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */