add OpenHarmony 1.0 baseline

This commit is contained in:
wenjun
2020-09-08 10:21:39 +08:00
parent 94f5f466b4
commit 6df931fc98
736 changed files with 111817 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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 "stdio.h"
#include "stdlib.h"
#include "los_signal.h"
#include "los_printf.h"
#include "los_task_pri.h"
#include "los_process_pri.h"
#include "log.h"
#ifdef LOSCFG_SHELL
#include "shcmd.h"
#include "shell.h"
#endif
LITE_OS_SEC_TEXT_MINOR VOID OsPrintKillUsage(VOID)
{
PRINTK("\nkill: usage: kill [sigspec] [pid]\n");
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdKill(INT32 argc, const CHAR **argv)
{
#define ARG_NUM 2
INT32 sigNo = 0;
INT32 pidNo = 0;
INT32 ret;
CHAR *endPtr = NULL;
if (argc == ARG_NUM) {
sigNo = strtoul(argv[0], &endPtr, 0);
if (*endPtr != 0) {
PRINTK("\nsigNo can't access %s.\n", argv[0]);
goto ERROR;
}
endPtr = NULL;
pidNo = strtoul(argv[1], &endPtr, 0);
if (*endPtr != 0) {
PRINTK("\npidNo can't access %s.\n", argv[1]);
goto ERROR;
}
ret = OsKill(pidNo, abs(sigNo), OS_USER_KILL_PERMISSION);
HILOG_INFO(LOG_CORE, "Send signal(%d) to pidNo = %d!\n", abs(sigNo), pidNo);
if (ret == -1) {
HILOG_ERROR(LOG_CORE, "Kill fail ret = %d! Operation not permitted\n", ret);
goto ERROR;
}
if (ret < 0) {
PRINTK("\n Kill fail ret = %d! process not exist or sigNo is invalid\n", ret);
goto ERROR;
}
} else {
PRINTK("\nPara number errno!\n");
goto ERROR;
}
return 0;
ERROR:
OsPrintKillUsage();
return 0;
}
#ifdef LOSCFG_SHELL
SHELLCMD_ENTRY(kill_shellcmd, CMD_TYPE_EX, "kill", 2, (CmdCallBackFunc)OsShellCmdKill);
#endif

69
kernel/base/misc/los_misc.c Executable file
View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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
#endif /* __cplusplus */
LITE_OS_SEC_TEXT UINTPTR LOS_Align(UINTPTR addr, UINT32 boundary)
{
if ((addr + boundary - 1) > addr) {
return (addr + boundary - 1) & ~((UINTPTR)(boundary - 1));
} else {
return addr & ~((UINTPTR)(boundary - 1));
}
}
LITE_OS_SEC_TEXT_MINOR VOID LOS_Msleep(UINT32 msecs)
{
UINT32 interval;
if (msecs == 0) {
interval = 0;
} else {
interval = LOS_MS2Tick(msecs);
if (interval == 0) {
interval = 1;
}
}
(VOID)LOS_TaskDelay(interval);
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

125
kernel/base/misc/los_stackinfo.c Executable file
View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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_stackinfo_pri.h"
#include "los_printf_pri.h"
#include "los_config.h"
#ifdef LOSCFG_SHELL
#include "shcmd.h"
#include "shell.h"
#endif
const StackInfo *g_stackInfo = NULL;
UINT32 g_stackNum;
UINT32 OsStackWaterLineGet(const UINTPTR *stackBottom, const UINTPTR *stackTop, UINT32 *peakUsed)
{
UINT32 size;
const UINTPTR *tmp = NULL;
if (*stackTop == OS_STACK_MAGIC_WORD) {
tmp = stackTop + 1;
while ((tmp < stackBottom) && (*tmp == OS_STACK_INIT)) {
tmp++;
}
size = (UINT32)((UINTPTR)stackBottom - (UINTPTR)tmp);
*peakUsed = (size == 0) ? size : (size + sizeof(CHAR *));
return LOS_OK;
} else {
*peakUsed = OS_INVALID_WATERLINE;
return LOS_NOK;
}
}
VOID OsExcStackCheck(VOID)
{
UINT32 index;
UINT32 cpuid;
UINTPTR *stackTop = NULL;
if (g_stackInfo == NULL) {
return;
}
for (index = 0; index < g_stackNum; index++) {
for (cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
stackTop = (UINTPTR *)((UINTPTR)g_stackInfo[index].stackTop + cpuid * g_stackInfo[index].stackSize);
if (*stackTop != OS_STACK_MAGIC_WORD) {
PRINT_ERR("cpu:%u %s overflow , magic word changed to 0x%x\n",
LOSCFG_KERNEL_CORE_NUM - 1 - cpuid, g_stackInfo[index].stackName, *stackTop);
}
}
}
}
VOID OsExcStackInfo(VOID)
{
UINT32 index;
UINT32 cpuid;
UINT32 size;
UINTPTR *stackTop = NULL;
UINTPTR *stack = NULL;
if (g_stackInfo == NULL) {
return;
}
PrintExcInfo("\n stack name cpu id stack addr total size used size\n"
" ---------- ------ --------- -------- --------\n");
for (index = 0; index < g_stackNum; index++) {
for (cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
stackTop = (UINTPTR *)((UINTPTR)g_stackInfo[index].stackTop + cpuid * g_stackInfo[index].stackSize);
stack = (UINTPTR *)((UINTPTR)stackTop + g_stackInfo[index].stackSize);
(VOID)OsStackWaterLineGet(stack, stackTop, &size);
PrintExcInfo("%11s %-5d %-10p 0x%-8x 0x%-4x\n", g_stackInfo[index].stackName,
LOSCFG_KERNEL_CORE_NUM - 1 - cpuid, stackTop, g_stackInfo[index].stackSize, size);
}
}
OsExcStackCheck();
}
VOID OsExcStackInfoReg(const StackInfo *stackInfo, UINT32 stackNum)
{
g_stackInfo = stackInfo;
g_stackNum = stackNum;
}
VOID OsStackInit(VOID *stacktop, UINT32 stacksize)
{
/* initialize the task stack, write magic num to stack top */
(VOID)memset_s(stacktop, stacksize, (INT32)OS_STACK_INIT, stacksize);
*((UINTPTR *)stacktop) = OS_STACK_MAGIC_WORD;
}
#ifdef LOSCFG_SHELL_CMD_DEBUG
SHELLCMD_ENTRY(stack_shellcmd, CMD_TYPE_EX, "stack", 1, (CmdCallBackFunc)OsExcStackInfo);
#endif

342
kernel/base/misc/mempt_shellcmd.c Executable file
View File

@@ -0,0 +1,342 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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 "stdlib.h"
#include "los_memory_pri.h"
#ifdef LOSCFG_MEM_RECORDINFO
#include "los_memrecord_pri.h"
#endif
#ifdef LOSCFG_SHELL_EXCINFO
#include "los_excinfo_pri.h"
#endif
#ifdef LOSCFG_SHELL
#include "shcmd.h"
#include "shell.h"
#endif
#include "los_vm_common.h"
#include "los_vm_boot.h"
#include "los_vm_map.h"
#include "los_vm_dump.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define MEM_SIZE_1K 0x400
#define MEM_SIZE_1M 0x100000
#define MEMPT_ARG_NUM_2 2
#define MEM_SIZE_TO_KB(size) (((size) + (MEM_SIZE_1K >> 1)) / MEM_SIZE_1K)
#define MEM_SIZE_TO_MB(size) (((size) + (MEM_SIZE_1M >> 1)) / MEM_SIZE_1M)
VOID OsDumpMemByte(size_t length, UINTPTR addr)
{
size_t dataLen;
UINTPTR *alignAddr = NULL;
UINT32 count = 0;
dataLen = ALIGN(length, sizeof(UINTPTR));
alignAddr = (UINTPTR *)TRUNCATE(addr, sizeof(UINTPTR));
if ((dataLen == 0) || (alignAddr == NULL)) {
return;
}
while (dataLen) {
if (IS_ALIGNED(count, sizeof(CHAR *))) {
PRINTK("\n 0x%lx :", alignAddr);
#ifdef LOSCFG_SHELL_EXCINFO
WriteExcInfoToBuf("\n 0x%lx :", alignAddr);
#endif
}
#ifdef __LP64__
PRINTK("%0+16lx ", *alignAddr);
#else
PRINTK("%0+8lx ", *alignAddr);
#endif
#ifdef LOSCFG_SHELL_EXCINFO
#ifdef __LP64__
WriteExcInfoToBuf("0x%0+16x ", *alignAddr);
#else
WriteExcInfoToBuf("0x%0+8x ", *alignAddr);
#endif
#endif
alignAddr++;
dataLen -= sizeof(CHAR *);
count++;
}
PRINTK("\n");
#ifdef LOSCFG_SHELL_EXCINFO
WriteExcInfoToBuf("\n");
#endif
return;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[])
{
if (argc > 0) {
PRINTK("\nUsage: memcheck\n");
return OS_ERROR;
}
if (LOS_MemIntegrityCheck(m_aucSysMem1) == LOS_OK) {
PRINTK("system memcheck over, all passed!\n");
#ifdef LOSCFG_SHELL_EXCINFO
WriteExcInfoToBuf("system memcheck over, all passed!\n");
#endif
}
#ifdef LOSCFG_EXC_INTERACTION
if (LOS_MemIntegrityCheck(m_aucSysMem0) == LOS_OK) {
PRINTK("exc interaction memcheck over, all passed!\n");
#ifdef LOSCFG_SHELL_EXCINFO
WriteExcInfoToBuf("exc interaction memcheck over, all passed!\n");
#endif
}
#endif
return 0;
}
#ifdef LOSCFG_SHELL
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemRead(INT32 argc, const CHAR *argv[])
{
size_t tempAddr;
size_t length;
CHAR *ptrlen = NULL;
CHAR *ptrAddr = NULL;
if ((argc == 0) || (argc > 2)) { /* argc is num of parameters */
PRINTK("\nUsage: readreg [ADDRESS] [LENGTH]\n");
return OS_ERROR;
}
if (argc == 1) {
length = 0;
} else {
length = strtoul(argv[1], &ptrlen, 0);
if ((ptrlen == NULL) || (*ptrlen != 0)) {
PRINTK("readreg invalid length %s\n", argv[1]);
return OS_ERROR;
}
}
tempAddr = strtoul(argv[0], &ptrAddr, 0);
if ((ptrAddr == NULL) || (*ptrAddr != 0)) {
PRINTK("readreg invalid address %s\n", argv[0]);
return OS_ERROR;
}
if (OsVmAddrCheck(tempAddr, length) == LOS_OK) {
goto DONE;
}
PRINTK("readreg invalid address %s\n", argv[0]);
return OS_ERROR;
DONE:
OsDumpMemByte(length, tempAddr);
return 0;
}
LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdSectionInfo(INT32 argc, const CHAR *argv[])
{
size_t textLen = &__text_end - &__text_start;
size_t dataLen = &__ram_data_end - &__ram_data_start;
size_t rodataLen = &__rodata_end - &__rodata_start;
size_t bssLen = &__bss_end - &__bss_start;
PRINTK("\r\n text data rodata bss\n");
if ((argc == 1) && (strcmp(argv[0], "-k") == 0)) {
PRINTK("Mem: %-9lu %-10lu %-10lu %-10lu\n", MEM_SIZE_TO_KB(textLen), MEM_SIZE_TO_KB(dataLen),
MEM_SIZE_TO_KB(rodataLen), MEM_SIZE_TO_KB(bssLen));
} else if ((argc == 1) && (strcmp(argv[0], "-m") == 0)) {
PRINTK("Mem: %-9lu %-10lu %-10lu %-10lu\n", MEM_SIZE_TO_MB(textLen), MEM_SIZE_TO_MB(dataLen),
MEM_SIZE_TO_MB(rodataLen), MEM_SIZE_TO_MB(bssLen));
} else {
PRINTK("Mem: %-9lu %-10lu %-10lu %-10lu\n", textLen, dataLen, rodataLen, bssLen);
}
}
LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OsShellCmdFreeInfo(INT32 argc, const CHAR *argv[])
{
#ifdef LOSCFG_EXC_INTERACTION
UINT32 memUsed0 = LOS_MemTotalUsedGet(m_aucSysMem0);
UINT32 totalMem0 = LOS_MemPoolSizeGet(m_aucSysMem0);
UINT32 freeMem0 = totalMem0 - memUsed0;
#endif
UINT32 memUsed = LOS_MemTotalUsedGet(m_aucSysMem1);
UINT32 totalMem = LOS_MemPoolSizeGet(m_aucSysMem1);
UINT32 freeMem = totalMem - memUsed;
UINT32 usedCount, totalCount;
UINT32 memUsedHeap = memUsed;
OsVmPhysUsedInfoGet(&usedCount, &totalCount);
totalMem = SYS_MEM_SIZE_DEFAULT;
memUsed = SYS_MEM_SIZE_DEFAULT - (totalCount << PAGE_SHIFT);
memUsed += (usedCount << PAGE_SHIFT) - freeMem;
freeMem = totalMem - memUsed;
if ((argc == 0) ||
((argc == 1) && (strcmp(argv[0], "-k") == 0)) ||
((argc == 1) && (strcmp(argv[0], "-m") == 0))) {
#ifdef LOSCFG_EXC_INTERACTION
PRINTK("\r\n***** Mem:system mem Mem1:exception interaction mem *****\n");
#endif
PRINTK("\r\n total used free heap\n");
}
if ((argc == 1) && (strcmp(argv[0], "-k") == 0)) {
PRINTK("Mem: %-9u %-10u %-10u %-10u\n", MEM_SIZE_TO_KB(totalMem), MEM_SIZE_TO_KB(memUsed),
MEM_SIZE_TO_KB(freeMem), MEM_SIZE_TO_KB(memUsedHeap));
#ifdef LOSCFG_EXC_INTERACTION
PRINTK("Mem1: %-9u %-10u %-10u\n", MEM_SIZE_TO_KB(totalMem), MEM_SIZE_TO_KB(memUsed),
MEM_SIZE_TO_KB(freeMem));
#endif
} else if ((argc == 1) && (strcmp(argv[0], "-m") == 0)) {
PRINTK("Mem: %-9u %-10u %-10u %-10u\n", MEM_SIZE_TO_MB(totalMem), MEM_SIZE_TO_MB(memUsed),
MEM_SIZE_TO_MB(freeMem), MEM_SIZE_TO_MB(memUsedHeap));
#ifdef LOSCFG_EXC_INTERACTION
PRINTK("Mem1: %-9u %-10u %-10u\n", MEM_SIZE_TO_MB(totalMem), MEM_SIZE_TO_MB(memUsed),
MEM_SIZE_TO_MB(freeMem));
#endif
} else if (argc == 0) {
PRINTK("Mem: %-9u %-10u %-10u %-10u\n", totalMem, memUsed, freeMem, memUsedHeap);
#ifdef LOSCFG_EXC_INTERACTION
PRINTK("Mem1: %-9u %-10u %-10u\n", totalMem0, memUsed0, freeMem0);
#endif
} else {
PRINTK("\nUsage: free or free [-k/-m]\n");
return OS_ERROR;
}
return 0;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdFree(INT32 argc, const CHAR *argv[])
{
if (argc > 1) {
PRINTK("\nUsage: free or free [-k/-m]\n");
return OS_ERROR;
}
if (OsShellCmdFreeInfo(argc, argv) != 0) {
return OS_ERROR;
}
OsShellCmdSectionInfo(argc, argv);
return 0;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdUname(INT32 argc, const CHAR *argv[])
{
if (argc == 0) {
PRINTK("%s\n", KERNEL_NAME);
return 0;
}
if (argc == 1) {
if (strcmp(argv[0], "-a") == 0) {
PRINTK("%s %d.%d.%d.%d %s %s\n", KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE,\
__DATE__, __TIME__);
return 0;
} else if (strcmp(argv[0], "-s") == 0) {
PRINTK("%s\n", KERNEL_NAME);
return 0;
} else if (strcmp(argv[0], "-t") == 0) {
PRINTK("build date : %s %s\n", __DATE__, __TIME__);
return 0;
} else if (strcmp(argv[0], "-v") == 0) {
PRINTK("%d.%d.%d.%d\n", KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
return 0;
} else if (strcmp(argv[0], "--help") == 0) {
PRINTK("-a, print all information\n"
"-s, print the kernel name\n"
"-t, print the build date\n"
"-v, print the kernel version\n");
return 0;
}
}
PRINTK("uname: invalid option %s\n"
"Try 'uname --help' for more information.\n",
argv[0]);
return OS_ERROR;
}
#ifdef LOSCFG_MEM_LEAKCHECK
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemUsed(INT32 argc, const CHAR *argv[])
{
if (argc > 0) {
PRINTK("\nUsage: memused\n");
return OS_ERROR;
}
OsMemUsedNodeShow(m_aucSysMem1);
#ifdef LOSCFG_EXC_INTERACTION
PRINTK("\n exc interaction memory\n");
OsMemUsedNodeShow(m_aucSysMem0);
#endif
return 0;
}
#endif
#ifdef LOSCFG_MEM_RECORDINFO
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemRecordEnable(INT32 argc, const CHAR *argv[])
{
OsMemRecordShowSet(1);
return 0;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdMemRecordDisable(INT32 argc, const CHAR *argv[])
{
OsMemRecordShowSet(0);
return 0;
}
SHELLCMD_ENTRY(memshowenable_shellcmd, CMD_TYPE_EX, "memshowenable", 0,
(CmdCallBackFunc)OsShellCmdMemRecordEnable);
SHELLCMD_ENTRY(memshowdisable_shellcmd, CMD_TYPE_EX, "memshowdisable", 0,
(CmdCallBackFunc)OsShellCmdMemRecordDisable);
#endif
#ifdef LOSCFG_MEM_LEAKCHECK
SHELLCMD_ENTRY(memused_shellcmd, CMD_TYPE_EX, "memused", 0, (CmdCallBackFunc)OsShellCmdMemUsed);
#endif
#ifdef LOSCFG_SHELL_CMD_DEBUG
SHELLCMD_ENTRY(memcheck_shellcmd, CMD_TYPE_EX, "memcheck", 0, (CmdCallBackFunc)OsShellCmdMemCheck);
SHELLCMD_ENTRY(readreg_shellcmd, CMD_TYPE_EX, "readreg", MEMPT_ARG_NUM_2, (CmdCallBackFunc)OsShellCmdMemRead);
#endif
SHELLCMD_ENTRY(free_shellcmd, CMD_TYPE_EX, "free", XARGS, (CmdCallBackFunc)OsShellCmdFree);
SHELLCMD_ENTRY(uname_shellcmd, CMD_TYPE_EX, "uname", XARGS, (CmdCallBackFunc)OsShellCmdUname);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

147
kernel/base/misc/swtmr_shellcmd.c Executable file
View File

@@ -0,0 +1,147 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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_CMD_DEBUG
#include "stdlib.h"
#include "los_swtmr_pri.h"
#include "shcmd.h"
#include "shell.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#define SWTMR_STRLEN 12
LITE_OS_SEC_DATA_MINOR STATIC CHAR g_shellSwtmrMode[][SWTMR_STRLEN] = {
"Once",
"Period",
"NSD",
"OPP",
};
LITE_OS_SEC_DATA_MINOR STATIC CHAR g_shellSwtmrStatus[][SWTMR_STRLEN] = {
"UnUsed",
"Created",
"Ticking",
};
STATIC VOID OsPrintSwtmrMsg(const SWTMR_CTRL_S *swtmr)
{
PRINTK("0x%08x "
"%-7s "
"%-6s "
"%-6u "
"%-6u "
"0x%08x "
"%p\n",
swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT,
g_shellSwtmrStatus[swtmr->ucState],
g_shellSwtmrMode[swtmr->ucMode],
swtmr->uwInterval,
swtmr->uwCount,
swtmr->uwArg,
swtmr->pfnHandler);
}
STATIC INLINE VOID OsPrintSwtmrMsgHead(VOID)
{
PRINTK("\r\nSwTmrID State Mode Interval Count Arg handlerAddr\n");
PRINTK("---------- ------- ------- --------- ------- ---------- --------\n");
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdSwtmrInfoGet(INT32 argc, const UINT8 **argv)
{
#define OS_ALL_SWTMR_MASK 0xffffffff
SWTMR_CTRL_S *swtmr = g_swtmrCBArray;
SWTMR_CTRL_S *swtmr1 = g_swtmrCBArray;
UINT16 index;
size_t timerID;
UINT16 num = 0;
CHAR *endPtr = NULL;
if (argc > 1) {
PRINTK("\nUsage: swtmr [ID]\n");
return OS_ERROR;
}
if (argc == 0) {
timerID = OS_ALL_SWTMR_MASK;
} else {
timerID = strtoul((CHAR *)argv[0], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0) || (timerID > LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
PRINTK("\nswtmr ID can't access %s.\n", argv[0]);
return OS_ERROR;
}
}
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr1++) {
if (swtmr1->ucState == 0) {
num = num + 1;
}
}
if (num == LOSCFG_BASE_CORE_SWTMR_LIMIT) {
PRINTK("\r\nThere is no swtmr was created!\n");
return OS_ERROR;
}
if (timerID == OS_ALL_SWTMR_MASK) {
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
if (swtmr->ucState != 0) {
OsPrintSwtmrMsgHead();
OsPrintSwtmrMsg(swtmr);
}
}
} else {
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
if ((timerID == (size_t)(swtmr->usTimerID % LOSCFG_BASE_CORE_SWTMR_LIMIT)) && (swtmr->ucState != 0)) {
OsPrintSwtmrMsgHead();
OsPrintSwtmrMsg(swtmr);
return LOS_OK;
}
}
PRINTK("\r\nThe SwTimerID is not exist.\n");
}
return LOS_OK;
}
SHELLCMD_ENTRY(swtmr_shellcmd, CMD_TYPE_EX, "swtmr", 1, (CmdCallBackFunc)OsShellCmdSwtmrInfoGet);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* LOSCFG_SHELL */

View File

@@ -0,0 +1,170 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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"
#include "los_swtmr.h"
#include "los_sem_pri.h"
#include "los_queue_pri.h"
#include "los_swtmr_pri.h"
#ifdef LOSCFG_SHELL
#include "shcmd.h"
#include "shell.h"
#endif
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#define SYSINFO_ENABLED(x) (((x) == YES) ? "YES" : "NO")
UINT32 OsShellCmdTaskCntGet(VOID)
{
UINT32 loop;
UINT32 taskCnt = 0;
UINT32 intSave;
LosTaskCB *taskCB = NULL;
intSave = LOS_IntLock();
for (loop = 0; loop < g_taskMaxNum; loop++) {
taskCB = (LosTaskCB *)g_taskCBArray + loop;
if (OsTaskIsUnused(taskCB)) {
continue;
}
taskCnt++;
}
LOS_IntRestore(intSave);
return taskCnt;
}
UINT32 OsShellCmdSemCntGet(VOID)
{
UINT32 loop;
UINT32 semCnt = 0;
UINT32 intSave;
LosSemCB *semNode = NULL;
intSave = LOS_IntLock();
for (loop = 0; loop < LOSCFG_BASE_IPC_SEM_LIMIT; loop++) {
semNode = GET_SEM(loop);
if (semNode->semStat == OS_SEM_USED) {
semCnt++;
}
}
LOS_IntRestore(intSave);
return semCnt;
}
UINT32 OsShellCmdQueueCntGet(VOID)
{
UINT32 loop;
UINT32 queueCnt = 0;
UINT32 intSave;
LosQueueCB *queueCB = NULL;
intSave = LOS_IntLock();
queueCB = g_allQueue;
for (loop = 0; loop < LOSCFG_BASE_IPC_QUEUE_LIMIT; loop++, queueCB++) {
if (queueCB->queueState == OS_QUEUE_INUSED) {
queueCnt++;
}
}
LOS_IntRestore(intSave);
return queueCnt;
}
UINT32 OsShellCmdSwtmrCntGet(VOID)
{
UINT32 loop;
UINT32 swtmrCnt = 0;
UINT32 intSave;
SWTMR_CTRL_S *swtmrCB = NULL;
intSave = LOS_IntLock();
swtmrCB = g_swtmrCBArray;
for (loop = 0; loop < LOSCFG_BASE_CORE_SWTMR_LIMIT; loop++, swtmrCB++) {
if (swtmrCB->ucState != OS_SWTMR_STATUS_UNUSED) {
swtmrCnt++;
}
}
LOS_IntRestore(intSave);
return swtmrCnt;
}
LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdSystemInfoGet(VOID)
{
UINT8 isTaskEnable = YES;
UINT8 isSemEnable = LOSCFG_BASE_IPC_SEM;
UINT8 isQueueEnable = LOSCFG_BASE_IPC_QUEUE;
UINT8 isSwtmrEnable = LOSCFG_BASE_CORE_SWTMR;
PRINTK("\n Module Used Total Enabled\n");
PRINTK("--------------------------------------------\n");
PRINTK(" Task %-10u%-10d%s\n",
OsShellCmdTaskCntGet(),
LOSCFG_BASE_CORE_TSK_LIMIT,
SYSINFO_ENABLED(isTaskEnable));
PRINTK(" Sem %-10u%-10d%s\n",
OsShellCmdSemCntGet(),
LOSCFG_BASE_IPC_SEM_LIMIT,
SYSINFO_ENABLED(isSemEnable));
PRINTK(" Queue %-10u%-10d%s\n",
OsShellCmdQueueCntGet(),
LOSCFG_BASE_IPC_QUEUE_LIMIT,
SYSINFO_ENABLED(isQueueEnable));
PRINTK(" SwTmr %-10u%-10d%s\n",
OsShellCmdSwtmrCntGet(),
LOSCFG_BASE_CORE_SWTMR_LIMIT,
SYSINFO_ENABLED(isSwtmrEnable));
}
INT32 OsShellCmdSystemInfo(INT32 argc, const CHAR **argv)
{
if (argc == 0) {
OsShellCmdSystemInfoGet();
return 0;
}
PRINTK("systeminfo: invalid option %s\n"
"Systeminfo has NO ARGS.\n",
argv[0]);
return -1;
}
#ifdef LOSCFG_SHELL
SHELLCMD_ENTRY(systeminfo_shellcmd, CMD_TYPE_EX, "systeminfo", 1, (CmdCallBackFunc)OsShellCmdSystemInfo);
#endif /* LOSCFG_SHELL */
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

501
kernel/base/misc/task_shellcmd.c Executable file
View File

@@ -0,0 +1,501 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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 "stdlib.h"
#include "los_config.h"
#include "los_exc.h"
#include "los_memstat_pri.h"
#include "los_sem_pri.h"
#include "los_seq_buf.h"
#include "los_task_pri.h"
#ifdef LOSCFG_SHELL
#include "shcmd.h"
#include "shell.h"
#endif
#ifdef LOSCFG_KERNEL_CPUP
#include "los_cpup_pri.h"
#endif
#ifdef LOSCFG_SHELL_EXCINFO
#include "los_excinfo_pri.h"
#endif
#include "los_process_pri.h"
#include "los_vm_dump.h"
#ifdef LOSCFG_FS_VFS
#include "fs/fs.h"
#endif
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#define OS_PROCESS_MEM_INFO 0x2U
#define OS_PROCESS_INFO_LEN (g_processMaxNum * (sizeof(LosProcessCB)))
#define OS_PROCESS_GROUP_INFO_LEN (g_processMaxNum * sizeof(UINT32))
#define OS_PROCESS_UID_INFO_LEN (g_processMaxNum * sizeof(UINT32))
#define OS_PROCESS_MEM_ALL_INFO_LEN (g_processMaxNum * PROCESS_MEMINFO_LEN)
#ifdef LOSCFG_KERNEL_CPUP
#define OS_PROCESS_CPUP_INFO_LEN (g_processMaxNum * sizeof(CPUP_INFO_S))
#define OS_PROCESS_CPUP_ALLINFO_LEN (OS_PROCESS_CPUP_INFO_LEN * 3)
#else
#define OS_PROCESS_CPUP_ALLINFO_LEN 0
#endif
#define OS_PROCESS_ALL_INFO_LEN (g_processMaxNum * (sizeof(LosProcessCB) + sizeof(UINT32)) + \
OS_PROCESS_CPUP_ALLINFO_LEN + OS_PROCESS_UID_INFO_LEN)
#ifdef LOSCFG_KERNEL_CPUP
LITE_OS_SEC_BSS STATIC CPUP_INFO_S *g_processCpupAll = NULL;
LITE_OS_SEC_BSS STATIC CPUP_INFO_S *g_processCpup10s = NULL;
LITE_OS_SEC_BSS STATIC CPUP_INFO_S *g_processCpup1s = NULL;
#endif
STATIC UINT32 *g_taskWaterLine = NULL;
#define OS_INVALID_SEM_ID 0xFFFFFFFF
#define OS_TASK_WATER_LINE_SIZE (g_taskMaxNum * sizeof(UINT32))
#define OS_TASK_INFO_LEN (g_taskMaxNum * sizeof(LosTaskCB))
#define OS_TASK_ALL_INFO_LEN (g_taskMaxNum * (sizeof(LosTaskCB) + sizeof(UINT32)))
#ifdef LOSCFG_FS_VFS
#define PROCESS_INFO_SHOW(seqBuf, arg...) do { \
if (seqBuf != NULL) { \
(void)LosBufPrintf((struct SeqBuf *)seqBuf, ##arg); \
} else { \
PRINTK(arg); \
} \
} while (0)
#else
#define PROCESS_INFO_SHOW(seqBuf, arg...) PRINTK(arg)
#endif
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellCmdProcessMode(UINT16 mode)
{
if (mode == OS_KERNEL_MODE) {
return (UINT8 *)"kernel";
} else if (mode == OS_USER_MODE) {
return (UINT8 *)"user";
}
return (UINT8 *)"ERROR";
}
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellCmdSchedPolicy(UINT16 policy)
{
if (policy == LOS_SCHED_RR) {
return (UINT8 *)"RR";
} else if (policy == LOS_SCHED_FIFO) {
return (UINT8 *)"FIFO";
}
return (UINT8 *)"ERROR";
}
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellProcessStatus(UINT16 status)
{
status = status & OS_PROCESS_STATUS_MASK;
if (status & OS_PROCESS_STATUS_ZOMBIES) {
return (UINT8 *)"Zombies";
} else if (status & OS_PROCESS_STATUS_INIT) {
return (UINT8 *)"Init";
} else if (status & OS_PROCESS_STATUS_RUNNING) {
return (UINT8 *)"Running";
} else if (status & OS_PROCESS_STATUS_READY) {
return (UINT8 *)"Ready";
} else {
if (status & OS_PROCESS_STATUS_PEND) {
return (UINT8 *)"Pend";
}
}
return (UINT8 *)"Invalid";
}
STATIC VOID OsShellCmdProcessTitle(VOID *seqBuf, UINT16 flag)
{
PROCESS_INFO_SHOW(seqBuf, "\r\n PID PPID PGID UID Status ");
if (flag & OS_PROCESS_MEM_INFO) {
PROCESS_INFO_SHOW(seqBuf, "VirtualMem ShareMem PhysicalMem ");
}
#ifdef LOSCFG_KERNEL_CPUP
if (flag & OS_PROCESS_INFO_ALL) {
PROCESS_INFO_SHOW(seqBuf, "CPUUSE CPUUSE10s CPUUSE1s ");
} else {
PROCESS_INFO_SHOW(seqBuf, "CPUUSE10s ");
}
#endif /* LOSCFG_KERNEL_CPUP */
if (flag & OS_PROCESS_INFO_ALL) {
PROCESS_INFO_SHOW(seqBuf, "Policy Priority MTID TaskTotal Mode ");
}
PROCESS_INFO_SHOW(seqBuf, " PName\n");
}
STATIC VOID OsShellCmdProcessInfoShow(const LosProcessCB *processCB, const INT32 *group,
const UINT32 *memArray, VOID *seqBuf, UINT16 flag)
{
const UINT32 *procMemUsage = NULL;
const INT32 *user = (const INT32 *)((UINTPTR)group + OS_PROCESS_GROUP_INFO_LEN);
UINT32 pid = processCB->processID;
PROCESS_INFO_SHOW(seqBuf, "%5u%6d%5d%10d%8s", pid, (INT32)processCB->parentProcessID, group[pid], user[pid],
OsShellProcessStatus(processCB->processStatus));
if (flag & OS_PROCESS_MEM_INFO) {
procMemUsage = &memArray[pid * PROCESS_VM_INDEX_MAX];
PROCESS_INFO_SHOW(seqBuf, "%#11x%#9x%#12x", procMemUsage[PROCESS_VM_INDEX], procMemUsage[PROCESS_SM_INDEX],
procMemUsage[PROCESS_PM_INDEX]);
}
#ifdef LOSCFG_KERNEL_CPUP
if (flag & OS_PROCESS_INFO_ALL) {
PROCESS_INFO_SHOW(seqBuf, "%5u.%1u%8u.%1u%7u.%-1u ",
g_processCpupAll[pid].uwUsage / LOS_CPUP_PRECISION_MULT,
g_processCpupAll[pid].uwUsage % LOS_CPUP_PRECISION_MULT,
g_processCpup10s[pid].uwUsage / LOS_CPUP_PRECISION_MULT,
g_processCpup10s[pid].uwUsage % LOS_CPUP_PRECISION_MULT,
g_processCpup1s[pid].uwUsage / LOS_CPUP_PRECISION_MULT,
g_processCpup1s[pid].uwUsage % LOS_CPUP_PRECISION_MULT);
} else {
PROCESS_INFO_SHOW(seqBuf, "%8u.%1u ",
g_processCpup10s[pid].uwUsage / LOS_CPUP_PRECISION_MULT,
g_processCpup10s[pid].uwUsage % LOS_CPUP_PRECISION_MULT);
}
#endif /* LOSCFG_KERNEL_CPUP */
if (flag & OS_PROCESS_INFO_ALL) {
PROCESS_INFO_SHOW(seqBuf, "%6s%9u%5d%10u%7s ",
OsShellCmdSchedPolicy(processCB->policy), processCB->priority,
(INT32)processCB->threadGroupID, processCB->threadNumber,
OsShellCmdProcessMode(processCB->processMode));
}
PROCESS_INFO_SHOW(seqBuf, " %-32s\n", processCB->processName);
}
STATIC VOID OsShellCmdAllProcessInfoShow(const LosProcessCB *pcbArray, const INT32 *group,
const UINT32 *memArray, VOID *seqBuf, UINT16 flag)
{
const LosProcessCB *processCB = NULL;
UINT32 pid;
for (pid = 1; pid < g_processMaxNum; ++pid) {
processCB = pcbArray + pid;
if (OsProcessIsUnused(processCB)) {
continue;
}
OsShellCmdProcessInfoShow(processCB, group, memArray, seqBuf, flag);
}
}
STATIC VOID OsProcessMemUsageGet(UINT32 *memArray)
{
UINT32 pid;
LosProcessCB *processCB = NULL;
UINT32 *proMemUsage = NULL;
for (pid = 0; pid < g_processMaxNum; ++pid) {
processCB = g_processCBArray + pid;
if (OsProcessIsUnused(processCB)) {
continue;
}
proMemUsage = &memArray[pid * PROCESS_VM_INDEX_MAX];
/* Process memory usage statistics, idle task defaults to 0 */
if (pid == OsGetIdleProcessID()) {
proMemUsage[PROCESS_VM_INDEX] = 0;
proMemUsage[PROCESS_SM_INDEX] = 0;
proMemUsage[PROCESS_PM_INDEX] = 0;
} else {
proMemUsage[PROCESS_VM_INDEX] = OsShellCmdProcessVmUsage(processCB->vmSpace);
OsShellCmdProcessPmUsage(processCB->vmSpace, &proMemUsage[PROCESS_SM_INDEX],
&proMemUsage[PROCESS_PM_INDEX]);
}
}
}
STATIC UINT32 OsProcessInfoGet(LosProcessCB **pcbArray, INT32 **group, UINT32 **memArray, UINT16 flag)
{
UINT32 len = OS_PROCESS_ALL_INFO_LEN;
LosProcessCB *processCB = NULL;
INT32 *user = NULL;
(VOID)memcpy_s(*pcbArray, OS_PROCESS_INFO_LEN, g_processCBArray, OS_PROCESS_INFO_LEN);
*group = (INT32 *)((UINTPTR)*pcbArray + OS_PROCESS_INFO_LEN);
user = (INT32 *)((UINTPTR)*group + OS_PROCESS_GROUP_INFO_LEN);
for (UINT32 pid = 0; pid < g_processMaxNum; ++pid) {
processCB = *pcbArray + pid;
if (OsProcessIsUnused(processCB)) {
continue;
}
if (processCB->group != NULL) {
(*group)[processCB->processID] = processCB->group->groupID;
} else {
(*group)[processCB->processID] = -1;
}
#ifdef LOSCFG_SECURITY_CAPABILITY
if (processCB->user != NULL) {
user[processCB->processID] = processCB->user->userID;
} else {
user[processCB->processID] = -1;
}
#else
user[processCB->processID] = 0;
#endif
}
#ifdef LOSCFG_KERNEL_CPUP
g_processCpupAll = (CPUP_INFO_S *)((UINTPTR)user + OS_PROCESS_UID_INFO_LEN);
g_processCpup10s = (CPUP_INFO_S *)((UINTPTR)g_processCpupAll + OS_PROCESS_CPUP_INFO_LEN);
g_processCpup1s = (CPUP_INFO_S *)((UINTPTR)g_processCpup10s + OS_PROCESS_CPUP_INFO_LEN);
(VOID)OsAllCpuUsageUnsafe(LOSCFG_BASE_CORE_PROCESS_LIMIT, g_processCpupAll, CPUP_ALL_TIME, 1);
(VOID)OsAllCpuUsageUnsafe(LOSCFG_BASE_CORE_PROCESS_LIMIT, g_processCpup10s, CPUP_LAST_TEN_SECONDS, 1);
(VOID)OsAllCpuUsageUnsafe(LOSCFG_BASE_CORE_PROCESS_LIMIT, g_processCpup1s, CPUP_LAST_ONE_SECONDS, 1);
#endif
if (flag & OS_PROCESS_MEM_INFO) {
*memArray = (UINT32 *)((UINTPTR)*pcbArray + OS_PROCESS_ALL_INFO_LEN);
OsProcessMemUsageGet(*memArray);
len += OS_PROCESS_MEM_ALL_INFO_LEN;
}
return len;
}
STATIC VOID OsShellCmdProcessInfoData(const LosProcessCB *pcbArray, const INT32 *group,
const UINT32 *memArray, VOID *seqBuf, UINT16 flag)
{
OsShellCmdProcessTitle(seqBuf, flag);
OsShellCmdAllProcessInfoShow(pcbArray, group, memArray, seqBuf, flag);
}
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellCmdConvertTskStatus(UINT16 taskStatus)
{
if (taskStatus & OS_TASK_STATUS_INIT) {
return (UINT8 *)"Init";
} else if (taskStatus & OS_TASK_STATUS_RUNNING) {
return (UINT8 *)"Running";
} else if (taskStatus & OS_TASK_STATUS_READY) {
return (UINT8 *)"Ready";
} else {
if (taskStatus & OS_TASK_STATUS_DELAY) {
return (UINT8 *)"Delay";
} else if (taskStatus & OS_TASK_STATUS_PEND_TIME) {
if (taskStatus & OS_TASK_STATUS_SUSPEND) {
return (UINT8 *)"SuspendTime";
} else if (taskStatus & OS_TASK_STATUS_PEND) {
return (UINT8 *)"PendTime";
}
} else if (taskStatus & OS_TASK_STATUS_PEND) {
return (UINT8 *)"Pend";
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
return (UINT8 *)"Suspend";
} else if (taskStatus & OS_TASK_STATUS_EXIT) {
return (UINT8 *)"Exit";
}
}
return (UINT8 *)"Invalid";
}
STATIC VOID OsShellCmdTaskWaterLineGet(const LosTaskCB *allTaskArray)
{
const LosTaskCB *taskCB = NULL;
UINT32 loop;
for (loop = 0; loop < g_taskMaxNum; ++loop) {
taskCB = allTaskArray + loop;
if (OsTaskIsUnused(taskCB)) {
continue;
}
(VOID)OsStackWaterLineGet((const UINTPTR *)((UINTPTR)taskCB->topOfStack + taskCB->stackSize),
(const UINTPTR *)taskCB->topOfStack, &g_taskWaterLine[taskCB->taskID]);
}
}
STATIC VOID OsShellCmdTskInfoTitle(VOID *seqBuf, UINT16 flag)
{
PROCESS_INFO_SHOW(seqBuf, "\r\n TID PID ");
#if (LOSCFG_KERNEL_SMP == YES)
PROCESS_INFO_SHOW(seqBuf, "Affi CPU ");
#endif
PROCESS_INFO_SHOW(seqBuf, " Status StackSize WaterLine ");
if (flag & OS_PROCESS_INFO_ALL) {
#ifdef LOSCFG_SHELL_CMD_DEBUG
PROCESS_INFO_SHOW(seqBuf, " StackPoint TopOfStack EventMask SemID ");
#endif
PROCESS_INFO_SHOW(seqBuf, "Policy Priority ");
}
PROCESS_INFO_SHOW(seqBuf, " MEMUSE TaskName\n");
}
#ifdef LOSCFG_SHELL_CMD_DEBUG
STATIC INLINE UINT32 OsGetSemID(const LosTaskCB *taskCB)
{
UINT32 semID = OS_INVALID_SEM_ID;
if (taskCB->taskSem != NULL) {
semID = ((LosSemCB *)taskCB->taskSem)->semID;
}
return semID;
}
#endif
STATIC INLINE VOID OsShellTskInfoData(const LosTaskCB *taskCB, VOID *seqBuf, UINT16 flag)
{
PROCESS_INFO_SHOW(seqBuf, " %4u%5u", taskCB->taskID, taskCB->processID);
#if (LOSCFG_KERNEL_SMP == YES)
PROCESS_INFO_SHOW(seqBuf, "%#5x%4d ", taskCB->cpuAffiMask, (INT16)(taskCB->currCpu));
#endif
PROCESS_INFO_SHOW(seqBuf, "%12s%#10x%#10x", OsShellCmdConvertTskStatus(taskCB->taskStatus),
taskCB->stackSize, g_taskWaterLine[taskCB->taskID]);
if (flag & OS_PROCESS_INFO_ALL) {
#ifdef LOSCFG_SHELL_CMD_DEBUG
PROCESS_INFO_SHOW(seqBuf, "%#12x%#12x%#10x%#12x", taskCB->stackPointer, taskCB->topOfStack,
taskCB->eventMask, OsGetSemID(taskCB));
#endif
PROCESS_INFO_SHOW(seqBuf, "%7s%9u", OsShellCmdSchedPolicy(taskCB->policy), taskCB->priority);
}
PROCESS_INFO_SHOW(seqBuf, "%#10x %-32s\n", OsTaskMemUsage(taskCB->taskID), taskCB->taskName);
}
STATIC VOID OsShellCmdAllTaskInfoData(const LosTaskCB *allTaskArray, VOID *seqBuf, UINT16 flag)
{
const LosTaskCB *taskCB = NULL;
UINT32 pid;
UINT32 loop;
for (pid = 1; pid < g_processMaxNum; ++pid) {
for (loop = 0; loop < g_taskMaxNum; ++loop) {
taskCB = allTaskArray + loop;
if (OsTaskIsUnused(taskCB) || (taskCB->processID != pid)) {
continue;
}
OsShellTskInfoData(taskCB, seqBuf, flag);
}
}
}
STATIC VOID OsShellCmdTskInfoData(const LosTaskCB *allTaskArray, VOID *seqBuf, UINT16 flag)
{
OsShellCmdTskInfoTitle(seqBuf, flag);
OsShellCmdAllTaskInfoData(allTaskArray, seqBuf, flag);
}
STATIC VOID OsProcessAndTaskInfoGet(LosProcessCB **pcbArray, INT32 **group, LosTaskCB **tcbArray,
UINT32 **memArray, UINT16 flag)
{
BOOL lockFlag = FALSE;
UINT32 intSave = 0;
UINT32 processInfoLen;
if (LOS_SpinHeld(&g_taskSpin) == FALSE) {
SCHEDULER_LOCK(intSave);
lockFlag = TRUE;
}
processInfoLen = OsProcessInfoGet(pcbArray, group, memArray, flag);
*tcbArray = (LosTaskCB *)((UINTPTR)*pcbArray + processInfoLen);
(VOID)memcpy_s(*tcbArray, OS_TASK_INFO_LEN, g_taskCBArray, OS_TASK_INFO_LEN);
g_taskWaterLine = (UINT32 *)((UINTPTR)*tcbArray + OS_TASK_INFO_LEN);
OsShellCmdTaskWaterLineGet(*tcbArray);
if (lockFlag == TRUE) {
SCHEDULER_UNLOCK(intSave);
}
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTskInfoGet(UINT32 taskID, VOID *seqBuf, UINT16 flag)
{
UINT32 size;
LosProcessCB *pcbArray = NULL;
INT32 *group = NULL;
LosTaskCB *tcbArray = NULL;
UINT32 *memArray = NULL;
if (taskID == OS_ALL_TASK_MASK) {
if (flag & OS_PROCESS_MEM_INFO) {
size = OS_PROCESS_ALL_INFO_LEN + OS_PROCESS_MEM_ALL_INFO_LEN + OS_TASK_ALL_INFO_LEN;
} else {
size = OS_PROCESS_ALL_INFO_LEN + OS_TASK_ALL_INFO_LEN;
}
pcbArray = (LosProcessCB *)LOS_MemAlloc(m_aucSysMem1, size);
if (pcbArray == NULL) {
PRINT_ERR("Memory is not enough to save task info!\n");
return LOS_NOK;
}
(VOID)memset_s(pcbArray, size, 0, size);
OsProcessAndTaskInfoGet(&pcbArray, &group, &tcbArray, &memArray, flag);
OsShellCmdProcessInfoData(pcbArray, group, memArray, seqBuf, flag);
OsShellCmdTskInfoData(tcbArray, seqBuf, flag);
(VOID)LOS_MemFree(m_aucSysMem1, pcbArray);
}
return LOS_OK;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv)
{
UINT32 flag = 0;
flag |= OS_PROCESS_MEM_INFO;
if (argc < 2) { /* 2:Just as number of parameters */
if (argc == 1) {
if (strcmp("-a", argv[0]) == 0) {
flag |= OS_PROCESS_INFO_ALL;
} else {
PRINTK("Unknown option: %s\n", argv[0]);
goto TASK_HELP;
}
}
return OsShellCmdTskInfoGet(OS_ALL_TASK_MASK, NULL, flag);
}
TASK_HELP:
PRINTK("usage: task or task -a\n");
return LOS_NOK;
}
#ifdef LOSCFG_SHELL
SHELLCMD_ENTRY(task_shellcmd, CMD_TYPE_EX, "task", 1, (CmdCallBackFunc)OsShellCmdDumpTask);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

265
kernel/base/misc/vm_shellcmd.c Executable file
View File

@@ -0,0 +1,265 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
*
* 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 "stdlib.h"
#include "stdio.h"
#include "ctype.h"
#include "los_printf.h"
#include "string.h"
#include "securec.h"
#ifdef LOSCFG_SHELL
#include "shcmd.h"
#include "shell.h"
#endif
#include "los_oom.h"
#include "los_vm_dump.h"
#include "los_process_pri.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define ARGC_2 2
#define ARGC_1 1
#define ARGC_0 0
#define VMM_CMD "vmm"
#define OOM_CMD "oom"
#define VMM_PMM_CMD "v2p"
LITE_OS_SEC_TEXT_MINOR VOID OsDumpKernelAspace(VOID)
{
LosVmSpace *kAspace = LOS_GetKVmSpace();
if (kAspace != NULL) {
OsDumpAspace(kAspace);
} else {
VM_ERR("kernel aspace is NULL");
}
return;
}
LITE_OS_SEC_TEXT_MINOR INT32 OsPid(const CHAR *str)
{
UINT32 len = strlen(str);
if (len <= 2) { // pid range is 0~63, max pid string length is 2
for (UINT32 i = 0; i < len; i++) {
if (isdigit(str[i]) == 0) {
return -1;
}
}
return atoi(str);
}
return -1;
}
LITE_OS_SEC_TEXT_MINOR VOID OsPrintUsage(VOID)
{
PRINTK("-a, print all vm address space information\n"
"-k, print the kernel vm address space information\n"
"pid(0~63), print process[pid] vm address space information\n"
"-h | --help, print vmm command usage\n");
}
LITE_OS_SEC_TEXT_MINOR VOID OsDoDumpVm(pid_t pid)
{
LosProcessCB *processCB = NULL;
if (OsProcessIDUserCheckInvalid(pid)) {
PRINTK("\tThe process [%d] not valid\n", pid);
return;
}
processCB = OS_PCB_FROM_PID(pid);
if (!OsProcessIsUnused(processCB) && (processCB->vmSpace != NULL)) {
OsDumpAspace(processCB->vmSpace);
} else {
PRINTK("\tThe process [%d] not active\n", pid);
}
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpVm(INT32 argc, const CHAR *argv[])
{
if (argc == 0) {
OsDumpAllAspace();
} else if (argc == 1) {
pid_t pid = OsPid(argv[0]);
if (strcmp(argv[0], "-a") == 0) {
OsDumpAllAspace();
} else if (strcmp(argv[0], "-k") == 0) {
OsDumpKernelAspace();
} else if (pid >= 0) {
OsDoDumpVm(pid);
} else if (strcmp(argv[0], "-h") == 0 || strcmp(argv[0], "--help") == 0) {
OsPrintUsage();
} else {
PRINTK("%s: invalid option: %s\n", VMM_CMD, argv[0]);
OsPrintUsage();
}
} else {
OsPrintUsage();
}
return OS_ERROR;
}
LITE_OS_SEC_TEXT_MINOR VOID V2PPrintUsage(VOID)
{
PRINTK("pid vaddr(0x1000000~0x3e000000), print physical address of virtual address\n"
"-h | --help, print v2p command usage\n");
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdV2P(INT32 argc, const CHAR *argv[])
{
UINT32 vaddr;
PADDR_T paddr;
CHAR *endPtr = NULL;
if (argc == 0) {
V2PPrintUsage();
} else if (argc == 1) {
if (strcmp(argv[0], "-h") == 0 || strcmp(argv[0], "--help") == 0) {
V2PPrintUsage();
}
} else if (argc == 2) {
pid_t pid = OsPid(argv[0]);
vaddr = strtoul((CHAR *)argv[1], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0)) {
PRINTK("vaddr %s invalid. should be in range(0x1000000~0x3e000000) \n", argv[1]);
return OS_ERROR;
} else {
if (pid >= 0) {
if (pid < g_taskMaxNum) {
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
if (!OsProcessIsUnused(processCB)) {
paddr = 0;
LOS_ArchMmuQuery(&processCB->vmSpace->archMmu, (VADDR_T)vaddr, &paddr, 0);
if (paddr == 0) {
PRINTK("vaddr %#x is not in range or mapped\n", vaddr);
} else {
PRINTK("vaddr %#x is paddr %#x\n", vaddr, paddr);
}
} else {
PRINTK("\tThe process [%d] not active\n", pid);
}
} else {
PRINTK("\tThe process [%d] not valid\n", pid);
}
} else {
PRINTK("%s: invalid option: %s %s\n", VMM_PMM_CMD, argv[0], argv[1]);
}
}
}
return LOS_OK;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpPmm(VOID)
{
OsVmPhysDump();
return OS_ERROR;
}
LITE_OS_SEC_TEXT_MINOR VOID OomPrintUsage(VOID)
{
PRINTK("\t-i [interval], set oom check interval (ms)\n"
"\t-m [mem byte], set oom low memory threshold (Byte)\n"
"\t-r [mem byte], set page cache reclaim memory threshold (Byte)\n"
"\t-h | --help, print vmm command usage\n");
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdOom(INT32 argc, const CHAR *argv[])
{
UINT32 lowMemThreshold;
UINT32 reclaimMemThreshold;
UINT32 checkInterval;
CHAR *endPtr = NULL;
if (argc == ARGC_0) {
OomInfodump();
} else if (argc == ARGC_1) {
if (strcmp(argv[0], "-h") != 0 && strcmp(argv[0], "--help") != 0) {
PRINTK("%s: invalid option: %s\n", OOM_CMD, argv[0]);
}
OomPrintUsage();
} else if (argc == ARGC_2) {
if (strcmp(argv[0], "-m") == 0) {
lowMemThreshold = strtoul((CHAR *)argv[1], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0)) {
PRINTK("[oom] low mem threshold %s(byte) invalid.\n", argv[1]);
return OS_ERROR;
} else {
OomSetLowMemThreashold(lowMemThreshold);
}
} else if (strcmp(argv[0], "-i") == 0) {
checkInterval = strtoul((CHAR *)argv[1], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0)) {
PRINTK("[oom] check interval %s(us) invalid.\n", argv[1]);
return OS_ERROR;
} else {
OomSetCheckInterval(checkInterval);
}
} else if (strcmp(argv[0], "-r") == 0) {
reclaimMemThreshold = strtoul((CHAR *)argv[1], &endPtr, 0);
if ((endPtr == NULL) || (*endPtr != 0)) {
PRINTK("[oom] reclaim mem threshold %s(byte) invalid.\n", argv[1]);
return OS_ERROR;
} else {
OomSetReclaimMemThreashold(reclaimMemThreshold);
}
} else {
PRINTK("%s: invalid option: %s %s\n", OOM_CMD, argv[0], argv[1]);
OomPrintUsage();
}
} else {
PRINTK("%s: invalid option\n", OOM_CMD);
OomPrintUsage();
}
return OS_ERROR;
}
#ifdef LOSCFG_SHELL_CMD_DEBUG
SHELLCMD_ENTRY(oom_shellcmd, CMD_TYPE_SHOW, OOM_CMD, 2, (CmdCallBackFunc)OsShellCmdOom);
SHELLCMD_ENTRY(vm_shellcmd, CMD_TYPE_SHOW, VMM_CMD, 1, (CmdCallBackFunc)OsShellCmdDumpVm);
SHELLCMD_ENTRY(v2p_shellcmd, CMD_TYPE_SHOW, VMM_PMM_CMD, 1, (CmdCallBackFunc)OsShellCmdV2P);
#endif
#ifdef LOSCFG_SHELL
SHELLCMD_ENTRY(pmm_shellcmd, CMD_TYPE_SHOW, "pmm", 0, (CmdCallBackFunc)OsShellCmdDumpPmm);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */