openocd.git
11 years agoprovide command context during cmd_init
Zachary T Welch [Fri, 20 Nov 2009 17:11:39 +0000 (09:11 -0800)]
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.

11 years agoimprove 'help' command
Zachary T Welch [Thu, 19 Nov 2009 14:48:37 +0000 (06:48 -0800)]
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).

11 years agofactor help script command into parts
Zachary T Welch [Thu, 19 Nov 2009 14:44:58 +0000 (06:44 -0800)]
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.

11 years agorefactor command registration
Zachary T Welch [Thu, 19 Nov 2009 16:38:17 +0000 (08:38 -0800)]
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.

11 years agochange command_find helper interface
Zachary T Welch [Thu, 19 Nov 2009 15:26:28 +0000 (07:26 -0800)]
change command_find helper interface

Avoid requiring double pointers where a single would suffice.

11 years agofactor script_command argv allocation
Zachary T Welch [Thu, 19 Nov 2009 00:34:34 +0000 (16:34 -0800)]
factor script_command argv allocation

Splits argument allocation out from script command, reusing free() code.

11 years agotarget.cfg: TAP id for Hilscher netX 500
David Brownell [Fri, 20 Nov 2009 20:21:00 +0000 (12:21 -0800)]
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>
11 years agofix flash/nand name parsing
Zachary T Welch [Fri, 20 Nov 2009 02:11:30 +0000 (18:11 -0800)]
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.

11 years agoCortex-A8: better context restore
David Brownell [Fri, 20 Nov 2009 03:03:12 +0000 (19:03 -0800)]
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>
11 years agoCortex-A8: mode support
David Brownell [Fri, 20 Nov 2009 03:03:02 +0000 (19:03 -0800)]
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>
11 years agotarget: create/use register_cache_invalidate()
David Brownell [Fri, 20 Nov 2009 03:02:10 +0000 (19:02 -0800)]
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>
11 years agoNAND verify doesn't advance.
Dean Glazeski [Thu, 19 Nov 2009 23:12:23 +0000 (17:12 -0600)]
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>
11 years agodocument new flash syntax
Zachary T Welch [Wed, 18 Nov 2009 11:16:37 +0000 (03:16 -0800)]
document new flash syntax

Updates the user documentation with the new syntax for defining
flash and nand banks.

11 years agoupdate 'nand device' usage in scripts
Zachary T Welch [Wed, 18 Nov 2009 10:19:35 +0000 (02:19 -0800)]
update 'nand device' usage in scripts

Add $_FLASHNAME variable to update 'nand device' command syntax.

11 years agoadd support for naming NAND banks
Zachary T Welch [Tue, 17 Nov 2009 22:11:24 +0000 (14:11 -0800)]
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.

11 years agorefactor handle_nand_device_command
Zachary T Welch [Tue, 17 Nov 2009 23:14:03 +0000 (15:14 -0800)]
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.

11 years agoupdate 'flash bank' usage in scripts
Zachary T Welch [Wed, 18 Nov 2009 10:15:52 +0000 (02:15 -0800)]
update 'flash bank' usage in scripts

Sets $_FLASHNAME to "$_CHIPNAME.flash" and passes it as the
first argument to 'flash bank'.

11 years agoadd support for naming flash banks
Zachary T Welch [Tue, 17 Nov 2009 22:04:25 +0000 (14:04 -0800)]
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.

11 years agorefactor handle_flash_bank_command
Zachary T Welch [Tue, 17 Nov 2009 21:52:43 +0000 (13:52 -0800)]
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.

11 years agorename flash and nand command helpers
Zachary T Welch [Tue, 17 Nov 2009 21:07:36 +0000 (13:07 -0800)]
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

11 years agoallow flash/nand banks commands to accept names
Zachary T Welch [Tue, 17 Nov 2009 21:04:49 +0000 (13:04 -0800)]
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.

11 years agoARM: remove per-register malloc
David Brownell [Thu, 19 Nov 2009 21:23:49 +0000 (13:23 -0800)]
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>
11 years agoARM: streamline register init
David Brownell [Thu, 19 Nov 2009 21:23:08 +0000 (13:23 -0800)]
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>
11 years agoCortex-A8: parts of examine() run just once
David Brownell [Thu, 19 Nov 2009 18:47:31 +0000 (10:47 -0800)]
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>
11 years agonand_fileio_parse_args parses wrong param for size
Dean Glazeski [Thu, 19 Nov 2009 05:22:25 +0000 (23:22 -0600)]
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>
11 years agoARMv7-A: use standard ARM core states
David Brownell [Thu, 19 Nov 2009 10:33:01 +0000 (02:33 -0800)]
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>
11 years agoARMv7-A: use standard ARM core_mode symbols
David Brownell [Thu, 19 Nov 2009 10:31:34 +0000 (02:31 -0800)]
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>
11 years agofix zy1000 command handler
Zachary T Welch [Wed, 18 Nov 2009 14:00:26 +0000 (06:00 -0800)]
fix zy1000 command handler

Rewrite ZY1000 power command handler to use new macros, simplify logic.

Remove unused port command handler declaration.

11 years agoremove fast command and jim_global_long
Zachary T Welch [Wed, 18 Nov 2009 13:02:08 +0000 (05:02 -0800)]
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.

11 years agoupdate src/hello.c with parsing examples
Zachary T Welch [Wed, 18 Nov 2009 23:20:58 +0000 (15:20 -0800)]
update src/hello.c with parsing examples

Adds the foo/bar commands to provide more working examples of command
argument parsing, including the new handle_command_parse_bool helper.

Updates hello command help text to provide useful information.

11 years agochange all bool parsers to accept any value
Zachary T Welch [Wed, 18 Nov 2009 20:41:20 +0000 (12:41 -0800)]
change all bool parsers to accept any value

This patch changes the behavior of all boolean parsing callers to
accept any one of "true/enable/on/yes/1" or "false/disable/off/no/0".

Since one particular pair will be most appropriate in any given
situation, the specific macros should continue to be used in
order to display the most informative error messages possible.

11 years agoadd handle_command_parse_bool command helper
Zachary T Welch [Wed, 18 Nov 2009 14:58:27 +0000 (06:58 -0800)]
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.

11 years agouse COMMAND_PARSE_ENABLE macro where appropriate
Zachary T Welch [Wed, 18 Nov 2009 13:36:18 +0000 (05:36 -0800)]
use COMMAND_PARSE_ENABLE macro where appropriate

Updates all command parsing of simple "enable" and "disable" arguments.
A few case in the tree use a tri-state or extended arguments, which
cannot use this simple macro.

Simlifies the xscale icache/dcache command handler logic.

11 years agouse COMMAND_PARSE_ON_OFF where appropriate
Zachary T Welch [Wed, 18 Nov 2009 13:22:44 +0000 (05:22 -0800)]
use COMMAND_PARSE_ON_OFF where appropriate

Updates all command parsing of "on" and "off" arguments.

11 years agoadd COMMAND_PARSE_BOOL macro and friends
Zachary T Welch [Wed, 18 Nov 2009 13:19:34 +0000 (05:19 -0800)]
add COMMAND_PARSE_BOOL macro and friends

Adds several macros similar to COMMAND_PARSE_NUMBER, but for parsing
boolean command arguments.  Two flavors are provided to provide
drop-in compatibility with existing code, allow for the elimination
of a lot of code bloat while improving the error checking and reporting.

COMMAND_PARSE_ON_OFF parses "on"/"off" command parameters.
COMMAND_PARSE_ENABLE parses "enable"/"disable" command parameters.

Both print the error and return an error out of the calling function.

11 years agoARM: rework "arm reg" output for new mode
David Brownell [Wed, 18 Nov 2009 23:31:24 +0000 (15:31 -0800)]
ARM: rework "arm reg" output for new mode

Change the layout to show the "Secure Monitor" registers too,
when they're present.

Instead of lining registers for each of six (or seven) modes up
in adjacent vertical columns, display each mode's registers (or
shadows) in a single block, avoiding duplicate value displays.

This also lets us shrink the line length to fits in standard 80
character lines ... six or seven 18-character columns can't fit.

Relabel "r13" as "sp", so it's more meaningful.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoCortex-A8: xPSR handling updates
David Brownell [Wed, 18 Nov 2009 23:04:58 +0000 (15:04 -0800)]
Cortex-A8: xPSR handling updates

When we read the CPSR on debug entry, update the CPSR cache in all
cases, not just when the current processor state is User or System.

Plus minor cleanup of how the (too-many) other registers' cache
entries get updated.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM: add a default full_context() method
David Brownell [Wed, 18 Nov 2009 22:49:22 +0000 (14:49 -0800)]
ARM: add a default full_context() method

If the core doesn't provide an optimized version of this
method, provide one without core-specific optimizations.
Use this to make Cortex-A8 support the "arm reg" command.

Related: make the two register access methods properly static,
have the "set" log a "not halted" error too, and make sure
that the "valid" flag is set on successful reads.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM: simplify ARMv7-A register handling
David Brownell [Wed, 18 Nov 2009 22:46:14 +0000 (14:46 -0800)]
ARM: simplify ARMv7-A register handling

ARMv7-A doesn't need to duplicate all the standard ARM code
for register handling.

 - Switch Cortex-A8 to use the standard register code
 - Remove duplicated infrastructure from ARMv7-A
 - Have ARMv7-A arch_state() show CPSR, like other ARMs

Add comments to show where the Cortex-A8 isn't actually doing
the right thing for register reads/writes, unless core happens
to be in the right mode to start with.  (Looks like maybe there
may be generic confusion between saved/current PSR values in all
the ARM code ...)

Make related ARMv7-A and Cortex-A8 symbols properly static.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM: setup "secure monitor mode" shadow regs
David Brownell [Wed, 18 Nov 2009 21:23:00 +0000 (13:23 -0800)]
ARM: setup "secure monitor mode" shadow regs

Teach the "armv4_5" register code to understand about the
secure monitor mode:

 - Add the other three shadowed registers to the arrays
 - Support another internal mode number (sigh) in mappings
 - Catch malloc/calloc failures building that register cache

This should kick in for Cortex-A8 and ARM1176.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM: add "core_type" field to "struct arm"
David Brownell [Wed, 18 Nov 2009 21:22:27 +0000 (13:22 -0800)]
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>
11 years agofix segfault at startup
Zachary T Welch [Wed, 18 Nov 2009 19:56:24 +0000 (11:56 -0800)]
fix segfault at startup

The previous changes to move the startup TCL code resulted in segfaults
during startup.  This seemingly innocuous patch fixes the problem.
I would explain why changing from 'foo[]' to '*foo' caused this issue,
but the difference seems superficial.  For now, this hot fix will do,
but this issue might bear further scrutiny.

11 years agopass startup_tcl to command_init
Zachary T Welch [Tue, 17 Nov 2009 17:15:09 +0000 (09:15 -0800)]
pass startup_tcl to command_init

Removes external linkage from helper module, making the startup
code a parameter to a new command context's initialization routine.

11 years agosplit startup.tcl file across modules
Zachary T Welch [Tue, 17 Nov 2009 16:29:20 +0000 (08:29 -0800)]
split startup.tcl file across modules

Moves definitions for each layer into their own file, eliminating
layering violations in the built-in TCL code.  Updates src/Makefile.am
rules to include all files in the final startup.tcl input file, and
others Makefile.am rules to distribute the new files in our packages.

11 years agomove startup.c to libopenocd
Zachary T Welch [Tue, 17 Nov 2009 16:30:51 +0000 (08:30 -0800)]
move startup.c to libopenocd

Moves the creation of startup_tcl.c from src/helper/ to src/.
Prepares to split the startup.tcl file into its per-module parts.

11 years agofix regression in md/mw commands
Zachary T Welch [Wed, 18 Nov 2009 11:34:52 +0000 (03:34 -0800)]
fix regression in md/mw commands

The recent migration broke them, the fixes broken them in a new way,
but this should restore them to working order.  Eliminates the
temporary variable, as the CMD_NAME macro can once again be use
in routines that increment CMD_ARGV without nasty side-effects.

11 years agojtag-api: get rid of unecessary buf_set_u23() that make code obtuse.
Øyvind Harboe [Tue, 17 Nov 2009 20:59:01 +0000 (21:59 +0100)]
jtag-api: get rid of unecessary buf_set_u23() that make code obtuse.

Also, this is on the path to increasing the word size for
bit vectors from 8 to something wider(32? natural host machine
width?)

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
11 years agoARM: add is_arm_mode()
David Brownell [Wed, 18 Nov 2009 07:50:26 +0000 (23:50 -0800)]
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>
11 years agoARM: add arm_mode_name()
David Brownell [Wed, 18 Nov 2009 07:50:23 +0000 (23:50 -0800)]
ARM: add arm_mode_name()

Add and use arm_mode_name() to map from PSR bits to user
meaningful names.   It uses a new table which, later, can
be used to hold other mode-coupled data.

Add definitions for the "Secure Monitor" mode, as seen on
some ARM11 cores (like ARM1176) and on Cortex-A8.  The
previous mode name scheme didn't understand that mode.

Remove the old mechanism ... there were two copies, caused
by Cortex-A8 needing to add "Secure Monitor" mode support.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM: only use one set of dummy FPA registers
David Brownell [Wed, 18 Nov 2009 07:50:17 +0000 (23:50 -0800)]
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>
11 years agoallow documentation to be configured
Zachary T Welch [Tue, 17 Nov 2009 14:54:56 +0000 (06:54 -0800)]
allow documentation to be configured

Add --disable-doxygen-html and --enable-doxygen-pdf options to the
configure script, allowing user to change the defaults.  These
update the proess of munging the Doxygen configuration file to
use the settings thusly provided.  Add options in README.

11 years agoupdate doxygen configuration to produce a PDF
Zachary T Welch [Tue, 17 Nov 2009 14:04:03 +0000 (06:04 -0800)]
update doxygen configuration to produce a PDF

A single PDF file for the developer manual allows accessing a single
index, browsing, and searching.  It takes significantly more time to
build this way, but this patch allows others to look at the results.

Migration Tip: If you have previously built the HTML Doxygen
documentatation, rename your 'doxygen' directory to 'doxygen/html'
to prevent needlessly rebuilding those files.

11 years agoupdate command_handler documentation
Zachary T Welch [Tue, 17 Nov 2009 13:38:17 +0000 (05:38 -0800)]
update command_handler documentation

Improve the developer manual and primer sections which talk about
writing command handlers.  Notably, it documents the new CMD_* macros.

11 years agoremove unused variable from run_command
Zachary T Welch [Mon, 16 Nov 2009 23:45:17 +0000 (15:45 -0800)]
remove unused variable from run_command

11 years agoadd CMD_NAME variable in command_invocation
Zachary T Welch [Mon, 16 Nov 2009 13:46:15 +0000 (05:46 -0800)]
add CMD_NAME variable in command_invocation

Update CMD_NAME from its migratory home in CMD_ARGV[-1] to cmd->name.
Allows CMD_ARGV++ idiom to be used safely in command handlers.

11 years agoadd struct command_invocation for COMMAND_HANDLER
Zachary T Welch [Sun, 15 Nov 2009 12:21:17 +0000 (04:21 -0800)]
add struct command_invocation for COMMAND_HANDLER

Adds the command_invocation structure to encapsulate parameters for
all COMMAND_HANDLER routines.  Rather than passing several arguments
to each successive subroutine, a single pointer may be passed around.

Changes the CMD_* macros to reference the new fields.

Updates run_command to create an instance and pass it to the handler.

11 years agocommand_handler: change 'cmd_ctx' to CMD_CTX
Zachary T Welch [Sun, 15 Nov 2009 13:57:37 +0000 (05:57 -0800)]
command_handler: change 'cmd_ctx' to CMD_CTX

Convert all command handler 'cmd_ctx' parameter usage with CMD_CTX.

11 years agocommand_handler: change 'args' to CMD_ARGV
Zachary T Welch [Sun, 15 Nov 2009 16:15:59 +0000 (08:15 -0800)]
command_handler: change 'args' to CMD_ARGV

This patch converts all instances of 'args' in COMMAND_HANDLER routines
to use CMD_ARGV macro.

11 years agocommand_handler: change to 'argc' to CMD_ARGC
Zachary T Welch [Sun, 15 Nov 2009 12:57:12 +0000 (04:57 -0800)]
command_handler: change to 'argc' to CMD_ARGC

This patch converts all instances of 'argc' in COMMAND_HANDLER routines
to use CMD_ARGC.

11 years agoadd more command_handler conversion macros
Zachary T Welch [Sun, 15 Nov 2009 12:18:51 +0000 (04:18 -0800)]
add more command_handler conversion macros

Add additional macros to allow command handling to be migrated easily:
CMD_CTX, CMD_ARGC, and CMD_ARGV.  Updates CMD_NAME to use CMD_ARGV.

In addition to making the remaining patches of this series cleaner,
this introduces easily sed-able symbols that could allow us to retire
these once the command handler infrastructure matures (i.e. pre-1.0).

11 years agotarget: simplify register get/set ops
David Brownell [Tue, 17 Nov 2009 17:06:45 +0000 (09:06 -0800)]
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>
11 years agojtag_registers: Avalon bridge flushing tweaks
Øyvind Harboe [Tue, 17 Nov 2009 10:03:55 +0000 (11:03 +0100)]
jtag_registers: Avalon bridge flushing tweaks

The code is now much more explicit. It flushes every
N writes. For now flush every time, but tinkering with
the bridge FIFO size and how often we flush clearly
points in the direction of the Avalon write FIFO full
being the culprit.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
11 years agozy1000: revC UART forwarding
Øyvind Harboe [Tue, 17 Nov 2009 10:00:02 +0000 (11:00 +0100)]
zy1000: revC UART forwarding

Name of serial device differs between revB/C.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
11 years agozy1000: add version command to print FPGA version and timestamps
Øyvind Harboe [Fri, 13 Nov 2009 12:54:20 +0000 (13:54 +0100)]
zy1000: add version command to print FPGA version and timestamps

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
11 years agozy1000: fix bug when running on non-arm CPU
Øyvind Harboe [Thu, 12 Nov 2009 09:10:11 +0000 (10:10 +0100)]
zy1000: fix bug when running on non-arm CPU

Shifting by more than 32 is undefined for 32 bit integers according
to the C standard. Robust solution is conditional code.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
11 years agozy1000: fix trivial syntax error introduced by latest refactorings
Øyvind Harboe [Tue, 17 Nov 2009 13:51:09 +0000 (14:51 +0100)]
zy1000: fix trivial syntax error introduced by latest refactorings

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
11 years agoARM9TDMI: remove now-needless "struct arm9tdmi"
David Brownell [Tue, 17 Nov 2009 09:09:50 +0000 (01:09 -0800)]
ARM9TDMI: remove now-needless "struct arm9tdmi"

And move the rest of the vector_catch stuff into the C file;
it's not part of the module interface.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM7TDMI: remove now-needless "struct arm7tdmi"
David Brownell [Tue, 17 Nov 2009 09:09:06 +0000 (01:09 -0800)]
ARM7TDMI: remove now-needless "struct arm7tdmi"

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agotarget: remove some more duplicate includes
David Brownell [Tue, 17 Nov 2009 09:06:16 +0000 (01:06 -0800)]
target: remove some more duplicate includes

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARMv7-A: no exit() calls
David Brownell [Tue, 17 Nov 2009 01:58:58 +0000 (17:58 -0800)]
ARMv7-A: no exit() calls

Also, switch integrity check over to the correct magic number,
and remove duplicate v4/v5 #define.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoCortex-A8: no exit() calls, add missing v7-A init
David Brownell [Tue, 17 Nov 2009 01:57:12 +0000 (17:57 -0800)]
Cortex-A8: no exit() calls, add missing v7-A init

Eventually there should be a v7a init routine, but for now
all that is inlined here.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoXScale: fewere exit() calls
David Brownell [Tue, 17 Nov 2009 01:55:49 +0000 (17:55 -0800)]
XScale: fewere exit() calls

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoMIPS: no exit() calls
David Brownell [Tue, 17 Nov 2009 01:55:30 +0000 (17:55 -0800)]
MIPS: no exit() calls

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARMv7-M: no exit() calls
David Brownell [Tue, 17 Nov 2009 01:54:51 +0000 (17:54 -0800)]
ARMv7-M: no exit() calls

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARMv4/ARMv5: no exit() calls
David Brownell [Tue, 17 Nov 2009 01:52:50 +0000 (17:52 -0800)]
ARMv4/ARMv5: no exit() calls

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM11: fewer exit() calls
David Brownell [Tue, 17 Nov 2009 01:51:55 +0000 (17:51 -0800)]
ARM11: fewer exit() calls

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoCortex-M3: don't exit()
David Brownell [Tue, 17 Nov 2009 00:42:51 +0000 (16:42 -0800)]
Cortex-M3: don't exit()

Get rid of undesirable and needless exit() calls
from the Cortex-M3 support.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARMv7A: use standard disassembler
David Brownell [Tue, 17 Nov 2009 00:36:21 +0000 (16:36 -0800)]
ARMv7A: use standard disassembler

We no longer need v7A-specific code for this.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM11: register (most) standard ARM commands
David Brownell [Tue, 17 Nov 2009 00:36:12 +0000 (16:36 -0800)]
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>
11 years agoARM: "armv4_5" command prefix becomes "arm"
David Brownell [Tue, 17 Nov 2009 00:36:09 +0000 (16:36 -0800)]
ARM: "armv4_5" command prefix becomes "arm"

Rename the "armv4_5" command prefix to straight "arm" so it makes
more sense for newer cores.  Add a simple compatibility script.

Make sure all the commands give the same "not an ARM" diagnostic
message (and fail properly) when called against non-ARM targets.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoJTAG: fix autoprobe failure.
David Brownell [Tue, 17 Nov 2009 00:36:03 +0000 (16:36 -0800)]
JTAG: fix autoprobe failure.

Fix bug noted by Øyvind: terminate the IR length autoscan when
the IR is too long, or otherwise broken.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agofileio: improve API types
Zachary T Welch [Fri, 13 Nov 2009 22:44:53 +0000 (14:44 -0800)]
fileio: improve API types

Use size_t instead of uint32_t when specifying file sizes.  Update all
consumers up through the layers to use size_t when required.  These
changes should be safe, but the higher-levels will need to be updated
further to receive the intended benefits (i.e. large file support).

Add error checking for fileio_read and file_write.  Previously, all
errors were being silently ignored, so this change might cause some
problems for some people in some cases.  However, it gives us the chance
to handle any errors that do occur at higher-levels, rather than burying
our heads in the sand.

11 years agostruct fileio: improve member types
Zachary T Welch [Fri, 13 Nov 2009 22:22:21 +0000 (14:22 -0800)]
struct fileio: improve member types

Add const keyword to file url and cast to free().

Make size an ssize_t and chase all format strings that use it.

11 years agohelper/log: improve API parameter types
Zachary T Welch [Sun, 15 Nov 2009 11:42:45 +0000 (03:42 -0800)]
helper/log: improve API parameter types

Uses unsigned type to pass line numbers.

Use uint64_t to pass sleep routines their milliseconds.  Updates sleep
routines to use this type and improve whitespace.

11 years agouse Jim_CmdProc in jim_register
Zachary T Welch [Sun, 15 Nov 2009 12:05:33 +0000 (04:05 -0800)]
use Jim_CmdProc in jim_register

The jim_register command just needed to use the type defined by jim.h.

11 years agoimprove constness of open_file_from_path
Zachary T Welch [Fri, 13 Nov 2009 22:21:56 +0000 (14:21 -0800)]
improve constness of open_file_from_path

11 years agomake command line options const
Zachary T Welch [Sun, 15 Nov 2009 11:53:19 +0000 (03:53 -0800)]
make command line options const

The getopt_long call allows a const struct option, so mark ours
const too.

11 years agoARM: standard disassembler uses Thumb2 entry
David Brownell [Mon, 16 Nov 2009 23:29:14 +0000 (15:29 -0800)]
ARM: standard disassembler uses Thumb2 entry

Tweak "standard" ARM disassembler diagnostics to fail if the target
is not "an ARM" (vs. not "an ARMV4/5"), so it makes more sense for
cores inheriting this as the "generic" disassembler.

Also, to use the Thumb2 entry instead of the original Thumb entry.
This makes it work better for both newer cores (which support those
added instructions) and for BL and BLX instructions on older cores.
(Those instructions are 32-bits, which requires curious state-aware
code to go through a 16-bit decode interface...)

Plus minor cleanups, notably to have fewer exit paths and to make
sure they all return failure codes.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agotarget: don't include "log.h" from "armv4_5.h"
David Brownell [Mon, 16 Nov 2009 23:27:40 +0000 (15:27 -0800)]
target: don't include "log.h" from "armv4_5.h"

No point in multiple includes, and that file doesn't
use its functions any more.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoARM: move mode functions out of header
David Brownell [Mon, 16 Nov 2009 23:27:36 +0000 (15:27 -0800)]
ARM: move mode functions out of header

They're really too big to inline, at least for code that's
not in any performance-critical loops.

Also move the associated string table to the rodata section.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agoJTAG: no LOG_WARNING() for taps without IDCODE
David Brownell [Mon, 16 Nov 2009 23:18:55 +0000 (15:18 -0800)]
JTAG: no LOG_WARNING() for taps without IDCODE

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agobinarybuffer: regression fix
David Brownell [Mon, 16 Nov 2009 22:50:07 +0000 (14:50 -0800)]
binarybuffer: regression fix

The "improve inline binarybuffer helpers" mis-handled bytes
with the high bit set; treat them as unsigned, not signed.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years ago"types.h" doxygen fix
David Brownell [Mon, 16 Nov 2009 18:42:01 +0000 (10:42 -0800)]
"types.h" doxygen fix

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
11 years agotarget: less implicit inclusion of "etm.h"
David Brownell [Mon, 16 Nov 2009 18:19:33 +0000 (10:19 -0800)]
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>
11 years agomove ARRAY_SIZE macro to types.h
Zachary T Welch [Mon, 16 Nov 2009 11:29:30 +0000 (03:29 -0800)]
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).

11 years agoarmv7m: make core reg read/write use unsigned
Zachary T Welch [Mon, 16 Nov 2009 11:33:22 +0000 (03:33 -0800)]
armv7m: make core reg read/write use unsigned

Eliminate redundant check that gets covered by using unsigned type.
Created to eliminate noise from subsequent patches, but this kind of
conversion will be beneficial in similar ways throughout the tree.

11 years agoremove TAP_SCAN_BYTES macro
Zachary T Welch [Mon, 16 Nov 2009 11:12:45 +0000 (03:12 -0800)]
remove TAP_SCAN_BYTES macro

Use DIV_ROUND_UP(n, 8) instead of TAP_SCAN_BYTES macro.

11 years agorename CEIL as DIV_ROUND_UP
Zachary T Welch [Mon, 16 Nov 2009 10:53:57 +0000 (02:53 -0800)]
rename CEIL as DIV_ROUND_UP

Improves the name of this macro, moves it to types.h, and adds a block
of Doxygen comments to describe what it does.

11 years agomove container_of to types.h
Zachary T Welch [Mon, 16 Nov 2009 10:29:09 +0000 (02:29 -0800)]
move container_of to types.h

The container_of macro is useful as a general solution.  It belongs
in types.h, rather than target.h where it was introduced.  Requires
the offsetof macro, which comes from <stddef.h> (moved as well).

11 years agonand_command_get_device_by_num: make COMMAND_HELPER
Zachary T Welch [Sun, 15 Nov 2009 15:20:19 +0000 (07:20 -0800)]
nand_command_get_device_by_num: make COMMAND_HELPER

Use COMMAND_HELPER macro to define nand_command_get_device_by_num.
Use CALL_COMMAND_HANDLER to invoke it.