Commit Graph

1362 Commits

Author SHA1 Message Date
Zachary T Welch
11061486b5 arm926ejs: use register_commands() 2009-11-24 21:37:35 -08:00
Zachary T Welch
509fe82b07 arm920t: use register_commands() 2009-11-24 21:37:35 -08:00
Zachary T Welch
e232dea176 arm7_9_common: use register_commands() 2009-11-24 21:37:35 -08:00
Zachary T Welch
e905fe6e75 arm720t: use register_commands() 2009-11-24 21:37:35 -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
Zachary T Welch
47cb10217a improve startup tcl scripts
Fix a couple of layering violations missed in the last round.
Add missing comment headers.
2009-11-24 21:37:29 -08:00
David Brownell
b6210907ea Cortex-A8: avoid DSCR reads
There was a lot of needless handshaking overhead in the current
Cortex-A8 DCC/ITR operations, since the status read by each step
was discarded rather than letting the next step know it.

This shrinks the handshaking by:  (a) passing status along from
previous steps, avoiding re-fetching; which enables the big win
(b) relying on a useful invariant:  that the DSCR_INSTR_COMP bit
is set after every call to a DPM method.

A "reg sp_usr" call previously took 17 flushes; now it takes just 9.
This visibly speeds common operations like entry to debug state and
stepping, as well as "arm reg" and so on.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 21:24:44 -08:00
David Brownell
e109bb6af2 Cortex-A8: hook up DPM
This replaces two versions of register access functions.  One
was commented out, and seemed to have uncertain intent.  The
other was fairly new, and helped motivate the DPM framework
once I observed that the ARM11 was doing the very same ops.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 21:24:44 -08:00
David Brownell
c008d30fe8 Cortex-A8: implement DPM
This implements the DPM interface for Cortex-A8 cores.  It
also adds a synchronization operation to the DPM framework,
which is needed by the Cortex-A8 after CPSR writes.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 21:24:44 -08:00
David Brownell
991daa03eb Cortex-A8: minor cleanup
Make various functions static, add some comments, report
vector catch as a flavor of DBG_REASON_BREAKPOINT, get
rid of needless/undesirable ARMV4_5_CORE_REG_MODE, etc.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 21:24:44 -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
caf827ee81 ARM11: implement provider for new DPM interface
This is a very thin layer over some of the current ARM11
debug TAP utilities.  The layer isn't yet hooked up.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 00:14:06 -08:00
David Brownell
e6dc927e97 ARM: new DPM interface
First version of interface for sharing code between ARMv6 and ARMv7a
debug modules ... now the architecture includes debug support.  (Not
the same as for the trimmed-down v7m or v6m though!)  This is a first
version of an interface that will let the ARM11 and Cortex-A8 support
share code, features, and bugfixes.  Based on existing code from both
of those cores.

The ARM v7-AR architecture specification calls this commonality the
"Debug Programmer's Model (DPM)", which seemed to be an appropriate
acronym -- a TLA even! -- for use in our code.  Made it so.  :)

The initial scope of this just supports register access, and is geared
towards supporting top level "struct arm" mechanisms.  Later, things
like breakpoint and watchpoint support should be included.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 00:13:58 -08:00
David Brownell
ad75af0b17 target: cope with *any* error setting a breakpoint
It's wrong to map unrecognized failure codes to success.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-24 00:13:43 -08:00
Jerry Ling
0d06a06f8b mips: fix gaffe when removing dynamic array allocation
Classic sizeof() gaffe.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-24 08:26:30 +01:00
Øyvind Harboe
eeb4276deb arm926ejs: retire cp15 commands, handled by mrc/mcr.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-23 14:02:03 +01: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
Øyvind Harboe
af7f6891e9 mips: remove dynamic arrays - reduces stack usage
Allocate working memory dynamically.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 20:23:34 +01:00
Øyvind Harboe
2d6829d698 mips: use const for code sequences
This will allow data to be allocated in read only
memory instead of on the stack. Speeds things up
and reduces stack usage.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 20:18:26 +01:00
Øyvind Harboe
5985dee35d arm11: do not use dynamic arrays
Allocate working memory dynamically, caught by checkstack.pl

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 19:57:57 +01:00
Øyvind Harboe
bcebce3ce2 arm926ejs: fix warnings
buf_set_u32() operated on an uninitialized stack
variable with non-byte boundaries, which led to
warnings about reading uninitialized stack.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 19:52:37 +01:00
David Brownell
b404b9ab57 ARM: use arm_reg_current()
Start using the arm_reg_current() call.  This shrinks and speeds
the affected code.  It can also prevent some coredumps coming from
invalid CPSR values ... the ARMV4_5_CORE_REG_MODE() macro returns
bogus registers if e.g. "Secure Monitor" mode isn't supported by
the current CPU.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 10:27:29 -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
1c619a2f12 target: make register flags "bool"
Mostly for clarity, but it also saves code and data space.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 10:27:29 -08:00
David Brownell
ab5ac33fd4 ARM: remove 'armv4_5_common_s' migration #define
Finish migrating from the old symbol to the new one.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 10:27:29 -08:00
Øyvind Harboe
aacc5b583c target: reduce stack usage
4096 byte buffer allocated dynamically. Better
for embedded OS's.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 18:58:42 +01:00
Øyvind Harboe
964c3639e2 embedded: do not allocate large temporary structures on stack
With -O3 when inlining aggressively the total stack usage will
be the sum of many fn's, which can easily get out of hand.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 13:38:42 +01:00
Øyvind Harboe
31da0003dc embedded: save stack
and also do not recaluate the crc32_table upon
every invocation.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 13:38:42 +01:00
David Brownell
dd9894f481 ARM: arm_set_cpsr() handles T and J bits
Have arm_set_cpsr() handle the two core state flags, updating
the CPU state.  This eliminates code in various debug_entry()
paths, and marginally improves handling of the J bit.

Catch and comment a few holes in the handling of the J bit on
ARM926ejs cores ... it's unlikely our users will care about
Jazelle mode, but we can at least warn of Impending Doom.  If
anyone does use it, these breadcrumbs may help them to find
the right path through the code.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 03:41:14 -08:00
David Brownell
ff810723e0 ARM: define two register utilities
Define arm_reg_current() ... returning handle to a given register,
and encapsulating the current mode's register shadowing.  It's got
one current use, for reporting the current register set to GDB.
This will let later patches clean up much ARMV4_5_CORE_REG_MODE()
nastiness, saving a bit of code.

Define and use arm_set_cpsr() ... initially it updates the cached
CPSR and sets up state used by arm_reg_current(), plus any SPSR
handle.   (Later: can also set up for T and J bits.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 03:38:34 -08:00
David Brownell
5706fd7860 ARM: simplify CPSR handling
Stash a pointer to the CPSR in the "struct arm", to help get rid
of the (common) references to its index in the register cache.

This removes almost all references to CPSR offsets outside of the
toplevel ARM code ... except a pair related to the current ARM11
"simulator" logic (which should be removable soonish).

This is a net minor code shrink of a few hundred bytes of object
code, and also makes the code more readable.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-22 03:37:21 -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
David Brownell
69c7519562 ARM: pass 'struct reg *' to register r/w routines
Implementations need to access the register struct they modify;
make it easier and less error-prone to identify the instance.
(This removes over 10% of the ARMV4_5_CORE_REG_MODE nastiness...)

Plus some minor fixes noted when making these updates:  ARM7/ARM9
accessor methods should be static; don't leave CPSR wrongly marked
"dirty"; note significant XScale omissions in register handling;
and have armv4_5_build_reg_cache() record its result.

Rename "struct armv4_5_core_reg" as "struct arm_reg"; it's used
for more than those older architecture generations.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-20 16:27:24 -08:00
David Brownell
85fe1506a2 ARM7/ARM9: remove old "debug commands"
Remove two commands that were documented as "debug commands"
and where "you probably don't want to use this".   We never
intended to support them, and at least one problem report
boiled down to using this when it shouldn't have been used.

Update the docs on the existing register commands to talk a
bit more about register access and cache behavior.  (Those
debug commands existed largely to *bypass* the cache.)  And
fix some minor doc goofs that snuck in with recent changes,
renaming "armv4_5" as "arm" and "arm9tdmi" as "arm9".

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-20 16:21:29 -08:00
David Brownell
a1777fc649 Cortex-A8: better context restore
The previous version never wrote dirty registers
for non-current CPU modes ... fix that.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 19:03:12 -08:00
David Brownell
d7760352e8 Cortex-A8: mode support
We *should* be able to read and write registers in any core mode,
instead of being stuck with whatever mode the core was when we
entered debug state.  This patch makes them work.

Note that the current restore_context() only handles the current
mode; writing to other-mode registers is a NOP without a followup
patch fixing that.  Also, that SPSR access needed some bugfixes;
it was confused with CPSR.

Secure monitor mode also seems dubious; there's probably more to
be done before that's sufficiently understood by the debugger.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 19:03:02 -08:00
David Brownell
71cde5e359 target: create/use register_cache_invalidate()
Create a generic register_cache_invalidate(), and use it to
replace three all-but-identical core-specific routines:

 - armv4_5_invalidate_core_regs()
 - armv7m_invalidate_core_regs
 - mips32_invalidate_core_regs() too.

Make cache->num_regs be unsigned, avoiding various errors.

Net code shrink and simplification.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 19:02:10 -08:00
David Brownell
8f446fcf67 ARM: remove per-register malloc
Just pre-allocate memory for the cached register value.
Shrinks heap overhead; increases locality-of-reference.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 13:23:49 -08:00
David Brownell
cbc13187c3 ARM: streamline register init
Combine register names with other per-register data into a
single template structure.  This saves space, and makes it
easier to change how registers get handled (by shrinking
the number of places that care about cache indices).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 13:23:08 -08:00
David Brownell
e3ed06579b Cortex-A8: parts of examine() run just once
The examine() method has some conceptual breakage.  Cope
with it by manually splitting out the run-once parts from
the after-each-reset parts ... this gets rid of memory
leaks and speeds up resets after the first one.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 10:47:31 -08:00
David Brownell
195ce5eb27 ARMv7-A: use standard ARM core states
We don't want an ARMv7-specific core state enumeration just to
add ThumbEE state.  Update the generic stuff to handle that,
and replace the V7-specific bits with it.

For Cortex-A8:  on debug entry, check both the T and J bits
instead of just the T bit.  When the J bit is set, set the
right state and warn appropriately.

(And while we're at it, move the generic arm struct to the front
of the v7a structure, for somewhat better code generation.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 02:33:01 -08:00
David Brownell
f320b12289 ARMv7-A: use standard ARM core_mode symbols
The only way ARMv7-A modes differ from ARMv4/ARMv5 flavors
is that v7-A is allowed to include "Secure monitor" support.
That's now handled by our standard top-level ARM code ... so
phase out the stuff that's specific to ARMv7-A.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-19 02:31:34 -08:00
Zachary T Welch
c0d14dc7f1 remove fast command and jim_global_long
Removing the fast command eliminates the fast_and_dangerous global,
which was used only by arm7_9_common as an initializer.  The command
is not called in the tree; instead, more explicit commands are used.

The jim_global_long function was not used anywhere in the tree.
2009-11-18 15:51:07 -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