mips32, use scan32 function for reading impcode/idcode. 03/4003/3
authorSalvador Arroyo <salvador@telecable.es>
Mon, 20 Feb 2017 19:45:37 +0000 (20:45 +0100)
committerFreddie Chopin <freddie.chopin@gmail.com>
Mon, 8 May 2017 17:05:58 +0000 (18:05 +0100)
There is no need to implement scan code in functions
mips_ejtag_get_idcode/impcode(), use mips_ejtag_drscan_32().
Impcode/idcode saved in ejtag.info.
Reorder the code in the callers of this functions.

Change-Id: Ia829c783a0b24c6a65cade736113fa6f67b0a170
Signed-off-by: Salvador Arroyo <salvador@telecable.es>
Reviewed-on: http://openocd.zylin.com/4003
Tested-by: jenkins
Reviewed-by: Peter Mamonov <pmamonov@gmail.com>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
src/target/mips_ejtag.c
src/target/mips_ejtag.h
src/target/mips_m4k.c

index d335c1bbd8b057bfdfc7580a17391039567db605..03a09529ce37a2f3486b79789d4470238fbc42ab 100644 (file)
@@ -48,54 +48,20 @@ void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr)
        }
 }
 
-int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode)
+int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info)
 {
-       struct scan_field field;
-       uint8_t r[4];
-
        mips_ejtag_set_instr(ejtag_info, EJTAG_INST_IDCODE);
 
-       field.num_bits = 32;
-       field.out_value = NULL;
-       field.in_value = r;
-
-       jtag_add_dr_scan(ejtag_info->tap, 1, &field, TAP_IDLE);
-
-       int retval;
-       retval = jtag_execute_queue();
-       if (retval != ERROR_OK) {
-               LOG_ERROR("register read failed");
-               return retval;
-       }
-
-       *idcode = buf_get_u32(field.in_value, 0, 32);
-
-       return ERROR_OK;
+       ejtag_info->idcode = 0;
+       return mips_ejtag_drscan_32(ejtag_info, &ejtag_info->idcode);
 }
 
-static int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info, uint32_t *impcode)
+int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info)
 {
-       struct scan_field field;
-       uint8_t r[4];
-
        mips_ejtag_set_instr(ejtag_info, EJTAG_INST_IMPCODE);
 
-       field.num_bits = 32;
-       field.out_value = NULL;
-       field.in_value = r;
-
-       jtag_add_dr_scan(ejtag_info->tap, 1, &field, TAP_IDLE);
-
-       int retval;
-       retval = jtag_execute_queue();
-       if (retval != ERROR_OK) {
-               LOG_ERROR("register read failed");
-               return retval;
-       }
-
-       *impcode = buf_get_u32(field.in_value, 0, 32);
-
-       return ERROR_OK;
+       ejtag_info->impcode = 0;
+       return mips_ejtag_drscan_32(ejtag_info, &ejtag_info->impcode);
 }
 
 void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info, uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf)
@@ -368,12 +334,11 @@ static void ejtag_main_print_imp(struct mips_ejtag *ejtag_info)
 
 int mips_ejtag_init(struct mips_ejtag *ejtag_info)
 {
-       int retval;
-
-       retval = mips_ejtag_get_impcode(ejtag_info, &ejtag_info->impcode);
-       if (retval != ERROR_OK)
+       int retval = mips_ejtag_get_impcode(ejtag_info);
+       if (retval != ERROR_OK) {
+               LOG_ERROR("impcode read failed");
                return retval;
-       LOG_DEBUG("impcode: 0x%8.8" PRIx32 "", ejtag_info->impcode);
+       }
 
        /* get ejtag version */
        ejtag_info->ejtag_version = ((ejtag_info->impcode >> 29) & 0x07);
index 226863ff56dcbfa64ddf5596da75936cded53b79..71f5c1b4b4e16287cdf6778f42b4d3cc42120ab0 100644 (file)
@@ -219,7 +219,7 @@ struct mips_ejtag {
 void mips_ejtag_set_instr(struct mips_ejtag *ejtag_info, uint32_t new_instr);
 int mips_ejtag_enter_debug(struct mips_ejtag *ejtag_info);
 int mips_ejtag_exit_debug(struct mips_ejtag *ejtag_info);
-int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info, uint32_t *idcode);
+int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info);
 void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info,
                            uint32_t ctrl, uint32_t data, uint8_t *in_scan_buf);
 void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data);
index e2007d99efdc58d400698d8a780daef9cb4cbd2c..7d1c06cf06fb7e95c74012bda02e0ee0a96e3f04 100644 (file)
@@ -1174,36 +1174,30 @@ static int mips_m4k_target_create(struct target *target, Jim_Interp *interp)
 
 static int mips_m4k_examine(struct target *target)
 {
-       int retval;
        struct mips_m4k_common *mips_m4k = target_to_m4k(target);
        struct mips_ejtag *ejtag_info = &mips_m4k->mips32.ejtag_info;
-       uint32_t idcode = 0;
 
        if (!target_was_examined(target)) {
-               retval = mips_ejtag_get_idcode(ejtag_info, &idcode);
-               if (retval != ERROR_OK)
+               int retval = mips_ejtag_get_idcode(ejtag_info);
+               if (retval != ERROR_OK) {
+                       LOG_ERROR("idcode read failed");
                        return retval;
-               ejtag_info->idcode = idcode;
-
-               if (((idcode >> 1) & 0x7FF) == 0x29) {
+               }
+               if (((ejtag_info->idcode >> 1) & 0x7FF) == 0x29) {
                        /* we are using a pic32mx so select ejtag port
                         * as it is not selected by default */
                        mips_ejtag_set_instr(ejtag_info, MTAP_SW_ETAP);
-                       LOG_DEBUG("PIC32MX Detected - using EJTAG Interface");
+                       LOG_DEBUG("PIC32 Detected - using EJTAG Interface");
                        mips_m4k->is_pic32mx = true;
                }
        }
 
        /* init rest of ejtag interface */
-       retval = mips_ejtag_init(ejtag_info);
+       int retval = mips_ejtag_init(ejtag_info);
        if (retval != ERROR_OK)
                return retval;
 
-       retval = mips32_examine(target);
-       if (retval != ERROR_OK)
-               return retval;
-
-       return ERROR_OK;
+       return mips32_examine(target);
 }
 
 static int mips_m4k_bulk_write_memory(struct target *target, target_addr_t address,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)