From 30a6e683b85291b8248a2f6189aa292fdf43162d Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Sun, 6 Dec 2009 21:30:21 -0800 Subject: add 'flash list', rewrite 'flash banks' Rename the existing 'flash banks' implementation as 'flash list', and replace the broken 'flash_banks' TCL wrapper with a new command handler. Adds documentation for the new 'flash list' command in the user guide. --- src/flash/nor/tcl.c | 34 ++++++++++++++++++++++++++++------ src/flash/startup.tcl | 14 -------------- 2 files changed, 28 insertions(+), 20 deletions(-) (limited to 'src/flash') diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index d417ca0f..5ba941b3 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -816,14 +816,30 @@ COMMAND_HANDLER(handle_flash_bank_command) flash_bank_add(c); return ERROR_OK; - } +COMMAND_HANDLER(handle_flash_banks_command) +{ + if (CMD_ARGC != 0) + return ERROR_INVALID_ARGUMENTS; -static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv) + unsigned n = 0; + for (struct flash_bank *p = flash_bank_list(); p; p = p->next, n++) + { + LOG_USER("#%u: %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32 ", " + "buswidth %u, chipwidth %u", n, + p->driver->name, p->base, p->size, + p->bus_width, p->chip_width); + } + return ERROR_OK; +} + +static int jim_flash_list(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - if (argc != 1) { - Jim_WrongNumArgs(interp, 1, argv, "no arguments to flash_banks command"); + if (argc != 1) + { + Jim_WrongNumArgs(interp, 1, argv, + "no arguments to 'flash list' command"); return JIM_ERR; } @@ -890,8 +906,14 @@ static const struct command_registration flash_config_command_handlers[] = { { .name = "banks", .mode = COMMAND_ANY, - .jim_handler = &jim_flash_banks, - .help = "return information about the flash banks", + .handler = &handle_flash_banks_command, + .help = "return readable information about the flash banks", + }, + { + .name = "list", + .mode = COMMAND_ANY, + .jim_handler = &jim_flash_list, + .help = "returns a list of details about the flash banks", }, COMMAND_REGISTRATION_DONE }; diff --git a/src/flash/startup.tcl b/src/flash/startup.tcl index 2c335d9f..6cb7d8e8 100644 --- a/src/flash/startup.tcl +++ b/src/flash/startup.tcl @@ -1,16 +1,2 @@ # Defines basic Tcl procs for OpenOCD flash module -# Show flash in human readable form -# This is an example of a human readable form of a low level fn -proc flash_banks {} { - set i 0 - set result "" - foreach {a} [ocd_flash banks] { - if {$i > 0} { - set result "$result\n" - } - set result [format "$result#%d: %s at 0x%08x, size 0x%08x, buswidth %d, chipwidth %d" $i $a(name) $a(base) $a(size) $a(bus_width) $a(chip_width)] - set i [expr $i+1] - } - return $result -} -- cgit v1.2.3