I have been giving this a lot of thought, and I would like to suggest a
compromise :)

I dont have the code with me right now so some of some function names
´might be a bit off but the idea should be clear.

> One problem about jtag_add_end_state() is that it's effectively
> setting a global variable.
>
> This makes it hard to tell, reading some code, what is expected
> to happen after a JTAG scan.
>
> Some other calling code invoked jtag_add_end_state() with some
> end state.

True, but for some parts of the code, the job is to send a certain
sequence through the DR scan chain without worring about end states, while
some other section handles the logic of rest states, if we must pass idle
a certain number of times, or not, etc.

So it happens that this is a feature, example in the arm_adi low level
scan functions, the end state is really a "dont care, unless top level has
a strong opinion". And there are several layers betwen the top layer and
the generation of the scan structures. In the worst case, every call to
memap_read/write_memory functions must supply an end state, and this must
propagate all the way down to the scan_inout funtions.

> Other than running the debugger, I don't know how to figure out
> what the end state is.

We can call get_end_state()

> Wouldn't it be better if the code had to pass in the end state
> as an argument to the scan operations?

Not always, TAP_INVALID is really TAP_DONTCARE

> That way there would be some clue locally in the code as to what state
> the JTAG state machine moves to after a scan....
>
> Is there a fundamental reason(other than that we need
> stability on svn head :-) why the following couldn't work:
>
> - remove jtag_add_endstate()

And my alternative suggestion is:

- ONLY call jtag_add_endstate() from target layers, never inside jtag
drivers.
- end_state is the resting state for the next complete scan, nor the end
of the next state_move generated within jtag drivers.

- add an state_move_end_state state to the state_move commands,
jtag_state_move(state_move_end_state)
effectively changing tho following pattern seen in some jtag drivers today

saved_end_state = get_end_state()
add_end_state(end_of_scan_section )
state_move() /* to end of scan section */
set_end_state(saved_end_state)
..
..
state_move() /* to "real" end state */


TO
state_move(end_of_scan_section)
..
..
state_move(get_end_state())

This will not change the api calling the jtag layer, but it will clean up
some of the jtag implementation code.

Best regards
Magnus


_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to