更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
shell_pri.h 文件参考

浏览源代码.

函数

void ShellEntry (ShellCB *shellCB)
 
voidShellTask (void *argv)
 

函数说明

◆ ShellEntry()

void ShellEntry ( ShellCB shellCB)

在文件 shmsg.c659 行定义.

660{
661 char ch;
662 int ret;
663 int n;
664 pid_t tid = syscall(__NR_gettid);//获取当前任务/线程ID, 即 "Shell Entry" 任务的ID
665
666 if (shellCB == NULL) {
667 return;
668 }
669
670 (void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
671
672 ret = ShellKernelReg((int)tid);//向内核注册shell,和控制台捆绑在一块
673 if (ret != 0) {
674 printf("another shell is already running!\n");
675 exit(-1);
676 }
677
678 while (1) {
679 n = read(0, &ch, 1);//读取输入字符
680 if (n == 1) {
681 ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);//对命令行内容进行解析
682 }
683 }
684 return;
685}
void(* OutputFunc)(const char *fmt,...)
Definition: shmsg.h:63
static int ShellKernelReg(unsigned int shellHandle)
Definition: shmsg.c:654
void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
Definition: shmsg.c:271
void exit(int status)
Definition: stdlib.c:60
char shellBuf[SHOW_MAX_LEN]
接受shell命令 buf大小
Definition: shell.h:83
ARG_NUM_3 ARG_NUM_1 ARG_NUM_2 ARG_NUM_2 ARG_NUM_3 ARG_NUM_1 ARG_NUM_4 ARG_NUM_2 ARG_NUM_2 ARG_NUM_5 ARG_NUM_2 void
函数调用图:
这是这个函数的调用关系图:

◆ ShellTask()

void * ShellTask ( void argv)

在文件 shmsg.c601 行定义.

602{
603 int ret;
604 ShellCB *shellCB = (ShellCB *)argv;
605
606 if (shellCB == NULL) {
607 return NULL;
608 }
609
610 ret = prctl(PR_SET_NAME, "ShellTask");
611 if (ret != SH_OK) {
612 return NULL;
613 }
614
615 printf(SHELL_PROMPT);
616 while (1) {
617 ret = ShellPend(shellCB);
618 if (ret == SH_OK) {
619 ShellCmdProcess(shellCB);
620 } else if (ret != SH_OK) {
621 break;
622 }
623 }
624
625 return NULL;
626}
static void ShellCmdProcess(ShellCB *shellCB)
Definition: shmsg.c:582
int ShellPend(ShellCB *shellCB)
Definition: shmsg.c:117
Definition: shell.h:71
函数调用图:
这是这个函数的调用关系图: