From b9c92b937f2aea3017518b8bbc9174689a2920eb Mon Sep 17 00:00:00 2001 From: "huanfeng.wang" Date: Mon, 5 Feb 2024 09:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89ape=E4=BE=A7=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E5=91=BD=E4=BB=A4=5Fape=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- driver/tfu | 2 +- osp/inc/ospShell.h | 2 + osp/src/ospNetShell.c | 2 +- osp/src/ospShell.c | 200 +++++++++++++++++++++++++++++++----------- 4 files changed, 152 insertions(+), 54 deletions(-) diff --git a/driver/tfu b/driver/tfu index 81b543d..070f58c 160000 --- a/driver/tfu +++ b/driver/tfu @@ -1 +1 @@ -Subproject commit 81b543d4ec66acdde54865eec21a3b3a863520fe +Subproject commit 070f58c7578fa8a9797cc4fdee51d9d0477ef5c9 diff --git a/osp/inc/ospShell.h b/osp/inc/ospShell.h index beb5d73..7a419da 100644 --- a/osp/inc/ospShell.h +++ b/osp/inc/ospShell.h @@ -111,6 +111,8 @@ void osp_show_info_by_coreid(osp_sw_msg_info_t *pMsg); void osp_set_oam(uint8_t ucOam); void osp_ushell_output(const char *fmt, ...); void osp_ushell_test(); +void osp_ape_cmd_show(); +void osp_arm_cmd_show(); #ifdef __cplusplus diff --git a/osp/src/ospNetShell.c b/osp/src/ospNetShell.c index 5cf52b5..f28c3ad 100644 --- a/osp/src/ospNetShell.c +++ b/osp/src/ospNetShell.c @@ -286,7 +286,7 @@ void osp_net_shell_proc() if (len <= 0) { //perror("recvfrom"); - return;; + return; } osp_local_shell_main((char *)&g_abuf); diff --git a/osp/src/ospShell.c b/osp/src/ospShell.c index 31c2aa4..54cf8db 100644 --- a/osp/src/ospShell.c +++ b/osp/src/ospShell.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "osp.h" #include "ospShell.h" #include "ospDbg.h" @@ -52,9 +53,12 @@ extern int32_t osp_base_logid; extern void *gpsw_que_share_mem; struct termios saveterm; - -OSP_CMD_RTN *ospCmdRtnTblExt = NULL; -lx_sem_t *ospCmdInsertSem = NULL; + +OSP_CMD_RTN ospApeCmdRtnTbl[MAX_CMD_NUM]; +OSP_CMD_RTN *ospCmdRtnTblExt = NULL; +lx_sem_t *ospCmdInsertSem = NULL; +lx_sem_t *ospApeCmdInsertSem = NULL; + void osp_mem_show(char *addr , uint32_t ulLen); void help(void); @@ -64,9 +68,7 @@ OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] = {"?", (OSP_FUNCPTR)help, NULL, }, {"i", (OSP_FUNCPTR)osp_show_task_info, NULL,"show alltask info", 0}, {"oam", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_set_oam, "set arm oam level", 1}, - //{"x", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_shell_dis_mem, "x num addr: show addr memory(length is num)", 2}, - //{"s", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_shell_set_mem, "s addr val: set addr memory(length is 4)", 2}, - //{"phym", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_display_phy_mem, "show phy mempry info", 2}, + {"phym", (OSP_FUNCPTR)osp_shell_mem_wrapper, (OSP_FUNCPTR)osp_display_phy_mem, "show phy mempry info", 2}, //{"c", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_tsk_diag_cnt, "show Task Diag Cnt", 1}, //{"sw", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_swqueue_info, "show arm print level", 0}, {"net", (OSP_FUNCPTR)osp_show_udp, NULL, "show net info", 0}, @@ -93,15 +95,17 @@ OSP_CMD_RTN ospCmdRtnTbl[MAX_CMD_NUM] = {"recmd_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_reget_ape_cmd, "get ape cmd again", 0}, {"intr_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_ape_csu_int_cnt, "show intr info", 0}, {"hb", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)get_heartbeat_status, "test heartbeat", 0}, - + {"apecmd", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_ape_cmd_show, "show ape register cmd", 0}, + {"armcmd", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_arm_cmd_show, "show arm register cmd", 0}, //{"level_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_set_log_level, "set ape log level", 1}, //{"csu_stop_ape", (OSP_FUNCPTR)osp_shell_wrapper,(OSP_FUNCPTR)osp_ape_csu_stop_cfg, "set csu start or stop", 2}, //{"i_ape", (OSP_FUNCPTR)osp_shell_wrapper, (OSP_FUNCPTR)osp_show_ape_taskinfo, "show ape task info", 0}, }; + -int32_t SHELL_CMD_NUM = OSP_NELEMENTS(ospCmdRtnTbl); -int32_t SHELL_CMD_NUM_EXT = 0; - +int32_t SHELL_CMD_NUM = OSP_NELEMENTS(ospCmdRtnTbl); +int32_t SHELL_CMD_NUM_EXT = 0; +uint32_t g_u32ApeShellCmdNum = 0; #define KEY_BACKSPACE '\b' // back space #define KEY_BACKSPACE1 127 // back space @@ -198,7 +202,16 @@ void help(void) } } - + + for (i = 0; i < MAX_CMD_NUM; i++) + { + if (ospApeCmdRtnTbl[i].cmd[0] != 0) + { + len += sprintf(buf + len, "%-16s%s\n", ospApeCmdRtnTbl[i].cmd, ospApeCmdRtnTbl[i].descption); + + } + } + UCP_PRINT_SHELL("%s\n", buf); osp_net_shell_out((char *)buf, len); @@ -493,8 +506,8 @@ int32_t osp_execcmd(void) int32_t ret = 0; if (nCmdField > 0) - { - /*±¾µØÃüÁî*/ + { + /*本地命令数组*/ for (i = 0; i < SHELL_CMD_NUM; i++) { if (strcmp(ospCmdRtnTbl[i].cmd, arg[0]) == 0) @@ -504,41 +517,48 @@ int32_t osp_execcmd(void) UCP_PRINT_ERROR("input wrong argnum should be %d\n", ospCmdRtnTbl[i].argnum); return OSP_ERROR; } - if(osp_is_ape_cmd(ospCmdRtnTbl[i].cmd))/*ape²àÃüÁî*/ - { - memcpy(gac_cmd, ospCmdRtnTbl[i].cmd, strlen(ospCmdRtnTbl[i].cmd)); - ret = (*ospCmdRtnTbl[i].wrapper)(&arg[1], nCmdField-1, ospCmdRtnTbl[i].routine); - memset(gac_cmd, 0, sizeof(gac_cmd)); - return (OSP_OK); - } + ret = (*ospCmdRtnTbl[i].wrapper)(&arg[1], nCmdField-1, ospCmdRtnTbl[i].routine); return (OSP_OK); } } + + /*armä¾§åŠ¨æ€æ³¨å†Œå‘½ä»¤*/ for (i = 0; i < SHELL_CMD_NUM_EXT; i++) { if (strcmp(ospCmdRtnTblExt[i].cmd, arg[0]) == 0) { if (ospCmdRtnTblExt[i].argnum != nCmdField-1) { - UCP_PRINT_ERROR("input wrong argnum should be %d\n", ospCmdRtnTblExt[i].argnum); + UCP_PRINT_ERROR("arm cmd:%s input wrong argnum should be %d\n", ospCmdRtnTblExt[i].cmd, ospCmdRtnTblExt[i].argnum); return OSP_ERROR; } - if(osp_is_ape_cmd(ospCmdRtnTblExt[i].cmd))/*ape²àÃüÁî*/ - { - memcpy(gac_cmd, ospCmdRtnTblExt[i].cmd, strlen(ospCmdRtnTblExt[i].cmd)); - ret = (*ospCmdRtnTblExt[i].wrapper)(&arg[1], nCmdField-1, ospCmdRtnTblExt[i].routine); - memset(gac_cmd, 0, sizeof(gac_cmd)); - - return (OSP_OK); - } - + ret = (*ospCmdRtnTblExt[i].wrapper)(&arg[1], nCmdField - 1, ospCmdRtnTblExt[i].routine); return (OSP_OK); } } + + /*apeä¾§åŠ¨æ€æ³¨å†Œå‘½ä»¤*/ + for (i = 0; i < g_u32ApeShellCmdNum; i++) + { + if (strcmp(ospApeCmdRtnTbl[i].cmd, arg[0]) == 0) + { + if (ospApeCmdRtnTbl[i].argnum != nCmdField-1) + { + UCP_PRINT_ERROR("ape cmd:%s input wrong argnum should be %d\n", ospApeCmdRtnTbl[i].cmd, ospApeCmdRtnTbl[i].argnum); + return OSP_ERROR; + } + + memcpy(gac_cmd, ospApeCmdRtnTbl[i].cmd, strlen(ospApeCmdRtnTbl[i].cmd)); + ret = (*ospApeCmdRtnTbl[i].wrapper)(&arg[1], nCmdField-1, ospApeCmdRtnTbl[i].routine); + memset(gac_cmd, 0, sizeof(gac_cmd)); + + return (OSP_OK); + } + } ret = osp_shell_symo(&arg[0], nCmdField); return ret; } @@ -989,11 +1009,29 @@ int32_t osp_insert_cmd(char *name, OSP_FUNCPTR pfunc, char *desc, uint32_t argnu return OSP_ERROR; } + for (i = 0; i < MAX_EXT_CMD_NUM; i++) + { + if (strcmp(ospCmdRtnTbl[i].cmd, name) == 0) + { + UCP_PRINT_ERROR("arm cmd i:%u cmd:%s has exist name:%s", i, ospCmdRtnTbl[i].cmd, name); + return OSP_ERROR; + } + } + for (i = 0; i < MAX_EXT_CMD_NUM; i++) { if (strcmp(ospCmdRtnTblExt[i].cmd, name) == 0) { - UCP_PRINT_ERROR("osp_insert_cmd i:%u cmd:%s has exist name:%s", i, ospCmdRtnTblExt[i].cmd, name); + UCP_PRINT_ERROR("arm insert cmd i:%u cmd:%s has exist name:%s", i, ospCmdRtnTblExt[i].cmd, name); + return OSP_ERROR; + } + } + + for (i = 0; i < MAX_EXT_CMD_NUM; i++) + { + if (strcmp(ospApeCmdRtnTbl[i].cmd, name) == 0) + { + UCP_PRINT_ERROR("ape cmd i:%u cmd:%s has exist name:%s", i, ospApeCmdRtnTbl[i].cmd, name); return OSP_ERROR; } } @@ -1031,20 +1069,22 @@ int32_t osp_insert_cmd(char *name, OSP_FUNCPTR pfunc, char *desc, uint32_t argnu int32_t osp_shell_init(void) { - ospCmdRtnTblExt = (OSP_CMD_RTN *)osp_get_init_mem(sizeof(OSP_CMD_RTN) * MAX_EXT_CMD_NUM); - ospCmdInsertSem = (lx_sem_t *)osp_get_init_mem(sizeof(lx_sem_t)); - + ospCmdRtnTblExt = (OSP_CMD_RTN *)osp_get_init_mem(sizeof(OSP_CMD_RTN) * MAX_EXT_CMD_NUM); + ospCmdInsertSem = (lx_sem_t *)osp_get_init_mem(sizeof(lx_sem_t)); + ospApeCmdInsertSem = (lx_sem_t *)osp_get_init_mem(sizeof(lx_sem_t)); if (0 == g_ProcessId) { memset(ospCmdRtnTblExt, 0, sizeof(OSP_CMD_RTN) *MAX_EXT_CMD_NUM); + memset(ospApeCmdInsertSem, 0, sizeof(OSP_CMD_RTN) *MAX_EXT_CMD_NUM); osp_semsm_create(ospCmdInsertSem); + osp_semsm_create(ospApeCmdInsertSem); } /*é…置文件读å–server ip ,port*/ osp_server_get(); - osp_insert_cmd("test", (OSP_FUNCPTR)osp_ushell_test, "test", 0); + osp_insert_cmd("test", (OSP_FUNCPTR)osp_ushell_test, "arm insert test", 0); return 0; } @@ -1158,10 +1198,9 @@ void osp_set_arm_log_mode(uint8_t ucIsNet) void osp_reget_ape_cmd() { - UCP_PRINT_SHELL("osp_reget_ape_cmd cmd:%s\n", gac_cmd); - SHELL_CMD_NUM_EXT = 0; - - osp_ape_msg_send((char *)gac_cmd); + g_u32ApeShellCmdNum = 0; + + osp_ape_msg_send((char *)"recmd_ape"); return; } @@ -1261,9 +1300,10 @@ void osp_ape_csu_stop_cfg(uint8_t ucstop, uint8_t ucadvance) void osp_ape_csu_int_cnt() { - UCP_PRINT_LOG("osp_show_ape_taskinfo cmd:%s\n", gac_cmd); - - osp_ape_msg_send((char *)gac_cmd); + + UCP_PRINT_LOG("osp_ape_csu_int_cnt intr_ape\n"); + + osp_ape_msg_send((char *)"intr_ape"); return; } @@ -1306,6 +1346,7 @@ void osp_ape_msg_send(char *pcmd) return; } + void osp_cmd_register(OSP_CMD_EXT *pCmdExt) { uint32_t num = 0; @@ -1313,28 +1354,82 @@ void osp_cmd_register(OSP_CMD_EXT *pCmdExt) if (NULL == pCmdExt) { + UCP_PRINT_ERROR("osp_cmd_register pCmdExt is null"); return; } + + UCP_PRINT_LOG("osp_cmd_register ape cmd:%s", pCmdExt->cmd); + + for (i = 0; i < MAX_EXT_CMD_NUM; i++) + { + if (strcmp(ospCmdRtnTbl[i].cmd, pCmdExt->cmd) == 0) + { + UCP_PRINT_LOG("osp_cmd_register arm cmd i:%u cmd:%s has exist name:%s", i, ospCmdRtnTbl[i].cmd, pCmdExt->cmd); + return ; + } + } for(i =0; i cmd)) { + UCP_PRINT_LOG("osp_cmd_register cmd:%s has exist name:%s", i, ospCmdRtnTblExt[i].cmd, pCmdExt->cmd); return; } } - - num = SHELL_CMD_NUM_EXT; + + for(i =0; i cmd)) + { + UCP_PRINT_LOG("osp_cmd_register ape cmd:%s has exist name:%s", ospApeCmdRtnTbl[i].cmd, pCmdExt->cmd); + return; + } + } + + num = g_u32ApeShellCmdNum; + + strcpy(ospApeCmdRtnTbl[num].cmd, pCmdExt->cmd); + ospApeCmdRtnTbl[num].wrapper = (OSP_FUNCPTR)osp_ape_shell_wrapper; + ospApeCmdRtnTbl[num].argnum = pCmdExt->argnum; - strcpy(ospCmdRtnTblExt[num].cmd, pCmdExt->cmd); - - ospCmdRtnTblExt[num].wrapper = (OSP_FUNCPTR)osp_ape_shell_wrapper; - ospCmdRtnTblExt[num].argnum = pCmdExt->argnum; - - SHELL_CMD_NUM_EXT++; + g_u32ApeShellCmdNum++; return ; } + +void osp_ape_cmd_show() +{ + uint8_t i = 0; + uint32_t len = 0; + char pbuf[2048]; + + for(i = 0; i < g_u32ApeShellCmdNum; i++) + { + len += sprintf(pbuf +len,"cmd:%s argnum:%u\n", ospApeCmdRtnTbl[i].cmd, ospApeCmdRtnTbl[i].argnum); + } + + osp_net_shell_out(pbuf, len); + + return; +} + +void osp_arm_cmd_show() +{ + uint8_t i = 0; + uint32_t len = 0; + char pbuf[2048]; + + for(i = 0; i < SHELL_CMD_NUM_EXT; i++) + { + len += sprintf(pbuf +len,"cmd:%s argnum:%u\n", ospCmdRtnTblExt[i].cmd, ospCmdRtnTblExt[i].argnum); + } + + osp_net_shell_out(pbuf, len); + + return; +} + #if 0 void osp_cmd_insert_proc(Osp_Ape_Msg_Head *pMsg) @@ -1380,7 +1475,7 @@ void osp_cmd_insert_proc(osp_sw_msg_info_t *pMsg) return; } - osp_sem_take(ospCmdInsertSem, -1); + osp_sem_take(ospApeCmdInsertSem, -1); pbuf = SPU_SHELL_MSG_HEAD_TO_COMM(pMsg); ulLen = SPU_SHELL_MSG_DADA_LEN(pMsg); @@ -1405,7 +1500,7 @@ void osp_cmd_insert_proc(osp_sw_msg_info_t *pMsg) break; } - osp_sem_give(ospCmdInsertSem); + osp_sem_give(ospApeCmdInsertSem); return; } @@ -1863,6 +1958,7 @@ void osp_set_clk_mode(clk_flag_e pseudo_flag) return; } #endif + void osp_show_swqueue_info() { uint8_t i;