int Set(int argc,char *argv[]) { int opt; while((opt=getopt(argc,argv,"b:")) != -1) { switch(opt) { case 'b': ChangeConsoleBaudrate(atoi(optarg)); return(CMD_SUCCESS); break; default: return(CMD_PARAM_ERROR); } } printf("Shell vars not included in build.\n"); return(CMD_FAILURE); }
/* init3(): * As each target boots up, it calls init1() and init2() to do multiple * phases of hardware initialization. This third initialization phase * is always common to all targets... * It is possible that this is being called by AppWarmStart(). In this * case, the user can specify which portions of the monitor code are * to be initialized by specifying them in the startmode mask. */ static void _init3(ulong startmode) { char *baud; #if INCLUDE_LINEEDIT /* Initialize command line history table. */ historyinit(); #endif #if INCLUDE_SHELLVARS /* Init shell variable table. */ ShellVarInit(); #endif #if INCLUDE_USRLVL /* Set user level to its max, then allow monrc file to adjust it. */ initUsrLvl(MAXUSRLEVEL); #endif #if INCLUDE_BOARDINFO /* Check for board-specific-information in some otherwise unused * sector. Also, establish shell variables from this information * based on the content of the boardinfo structure. * Note that the second half of the board-specific information setup * (the call to BoardInfoEnvInit()) must be done AFTER ShellVarInit() * because shell variables are established here. */ if(startmode & WARMSTART_BOARDINFO) { BoardInfoInit(); BoardInfoEnvInit(); } #endif #ifdef MONCOMPTR /* If MONCOMPTR is defined, then verify that the definition matches * the location of the actual moncomptr value. The definition in * config.h is provided so that outside applications can include that * header file so that the value passed into monConnect() is defined * formally. The REAL value of moncomptr is based on the location of * the pointer in monitor memory space, determined only after the final * link has been done. As a result, this check is used to simply verify * that the definition matches the actual value. */ { if(MONCOMPTR != (ulong)&moncomptr) { printf("\nMONCOMPTR WARNING: runtime != definition\n"); } } #endif #if INCLUDE_TFS /* After basic initialization, if the monitor's run-control file * exists, run it prior to EthernetStartup() so that the * MAC/IP addresses can be configured based on shell variables * that would be loaded by the rc file. */ if(startmode & WARMSTART_RUNMONRC) { tfsrunrcfile(); } #endif /* After MONRC is run, establish monitor flags... */ InitMonitorFlags(); /* We've run the monrc file at this point, so check for the * presence of the CONSOLEBAUD shell variable. If it's set, * then use the value to re-establish the console baud rate. * If it isn't set, then establish the CONSOLEBAUD shell variable * using the default, pre-configured baud rate. */ baud = getenv("CONSOLEBAUD"); if(baud) { ChangeConsoleBaudrate(atoi(baud)); } ConsoleBaudEnvSet(); #if INCLUDE_ETHERNET #if INCLUDE_STOREMAC storeMac(0); #endif if(startmode & WARMSTART_IOINIT) { EthernetStartup(0,1); } #endif /* Now that all has been initialized, display the monitor header. */ #ifndef NO_UMON_STARTUP_HDR if(startmode & WARMSTART_MONHEADER) { if(!MFLAGS_NOMONHEADER()) { monHeader(1); } } #endif #if INCLUDE_FBI if(StateOfMonitor == INITIALIZE) { fbi_splash(); } #endif #if INCLUDE_TFS if(startmode & WARMSTART_TFSAUTOBOOT) { tfsrunboot(); } #endif }
int Set(int argc,char *argv[]) { char *file, *envp, buf[CMDLINESIZE]; int opt, decimal, setop, i; setop = SET_NOOP; file = (char *)0; envp = (char *)0; decimal = 1; while((opt=getopt(argc,argv,"ab:cdef:iox")) != -1) { switch(opt) { case 'a': /* logical and */ setop = SET_AND; decimal = 0; break; case 'b': ChangeConsoleBaudrate(atoi(optarg)); return(CMD_SUCCESS); case 'c': /* clear environment */ clearenv(); break; case 'd': /* decrement */ setop = SET_DECR; break; case 'e': envp = getenvp(); break; #if INCLUDE_TFS case 'f': /* build script from environment */ envToExec(optarg); return(0); #endif case 'i': /* increment */ setop = SET_INCR; break; case 'o': /* logical or */ setop = SET_OR; decimal = 0; break; case 'x': decimal = 0; break; default: return(CMD_PARAM_ERROR); } } if (!shell_vars) { printf("No memory allocated for environment.\n"); return(CMD_FAILURE); } if (setop != SET_NOOP) { /* Do some operation on a shell variable */ char *varval; unsigned long value, opval; /* For -i & -d, if value is not specified, then assume 1. */ if (argc == optind+1) { if ((setop == SET_INCR) || (setop == SET_DECR)) opval = 1; else return(CMD_PARAM_ERROR); } else if (argc == optind+2) opval = strtoul(argv[optind+1],0,0); else return(CMD_PARAM_ERROR); varval = getenv(argv[optind]); if (!varval) { printf("%s: not found\n", argv[optind]); return(CMD_FAILURE); } value = strtoul(varval,(char **)0,0); switch(setop) { case SET_INCR: value += opval; break; case SET_DECR: value -= opval; break; case SET_AND: value &= opval; break; case SET_OR: value |= opval; break; } if (decimal) sprintf(buf,"%ld",value); else sprintf(buf,"0x%lx",value); setenv(argv[optind],buf); } else if (argc == optind) { /* display all variables */ shell_print(); } else if (argc == (optind+1)) { /* run EE or clear one var or set envp */ #if INCLUDE_EE switch(setEE(argv[optind])) { case 1: return(CMD_SUCCESS); case -1: return(CMD_FAILURE); } #endif if (envp) shell_sprintf(argv[optind],"0x%lx",(ulong)envp); else setenv(argv[optind],0); } else if (argc >= (optind+2)) { /* Set a specific variable */ buf[0] = 0; for(i=optind+1;i<argc;i++) { if ((strlen(buf) + strlen(argv[i]) + 2) >= sizeof(buf)) { printf("String too large\n"); break; } strcat(buf,argv[i]); if (i != (argc-1)) strcat(buf," "); } if (!decimal) shell_sprintf(argv[optind],"0x%lx",atoi(buf)); else setenv(argv[optind],buf); } else return(CMD_PARAM_ERROR); return(CMD_SUCCESS); }