Commit Graph

3332 Commits

Author SHA1 Message Date
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
5416c525d4 flash: dynamically allocate working storage
Allocate working memory rather than using stack.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 19:14:06 +01: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
7daec5a0ce todo: add tip on how to identify excessive stack usage
Use dynamic allocations for working memory rather than stack.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 18:50:57 +01:00
Øyvind Harboe
5c4a73d0d8 zy1000: un-break uart command after command handler refactoring
Switched it to jim command to insulate it from command refactoring.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 13:46:42 +01:00
Øyvind Harboe
700a60ec57 embedded: reduce stack usage
Allocate working structures on stack to avoid issues with
path lengths + reduce stack usage.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 13:38: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
Øyvind Harboe
808e53368c zy1000: fix breakage in command parsing code for power command
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 13:38:42 +01:00
Øyvind Harboe
d1fbcc3589 build: fix breakage in building bin2char
bin2char build relied on $(builddir) which is not defined
for arm-elf X builds at least.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-22 13:35:13 +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
Zachary T Welch
b58239e4c0 jtag: remove useless forward declarations
Removes some more useless forward declarations from a few JTAG drivers.
Moves interface and bit-bang structure defitions below their callbacks.
2009-11-21 10:20:56 -08:00
Zachary T Welch
c46c2d77e6 allow jtag interfaces to lack commands
Allow JTAG interface drivers to skip registering an register_commands
callback when it will just be empty.
2009-11-21 10:19:47 -08:00
Andreas Fritiofson
425e43d9d1 show script search dirs in debug log
Add this to ease debugging why the standard scripts aren't
found on the default script search path in some build/install
enviroments. Especially on Windows it's not straight forward
where openocd actually looks for the scripts.

Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-21 09:30:09 -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
Zachary T Welch
7a67aae93c maintain command lists in sorted order
Use insertion sort to the command link lists.  The only practical effect
of this is to order the output of the new 'help' command.
2009-11-20 15:03:41 -08:00
Zachary T Welch
a19aaf9136 add add_help_text command handler
Rewrite means for scripts to register help text for commands.  These
cause the new commands to be stored in the command heirarchy, with
built-in commands; however, they will never be invoked there because
they do not receive a command handler.  The same trick is used for
the Jim commands.

Remove the old helpers that were used to register commands.
2009-11-20 15:03:35 -08:00
Zachary T Welch
e5b0a69ba9 provide command context during cmd_init
For the startup.tcl code to use built-in commands, the context must be
associated with the interpreter temporarily.  This will be required to
add help text.
2009-11-20 14:52:56 -08:00
Zachary T Welch
5458fef43c improve 'help' command
Rewrites 'help' command in C, using new 'cmd_help' for display.  Adds the
built-in 'help' COMMAND_HANDLER to provide better output than the
TCL-based script command (e.g. heirarchical listing of commands).

The help string is stored in the command structure, though it conitnues
to be pushed into the Jim environment.  The current idiomatic usage
suggests the addition of a usage field as well, to provide two levels
of detail for users to consume (i.e. terse usage list, or verbose help).
2009-11-20 14:52:56 -08:00
Zachary T Welch
82449e2d60 factor help script command into parts
Creates a helper function, cmd_help, which displays the help string
for a single command.  Presently, it is called from the loop in help.

The routine has been extended to allow indentation of command groups,
so an improved help command can improve the display of information.
2009-11-20 14:52:56 -08:00
Zachary T Welch
9e9633c6b9 refactor command registration
Refactors the command registration to use helpers to simplify the code.
The unregistration routines were made more flexible by allowing them
to operate on a single command, such that one can remove all of a
commands children in one step (perhaps before adding back a 'config'
subcommand that allows getting the others back).  Eliminates a bit
of duplicated code and adds full API documentation for these routines.
2009-11-20 14:52:56 -08:00
Zachary T Welch
73c6e3bb18 change command_find helper interface
Avoid requiring double pointers where a single would suffice.
2009-11-20 14:52:56 -08:00
Zachary T Welch
67c29d9935 factor script_command argv allocation
Splits argument allocation out from script command, reusing free() code.
2009-11-20 14:52:56 -08:00
David Brownell
7b77b3c5d1 target.cfg: TAP id for Hilscher netX 500
Based on email from "Martin Kaul <martin.kaul@leuze.de>".

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-20 12:21:00 -08:00
Zachary T Welch
153848e6cc fix flash/nand name parsing
Start driver.num check from end, and make sure the numeric part is
actually a number.  Fix problems trying to parse bank names.
2009-11-20 07:10:55 -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
Dean Glazeski
31fb7788a6 NAND verify doesn't advance.
Fix to move the device address up as the contents are verified.

Signed-off-by: Zachary T Welch <zw@superlucidity.net>
2009-11-19 15:25:18 -08:00
Zachary T Welch
4b18ef15a3 document new flash syntax
Updates the user documentation with the new syntax for defining
flash and nand banks.
2009-11-19 13:39:42 -08:00
Zachary T Welch
3e1f5e7c64 update 'nand device' usage in scripts
Add $_FLASHNAME variable to update 'nand device' command syntax.
2009-11-19 13:39:41 -08:00
Zachary T Welch
664ba309d5 add support for naming NAND banks
Requires users to name their nand banks, allowing them to be used
instead of bank numbers in script commands.
2009-11-19 13:39:41 -08:00
Zachary T Welch
59d4466b55 refactor handle_nand_device_command
Move bulk of for-loop to a new static command helper function.

Adds handle_nand_list_drivers command handler, registered as
'nand drivers'.

Improves command help text and error reporting.
2009-11-19 13:39:41 -08:00
Zachary T Welch
2dfa5e9c84 update 'flash bank' usage in scripts
Sets $_FLASHNAME to "$_CHIPNAME.flash" and passes it as the
first argument to 'flash bank'.
2009-11-19 13:39:41 -08:00
Zachary T Welch
fd654c8a3e add support for naming flash banks
Requires users to name their flash banks, allowing them to be used
instead of bank numbers in script commands.
2009-11-19 13:39:41 -08:00
Zachary T Welch
dd44ae18b4 refactor handle_flash_bank_command
Move variables to point of first use, reducing their scope.
Add driver_name temporary to help arguments be changed later.

Eliminates the useless 'found' variable, changing the code to terminate
the loop immediate and return its success.
2009-11-19 13:39:41 -08:00
Zachary T Welch
ff25e76bad rename flash and nand command helpers
After adding support for referencing banks by name, renames
the COMMAND_HELPERs appropriately:
flash_command_get_bank_by_num  -> flash_command_get_bank
nand_command_get_device_by_num -> flash_command_get_device
2009-11-19 13:39:41 -08:00
Zachary T Welch
870b8c0455 allow flash/nand banks commands to accept names
Add get_flash_bank_by_name (and get_nand_device_by_name) helpers
to retrieves struct flash_bank * (struct nand_device *) given a
driver name and an (optional) driver-specific bank index.

These are used to extend flash_command_get_bank_by_num (and
nand_command_get_device_by_num) to allow all flash (nand) commands to
reference defined banks by name, not just by number.

To avoid some code duplication, add the flash/common.[ch] files to hold
functionality common to both types driver.  The first two methods are
helpers for the above routines to find a bank specified by a "name" or
"name.index" string.  get_flash_name_index() finds the '.index' portion,
while flash_driver_name_matches() performs the string portion matching.
2009-11-19 13:39:41 -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
Dean Glazeski
c049033fde nand_fileio_parse_args parses wrong param for size
This changes the size parameter from argv[2] to argv[3], which is what it's
supposed to be.

Signed-off-by: Zachary T Welch <zw@superlucidity.net>
2009-11-19 07:00:30 -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