コード例 #1
0
ファイル: prjConfig.c プロジェクト: vineethkartha/VxWorks
void usrShellInit (void)
    {
    shellLibInit ();                    /* Handles the shell core files */
    dbgInit ();                         /* Breakpoints and stack tracer on target. Not needed for remote debugging with tornado. */
    vxdbgRtpLibInit ();                 /* Initialize process debugging library. */
    usrBanner ();                       /* Display the WRS banner on startup */
    ledModeRegister (viLedLibInit);     /* Editing mode similar to the Vi editing mode */
    ledModeRegister (emacsLedLibInit);  /* Editing mode similar to the emacs editing mode */
    shellInterpRegister (shellInterpCInit); /* The C interpreter for the kernel shell */
    shellInterpRegister (shellInterpCmdInit); /* The command interpreter for the kernel shell */
    usrShellCmdInit ();                 /* The kernel shell commands initialization sequence */
    usrStartupScript (startupScriptFieldSplit (sysBootParams.startupScript)); /* Initial kernel shell script run at VxWorks startup */
    usrShell ();                        /* Interpreter for interactive development, prototyping, debugging and testing */
    }
コード例 #2
0
/*****************************************************************************
* 函 数 名     :  cshell_direction
*
* 功能描述  : 改变cshell的方向
*
* 输入参数  :  cshell_mode_tpye mode :
*                           CSHELL_MODE_UART : 切换到UART
*                           CSHELL_MODE_USB   : 切换到USB
* 输出参数  :  无
*
* 返 回 值     :  无
*
* 修改记录  :
*****************************************************************************/
int cshell_direction(cshell_mode_tpye mode)
{
    int key = 0;
    int fd = 0;
    SHELL_ID ShellID;
    char ttyFg[16] = {0x00};
    char ttyBg[16] = {0x00};
    SHELL_IO_CHAN *ptr_shell = &shell_io_channel;
	SRAM_SMALL_SECTIONS * sram = (SRAM_SMALL_SECTIONS * )SRAM_SMALL_SECTIONS_ADDR;

    if ((cshell_mode_tpye)(ptr_shell->shell_mode) == mode)
    {
		cshell_print_error("C:no need to redirect cshell!\n");
        return OK;
    }

    if (CSHELL_MODE_UART == mode)
    {
        /* coverity[secure_coding] */
        sprintf(ttyFg, "/tyCo/0");
        /* coverity[secure_coding] */
        sprintf(ttyBg, "/tyCo/3");
    }
    else if (CSHELL_MODE_USB == mode)
    {
        /* coverity[secure_coding] */
        sprintf(ttyFg, "/tyCo/3");
        /* coverity[secure_coding] */
        sprintf(ttyBg, "/tyCo/0");
    }
    else
    {
		cshell_print_error("C:redirect parm error[%d]!\n", mode);
        return ERROR;
    }
	if (CSHELL_MODE_UART == mode)
		intEnable((int)sram->UART_INFORMATION[1].interrupt_num);
    else
    {
        /* 禁止串口中断,M核心采用UART */
   	    intDisable((int)sram->UART_INFORMATION[1].interrupt_num);
    }

    key = intLock();
    //taskLock();

    /* 关闭Shell当前使用的串口 */
    fd = ioGlobalStdGet(STD_IN);
    (void)ioctl (fd, FIOSETOPTIONS, OPT_RAW);
    close(fd);

    ShellID = shellFromTaskGet(shellConsoleTaskId);
    shellTerminate(ShellID);/* [false alarm]:误报 */

    if (0 != (fd = open(ttyFg, O_RDWR, 0)))/* [false alarm]:误报 */
    {
        /* 切换成功 */
        ptr_shell->shell_mode = mode;
    }
    else
    {
        /* 切换失败 */
        fd = open(ttyBg, O_RDWR, 0);
        if (0 == fd)
        {
            //taskUnlock();
            intUnlock(key);
            return ERROR;
        }
    }

    /* coverity[noescape] */
    (void)ioctl (fd, FIOSETOPTIONS, OPT_TERMINAL);

    /* coverity[noescape] */
    ioGlobalStdSet (STD_OUT, fd);
    /* coverity[noescape] */
    ioGlobalStdSet (STD_IN,  fd);
    /* coverity[noescape] */
    ioGlobalStdSet (STD_ERR, fd);

    //taskUnlock();
    intUnlock(key);

    usrShell();

    return OK;
}