From cfa19fc564ec504491019f67e30a398889875cd0 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 30 Jun 2011 03:04:26 +0000 Subject: [PATCH] pass down the tokenized array to completion handlers in case they want to parse info in earlier tokens git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1930 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 11 +++++++++++ urjtag/src/bfin/bfin.c | 33 ++++++++++++++++++++++++++++++-- urjtag/src/cmd/cmd.h | 3 ++- urjtag/src/cmd/cmd_bfin.c | 3 ++- urjtag/src/cmd/cmd_cable.c | 3 ++- urjtag/src/cmd/cmd_cmd.c | 3 ++- urjtag/src/cmd/cmd_debug.c | 3 ++- urjtag/src/cmd/cmd_endian.c | 3 ++- urjtag/src/cmd/cmd_flashmem.c | 3 ++- urjtag/src/cmd/cmd_get.c | 3 ++- urjtag/src/cmd/cmd_help.c | 3 ++- urjtag/src/cmd/cmd_include.c | 3 ++- urjtag/src/cmd/cmd_initbus.c | 3 ++- urjtag/src/cmd/cmd_instruction.c | 3 ++- urjtag/src/cmd/cmd_print.c | 3 ++- urjtag/src/cmd/cmd_readmem.c | 3 ++- urjtag/src/cmd/cmd_salias.c | 3 ++- urjtag/src/cmd/cmd_set.c | 3 ++- urjtag/src/cmd/cmd_shift.c | 3 ++- urjtag/src/cmd/cmd_test.c | 3 ++- 20 files changed, 78 insertions(+), 20 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 5aa55d1e..ba928d83 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -14,6 +14,17 @@ all of the sub-commands actually supported. Pull out the const strings (things you actually type) out of the translated string. + * src/cmd/cmd.h (urj_cmd_t.complete): Add a new arg for the token list. + * src/cmd/cmd_cmd.c (urj_cmd_complete): Pass down tokenized list for + handlers to work off of if they want info about previous tokens. + * src/cmd/cmd_bfin.c, src/cmd/cmd_cable.c, src/cmd/cmd_cmd.c, + src/cmd/cmd_debug.c, src/cmd/cmd_endian.c, src/cmd/cmd_flashmem.c, + src/cmd/cmd_get.c, src/cmd/cmd_help.c, src/cmd/cmd_include.c, + src/cmd/cmd_initbus.c, src/cmd/cmd_instruction.c, src/cmd/cmd_print.c, + src/cmd/cmd_readmem.c, src/cmd/cmd_salias.c, src/cmd/cmd_set.c, + src/cmd/cmd_shift.c, src/cmd/cmd_test.c: Add new tokens arg to completion + handlers. + 2011-06-27 Jie Zhang * include/urjtag/Makefile.am (nodist_pkginclude_HEADERS): New and diff --git a/urjtag/src/bfin/bfin.c b/urjtag/src/bfin/bfin.c index 87b9bfef..194658a7 100644 --- a/urjtag/src/bfin/bfin.c +++ b/urjtag/src/bfin/bfin.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -1537,13 +1538,41 @@ chain_system_reset (urj_chain_t *chain) p0 = part_get_p0 (chain, chain->main_part); r0 = part_get_r0 (chain, chain->main_part); + /* + * Flush all system events like cache line fills. Otherwise, + * when we reset the system side, any events that the core was + * waiting on no longer exist, and the core hangs. + */ + part_emuir_set (chain, chain->main_part, INSN_SSYNC, URJ_CHAIN_EXITMODE_IDLE); + + /* Write 0x7 to SWRST to start system reset. */ part_set_p0 (chain, chain->main_part, SWRST); part_set_r0 (chain, chain->main_part, 0x7); part_emuir_set (chain, chain->main_part, gen_store16_offset (REG_P0, 0, REG_R0), URJ_CHAIN_EXITMODE_IDLE); - part_emuir_set (chain, chain->main_part, INSN_SSYNC, URJ_CHAIN_EXITMODE_IDLE); + + /* + * Delay at least 10 SCLKs instead of doing an SSYNC insn. + * Since the system is being reset, the sync signal might + * not be asserted, and so the core hangs waiting for it. + * The magic "10" number was given to us by ADI designers + * who looked at the schematic and ran some simulations. + */ + usleep (100); + + /* Write 0x0 to SWRST to stop system reset. */ part_set_r0 (chain, chain->main_part, 0); part_emuir_set (chain, chain->main_part, gen_store16_offset (REG_P0, 0, REG_R0), URJ_CHAIN_EXITMODE_IDLE); - part_emuir_set (chain, chain->main_part, INSN_SSYNC, URJ_CHAIN_EXITMODE_IDLE); + + /* Delay at least 1 SCLK; see comment above for more info. */ + usleep (100); + + /* + * Clear software reset status bit to workaround some bootrom + * bugs. Specifically, the BF526-0.0 will crash when starting + * up if this is set. Should be harmless to everyone else other + * than the bit in SWRST is always cleared ... + */ +// part_set_p0 (chain, chain->main_part, SWRST + 4); /* SYSCR */ part_set_p0 (chain, chain->main_part, p0); part_set_r0 (chain, chain->main_part, r0); diff --git a/urjtag/src/cmd/cmd.h b/urjtag/src/cmd/cmd.h index ad405e11..4eb722ab 100644 --- a/urjtag/src/cmd/cmd.h +++ b/urjtag/src/cmd/cmd.h @@ -48,7 +48,8 @@ typedef struct * syntax and library errors */ int (*run) (urj_chain_t *chain, char *params[]); void (*complete) (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point); + char * const *tokens, const char *text, size_t text_len, + size_t token_point); } urj_cmd_t; #define _URJ_CMD(cmd) extern const urj_cmd_t urj_cmd_##cmd; diff --git a/urjtag/src/cmd/cmd_bfin.c b/urjtag/src/cmd/cmd_bfin.c index 3de5cb79..c33b00ec 100644 --- a/urjtag/src/cmd/cmd_bfin.c +++ b/urjtag/src/cmd/cmd_bfin.c @@ -512,7 +512,8 @@ cmd_bfin_help (void) static void cmd_bfin_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { if (token_point != 1) return; diff --git a/urjtag/src/cmd/cmd_cable.c b/urjtag/src/cmd/cmd_cable.c index e5c69a94..939e78ae 100644 --- a/urjtag/src/cmd/cmd_cable.c +++ b/urjtag/src/cmd/cmd_cable.c @@ -118,7 +118,8 @@ cmd_cable_help (void) static void cmd_cable_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { size_t i; diff --git a/urjtag/src/cmd/cmd_cmd.c b/urjtag/src/cmd/cmd_cmd.c index 7f8a94f4..57fe06bd 100644 --- a/urjtag/src/cmd/cmd_cmd.c +++ b/urjtag/src/cmd/cmd_cmd.c @@ -157,7 +157,8 @@ urj_cmd_complete (urj_chain_t *chain, const char *line, int point) else name = ""; - cmd->complete (chain, &ret, &ret_cnt, name, strlen (name), token_point); + cmd->complete (chain, &ret, &ret_cnt, tokens, name, + strlen (name), token_point); if (ret_cnt) ret[ret_cnt] = NULL; diff --git a/urjtag/src/cmd/cmd_debug.c b/urjtag/src/cmd/cmd_debug.c index bffb655a..883165d1 100644 --- a/urjtag/src/cmd/cmd_debug.c +++ b/urjtag/src/cmd/cmd_debug.c @@ -133,7 +133,8 @@ cmd_debug_help (void) static void cmd_debug_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { if (token_point != 1) return; diff --git a/urjtag/src/cmd/cmd_endian.c b/urjtag/src/cmd/cmd_endian.c index 9e74d11d..aadd0a31 100644 --- a/urjtag/src/cmd/cmd_endian.c +++ b/urjtag/src/cmd/cmd_endian.c @@ -123,7 +123,8 @@ cmd_endian_help (void) static void cmd_endian_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { if (token_point != 1) return; diff --git a/urjtag/src/cmd/cmd_flashmem.c b/urjtag/src/cmd/cmd_flashmem.c index c0cbb06a..623e49e9 100644 --- a/urjtag/src/cmd/cmd_flashmem.c +++ b/urjtag/src/cmd/cmd_flashmem.c @@ -114,7 +114,8 @@ cmd_flashmem_help (void) static void cmd_flashmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { switch (token_point) { diff --git a/urjtag/src/cmd/cmd_get.c b/urjtag/src/cmd/cmd_get.c index 2aa7d3e9..7f624e8a 100644 --- a/urjtag/src/cmd/cmd_get.c +++ b/urjtag/src/cmd/cmd_get.c @@ -94,7 +94,8 @@ cmd_get_help (void) static void cmd_get_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { switch (token_point) { diff --git a/urjtag/src/cmd/cmd_help.c b/urjtag/src/cmd/cmd_help.c index 10818288..1aa2bbec 100644 --- a/urjtag/src/cmd/cmd_help.c +++ b/urjtag/src/cmd/cmd_help.c @@ -80,7 +80,8 @@ cmd_help_help (void) static void cmd_help_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { size_t i; diff --git a/urjtag/src/cmd/cmd_include.c b/urjtag/src/cmd/cmd_include.c index e2f30431..b17faaa6 100644 --- a/urjtag/src/cmd/cmd_include.c +++ b/urjtag/src/cmd/cmd_include.c @@ -103,7 +103,8 @@ cmd_include_help (void) static void cmd_include_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { #ifdef HAVE_LIBREADLINE int state; diff --git a/urjtag/src/cmd/cmd_initbus.c b/urjtag/src/cmd/cmd_initbus.c index 756ef0bf..d7d405ee 100644 --- a/urjtag/src/cmd/cmd_initbus.c +++ b/urjtag/src/cmd/cmd_initbus.c @@ -67,7 +67,8 @@ cmd_initbus_help (void) static void cmd_initbus_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { size_t i; diff --git a/urjtag/src/cmd/cmd_instruction.c b/urjtag/src/cmd/cmd_instruction.c index 77949c93..e02d69bd 100644 --- a/urjtag/src/cmd/cmd_instruction.c +++ b/urjtag/src/cmd/cmd_instruction.c @@ -113,7 +113,8 @@ cmd_instruction_help (void) static void cmd_instruction_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { urj_part_t *part; urj_part_instruction_t *i; diff --git a/urjtag/src/cmd/cmd_print.c b/urjtag/src/cmd/cmd_print.c index 61bef768..986777cc 100644 --- a/urjtag/src/cmd/cmd_print.c +++ b/urjtag/src/cmd/cmd_print.c @@ -281,7 +281,8 @@ cmd_print_help (void) static void cmd_print_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { if (token_point != 1) return; diff --git a/urjtag/src/cmd/cmd_readmem.c b/urjtag/src/cmd/cmd_readmem.c index f9b7f165..7b7601c2 100644 --- a/urjtag/src/cmd/cmd_readmem.c +++ b/urjtag/src/cmd/cmd_readmem.c @@ -95,7 +95,8 @@ cmd_readmem_help (void) static void cmd_readmem_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { switch (token_point) { diff --git a/urjtag/src/cmd/cmd_salias.c b/urjtag/src/cmd/cmd_salias.c index 637deed7..a8debe63 100644 --- a/urjtag/src/cmd/cmd_salias.c +++ b/urjtag/src/cmd/cmd_salias.c @@ -96,7 +96,8 @@ cmd_salias_help (void) static void cmd_salias_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { if (token_point != 2) return; diff --git a/urjtag/src/cmd/cmd_set.c b/urjtag/src/cmd/cmd_set.c index deeb29f9..e465d10f 100644 --- a/urjtag/src/cmd/cmd_set.c +++ b/urjtag/src/cmd/cmd_set.c @@ -119,7 +119,8 @@ cmd_set_help (void) static void cmd_set_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { switch (token_point) { diff --git a/urjtag/src/cmd/cmd_shift.c b/urjtag/src/cmd/cmd_shift.c index b2d29792..32e56fa1 100644 --- a/urjtag/src/cmd/cmd_shift.c +++ b/urjtag/src/cmd/cmd_shift.c @@ -79,7 +79,8 @@ cmd_shift_help (void) static void cmd_shift_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { if (token_point != 1) return; diff --git a/urjtag/src/cmd/cmd_test.c b/urjtag/src/cmd/cmd_test.c index 6a22cc51..935ced67 100644 --- a/urjtag/src/cmd/cmd_test.c +++ b/urjtag/src/cmd/cmd_test.c @@ -110,7 +110,8 @@ cmd_test_help (void) static void cmd_test_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt, - const char *text, size_t text_len, size_t token_point) + char * const *tokens, const char *text, size_t text_len, + size_t token_point) { switch (token_point) {