Commit Graph

846 Commits

Author SHA1 Message Date
Øyvind Harboe
3a693ef526 fileio: refactor struct fileio to be an opaque structure
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-29 08:43:27 +02:00
Øyvind Harboe
ea48794210 startup: removed capture_catch
not used.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-20 20:45:48 +02:00
Øyvind Harboe
1abc26d7a2 helper: fix flaky capture command
capture of progress output would get polling
results. This will break in the example below
where polling output would override the tcl
return value.

capture {sleep 10000; set abc def}

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-20 20:45:48 +02:00
Øyvind Harboe
f6a3fc818b warnings: fix alignment warnings
These warnings are for architectures that do not
support non-aligned word access.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-20 13:12:35 +02:00
Øyvind Harboe
73e5dffdfd jim: fix crash when using Jim_ListInsertElements
Jim_ListInsertElements was simply forgotten from the
fn that registered all the APIs.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-12 20:18:43 +02:00
Øyvind Harboe
ac86f4ccba command: capture command now handles both types commands
Commands that output progress output and no return value
will have the progress output captured.

Commands that do not output progress output(tcl commands)
will return the tcl return value instead.

The advantage here is that it is no longer necessary to
consider which command one is capturing, it works for
either.

Example #1: capture progress output:

set foo [capture help]

Example #2: capture tcl return value

set foo [capture {set abc def}]

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-11 11:42:38 +02:00
Øyvind Harboe
6ed9ab5b58 ioutil: fix internal fn names
prefix w/ioutil_

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-08-02 11:59:46 +02:00
Øyvind Harboe
630fc86ee3 util: ms command to calculate length of operations
This can be used to calculate approximate RTCK frequency
for instance.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-08-01 09:35:58 +02:00
Antonio Borneo
b978dcbbee helper/jim-eventloop.h: review unused definitions
Remove unused typedef and define

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-06-21 22:14:12 +08:00
Antonio Borneo
3cfbf70559 helper/jim-eventloop: review unused symbols
Remove unused functions:
- Jim_CreateSignalHandler
- Jim_DeleteSignalHandler

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-06-21 22:14:11 +08:00
Antonio Borneo
ec073e8943 helper/jim-eventloop: review scope of symbols
Add "static" qualifier to private functions.
Remove private prototypes from include file.
Remove empty definition of JIM_STATIC.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-06-21 22:14:08 +08:00
Andreas Fritiofson
3f9d377ce7 reverse order of Jim stack trace output
The stack traces makes much more sense this way.

Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2010-06-18 08:06:19 +02:00
Andreas Fritiofson
127f9da4fe don't add confusing source info to Jim
When an interactive command fails, the Jim stack trace prints references to
the line in "command.c" where the interpreter was invoked. Since that
location has no relation to the actual command that failed, the information
serves only to add confusion.

By not adding the useless source info to Jim the noise can be reduced,
while still printing a useful trace for nested commands.

Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-18 07:57:15 +02:00
Antonio Borneo
c3ee63be77 helper/jim: review unused symbols
Remove unused functions:
- Jim_IdentityHashFunction
- StringAppendObj
- JimReferencesHTDoubleHashFunction

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-18 07:52:51 +02:00
Antonio Borneo
cebd817cee helper/jim: review scope of symbols
Add "static" qualifier to private functions.

Function Jim_InterpolateTokens() is private, but has not
been changed to "static".
This function is called only once, so compiler inlines it.
After inline, there is a warning for variable uninitialized.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-18 07:52:47 +02:00
Freddie Chopin
b1cd202f9a mingw32: -Wshadow fixes
in jim.c (error: declaration of ‘boolean’ shadows a global declaration; /usr/local/lib/gcc/i686-w64-mingw32/4.4.2/../../../../i686-w64-mingw32/include/rpcndr.h:52: error: shadowed declaration is here)

Signed-off-by: Freddie Chopin <freddie_chopin@op.pl>
2010-06-17 21:09:24 +02:00
Antonio Borneo
b89462d7dc helper: remove helper membuf
Helper is now unused. Can be removed.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-06-17 07:20:42 +02:00
Øyvind Harboe
f1ce4fe288 oops... backup file snuck in, remove it.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-16 00:04:23 +02:00
Øyvind Harboe
395d3bff8c fileio: -Wshadow warning fix
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-15 23:01:42 +02:00
Øyvind Harboe
00017c90ae jim: -Wshadow warning fix
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-15 22:47:52 +02:00
Øyvind Harboe
3c8a0e72f3 jim: more jim -Wshadow fixes that should be straightforward
this bunch was a bit less obvious, but looked
straightforward.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-15 22:45:24 +02:00
Øyvind Harboe
2eba49b8b1 jim: -Wshadow fixes
this batch of fixes should be pretty straightforward
rename of 'index' and an 'i' local variable shadowing.

'index' conflicts with a global name.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-15 22:45:23 +02:00
Øyvind Harboe
3e51d893ed -Wshadow fixes
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-14 22:12:04 +02:00
Øyvind Harboe
f3ae52cace helper: fix -Wshadow warning in number parsing
use obtuse local variable names in macros to avoid
interfering with global name space

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-06-14 12:27:57 +02:00
Øyvind Harboe
c86d7bdad4 jim: fix bug in tcl "puts"
tcl "puts" didn't work because the logging code sensored strings
that did not include a '\n'. The correct thing is to sensor
empty strings, which are used to keep gdb connection alive.

The tcl "puts" code broke apart strings which do contain '\n' in
order to implement the -nonewline argument, which is how it
got hurt by the bug in log.c

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-05-18 12:34:12 +02:00
Øyvind Harboe
91b9f3de0b command context: fix errors when running certain commands on startup
Various commands, e.g. "arm mcr xxxx" would fail if invoked upon startup
since it there was no command context defined for the jim interpreter
in that case.

A Jim interpreter is now associated with a command context(telnet,
gdb server's) or the default global command context.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-05-05 15:24:24 +02:00
Antonio Borneo
f1be0e6af2 HELPER/LOG: review unused symbols
Remove unused functions:
- log_catch
- log_rethrow
- log_try

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-04-10 22:25:22 +08:00
Antonio Borneo
fdb9199001 BINARYBUFFER: review scope of data and functions
Add "static" qualifier to private data and functions.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-04-10 21:54:37 +08:00
Antonio Borneo
c0b5ca6d17 TIME_SUPPORT: review unused symbols
Remove unused functions:
- timeval_add

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-04-10 19:25:32 +08:00
Øyvind Harboe
fa1cfc2d4d gpl: fix GPL startup message
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-02-15 22:59:41 +01:00
Spencer Oliver
709f08f17a CMD: duplicate cmd error msg
When registering cmds we report duplicate attempts to register a cmd
as a LOG_ERROR.
Some situations need this, such as when registering dual flash banks.
http://www.mail-archive.com/openocd-development@lists.berlios.de/msg11152.html

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
2010-02-04 10:33:33 +00:00
Alex Austin
cd3017cffa Clang buildfixes
Building with clang took a few very small changes. The change to
helper/log.h is because clang doesn't like an expression where the
result is unused. In helper/system.h, I just defined true and false
since clang doesn't have them builtin.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-29 00:02:12 -08:00
Spencer Oliver
75cfda4cd1 ARM semihosting: win32 and cygwin fixes
Cygwin would fail to reopen a previously written file if the mode is
not given.

Simplified converting the open flags and made sure the win32 O_BINARY
bit is set.

Added define for systems that do not support O_BINARY.

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
2010-01-28 21:05:09 +00:00
Spencer Oliver
465a06dfdc ARM semihosting: fix writing to stdout
SYS_FLEN would be called before a write on a descriptor to check its size.
Currently lseek would fail with -1 when given the stdout/stderr descriptor.
Changing to use fstat seems to be the standard way of handling this.

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
2010-01-28 20:21:31 +00:00
Øyvind Harboe
60cb5bdd30 ecos: add missing PRId8 definition
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-01-21 08:11:39 +01:00
Andreas Fritiofson
4f310aa0c9 update win32 script search path
The default script search path on Windows is out of date with
the current layout (from installation and documentation), which
makes the standard script library not be found after a normal

	./configure && make && make install

under msys/MinGW. The same should hold true for cygwin native builds
(not verified).

Update search path to ../share/openocd/scripts not ../lib/openocd,
relative to the openocd executable.

Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-19 15:02:15 -08:00
Øyvind Harboe
6c75f5249c debug: make logging of commands terser
one line / command instead of one line per argument.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-01-13 08:32:15 +01:00
Øyvind Harboe
6d8604de37 commands: make error messages a bit more terse
we don't need to know the build path of command.c when
reading normal user level error messages.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-01-11 12:58:06 +01:00
David Brownell
c8267930c7 FreeBSD build fixes
Based on notes from Tomek Cedro <tomek.cedro@gmail.com> and
Steve Franks <bahamasfranks@gmail.com>.

In the User's Guide, sort the list of operating systems reported
through Tcl with $ocd_HOSTOS ... and include FreeBSD.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-10 10:06:58 -08:00
David Brownell
1dd5277ba3 src/helper: usage/help updates
Make "usage" messages use the same EBNF as the User's Guide;
no angle brackets.  Improve and correct various helptexts.

Don't use "&function"; a function's name is its address.
Fix some whitespace glitches, shrink a few overlong lines.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-09 13:32:08 -08:00
Masaki Muranaka
aafd3877e6 buildfix on MacOS
Recent Apple gcc versions use __APPLE__ instead of __DARWIN__; accept
that too.

Also use #warning, not #warn; neither is standard, but most CPP versions
require it to be spelled out.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-09 00:10:18 -08:00
David Brownell
844b5eb49d don't require 'openocd.cfg' to start
Starting the daemon with with just a bare "openocd" I saw:

	Can't find openocd.cfg

That's not an error; don't treat it as if it were.  There may
be an error later -- like, "no interface set up" -- but let
messages only report real errors, not fake ones.
2010-01-05 13:32:39 -08:00
David Brownell
b3bf1d12b2 streamline and document helptext mode displays
Most commands are usable only at runtime; so don't bother saying
that, it's noise.  Moreover, tokens like EXEC are cryptic.  Be
more clear: highlight only the commands which may (also) be used
during the config stage, thus matching the docs more closely.
There are

 - Configuration commands (per documentation)
 - And also some commands that valid at *any* time.

Update the docs to note that "help" now shows this mode info.

This also highlighted a few mistakes in command configuration,
mostly commands listed as "valid at any time" which shouldn't
have been.  This just fixes ones I noted when sanity testing.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-02 15:52:35 -08:00
Dean Glazeski
9d167d62f2 Fix usage/help search for subcommands.
This makes it so that the usage/help command properly uses the whole command,
including subcommand, in the search for help information.  This previously
caused erroneous output from the usage command handler.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-02 02:10:55 -08:00
Dean Glazeski
be01786186 Add the current command to the command information
I wanted to make it so I can be ignorant of a commands invocation string, so
I tried to use CMD_CURRENT (aka cmd->current) which is supposed to house a
pointer to the current command.  It turns out that this wasn't being set.

This patch adds the current command structure to the command invocation
structure before sending it along to the command handler.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-02 01:50:57 -08:00
David Brownell
08a890e4aa cygwin 1.7 build fixes
It's less accepting of signed char ... insisting that e.g. tolower()
not receive one as a parameter.

It's probably good to phase out such usage, given the number of bugs
that lurk in the vicinity (assumptions that char is unsigned), so fix
these even though such usage is actually legal.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-26 10:19:19 -08:00
Oyvind Harboe
b5962b23d8 help: list all commands that match string
Restore behavior where help lists all commands that
match string passed to help.

Signed-off-by: Oyvind Harboe <oyvind.harboe@zylin.com>
2009-12-21 11:19:42 +01:00
Øyvind Harboe
c8b8a34bb5 ecos: crisper implementation of timeval_ms()
A crisper/faster implementation under eCos that makes profiling a
tad easier.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-16 08:15:05 +01:00
Øyvind Harboe
dca173053b command: retire obsolete macro
COMMAND_REGISTER() was only used transiently during
code conversion.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-15 13:23:07 +01:00
Øyvind Harboe
eb1bc657ae build: add build/src to include path
This allows including generated include files.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-08 10:16:10 +01:00
David Brownell
dd9d1a3459 misc code review updates
More updates from the code review by Steve Grubb <sgrubb@redhat.com>.
The Jim float-comparision bug just gets a comment not a fix, though.

Cc: Steve Grubb <sgrubb@redhat.com>.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-05 14:40:06 -08:00
Zachary T Welch
b58c1d808f switch 'rm' command away from using Jim
Commands that do not need to use Jim should be registered as
high-level command handlers.
2009-12-04 03:34:32 -08:00
David Brownell
f62c035c52 doxygen: remove some warnings
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-03 18:31:38 -08:00
Zachary T Welch
822c06d9e3 remove tertiary include paths
With all #include directives converted, we only need to have the
top-level src/ directory in the search path.
2009-12-03 04:24:50 -08:00
Zachary T Welch
c538a830cd change #include "server.h" to <server/server.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "server.h"

the following form should be used.

	#include <server/server.h>

The exception is from .c files in the same directory.
2009-12-03 04:24:49 -08:00
Zachary T Welch
c6dd6a576d change #include "target.h" to <target/target.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "target.h"

the following form should be used.

	#include <target/target.h>

The exception is from .c files in the same directory.
2009-12-03 04:24:42 -08:00
Zachary T Welch
df0e90ec8c change #include "types.h" to <helper/types.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "types.h"

the following form should be used.

	#include <helper/types.h>

The exception is from .c files in the same directory.
2009-12-03 04:22:52 -08:00
Zachary T Welch
35f1a40f6f change #include "jim.h" to <helper/jim.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "jim.h"

the following form should be used.

	#include <helper/jim.h>

The exception is from .c files in the same directory.
2009-12-03 04:22:52 -08:00
Zachary T Welch
264d24495d change #include "command.h" to <helper/command.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "command.h"

the following form should be used.

	#include <helper/command.h>

The exception is from .c files in the same directory.
2009-12-03 04:22:48 -08:00
Zachary T Welch
896ac8d4ef allow #include directives to use module name
Includes the src directory in the search path, so header files may be
migrated from:

  #include "foo.h"

to
  #include <module/foo.h>

which is more conducive for installation.
2009-12-03 01:54:15 -08:00
David Brownell
a79b76d893 stubs: buildfix
The new stubs for httpd and ioutil gave errors like:

  ioutil_stubs.c: In function ‘ioutil_init’:
  ioutil_stubs.c:27: error: implicit declaration of function ‘LOG_DEBUG’
  ioutil_stubs.c:28: error: ‘ERROR_OK’ undeclared (first use in this function)
  ioutil_stubs.c:28: error: (Each undeclared identifier is reported only once
  ioutil_stubs.c:28: error: for each function it appears in.)

Fix.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-02 15:24:14 -08:00
Zachary T Welch
eaf10f69de remove BUILD_IOUTIL symbol
Add ioutil_stubs.c to provide an empty ioutil_init() routine.
Add ioutil.h to prevent applications from needing to declare it.

Allows unconditionally calling that function during startup, and the
resulting libocdhelper library API is now more stable.

Prints a DEBUG message when the stub implementation is included.
2009-12-02 13:26:26 -08:00
Øyvind Harboe
5576a6240a command: the Jim interpreter can now be provided rather than created
In embedded hosts, the Jim interpreter can come from the
existing context rather than be created by OpenOCD.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-01 09:53:23 +01:00
Zachary T Welch
330733eadf improve command prohibition error report
Ensures that the correct information gets displayed, depending on the
mode of the command being denied.  Fixes misreporting all commands as
needing to run "before 'init'".
2009-11-30 20:54:40 -08:00
Zachary T Welch
8fc5a9a5e9 remove interp global variable!
Finish removing references to the 'interp' global variable from the
command module, encapsulating all reference via command_context.

Eliminates use of the global entirely, so it can be removed.  Hurrah!
2009-11-30 16:29:34 -08:00
Zachary T Welch
cbc894ed7b command output capture: do not use interp global
Adds a log_capture_state structure to pass to the log capture
callback used by the command module.  Ensures that the capture occurs
in the proper context.
2009-11-30 16:29:34 -08:00
Zachary T Welch
7b2906de24 do not extern 'interp' from command.c
Adds 'interp' field to command_context, chasing the few remaining
references to the global variable outside of the command module.
2009-11-30 16:29:34 -08:00
Zachary T Welch
5dd6457d2c make syntax errors respond with 'usage'
The 'help' text will become more verbose, so its entire text will be
far more than desired when you only borked your syntax.  The usage
still allows the commands to be looked up for more help.
2009-11-30 16:29:34 -08:00
Zachary T Welch
3d204ec66a move improperly located documentation
Somehow, the comment block for command handlers ended up associated
with the output_handler.  Move it to the command_handler_t declaration.
2009-11-30 16:29:34 -08:00
Zachary T Welch
bc9ae74073 improve command_done() API and docs
command_done() does not need to return an error, but it needed
Doxygen comment.  Provide some for copy_command_context as well.

Note: this audit revealed some potential bugs with the command context
implementation.  There was a reason that commands were added at the
end of the list.  Shallow copying of command_context means that
the list is shared between them.  And commands added at the top-level
before the pre-existing commands will not be available in the shared
context as they were before.  Yikes!

Fortunately, this does not seem to occur in general use, as
'add_help_text' gets registered in startup.tcl and claims the first slot
in my own test cases.  Thus, it seems that we have been masking the issue
for now, but it shows the need for further architectural improvement in
the core command module.
2009-11-30 16:29:34 -08:00
Zachary T Welch
c0630d8a58 only display usable commands in help
With the ability to defer 'init', users can access the help system while
still in CONFIG mode.  This patch omits commands from the help and usage
list when they cannot be run in the current command mode, making it much
easier to see what can be done at a given time.
2009-11-30 16:29:24 -08:00
Zachary T Welch
2da2864632 remove redundant 'rm' command handler
Two 'rm' commands were implemented and registered.  This removes the
version that would have never been called prior to refactoring the
command registration.
2009-11-28 13:00:39 -08:00
Zachary T Welch
8795b8f9df add error checking in command_new
Adds checks for memory allocation failures.  Started to use calloc()
instead of malloc()/memset(), but I got carried away.  This kind of work
should be done throughout the tree, but it's almost hopeless at present.
2009-11-28 13:00:39 -08:00
Zachary T Welch
42e00bb379 include mode information in help text.
Extends the help output to list the valid modes for each commands.
Fixes a memory leak of the returned command_name() string.
2009-11-28 13:00:39 -08:00
Zachary T Welch
fd343bea7f refactor command mode detection
Splits the check for a command's ability to run into a helper.

This also fixes a bug whereby commands that specified COMMAND_EXEC
were allowed to run during the configuration stage.  This allowed
problematic commands to be called before 'init', defeating the intention
of specifying that command mode.  With this change, the run_command()
helper denies access to handlers that should run only after 'init'
during the configuration stage.
2009-11-28 13:00:39 -08:00
Zachary T Welch
933b4579f0 add command private data setter/accessor
Presently, commands registration taks a static handler data pointer.
This patch adds support for commands that require a dynamic pointer,
such as those registered in a dynamic context (e.g. subcommands for a
user-created 'foo.cpu' command).  The command_set_handler_data will
update a command (group) to use a new context pointer, while the
CMD_DATA macro allows command handlers to access the value.
Jim handlers should find this value in interp->cmdPrivData.
2009-11-28 13:00:39 -08:00
Zachary T Welch
3b5751a4d4 add 'command mode' introspective handler
Allows scripts to behave different depending on the current mode.
Also allows introspection of the mode required for commands.
2009-11-28 13:00:39 -08:00
Zachary T Welch
89fa493a3b remove unknown handler
Updates command registration to provide top-level handlers for all
commands, rather than falling back onto the 'unknown' command. Instead,
that same handler is registered for placeholders, providing the same
functionality under the root verb command name instead.  This permits
users to implement their own 'unknown' function, and it resolves some
mind-bending breakage related to function object lookup while recursing.

Changes 'ocd_bounce' to call 'ocd_command' and 'ocd_help' from the
wrapper directly, rather than bouncing through their wrappers. This
prevents endless recursion caused by the above changes, whereby the
'command' wrapper's type check would blow the stack to hell and gone.
2009-11-28 13:00:39 -08:00
Zachary T Welch
df22f0f9ca improve command handler wrapper script
Adds 'ocd_bouncer' in startup.tcl that is called as a helper for
all command handlers, shrinking the embedded C wrapper to a mere stub.

Jim handlers are called directly, simple handlers get called with the
wrapper to capture and discard their output on error, and placeholders
call help directly (though the unknown handler still does this too).
It attempts to improve the quality of the error messages as well.
2009-11-28 13:00:38 -08:00
Zachary T Welch
37dd5a685a add 'command type' introspective handler
Adds the 'command' group handler, with the 'type' command producing
a string that tells whether the given command is 'native' (for Jim-based
command handlers), 'simple' (for simple built-in commands), 'group'
for command group placeholders, and 'unknown' if not found in the
command registration tables (e.g. core built-ins functions).
2009-11-28 12:58:35 -08:00
Zachary T Welch
77aa7ca8d6 fix regression causing duplicated output
The command refactoring caused subcommand handlers to produce duplicate
output when run.  The problem was introduced by failing to ensure all
such invocations went through a top-level "catcher" script, prefixing
the command name with the 'ocd_' prefix and consuming its results.

The fix is to ensure such a top-level "catcher" script gets created
for each top-level command, regardless of whether it has a handler.
Indeed, this patch removes all command registrations for sub-commands,
which would not have worked in the new registration scheme anyway.

For now, dispatch of subcommands continues to be handled by the new
'unknown' command handler, which gets fixed here to strip the 'ocd_'
prefix if searching for the top-level command name fails initially.
Some Jim commands may be registered with this prefix, and that situation
seems to require the current fallback approach.  Otherwise, that prefix
could be stripped unconditionally and the logic made a little simpler.
The same problem must be handled by the 'help' command handler too,
so its lookup process works as intended.

Overall, the command dispatching remains more complicated than desired,
but this patch fixes the immediate regressions.
2009-11-27 14:30:26 -08:00
Zachary T Welch
a3d81eed4d support OPENOCD_DEBUG_LEVEL environment setting
Detect the OPENOCD_DEBUG_LEVEL setting in log_init(), allowing the
very early startup phases to be debugged.
2009-11-25 10:29:06 -08:00
Zachary T Welch
be482a5335 log: improve initialization
Removes redundant assignment of start_ms from log_register_commands().
Eliminates command_context parameter and return value.
Adds Doxygen comment block for this API call.
2009-11-25 10:29:06 -08:00
Zachary T Welch
d89c631014 add script_command_run helper
Eliminates duplicated code in script_command and handle_unknown_command.
Fixes bug with duplicated help output generated by placeholder commands.
2009-11-25 10:29:05 -08:00
Zachary T Welch
9e5d8a94f1 encapsulate and re-use log capture, retval setup
Factors log capture while running script commands, eliminating
duplicated code between script_command and jim_capture.  Factors
setting a command's Jim "retval" into a new helper as well.

Using these new helpers in the new unknown command handler's
fixes possible regressions caused by these bits being missing.
2009-11-25 10:29:05 -08:00
Zachary T Welch
910bb250c4 combine help and usage command handlers
Remove duplicated handler code by checking the running command name.
2009-11-25 10:29:05 -08:00
Zachary T Welch
c297a14f70 improve usage and help command output
Rewrite formatting code in C, removing last remenants of TCL help code.
Sinificantly improves the readability by using smarter indent and wrap.
2009-11-24 21:37:37 -08:00
Zachary T Welch
6b066cd170 allow scripts to update usage information
The add_usage_text command uses the same C handler, which was updated
to support its new polymorphic role.  This patch updates the two script
commands that needed this support: 'find' and 'script'.
2009-11-24 21:37:37 -08:00
Zachary T Welch
17a9dea53a add jim_handler to command_registration
Adding jim_handler field to command_registration allows removing the
register_jim helper.  All command registrations now go through the
register_command{,s}() functions.
2009-11-24 21:37:37 -08:00
Zachary T Welch
cd7e76ebf0 refactor command_new to use command_registration
Save stack space: use a struct.  Makes it easier to add new parameters.
2009-11-24 21:37:37 -08:00
Zachary T Welch
29772ec372 log: use register_commands()
Use register_commands() for logging callbacks.  Improve help and add
proper usage.
2009-11-24 21:37:32 -08:00
Zachary T Welch
8de1e7bd9e ioutil: use register_commands()
Use table instead of individual calls.  Add proper usage information.
2009-11-24 21:37:32 -08:00
Zachary T Welch
62e5649600 rewrite 'unknown' command dispatching in C
Rewrite the magical 'unknown' command in C as a Jim handler, allowing
it to dispatch commands to any level in the tree.
2009-11-24 21:37:30 -08:00
Zachary T Welch
769fbfa058 add public API for locating commands
Allow other modules to find a command, primarily for the purpose of
registering and unregistering subcommands.
2009-11-24 21:37:30 -08:00
Zachary T Welch
4c54c27da7 refactor script_command context grabbing
Move command context acquisition to current_command_context() for re-use.
2009-11-24 21:37:30 -08:00
Zachary T Welch
60ba4641d6 add command registration chaining
Adds the ability to chain registration structures.  Modules can define a
command with the 'chain' and 'num_chain' fields defined in their
registration table, and the register_commands() function will initialize
these commands.  If the registration record creates a new command, then
the chained commands are created under it; otherwise, they are created
in the same context as the other commands (i.e. the parent argument).
2009-11-24 21:37:30 -08:00
Zachary T Welch
607634f967 more command registration refactoring
Split out the handler registration into its own function, and add a
few obviously missing NULL pointer error checking.
2009-11-24 21:37:30 -08:00
Zachary T Welch
25a7ac2c75 command: use register_commands for handlers
Use register_commands() to register low-level command handlers,
adding a builtin_command_handlers declaration that is easy to understand.
Splits help and usage information into their appropriate fields.
2009-11-24 21:37:30 -08:00
Zachary T Welch
d107f71c50 add command usage, separate from help
Adds the usage command, to display usage information for commands.
The output for this command will remain erronenously empty until
commands are updated to use these new coventions.
2009-11-24 21:37:29 -08:00
Zachary T Welch
2461855494 add register_commands for batch registration
The register_commands API takes multiple commands in one call, allowing
modules to declare and pass a much simpler (and more explicit) array of
command_registration records.
2009-11-24 21:37:29 -08:00
Zachary T Welch
69076057dd add struct command_registration
Add a structure to encapsulate command registration information, rather
than passing them all as parameters.  Enables further API changes that
require additional required or optional parameters.

Updates the register_command API and COMMAND_REGISTER macro to use it,
along with their documentation.
2009-11-24 21:37:29 -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
f7e1f2df74 add COMMAND_REGISTER macro
Provides a migration path for the widely used register_command API,
which needs to be updated to provide new functionality.

This macro allows the API to change without having to update all of its
callers at the same time.
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
Andreas Fritiofson
338a674faa improve alloc_vprintf
The previous implementation was unnecessarily complex. Get rid of the loops,
let vsnprintf() tell us directly how much storage we need and allocate that. A
second pass writes the actual string. Also add a va_end() that was missing.
This should be much faster for large strings and less wasteful for small ones.

A quirk that has been retained is that some callers patch in a newline at the
end of the returned string and depend on alloc_vprintf to allocate at least
one byte extra.

Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: Zachary T Welch <zw@superlucidity.net>
2009-11-24 12:48:02 -08:00
Andreas Fritiofson
0583cb0a0d support for scripts in $HOME/.openocd
Add $HOME/.openocd as the first default script search directory, allowing
the user to override the standard scripts.

Update the user guide with information on where OpenOCD expects to find
configuration files and scripts. Also fixed some minor formatting issues.

Add entry to NEWS as well.

Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-24 08:57:02 +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
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
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
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
4d8d1d32d0 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.
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
Zachary T Welch
bd5a1799ea 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.
2009-11-18 15:51:07 -08:00
Zachary T Welch
5e229bbf87 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.
2009-11-18 07:22:22 -08:00
Zachary T Welch
cb7dbc1af4 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.
2009-11-18 07:21:42 -08:00
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
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
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
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
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
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
a94748ec6d 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.
2009-11-16 09:58:11 -08:00
Zachary T Welch
f0ce88b3af 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).
2009-11-16 09:57:59 -08:00
Zachary T Welch
da4cb3c029 Add FILEIO_NONE access mode.
In some cases, the FILEIO_NONE access mode may be useful as a parameter
to indicate that file access should be disabled.  High-level routines can
use it to skip file access calls, as 'fileio_open' will fail presently
if called to open a file using this mode.
2009-11-16 01:38:19 -08:00
Zachary T Welch
45527ee82c binarybuffer: add API documentation
Adds Doxygen documentation for a number of the binarybuffer APIs,
including "unexpected" behavior exposed during review on the list.
2009-11-16 01:25:47 -08:00
Zachary T Welch
d6348d4316 improve inline binarybuffer helpers
Use void*, unsigned, and bool types with inline helpers.
2009-11-16 00:46:34 -08:00
Zachary T Welch
21b452cf67 improve buf_set_buf helper
Use void * and unsigned types for buffer and their sizes.
Allows it to be used with more than uint8_t * without casts.
2009-11-16 00:46:34 -08:00
Zachary T Welch
d8d8c5d8c3 improve buf_set_ones
Use memset instead of loop. Improve types, using void * and unsigned.
2009-11-16 00:46:34 -08:00
Zachary T Welch
d09e308130 improve buf_cpy helper
Use memcpy for bulk of copy, improve final byte handling.
Improve types by using void * for buffers and unsigned for size.
2009-11-16 00:46:34 -08:00
Zachary T Welch
e4ee891759 improve buf_cmp and buf_cmp_mask helpers
Rewrite buf_cmp to use memcpy for bulk of comparison.  Add static
helper to perform comparison of trailing byte, which uses another
static helper to perform a maksed comparison.  The masked comparison
helper is used by the buf_cmp_mask to simplify its loop.
Improve types to use void *, unsigned, and return bool.
2009-11-16 00:46:33 -08:00
Zachary T Welch
d50caa97d1 improve str_to_buf and buf_to_str helpers
Improve types: use void * and unsigned.  Move all variables to point of
first use.  Move radix guessing logic to new str_radix_guess helper.
2009-11-16 00:46:33 -08:00
Zachary T Welch
5a43bd2e18 binarybuffer: move variables to point of first use
Reduce some noise from subsequent patches.
2009-11-16 00:46:33 -08:00
Zachary T Welch
82fc2f9628 binarybuffer: fix whitespace related issues
Add inter-operator whitespace.  Improve existing documentation.
2009-11-16 00:46:33 -08:00
David Brownell
1186f7efa7 target: less implicit inclusion of "command.h"
Lots of files still include it, often through needless
duplicate inclusion of "log.h"; sigh.

This cleans up the inclusion graph a bunch, so there are
fewer inclusion paths, but it doesn't change much otherwise.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-16 00:35:11 -08:00
Zachary T Welch
bc07ee82fb remove unused buf_to_u32_handler
Purge an unused routine from the tree and remove a layering violation.
If this code is needed, it should reappear somwhere in src/jtag/,
where struct scan_field gets defined.
2009-11-14 18:21:02 -08:00
Zachary T Welch
4d4b2958a5 struct scan_field_s -> struct scan_field
Remove obsolete suffix from struct scan_field.  Somehow, these
definitions did not get updated but did not cause any errors.
2009-11-14 18:21:02 -08:00
Zachary T Welch
ef746e27c5 command_t -> struct command
Remove misleading typedef and redundant suffix from struct command.
2009-11-13 13:30:50 -08:00
Zachary T Welch
98723c4ecd command_context_t -> struct command_context
Remove misleading typedef and redundant suffix from struct command_context.
2009-11-13 13:25:47 -08:00
Zachary T Welch
42ef503d37 jtag_tap_t -> struct jtag_tap
Search and destroy the jtag_tap_t typedef.  This also cleans up a
layering violation, removing the declaration from types.h.
2009-11-13 11:58:04 -08:00
Zachary T Welch
9f212b01be fileio_t -> struct fileio
Remove useless structure typedef.
2009-11-13 11:58:04 -08:00
Zachary T Welch
f59ec2043b log_callback_t -> struct log_callback
Removes useless and confusing typedef for log callback structure.
Types with _t should be suitable for passing by-value as arguments.
2009-11-13 11:58:04 -08:00
Zachary T Welch
f973320cbb command_handler_t: make cmd an indirect parameter
This patch removes 'cmd' from the list of direct parameters, moving
that pointer to args[-1] (by way of the new CMD_NAME macro).
2009-11-13 10:56:55 -08:00
Zachary T Welch
deede35c27 command_handler_t: make args parameter const
This patch prevents command handlers from modifying the strings passed
in the 'args' array.
2009-11-13 10:55:27 -08:00
Zachary T Welch
cc63d6e72b command_handler_t: make cmd parameter const
Prevents the command name from being modified in command handlers.
Again, this has cascading effects, but the patches are fairly minimal.
2009-11-13 10:55:27 -08:00
Zachary T Welch
d22270e0ed command_handler_t: make argc unsigned
The number of command arguments will always be 0 or more, so use
the right type in handlers.  This has a cascading effect up through
the layers, but the new COMMAND_HANDLER macros prevented total chaos.
2009-11-13 10:55:27 -08:00
Zachary T Welch
a585bdf726 add CMD_NAME macro for command handlers
By introducing the CMD_NAME macro, this parameter may be integrated
as args[-1] in command.[ch], without touching any other call sites.
2009-11-13 10:55:00 -08:00
Zachary T Welch
cfc4d5c6b7 use COMMAND_HANDLER macro to define all commands 2009-11-13 10:51:45 -08:00
Zachary T Welch
ddb6138ed4 add command_handler_t type
This patch adds new typedefs for command handler callback functions.
Users of this type signature were updated to use these new types.
It uses the new __COMMAND_HANDLER macro to prevent duplication.
2009-11-13 10:51:45 -08:00
Zachary T Welch
3f9fd4e2a6 add COMMAND_HANDLER and COMMAND_HELPER macros
The COMMAND_HANDLER and COMMAND_HELPER macros allow commands to be
defined in a manner that decouples them from the exact order and type of
their parameters.  Once converted, incremental changes to the command
handler type can be addressed in incremental patches that do not need to
touch the entire tree.

These macros' implementation, __COMMAND_HANDLER, is used to define the
new command_handler_t type, and additional patches will use it to derive
new macros to define extended command types (e.g. flash, nand, pld).
The CALL_COMMAND_HANDLER provides a means of calling helpers or nested
handlers from withing a command handler.

This patch uses C99 varadic macro expansion.  Please report compilers
that cannot handle this code.
2009-11-13 10:51:45 -08:00
Zachary T Welch
1ae4d93c3c add command_output_handler_t
Add a typedef for command output handler function type, simplifying
the appearance of functions that use it and eliminating duplicate code.
2009-11-13 10:51:45 -08:00
Zachary T Welch
158698e333 improve command registration
Eliminate duplicate code for linking commands into a list.

Adds a check to ensure the command does not already exist;
if it does, return that one instead of creating a duplicate.
2009-11-11 13:50:28 -08:00
Zachary T Welch
46d9ba4c8b add help regardless of callback
Add help for commands regardless of whether a handler is involved.
With this, all sorts of new commands can be found in 'help' text.
Hopefully, all of them have been documented....

Sadly, the lsort function appears to handle nested lists poorly, such
that sub-commands do not group with their parents.
2009-11-11 12:15:39 -08:00
Zachary T Welch
a1a3ee579c eliminate duplicate helptext management
Add helpers to manage adding entries to the helptext list.
Adds support for arbitrarily nested commands.
2009-11-11 12:15:39 -08:00
Zachary T Welch
2d3cc1eac1 add command_name helper
The command_name function returns a malloced string for a given
command and its parents.  This can be used to display a message
to the user, but it is used internally to handle registration
and syntax errors.  This helps permit arbitrary command nesting.
2009-11-11 12:15:39 -08:00
Zachary T Welch
f93c98081f wrap help command
Use continuation characters to wrap the help command into 80 columns.
2009-11-11 12:15:39 -08:00
Zachary T Welch
e09d8938f5 script_debug(): improve types
Use unsigned type for number of arguments.
2009-11-11 05:40:48 -08:00
Zachary T Welch
c942969377 command.c: make private routines static
This patch also improves the signature of run_command function.
2009-11-11 05:40:48 -08:00
Zachary T Welch
6a2e83c017 log: improve log_callback_fn signature
Use unsigned type for line number in log_callback_fn signature.
2009-11-11 05:40:48 -08:00
Zachary T Welch
0cd414c7d6 time_support: improve use of types
Update timeval_add_time to use long int; implement timeval_add with it.
Update timeval_ms to check gettimeofday return value, return int64_t.
2009-11-11 05:40:48 -08:00
Øyvind Harboe
151a270695 tcl: HostOs now picks up eCos as well during compile time
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-11-10 08:36:19 +01:00
Zachary T Welch
841721929a command.c: make commands static
Removes useless declarations, moving the handler functions to appear
before their use in the (much bigger) command registriation function.
2009-11-09 21:39:46 -08:00
Zachary T Welch
1712d7835e src/helper: wrap and clean headers.
Remove all useless 'extern' keywords from function prototypes.
Wraps long lines for readability.
2009-11-09 09:44:33 -08:00
David Brownell
4882647f3e User's Guide: bugfix global state info
The "$ocd_HOSTOS" variable was wrongly documented.  Fix its
documentation, and its value on Linux.

Shrink a few of the too-long lines.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-11-09 09:40:55 -08:00
Zachary T Welch
2689f58f2a Overhaul time support API
This patch changes the duration_* API in several ways.  First, it
updates the API to use better names.  Second, string formatting has
been removed from the API (with its associated malloc).  Finally, a
new function added to convert the time into seconds, which can be
used (or formatted) by the caller.  This eliminates hidden calls to
malloc that require associated calls to free().

This patch also removes the useless extern keyword from prototypes,
and it eliminates the duration_t typedef (use 'struct duration').
These API also allows proper error checking, as it is possible for
gettimeofday to fail in certain circumstances.

The consumers have all been chased to use this new API as well, as
there were relatively few cases doing this type of measurement.
In most cases, the code performs additional checks for errors, but
the calling code looks much cleaner in every case.
2009-11-09 01:21:50 -08:00
Zachary T Welch
f6f1dbfafd Improve debug_level command argument parsing. 2009-11-05 18:03:18 -08:00
Zachary T Welch
36a3646c22 Add macro for parsing numeric command arguments.
This helper eliminates significant amount of redundant code in command
handler functions throughout the system.  It wraps the lower-level
parse_* macros to implement a policy for reporting parse errors to the
active command context (cmd_ctx).  If errors do occur, this macro causes
the calling function to abort with the proper return code.
2009-11-05 17:27:25 -08:00
Zachary T Welch
68785af4da Add stringify macros in src/helper/types.h. 2009-11-05 17:20:18 -08:00
Spencer Oliver
e8a5092f1e bin2char: for win32 set stdin/stdout to binary mode
Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
2009-10-30 11:59:57 +00:00
Øyvind Harboe
a02411a15f eCos synthetic target updates. 2009-10-21 12:02:04 +02:00
Redirect 'Slash' NIL
113679ff59 corrective fix for MinGW GNU C99 printf compliance
Compilation on cygwin, using gcc v3 with option -mno-cygwin,
currently produces a large number of the following warnings:

   warning: `gnu_printf' is an unrecognized format function type

These have been introduced with the recent MinGW GNU C99 printf
compliance patch, as gnu_printf was only introduced with gcc v4.4
and is not recognized with earlier versions.

The attached fix adds gcc version detection to the previous patch
to avoid the problem.
2009-10-19 09:49:34 -07:00
oyvind
557d1b6490 Sync with official Jim Tcl repository. 2009-10-19 15:16:42 +02:00
Redirect 'Slash' NIL
990f50a73b safer conversion to HANDLER on MinGW-W64
Assign to "intptr_t", which on some versions of MS-Windows
will widen the variable; then cast to HANDLE.
2009-10-17 22:18:38 -07:00
Redirect 'Slash' NIL
73349dc5ac More MinGW C99 printf compliance
Passing "--std=gun99" is unfortunately not sufficient to make current
MinGW compilers conform with respect to checking printf format strings.
(The C runtime seems not to have problems.)

Fix by using a "gnu_printf" format specifier not "printf".
2009-10-17 17:47:52 -07:00
Redirect \"Slash\" NIL
c9fbfbd95c jim-eventloop for MinGW-w64
Use JIM_WIDE_MODIFIER for the sscanf format, and apply it for MINGW32 as
well as other Windows environments.  (Microsoft doesn't conform to the
C99 standard, and uses "%I64d" not "%lld" for "long long".)

NB: __MINGW32__ should work on both w32 and w64,.
2009-10-17 12:15:13 -07:00
David Brownell
cb7965da15 xscale: better fix for debug_handler.bin
Generate a C struct with the data, and use that, instead of an
assembly language file.  The assembly language causes issues on
Darwin and MS-Windows, which don't necessarily use GNU AS; or
if they do, don't necessarily use its ELF syntax.

It's also better in two other ways:  fewer global symbols; and
the init-time size check gets optimized away at compile time.
(Unless it fails, in which case bigger chunks of the file vanish.)

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-10-16 13:52:40 -07:00
David Brownell
510db585fd portability updates
Based on some patches from <redirect.slash.nil@gmail.com>
for preliminary Win64 compilation.  More such updates are
needed, but they need work.  Compile tested on 64 and 32 bit
Linuxes, and Cygwin.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-10-14 20:04:33 -07:00
David Brownell
bc792857a5 doc updates to match "help" better
This makes the documentation a closer match to "help" output:

 - "pathmove" somehow was not documented in the User's Guide

 - "jtag_nsrst_assert_width" and "jtag_ntrst_assert_width"
   are new; both needed descriptions.

 - Removed two undocumented and fairly useless script mechanisms:
    * production/production_info/production_test ... using it,
      requires replacing everything; so having it adds no value.
    * cpu ... way out of date; hopeless to keep that current

Note that anyone using that "production" stuff already defines
their own procedures, and can keep using them with no change.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-10-14 15:18:00 -07:00
Øyvind Harboe
4d32b6eee9 Missing type for eCos. 2009-10-13 13:13:29 +02:00
David Brownell
6160a946ec add overridable Tcl "init_reset"
This abstracts the "jtag arp_init-reset" call into a method
called from OpenOCD startup and reset processing.

Platforms which have different requirements for how such hard
resets must be performed can now override "init_reset" instead
of needing to rebuild custom hacked versions of the server.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-10-08 23:51:50 -07:00
Øyvind Harboe
d75b9ec697 Update copyright statements. Make it easier to sync with Jim Tcl 2009-10-08 13:56:57 +02:00
oharboe
39b57471bf Introduced jtag_init and "jtag arp_init" to allow target scripts more control over how OpenOCD starts up and initializes the target.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2805 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-10-06 08:10:57 +00:00
dbrownell
f64e924ba9 Updates to the initial scanchain validation code:
- minor bug fixes
  - code cleanup
  - update comments
  - improve diagnostics
  - etc


git-svn-id: svn://svn.berlios.de/openocd/trunk@2759 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-26 19:18:42 +00:00
oharboe
1c262c8826 Try/catch scheme. Typed up the functionality and regression tested.
Ready for discussion and tiny patches that tries out this scheme.

git-svn-id: svn://svn.berlios.de/openocd/trunk@2755 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-25 11:11:39 +00:00
dbrownell
23e22b6ec4 Start handling the (second) SRST stage of reset better:
make sure that when there are two or more targets, their
various pre/post event reports are correctly ordered.

Previously, only the first target always saw its "pre"
method before SRST was asserted or deasserted.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2753 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-23 22:03:41 +00:00
oharboe
7393fcfc90 Nico Coesel <ncoesel@dealogic.nl> fix warnings. . I'm wondering why these
didn't turn up earlier. Is everyone still using gcc 3.x? Or is the x86
version of gcc 4.x much more relaxed?

git-svn-id: svn://svn.berlios.de/openocd/trunk@2749 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-23 07:14:03 +00:00
dbrownell
86a7d813a1 Remove annoying end-of-line whitespace from most src/*
files; omitted src/httpd


git-svn-id: svn://svn.berlios.de/openocd/trunk@2742 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-21 18:40:55 +00:00
dbrownell
358263f484 Tweak TCL reset script ... mostly improving descriptions of
the various steps, but also calling [target names] only once.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2726 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-18 00:11:51 +00:00
dbrownell
9655c5b093 Fix coredump seen in some code paths.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2723 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-17 18:52:32 +00:00
oharboe
14dc22612b error message upon recursive invocation of reset from reset event handlers
git-svn-id: svn://svn.berlios.de/openocd/trunk@2707 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-14 13:54:49 +00:00
oharboe
072d6d3db6 Dirk Behme <dirk.behme@googlemail.com> Fix typo in help text. It has to be 'production_test' instead of 'production' here.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2654 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-08-30 20:08:07 +00:00
oharboe
d879faa3cb David Brownell <david-b@pacbell.net> start phasing out integers as target IDs
git-svn-id: svn://svn.berlios.de/openocd/trunk@2650 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-08-30 17:30:14 +00:00
oharboe
4b9bdd664a David Brownell <david-b@pacbell.net> Be sure the built-in search paths always go *after* ones provided
on the command line ... matching comment in add_default_dirs().

Without this it's impossible to use a private config file which
happens to have the same name as an installed one.  Say, because
you're bugfixing a private copy...

git-svn-id: svn://svn.berlios.de/openocd/trunk@2649 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-08-30 17:27:50 +00:00
oharboe
0ed5f5afd9 add missing isblank() for eCos
git-svn-id: svn://svn.berlios.de/openocd/trunk@2607 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-08-25 06:45:40 +00:00
oharboe
bf5f21e39a Steve Grubb <sgrubb@redhat.com> fix various and sundry leaks
git-svn-id: svn://svn.berlios.de/openocd/trunk@2606 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-08-24 07:53:46 +00:00
ntfreak
bb5086b83e Jonas Horberg [jhorberg@sauer-danfoss.com]
Change jtag_rclk behaviour so it can be called before the interface init function

git-svn-id: svn://svn.berlios.de/openocd/trunk@2590 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-08-18 12:14:01 +00:00
oharboe
8b994145b8 Andreas Fritiofson <andreas.fritiofson@gmail.com> UTF8 fixes
git-svn-id: svn://svn.berlios.de/openocd/trunk@2549 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-17 19:54:25 +00:00
oharboe
fc889f0357 delete long retired commented out code (daemon_startup)
git-svn-id: svn://svn.berlios.de/openocd/trunk@2487 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-07 10:43:44 +00:00
ntfreak
d41f2bfb14 - fix build when using a cross compiler - do not try and run any host tools
- add missing types.h when platform does not contain elf.h

git-svn-id: svn://svn.berlios.de/openocd/trunk@2482 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-06 15:19:10 +00:00
oharboe
5fe4500e50 try to use tabs instead of spaces
git-svn-id: svn://svn.berlios.de/openocd/trunk@2465 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-06 08:01:22 +00:00
oharboe
fca8cddc26 human readable error message upon invalid arguments
git-svn-id: svn://svn.berlios.de/openocd/trunk@2464 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-06 07:33:38 +00:00
zwelch
f7c85c42a0 Add missing copyright header and fix @page direction in membuf.h.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2443 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-01 19:55:39 +00:00
zwelch
1d61e34e1e Fix doxygen 'undocumented parameter' warnings in membuf.h.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2426 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-30 05:34:36 +00:00
duane
9c05c92c14 Switch to strotk() grr....
git-svn-id: svn://svn.berlios.de/openocd/trunk@2406 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-27 16:44:35 +00:00
duane
8adda07ed1 Fixes from Oleksandr Tymoshenko "gonzo@bluezbox.com"
git-svn-id: svn://svn.berlios.de/openocd/trunk@2401 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-25 00:12:40 +00:00
zwelch
fddbc58091 Remove whitespace at end of lines, step 2.
- Replace '\s*$' with ''.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2398 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:38:21 +00:00
zwelch
2428bc2a5c - Replace '){' with ') {'.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2397 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:38:15 +00:00
zwelch
f11b1ff485 Remove whitespace that occurs before ')'.
- Replace '[ \t]*[)]' with ')'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2396 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:38:08 +00:00
zwelch
1793150091 Remove whitespace that occurs after '('.
- Replace '([ \t]*' with '('.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2395 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:38:01 +00:00
zwelch
dbb0f31abb - Fixes '[<>]' whitespace
- Replace '\(\w\)\([<>]\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2394 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:37:56 +00:00
zwelch
9cd160608c - Fixes '+' whitespace
- Replace '\(\w\)\(+\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2392 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:37:44 +00:00
zwelch
5e53d488dc - Fixes '=' whitespace
- Replace '\(\w\)\(=\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2391 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:37:37 +00:00
zwelch
e47be43ed1 - Fixes '==' whitespace
- Replace '\(\w\)\(==\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2390 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:37:31 +00:00
zwelch
c3e7d33b54 - Replace 'for(' with 'for ('.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2389 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:37:23 +00:00
zwelch
cb3429570c - Replace 'if(' with 'if ('.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2386 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 09:37:05 +00:00
zwelch
3324841558 Fix end-of-line style properties on newly added files.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2384 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 07:43:18 +00:00
duane
176b5600ed Add a growable sprintf memory buffer library
git-svn-id: svn://svn.berlios.de/openocd/trunk@2381 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-24 01:54:25 +00:00
zwelch
c97caebccd Remove whitespace at end of lines, step 2.
- Replace '\s*$' with ''.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2380 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:50:08 +00:00
zwelch
c493543fc9 - Replace '){' with ') {'.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2378 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:49:06 +00:00
zwelch
dc575dc5bf Remove whitespace that occurs before ')'.
- Replace '[ \t]*[)]' with ')'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2377 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:47:42 +00:00
zwelch
f90d8fa45f Remove whitespace that occurs after '('.
- Replace '([ \t]*' with '('.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2376 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:46:23 +00:00
zwelch
6d1d58a1fc - Fixes '[<>]' whitespace
- Replace ')\([<>]\)(' with ') \1 ('.
- Replace ')\([<>]\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\([<>]\)(' with '\1 \2 ('.
- Replace '\(\w\)\([<>]\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2375 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:45:47 +00:00
zwelch
fb1a9b2cb2 - Fixes '[|]' whitespace
- Replace ')\([|]\)(' with ') \1 ('.
- Replace ')\([|]\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\([|]\)(' with '\1 \2 ('.
- Replace '\(\w\)\([|]\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2374 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:45:15 +00:00
zwelch
8959de9f67 - Fixes '+' whitespace
- Replace ')\(+\)(' with ') \1 ('.
- Replace ')\(+\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(+\)(' with '\1 \2 ('.
- Replace '\(\w\)\(+\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2373 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:44:17 +00:00
zwelch
84df52f9ea - Fixes '=' whitespace
- Replace ')\(=\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(=\)(' with '\1 \2 ('.
- Replace '\(\w\)\(=\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2372 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:42:54 +00:00
zwelch
3813fda44a - Fixes '==' whitespace
- Replace ')\(==\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(==\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2371 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:42:03 +00:00
zwelch
aea6815462 - Fixes '<<' whitespace
- Replace ')\(<<\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(<<\)(' with '\1 \2 ('.
- Replace '\(\w\)\(<<\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2370 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:41:13 +00:00
zwelch
0e2c2fe1d1 - Fixes '>>' whitespace
- Replace ')\(>>\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(>>\)(' with '\1 \2 ('.
- Replace '\(\w\)\(>>\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2369 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:40:42 +00:00
zwelch
6319ea33f7 - Fixes '<=' whitespace
- Replace '\(\w\)\(<=\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2368 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:40:33 +00:00
zwelch
4ce93ac479 - Fixes '>=' whitespace
- Replace ')\(>=\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(>=\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2367 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:40:10 +00:00
zwelch
128a733428 - Fixes '&&' whitespace
- Replace ')\(&&\)(' with ') \1 ('.
- Replace '\(\w\)\(&&\)(' with '\1 \2 ('.
- Replace '\(\w\)\(&&\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2366 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:39:47 +00:00
zwelch
d61714f4d5 - Fixes '[+]=' whitespace
- Replace '\(\w\)\([+]=\)(' with '\1 \2 ('.
- Replace '\(\w\)\([+]=\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2364 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:39:18 +00:00
zwelch
53d605e12c - Fixes '!=' whitespace
- Replace ')\(!=\)\(\w\)' with ') \1 \2'.
- Replace '\(\w\)\(!=\)(' with '\1 \2 ('.
- Replace '\(\w\)\(!=\)\(\w\)' with '\1 \2 \3'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2363 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:38:12 +00:00
zwelch
95d2a23724 - Replace 'for(' with 'for ('.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2360 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:37:21 +00:00
zwelch
9af5e445b7 - Replace 'switch(' with 'switch ('.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2359 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:36:56 +00:00
zwelch
50c086ffb9 - Replace 'while(' with 'while ('.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2358 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:36:11 +00:00
zwelch
e43979e702 - Replace 'if(' with 'if ('.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2357 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 22:35:09 +00:00
oharboe
8591335ba6 update w/missing eCos definitions after latest round of compiler formatting warnings fixes
git-svn-id: svn://svn.berlios.de/openocd/trunk@2356 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23 07:38:01 +00:00
ntfreak
1d9ce8d2b3 - fix break caused by r2208 when using --pipe option
- issue is gdb stdin buffer gets full before we redirect openocd output

git-svn-id: svn://svn.berlios.de/openocd/trunk@2350 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-21 21:20:10 +00:00
duane
836b6c18f0 C99 Type updates, include inttypes.h - it is catagorically required
git-svn-id: svn://svn.berlios.de/openocd/trunk@2296 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-21 02:59:39 +00:00
zwelch
580a05a07f Remove editor preferences from source files.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2294 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-19 23:56:52 +00:00
zwelch
e8ba53ef6f Oyvind Harboe <oyvind.harboe@zylin.com>:
Ecos uses sys/types.h not stdint.h.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2286 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 10:42:40 +00:00
zwelch
4cf8d5ec17 Remove redundant typedefs in types.h; include stdint.h unconditionally.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2283 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 07:11:48 +00:00
zwelch
0ca97d82d8 Transform 'u64' to 'uint64_t'
- Replace '\([^_]\)u64' with '\1uint64_t'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2282 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 07:11:40 +00:00
zwelch
86e4324f1b Finish transforming 'u32' to 'uint32_t'.
- Replace '\([^_]\)u32' with '\1uint32_t'.
- Replace '^u32' with 'uint32_t'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2281 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 07:11:11 +00:00
zwelch
f876d5e9c7 Transform 'u16' to 'uint16_t'
- Replace '\([^_]\)u16' with '\1uint16_t'.
- Replace '^u16' with 'uint16_t'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2277 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 07:07:59 +00:00
zwelch
c18947b947 Transform 'u8' to 'uint8_t'
- Replace '\([^_]\)u8' with '\1uint8_t'.
- Replace '^u8' with 'uint8_t'.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2276 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 07:07:12 +00:00
zwelch
ed5b5b834e Fix compilation for Ubuntu 9.04 on x86-64 when using --enable-httpd.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2262 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 06:10:10 +00:00
zwelch
2d0afa36a8 Ensure range errors are reported only when errno indicates one occurred.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2260 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:31:06 +00:00
zwelch
c0f4495d5e Change parse_type macros to be sed-friendly.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2259 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:30:52 +00:00
zwelch
d579befc07 Add argument parsing errors in command.h, use in parse_type routines.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2258 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:30:44 +00:00
zwelch
0e28997989 Move definition of parse_type helpers to command.c:
- Add declarations in header file.
- Improve wrapper implementations to check for underflow.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2257 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:30:36 +00:00
zwelch
06a1bb335e Convert core parse_type implementations to check for underflow errors.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2256 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:30:29 +00:00
zwelch
a830197f59 Add improved support for parsing signed integers.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2255 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:30:20 +00:00
zwelch
a3ec1e1f94 Update parse_type macro definitions to allow re-use with signed types.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2254 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:30:11 +00:00
zwelch
8b16068941 Improve definitions of parse_ulong and parse_ullong:
- Use macro to eliminate duplicate body definitions.
- Rename okay as is_okay; add parenthesis to help "clarify" logic.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2253 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-17 00:29:56 +00:00
oharboe
588a17da43 fix eCos build problems w/latest parse_ulong() stuff
git-svn-id: svn://svn.berlios.de/openocd/trunk@2241 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-15 14:22:13 +00:00
zwelch
cdd8f23b9b David Brownell <david-b@pacbell.net>:
Currently the "debug_level 3" command tracing ignores commands
that could return values to TCL scripts (by plugging in to a
slightly lower level of the interpreter stack).

Fix that by abstracting the tracing command and starting to
make some of those previously-untraced commands use this new
mechanism.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2224 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-12 22:06:02 +00:00
zwelch
0f6a47837e Simplify and improve handle_debug_level_comamnd:
- Bug fix: Return a syntax error if more than one argument is given.
- Bug fix: Use new parse_uint helper ensure debug_level parses correctly.
- Change: Display the debug_level after it has been set.
- Simplify bounds checking of debug_level.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2208 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-12 01:39:57 +00:00
zwelch
5af1bdcff4 Simplify handle_sleep_command:
- Use new parse_ulong to ensure duration parses as a valid number.
- Rework logic to improve readability and seliminate uperfluous braces.
- Change whitespace to improve style.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2207 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-12 01:39:51 +00:00
zwelch
5c123481a1 Add new parse_uinttype wrappers for strtoul in src/helper/command.[ch].
- Used to improve command argument parsing of unsigned integers values.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2206 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-12 01:39:44 +00:00
zwelch
5bb0f1d29a David Brownell <david-b@pacbell.net>:
Minor bugfix:  command_print_sameline() is what the
headers declare; make the code match.

Minor improvement:  make the printf format params always be const.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2205 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-11 21:55:43 +00:00
oharboe
1b2c1c6ff0 fix ordering of arguments to fwrite()
git-svn-id: svn://svn.berlios.de/openocd/trunk@2197 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-11 13:00:08 +00:00
zwelch
00228aa839 Fix make maintainer-clean for out-of-tree builds.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2172 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-09 10:28:16 +00:00
zwelch
695c6c0960 David Brownell <david-b@pacbell.net>:
Let disabled targets be ignored during normal operation:

 - In target_examine(), ignore disabled TAPs

 - Reset handling must not poke at them either:
     * fail $target_name arp_* operations on disabled TAPs
     * in startup.tcl, don't even issue the arp_* wait ops 

ZW: removed superfluous braces from the patch to target.c.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2100 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-07 23:35:29 +00:00
oharboe
aee65603ee remove hacks no longer required to build OpenOCD w/eCos
git-svn-id: svn://svn.berlios.de/openocd/trunk@2074 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-05 06:43:09 +00:00
oharboe
3b3a5b642c remove unused include file: inttypes.h
git-svn-id: svn://svn.berlios.de/openocd/trunk@2072 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-05 06:41:54 +00:00
zwelch
9a5acdc161 Improve in-source documentation that was causing Doxygen warnings.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2025 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-03 04:37:51 +00:00
oharboe
cd5e09303c more missing eCos types
git-svn-id: svn://svn.berlios.de/openocd/trunk@2001 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-02 10:07:47 +00:00
zwelch
e8e0af3956 Whitespace-only updates to automake input files:
- use continuations to break long lines of variable assignments
- makes these variables more patch-friendly and conform to style guide


git-svn-id: svn://svn.berlios.de/openocd/trunk@1970 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-31 12:10:57 +00:00
kc8apf
35d8b2bf77 Author: Nicolas Pitre <nico@cam.org>
- Silence errors about keep_alive() not being called frequently enough unless
	a gdb session is active or debugging is enabled


git-svn-id: svn://svn.berlios.de/openocd/trunk@1933 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-27 20:30:17 +00:00
zwelch
dd86b54e6e Update build system to find moved scripts -- Step 3 of 2:
- Update references from using PKGLIBDIR to PKGDATADIR.
- Update built-in script search paths to reflect new install location:
  - $(pkgdatadir)       =>   $(pktdatadir)/site
  - $(pkglibdir)        =>   $(pktdatadir)/scripts
- Update installed location of httpd files:
  - $(pkglibdir)/httpd   =>   $(pkgdatadir)/httpd


git-svn-id: svn://svn.berlios.de/openocd/trunk@1920 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-27 07:49:58 +00:00
zwelch
2e55b68360 David Brownell <david-b@pacbell.net>:
The "Illegal mode for command" diagnostic is deeply useless.
Say "Command '%s' only runs during configuration stage" instead,
letting users know what the real issue is.


git-svn-id: svn://svn.berlios.de/openocd/trunk@1908 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-24 20:57:53 +00:00
oharboe
2f8c6015ba delete unused code
git-svn-id: svn://svn.berlios.de/openocd/trunk@1878 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-21 17:44:04 +00:00
oharboe
576b8a8a48 fix warning. Use %p for pointers
git-svn-id: svn://svn.berlios.de/openocd/trunk@1877 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-21 17:42:19 +00:00
zwelch
08c11a4c70 Additional format warning fixes in ioutil, required by r1873 changes.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1874 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-21 09:49:19 +00:00
zwelch
570631454d David Brownell <david-b@pacbell.net>: This patch adds annotations to
the key command_*() helper functions, fixng the bugs that turned up.

Several of these bugs were from misuse of PRIi64; that's for 64-bit
integers, NOT for "long long" or "u64" (which work best with %lld).


git-svn-id: svn://svn.berlios.de/openocd/trunk@1873 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-21 09:28:57 +00:00
oharboe
208fda15d5 fix warnings
git-svn-id: svn://svn.berlios.de/openocd/trunk@1837 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-19 14:36:04 +00:00
oharboe
a8daf2251d Remove unecessary(and poptentially harmful?) "" around arguments
passed in to "eval" in command.c


git-svn-id: svn://svn.berlios.de/openocd/trunk@1811 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-18 13:55:38 +00:00
oharboe
7eaed436c6 less weird error messages for unknown commands. Check if command exists before trying it.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1810 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-18 13:07:37 +00:00
zwelch
ea3ddc7e4f Initialize a more variables in jim.c to allow gcc-4.4 to build.
Fix provided by Benjamin Schmidt <DeMonk@gmx.net>.


git-svn-id: svn://svn.berlios.de/openocd/trunk@1797 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-15 23:35:27 +00:00
zwelch
5cff9997c5 Initialize value of objPtr local variable; prevents warning w/ gcc-4.4.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1796 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-15 22:10:32 +00:00