From: Hicks, Jamey (Jamey.Hicks@compaq.com)
Date: Wed Mar 06 2002 - 12:00:30 EST
Sacha,
This is an even more important project than the previous one. I've been thinking about something along these lines. I do not like the way all the subcommands require if (strcmp(argv[1], foobar) ..., however.
Take a look at params.h and params.c to see how the parameters are defined. These used to be defined in a giant table like the toplevel commands are.
I would like you to add commands.h and commands.c so that the commands can be defined in files other than bootldr.c. Unlike params, there will be toplevel and nested commands.
How about something like:
COMMAND("load", command_load, "load", BB_RUN_FROM_RAM);
SUBCOMMAND("load", "flash", command_load_flash, "load flash <dstaddr>", 0 );
...
which would create bootblk_command entries in the .data.commands section of the executable.
bootblk_command will need a new field containing the subcommand name. It should probably be renamed to bootldr_command.
Another note: params.h has a bunch of declarations for each of the params structures -- we do not need that for the commands.
If this makes sense, please start by creating appropriate macros in commands.h. Add COMMAND() and SUBCOMMAND() declarations just before the implementation of the corresponding command routines. Add a test command to test out this interface, e.g.,
testcmd load flash
will use the new command code.
After this is debugged, we can make it the standard command interface and then we can split some of the command definitions out of bootldr.c.
Jamey
This archive was generated by hypermail 2.1.5 : Fri Jan 17 2003 - 17:47:03 EST