X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Fdriver.c;h=d50ae9055ed2e0367592200b08096271bb2da1d1;hp=1555561d6c3629c9be53f5e3c7011f0e6bb1aa54;hb=2ddeec9db5a8771c948294b7194778a95295b7a0;hpb=84df52f9ea78e2d71bde648a16b69d80404c6421 diff --git a/src/jtag/driver.c b/src/jtag/driver.c index 1555561d6c..d50ae9055e 100644 --- a/src/jtag/driver.c +++ b/src/jtag/driver.c @@ -56,11 +56,11 @@ static void jtag_callback_queue_reset(void) } /** - * Copy a scan_field_t for insertion into the queue. + * Copy a struct scan_field for insertion into the queue. * * This allocates a new copy of out_value using cmd_queue_alloc. */ -static void cmd_queue_scan_field_clone(scan_field_t * dst, const scan_field_t * src) +static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct scan_field * src) { dst->tap = src->tap; dst->num_bits = src->num_bits; @@ -73,13 +73,13 @@ static void cmd_queue_scan_field_clone(scan_field_t * dst, const scan_field_t * * see jtag_add_ir_scan() * */ -int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state) +int interface_jtag_add_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state) { size_t num_taps = jtag_tap_count_enabled(); jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t)); - scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t)); - scan_field_t * out_fields = cmd_queue_alloc(num_taps * sizeof(scan_field_t)); + struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command)); + struct scan_field * out_fields = cmd_queue_alloc(num_taps * sizeof(struct scan_field)); jtag_queue_command(cmd); @@ -92,11 +92,11 @@ int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields, scan->end_state = state; - scan_field_t * field = out_fields; /* keep track where we insert data */ + struct scan_field * field = out_fields; /* keep track where we insert data */ /* loop over all enabled TAPs */ - for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) + for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) { /* search the input field list for fields for the current TAP */ @@ -147,12 +147,12 @@ int interface_jtag_add_ir_scan(int in_num_fields, const scan_field_t *in_fields, * see jtag_add_plain_ir_scan() * */ -int interface_jtag_add_plain_ir_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state) +int interface_jtag_add_plain_ir_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state) { jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t)); - scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t)); - scan_field_t * out_fields = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t)); + struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command)); + struct scan_field * out_fields = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field)); jtag_queue_command(cmd); @@ -176,21 +176,21 @@ int interface_jtag_add_plain_ir_scan(int in_num_fields, const scan_field_t *in_f * see jtag_add_dr_scan() * */ -int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state) +int interface_jtag_add_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state) { /* count devices in bypass */ size_t bypass_devices = 0; - for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) + for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) { if (tap->bypass) bypass_devices++; } jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t)); - scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t)); - scan_field_t * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t)); + struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command)); + struct scan_field * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field)); jtag_queue_command(cmd); @@ -203,17 +203,17 @@ int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields, scan->end_state = state; - scan_field_t * field = out_fields; /* keep track where we insert data */ + struct scan_field * field = out_fields; /* keep track where we insert data */ /* loop over all enabled TAPs */ - for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) + for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) { /* if TAP is not bypassed insert matching input fields */ if (!tap->bypass) { - scan_field_t * start_field = field; /* keep initial position for assert() */ + struct scan_field * start_field = field; /* keep initial position for assert() */ for (int j = 0; j < in_num_fields; j++) { @@ -261,7 +261,7 @@ int interface_jtag_add_dr_scan(int in_num_fields, const scan_field_t *in_fields, * The bypass status of TAPs is set by jtag_add_ir_scan(). * */ -void interface_jtag_add_dr_out(jtag_tap_t *target_tap, +void interface_jtag_add_dr_out(struct jtag_tap *target_tap, int in_num_fields, const int *num_bits, const uint32_t *value, @@ -271,7 +271,7 @@ void interface_jtag_add_dr_out(jtag_tap_t *target_tap, size_t bypass_devices = 0; - for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) + for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) { if (tap->bypass) bypass_devices++; @@ -279,8 +279,8 @@ void interface_jtag_add_dr_out(jtag_tap_t *target_tap, jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t)); - scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t)); - scan_field_t * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(scan_field_t)); + struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command)); + struct scan_field * out_fields = cmd_queue_alloc((in_num_fields + bypass_devices) * sizeof(struct scan_field)); jtag_queue_command(cmd); @@ -295,11 +295,11 @@ void interface_jtag_add_dr_out(jtag_tap_t *target_tap, bool target_tap_match = false; - scan_field_t * field = out_fields; /* keep track where we insert data */ + struct scan_field * field = out_fields; /* keep track where we insert data */ /* loop over all enabled TAPs */ - for (jtag_tap_t * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) + for (struct jtag_tap * tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) { /* if TAP is not bypassed insert matching input fields */ @@ -344,11 +344,11 @@ void interface_jtag_add_dr_out(jtag_tap_t *target_tap, * see jtag_add_plain_dr_scan() * */ -int interface_jtag_add_plain_dr_scan(int in_num_fields, const scan_field_t *in_fields, tap_state_t state) +int interface_jtag_add_plain_dr_scan(int in_num_fields, const struct scan_field *in_fields, tap_state_t state) { jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t)); - scan_command_t * scan = cmd_queue_alloc(sizeof(scan_command_t)); - scan_field_t * out_fields = cmd_queue_alloc(in_num_fields * sizeof(scan_field_t)); + struct scan_command * scan = cmd_queue_alloc(sizeof(struct scan_command)); + struct scan_field * out_fields = cmd_queue_alloc(in_num_fields * sizeof(struct scan_field)); jtag_queue_command(cmd); @@ -418,7 +418,7 @@ int interface_jtag_add_runtest(int num_cycles, tap_state_t state) return ERROR_OK; } -int interface_jtag_add_clocks( int num_cycles ) +int interface_jtag_add_clocks(int num_cycles) { /* allocate memory for a new list member */ jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t)); @@ -489,6 +489,11 @@ void interface_jtag_add_callback4(jtag_callback_t callback, jtag_callback_data_t int interface_jtag_execute_queue(void) { + static int reentry = 0; + + assert(reentry==0); + reentry++; + int retval = default_interface_jtag_execute_queue(); if (retval == ERROR_OK) { @@ -504,6 +509,8 @@ int interface_jtag_execute_queue(void) jtag_command_queue_reset(); jtag_callback_queue_reset(); + reentry--; + return retval; }