From a30a4f0fc76b72936a6557e08d6b55b3a46eaafd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Harboe?= Date: Tue, 13 Dec 2011 23:44:34 +0100 Subject: [PATCH] jtag: make caller always allocate buffer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit simplifies the API and there is only one remaining user at this point. Is the implementation busted where the check does not actually happen now? Change-Id: I776a43766f5576a08df320f6fe41a2750d101bde Signed-off-by: Øyvind Harboe Reviewed-on: http://openocd.zylin.com/264 Tested-by: jenkins Reviewed-by: Spencer Oliver --- src/jtag/core.c | 16 ++-------------- src/jtag/jtag.h | 9 --------- src/jtag/minidriver/minidriver_imp.h | 18 ------------------ 3 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/jtag/core.c b/src/jtag/core.c index 3090dddd2a..529e9bcd1b 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -417,12 +417,8 @@ static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(s for (int i = 0; i < in_num_fields; i++) { struct scan_field *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; + /* caller must provide in_buffer if needed for callback */ + assert((field->check_value == NULL) || (field->in_value != NULL)); } jtag_add_scan(active, in_num_fields, in_fields, state); @@ -437,14 +433,6 @@ static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(s (jtag_callback_data_t)in_fields[i].check_mask, (jtag_callback_data_t)in_fields[i].num_bits); } - if (in_fields[i].allocated) - { - free(in_fields[i].in_value); - } - if (in_fields[i].modified) - { - in_fields[i].in_value = NULL; - } } } diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 1476150366..f4b89a7ffe 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -105,8 +105,6 @@ extern tap_state_t cmd_queue_cur_state; * * In addition, this structure includes a value and mask that is used by * jtag_add_dr_scan_check() to validate the value that was scanned out. - * - * The allocated, modified, and intmp fields are internal work space. */ struct scan_field { /// The number of bits this field specifies (up to 32) @@ -120,13 +118,6 @@ struct scan_field { uint8_t* check_value; /// The mask to go with check_value uint8_t* check_mask; - - /// in_value has been allocated for the queue - int allocated; - /// Indicates we modified the in_value. - int modified; - /// temporary storage for performing value checks synchronously - uint8_t intmp[4]; }; struct jtag_tap { diff --git a/src/jtag/minidriver/minidriver_imp.h b/src/jtag/minidriver/minidriver_imp.h index b6cdbead54..98d87fe7eb 100644 --- a/src/jtag/minidriver/minidriver_imp.h +++ b/src/jtag/minidriver/minidriver_imp.h @@ -23,24 +23,6 @@ #include -static inline void interface_jtag_alloc_in_value32(struct scan_field *field) -{ - field->in_value = field->intmp; -} - -static inline void interface_jtag_add_scan_check_alloc(struct scan_field *field) -{ - /* We're executing this synchronously, so try to use local storage. */ - if (field->num_bits > 32) - { - unsigned num_bytes = DIV_ROUND_UP(field->num_bits, 8); - field->in_value = (uint8_t *)malloc(num_bytes); - field->allocated = 1; - } - else - field->in_value = field->intmp; -} - static inline void jtag_add_dr_out(struct jtag_tap* tap, int num_fields, const int* num_bits, const uint32_t* value, tap_state_t end_state) -- 2.30.2