diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-02-26 11:53:54 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-02-26 11:53:54 +0000 |
commit | 4c7891ecebbf28659f24a21e0156284c802ab6e7 (patch) | |
tree | ad1ac12d6254f51fdc8b39bc7aefc9def0ba0037 | |
parent | 11fa1489444823db38484d5e995f816b3652b594 (diff) | |
download | openocd_libswd-4c7891ecebbf28659f24a21e0156284c802ab6e7.tar.gz openocd_libswd-4c7891ecebbf28659f24a21e0156284c802ab6e7.tar.bz2 openocd_libswd-4c7891ecebbf28659f24a21e0156284c802ab6e7.tar.xz openocd_libswd-4c7891ecebbf28659f24a21e0156284c802ab6e7.zip |
Next step in the JTAG minidriver. This should be fairly close to the final thing, but
I'm not calling it "done" quite yet.
git-svn-id: svn://svn.berlios.de/openocd/trunk@350 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r-- | src/jtag/jtag.c | 162 | ||||
-rw-r--r-- | src/jtag/jtag.h | 4 |
2 files changed, 100 insertions, 66 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c index eb4a245a..a4fd7553 100644 --- a/src/jtag/jtag.c +++ b/src/jtag/jtag.c @@ -496,15 +496,31 @@ int INTERFACE(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields, int jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state) { - jtag_command_t **last_cmd; - int i; - if (jtag_trst == 1) { WARNING("JTAG command queued, while TRST is low (TAP in reset)"); - return ERROR_JTAG_TRST_ASSERTED; + return jtag_error=ERROR_JTAG_TRST_ASSERTED; } + if (state != -1) + cmd_queue_end_state = state; + + if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_RELEASED); + + if (cmd_queue_end_state == TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_ASSERTED); + + cmd_queue_cur_state = cmd_queue_end_state; + + return interface_jtag_add_plain_ir_scan(num_fields, fields, state); +} + +int INTERFACE(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *fields, enum tap_state state) +{ + int i; + jtag_command_t **last_cmd; + last_cmd = jtag_get_last_command_p(); /* allocate memory for a new list member */ @@ -520,17 +536,6 @@ int jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state (*last_cmd)->cmd.scan->fields = cmd_queue_alloc(num_fields * sizeof(scan_field_t)); (*last_cmd)->cmd.scan->end_state = state; - if (state != -1) - cmd_queue_end_state = state; - - if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_RELEASED); - - if (cmd_queue_end_state == TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_ASSERTED); - - cmd_queue_cur_state = cmd_queue_end_state; - for (i = 0; i < num_fields; i++) { int num_bits = fields[i].num_bits; @@ -550,18 +555,35 @@ int jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state int jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state) { + if (jtag_trst == 1) + { + WARNING("JTAG command queued, while TRST is low (TAP in reset)"); + return jtag_error=ERROR_JTAG_TRST_ASSERTED; + } + + if (state != -1) + cmd_queue_end_state = state; + + if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_RELEASED); + + if (cmd_queue_end_state == TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_ASSERTED); + + cmd_queue_cur_state = cmd_queue_end_state; + + return interface_jtag_add_dr_scan(num_fields, fields, state); +} + +int INTERFACE(interface_jtag_add_dr_scan)(int num_fields, scan_field_t *fields, enum tap_state state) +{ int i, j; int bypass_devices = 0; int field_count = 0; - jtag_command_t **last_cmd = jtag_get_last_command_p(); - jtag_device_t *device = jtag_devices; int scan_size; - if (jtag_trst == 1) - { - WARNING("JTAG command queued, while TRST is low (TAP in reset)"); - return ERROR_JTAG_TRST_ASSERTED; - } + jtag_command_t **last_cmd = jtag_get_last_command_p(); + jtag_device_t *device = jtag_devices; /* count devices in bypass */ while (device) @@ -584,17 +606,6 @@ int jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state) (*last_cmd)->cmd.scan->fields = cmd_queue_alloc((num_fields + bypass_devices) * sizeof(scan_field_t)); (*last_cmd)->cmd.scan->end_state = state; - if (state != -1) - cmd_queue_end_state = state; - - if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_RELEASED); - - if (cmd_queue_end_state == TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_ASSERTED); - - cmd_queue_cur_state = cmd_queue_end_state; - for (i = 0; i < jtag_num_devices; i++) { int found = 0; @@ -650,15 +661,31 @@ int jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state) int jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state) { - int i; - jtag_command_t **last_cmd = jtag_get_last_command_p(); - if (jtag_trst == 1) { WARNING("JTAG command queued, while TRST is low (TAP in reset)"); - return ERROR_JTAG_TRST_ASSERTED; + return jtag_error=ERROR_JTAG_TRST_ASSERTED; } + if (state != -1) + cmd_queue_end_state = state; + + if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_RELEASED); + + if (cmd_queue_end_state == TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_ASSERTED); + + cmd_queue_cur_state = cmd_queue_end_state; + + return interface_jtag_add_plain_dr_scan(num_fields, fields, state); +} + +int INTERFACE(interface_jtag_add_plain_dr_scan)(int num_fields, scan_field_t *fields, enum tap_state state) +{ + int i; + jtag_command_t **last_cmd = jtag_get_last_command_p(); + /* allocate memory for a new list member */ *last_cmd = cmd_queue_alloc(sizeof(jtag_command_t)); last_comand_pointer = &((*last_cmd)->next); @@ -671,17 +698,6 @@ int jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state (*last_cmd)->cmd.scan->num_fields = num_fields; (*last_cmd)->cmd.scan->fields = cmd_queue_alloc(num_fields * sizeof(scan_field_t)); (*last_cmd)->cmd.scan->end_state = state; - - if (state != -1) - cmd_queue_end_state = state; - - if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_RELEASED); - - if (cmd_queue_end_state == TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_ASSERTED); - - cmd_queue_cur_state = cmd_queue_end_state; for (i = 0; i < num_fields; i++) { @@ -741,22 +757,36 @@ int INTERFACE(interface_jtag_add_statemove)(enum tap_state state) int jtag_add_pathmove(int num_states, enum tap_state *path) { - jtag_command_t **last_cmd = jtag_get_last_command_p(); - int i; - if (jtag_trst == 1) { WARNING("JTAG command queued, while TRST is low (TAP in reset)"); - return ERROR_JTAG_TRST_ASSERTED; + return jtag_error=ERROR_JTAG_TRST_ASSERTED; } /* the last state has to be a stable state */ if (tap_move_map[path[num_states - 1]] == -1) { ERROR("TAP path doesn't finish in a stable state"); - return ERROR_JTAG_NOT_IMPLEMENTED; + return jtag_error=ERROR_JTAG_NOT_IMPLEMENTED; } + if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_RELEASED); + + if (cmd_queue_end_state == TAP_TLR) + jtag_call_event_callbacks(JTAG_TRST_ASSERTED); + + cmd_queue_cur_state = path[num_states - 1]; + + return interface_jtag_add_pathmove(num_states, path); +} + + +int INTERFACE(interface_jtag_add_pathmove)(int num_states, enum tap_state *path) +{ + jtag_command_t **last_cmd = jtag_get_last_command_p(); + int i; + /* allocate memory for a new list member */ *last_cmd = cmd_queue_alloc(sizeof(jtag_command_t)); last_comand_pointer = &((*last_cmd)->next); @@ -769,14 +799,6 @@ int jtag_add_pathmove(int num_states, enum tap_state *path) for (i = 0; i < num_states; i++) (*last_cmd)->cmd.pathmove->path[i] = path[i]; - - if (cmd_queue_cur_state == TAP_TLR && cmd_queue_end_state != TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_RELEASED); - - if (cmd_queue_end_state == TAP_TLR) - jtag_call_event_callbacks(JTAG_TRST_ASSERTED); - - cmd_queue_cur_state = path[num_states - 1]; return ERROR_OK; } @@ -931,7 +953,7 @@ int INTERFACE(interface_jtag_add_reset)(int req_trst, int req_srst) return ERROR_OK; } -int jtag_add_end_state(enum tap_state state) +int INTERFACE(interface_jtag_add_end_state)(enum tap_state state) { jtag_command_t **last_cmd = jtag_get_last_command_p(); @@ -944,13 +966,18 @@ int jtag_add_end_state(enum tap_state state) (*last_cmd)->cmd.end_state = cmd_queue_alloc(sizeof(end_state_command_t)); (*last_cmd)->cmd.end_state->end_state = state; + return ERROR_OK; +} + +int jtag_add_end_state(enum tap_state state) +{ + int retval = interface_jtag_add_end_state(state); if (state != -1) cmd_queue_end_state = state; - - return ERROR_OK; + return retval; } -int jtag_add_sleep(u32 us) +int INTERFACE(interface_jtag_add_sleep)(u32 us) { jtag_command_t **last_cmd = jtag_get_last_command_p(); @@ -966,6 +993,11 @@ int jtag_add_sleep(u32 us) return ERROR_OK; } +int jtag_add_sleep(u32 us) +{ + return interface_jtag_add_sleep(us); +} + int jtag_scan_size(scan_command_t *cmd) { int bit_count = 0; diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 0c9c3675..e190858a 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -275,6 +275,8 @@ extern int interface_jtag_add_statemove(enum tap_state endstate); /* A list of unambigious single clock state transitions, not * all drivers can support this, but it is required for e.g. * XScale and Xilinx support + * + * Note! TAP_TLR must not be used in the path! */ extern int jtag_add_pathmove(int num_states, enum tap_state *path); extern int interface_jtag_add_pathmove(int num_states, enum tap_state *path); @@ -284,7 +286,7 @@ extern int interface_jtag_add_runtest(int num_cycles, enum tap_state endstate); extern int jtag_add_reset(int trst, int srst); extern int interface_jtag_add_reset(int trst, int srst); extern int jtag_add_end_state(enum tap_state endstate); -extern int inteface_jtag_add_end_state(enum tap_state endstate); +extern int interface_jtag_add_end_state(enum tap_state endstate); extern int jtag_add_sleep(u32 us); extern int interface_jtag_add_sleep(u32 us); /* |