Commit Graph

2720 Commits

Author SHA1 Message Date
Zachary T Welch
903daa796a 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.
2009-11-18 03:59:14 -08:00
Zachary T Welch
59f32cbe53 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.
2009-11-18 03:34:52 -08:00
Øyvind Harboe
6e95f16d0a 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>
2009-11-18 09:24:28 +01: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
ec93209f51 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>
2009-11-17 23:50:23 -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
cfaf7bdd0a remove unused variable from run_command 2009-11-17 11:40:21 -08:00
Zachary T Welch
cffc98ad80 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.
2009-11-17 11:40:21 -08:00
Zachary T Welch
be084414ba 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.
2009-11-17 11:40:21 -08:00
Zachary T Welch
2861877b32 command_handler: change 'cmd_ctx' to CMD_CTX
Convert all command handler 'cmd_ctx' parameter usage with CMD_CTX.
2009-11-17 11:40:06 -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
Zachary T Welch
5b9899d6ea 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).
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
Øyvind Harboe
959b373f8c 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>
2009-11-17 15:39:05 +01:00
Øyvind Harboe
741cd3c3ab zy1000: revC UART forwarding
Name of serial device differs between revB/C.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-17 15:04:17 +01:00
Øyvind Harboe
ca32f25638 zy1000: add version command to print FPGA version and timestamps
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-17 15:04:17 +01:00
Øyvind Harboe
83104648e6 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>
2009-11-17 15:04:17 +01:00
Øyvind Harboe
b888b63fe9 zy1000: fix trivial syntax error introduced by latest refactorings
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-17 15:01:48 +01:00
David Brownell
0181296f61 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>
2009-11-17 01:09:50 -08:00
David Brownell
812ab89f58 ARM7TDMI: remove now-needless "struct arm7tdmi"
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-17 01:09:06 -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
e722396890 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>
2009-11-16 17:58:58 -08:00
David Brownell
36a538c6d7 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>
2009-11-16 17:57:12 -08:00
David Brownell
c5e0026836 XScale: fewere exit() calls
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 17:55:49 -08:00
David Brownell
1d4a09c2ef MIPS: no exit() calls
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 17:55:30 -08:00
David Brownell
1f3e067b86 ARMv7-M: no exit() calls
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 17:54:51 -08:00
David Brownell
9d57f4d5a1 ARMv4/ARMv5: no exit() calls
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 17:52:50 -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
47f2305229 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>
2009-11-16 16:42:51 -08:00
David Brownell
56adbaffd0 ARMv7A: use standard disassembler
We no longer need v7A-specific code for this.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 16:36:21 -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
f86137066a 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>
2009-11-16 16:36:09 -08:00
David Brownell
7c393679c0 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>
2009-11-16 16:36:03 -08:00
Zachary T Welch
51862bb98c 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.
2009-11-16 15:47:09 -08:00
Zachary T Welch
69df712d1d 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.
2009-11-16 15:47:09 -08:00
Zachary T Welch
9763aef76a 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.
2009-11-16 15:47:09 -08:00
Zachary T Welch
df9b12695f use Jim_CmdProc in jim_register
The jim_register command just needed to use the type defined by jim.h.
2009-11-16 15:47:08 -08:00
Zachary T Welch
0a9daddc2e improve constness of open_file_from_path 2009-11-16 15:47:08 -08:00
Zachary T Welch
ccf59123b7 make command line options const
The getopt_long call allows a const struct option, so mark ours
const too.
2009-11-16 15:47:08 -08:00
David Brownell
91ac164d95 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>
2009-11-16 15:29:14 -08:00
David Brownell
bf97237401 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>
2009-11-16 15:27:40 -08:00
David Brownell
2fb58116a5 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>
2009-11-16 15:27:36 -08:00
David Brownell
a7c04a0e49 JTAG: no LOG_WARNING() for taps without IDCODE
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 15:18:55 -08:00
David Brownell
b6e0f2e1c3 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>
2009-11-16 14:50:07 -08:00
David Brownell
66300d5966 "types.h" doxygen fix
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 10:42:01 -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
Zachary T Welch
10cce4a5fe 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.
2009-11-16 09:58:11 -08:00
Zachary T Welch
0535a92456 remove TAP_SCAN_BYTES macro
Use DIV_ROUND_UP(n, 8) instead of TAP_SCAN_BYTES macro.
2009-11-16 09:58:11 -08:00