pmon/mycmd.c
Optdesc mycmd_opts[] = {
{"","My Command"},
{0}};
mycmd(argc,argv)
int argc;
char *argv[];
{
int i;
printf("This is my command. Arguments were: ");
for (i=1;i<argc;i++) printf("%s ",argv[i]);
printf("\n");
}
Note that you can also list any options that your new command accepts, to
the mycmd_opts array. The first field can contain the list of options.
Additional lines would explain those options. For example,
Optdesc mycmd_opts[] = {
{"[-fl]","My Command"},
{"-f","Find bug"},
{"-l","Lose bug"},
{0}};
The name of this function must now be installed in the table of
commands. The easiest way to do this is by using addCmdRec(). You
can place this call almost anywhere, but perhaps the best place is
in the CPU-specific high-init init code, eg. c4101.c. There is already
a list of commands in this file, you just need to all yours to the list.
CmdRec cmds[] = {
{"cache",mycmd_opts,mycmd},
.....
{0}};
Finally, the new module must be added to the list used by the Makefile.
pmon/files.mk CFILES = sonic.c main.c commands.c dis.c hist.c regs.c sym.c \ set.c stty.c more.c memtst.c go.c load.c debug.c \ cmdtable.c sbrk.c mycmd.cTo support arguments that can be complex expressions, convert the argument from ascii to binary using the function get_rsa(). This function has the prototype:
int get_rsa(unsigned long *value, char *source);Where:
| source | is the input ascii string. |
| value | is the place where the binary value is to be written. |
| The return value is 1 if the conversion was successful, otherwise it is zero. get_rsa() prints its own messages if the conversion was unsuccessful. | |
Example:
if(!get_rsa(&adr,av[i])) return;Once the files havebeen modified, you need to rebuild PMON and make new ROMs.