⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 go.c

📁 MIPS YAMON, a famous monitor inc. source, make file and PDF manuals.
💻 C
📖 第 1 页 / 共 2 页
字号:
/************************************************************************ * *  go.c * *  Shell go command * *  go [?|.|<address> [<args>]]", * * ###################################################################### * * mips_start_of_legal_notice *  * Copyright (c) 2004 MIPS Technologies, Inc. All rights reserved. * * * Unpublished rights (if any) reserved under the copyright laws of the * United States of America and other countries. * * This code is proprietary to MIPS Technologies, Inc. ("MIPS * Technologies"). Any copying, reproducing, modifying or use of this code * (in whole or in part) that is not expressly permitted in writing by MIPS * Technologies or an authorized third party is strictly prohibited. At a * minimum, this code is protected under unfair competition and copyright * laws. Violations thereof may result in criminal penalties and fines. * * MIPS Technologies reserves the right to change this code to improve * function, design or otherwise. MIPS Technologies does not assume any * liability arising out of the application or use of this code, or of any * error or omission in such code. Any warranties, whether express, * statutory, implied or otherwise, including but not limited to the implied * warranties of merchantability or fitness for a particular purpose, are * excluded. Except as expressly provided in any written license agreement * from MIPS Technologies or an authorized third party, the furnishing of * this code does not give recipient any license to any intellectual * property rights, including any patent rights, that cover this code. * * This code shall not be exported, reexported, transferred, or released, * directly or indirectly, in violation of the law of any country or * international law, regulation, treaty, Executive Order, statute, * amendments or supplements thereto. Should a conflict arise regarding the * export, reexport, transfer, or release of this code, the laws of the * United States of America shall be the governing law. * * This code constitutes one or more of the following: commercial computer * software, commercial computer software documentation or other commercial * items. If the user of this code, or any related documentation of any * kind, including related technical data or manuals, is an agency, * department, or other entity of the United States government * ("Government"), the use, duplication, reproduction, release, * modification, disclosure, or transfer of this code, or any related * documentation of any kind, is restricted in accordance with Federal * Acquisition Regulation 12.212 for civilian agencies and Defense Federal * Acquisition Regulation Supplement 227.7202 for military agencies. The use * of this code by the Government is further restricted in accordance with * the terms of the license agreement(s) and/or applicable contract terms * and conditions covering this code from MIPS Technologies or an authorized * third party. * * * *  * mips_end_of_legal_notice *  * ************************************************************************//************************************************************************ *  Include files ************************************************************************/#include <sysdefs.h>#include <syscon_api.h>#include <string.h>#include <stdio.h>#include <shell_api.h>#include <yamon_api.h>#include <string.h>#include <mips.h>#include <sys_api.h>#include <excep_api.h>#include <env_api.h>#include <shell.h>/************************************************************************ *  Definitions ************************************************************************//************************************************************************ *  Public variables ************************************************************************/UINT32 shell_argc_appl; char   *(shell_argv_appl[SHELL_APPL_MAX_ARGS]);t_gdb_regs   shell_context;t_gdb_regs   appl_context;UINT32       appl_shell_func_code;/************************************************************************ *  Static variables ************************************************************************/static char *go_string = "go";static bool  shift_gdb_retval;/************************************************************************ *  Static function prototypes ************************************************************************/static UINT32 get_options(    UINT32 argc,    char   **argv,    void   **address,    bool   *disp_addr );static voidappl_exception( void );/************************************************************************ *  Implementation : Static functions ************************************************************************//************************************************************************ *                          go ************************************************************************/static MON_FUNC(go){    void   *address;    bool   disp_addr;    UINT32 rc;    /* Options */    rc = get_options( argc, argv, &address, &disp_addr );    if( rc != OK )        return rc;    if( disp_addr )    {	if( shell_addr_go_valid )	    printf( "Address = 0x%08x\n", (UINT32)shell_addr_go );	else	    printf( "Address unknown\n" );    }    else    {        /* Store start address */        shell_addr_go_valid = TRUE;        shell_addr_go       = address;        /* Setup startup conditions */	shell_setup_default_cpu( &appl_context, (UINT32)address );	/* Shift to user application */        shell_shift_to_user( FALSE, TRUE );    }    return OK;}/************************************************************************ *                          get_options ************************************************************************/static UINT32get_options(    UINT32 argc,    char   **argv,    void   **address,    bool   *disp_addr ){    char	   *token;    bool           ok   = TRUE;    bool	   args = FALSE;    bool	   addr_valid;    t_shell_option decode;    UINT32	   arg;    UINT32	   error = SHELL_ERROR_SYNTAX;    /* Defaults */    if( shell_addr_go_valid )    {        *address   = shell_addr_go;	addr_valid = TRUE;    }    else        addr_valid = FALSE;    shell_argc_appl    = 1;    shell_argv_appl[0] = go_string;    *disp_addr         = FALSE;    for( arg = 1; 	          ok && 	          (arg < argc) && 		  (token = argv[arg]);         arg++ )    {        if( args )	{	    if( shell_argc_appl == SHELL_APPL_MAX_ARGS )	    {	        return SHELL_ERROR_ARGV;	    }	    else	    {	        shell_argv_appl[shell_argc_appl] = token;	        shell_argc_appl++;	    }        }	else	{	    if( *token == '-' )	    {	        error		 = SHELL_ERROR_OPTION;		shell_error_data = token;		ok		 = FALSE;	    }	    else if( strcmp( token, "?" ) == 0 )	    {		if( argc != 2 )		    ok = FALSE;		else	            *disp_addr = TRUE;	    }            else if( strcmp( token, "." ) == 0 )	    {	        args = TRUE;	    }            else	    {		ok = shell_decode_number( &decode, NULL, token );		if( ok )		{	            *address   = (void *)decode.number;		    addr_valid = TRUE;	            args       = TRUE;		}	    }	}    }    if( !ok )    {	return error;    }    if( *disp_addr )        return OK;        if( !addr_valid )    {	return SHELL_ERROR_ADDRESS_UNKNOWN;    }    if( sys_mips16e && ((UINT32)(*address) & 1) )    {        return sys_validate_range( (UINT32)(*address) & ~1, 			           sizeof(UINT16), 			           sizeof(UINT16),			           FALSE );    }    else    {        return sys_validate_range( (UINT32)(*address), 			           sizeof(UINT32), 			           sizeof(UINT32),			           FALSE );    }}/************************************************************************ *                          appl_exception ************************************************************************/static voidappl_exception( void ){    /* Called from exception_sr()     *  (normal or ejtag exception context holds context)     */    t_gdb_regs *context = EXCEP_get_context_ptr();    if( shift_gdb_retval )    {	/* return value of gdb_shift_to_appl() in case of exception */	shift_gdb_retval = FALSE;	memcpy( &appl_context, context, sizeof(t_gdb_regs ) );    }    else    {	/* Print context */	EXCEP_print_context( context, NULL, TRUE, FALSE );	printf( "\n" );    }    EXCEP_exc_handler_ret_ss( &shell_context );}/* Command definition for help */static t_cmd cmd_def ={    "go",     go,    "go [?|.|<address> [<args>]]",    "Execute application code.\n"    "\n"    "If a target address is not specified, the address obtained from the last\n"    "successful 'load' or 'go' command (if any) is used as the target address.\n"    "This address may be determined by issuing a 'go ?' command. The application\n"    "will not be executed in this case.\n"    "\n"    "If arguments for the user program need to be specified, the default\n"    "execution address can be referenced by a '.'.\n"    "\n"    "<args> is broken up in substrings and passed to the application.\n"    "The first argument (argv[0]) will be the string 'go'.\n"    "\n"    "a0 is set to the number of substrings (argc).\n"    "a1 is set to the address of an array of pointers to the substrings (argv).\n"    "a2 is set to the address of the environment table.\n"    "a3 is set to the memory size.\n"    "ra holds the return address to YAMON.\n"    "\n"    "The application may return to YAMON by jumping to the address\n"    "specified in ra or by calling the exit(rc) function supplied by YAMON.",    NULL,    0,    FALSE};/************************************************************************ *  Implementation : Public functions ************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -