mips32, add generic scan 32 function 05/4005/3
authorSalvador Arroyo <sarroyofdez@yahoo.es>
Mon, 20 Feb 2017 22:05:38 +0000 (23:05 +0100)
committerFreddie Chopin <freddie.chopin@gmail.com>
Mon, 24 Apr 2017 22:07:29 +0000 (23:07 +0100)
Will be used later, allow queuing all needed scans in a pracc
access. This makes faster execution with ftdi based adapters
working in sync with pracc.
Added now because the overall code is shorter.

Change-Id: Ib32b89307b75785f88870db8d7c9255dc5bbd426
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/4005
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
src/target/mips_ejtag.c

index 650af3e..ebf0d73 100644 (file)
@@ -121,52 +121,42 @@ void mips_ejtag_add_scan_96(struct mips_ejtag *ejtag_info, uint32_t ctrl, uint32
        keep_alive();
 }
 
-int mips_ejtag_drscan_32(struct mips_ejtag *ejtag_info, uint32_t *data)
+void mips_ejtag_drscan_32_queued(struct mips_ejtag *ejtag_info, uint32_t data_out, uint8_t *data_in)
 {
-       struct jtag_tap *tap;
-       tap  = ejtag_info->tap;
-       assert(tap != NULL);
+       assert(ejtag_info->tap != NULL);
+       struct jtag_tap *tap = ejtag_info->tap;
 
        struct scan_field field;
-       uint8_t t[4], r[4];
-       int retval;
-
        field.num_bits = 32;
-       field.out_value = t;
-       buf_set_u32(t, 0, field.num_bits, *data);
-       field.in_value = r;
 
+       uint8_t scan_out[4];
+       field.out_value = scan_out;
+       buf_set_u32(scan_out, 0, field.num_bits, data_out);
+
+       field.in_value = data_in;
        jtag_add_dr_scan(tap, 1, &field, TAP_IDLE);
 
-       retval = jtag_execute_queue();
+       keep_alive();
+}
+
+int mips_ejtag_drscan_32(struct mips_ejtag *ejtag_info, uint32_t *data)
+{
+       uint8_t scan_in[4];
+       mips_ejtag_drscan_32_queued(ejtag_info, *data, scan_in);
+
+       int retval = jtag_execute_queue();
        if (retval != ERROR_OK) {
                LOG_ERROR("register read failed");
                return retval;
        }
 
-       *data = buf_get_u32(field.in_value, 0, 32);
-
-       keep_alive();
-
+       *data = buf_get_u32(scan_in, 0, 32);
        return ERROR_OK;
 }
 
 void mips_ejtag_drscan_32_out(struct mips_ejtag *ejtag_info, uint32_t data)
 {
-       uint8_t t[4];
-       struct jtag_tap *tap;
-       tap  = ejtag_info->tap;
-       assert(tap != NULL);
-
-       struct scan_field field;
-
-       field.num_bits = 32;
-       field.out_value = t;
-       buf_set_u32(t, 0, field.num_bits, data);
-
-       field.in_value = NULL;
-
-       jtag_add_dr_scan(tap, 1, &field, TAP_IDLE);
+       mips_ejtag_drscan_32_queued(ejtag_info, data, NULL);
 }
 
 int mips_ejtag_drscan_8(struct mips_ejtag *ejtag_info, uint8_t *data)