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

📄 load.c

📁 MIPS YAMON, a famous monitor inc. source, make file and PDF manuals.
💻 C
📖 第 1 页 / 共 2 页
字号:
    	    break;        }	if( rc != OK )	{	    /* Pause 1 sec */	    sys_wait_ms( 1000 );	}    }    while( rc != OK );    /* print load status message */    printf(MSG_LOAD, (UINT32)load_adr_context[0],                     (UINT32)load_adr_context[1],                     (UINT32)load_adr_context[2],                     (format == MOTOROLA_S3 ? "SREC" :                     (format == MICROSOFT_BIN ? "WINCEBIN" :	              "UNKNOWN") ) );    return OK;}/************************************************************************ *                          parse ************************************************************************/static UINT32parse(    char   *s,    UINT32 *protocol,    UINT32 *src,    char   **filename ){    UINT32 state;    char   *proto_start;    char   *src_start;    char   *name_start;    proto_start = NULL;    src_start   = NULL;    name_start  = NULL;    state = ST_START;    while( (state != ST_DONE) && (state != ST_ERROR) )    {        switch( state )	{	  case ST_START :	    switch( *s )	    {	      case ':' :		shell_error_hint = msg_hint_filename;		state = ST_ERROR;		break;	      case '/' :		state = ST_GET_SRC_OR_NAME;		break;	      case ' ' :		state = ST_ERROR;		break;	      case '\0' :		state = ST_DONE;		break;	      default :	        proto_start = s;		state       = ST_GET_PROTOCOL;		break;	    }	    break;	  	  case ST_GET_PROTOCOL :	    switch( *s )	    {	      case ':' :	        *s    = '\0';		state = ST_GOT_PROTOCOL;		break;	      case '/' :	      case ' ' :	      case '\0' :		shell_error_hint = msg_hint_filename;		state = ST_ERROR;		break;	      default :		state = ST_GET_PROTOCOL;		break;	    }	    break;	  case ST_GOT_PROTOCOL :	    switch( *s )	    {	      case ':' :	        state = ST_ERROR;	        break;	      case '/' :	        state = ST_GET_SRC_OR_NAME;	        break;	      case ' ' :	        state = ST_ERROR;	        break;	      case '\0' :	        state = ST_DONE;		break;	      default :	        state = ST_ERROR;	        break;	    }	    break;	  case ST_GET_SRC_OR_NAME :	    switch( *s )	    {	      case '/' :	        src_start = s + 1;	        state     = ST_GET_SRC;	        break;	      case ' ' :	        state = ST_ERROR;	        break;	      case '\0' :	        state = ST_ERROR;		break;	      case ':' :	      default  :	        name_start = s;	        state      = ST_GET_NAME;	        break;	    }	    break;	  case ST_GET_SRC :	    switch( *s )	    {	      case ':' :	        state = ST_ERROR;	        break;	      case '/' :	        *s         = '\0';		name_start = s + 1;		state      = ST_GET_NAME;	        break;	      case ' ' :	        state = ST_ERROR;	        break;	      case '\0' :		state = ST_DONE;		break;	      default :	        state = ST_GET_SRC;	        break;	    }	    break;	  case ST_GET_NAME :	    switch( *s )	    {	      case '/' :		if( s[-1] == '/' )		    state = ST_ERROR;		else	            state = ST_GET_NAME;	        break;	      case ' ' :	        state = ST_ERROR;	        break;	      case '\0' :		state = ST_DONE;		break;	      case ':' :	      default :	        state = ST_GET_NAME;	        break;	    }	    break;	  default :	    break;	}        s++;    }    if( state == ST_DONE )    {        /* Get protocol */        if( !proto_start )	{            if( !env_get( "bootprot",		          &proto_start, NULL, 0 ) )	    {	        /* Only fails on platforms not supporting Ethernet */	        proto_start = "asc";	    }	}	if( !env_decode_bootprot(	        proto_start,		protocol,		sizeof(UINT32) ) )        {	    shell_error_hint = msg_hint_filename;	    return SHELL_ERROR_BOOTPROT;        }	/* Get source */	if( !src_start )	{	    if( !env_get( (*protocol == PROTOCOL_ASC) ?		         "bootserport" : "bootserver",		    &src_start, NULL, 0 ) )	    {	        src_start = "";	    }        }        if( *protocol == PROTOCOL_ASC )        {	    if( !env_decode_bootserport(	            src_start,		    src,		    sizeof(UINT32) ) )            {	        return SHELL_ERROR_PORT;            }	}	else	{	    /* Must be IP address */	    if( !env_ip_s2num( src_start, src, sizeof(UINT32) ) )	        return SHELL_ERROR_IP;	}	/* Filename */        if( *protocol == PROTOCOL_TFTP )	{	    if( name_start )		*filename = name_start;	    else	    {	        if( !env_get( "bootfile", filename, NULL, 0 ) )		    *filename = "";	    }	    if( strspn( *filename, " " ) == strlen( *filename ) )	    {		/* All whitespace filename */		return SHELL_ERROR_FILENAME;	    }	}	else	{  	    if( name_start )	        return SHELL_ERROR_SYNTAX;        }        return OK;    }    else        return SHELL_ERROR_SYNTAX;}/* Command definition for help */static t_cmd cmd_def ={    "load",     load,    "load [-r]\n"    "     ([tftp:][//<ipaddr>][/<filename>]) |\n"    "     ([asc:] [//(tty0|tty1)])",    "Load image from serial port or Ethernet to RAM or flash (depending\n"    "on address). The only image type currently supported is SREC.\n"    "\n"    "On platforms supporting both Ethernet and serial port, the default\n"    "protocol is taken from the environment variable 'bootprot'. On\n"    "platforms without Ethernet, the only (and default) protocol is 'asc'.\n"    "\n"    "If loading from serial port, the default port is taken from the\n"    "environment variable 'bootserport'.\n"    "\n"    "If loading from Ethernet, the IP address of the TFTP server and\n"    "the filename may be specified. If an IP address is not specified,\n"    "it is taken from the environment variable 'bootserver'. If a\n"    "filename is not specified, it is taken from the environment\n"    "variable 'bootfile'.\n"    "Note that the exact limitation on the filesize in the TFTP protocol\n"    "is 33553919 bytes (appr. 32 Mbytes). Any file larger than this size\n"    "cannot be transferred.\n"    "\n"    "For the currently supported formats, the execution entrypoint of the\n"    "image is embedded in the image. This address is saved such that the\n"    "'go' command can use it as the default entrypoint.\n"    "\n"    "During the load operation, the current load address will be shown on\n"    "the 8-position hex display (if present).\n"    "\n"    "Note that the load command prevents the user from overwriting the\n"    "environment flash area.",    options,    OPTION_COUNT,    FALSE};/* Command definitions for SDB 'l' command (secret command) */static t_cmd cmd_def_sdb_lower ={    "l",    load_sdb,    "l                        (Microsoft SDB command)",    "Load image from serial port (console tty0) to RAM or Flash (depending\n"    "on destination addresses).\n"    "\n"    "The only image type currently supported is SREC.",    NULL,    0,    TRUE};/************************************************************************ *  Implementation : Public functions ************************************************************************//************************************************************************ * *                          shell_load_init *  Description : *  ------------- * *  Initialise command * *  Return values : *  --------------- * *  void * ************************************************************************/t_cmd *shell_load_init( void ){    return &cmd_def;}/************************************************************************ * *                          shell_load_sdb_init *  Description : *  ------------- * *  Initialise command * *  Return values : *  --------------- * *  void * ************************************************************************/t_cmd *shell_load_sdb_init( void ){    return &cmd_def_sdb_lower;}

⌨️ 快捷键说明

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