Commit Graph

3542 Commits

Author SHA1 Message Date
David Brownell a65e75ea34 Tcl and doc: update to match new 'arm mcr ...' etc
Make them match the C code.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 01:10:19 -08:00
Øyvind Harboe 48edd58c39 target: at91eb40a.cfg is a board, not a target.
Also updated to use target name when creating flash
and set jtag_khz to 16000.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-01 10:06:40 +01:00
Øyvind Harboe 445da543d8 zy1000: keep up with latest changes to command handling
Keep up with Jim Tcl interpreter creation cleanup.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-01 09:53:23 +01:00
Øyvind Harboe 5576a6240a command: the Jim interpreter can now be provided rather than created
In embedded hosts, the Jim interpreter can come from the
existing context rather than be created by OpenOCD.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-01 09:53:23 +01:00
David Brownell 63dc352876 ARM11: remove previous mcr()/mrc() methods
We don't need this code, now that the DPM code handles it.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 00:49:16 -08:00
David Brownell 5949a3b3a5 Cortex-A8: remove previous mcr()/mrc() methods
We don't need this code, now that the DPM code handles it.
Neither do we need the ARMv7-A CP15 operations; remove their
remnants too.  And disable a mostly-needless diagnostic.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 00:49:11 -08:00
David Brownell 563d937c3c ARM: implement mrc()/mcr() as DPM ops
Instead of having separate ARM11 and Cortex-A8 implementations of
this code, have one shared implementation which just builds on the
existing "run instruction via R0" support.

This enables followup patches to remove that now-unused code from
those two drivers.  (Patches to move the "mrc" and "mcr" code into
"struct arm" are due too ... MIPS and other cores do not support
those ARM-specific concepts.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 00:49:04 -08:00
David Brownell 177bbd8891 target: "mcr" and "mrc" are ARM-specific
Switch "mrc" and "mcr" commands to be toplevel ARM operations,
as they should initially have been.

Correct the usage message for both commands:  it matches ARM
documentation (as one wants!) instead of reordering them to
match the funky mrc() and mcr() method usage (sigh).

For Cortex-A8: restore a line that got accidentally dropped,
so the secure monitor mode shadow registers will show again.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 00:48:53 -08:00
David Brownell 209a0197f0 ARMv7-A: stop using CP15 ops
The ARMv7-A code uses read_cp15() to access fault registers.
Instead, use DPM operations directly, passing in the relevant
MRC instructions.

This eliminates per-operation overhead (though it'll be hard
to observe, this is uncommon) and helps eliminate read_cp15().

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 00:48:40 -08:00
David Brownell fb984a477d Cortex-A8: stop using CP15 ops
There were two chunks of Cortex-A8 code which called the
ARMv7-A CP15 operations; get rid of them, helping prepare
to remove those methods completely:

 - post_debug_entry() can use the mrc() method to read
   its two registers.

 - write_memory() can use dpm->instr_write_data_r0() to
   flush the ICache and DCache ... doing it this way is
   actually faster since it reduces per-write overhead.

Note that the mrc() method parameters are re-ordered with
respect to the ARM instruction documentation, so that part
can be confusing.

Cleaned up the layout and comments in those areas a bit.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 00:48:40 -08:00
Øyvind Harboe 51e9b25c9a main: invoke jtag_interface_quit() explicitly
There is no particular reason to invoke jtag_interface_quit()
on the atexit() handler, it just makes the code more obtuse
and stops other legitimate usage of atexit().

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-01 07:51:26 +01:00
Zachary T Welch 330733eadf improve command prohibition error report
Ensures that the correct information gets displayed, depending on the
mode of the command being denied.  Fixes misreporting all commands as
needing to run "before 'init'".
2009-11-30 20:54:40 -08:00
David Brownell 892604bc7e XScale: restore_context() cleanup
Clean up two aspects to this routine:  bad naming, since it
doesn't restore the context, just the banked registers; and
excess indentation for the bulk of the code.

Also make some of its call sites stash the function's return
code; someday they should use it for error checking.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-30 19:14:19 -08:00
David Brownell da7c202b57 XScale: context restore, cleanup/bugfix
This "loop over all registers" routine shared the same mess as
full_context() in terms of dozens of needless number_to_mode()
calls.  Fix that, and comments, with related cleanup.

The misnamed xscale_restore_context() had a related bug.  It
was restoring the *WRONG REGISTERS* ... always from whatever
the current mode was, instead of using the copy from whichever
register bank it was trying to restore.  (But it marked the
intended register as having been restored...)  Fixed that.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-30 19:14:19 -08:00
Zachary T Welch 8fc5a9a5e9 remove interp global variable!
Finish removing references to the 'interp' global variable from the
command module, encapsulating all reference via command_context.

Eliminates use of the global entirely, so it can be removed.  Hurrah!
2009-11-30 16:29:34 -08:00
Zachary T Welch cbc894ed7b command output capture: do not use interp global
Adds a log_capture_state structure to pass to the log capture
callback used by the command module.  Ensures that the capture occurs
in the proper context.
2009-11-30 16:29:34 -08:00
Zachary T Welch 7b2906de24 do not extern 'interp' from command.c
Adds 'interp' field to command_context, chasing the few remaining
references to the global variable outside of the command module.
2009-11-30 16:29:34 -08:00
Zachary T Welch 8e8a359af2 target: avoid using interp global variable
Adds 'interp' to target_event_action structure to avoid using the
global variable of the same name.
2009-11-30 16:29:34 -08:00
Zachary T Welch e1ee270265 jtag: avoid using interp global variable
Adds 'interp' field to jtag_tap_event_action structure to avoid
using the global variable of same name.
2009-11-30 16:29:34 -08:00
Zachary T Welch be65f497f5 fix foo command group help messages
Splits the old help strings to provide proper usage as well.
2009-11-30 16:29:34 -08:00
Zachary T Welch 5dd6457d2c make syntax errors respond with 'usage'
The 'help' text will become more verbose, so its entire text will be
far more than desired when you only borked your syntax.  The usage
still allows the commands to be looked up for more help.
2009-11-30 16:29:34 -08:00
Zachary T Welch 3d204ec66a move improperly located documentation
Somehow, the comment block for command handlers ended up associated
with the output_handler.  Move it to the command_handler_t declaration.
2009-11-30 16:29:34 -08:00
Zachary T Welch bc9ae74073 improve command_done() API and docs
command_done() does not need to return an error, but it needed
Doxygen comment.  Provide some for copy_command_context as well.

Note: this audit revealed some potential bugs with the command context
implementation.  There was a reason that commands were added at the
end of the list.  Shallow copying of command_context means that
the list is shared between them.  And commands added at the top-level
before the pre-existing commands will not be available in the shared
context as they were before.  Yikes!

Fortunately, this does not seem to occur in general use, as
'add_help_text' gets registered in startup.tcl and claims the first slot
in my own test cases.  Thus, it seems that we have been masking the issue
for now, but it shows the need for further architectural improvement in
the core command module.
2009-11-30 16:29:34 -08:00
Zachary T Welch c0630d8a58 only display usable commands in help
With the ability to defer 'init', users can access the help system while
still in CONFIG mode.  This patch omits commands from the help and usage
list when they cannot be run in the current command mode, making it much
easier to see what can be done at a given time.
2009-11-30 16:29:24 -08:00
Zachary T Welch cee1f39f18 allow deferal of init
Adds 'noinit' command to prevent OpenOCD from running 'init' at the end
up startup, allowing it to be given from telnet or TCL.  This provides
the old behavior by default, and users can add this command to their
scripts to get the new behavior.
2009-11-30 16:29:24 -08:00
Zachary T Welch 64653b0bbb move server_init() to openocd_main()
Moves the telnet and TCL server startup to server_init(), moving their
respective command registration in to server_register_commands().
Adds proper error checking for these particular startup processes.

Moves the core server startup to openocd_main(), improving related error
checking and preparing to defer 'init'.
2009-11-30 16:29:24 -08:00
Zachary T Welch ec6c1962c2 improve gdb_init() sequence
Rework gdb_init to create flexible APIs (gdb_target_add_{one,all}) and
static helper (gdb_target_start) for starting GDB services.  Eliminates
duplicated code and provides general mechanisms for adding GDB services.
The 'init' command is updated to call the new API, and later patches can
decouple its policy of adding all targets therein.

Provides the new capability to use both piped and TCP servers when
multiple targets are defined.  The first target fills the pipe, and
others will be started on TCP ports (unless disabled, i.e. gdb_port=0).
2009-11-30 16:29:24 -08:00
Øyvind Harboe 2264270fe4 zy1000: keep up with changes to command structure
Add missing COMMAND_REGISTRATION_DONE.

For now the command syntax for zy1000 needs to be compatible
across 0.3/0.4, the world outside OpenOCD interfaces to
zy1000 using the old syntax. Post 0.4 release(0.4.1 even)
I'll switch to subcommand scheme.

Switch to subcommands post 0.3 lifecycle.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-30 08:54:52 +01:00
David Brownell 5219b35be6 XScale: clean up full_context() (#2)
Streamline the loop by continuing as soon as we know there's no
work to be done; this lets us un-indent almost everything.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-29 13:06:12 -08:00
David Brownell 8c8e53baf6 XScale: clean up full_context() (#1)
When fetching all the registers, XScale was doing various stupid
things like calling number_to_mode() a few dozen times instead of
just once, and mapping access to each register three times (again,
instead of just once).  Stop that.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-29 13:04:56 -08:00
David Brownell e456da073a XScale: debug entry uses new register mapping
Use the new mapping interfaces in the debug entry path.
SPSR and the banked registers now have smaller and faster
accessors ... use them.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-29 12:58:30 -08:00
Marek Vasut 8c2846ed45 create target/pxa3xx.cfg
[dbrownell@users.sourceforge.net; remove pxa255 comment]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-29 12:57:05 -08:00
Marek Vasut 17b7600a59 XScale: initial PXA3xx support
[dbrownell@users.sourceforge.net: user's guide; variant param is optional]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-29 12:57:05 -08:00
David Brownell 73ec6d9b89 ARM11: fix warning on cygwin
Previous version of JTAG_DEBUG() macro hid this bug.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-29 09:14:52 -08:00
David Brownell 3debd59c5e bugfix: 'init' changes state, not main()
Code other than main() may invoke "init".  When it does so,
customized handlers may need to run ... so make sure the
command context state is updated before they do so.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-28 23:11:31 -08:00
lementec fabien b0858e89c7 fix s3c24xx device command helper
Returns the common structure for the s3c24xx device, which was
somehow nuked during past cleaning efforts.
2009-11-28 15:52:03 -08:00
David Brownell a398c85de7 Cortex-M3: don't chain "struct arm" commands
Those commands presume support for the "classic" set of CPU
modes (FIQ, supervisor, IRQ, etc) ... which aren't supported
by the ARMv7-M or ARMv6-M architectures.  They also presume
a "struct arm" base type, which this code doesn't use.

We haven't cleaned up the register handling enough to be able
to share any of those "base" methods.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-28 14:19:45 -08:00
Zachary T Welch 01f93137c4 add 'nonce' nand driver
The nonce NAND driver provides a no-op implementation useful for
testing the system independently of any driver side-effects.
2009-11-28 13:00:39 -08:00
Zachary T Welch cdfdcb2854 add more stub handlers to testee target
Prevent everything from crashing when exercising various commands.
2009-11-28 13:00:39 -08:00
Zachary T Welch 070259cadb explode tcl_target_func into many handlers
Eliminate the monolithic tcl_target_func by registering each of its
commands using the new chained command registration mechanism.

Also chains the target's commands under the CPU command, though these
may not work properly without some further modification.
2009-11-28 13:00:39 -08:00
Zachary T Welch cb8d567b75 split jim_target into multiple handlers
The 'target' command group was implemented using its own command
dispatching, which can be eliminated by using the new chained command
registration mechanism.  This patch splits the jim_target() function
into individual handlers, which makes them to be visible to the help and
usage commands.  These one-trick handlers are much easier to understand.
2009-11-28 13:00:39 -08:00
Zachary T Welch f8a62fb9c6 split jim_newtap_cmd into pieces
Moves the ID and IR-related option parsing to static helpers, removing
two levels of indent.
2009-11-28 13:00:39 -08:00
Zachary T Welch 7124be8247 improve jtag_tap_configure
Splits bulk of the jtag_tap_configure into jtag_tap_configure_event,
removing three or four levels of indentation in the process.
The resulting code was stylistically improved in other ways, but it
should be functionally identical.
2009-11-28 13:00:39 -08:00
Zachary T Welch 4ff5eda576 improve jtag_tap_handle_event indentation
Use 'continue' to reduce identation levels and superfluous logic.
2009-11-28 13:00:39 -08:00
Zachary T Welch 0377e5b54d begin moving JTAG jim handlers/helpers
Moves the tertiary jim handlers and required static helpers to the top
of tcl.c, defining them in a new registration array that is chained in
both the top-level context and under the jtag command.  The top-level
commands can be removed at some point in the future to reduce clutter.
2009-11-28 13:00:39 -08:00
Zachary T Welch c4992c6d86 split jim_jtag_command into multiple handlers
Explodes the 'jtag' into separate command handlers, which are easier
to understand and extend.  Makes the code much easier to understand,
though further simplifications are possible.  This patch tries to
minimize the noise when viewed with 'git diff -w'.

Gives these commands improved built-in help and usage information.
2009-11-28 13:00:39 -08:00
Zachary T Welch 2da2864632 remove redundant 'rm' command handler
Two 'rm' commands were implemented and registered.  This removes the
version that would have never been called prior to refactoring the
command registration.
2009-11-28 13:00:39 -08:00
Zachary T Welch 8795b8f9df add error checking in command_new
Adds checks for memory allocation failures.  Started to use calloc()
instead of malloc()/memset(), but I got carried away.  This kind of work
should be done throughout the tree, but it's almost hopeless at present.
2009-11-28 13:00:39 -08:00
Zachary T Welch 42e00bb379 include mode information in help text.
Extends the help output to list the valid modes for each commands.
Fixes a memory leak of the returned command_name() string.
2009-11-28 13:00:39 -08:00
Zachary T Welch fd343bea7f refactor command mode detection
Splits the check for a command's ability to run into a helper.

This also fixes a bug whereby commands that specified COMMAND_EXEC
were allowed to run during the configuration stage.  This allowed
problematic commands to be called before 'init', defeating the intention
of specifying that command mode.  With this change, the run_command()
helper denies access to handlers that should run only after 'init'
during the configuration stage.
2009-11-28 13:00:39 -08:00