From: Zach W. <zw...@us...> - 2009-12-02 22:29:52
|
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 62fbb0f545213f8a813819f319e20fee8a859319 (commit) via e03f3c57a52b36eac18a673fd3515b5ebac3f08d (commit) via ac1887c703d0d5ae83c513df61127f59e44a0469 (commit) via 37201c019ffc6b806aa61bf2eb8fc18c58083f02 (commit) via 1de0b9d351313f186433f4d71d31241c95665cbf (commit) via 747f8af672026f9778c6272ab48405d93b41acad (commit) via 682910fdc24c8ae970b3cd1e5b4ff7042e0522be (commit) from 55eeea7fceb67f29c9a43eeb7993c70214157343 (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 62fbb0f545213f8a813819f319e20fee8a859319 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 18:45:38 2009 -0800 target: factor init to 'target init' Adds 'target init' command handler, called as part of 'init'. diff --git a/src/openocd.c b/src/openocd.c index 79a30e7..12bcf44 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -111,11 +111,9 @@ COMMAND_HANDLER(handle_init_command) initialized = 1; - command_context_mode(CMD_CTX, COMMAND_EXEC); - - if (target_init(CMD_CTX) != ERROR_OK) + retval = command_run_line(CMD_CTX, "target init"); + if (ERROR_OK != retval) return ERROR_FAIL; - LOG_DEBUG("target init complete"); if ((retval = jtag_interface_init(CMD_CTX)) != ERROR_OK) { @@ -126,7 +124,6 @@ COMMAND_HANDLER(handle_init_command) /* Try to initialize & examine the JTAG chain at this point, but * continue startup regardless */ - command_context_mode(CMD_CTX, COMMAND_CONFIG); if (command_run_line(CMD_CTX, "jtag init") == ERROR_OK) { command_context_mode(CMD_CTX, COMMAND_EXEC); diff --git a/src/target/target.c b/src/target/target.c index abf8bfd..4013442 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -787,6 +787,23 @@ int target_init(struct command_context *cmd_ctx) return ERROR_OK; } +COMMAND_HANDLER(handle_target_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool target_initialized = false; + if (target_initialized) + { + LOG_INFO("'target init' has already been called"); + return ERROR_OK; + } + target_initialized = true; + + LOG_DEBUG("Initializing targets..."); + return target_init(CMD_CTX); +} + int target_register_event_callback(int (*callback)(struct target *target, enum target_event event, void *priv), void *priv) { struct target_event_callback **callbacks_p = &target_event_callbacks; @@ -4787,6 +4804,12 @@ COMMAND_HANDLER(handle_fast_load_command) static const struct command_registration target_command_handlers[] = { { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_target_init_command, + .help = "initialize targets", + }, + { .name = "targets", .handler = &handle_targets_command, .mode = COMMAND_ANY, commit e03f3c57a52b36eac18a673fd3515b5ebac3f08d Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 18:27:23 2009 -0800 target: factor target_init() into pieces Moves body of target initialization loop into a helper function, cleaning up its visual flow in the process. diff --git a/src/target/target.c b/src/target/target.c index 88931b5..abf8bfd 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -681,94 +681,109 @@ err_write_phys_memory(struct target *target, uint32_t address, static int handle_target(void *priv); -int target_init(struct command_context *cmd_ctx) +static int target_init_one(struct command_context *cmd_ctx, + struct target *target) { - struct target *target; - int retval; + target_reset_examined(target); - for (target = all_targets; target; target = target->next) { - struct target_type *type = target->type; + struct target_type *type = target->type; + if (type->examine == NULL) + type->examine = default_examine; - target_reset_examined(target); - if (target->type->examine == NULL) - { - target->type->examine = default_examine; - } + int retval = type->init_target(cmd_ctx, target); + if (ERROR_OK != retval) + { + LOG_ERROR("target '%s' init failed", target_name(target)); + return retval; + } - if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK) - { - LOG_ERROR("target '%s' init failed", target_name(target)); - return retval; - } + /** + * @todo get rid of those *memory_imp() methods, now that all + * callers are using target_*_memory() accessors ... and make + * sure the "physical" paths handle the same issues. + */ + /* a non-invasive way(in terms of patches) to add some code that + * runs before the type->write/read_memory implementation + */ + type->write_memory_imp = target->type->write_memory; + type->write_memory = target_write_memory_imp; + type->read_memory_imp = target->type->read_memory; + type->read_memory = target_read_memory_imp; - /** - * @todo get rid of those *memory_imp() methods, now that all - * callers are using target_*_memory() accessors ... and make - * sure the "physical" paths handle the same issues. - */ + type->soft_reset_halt_imp = target->type->soft_reset_halt; + type->soft_reset_halt = target_soft_reset_halt_imp; - /* a non-invasive way(in terms of patches) to add some code that - * runs before the type->write/read_memory implementation - */ - target->type->write_memory_imp = target->type->write_memory; - target->type->write_memory = target_write_memory_imp; - target->type->read_memory_imp = target->type->read_memory; - target->type->read_memory = target_read_memory_imp; - target->type->soft_reset_halt_imp = target->type->soft_reset_halt; - target->type->soft_reset_halt = target_soft_reset_halt_imp; - target->type->run_algorithm_imp = target->type->run_algorithm; - target->type->run_algorithm = target_run_algorithm_imp; - - /* Sanity-check MMU support ... stub in what we must, to help - * implement it in stages, but warn if we need to do so. - */ - if (type->mmu) { - if (type->write_phys_memory == NULL) { - LOG_ERROR("type '%s' is missing %s", - type->name, - "write_phys_memory"); - type->write_phys_memory = err_write_phys_memory; - } - if (type->read_phys_memory == NULL) { - LOG_ERROR("type '%s' is missing %s", - type->name, - "read_phys_memory"); - type->read_phys_memory = err_read_phys_memory; - } - if (type->virt2phys == NULL) { - LOG_ERROR("type '%s' is missing %s", - type->name, - "virt2phys"); - type->virt2phys = identity_virt2phys; - } + type->run_algorithm_imp = target->type->run_algorithm; + type->run_algorithm = target_run_algorithm_imp; + /* Sanity-check MMU support ... stub in what we must, to help + * implement it in stages, but warn if we need to do so. + */ + if (type->mmu) + { + if (type->write_phys_memory == NULL) + { + LOG_ERROR("type '%s' is missing write_phys_memory", + type->name); + type->write_phys_memory = err_write_phys_memory; + } + if (type->read_phys_memory == NULL) + { + LOG_ERROR("type '%s' is missing read_phys_memory", + type->name); + type->read_phys_memory = err_read_phys_memory; + } + if (type->virt2phys == NULL) + { + LOG_ERROR("type '%s' is missing virt2phys", type->name); + type->virt2phys = identity_virt2phys; + } + } + else + { /* Make sure no-MMU targets all behave the same: make no * distinction between physical and virtual addresses, and * ensure that virt2phys() is always an identity mapping. */ - } else { - if (type->write_phys_memory - || type->read_phys_memory - || type->virt2phys) - LOG_WARNING("type '%s' has broken MMU hooks", - type->name); - - type->mmu = no_mmu; - type->write_phys_memory = type->write_memory; - type->read_phys_memory = type->read_memory; - type->virt2phys = identity_virt2phys; + if (type->write_phys_memory || type->read_phys_memory + || type->virt2phys) + { + LOG_WARNING("type '%s' has bad MMU hooks", type->name); } + + type->mmu = no_mmu; + type->write_phys_memory = type->write_memory; + type->read_phys_memory = type->read_memory; + type->virt2phys = identity_virt2phys; } + return ERROR_OK; +} - if (all_targets) +int target_init(struct command_context *cmd_ctx) +{ + struct target *target; + int retval; + + for (target = all_targets; target; target = target->next) { - if ((retval = target_register_user_commands(cmd_ctx)) != ERROR_OK) - return retval; - if ((retval = target_register_timer_callback(&handle_target, 100, 1, cmd_ctx->interp)) != ERROR_OK) + retval = target_init_one(cmd_ctx, target); + if (ERROR_OK != retval) return retval; } + if (!all_targets) + return ERROR_OK; + + retval = target_register_user_commands(cmd_ctx); + if (ERROR_OK != retval) + return retval; + + retval = target_register_timer_callback(&handle_target, + 100, 1, cmd_ctx->interp); + if (ERROR_OK != retval) + return retval; + return ERROR_OK; } commit ac1887c703d0d5ae83c513df61127f59e44a0469 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 18:30:38 2009 -0800 jtag: factor init into 'jtag init' Adds 'jtag init' command handler, which can be called as part of a fine-grained 'init' process. diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 68bb21e..cc89080 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -808,8 +808,31 @@ static int jim_jtag_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } +COMMAND_HANDLER(handle_jtag_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool jtag_initialized = false; + if (jtag_initialized) + { + LOG_INFO("'jtag init' has already been called"); + return ERROR_OK; + } + jtag_initialized = true; + + LOG_DEBUG("Initializing jtag devices..."); + return jtag_init(CMD_CTX); +} + static const struct command_registration jtag_subcommand_handlers[] = { { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_jtag_init_command, + .help = "initialize jtag scan chain", + }, + { .name = "interface", .mode = COMMAND_ANY, .jim_handler = &jim_jtag_interface, diff --git a/src/openocd.c b/src/openocd.c index aaa4531..79a30e7 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -126,16 +126,18 @@ COMMAND_HANDLER(handle_init_command) /* Try to initialize & examine the JTAG chain at this point, but * continue startup regardless */ - if (jtag_init(CMD_CTX) == ERROR_OK) + command_context_mode(CMD_CTX, COMMAND_CONFIG); + if (command_run_line(CMD_CTX, "jtag init") == ERROR_OK) { - LOG_DEBUG("jtag init complete"); - if (target_examine() == ERROR_OK) - { - LOG_DEBUG("jtag examine complete"); - } + command_context_mode(CMD_CTX, COMMAND_EXEC); + LOG_DEBUG("Examining targets..."); + if (target_examine() != ERROR_OK) + LOG_DEBUG("target examination failed"); + command_context_mode(CMD_CTX, COMMAND_CONFIG); } + else + LOG_WARNING("jtag initialization failed; try 'jtag init' again."); - command_context_mode(CMD_CTX, COMMAND_CONFIG); if (command_run_line(CMD_CTX, "flash init") != ERROR_OK) return ERROR_FAIL; commit 37201c019ffc6b806aa61bf2eb8fc18c58083f02 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 17:38:02 2009 -0800 flash: factor init to 'flash init' Split flash initialiation into 'flash init', called from 'init'. diff --git a/src/flash/flash.c b/src/flash/flash.c index 7023ef9..1e5ac9a 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -1375,6 +1375,23 @@ int flash_init_drivers(struct command_context *cmd_ctx) return register_commands(cmd_ctx, parent, flash_exec_command_handlers); } +COMMAND_HANDLER(handle_flash_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool flash_initialized = false; + if (flash_initialized) + { + LOG_INFO("'flash init' has already been called"); + return ERROR_OK; + } + flash_initialized = true; + + LOG_DEBUG("Initializing flash devices..."); + return flash_init_drivers(CMD_CTX); +} + static const struct command_registration flash_config_command_handlers[] = { { .name = "bank", @@ -1387,6 +1404,12 @@ static const struct command_registration flash_config_command_handlers[] = { "using the specified NOR flash driver.", }, { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_flash_init_command, + .help = "initialize flash devices", + }, + { .name = "banks", .mode = COMMAND_ANY, .jim_handler = &jim_flash_banks, diff --git a/src/openocd.c b/src/openocd.c index ff35f87..aaa4531 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -135,11 +135,10 @@ COMMAND_HANDLER(handle_init_command) } } - if (flash_init_drivers(CMD_CTX) != ERROR_OK) + command_context_mode(CMD_CTX, COMMAND_CONFIG); + if (command_run_line(CMD_CTX, "flash init") != ERROR_OK) return ERROR_FAIL; - LOG_DEBUG("flash init complete"); - command_context_mode(CMD_CTX, COMMAND_CONFIG); if (command_run_line(CMD_CTX, "mflash init") != ERROR_OK) return ERROR_FAIL; commit 1de0b9d351313f186433f4d71d31241c95665cbf Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 17:32:56 2009 -0800 mflash: factor init to 'mflash init' Splits mflash initialiation to 'mflash init', called from 'init'. diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 03a56e2..8f42aa6 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -1304,6 +1304,23 @@ int mflash_init_drivers(struct command_context *cmd_ctx) return register_commands(cmd_ctx, NULL, mflash_exec_command_handlers); } +COMMAND_HANDLER(handle_mflash_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool mflash_initialized = false; + if (mflash_initialized) + { + LOG_INFO("'mflash init' has already been called"); + return ERROR_OK; + } + mflash_initialized = true; + + LOG_DEBUG("Initializing mflash devices..."); + return mflash_init_drivers(CMD_CTX); +} + COMMAND_HANDLER(mg_bank_cmd) { struct target *target; @@ -1352,6 +1369,12 @@ static const struct command_registration mflash_config_command_handlers[] = { .help = "configure a mflash device bank", .usage = "<soc> <base> <RST pin> <target #>", }, + { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_mflash_init_command, + .help = "initialize mflash devices", + }, COMMAND_REGISTRATION_DONE }; static const struct command_registration mflash_command_handler[] = { diff --git a/src/openocd.c b/src/openocd.c index 1026379..ff35f87 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -139,11 +139,10 @@ COMMAND_HANDLER(handle_init_command) return ERROR_FAIL; LOG_DEBUG("flash init complete"); - if (mflash_init_drivers(CMD_CTX) != ERROR_OK) + command_context_mode(CMD_CTX, COMMAND_CONFIG); + if (command_run_line(CMD_CTX, "mflash init") != ERROR_OK) return ERROR_FAIL; - LOG_DEBUG("mflash init complete"); - command_context_mode(CMD_CTX, COMMAND_CONFIG); if (command_run_line(CMD_CTX, "nand init") != ERROR_OK) return ERROR_FAIL; commit 747f8af672026f9778c6272ab48405d93b41acad Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 17:27:21 2009 -0800 nand: factor init to 'nand init' Split NAND initialization into 'nand init', which gets called from the main 'init' command. diff --git a/src/flash/nand.c b/src/flash/nand.c index 94cec8d..1c8c0c8 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -281,6 +281,9 @@ COMMAND_HANDLER(handle_nand_device_command) return CALL_COMMAND_HANDLER(handle_nand_list_drivers); } + +COMMAND_HANDLER(handle_nand_init_command); + static const struct command_registration nand_config_command_handlers[] = { { .name = "device", @@ -294,6 +297,12 @@ static const struct command_registration nand_config_command_handlers[] = { .mode = COMMAND_ANY, .help = "lists available NAND drivers", }, + { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_nand_init_command, + .help = "initialize NAND devices", + }, COMMAND_REGISTRATION_DONE }; static const struct command_registration nand_command_handlers[] = { @@ -1794,3 +1803,20 @@ int nand_init(struct command_context *cmd_ctx) struct command *parent = command_find_in_context(cmd_ctx, "nand"); return register_commands(cmd_ctx, parent, nand_exec_command_handlers); } + +COMMAND_HANDLER(handle_nand_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool nand_initialized = false; + if (nand_initialized) + { + LOG_INFO("'nand init' has already been called"); + return ERROR_OK; + } + nand_initialized = true; + + LOG_DEBUG("Initializing NAND devices..."); + return nand_init(CMD_CTX); +} diff --git a/src/openocd.c b/src/openocd.c index 777e630..1026379 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -143,11 +143,10 @@ COMMAND_HANDLER(handle_init_command) return ERROR_FAIL; LOG_DEBUG("mflash init complete"); - if (nand_init(CMD_CTX) != ERROR_OK) + command_context_mode(CMD_CTX, COMMAND_CONFIG); + if (command_run_line(CMD_CTX, "nand init") != ERROR_OK) return ERROR_FAIL; - LOG_DEBUG("NAND init complete"); - command_context_mode(CMD_CTX, COMMAND_CONFIG); if (command_run_line(CMD_CTX, "pld init") != ERROR_OK) return ERROR_FAIL; command_context_mode(CMD_CTX, COMMAND_EXEC); commit 682910fdc24c8ae970b3cd1e5b4ff7042e0522be Author: Zachary T Welch <zw...@su...> Date: Mon Nov 30 17:20:18 2009 -0800 pld: factor init to 'pld init' Split PLD initialization into 'pld init', which gets called from 'init'. diff --git a/src/openocd.c b/src/openocd.c index 44e0292..777e630 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -147,9 +147,10 @@ COMMAND_HANDLER(handle_init_command) return ERROR_FAIL; LOG_DEBUG("NAND init complete"); - if (pld_init(CMD_CTX) != ERROR_OK) + command_context_mode(CMD_CTX, COMMAND_CONFIG); + if (command_run_line(CMD_CTX, "pld init") != ERROR_OK) return ERROR_FAIL; - LOG_DEBUG("pld init complete"); + command_context_mode(CMD_CTX, COMMAND_EXEC); /* initialize telnet subsystem */ gdb_target_add_all(all_targets); diff --git a/src/pld/pld.c b/src/pld/pld.c index 24afd07..df7ac0d 100644 --- a/src/pld/pld.c +++ b/src/pld/pld.c @@ -213,6 +213,23 @@ int pld_init(struct command_context *cmd_ctx) return register_commands(cmd_ctx, parent, pld_exec_command_handlers); } +COMMAND_HANDLER(handle_pld_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool pld_initialized = false; + if (pld_initialized) + { + LOG_INFO("'pld init' has already been called"); + return ERROR_OK; + } + pld_initialized = true; + + LOG_DEBUG("Initializing PLDs..."); + return pld_init(CMD_CTX); +} + static const struct command_registration pld_config_command_handlers[] = { { .name = "device", @@ -221,6 +238,12 @@ static const struct command_registration pld_config_command_handlers[] = { .help = "configure a PLD device", .usage = "<driver> ...", }, + { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_pld_init_command, + .help = "initialize PLD devices", + }, COMMAND_REGISTRATION_DONE }; static const struct command_registration pld_command_handler[] = { ----------------------------------------------------------------------- Summary of changes: src/flash/flash.c | 23 +++++++ src/flash/mflash.c | 23 +++++++ src/flash/nand.c | 26 ++++++++ src/jtag/tcl.c | 23 +++++++ src/openocd.c | 33 +++++----- src/pld/pld.c | 23 +++++++ src/target/target.c | 176 +++++++++++++++++++++++++++++++-------------------- 7 files changed, 240 insertions(+), 87 deletions(-) hooks/post-receive -- Main OpenOCD repository |