From: Kumar Gala Date: Tue, 23 Sep 2008 09:08:20 -0500 (CDT) Subject: [U-Boot] [RFC] exposing finding a command for subcommands In-Reply-To: References: Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Here's an example of how we sould use this. Obviously the code after the if (cmd) would change. - k diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 3a20ad2..64e7571 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -377,10 +377,23 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress) return 0; } +cmd_tbl_t cmd_bootm_sub[] = { + U_BOOT_CMD_INIT(start, CFG_MAXARGS, 1, BOOTM_STATE_START, "", ""), + U_BOOT_CMD_INIT(loados, CFG_MAXARGS, 1, BOOTM_STATE_LOADOS, "", ""), + U_BOOT_CMD_INIT(ramdisk, CFG_MAXARGS, 1, BOOTM_STATE_RAMDISK, "", ""), +}; + + int do_bootm_subcommand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int ret = 0; int state; + cmd_tbl_t *cmd; + + cmd = __find_cmd(argv[1], &cmd_bootm_sub[0], ARRAY_SIZE(cmd_bootm_sub)); + + if (cmd) + printf("%s %d\n", cmd->name, cmd->cmd); /* start */ if (strcmp(argv[1], "start") == 0) {