From b9b582ed376318eef2562d8c7d4b8b86fdd9f587 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 28 Jan 2010 22:58:29 +0000 Subject: [PATCH] replace Blackfin one-insn-a-file with exact instruction counting git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1739 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 5 ++ urjtag/src/cmd/cmd_bfin.c | 96 +++++---------------------------------- 2 files changed, 16 insertions(+), 85 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 1ff599b1..2583838a 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,8 @@ +2010-01-28 Mike Frysinger + + * src/cmd/cmd_bfin.c: Replace one-insn-a-file option with dynamic instruction + counting so multi-instructions are properly parsed. + 2010-01-28 Arnim Laeuger * src/bus/mpc837x.c, src/bus/buses_list.h, src/bus/Makefile.am, diff --git a/urjtag/src/cmd/cmd_bfin.c b/urjtag/src/cmd/cmd_bfin.c index d253c861..c0ed0ad3 100644 --- a/urjtag/src/cmd/cmd_bfin.c +++ b/urjtag/src/cmd/cmd_bfin.c @@ -34,18 +34,6 @@ #include "cmd.h" -/* For "bfin execute", Blackfin assembler assembles instruction(s) - into a temporary object file. When this variable is non-zero, there - should be only one instruction in the object file. For example, - assembler assembles one instruction a time, which is how we do now. - - Blackfin GAS rounds the section size to 4 bytes. Usually we don't - want the padding bytes to be executed as a NOP. With this variable - set, only the first instruction in the object file will be - executed. */ - -int bfin_one_insn_a_file = 1; - #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) static int @@ -63,72 +51,6 @@ cmd_bfin_run (urj_chain_t *chain, char *params[]) return URJ_STATUS_FAIL; } - /* These commands don't need cable or parts. */ - - if (strcmp (params[1], "set") == 0) - { - if (num_params != 4) - { - urj_error_set (URJ_ERROR_BFIN, - "'bfin set' requires 2 parameters, not %d", - num_params - 2); - return URJ_STATUS_FAIL; - } - - if (strcmp (params[2], "one-insn-a-file") == 0) - { - if (strcmp (params[3], "0") == 0) - bfin_one_insn_a_file = 0; - else if (strcmp (params[3], "1") == 0) - bfin_one_insn_a_file = 1; - else - { - urj_error_set (URJ_ERROR_BFIN, - "bad value for one-insn-a-file '%s'", - params[3]); - return URJ_STATUS_FAIL; - } - } - else - { - urj_error_set (URJ_ERROR_BFIN, - "unknown set variable '%s'", - params[2]); - return URJ_STATUS_FAIL; - } - - return URJ_STATUS_OK; - } - else if (strcmp (params[1], "show") == 0) - { - int found = 0; - - if (num_params > 3) - { - urj_error_set (URJ_ERROR_BFIN, - "'bfin show' requires 0 or 1 parameter, not %d", - num_params - 2); - return URJ_STATUS_FAIL; - } - - if (num_params == 2 || strcmp (params[2], "one-insn-a-file") == 0) - { - found = 1; - urj_log (URJ_LOG_LEVEL_NORMAL, - "one-insn-a-file: %d\n", bfin_one_insn_a_file); - } - - if (!found && num_params == 3) - { - urj_error_set (URJ_ERROR_BFIN, - "unknown set variable '%s'", - params[2]); - return URJ_STATUS_FAIL; - } - - return URJ_STATUS_OK; - } - /* The remaining commands require cable or parts. */ if (urj_cmd_test_cable (chain) != URJ_STATUS_OK) @@ -426,7 +348,16 @@ cmd_bfin_run (urj_chain_t *chain, char *params[]) if (fp == NULL) goto execute_cleanup; - while (fread (raw_insn, 1, 2, fp) == 2) + /* Figure out how many instructions there are */ + t = 0; + p = insns_string; + while ((p = strchr(p, ';')) != NULL) + { + ++t; + ++p; + } + + while (t-- && fread (raw_insn, 1, 2, fp) == 2) { uint16_t iw = raw_insn[0] | (raw_insn[1] << 8); uint64_t n = iw; @@ -460,9 +391,6 @@ cmd_bfin_run (urj_chain_t *chain, char *params[]) (*last)->type = BFIN_INSN_NORMAL; (*last)->next = NULL; last = &((*last)->next); - - if (bfin_one_insn_a_file) - break; } fclose (fp); @@ -558,13 +486,11 @@ cmd_bfin_help (void) _("Usage: %s execute INSTRUCTIONs\n" "Usage: %s emulation enter|exit|singlestep|status\n" "Usage: %s reset [core|system]\n" - "Usage: %s set one-insn-a-file VALUE\n" - "Usage: %s show [one-insn-a-file]\n" "Blackfin specific commands\n" "\n" "INSTRUCTIONs are a sequence of Blackfin encoded instructions,\n" "double quoted assembly statements and [EMUDAT_IN]s\n"), - "bfin", "bfin", "bfin", "bfin", "bfin" ); + "bfin", "bfin", "bfin" ); } const urj_cmd_t urj_cmd_bfin = {