From: Zach W. <zw...@us...> - 2009-11-25 19:57:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 90d09e35e4be6f0b35899238b253154249f85cb6 (commit) via ad090413a8dfacccc993ff15b8376e0f2bd56712 (commit) via 6b9bb584a5edec4889b12ed3f99a1e2eeab1ada2 (commit) via b4e95c37205bae2c22d9c223a4e92bcea38bf7dd (commit) via 5e977b46c3a4688d9bf5091306ce3003f1bd6713 (commit) via dfa856ca186bd703b3c75f374b4f84dff372345c (commit) via f9606a6cb72d8bce8964b66e5aa5eec5d98a7b1d (commit) via 737f8f2735011256f9ca5a3988ee02167f2847a2 (commit) via 0ff0dbba497374dddac9641b466e97d67bb6678d (commit) via ccae9ae0200a66472409334d18108b309a9fae70 (commit) via 1bf7462edb89a79835e8bd42905d69282ba4ba17 (commit) via 7609e1091abfacfc1b62aca06c642e42003aa444 (commit) via 1cbe3ec6f105e35e641293cd7e62e6fefac1b271 (commit) via a12a29c28a92f51861957a09d86177625220483b (commit) via b90bf52be340d8ad2285f2f359174fbc1e31ce24 (commit) via 1765b103044179baa2d5036bb61710369ae59e70 (commit) via b595ab8b97ae15babe530a935bb5009cdb02fcd7 (commit) via c4aa2fd6e745d7d9fb82673f5845a09c98b10912 (commit) via bdae918dcd3bbcd1a90b2c5f65291908271727f7 (commit) via 2a4a94b7ac4401802832f37ef07b0500efc92f0e (commit) from 8d46720cda288f498787a706bb2518e6f852b9f1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 90d09e35e4be6f0b35899238b253154249f85cb6 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 06:24:19 2009 -0800 remove nand_controller->register_callbacks Replace flash_driver callback with pointer to command_registration. Eliminates all related routines and allows drivers to omit commands. diff --git a/src/flash/davinci_nand.c b/src/flash/davinci_nand.c index ebd9ba8..72cd378 100644 --- a/src/flash/davinci_nand.c +++ b/src/flash/davinci_nand.c @@ -78,11 +78,6 @@ static int halted(struct target *target, const char *label) return false; } -static int davinci_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - static int davinci_init(struct nand_device *nand) { struct davinci_nand *info = nand->controller_priv; @@ -747,7 +742,6 @@ fail: struct nand_flash_controller davinci_nand_controller = { .name = "davinci", .nand_device_command = davinci_nand_device_command, - .register_commands = davinci_register_commands, .init = davinci_init, .reset = davinci_reset, .command = davinci_command, diff --git a/src/flash/lpc3180_nand_controller.c b/src/flash/lpc3180_nand_controller.c index 2dec3e1..146c843 100644 --- a/src/flash/lpc3180_nand_controller.c +++ b/src/flash/lpc3180_nand_controller.c @@ -893,15 +893,10 @@ static const struct command_registration lpc3180_command_handler[] = { COMMAND_REGISTRATION_DONE }; -static int lpc3180_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, lpc3180_command_handler); -} - struct nand_flash_controller lpc3180_nand_controller = { .name = "lpc3180", + .commands = lpc3180_command_handler, .nand_device_command = lpc3180_nand_device_command, - .register_commands = lpc3180_register_commands, .init = lpc3180_init, .reset = lpc3180_reset, .command = lpc3180_command, diff --git a/src/flash/mx3_nand.c b/src/flash/mx3_nand.c index 459e2a6..1dc4fcb 100644 --- a/src/flash/mx3_nand.c +++ b/src/flash/mx3_nand.c @@ -315,11 +315,6 @@ static int imx31_nand_ready (struct nand_device *nand, int timeout) return imx31_controller_ready (nand, timeout); } -static int imx31_register_commands (struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - static int imx31_reset (struct nand_device *nand) { /* @@ -871,7 +866,6 @@ static int do_data_output (struct nand_device *nand) struct nand_flash_controller imx31_nand_flash_controller = { .name = "imx31", .nand_device_command = &imx31_nand_device_command, - .register_commands = &imx31_register_commands, .init = &imx31_init, .reset = &imx31_reset, .command = &imx31_command, diff --git a/src/flash/nand.c b/src/flash/nand.c index bc0e350..1e28ba2 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -214,11 +214,12 @@ COMMAND_HANDLER(handle_nand_list_drivers) static COMMAND_HELPER(create_nand_device, const char *bank_name, struct nand_flash_controller *controller) { - int retval = controller->register_commands(CMD_CTX); - if (ERROR_OK != retval) + if (NULL != controller->commands) { - LOG_ERROR("couldn't register '%s' commands", controller->name); - return retval; + int retval = register_commands(CMD_CTX, NULL, + controller->commands); + if (ERROR_OK != retval) + return retval; } struct nand_device *c = malloc(sizeof(struct nand_device)); @@ -233,7 +234,7 @@ static COMMAND_HELPER(create_nand_device, const char *bank_name, c->use_raw = 0; c->next = NULL; - retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c); + int retval = CALL_COMMAND_HANDLER(controller->nand_device_command, c); if (ERROR_OK != retval) { LOG_ERROR("'%s' driver rejected nand flash", controller->name); diff --git a/src/flash/nand.h b/src/flash/nand.h index af52c77..b780f28 100644 --- a/src/flash/nand.h +++ b/src/flash/nand.h @@ -35,8 +35,8 @@ struct nand_device; struct nand_flash_controller { char *name; + const struct command_registration *commands; __NAND_DEVICE_COMMAND((*nand_device_command)); - int (*register_commands)(struct command_context *cmd_ctx); int (*init)(struct nand_device *nand); int (*reset)(struct nand_device *nand); int (*command)(struct nand_device *nand, uint8_t command); diff --git a/src/flash/orion_nand.c b/src/flash/orion_nand.c index c8fc969..77a03f2 100644 --- a/src/flash/orion_nand.c +++ b/src/flash/orion_nand.c @@ -120,11 +120,6 @@ static int orion_nand_controller_ready(struct nand_device *nand, int timeout) return 1; } -static int orion_nand_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command) { struct orion_nand_controller *hw; @@ -180,7 +175,6 @@ struct nand_flash_controller orion_nand_controller = .reset = orion_nand_reset, .controller_ready = orion_nand_controller_ready, .nand_device_command = orion_nand_device_command, - .register_commands = orion_nand_register_commands, .init = orion_nand_init, }; diff --git a/src/flash/s3c2410_nand.c b/src/flash/s3c2410_nand.c index 6fe8bae..ca50c99 100644 --- a/src/flash/s3c2410_nand.c +++ b/src/flash/s3c2410_nand.c @@ -110,7 +110,6 @@ static int s3c2410_nand_ready(struct nand_device *nand, int timeout) struct nand_flash_controller s3c2410_nand_controller = { .name = "s3c2410", .nand_device_command = &s3c2410_nand_device_command, - .register_commands = &s3c24xx_register_commands, .init = &s3c2410_init, .reset = &s3c24xx_reset, .command = &s3c24xx_command, diff --git a/src/flash/s3c2412_nand.c b/src/flash/s3c2412_nand.c index 2ca4cd3..acc6d99 100644 --- a/src/flash/s3c2412_nand.c +++ b/src/flash/s3c2412_nand.c @@ -64,7 +64,6 @@ static int s3c2412_init(struct nand_device *nand) struct nand_flash_controller s3c2412_nand_controller = { .name = "s3c2412", .nand_device_command = &s3c2412_nand_device_command, - .register_commands = &s3c24xx_register_commands, .init = &s3c2412_init, .reset = &s3c24xx_reset, .command = &s3c24xx_command, diff --git a/src/flash/s3c2440_nand.c b/src/flash/s3c2440_nand.c index 65e5a51..556f6f1 100644 --- a/src/flash/s3c2440_nand.c +++ b/src/flash/s3c2440_nand.c @@ -156,7 +156,6 @@ int s3c2440_write_block_data(struct nand_device *nand, uint8_t *data, int data_s struct nand_flash_controller s3c2440_nand_controller = { .name = "s3c2440", .nand_device_command = &s3c2440_nand_device_command, - .register_commands = &s3c24xx_register_commands, .init = &s3c2440_init, .reset = &s3c24xx_reset, .command = &s3c24xx_command, diff --git a/src/flash/s3c2443_nand.c b/src/flash/s3c2443_nand.c index 5afb26f..311bb69 100644 --- a/src/flash/s3c2443_nand.c +++ b/src/flash/s3c2443_nand.c @@ -65,7 +65,6 @@ static int s3c2443_init(struct nand_device *nand) struct nand_flash_controller s3c2443_nand_controller = { .name = "s3c2443", .nand_device_command = &s3c2443_nand_device_command, - .register_commands = &s3c24xx_register_commands, .init = &s3c2443_init, .reset = &s3c24xx_reset, .command = &s3c24xx_command, diff --git a/src/flash/s3c24xx_nand.c b/src/flash/s3c24xx_nand.c index 262569e..e7afb48 100644 --- a/src/flash/s3c24xx_nand.c +++ b/src/flash/s3c24xx_nand.c @@ -52,11 +52,6 @@ S3C24XX_DEVICE_COMMAND() return ERROR_OK; } -int s3c24xx_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - int s3c24xx_reset(struct nand_device *nand) { struct s3c24xx_nand_controller *s3c24xx_info = nand->controller_priv; diff --git a/src/flash/s3c24xx_nand.h b/src/flash/s3c24xx_nand.h index 4829c7c..fad33a0 100644 --- a/src/flash/s3c24xx_nand.h +++ b/src/flash/s3c24xx_nand.h @@ -59,8 +59,6 @@ S3C24XX_DEVICE_COMMAND(); return retval; \ } while (0) -int s3c24xx_register_commands(struct command_context *cmd_ctx); - int s3c24xx_reset(struct nand_device *nand); int s3c24xx_command(struct nand_device *nand, uint8_t command); commit ad090413a8dfacccc993ff15b8376e0f2bd56712 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 06:12:04 2009 -0800 remove flash_driver->register_callbacks Replace flash_driver callback with pointer to command_registration. Eliminates all related routines and allows drivers to omit commands. diff --git a/src/flash/at91sam3.c b/src/flash/at91sam3.c index 75e8495..be17a5f 100644 --- a/src/flash/at91sam3.c +++ b/src/flash/at91sam3.c @@ -2501,14 +2501,9 @@ static const struct command_registration at91sam3_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int sam3_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, at91sam3_command_handlers); -} - struct flash_driver at91sam3_flash = { .name = "at91sam3", - .register_commands = &sam3_register_commands, + .commands = at91sam3_command_handlers, .flash_bank_command = &sam3_flash_bank_command, .erase = &sam3_erase, .protect = &sam3_protect, diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index 0204660..f9b87ba 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -1198,14 +1198,9 @@ static const struct command_registration at91sam7_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int at91sam7_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, at91sam7_command_handlers); -} - struct flash_driver at91sam7_flash = { .name = "at91sam7", - .register_commands = &at91sam7_register_commands, + .commands = at91sam7_command_handlers, .flash_bank_command = &at91sam7_flash_bank_command, .erase = &at91sam7_erase, .protect = &at91sam7_protect, diff --git a/src/flash/avrf.c b/src/flash/avrf.c index 9aea47d..1c48464 100644 --- a/src/flash/avrf.c +++ b/src/flash/avrf.c @@ -468,14 +468,9 @@ static const struct command_registration avrf_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int avrf_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, avrf_command_handlers); -} - struct flash_driver avr_flash = { .name = "avr", - .register_commands = &avrf_register_commands, + .commands = avrf_command_handlers, .flash_bank_command = &avrf_flash_bank_command, .erase = &avrf_erase, .protect = &avrf_protect, diff --git a/src/flash/cfi.c b/src/flash/cfi.c index b92ecbd..6dbffb9 100644 --- a/src/flash/cfi.c +++ b/src/flash/cfi.c @@ -589,11 +589,6 @@ static int cfi_intel_info(struct flash_bank *bank, char *buf, int buf_size) return ERROR_OK; } -static int cfi_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - /* flash_bank cfi <base> <size> <chip_width> <bus_width> <target#> [options] */ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command) @@ -2623,7 +2618,6 @@ static int cfi_info(struct flash_bank *bank, char *buf, int buf_size) struct flash_driver cfi_flash = { .name = "cfi", - .register_commands = &cfi_register_commands, .flash_bank_command = &cfi_flash_bank_command, .erase = &cfi_erase, .protect = &cfi_protect, diff --git a/src/flash/ecos.c b/src/flash/ecos.c index f6f3307..7a0b26f 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -336,11 +336,6 @@ static int ecosflash_probe(struct flash_bank *bank) return ERROR_OK; } -static int ecosflash_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - #if 0 static void command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf) { @@ -437,7 +432,6 @@ static int ecosflash_handle_gpnvm_command(struct command_context *cmd_ctx, char struct flash_driver ecosflash_flash = { .name = "ecosflash", - .register_commands = &ecosflash_register_commands, .flash_bank_command = &ecosflash_flash_bank_command, .erase = &ecosflash_erase, .protect = &ecosflash_protect, diff --git a/src/flash/faux.c b/src/flash/faux.c index 558d7b0..adfc7bd 100644 --- a/src/flash/faux.c +++ b/src/flash/faux.c @@ -87,11 +87,6 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command) return ERROR_OK; } -static int faux_register_commands(struct command_context *cmd_ctx) -{ - return ERROR_OK; -} - static int faux_erase(struct flash_bank *bank, int first, int last) { struct faux_flash_bank *info = bank->driver_priv; @@ -130,7 +125,6 @@ static int faux_probe(struct flash_bank *bank) struct flash_driver faux_flash = { .name = "faux", - .register_commands = &faux_register_commands, .flash_bank_command = &faux_flash_bank_command, .erase = &faux_erase, .protect = &faux_protect, diff --git a/src/flash/flash.c b/src/flash/flash.c index de95b62..4584c5d 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -263,15 +263,20 @@ COMMAND_HANDLER(handle_flash_bank_command) if (strcmp(driver_name, flash_drivers[i]->name) != 0) continue; - struct flash_bank *p, *c; - /* register flash specific commands */ - if (flash_drivers[i]->register_commands(CMD_CTX) != ERROR_OK) + if (NULL != flash_drivers[i]->commands) { - LOG_ERROR("couldn't register '%s' commands", driver_name); - return ERROR_FAIL; + int retval = register_commands(CMD_CTX, NULL, + flash_drivers[i]->commands); + if (ERROR_OK != retval) + { + LOG_ERROR("couldn't register '%s' commands", + driver_name); + return ERROR_FAIL; + } } + struct flash_bank *p, *c; c = malloc(sizeof(struct flash_bank)); c->name = strdup(bank_name); c->target = target; diff --git a/src/flash/flash.h b/src/flash/flash.h index ac1600e..92727bf 100644 --- a/src/flash/flash.h +++ b/src/flash/flash.h @@ -91,13 +91,11 @@ struct flash_driver char *name; /** - * Registers driver-specific commands. When called (during the - * "flash bank" command), the driver may register addition + * An array of driver-specific commands to register. When called + * during the "flash bank" command, the driver can register addition * commands to support new flash chip functions. - * - * @returns ERROR_OK if successful; otherwise, an error code. */ - int (*register_commands)(struct command_context *cmd_ctx); + const struct command_registration *commands; /** * Finish the "flash bank" command for @a bank. The diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 896b794..418b5b0 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -795,14 +795,9 @@ static const struct command_registration lpc2000_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int lpc2000_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, lpc2000_command_handlers); -} - struct flash_driver lpc2000_flash = { .name = "lpc2000", - .register_commands = &lpc2000_register_commands, + .commands = lpc2000_command_handlers, .flash_bank_command = &lpc2000_flash_bank_command, .erase = &lpc2000_erase, .protect = &lpc2000_protect, diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 0d961e4..81e2def 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -1003,15 +1003,6 @@ static const struct command_registration lpc2900_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -/** - * Register private command handlers. - */ -static int lpc2900_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, lpc2900_command_handlers); -} - - /// Evaluate flash bank command. FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command) { @@ -1830,7 +1821,7 @@ static int lpc2900_info(struct flash_bank *bank, char *buf, int buf_size) struct flash_driver lpc2900_flash = { .name = "lpc2900", - .register_commands = lpc2900_register_commands, + .commands = lpc2900_command_handlers, .flash_bank_command = lpc2900_flash_bank_command, .erase = lpc2900_erase, .protect = lpc2900_protect, diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index 1950e05..9bb6c97 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -907,14 +907,9 @@ static const struct command_registration pic32mx_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int pic32mx_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, pic32mx_command_handlers); -} - struct flash_driver pic32mx_flash = { .name = "pic32mx", - .register_commands = &pic32mx_register_commands, + .commands = pic32mx_command_handlers, .flash_bank_command = &pic32mx_flash_bank_command, .erase = &pic32mx_erase, .protect = &pic32mx_protect, diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 1cff486..771f0a7 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -1180,15 +1180,9 @@ static const struct command_registration stellaris_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int stellaris_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, stellaris_command_handlers); -} - - struct flash_driver stellaris_flash = { .name = "stellaris", - .register_commands = &stellaris_register_commands, + .commands = stellaris_command_handlers, .flash_bank_command = &stellaris_flash_bank_command, .erase = &stellaris_erase, .protect = &stellaris_protect, diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index 808e32c..2f51aa5 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -1225,13 +1225,9 @@ static const struct command_registration stm32x_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int stm32x_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, stm32x_command_handlers); -} struct flash_driver stm32x_flash = { .name = "stm32x", - .register_commands = &stm32x_register_commands, + .commands = stm32x_command_handlers, .flash_bank_command = &stm32x_flash_bank_command, .erase = &stm32x_erase, .protect = &stm32x_protect, diff --git a/src/flash/str7x.c b/src/flash/str7x.c index e72946f..7edffac 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -691,14 +691,9 @@ static const struct command_registration str7x_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int str7x_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, str7x_command_handlers); -} - struct flash_driver str7x_flash = { .name = "str7x", - .register_commands = &str7x_register_commands, + .commands = str7x_command_handlers, .flash_bank_command = &str7x_flash_bank_command, .erase = &str7x_erase, .protect = &str7x_protect, diff --git a/src/flash/str9x.c b/src/flash/str9x.c index f6ad51a..98f15e7 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -696,14 +696,9 @@ static const struct command_registration str9x_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int str9x_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, str9x_command_handlers); -} - struct flash_driver str9x_flash = { .name = "str9x", - .register_commands = &str9x_register_commands, + .commands = str9x_command_handlers, .flash_bank_command = &str9x_flash_bank_command, .erase = &str9x_erase, .protect = &str9x_protect, diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index 7f6a29a..96e1259 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -1242,15 +1242,9 @@ static const struct command_registration str9xpec_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int str9xpec_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, str9xpec_command_handlers); -} - - struct flash_driver str9xpec_flash = { .name = "str9xpec", - .register_commands = &str9xpec_register_commands, + .commands = str9xpec_command_handlers, .flash_bank_command = &str9xpec_flash_bank_command, .erase = &str9xpec_erase, .protect = &str9xpec_protect, diff --git a/src/flash/tms470.c b/src/flash/tms470.c index 3f32b51..682013e 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -848,11 +848,6 @@ static const struct command_registration tms470_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -static int tms470_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, tms470_command_handlers); -} - /* ---------------------------------------------------------------------- */ static int tms470_erase(struct flash_bank *bank, int first, int last) @@ -1263,7 +1258,7 @@ FLASH_BANK_COMMAND_HANDLER(tms470_flash_bank_command) struct flash_driver tms470_flash = { .name = "tms470", - .register_commands = &tms470_register_commands, + .commands = tms470_command_handlers, .flash_bank_command = &tms470_flash_bank_command, .erase = &tms470_erase, .protect = &tms470_protect, commit 6b9bb584a5edec4889b12ed3f99a1e2eeab1ada2 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 tms470: use register_commands() diff --git a/src/flash/tms470.c b/src/flash/tms470.c index bf58f1d..3f32b51 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -817,15 +817,40 @@ static int tms470_erase_sector(struct flash_bank *bank, int sector) Implementation of Flash Driver Interfaces ---------------------------------------------------------------------- */ +static const struct command_registration tms470_any_command_handlers[] = { + { + .name = "flash_keyset", + .handler = &tms470_handle_flash_keyset_command, + .mode = COMMAND_ANY, + .help = "tms470 flash_keyset <key0> <key1> <key2> <key3>", + }, + { + .name = "osc_megahertz", + .handler = &tms470_handle_osc_megahertz_command, + .mode = COMMAND_ANY, + .help = "tms470 osc_megahertz <MHz>", + }, + { + .name = "plldis", + .handler = &tms470_handle_plldis_command, + .mode = COMMAND_ANY, + .help = "tms470 plldis <0/1>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration tms470_command_handlers[] = { + { + .name = "tms470", + .mode = COMMAND_ANY, + .help = "TI tms470 flash command group", + .chain = tms470_any_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int tms470_register_commands(struct command_context *cmd_ctx) { - struct command *tms470_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "tms470", NULL, COMMAND_ANY, "applies to TI tms470 family"); - - COMMAND_REGISTER(cmd_ctx, tms470_cmd, "flash_keyset", tms470_handle_flash_keyset_command, COMMAND_ANY, "tms470 flash_keyset <key0> <key1> <key2> <key3>"); - COMMAND_REGISTER(cmd_ctx, tms470_cmd, "osc_megahertz", tms470_handle_osc_megahertz_command, COMMAND_ANY, "tms470 osc_megahertz <MHz>"); - COMMAND_REGISTER(cmd_ctx, tms470_cmd, "plldis", tms470_handle_plldis_command, COMMAND_ANY, "tms470 plldis <0/1>"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, tms470_command_handlers); } /* ---------------------------------------------------------------------- */ commit b4e95c37205bae2c22d9c223a4e92bcea38bf7dd Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 str9xpec: use register_commands() diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index 7519413..7f6a29a 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -1163,48 +1163,91 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command) return ERROR_OK; } +static const struct command_registration str9xpec_config_command_handlers[] = { + { + .name = "enable_turbo", + .handler = str9xpec_handle_flash_enable_turbo_command, + .mode = COMMAND_EXEC, + .help = "enable str9xpec turbo mode", + }, + { + .name = "disable_turbo", + .handler = str9xpec_handle_flash_disable_turbo_command, + .mode = COMMAND_EXEC, + .help = "disable str9xpec turbo mode", + }, + { + .name = "options_cmap", + .handler = str9xpec_handle_flash_options_cmap_command, + .mode = COMMAND_EXEC, + .help = "configure str9xpec boot sector", + }, + { + .name = "options_lvdthd", + .handler = str9xpec_handle_flash_options_lvdthd_command, + .mode = COMMAND_EXEC, + .help = "configure str9xpec lvd threshold", + }, + { + .name = "options_lvdsel", + .handler = str9xpec_handle_flash_options_lvdsel_command, + .mode = COMMAND_EXEC, + .help = "configure str9xpec lvd selection", + }, + { + .name = "options_lvdwarn", + .handler = str9xpec_handle_flash_options_lvdwarn_command, + .mode = COMMAND_EXEC, + .help = "configure str9xpec lvd warning", + }, + { + .name = "options_read", + .handler = str9xpec_handle_flash_options_read_command, + .mode = COMMAND_EXEC, + .help = "read str9xpec options", + }, + { + .name = "options_write", + .handler = str9xpec_handle_flash_options_write_command, + .mode = COMMAND_EXEC, + .help = "write str9xpec options", + }, + { + .name = "lock", + .handler = str9xpec_handle_flash_lock_command, + .mode = COMMAND_EXEC, + .help = "lock str9xpec device", + }, + { + .name = "unlock", + .handler = str9xpec_handle_flash_unlock_command, + .mode = COMMAND_EXEC, + .help = "unlock str9xpec device", + }, + { + .name = "part_id", + .handler = str9xpec_handle_part_id_command, + .mode = COMMAND_EXEC, + .help = "print part id of str9xpec flash bank <num>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration str9xpec_command_handlers[] = { + { + .name = "str9xpec", + .mode = COMMAND_ANY, + .help = "str9xpec flash command group", + .chain = str9xpec_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int str9xpec_register_commands(struct command_context *cmd_ctx) { - struct command *str9xpec_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "str9xpec", - NULL, COMMAND_ANY, "str9xpec flash specific commands"); - - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "enable_turbo", - str9xpec_handle_flash_enable_turbo_command, - COMMAND_EXEC, "enable str9xpec turbo mode"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "disable_turbo", - str9xpec_handle_flash_disable_turbo_command, - COMMAND_EXEC, "disable str9xpec turbo mode"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "options_cmap", - str9xpec_handle_flash_options_cmap_command, - COMMAND_EXEC, "configure str9xpec boot sector"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "options_lvdthd", - str9xpec_handle_flash_options_lvdthd_command, - COMMAND_EXEC, "configure str9xpec lvd threshold"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "options_lvdsel", - str9xpec_handle_flash_options_lvdsel_command, - COMMAND_EXEC, "configure str9xpec lvd selection"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "options_lvdwarn", - str9xpec_handle_flash_options_lvdwarn_command, - COMMAND_EXEC, "configure str9xpec lvd warning"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "options_read", - str9xpec_handle_flash_options_read_command, - COMMAND_EXEC, "read str9xpec options"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "options_write", - str9xpec_handle_flash_options_write_command, - COMMAND_EXEC, "write str9xpec options"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "lock", - str9xpec_handle_flash_lock_command, - COMMAND_EXEC, "lock str9xpec device"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "unlock", - str9xpec_handle_flash_unlock_command, - COMMAND_EXEC, "unlock str9xpec device"); - COMMAND_REGISTER(cmd_ctx, str9xpec_cmd, "part_id", - str9xpec_handle_part_id_command, - COMMAND_EXEC, "print part id of str9xpec flash bank <num>"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, str9xpec_command_handlers); } + struct flash_driver str9xpec_flash = { .name = "str9xpec", .register_commands = &str9xpec_register_commands, commit 5e977b46c3a4688d9bf5091306ce3003f1bd6713 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 str9x: use register_commands() diff --git a/src/flash/str9x.c b/src/flash/str9x.c index 6d556d9..f6ad51a 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -676,16 +676,29 @@ COMMAND_HANDLER(str9x_handle_flash_config_command) return ERROR_OK; } +static const struct command_registration str9x_config_command_handlers[] = { + { + .name = "disable_jtag", + .handler = &str9x_handle_flash_config_command, + .mode = COMMAND_EXEC, + .help = "configure str9x flash controller", + .usage = "<bank_id> <BBSR> <NBBSR> <BBADR> <NBBADR>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration str9x_command_handlers[] = { + { + .name = "str9x", + .mode = COMMAND_ANY, + .help = "str9x flash command group", + .chain = str9x_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int str9x_register_commands(struct command_context *cmd_ctx) { - struct command *str9x_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "str9x", - NULL, COMMAND_ANY, "str9x flash commands"); - - COMMAND_REGISTER(cmd_ctx, str9x_cmd, "flash_config", - str9x_handle_flash_config_command, COMMAND_EXEC, - "configure str9 flash controller"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, str9x_command_handlers); } struct flash_driver str9x_flash = { commit dfa856ca186bd703b3c75f374b4f84dff372345c Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 str7x: use register_commands() diff --git a/src/flash/str7x.c b/src/flash/str7x.c index b53ddf9..e72946f 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -672,16 +672,28 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command) return ERROR_OK; } +static const struct command_registration str7x_exec_command_handlers[] = { + { + .name = "disable_jtag", + .handler = &str7x_handle_disable_jtag_command, + .mode = COMMAND_EXEC, + .help = "disable jtag access", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration str7x_command_handlers[] = { + { + .name = "str7x", + .mode = COMMAND_ANY, + .help = "str7x flash command group", + .chain = str7x_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int str7x_register_commands(struct command_context *cmd_ctx) { - struct command *str7x_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "str7x", - NULL, COMMAND_ANY, "str7x flash specific commands"); - - COMMAND_REGISTER(cmd_ctx, str7x_cmd, "disable_jtag", - str7x_handle_disable_jtag_command, COMMAND_EXEC, - "disable jtag access"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, str7x_command_handlers); } struct flash_driver str7x_flash = { commit f9606a6cb72d8bce8964b66e5aa5eec5d98a7b1d Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 stm32x: use register_commands() diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index c628f18..808e32c 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -1182,30 +1182,53 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command) return ERROR_OK; } +static const struct command_registration stm32x_exec_command_handlers[] = { + { + .name = "lock", + .handler = &stm32x_handle_lock_command, + .mode = COMMAND_EXEC, + .help = "lock device", + }, + { + .name = "unlock", + .handler = &stm32x_handle_unlock_command, + .mode = COMMAND_EXEC, + .help = "unlock protected device", + }, + { + .name = "mass_erase", + .handler = &stm32x_handle_mass_erase_command, + .mode = COMMAND_EXEC, + .help = "mass erase device", + }, + { + .name = "options_read", + .handler = &stm32x_handle_options_read_command, + .mode = COMMAND_EXEC, + .help = "read device option bytes", + }, + { + .name = "options_write", + .handler = &stm32x_handle_options_write_command, + .mode = COMMAND_EXEC, + .help = "write device option bytes", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration stm32x_command_handlers[] = { + { + .name = "stm32x", + .mode = COMMAND_ANY, + .help = "stm32x flash command group", + .chain = stm32x_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int stm32x_register_commands(struct command_context *cmd_ctx) { - struct command *stm32x_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "stm32x", - NULL, COMMAND_ANY, "stm32x flash specific commands"); - - COMMAND_REGISTER(cmd_ctx, stm32x_cmd, "lock", - stm32x_handle_lock_command, COMMAND_EXEC, - "lock device"); - COMMAND_REGISTER(cmd_ctx, stm32x_cmd, "unlock", - stm32x_handle_unlock_command, COMMAND_EXEC, - "unlock protected device"); - COMMAND_REGISTER(cmd_ctx, stm32x_cmd, "mass_erase", - stm32x_handle_mass_erase_command, COMMAND_EXEC, - "mass erase device"); - COMMAND_REGISTER(cmd_ctx, stm32x_cmd, "options_read", - stm32x_handle_options_read_command, COMMAND_EXEC, - "read device option bytes"); - COMMAND_REGISTER(cmd_ctx, stm32x_cmd, "options_write", - stm32x_handle_options_write_command, COMMAND_EXEC, - "write device option bytes"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, stm32x_command_handlers); } - struct flash_driver stm32x_flash = { .name = "stm32x", .register_commands = &stm32x_register_commands, commit 737f8f2735011256f9ca5a3988ee02167f2847a2 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 stellaris: use register_commands() diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 2d653ec..1cff486 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -1161,15 +1161,28 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command) return ERROR_OK; } +static const struct command_registration stellaris_exec_command_handlers[] = { + { + .name = "mass_erase", + .handler = &stellaris_handle_mass_erase_command, + .mode = COMMAND_EXEC, + .help = "erase entire device", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration stellaris_command_handlers[] = { + { + .name = "stellaris", + .mode = COMMAND_ANY, + .help = "Stellaris flash command group", + .chain = stellaris_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int stellaris_register_commands(struct command_context *cmd_ctx) { - struct command *stm32x_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "stellaris", - NULL, COMMAND_ANY, "stellaris flash specific commands"); - - COMMAND_REGISTER(cmd_ctx, stm32x_cmd, "mass_erase", - stellaris_handle_mass_erase_command, COMMAND_EXEC, - "mass erase device"); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, stellaris_command_handlers); } commit 0ff0dbba497374dddac9641b466e97d67bb6678d Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 pic32mx: use register_commands() diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index c6d4615..1950e05 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -882,26 +882,34 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) return ERROR_OK; } +static const struct command_registration pic32mx_exec_command_handlers[] = { + { + .name = "chip_erase", + .handler = &pic32mx_handle_chip_erase_command, + .mode = COMMAND_EXEC, + .help = "erase device", + }, + { + .name = "pgm_word", + .handler = &pic32mx_handle_pgm_word_command, + .mode = COMMAND_EXEC, + .help = "program a word", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration pic32mx_command_handlers[] = { + { + .name = "pic32mx", + .mode = COMMAND_ANY, + .help = "pic32mx flash command group", + .chain = pic32mx_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; static int pic32mx_register_commands(struct command_context *cmd_ctx) { - struct command *pic32mx_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "pic32mx", - NULL, COMMAND_ANY, "pic32mx flash specific commands"); -#if 0 - COMMAND_REGISTER(cmd_ctx, pic32mx_cmd, "lock", - pic32mx_handle_lock_command, COMMAND_EXEC, - "lock device"); - COMMAND_REGISTER(cmd_ctx, pic32mx_cmd, "unlock", - pic32mx_handle_unlock_command, COMMAND_EXEC, - "unlock protected device"); -#endif - COMMAND_REGISTER(cmd_ctx, pic32mx_cmd, "chip_erase", - pic32mx_handle_chip_erase_command, COMMAND_EXEC, - "erase device"); - COMMAND_REGISTER(cmd_ctx, pic32mx_cmd, "pgm_word", - pic32mx_handle_pgm_word_command, COMMAND_EXEC, - "program a word"); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, pic32mx_command_handlers); } struct flash_driver pic32mx_flash = { commit ccae9ae0200a66472409334d18108b309a9fae70 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 nand: use register_commands() Eliminates 'nand_cmd' global variable. diff --git a/src/flash/nand.c b/src/flash/nand.c index 2438ddd..bc0e350 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -63,7 +63,6 @@ static struct nand_flash_controller *nand_flash_controllers[] = /* configured NAND devices and NAND Flash command handler */ static struct nand_device *nand_devices = NULL; -static struct command *nand_cmd; /* Chip ID list * @@ -279,19 +278,34 @@ COMMAND_HANDLER(handle_nand_device_command) return CALL_COMMAND_HANDLER(handle_nand_list_drivers); } +static const struct command_registration nand_config_command_handlers[] = { + { + .name = "device", + .handler = &handle_nand_device_command, + .mode = COMMAND_CONFIG, + .help = "defines a new NAND bank", + }, + { + .name = "drivers", + .handler = &handle_nand_list_drivers, + .mode = COMMAND_ANY, + .help = "lists available NAND drivers", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration nand_command_handlers[] = { + { + .name = "nand", + .mode = COMMAND_ANY, + .help = "NAND flash command group", + .chain = nand_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + int nand_register_commands(struct command_context *cmd_ctx) { - nand_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "nand", - NULL, COMMAND_ANY, "NAND specific commands"); - - COMMAND_REGISTER(cmd_ctx, nand_cmd, "device", - &handle_nand_device_command, COMMAND_CONFIG, - "defines a new NAND bank"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "drivers", - &handle_nand_list_drivers, COMMAND_ANY, - "lists available NAND drivers"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, nand_command_handlers); } struct nand_device *get_nand_device_by_name(const char *name) @@ -1700,43 +1714,80 @@ COMMAND_HANDLER(handle_nand_raw_access_command) return ERROR_OK; } +static const struct command_registration nand_exec_command_handlers[] = { + { + .name = "list", + .handler = &handle_nand_list_command, + .mode = COMMAND_EXEC, + .help = "list configured NAND flash devices", + }, + { + .name = "info", + .handler = &handle_nand_info_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "print info about a NAND flash device", + }, + { + .name = "probe", + .handler = &handle_nand_probe_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "identify NAND flash device <num>", + + }, + { + .name = "check_bad_blocks", + .handler = &handle_nand_check_bad_blocks_command, + .mode = COMMAND_EXEC, + .usage = "<bank> [<offset> <length>]", + .help = "check NAND flash device <num> for bad blocks", + }, + { + .name = "erase", + .handler = &handle_nand_erase_command, + .mode = COMMAND_EXEC, + .usage = "<bank> [<offset> <length>]", + .help = "erase blocks on NAND flash device", + }, + { + .name = "dump", + .handler = &handle_nand_dump_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <filename> <offset> <length> " + "[oob_raw | oob_only]", + .help = "dump from NAND flash device", + }, + { + .name = "verify", + .handler = &handle_nand_verify_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <filename> <offset> " + "[oob_raw | oob_only | oob_softecc | oob_softecc_kw]", + .help = "verify NAND flash device", + }, + { + .name = "write", + .handler = &handle_nand_write_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <filename> <offset> " + "[oob_raw | oob_only | oob_softecc | oob_softecc_kw]", + .help = "write to NAND flash device", + }, + { + .name = "raw_access", + .handler = &handle_nand_raw_access_command, + .mode = COMMAND_EXEC, + .usage = "<num> ['enable'|'disable']", + .help = "raw access to NAND flash device", + }, + COMMAND_REGISTRATION_DONE +}; + int nand_init(struct command_context *cmd_ctx) { if (!nand_devices) return ERROR_OK; - - COMMAND_REGISTER(cmd_ctx, nand_cmd, "list", - handle_nand_list_command, COMMAND_EXEC, - "list configured NAND flash devices"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "info", - handle_nand_info_command, COMMAND_EXEC, - "print info about NAND flash device <num>"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "probe", - handle_nand_probe_command, COMMAND_EXEC, - "identify NAND flash device <num>"); - - COMMAND_REGISTER(cmd_ctx, nand_cmd, "check_bad_blocks", - handle_nand_check_bad_blocks_command, COMMAND_EXEC, - "check NAND flash device <num> for bad blocks [<offset> <length>]"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "erase", - handle_nand_erase_command, COMMAND_EXEC, - "erase blocks on NAND flash device <num> [<offset> <length>]"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "dump", - handle_nand_dump_command, COMMAND_EXEC, - "dump from NAND flash device <num> <filename> " - "<offset> <length> [oob_raw | oob_only]"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "verify", - &handle_nand_verify_command, COMMAND_EXEC, - "verify NAND flash device <num> <filename> <offset> " - "[oob_raw | oob_only | oob_softecc | oob_softecc_kw]"); - COMMAND_REGISTER(cmd_ctx, nand_cmd, "write", - handle_nand_write_command, COMMAND_EXEC, - "write to NAND flash device <num> <filename> <offset> " - "[oob_raw | oob_only | oob_softecc | oob_softecc_kw]"); - - COMMAND_REGISTER(cmd_ctx, nand_cmd, "raw_access", - handle_nand_raw_access_command, COMMAND_EXEC, - "raw access to NAND flash device <num> ['enable'|'disable']"); - - return ERROR_OK; + struct command *parent = command_find_in_context(cmd_ctx, "nand"); + return register_commands(cmd_ctx, parent, nand_exec_command_handlers); } commit 1bf7462edb89a79835e8bd42905d69282ba4ba17 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 mflash: use register_commands() diff --git a/src/flash/mflash.c b/src/flash/mflash.c index a4a45dc..03a56e2 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -33,8 +33,6 @@ static int s3c2440_set_gpio_output_val (struct mflash_gpio_num gpio, uint8_t val static int pxa270_set_gpio_to_output (struct mflash_gpio_num gpio); static int pxa270_set_gpio_output_val (struct mflash_gpio_num gpio, uint8_t val); -static struct command *mflash_cmd; - static struct mflash_bank *mflash_bank; static struct mflash_gpio_drv pxa270_gpio = { @@ -1268,19 +1266,42 @@ COMMAND_HANDLER(mg_config_cmd) } } +static const struct command_registration mflash_exec_command_handlers[] = { + { + .name = "probe", + .handler = &mg_probe_cmd, + .mode = COMMAND_EXEC, + .help = "Detect bank configuration information", + }, + { + .name = "write", + .handler = &mg_write_cmd, + .mode = COMMAND_EXEC, + .usage = "<num> <file> <address>", + .help = "Write a file at the specified address", + }, + { + .name = "dump", + .handler = &mg_dump_cmd, + .mode = COMMAND_EXEC, + .usage = "<num> <file> <address> <size>", + .help = "Dump to a file from the specified address", + }, + { + .name = "config", + .handler = &mg_config_cmd, + .mode = COMMAND_EXEC, + .usage = "<num> <stage>", + .help = "Dump to a file from the specified address", + }, + COMMAND_REGISTRATION_DONE +}; + int mflash_init_drivers(struct command_context *cmd_ctx) { - if (mflash_bank) { - COMMAND_REGISTER(cmd_ctx, mflash_cmd, "probe", mg_probe_cmd, COMMAND_EXEC, NULL); - COMMAND_REGISTER(cmd_ctx, mflash_cmd, "write", mg_write_cmd, COMMAND_EXEC, - "mflash write <num> <file> <address>"); - COMMAND_REGISTER(cmd_ctx, mflash_cmd, "dump", mg_dump_cmd, COMMAND_EXEC, - "mflash dump <num> <file> <address> <size>"); - COMMAND_REGISTER(cmd_ctx, mflash_cmd, "config", mg_config_cmd, - COMMAND_EXEC, "mflash config <num> <stage>"); - } - - return ERROR_OK; + if (!mflash_bank) + return ERROR_OK; + return register_commands(cmd_ctx, NULL, mflash_exec_command_handlers); } COMMAND_HANDLER(mg_bank_cmd) @@ -1323,10 +1344,26 @@ COMMAND_HANDLER(mg_bank_cmd) return ERROR_OK; } +static const struct command_registration mflash_config_command_handlers[] = { + { + .name = "bank", + .handler = &mg_bank_cmd, + .mode = COMMAND_CONFIG, + .help = "configure a mflash device bank", + .usage = "<soc> <base> <RST pin> <target #>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration mflash_command_handler[] = { + { + .name = "mflash", + .mode = COMMAND_ANY, + .help = "mflash command group", + .chain = mflash_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; int mflash_register_commands(struct command_context *cmd_ctx) { - mflash_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "mflash", NULL, COMMAND_ANY, NULL); - COMMAND_REGISTER(cmd_ctx, mflash_cmd, "bank", mg_bank_cmd, COMMAND_CONFIG, - "mflash bank <soc> <base> <RST pin> <target #>"); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, mflash_command_handler); } commit 7609e1091abfacfc1b62aca06c642e42003aa444 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 lpc3180_nand_controller: use register_commands() diff --git a/src/flash/lpc3180_nand_controller.c b/src/flash/lpc3180_nand_controller.c index 801607d..2dec3e1 100644 --- a/src/flash/lpc3180_nand_controller.c +++ b/src/flash/lpc3180_nand_controller.c @@ -873,13 +873,29 @@ COMMAND_HANDLER(handle_lpc3180_select_command) return ERROR_OK; } +static const struct command_registration lpc3180_exec_command_handlers[] = { + { + .name = "select", + .handler = &handle_lpc3180_select_command, + .mode = COMMAND_EXEC, + .help = "select <'mlc'|'slc'> controller (default is mlc)", + .usage = "<device_id> (mlc|slc)", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration lpc3180_command_handler[] = { + { + .name = "lpc3180", + .mode = COMMAND_ANY, + .help = "LPC3180 NAND flash controller commands", + .chain = lpc3180_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int lpc3180_register_commands(struct command_context *cmd_ctx) { - struct command *lpc3180_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "lpc3180", NULL, COMMAND_ANY, "commands specific to the LPC3180 NAND flash controllers"); - - COMMAND_REGISTER(cmd_ctx, lpc3180_cmd, "select", handle_lpc3180_select_command, COMMAND_EXEC, "select <'mlc'|'slc'> controller (default is mlc)"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, lpc3180_command_handler); } struct nand_flash_controller lpc3180_nand_controller = { commit 1cbe3ec6f105e35e641293cd7e62e6fefac1b271 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 lpc2900: use register_commands() diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index c7f1b3a..0d961e4 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -948,46 +948,67 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) /*********************** Flash interface functions **************************/ +static const struct command_registration lpc2900_exec_command_handlers[] = { + { + .name = "signature", + .handler = &lpc2900_handle_signature_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "print device signature of flash bank", + }, + { + .name = "read_custom", + .handler = &lpc2900_handle_read_custom_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <filename>", + .help = "read customer information from index sector to file", + }, + { + .name = "password", + .handler = &lpc2900_handle_password_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <password>", + .help = "enter password to enable 'dangerous' options", + }, + { + .name = "write_custom", + .handler = &lpc2900_handle_write_custom_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <filename> [<type>]", + .help = "write customer info from file to index sector", + }, + { + .name = "secure_sector", + .handler = &lpc2900_handle_secure_sector_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <first> <last>", + .help = "activate sector security for a range of sectors", + }, + { + .name = "secure_jtag", + .handler = &lpc2900_handle_secure_jtag_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <level>", + .help = "activate JTAG security", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration lpc2900_command_handlers[] = { + { + .name = "lpc2900", + .mode = COMMAND_ANY, + .help = "LPC2900 flash command group", + .chain = lpc2900_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; /** * Register private command handlers. */ static int lpc2900_register_commands(struct command_context *cmd_ctx) { - struct command *lpc2900_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "lpc2900", - NULL, COMMAND_ANY, NULL); - - COMMAND_REGISTER(cmd_ctx, lpc2900_cmd, "signature", - &lpc2900_handle_signature_command, COMMAND_EXEC, - "<bank> | " - "print device signature of flash bank"); - - COMMAND_REGISTER(cmd_ctx, lpc2900_cmd, "read_custom", - &lpc2900_handle_read_custom_command, COMMAND_EXEC, - "<bank> <filename> | " - "read customer information from index sector to file"); - - COMMAND_REGISTER(cmd_ctx, lpc2900_cmd, "password", - &lpc2900_handle_password_command, COMMAND_EXEC, - "<bank> <password> | " - "enter password to enable 'dangerous' options"); - - COMMAND_REGISTER(cmd_ctx, lpc2900_cmd, "write_custom", - &lpc2900_handle_write_custom_command, COMMAND_EXEC, - "<bank> <filename> [<type>] | " - "write customer info from file to index sector"); - - COMMAND_REGISTER(cmd_ctx, lpc2900_cmd, "secure_sector", - &lpc2900_handle_secure_sector_command, COMMAND_EXEC, - "<bank> <first> <last> | " - "activate sector security for a range of sectors"); - - COMMAND_REGISTER(cmd_ctx, lpc2900_cmd, "secure_jtag", - &lpc2900_handle_secure_jtag_command, COMMAND_EXEC, - "<bank> <level> | " - "activate JTAG security"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, lpc2900_command_handlers); } commit a12a29c28a92f51861957a09d86177625220483b Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 lpc2000: use register_commands() diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 4a934c0..896b794 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -776,16 +776,28 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command) return ERROR_OK; } +static const struct command_registration lpc2000_exec_command_handlers[] = { + { + .name = "part_id", + .handler = &lpc2000_handle_part_id_command, + .mode = COMMAND_EXEC, + .help = "print part id of lpc2000 flash bank <num>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration lpc2000_command_handlers[] = { + { + .name = "lpc2000", + .mode = COMMAND_ANY, + .help = "lpc2000 flash command group", + .chain = lpc2000_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int lpc2000_register_commands(struct command_context *cmd_ctx) { - struct command *lpc2000_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "lpc2000", - NULL, COMMAND_ANY, NULL); - - COMMAND_REGISTER(cmd_ctx, lpc2000_cmd, "part_id", - lpc2000_handle_part_id_command, COMMAND_EXEC, - "print part id of lpc2000 flash bank <num>"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, lpc2000_command_handlers); } struct flash_driver lpc2000_flash = { commit b90bf52be340d8ad2285f2f359174fbc1e31ce24 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 flash: use register_commands() Eliminates 'flash_cmd' global variable. diff --git a/src/flash/flash.c b/src/flash/flash.c index 7bc74ab..de95b62 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -78,7 +78,6 @@ struct flash_driver *flash_drivers[] = { }; struct flash_bank *flash_banks; -static struct command *flash_cmd; /* wafer thin wrapper for invoking the flash driver */ static int flash_driver_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) @@ -1272,64 +1271,132 @@ int default_flash_blank_check(struct flash_bank *bank) return ERROR_OK; } +static const struct command_registration flash_exec_command_handlers[] = { + { + .name = "probe", + .handler = &handle_flash_probe_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "identify flash bank", + }, + { + .name = "info", + .handler = &handle_flash_info_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "print bank information", + }, + { + .name = "erase_check", + .handler = &handle_flash_erase_check_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "check erase state of sectors", + }, + { + .name = "protect_check", + .handler = &handle_flash_protect_check_command, + .mode = COMMAND_EXEC, + .usage = "<bank>", + .help = "check protection state of sectors", + }, + { + .name = "erase_sector", + .handler = &handle_flash_erase_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <first> <last>", + .help = "erase sectors", + }, + { + .name = "erase_address", + .handler = &handle_flash_erase_address_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <address> <length>", + .help = "erase address range", + + }, + { + .name = "fillw", + .handler = &handle_flash_fill_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <address> <word_pattern> <count>", + .help = "fill with pattern (no autoerase)", + }, + { + .name = "fillh", + .handler = &handle_flash_fill_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <address> <halfword_pattern> <count>", + .help = "fill with pattern", + }, + { + .name = "fillb", + .handler = &handle_flash_fill_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <address> <byte_pattern> <count>", + .help = "fill with pattern", + + }, + { + .name = "write_bank", + .handler = &handle_flash_write_bank_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <file> <offset>", + .help = "write binary data", + }, + { + .name = "write_image", + .handler = &handle_flash_write_image_command, + .mode = COMMAND_EXEC, + .usage = "<bank> [erase] [unlock] <file> [offset] [type]", + .help = "write an image to flash" + }, + { + .name = "protect", + .handler = &handle_flash_protect_command, + .mode = COMMAND_EXEC, + .usage = "<bank> <first> <last> <on | off>", + .help = "set protection of sectors", + }, + COMMAND_REGISTRATION_DONE +}; + int flash_init_drivers(struct command_context *cmd_ctx) { register_jim(cmd_ctx, "ocd_flash_banks", jim_flash_banks, "return information about the flash banks"); - if (!flash_banks) return ERROR_OK; - COMMAND_REGISTER(cmd_ctx, flash_cmd, "info", - handle_flash_info_command, COMMAND_EXEC, - "print info about flash bank <num>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "probe", - handle_flash_probe_command, COMMAND_EXEC, - "identify flash bank <num>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "erase_check", - handle_flash_erase_check_command, COMMAND_EXEC, - "check erase state of sectors in flash bank <num>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "protect_check", - handle_flash_protect_check_command, COMMAND_EXEC, - "check protection state of sectors in flash bank <num>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "erase_sector", - handle_flash_erase_command, COMMAND_EXEC, - "erase sectors at <bank> <first> <last>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "erase_address", - handle_flash_erase_address_command, COMMAND_EXEC, - "erase address range <address> <length>"); - - COMMAND_REGISTER(cmd_ctx, flash_cmd, "fillw", - handle_flash_fill_command, COMMAND_EXEC, - "fill with pattern (no autoerase) <address> <word_pattern> <count>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "fillh", - handle_flash_fill_command, COMMAND_EXEC, - "fill with pattern <address> <halfword_pattern> <count>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "fillb", - handle_flash_fill_command, COMMAND_EXEC, - "fill with pattern <address> <byte_pattern> <count>"); - - COMMAND_REGISTER(cmd_ctx, flash_cmd, "write_bank", - handle_flash_write_bank_command, COMMAND_EXEC, - "write binary data to <bank> <file> <offset>"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "write_image", - handle_flash_write_image_command, COMMAND_EXEC, - "write_image [erase] [unlock] <file> [offset] [type]"); - COMMAND_REGISTER(cmd_ctx, flash_cmd, "protect", - handle_flash_protect_command, COMMAND_EXEC, - "set protection of sectors at <bank> <first> <last> <on | off>"); - - return ERROR_OK; + struct command *parent = command_find_in_context(cmd_ctx, "flash"); + return register_commands(cmd_ctx, parent, flash_exec_command_handlers); } + +static const struct command_registration flash_config_command_handlers[] = { + { + .name = "bank", + .handler = &handle_flash_bank_command, + .mode = COMMAND_CONFIG, + .usage = "<name> <driver> <base> <size> " + "<chip_width> <bus_width> <target> " + "[driver_options ...]", + .help = "Define a new bank with the given name, " + "using the specified NOR flash driver.", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration flash_command_handlers[] = { + { + .name = "flash", + .mode = COMMAND_ANY, + .help = "NOR flash command group", + .chain = flash_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + int flash_register_commands(struct command_context *cmd_ctx) { - flash_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "flash", - NULL, COMMAND_ANY, NULL); - - COMMAND_REGISTER(cmd_ctx, flash_cmd, "bank", - handle_flash_bank_command, COMMAND_CONFIG, - "flash bank <driver> <base> <size> " - "<chip_width> <bus_width> <target> [driver_options ...]"); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, flash_command_handlers); } commit 1765b103044179baa2d5036bb61710369ae59e70 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 ecos: use register_commands() diff --git a/src/flash/ecos.c b/src/flash/ecos.c index 381f858..f6f3307 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -338,8 +338,6 @@ static int ecosflash_probe(struct flash_bank *bank) static int ecosflash_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(cmd_ctx, NULL, "ecosflash", NULL, COMMAND_ANY, NULL); - return ERROR_OK; } commit b595ab8b97ae15babe530a935bb5009cdb02fcd7 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 04:13:56 2009 -0800 cfi: use register_commands() diff --git a/src/flash/cfi.c b/src/flash/cfi.c index e743fe9..b92ecbd 100644 --- a/src/flash/cfi.c +++ b/src/flash/cfi.c @@ -591,12 +591,6 @@ static int cfi_intel_info(struct flash_bank *bank, char *buf, int buf_size) static int cfi_register_commands(struct command_context *cmd_ctx) { - /*struct c... [truncated message content] |