Commit Graph

162 Commits

Author SHA1 Message Date
David Brownell a0edb8a328 ARM11: basic watchpoint support
Use the DPM watchpoint support; remove old incomplete stubs.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-04 18:57:31 -08:00
David Brownell f4651c869f ARM11: tweak TAP ops and debugging
Tweak scanchain 7 debug messaging:

 - show register addresses in decimal, matching ARM docs;
 - remove some pointless noise

Avoid some needless roundtrips:

 - skip SCAN_N when SCREG already holds that number (speeds up
   polling and other common operations)
 - avoid zeroing vcr twice on resume

Show the IR opcode as a label ("RESTART") too; and in decimal,
matching ARM docs.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-04 18:57:30 -08:00
David Brownell ea7a49cb9b ARM DPM: share debug reason logic
No point in both ARM11 and Cortex-A8 having private copies
of the logic sorting out e.g. DBG_REASON_WATCHPOINT.

Add and use a shared routine for this ... there's actually
a bunch more debug entry logic that could be shared, this
is just a start on that.  Note that this routine fixes a
bug observed in the ARM11 code, where some abort mode quirks
were displayed as being an unknown debug reason; and also
silences needless ARM11 chatter.

Likewise with private copies of DSCR ... add one to the DPM
struct.  Save it as part of setting DBG_REASON_* so later
patches can switch over to using that copy.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-03 16:08:04 -08:00
David Brownell 6eee0729d7 ARM11: use shared DSCR bit names
For the bits now defined in "arm_dpm.h", switch to the
shared DSCR_* symbol and remove the ARM11_DSCR_* version.

Define DSCR_INT_DIS and use it instead of the ARM11_DSCR_*
sibling symbol.  (Note:  for both ARM11 and Cortex-A8, this
should arguably be enabled by default when single stepping.)

Remove some other unused declarations in "arm11.h".

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-03 16:08:04 -08:00
Zachary T Welch 6512e5e36b change #include "time_support.h" to <helper/time_support.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "time_support.h"

the following form should be used.

	#include <helper/time_support.h>

The exception is from .c files in the same directory.
2009-12-03 04:22:52 -08:00
David Brownell d5e4e23f9a ARM11: don't expose DSCR
Remove the remaining extra copy of DSCR, and the register cache
of which it was a part.  That cache wasn't a very safe, or even
necessary, idea; it was essentialy letting debugger-private state
be manipulated by Tcl code that couldn't know how to do it right.

This makes the "reg" output of an ARM11 resemble what most other
ARM cores produce ... forward motion in the "make ARM11 work like
the rest of the ARM cores" Jihad!
2009-12-02 23:08:43 -08:00
David Brownell f0c3e7011f ARM11: store a clean copy of DSCR
Just store a clean copy of DSCR in the per-CPU struct, so we
trivially pass a pointer to a recent copy.  This replaces the
previous "last_dscr" and cleans up most of the related calling
conventions ... but it doesn't remove the other DSCR copy.
2009-12-02 23:08:43 -08:00
David Brownell 62dd15d78f ARM11: don't expose WDTR
Don't expose the WDTR register through the register cache any
more.  If anyone wants Tcl scripts to be able to use DCC based
communication with app code in the target, this wouldn't do it.

Bugfix:  don't trust the Tcl-accessible version of DSCR to
flag whether WDTR needs to be restored when resuming.
2009-12-02 23:08:42 -08:00
David Brownell 7e18d96d03 ARM11: don't expose RDTR
Don't expose the RDTR register through the register cache any
more.  If anyone wants Tcl scripts to be able to use DCC based
communication with app code in the target, this wouldn't do it.

Bugfix:  don't trust the Tcl-accessible version of DSCR to
flag whether RDTR needs to be restored when resuming.
2009-12-02 23:08:42 -08:00
David Brownell 6ec5b9c674 ARM11: streamline debug entry
Streamline arm11_on_enter_debug_state() entry:

 - It should handle the standard updates:
    * target->debug_reason
    * target->state

 - Don't waste time re-reading DSCR; just pass it in

Also rename the routine to "arm11_debug_entry()", matching the
convention used elsewhere in OpenOCD.
2009-12-02 23:08:42 -08:00
David Brownell 1d29440a9c ARM11: remove arm11->target
Don't need/want arm11->target; we have arm11->arm.target instead.
Also remove some unused watchpoint stuff.
2009-12-02 23:08:42 -08:00
David Brownell c2af99d471 ARM DPM: tweak initialization
Move the initial breakpoint/watchpoint disable calls to
arm_dpm_initialize(), and start using that routine.  This
split helps with arm11 support.
2009-12-02 23:08:42 -08:00
David Brownell 66ca84b581 ARM: core DPM support for watchpoints
This is a NOP unless the underlying core exposes two new methods, and
neither of the two cores using this (ARM11xx, Cortex-A8) do so yet.

This patch only updates those cores so they pass a flag saying whether
or not to update breakpoint and watchpoint status before resuming; and
removing some now-needless anti-segfault code from ARM11.  Cortex-A8
didn't have that code ... yes, it segfaulted when setting watchpoints.

NOTE:  this uses a slightly different strategy for setting/clearing
breakpoints than the ARM7/ARM9/etc code uses.  It leaves them alone
unless it's *got* to change something, to speed halt/resume cycles
(including single stepping).

ALSO NOTE:  this under-delivers for Cortex-A8, where regions with size
up to 2 GBytes can be watched ... it handles watchpoints which ARM11 can
also handle (size 1/2/4 bytes).  Should get fixed later.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-01 21:47:45 -08: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 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 4d2750e571 ARM11: write_memory() avoids increment check
When writing to a chip's "reset yourself" register, the ARM11 code
was reporting a spurious failure.  Just don't bother checking for
correctly incremented pointers given single-unit writes ... it's
a bit faster that way too.  (Reads should likely do the same thing.
For that matter, such checks are usually just a waste...)

Shrink an overlong parameter name, and associated lines'o'code.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-27 18:40:37 -08:00
Zachary T Welch 66ee303456 remove target_type register_command callback
Uses chaining of command_registration structures to eliminate all
target_type register_callback routines.  Exports the command_handler
registration arrays for those target types that are used by others.
2009-11-24 21:37:36 -08:00
Zachary T Welch b40f265f9c arm11: use register_commands() 2009-11-24 21:37:35 -08:00
Zachary T Welch 833e7f5248 use COMMAND_REGISTER macro
Replaces direct calls to register_command() with a macro, to allow
its parameters to be changed and callers updated in phases.
2009-11-24 21:37:29 -08:00
David Brownell 3efc99b34a ARM11: remove old R0..R15/CPSR code
This finishes the basic switchover to the new register code,
for everything except the debug registers.  (And maybe we
shouldn't have a cache for *those* which works this way...)

The context save/restore code now uses the new code, but
it's in a slightly different sequence.  That should be fine
since the R0/PC/CPSR stuff is all that really matters (and
if we can update those, we can update the rest).

Now there's no longer a way any code can be confused about
which copy of "r1" (etc) to use.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 01:27:29 -08:00
David Brownell ec64acf536 ARM11: use standard run_algorithm()
As with single stepping, the previous stuff was needed because
the ARM11 code wasn't using the standard ARM base type and
register access ... but now those mechanisms work, so we can
switch out that special-purpose glue, in favor of the more
thoroughly tested/capable "standard" code.

Fixes a bug in the resume() implementation:  it wasn't handling
two of its arguments correctly, preventing the "flash erase_check"
algorithm from working.  (This code needs a *subsequent* update
for correct register handling, though... removing the confusion
about which "r2", for example, to use.)

This should resolve some "FIXME" comments too, for Thumb and
processor mode support.  It also gets rid of a nasty exit()
call; servers should only have *clean* shutdown paths.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 01:27:24 -08:00
David Brownell bf3abc48f0 ARM11: use standard single step simulation
The previous stuff was needed because the ARM11 code wasn't using
the standard ARM base type and register access ... but now those
mechanisms work, so we can switch out that special-purpose glue.

This should resolve all the "FIXME -- handle Thumb single stepping"
comments too, and properly handle the processor's mode.  (Modulo
the issue that this code doesn't yet handle two-byte breakpoints.)

Clarify the comments about the the hardware single stepping.  When
we eventually share breakpoint code with Cortex-A8, we can just make
that be the default on cores which support it.  We may still want an
override command, not just to facilitate testing but to cope with
"instruction address mismatch" not quite being true single-step.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 01:27:21 -08:00
David Brownell 5eb893ec41 ARM11: partial support for standard ARM register interfaces.
This provides "standard" ARM register support -- with twenty or
more shadow registers on top of what this code now handles, but
properly associated with the various core modes -- parallel to
the current register code.  That is, the current code is stilil
managing the "current" registers; the new code shadows them.

You can see all the registers with "arm reg", modify the shadows
like "r8_fiq" or "sp_abt" with "reg", and see them get properly
written back when you step.  (Just don't do that with any of the
registers managed by the "old" code ...)

It also switches to using more standard code, relying on those
standard registers, in two places:  (a) the poll status display,
which now shows core state (ARM/Thumb/...) and mode (Supervisor,
IRQ, etc); and (b) GDB register access.

So it's not a full migration, there are warts -- every place that
touches the old register cache is a potential bug -- but it's a
small more-or-less-comprehensible step that's even somewhat useful.
Later patches complete the migration.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 01:27:16 -08:00
David Brownell 6ff33a4ee8 ARM11: remove register "history" debug stuff
This was a private mechanism to snapshot registers before leaving
debug state, and then on reentry to optionally display what changed.
It was coupled to the private register cache, which won't be sticking
around in that form for much longer.  Remove (instead of teaching
it how to handle *all* the registers).

(The idea is interesting, but we ought to be able to implement
this in a generic way.  Ideally through Tcl scripts that can
automatically be invoked following debug entry...)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 00:14:15 -08:00
David Brownell b8b1353dd7 ARM11: remove unused state and exports
For now there's no point in saving this stuff after examine()
checks it out as OK.  Ditto exporting symbols that aren't
used outside of the module which defines them.  In fact, those
two things needlessly complicate the code...

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 15:51:16 -08:00
David Brownell fa9b0e2167 ARM11: macro cleanup
Make this code look more like the rest of the OpenOCD code.

 - Use calloc() directly, not NEW() ... and fix some potential
   memory leaks while we're at it.

 - Remove FNC_INFO ... it's a NOP that just clutters things,
   and it's trivial for developers to add tracing as needed.

 - Replace FNC_INFO_NOTIMPLEMENTED with LOG_WARNING calls;
   ditto.  And stop having those call sites wrongly succeed!

 - Waste less space with the CHECK_RETVAL() macro.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 15:50:24 -08:00
David Brownell fa618cc74d ARM11: remove needless string format #ifdeffery
We don't need to use size_t in these places; so it's easy
to be rid of the need for this #ifdef and its MS-derived
portability problems.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 10:27:29 -08:00
David Brownell 60a2d85af1 ARM11: remove disabled register hooks
Minor cleanup of ARM11 register handling:  remove disabled
register hooks.  This should all be handled by shared code,
and this stuff is just clutter.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 03:36:24 -08:00
Zachary T Welch 7e4adfe1c5 add handle_command_parse_bool command helper
Rewrite arm11_handle_bool to provide a generic on/off command helper.

Refactors COMMAND_PARSE_BOOL to use new command_parse_bool helper,
which gets reused by the new command_parse_bool_any helper.
This later helper is called by the new command helper function to
accepts any on/off, enable/disable, true/false, yes/no, or 0/1 parameter.
2009-11-18 15:51:07 -08:00
David Brownell bbebfd9e13 ARM: add "core_type" field to "struct arm"
It's used to flag cores with the "TrustZone" extension,
and is used in subsequent patches to set up support for
the registers shadowed by its new secure monitor mode.

The ARM1176 and Cortex-A8 both support this new mode.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-18 13:22:27 -08:00
David Brownell 181d401d59 ARM: add is_arm_mode()
Add a new is_arm_mode() predicate, and use it to replace almost
all calls to current armv4_5_mode_to_number().

Eventually those internal mode numbers should vanish... along
with their siblings in the armv7a.c file.

Remove a handful of superfluous checks ... e.g. the mode number
was just initialized, or (debug entry methods) already validated.

Move one of the macros using internal mode numbers into the only
file which uses that macro.  Make the tables manipulated with
those numbers be read-only and, where possible, static so they're
not confused with part of the generic ARM interface.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-17 23:50:26 -08:00
David Brownell d6c8945662 ARM: only use one set of dummy FPA registers
All ARM cores need to provide obsolete FPA registers in their
GDB register dumps.  (Even though cores with floating point
support now generally use some version of VFP...)

Clean up that support a bit by sharing the same dummy registers,
and removing the duplicate copies.  Eventually we shouldn't need
to export those dummies.

(This makes the ARMv7-M support include the armv4_5 header, and
cleans up related #includes, but doesn't yet use anything from
there except those dummies.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-17 23:50:17 -08:00
Zachary T Welch 23402315ce command_handler: change 'args' to CMD_ARGV
This patch converts all instances of 'args' in COMMAND_HANDLER routines
to use CMD_ARGV macro.
2009-11-17 11:38:07 -08:00
Zachary T Welch 7bf1a86e47 command_handler: change to 'argc' to CMD_ARGC
This patch converts all instances of 'argc' in COMMAND_HANDLER routines
to use CMD_ARGC.
2009-11-17 11:38:06 -08:00
David Brownell f4788652e4 target: simplify register get/set ops
No need to indirect from registered integers to pointers.
Just stash the pointers directly in the register struct,
and don't even bother registering.

This is a small code shrink, speeds register access just
a smidgeon, and gets rid of another rude exit() path.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-17 09:06:45 -08:00
David Brownell a2df544fd9 target: remove some more duplicate includes
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-17 01:06:16 -08:00
David Brownell 6030f2ca03 ARM11: fewer exit() calls
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 17:51:55 -08:00
David Brownell d7d857a189 ARM11: register (most) standard ARM commands
Have ARM11 register the "standard" ARM commands.  For now, only
disassembly really works.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 16:36:12 -08:00
David Brownell 9a98e83b49 target: less implicit inclusion of "etm.h"
Don't include it in more headers than necessary; just
use it in the few files that actually need it.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 10:19:33 -08:00
Zachary T Welch dc1685ca25 move ARRAY_SIZE macro to types.h
The ARRAY_SIZE macro was defined in several target files, so move it
to types.h.

This patch also removes two other identical macros: DIM (from jtag.h)
and asizeof (from arm11.h).
2009-11-16 09:58:11 -08:00
David Brownell 8193f17c3a target: no implicit #includes of "register.h"
Same deal:  "register.h" got needlessly included all over the
place because of being in a few widely included headers.

So take it out of the header files which included it, and put
it in files which use it ... reduce needless interdependencies.

Also, don't need that extra "types.h" inclusion.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 00:35:14 -08:00
David Brownell db094c2e60 target: don't implicitly include "algorithm.h"
Most files in the tree seem to have ended up including this,
and *quite* needlessly ... only code implementing or using
downloadable algorithms actually needs these declarations.

So take it out of the header files which included it, and put
it in files which use it ... reduce needless interdependencies.

Also: "algorithm.h" doesn't need to include "types.h" again;
it already comes from a different header.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 00:35:05 -08:00
David Brownell aa7c449600 target: don't implicitly include "breakpoint.h"
Most files in the tree seem to have ended up including this,
and *quite* needlessly ... only code implementing or using
breakpoints actually needs these declarations.

So take it out of the header files which included it, and put
it in files which use it ... reduce needless interdependencies.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 00:34:57 -08:00
David Brownell 5d1a9033ab ARM11: use now-generic memory utils
Now the ARM11 cores can use the renamed arm_checksum_memory()
and arm_blank_check_memory() routines ... do so.

Sanity checked with "flash erase_check" of both NOR banks on an
OMAP2420 ... the algorithm code dumped four lines of of "poll"
status after each of almost 520 blocks (yes, *very* annoying) but
gave plausible results after producing that spam.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-15 10:35:47 -08:00
David Brownell 2280ddeea5 ARM11: fixup method table
Three changes:  remove ARM11_HANDLER() in favor of normal structure
initialization syntax; fix goofy indentation in that structure; and
don't needlessly export arm11_register_commands(), it's only called
through that method table.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-15 10:35:41 -08:00
David Brownell 9ac7cdec82 target: make "examined" flag be per-target
Previously this flag was stored in "target_type", so that for example
if there were two ARM7TDMI targets in a scan chain, both would claim
to have been examined although only the first one actually had its
examine() method called.

Move this state to where it should have been in the first place, and
hide a method that didn't need exposure ... the flag is write-once.

Provide some doxygen.  The examine() method is confusing, since it
isn't separating one-time setup from the after-each-reset stuff.  And
the ARM7/ARM9 version is, somewhat undesirably, not leaving the debug
state alone after reset ... probably more of an issue for trace setup
than for watchpoints and breakpoints.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-15 10:35:25 -08:00
David Brownell ecab0cfe25 ARM11: ETM + ETB support
Kick in ETM (and ETB) support for ARM11.  Tested on OMAP 2420,
so update that configuration.  (That's an ARM1136ejs, ETB,
OpenGL ES1.1, C55x DSP, etc.)

Also update the other ARM11 ETM + ETB targets in the tree
to set up these modules.  (Not tested.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-13 16:58:14 -08:00
David Brownell 817bf74302 ARM11: revert etmr/etmw commands
These aren't desirable, given "standard" ETM support.
Also remove the now-unused arm11_find_target().

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-13 16:56:11 -08:00
David Brownell a7f5cdf999 ARM11: switch to new "arm" base type
This will enable reusing many common ARM utilities, in
particular the ETM and ETB support.  The ARM11 support
can still be much simplified after this patch, though.

Note:  none of those common utilities kick in yet...

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-13 16:22:36 -08:00
David Brownell 04b514707f target: remove unused "bitfield" infrastructure
We have too many different registers, and too many version and
context dependent interpretations, for this type of bitfield
management to be scalable.

(Anyone who really wants bitfield interpretation *can* do that
in Tcl code...)

There are ... quite a few copies of the same ARM dummy registers.
There should eventually be one copy; this many is craziness.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-13 16:22:36 -08:00