📄 commands.c
字号:
/* -*-C-*- * * $Revision: 1.2 $ * $Author: mechavar $ * $Date: 2000/05/01 19:37:08 $ * * Copyright (c) 2000 ARM, INC. * All Rights Reserved. * * Project: BootStrap Loader * * Boot monitor command decoding */#include <string.h>#include "swis.h"#include "modules.h"#include "bsl_platform.h"#include "lib.h"#include "gdata.h"#include "commands.h"#include "errors.h"static int unsetenv(char *name){ char *env, *next, *end; env = env_lookup(name); if (!env) return 0; next = env; next += strlen(next) + 1; end = next; while (*end >= ' ' && *end <= '~' || *end == 0) end++; end++; FlashWrite((unsigned)env, (unsigned)env+(end-next), next); return 1;}CallBack SetEnvCommand(char *name){ char *env; int len; name = strcpy(command_line, name); unsetenv(name); env = (char *)ENV_BASE; while (*env >= ' ' && *env <= '~' || *env == 0) env++; len = strlen(name) + 1; len += 1; if (env + len >= (char *)ENV_LIMIT) { return ReportError(ENOMEM, "Out of room in environment area. Use UnsetEnv to delete variables."); } name[len-1] = 0xff; FlashWrite((unsigned)env, (unsigned)env + len, name); return ReportOK();}CallBack UnSetEnvCommand(char *tail){ if (!unsetenv(tail)) return ReportError(EINVAL, "Environment variable '%s' not found. Use PrintEnv to list variables.", tail); return ReportOK();}CallBack PrintEnvCommand(char *tail){ char *env; int i; PrettyPrint("Variable\tValue"); PrettyPrint("========\t====="); env = (char *)ENV_BASE; while (*env > ' ' && *env < '~') { for (i = 0; *env > ' '; env++, i++) WriteC(*env); while (*env == ' ') env++; do { WriteC(' '); } while (++i < 16); Write0(env); env += strlen(env)+1; NewLine(); } return ReportOK();}const CmdTable CommandTable[] = { { "Help", HelpCommand, 0, "Help [<command>]", "Help gives help on the command, if none specified, gives a list of commands." }, { "Modules", ModulesCommand, 0, "Modules", "Modules lists all currently active modules." }, { "ROMModules", ROMModules, 0, "ROMModules", "ROMModules lists the modules in ROM." }, { "UnPlug", UnPlugCommand, 0, "UnPlug <module name>", "UnPlug marks a ROM Module as unplugged so it entries will not be called." }, { "PlugIn", PlugInCommand, 0, "PlugIn <module name>", "PlugIn reinstates an unplugged module." }, { "Kill", KillCommand, 0, "Kill <module name>", "Kill removes a module from the list of currently active modules." }, { "SetEnv", SetEnvCommand, 0, "SetEnv <variable-name> <value>", "SetEnv programs the specified variable name into non volatile RAM." }, { "UnSetEnv", UnSetEnvCommand, 0, "UnSetEnv <varaiable-name>", "UnSetEnv deletes the specified variable name from non volatile RAM." }, { "PrintEnv", PrintEnvCommand, 0, "PrintEnv", "PrintEnv lists alls variables stored in non volatile RAM." }, { "DownLoad", DownLoadCommand, 0, "DownLoad [<address>]", "DownLoad loads a uuencoded program to memory, default download address = 0x8000." }, { "Go", GoCommand, 0, "Go [<command line>]", "Starts execution at address specified by previous PC or DownLoad command." }, { "GoS", GoSCommand, 0, "GoS [<command line>]", "Like Go command, but starts execution in SVC mode." }, { "Boot", Boot, 0, "Boot", "Boots the system." }, { "PC", PCCommand, 0, "PC <address>", "Sets the PC prior to a Go or GoS command." }, { "FlashWrite", FlashWriteCommand, 0, "FlashWrite <address> <source> <length>", "Writes the specified range of memory into flash." }, { "FlashLoad", FlashLoadCommand, 0, "FlashLoad <address>", "Performs a DownLoad, then writes the downloaded file to flash." }, { "FlashErase", FlashEraseCommand, 0, "FlashErase <address> <length>", "Erases the specified flash region by writing it with 0xFF." }, { 0, 0, 0, 0, 0 }};CallBack go_common(char *tail, void (*go)(void)){ ServiceBlock sb; CallBack cb; cb = SetEnv(tail, himem); if (cb) return cb; sb = ServiceCall(Service_AppStart, current_pc, go); if (sb.r0) return sb.r0; current_pc = sb.r1; go = (CallBack)sb.r2; return go;}CallBack GoCommand(char *tail){ return go_common(tail, DoGo);}CallBack GoSCommand(char *tail){ return go_common(tail, DoGoS);}CallBack PCCommand(char *tail){ CallBack cb; unsigned args; if (*tail) { cb = read_args_hex(tail, 1, &args); if (cb) return cb; current_pc = args; } PrettyPrint("PC = %x", current_pc); return ReportOK();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -