summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-02 03:38:50 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-02 03:38:50 +0000
commitdeed7fb56c1067b84d5805df5ead428e09e8325e (patch)
tree77ce2b802806a985738f353f1ca0906ad2a8f3fb /src
parenta8f3ba8f5f66180fb293d0f65b6520ecce9cfe73 (diff)
downloadopenocd+libswd-deed7fb56c1067b84d5805df5ead428e09e8325e.tar.gz
openocd+libswd-deed7fb56c1067b84d5805df5ead428e09e8325e.tar.bz2
openocd+libswd-deed7fb56c1067b84d5805df5ead428e09e8325e.tar.xz
openocd+libswd-deed7fb56c1067b84d5805df5ead428e09e8325e.zip
Start clean-up of JTAG driver interface:
- Factor jtag_add_scan_check to call new jtag_add_scan_check_alloc helper. - Use conditional logic to define two versions of the helper. - These helpers will be moved to other files in future patches. git-svn-id: svn://svn.berlios.de/openocd/trunk@1989 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/jtag/jtag.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index ec233086..64a168cb 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -740,31 +740,39 @@ static int jtag_check_value_mask_callback(u8 *in, jtag_callback_data_t data1, jt
return jtag_check_value_inner(in, (u8 *)data1, (u8 *)data2, (int)data3);
}
+#ifdef HAVE_JTAG_MINIDRIVER_H
+void interface_jtag_add_scan_check_alloc(scan_field_t *field)
+{
+ /* We're executing this synchronously, so try to use local storage. */
+ if (field->num_bits > 32)
+ {
+ unsigned num_bytes = TAP_SCAN_BYTES(field->num_bits);
+ field->in_value = (u8 *)malloc(num_bytes);
+ field->allocated = 1;
+ }
+ else
+ field->in_value = field->intmp;
+}
+#else
+void interface_jtag_add_scan_check_alloc(scan_field_t *field)
+{
+ unsigned num_bytes = TAP_SCAN_BYTES(field->num_bits);
+ field->in_value = (u8 *)cmd_queue_alloc(num_bytes);
+}
+#endif
+
static void jtag_add_scan_check(void (*jtag_add_scan)(int in_num_fields, const scan_field_t *in_fields, tap_state_t state),
int in_num_fields, scan_field_t *in_fields, tap_state_t state)
{
for (int i = 0; i < in_num_fields; i++)
{
- in_fields[i].allocated = 0;
- in_fields[i].modified = 0;
- if ((in_fields[i].check_value != NULL) && (in_fields[i].in_value == NULL))
- {
- in_fields[i].modified = 1;
- /* we need storage space... */
-#ifdef HAVE_JTAG_MINIDRIVER_H
- if (in_fields[i].num_bits <= 32)
- {
- /* This is enough space and we're executing this synchronously */
- in_fields[i].in_value = in_fields[i].intmp;
- } else
- {
- in_fields[i].in_value = (u8 *)malloc(CEIL(in_fields[i].num_bits, 8));
- in_fields[i].allocated = 1;
- }
-#else
- in_fields[i].in_value = (u8 *)cmd_queue_alloc(CEIL(in_fields[i].num_bits, 8));
-#endif
- }
+ struct scan_field_s *field = &in_fields[i];
+ field->allocated = 0;
+ field->modified = 0;
+ if (field->check_value || field->in_value)
+ continue;
+ interface_jtag_add_scan_check_alloc(field);
+ field->modified = 1;
}
jtag_add_scan(in_num_fields, in_fields, state);