diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-17 14:04:25 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-19 13:39:41 -0800 |
commit | fd654c8a3e3dbd5ab97eb6b3834ee462dd509a66 (patch) | |
tree | ca2db5f1ab73368f14ee93b19f64e297770c8bad /src | |
parent | dd44ae18b49f6cb54a4c361e9fab70f4d0fafeec (diff) | |
download | riscv-openocd-fd654c8a3e3dbd5ab97eb6b3834ee462dd509a66.zip riscv-openocd-fd654c8a3e3dbd5ab97eb6b3834ee462dd509a66.tar.gz riscv-openocd-fd654c8a3e3dbd5ab97eb6b3834ee462dd509a66.tar.bz2 |
add support for naming flash banks
Requires users to name their flash banks, allowing them to be used
instead of bank numbers in script commands.
Diffstat (limited to 'src')
-rw-r--r-- | src/flash/flash.c | 10 | ||||
-rw-r--r-- | src/flash/flash.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c index e93aa63..ef6c6da 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -189,6 +189,8 @@ struct flash_bank *get_flash_bank_by_name(const char *name) struct flash_bank *bank; for (bank = flash_banks; NULL != bank; bank = bank->next) { + if (strcmp(bank->name, name) == 0) + return bank; if (!flash_driver_name_matches(bank->driver->name, name)) continue; if (++found < requested) @@ -239,12 +241,15 @@ COMMAND_HELPER(flash_command_get_bank, unsigned name_index, COMMAND_HANDLER(handle_flash_bank_command) { - if (CMD_ARGC < 6) + if (CMD_ARGC < 7) { - LOG_ERROR("usage: flash bank <driver> " + LOG_ERROR("usage: flash bank <name> <driver> " "<base> <size> <chip_width> <bus_width>"); return ERROR_COMMAND_SYNTAX_ERROR; } + // save bank name and advance arguments for compatibility + const char *bank_name = *CMD_ARGV++; + CMD_ARGC--; struct target *target; if ((target = get_target(CMD_ARGV[5])) == NULL) @@ -269,6 +274,7 @@ COMMAND_HANDLER(handle_flash_bank_command) } c = malloc(sizeof(struct flash_bank)); + c->name = strdup(bank_name); c->target = target; c->driver = flash_drivers[i]; c->driver_priv = NULL; diff --git a/src/flash/flash.h b/src/flash/flash.h index 1235a41..ac1600e 100644 --- a/src/flash/flash.h +++ b/src/flash/flash.h @@ -240,6 +240,8 @@ struct flash_driver */ struct flash_bank { + char *name; + struct target *target; /**< Target to which this bank belongs. */ struct flash_driver *driver; /**< Driver for this bank. */ |