void tap_capture_dr( chain_t *chain ) { if ((tap_state( chain ) & (TAPSTAT_RESET | TAPSTAT_IDLE)) != TAPSTAT_IDLE) printf( _("%s: Invalid state: %2X\n"), "tap_capture_dr", tap_state( chain ) ); /* Run-Test/Idle or Update-DR or Update-IR state */ chain_clock( chain, 1, 0 ); /* Select-DR-Scan */ chain_clock( chain, 0, 0 ); /* Capture-DR */ }
void tap_shift_register( chain_t *chain, const tap_register *in, tap_register *out, int exit ) { int i; if (!(tap_state( chain ) & TAPSTAT_SHIFT)) printf( _("%s: Invalid state: %2X\n"), "tap_shift_register", tap_state( chain ) ); /* Capture-DR, Capture-IR, Shift-DR, Shift-IR, Exit2-DR or Exit2-IR state */ if (tap_state( chain ) & TAPSTAT_CAPTURE) chain_clock( chain, 0, 0 ); /* save last TDO bit :-) */ for (i = 0; i < in->len; i++) { if (out && (i < out->len)) out->data[i] = cable_get_tdo( chain->cable ); chain_clock( chain, (exit && ((i + 1) == in->len)) ? 1 : 0, in->data[i] ); /* Shift (& Exit1) */ } /* Shift-DR, Shift-IR, Exit1-DR or Exit1-IR state */ if (exit) { chain_clock( chain, 1, 0 ); /* Update-DR or Update-IR */ chain_clock( chain, 0, 0 ); /* Run-Test/Idle */ } }
void tap_reset( chain_t *chain ) { tap_state_reset( chain ); chain_clock( chain, 1, 0 ); chain_clock( chain, 1, 0 ); chain_clock( chain, 1, 0 ); chain_clock( chain, 1, 0 ); chain_clock( chain, 1, 0 ); /* Test-Logic-Reset */ chain_clock( chain, 0, 0 ); /* Run-Test/Idle */ }
/* * svf_goto_state(state) * * Moves from any TAP state to the specified state. * The state traversal is done according to the SVF specification. * See STATE of the Serial Vector Format Specification * * Encoding of state is according to the jtag suite's defines. * * Parameter: * state : new TAP controller state */ static void svf_goto_state( chain_t *chain, int new_state) { int current_state; current_state = tap_state(chain); /* handle unknown state */ if (new_state == Unknown_State) new_state = Test_Logic_Reset; /* abort if new_state already reached */ if (current_state == new_state) return; switch (current_state) { case Test_Logic_Reset: chain_clock(chain, 0, 0, 1); break; case Run_Test_Idle: chain_clock(chain, 1, 0, 1); break; case Select_DR_Scan: case Select_IR_Scan: if (new_state == Test_Logic_Reset || new_state == Run_Test_Idle || (current_state & TAPSTAT_DR && new_state & TAPSTAT_IR) || (current_state & TAPSTAT_IR && new_state & TAPSTAT_DR)) /* progress in select-idle/reset loop */ chain_clock(chain, 1, 0, 1); else /* enter DR/IR branch */ chain_clock(chain, 0, 0, 1); break; case Capture_DR: if (new_state == Shift_DR) /* enter Shift_DR state */ chain_clock(chain, 0, 0, 1); else /* bypass Shift_DR */ chain_clock(chain, 1, 0, 1); break; case Capture_IR: if (new_state == Shift_IR) /* enter Shift_IR state */ chain_clock(chain, 0, 0, 1); else /* bypass Shift_IR */ chain_clock(chain, 1, 0, 1); break; case Shift_DR: case Shift_IR: /* progress to Exit1_DR/IR */ chain_clock(chain, 1, 0, 1); break; case Exit1_DR: if (new_state == Pause_DR) /* enter Pause_DR state */ chain_clock(chain, 0, 0, 1); else /* bypass Pause_DR */ chain_clock(chain, 1, 0, 1); break; case Exit1_IR: if (new_state == Pause_IR) /* enter Pause_IR state */ chain_clock(chain, 0, 0, 1); else /* bypass Pause_IR */ chain_clock(chain, 1, 0, 1); break; case Pause_DR: case Pause_IR: /* progress to Exit2_DR/IR */ chain_clock(chain, 1, 0, 1); break; case Exit2_DR: if (new_state == Shift_DR) /* enter Shift_DR state */ chain_clock(chain, 0, 0, 1); else /* progress to Update_DR */ chain_clock(chain, 1, 0, 1); break; case Exit2_IR: if (new_state == Shift_IR) /* enter Shift_IR state */ chain_clock(chain, 0, 0, 1); else /* progress to Update_IR */ chain_clock(chain, 1, 0, 1); break; case Update_DR: case Update_IR: if (new_state == Run_Test_Idle) /* enter Run_Test_Idle */ chain_clock(chain, 0, 0, 1); else /* progress to Select_DR/IR */ chain_clock(chain, 1, 0, 1); break; default: svf_force_reset_state(chain); break; } /* continue state changes */ svf_goto_state(chain, new_state); }
/* * svf_force_reset_state() * * Puts TAP controller into reset state by clocking 5 times with TMS = 1. */ static void svf_force_reset_state( chain_t *chain ) { chain_clock(chain, 1, 0, 5); tap_state_reset(chain); }