On Dec 10, 2008, at 12:05 PM, Øyvind Harboe wrote:

That just complicates the normal case for no reason. If you leave the
expected-id comparison in C, you can still do things like:

A shorthand for the normal case is of course a requirement.

-expected-id can be implemented in Tcl: it can attach a default
piece of tcl to handle the normal case.


There is no real reason though. It is an unnecessary code change for no benefit. Any of the complex cases would need to have -expected-id removed from their jtag newtap command. We would need to explain that the "id" event is called when the target ID is read and that it _must_ be implemented. Just adding jtag match/nomatch events and allowing - expected-id to be specified multiple times solves all foreseeable problems.

Here we "eat our own dogfood", i.e. we reuse the same codepath and
prove that the tcl handler can do whatever C can do.


But the TCL handler _doesn't need to_ do everything C can do. The _only_ thing C will be able to do is compare the captured ID against a set of expected ids and call a match/nomatch event. The scripts become a lot more straightforward since they are divided into the 2 main cases, matched something we expected or didn't, instead of having one big event that always has a top-level if to distinguish the cases.

The match/nomatch events allow the target script to do whatever they need to do depending on if the captured ID is expected or not. We just make it simpler so that the target script doesn't need to encode lots of "if ID is X, then" logic. We could even make the match events dynamic based on the expected IDs provided. So, a command such as:

jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f - expected-id $_CPUTAPID -expected-id $_OTHERCPUTAPID

would create a tap with 3 events available: matched-id-$_CPUTAPID, matched-id-$_OTHERCPUTAPID, and nomatch. Then the target scripts can be focused on whatever needs to be done when a given ID is captured rather than having to figure out which ID it is. Simple scripts could be used with no changes. Complex scripts can be easily written without a lot of boilerplate code and allow the script author to do anything necessary. The code path would be the event mechanism and I'm certain TCL can do "if-then-else" constructs so concerns about not providing capability to target scripts are unfounded.

btw, I think the best way is to "return -error" to throw an exception and leave
the primary return value alone.


My knowledge of TCL is limited. The intent was to return a failure condition.

--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer

--
Rick Altherr
[EMAIL PROTECTED]

"He said he hadn't had a byte in three days. I had a short, so I split it with him."
 -- Unsigned



Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to