X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fjtag%2Fdriver.c;h=1f28d183ab70044e5b4816bde6594f3113d7bc0a;hp=cc1342849f75c113768b48e89e5f6825903fb6c3;hb=2fecae46f62ca98657d650de9fc73d44247971e8;hpb=f90d8fa45f2d4c9d4b7990f198b232ee55cbb4e1 diff --git a/src/jtag/driver.c b/src/jtag/driver.c index cc1342849f..1f28d183ab 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); @@ -377,7 +377,7 @@ int interface_jtag_add_tlr(void) cmd->type = JTAG_STATEMOVE; - cmd->cmd.statemove = cmd_queue_alloc(sizeof(statemove_command_t)); + cmd->cmd.statemove = cmd_queue_alloc(sizeof(struct statemove_command)); cmd->cmd.statemove->end_state = state; return ERROR_OK; @@ -392,7 +392,7 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path) cmd->type = JTAG_PATHMOVE; - cmd->cmd.pathmove = cmd_queue_alloc(sizeof(pathmove_command_t)); + cmd->cmd.pathmove = cmd_queue_alloc(sizeof(struct pathmove_command)); cmd->cmd.pathmove->num_states = num_states; cmd->cmd.pathmove->path = cmd_queue_alloc(sizeof(tap_state_t) * num_states); @@ -411,14 +411,14 @@ int interface_jtag_add_runtest(int num_cycles, tap_state_t state) cmd->type = JTAG_RUNTEST; - cmd->cmd.runtest = cmd_queue_alloc(sizeof(runtest_command_t)); + cmd->cmd.runtest = cmd_queue_alloc(sizeof(struct runtest_command)); cmd->cmd.runtest->num_cycles = num_cycles; cmd->cmd.runtest->end_state = 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)); @@ -427,7 +427,7 @@ int interface_jtag_add_clocks(int num_cycles ) cmd->type = JTAG_STABLECLOCKS; - cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(stableclocks_command_t)); + cmd->cmd.stableclocks = cmd_queue_alloc(sizeof(struct stableclocks_command)); cmd->cmd.stableclocks->num_cycles = num_cycles; return ERROR_OK; @@ -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; }