Commit Graph

846 Commits

Author SHA1 Message Date
Spencer Oliver adb8ec32dc icdi: add TI icdi interface
This is the new proprietary interface replacing the older FTDI based adapters.
It is currently fitted to the ek-lm4f232 and Stellaris LaunchPad.

Change-Id: I794ad79e31ff61ec8e9f49530aca9308025c0b60
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/922
Tested-by: jenkins
2012-12-23 21:46:20 +00:00
Spencer Oliver 27ad96e0d9 helper: fix code formatting
Change-Id: Ide2d704c9ef4f5563649d5db53bbdd3641868b70
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/995
Tested-by: jenkins
2012-12-03 16:37:03 +00:00
Aymeric Vincent 1a8223f28b Make NetBSD a recognized system
Change-Id: I7fcb540553da7833a8b6a82335a7296539a8f491
Signed-off-by: Aymeric Vincent <vincent.aymeric@gmail.com>
Reviewed-on: http://openocd.zylin.com/998
Reviewed-by: Peter Stuge <peter@stuge.se>
Tested-by: jenkins
2012-11-30 17:16:45 +00:00
Edgar Grimberg 6f65045b37 ioutil: make the file compile on MacOS
The meminfo command cannot exist if the malloc.h header is not
present.
Cannot get the mac address without sys/ioctl.h and SIOCGIFHWADDR
defined

Change-Id: Ifc0fb98c3a60c53ad2e19473e08b34c460529d0b
Signed-off-by: Edgar Grimberg <edgar.grimberg@gmail.com>
Reviewed-on: http://openocd.zylin.com/912
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Peter Stuge <peter@stuge.se>
2012-10-28 01:38:58 +00:00
Spencer Oliver 8a271d9dd1 build: remove unnecessary jim.h include
as well as not being required, as it is already included by jim-nvp.h.
It also makes the doxygen output a bit clearer to read.

Change-Id: Ia2bed7142b4a56b48b1ecf0734e63f860dcd1014
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/859
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2012-10-02 11:36:39 +00:00
Freddie Chopin 07158a7f8a Add another scripts search path for Windows builds
Add single "scripts" folder to search path for Windows OpenOCD builds
that don't use cygwin
bin/openocd.exe
scripts/interface/dummy.cfg
scripts/target/at91eb40a.cfg

Do some refactoring of current code (thx to Andreas).

Change-Id: Idbb08d1368b06f25da44f4f9ab1511db992b1724
Signed-off-by: Freddie Chopin <freddie.chopin@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/785
Tested-by: jenkins
2012-08-29 06:26:21 +00:00
Spencer Oliver 0e4dee1164 helper: command.c cleanup
Change-Id: I66643960e38625e843b5f54d1c072e4eee78284d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/772
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2012-08-24 16:49:30 +00:00
Alan Bowman 8cf671ea7b Test the incoming debug_level, rather than the current.
The existing code tests the current debug_level for validity, allowing
the user to set it too high and never change it after that.  The new
behaviour is to test the debug_level that the user has requested.

Change-Id: I85726a2e606c8d137e9b1cfe76fee865084844b1
Signed-off-by: Alan Bowman <alan.michael.bowman@gmail.com>
Reviewed-on: http://openocd.zylin.com/764
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-07-27 09:50:34 +00:00
Alex Austin 10fd274cfe Revert "When calling openocd from a shell like this:"
This reverts commit e8641695c6

Original premise was wrong. Proper command is "shutdown", not "exit".

Change-Id: I07f5fe0dda9c24abe53628da986bfda0e406bb4a
Signed-off-by: Alex Austin <alex.austin@spectrumdsi.com>
Reviewed-on: http://openocd.zylin.com/757
Tested-by: jenkins
Reviewed-by: Peter Stuge <peter@stuge.se>
2012-07-22 19:18:22 +00:00
Stian Skjelsad e8641695c6 When calling openocd from a shell like this:
openocd -f board/sheevaplug.cfg -c init -c exit

the calling shell will believe that openocd exited with an error due to exitval will be non-zero

This is not tested against incomming telnet

Change-Id: I63d15715a7b46f39a7de261a45039f8c3cad7a98
Signed-off-by: Stian Skjelstad <stian@nixia.no>
Reviewed-on: http://openocd.zylin.com/470
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Bill Traynor <wmat@alphatroop.com>
Reviewed-by: Mathias Küster <kesmtp@freenet.de>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2012-07-11 08:16:04 +00:00
Andreas Fritiofson 6d639b09f0 Add a bit-level transfer queue
Interface drivers regularly need to keep track of where each part of a long
read buffer should be copied, once that data arrives. Both source and
destination are often at an arbitrary bit offset.

This queued bit-level copy can help with that, by allowing the driver to
perform postponed reads from the receive buffer already when building the
transmit buffer, and have those reads executed at a later time when data is
available.

For simplicity, it uses the linked list implementation list.h imported from
the Linux kernel.

Change-Id: I06862a0a6f057cbbcacfb021f17a795195faded2
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/450
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Reviewed-by: Peter Stuge <peter@stuge.se>
2012-07-06 14:58:25 +00:00
Spencer Oliver 7bfcc10839 build: add helper/types.h to config.h
this header is used in numerous files and adding to config.h
simplifies its use globally.

Change-Id: Id724a9950b90504721233022c7fb5768e9bc5548
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/649
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
2012-05-21 16:15:26 +00:00
Spencer Oliver 8cb0dae823 remote_bitbang: fix native windows build
Change-Id: Ied29ade0346c4595ffc1dafa788e2d5a595e0de3
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/648
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
2012-05-19 20:27:56 +00:00
Wim Lewis d40cb56d49 Add value "openbsd" for ocd_HOSTOS.
Change-Id: I9b0dd87d85c0792730f507176001d39c44da7117
Signed-off-by: Wim Lewis <wiml@hhhh.org>
Reviewed-on: http://openocd.zylin.com/547
Tested-by: jenkins
Reviewed-by: Peter Stuge <peter@stuge.se>
2012-03-31 04:02:24 +00:00
Øyvind Harboe 39650e2273 ecosboard: delete bit-rotted eCos code
Change-Id: Iff7943eb9da3f41dcc45492acd0f36cf63b3497f
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/503
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Tested-by: jenkins
2012-03-13 19:11:11 +00:00
Øyvind Harboe ed12a6521f flash: retire unused eCos flash driver
even the AT91EB40a's flash is covered by CFI and nobody ever submitted
any other drivers based on eCos code. It's just possible that this
idea was missing documentation and "marketing", but it's in git if
somebody wants to resurrect it.

Change-Id: I66449aa6e0997301f9d67f28098789bfc891d6e9
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/502
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-03-11 21:14:21 +00:00
Spencer Oliver 7719e2188e doxygen: use correct comment syntax
This issue was caused by uncrustify not correctly converting the doxygen
comments.

Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Change-Id: Ie6dc3b057a08603b670cb27312e5f0d989426e6c
Reviewed-on: http://openocd.zylin.com/431
Tested-by: jenkins
2012-02-06 12:55:03 +00:00
Spencer Oliver 8b00e56e64 build: cleanup src/helper directory
Change-Id: I71a312df783995e9083c345c25e73902d5aef59e
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/415
Tested-by: jenkins
2012-02-06 10:49:52 +00:00
Mathias K 16b6b5e7a8 Change return value on error.
On wrong parameters a error is signalized to the calling function.

Change-Id: I484443fdb39938e20382edc9246d5ec546a5c960
Signed-off-by: Mathias K <kesmtp@freenet.de>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/282
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-01-04 17:56:46 +00:00
Øyvind Harboe 4668bd264c retire ERROR_INVALID_ARGUMENTS and replace with ERROR_COMMAND_SYNTAX_ERROR
Change-Id: I6dee51e1fab1944085391f274a343cdb9014c7a4
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/300
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2012-01-04 17:13:46 +00:00
Mathias K 54d6330b78 command: print BUG warning when usage is missing
These error messages will prompt patches to be submitted for missing
.usage or empty fields. All of the below must be resolved before next
release.

The Jim defined commands are excluded from this checklist because the
help text can be set later than during command registration.

strlen(.usage) == 0 means that the command expects no arguments.

Updates to this patch in Gerrit to fix problems below are most
welcome. Anyone can push updated versions of a patch to Gerrit. If
there are no further updates to this patch within a week, it will be
pushed to the master branch to prompt more fixes.

These were caught by launching OpenOCD.

Error: BUG: command 'command' does not have the '.usage' field filled out
Error: BUG: command 'script' does not have the '.usage' field filled out
Error: BUG: command 'power_restore' does not have the '.usage' field filled out
Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out
Error: BUG: command 'measure_clk' does not have the '.usage' field filled out
Error: BUG: command 'exit' does not have the '.usage' field filled out
Error: BUG: command 'shutdown' does not have the '.usage' field filled out
Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out
Error: BUG: command 'interface_list' does not have the '.usage' field filled out
Error: BUG: command 'target' does not have the '.usage' field filled out
Error: BUG: command 'target init' does not have the '.usage' field filled out
Error: BUG: command 'flash' does not have the '.usage' field filled out
Error: BUG: command 'flash init' does not have the '.usage' field filled out
Error: BUG: command 'flash banks' does not have the '.usage' field filled out
Error: BUG: command 'nand' does not have the '.usage' field filled out
Error: BUG: command 'nand drivers' does not have the '.usage' field filled out
Error: BUG: command 'nand init' does not have the '.usage' field filled out
Error: BUG: command 'pld' does not have the '.usage' field filled out
Error: BUG: command 'pld init' does not have the '.usage' field filled out
Error: BUG: command 'mflash' does not have the '.usage' field filled out
Error: BUG: command 'mflash init' does not have the '.usage' field filled out
Error: BUG: command 'dummy' does not have the '.usage' field filled out
Error: BUG: command 'dummy foo' does not have the '.usage' field filled out
Error: BUG: command 'scan_chain' does not have the '.usage' field filled out
Error: BUG: command 'jtag' does not have the '.usage' field filled out
Error: BUG: command 'jtag init' does not have the '.usage' field filled out
Error: BUG: command 'arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'etm' does not have the '.usage' field filled out
Error: BUG: command 'arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'target_request' does not have the '.usage' field filled out
^C
oyvind@fierce:~/openocd$ openocd -c "interface dummy" -f board/at91eb40a.cfg 2>&1 | grep -w BUG
Error: BUG: command 'command' does not have the '.usage' field filled out
Error: BUG: command 'script' does not have the '.usage' field filled out
Error: BUG: command 'power_restore' does not have the '.usage' field filled out
Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out
Error: BUG: command 'measure_clk' does not have the '.usage' field filled out
Error: BUG: command 'exit' does not have the '.usage' field filled out
Error: BUG: command 'shutdown' does not have the '.usage' field filled out
Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out
Error: BUG: command 'interface_list' does not have the '.usage' field filled out
Error: BUG: command 'target' does not have the '.usage' field filled out
Error: BUG: command 'target init' does not have the '.usage' field filled out
Error: BUG: command 'flash' does not have the '.usage' field filled out
Error: BUG: command 'flash init' does not have the '.usage' field filled out
Error: BUG: command 'flash banks' does not have the '.usage' field filled out
Error: BUG: command 'nand' does not have the '.usage' field filled out
Error: BUG: command 'nand drivers' does not have the '.usage' field filled out
Error: BUG: command 'nand init' does not have the '.usage' field filled out
Error: BUG: command 'pld' does not have the '.usage' field filled out
Error: BUG: command 'pld init' does not have the '.usage' field filled out
Error: BUG: command 'mflash' does not have the '.usage' field filled out
Error: BUG: command 'mflash init' does not have the '.usage' field filled out
Error: BUG: command 'dummy' does not have the '.usage' field filled out
Error: BUG: command 'dummy foo' does not have the '.usage' field filled out
Error: BUG: command 'scan_chain' does not have the '.usage' field filled out
Error: BUG: command 'jtag' does not have the '.usage' field filled out
Error: BUG: command 'jtag init' does not have the '.usage' field filled out
Error: BUG: command 'arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'etm' does not have the '.usage' field filled out
Error: BUG: command 'arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'target_request' does not have the '.usage' field filled out

Change-Id: I2c3e529530a15d2295a1950ffc59e8f2fc661012
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/299
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2012-01-04 17:13:03 +00:00
Spencer Oliver 4c11906241 helper: fix arm11 help text
This fixes a long standing bug: see Trac #4
Increased help text recursion limit and added LOG_DEBUG so we can
catch future errors like this.

Change-Id: I5fac95c4486eaddaf1e88a27ecb1835168f87711
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/291
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-01-03 09:30:14 +00:00
Spencer Oliver 7e2257663d build: fix mingw build issues
8901fca027 broke the build under mingw, this
fixes that.

Change-Id: I22b91e220dac3b68cc576b65a9f1b8711e64263a
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/298
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2011-12-31 12:23:55 +00:00
Spencer Oliver 3dde0f47b2 binarybuffer: use strndup to allocate string
Change-Id: I65d8f37b18d5b5a798406b956f50ab7bb550e172
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/246
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2011-12-01 19:11:20 +00:00
Freddie Chopin ea10093422 Fix "Evaluate 'script' in the global scope"
This fixes commit Evaluate 'script' in the global scope. It caused
Windows builds behave differently than before because path was evaluated twice
and backslashes from Windows' paths got unescaped and effectively wiped out.
Configs could only be passed with "-f ../dir/config.cfg" or "-f
..\\dir\\config.cfg" instead of usual "-f dir/config.cfg" (or using backslash)
as previously.

Change-Id: I13b4abac6dbe6d770cc11a4e61c9421ef340da83
Author: Steve Bennett <steveb@workware.net.au>
Signed-off-by: Freddie Chopin <freddie.chopin@gmail.com>
Reviewed-on: http://openocd.zylin.com/40
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2011-10-24 17:40:52 +00:00
Spencer Oliver 7fe05ff330 jim: add missing jim license
Change-Id: Ib8e34739d92cd54655b9b47d07b856a82ff25f3c
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/39
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2011-10-21 09:29:44 +00:00
Steve Bennett ef885d3b2a jim-nvp is moving from jimtcl to openocd
The jim-nvp code is specific to openocd, so it belongs in openocd,
not in the core jimtcl.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-09-30 09:38:22 +02:00
Steve Bennett a62d8f2271 Evaluate 'script' in the global scope
Scripts sourced via 'script' should evaluate in the global
scope to make it easy to set and reference global variables.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-08-11 16:20:56 +02:00
Øyvind Harboe 5c739b148e ecos: add 64 bit types for sprintf/sscanf 2011-04-28 22:17:48 +02:00
Øyvind Harboe 68bd107c6d command: fix leak when executing commands
found via valgrind, not observed/reported.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-03-27 23:51:30 +02:00
Øyvind Harboe 95de667e24 log: debug level is between silent and debug output levels
It wasn't previously possible to silence the output.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-02-25 16:36:42 +01:00
Mathias K b21be6054a performance: committed wrong version of buf_set_buf optimization
oops...

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-02-08 11:06:56 +01:00
Mathias K 706284a8fd buf_set_buf around 30% speed increase
Also i have checked the input of this function and in many cases
a simple byte copy is possible.

I have added this check now and is it possible the buffer is
copied byte by byte and not bit by bit.

With byte boundary input the test looks like this:

buf_set_buf 0x02000000 iteration test:
runtime (seconds): old: 6.828559 new: 0.436191 diff: 6.392368
runtime (seconds): old: 6.853636 new: 0.430389 diff: 6.423247
runtime (seconds): old: 6.794985 new: 0.423065 diff: 6.371920

Without:

buf_set_buf 0x02000000 iteration test:
runtime (seconds): old: 6.370869 new: 5.552624 diff: 0.818245
runtime (seconds): old: 6.420730 new: 5.665887 diff: 0.754843
runtime (seconds): old: 6.583306 new: 5.599021 diff: 0.984285

Regards,

Mathias
2011-02-08 09:39:59 +01:00
Mathias K b0bdc4e2f2 24bit buffer support
Hello,

this patch add 24bit support to the target buffer functions and little/big endian functions.

Regards,

Mathias
2011-02-03 12:23:55 +01:00
Øyvind Harboe 859ccccd80 error: remove debug output when reporting errors
The user does not need to know or care about "command handlers".

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-01-31 12:09:46 +01:00
Eric Wetzel 0535531d27 nit: more LOG_* \n fixes
Remove extra \n from LOG_DEBUG, LOG_INFO, and LOG_WARNING messages

Remove LOG_INFO_N
LOG_INFO_N was only used once and had a \n at the end

Change LOG_USER_N calls that end with \n to LOG_USER
2011-01-09 21:35:23 +01:00
Eric Wetzel a665ef716a nit: do not add \n at end of LOG_ERROR
Fixed in many other places, and submitted in response to Øyvind's invitation.
2011-01-05 21:46:12 +01:00
Øyvind Harboe c69553cbc5 error handling: the error number is not part of the user interface
Do not propagate error number to user. This is for internal
programming purposes only. Error messages to the user is
reported as text via LOG_ERROR().

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-01-03 13:33:27 +01:00
Andrew MacIsaac 50e79d60ce Compilation Warnings on OS X 10.5
I received a number of "-Wshadow" related warnings (treated as errors) while
trying to build on OS X Leopard.  In addition, there were two miscellaneous
other warnings in the flash drivers.  Attached are two patches which correct
these issues and the commit messages to accompany them.

My system has the following configuration (taken from uname -a):

Darwin 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009;
root:xnu-1228.15.4~1/RELEASE_I386 i386

=== Werror_patch.txt Commit Message ===
compilation: fixes for -Wshadow warnings on OS X

These changes fix -Wshadow compilation warnings on OS X 10.5.8

Compiled with the following configure command:

../configure --prefix=/usr/local --enable-maintainer-mode --enable-jlink
--enable-ft2232_libftdi

=== flash_patch.txt Commit Message ===
compilation: fixes for flash driver warnings on OS X

These changes fix two compilation warnings on OS X 10.5.8:

../../../../src/flash/nor/at91sam3.c:2767: warning: redundant redeclaration
of 'at91sam3_flash'
../../../../src/flash/nor/at91sam3.c:101: warning: previous declaration of
'at91sam3_flash' was here

and

../../../../src/flash/nor/stmsmi.c:205: warning: format not a string literal
and no format arguments

Compiled with the following configure command:

../configure --prefix=/usr/local --enable-maintainer-mode --enable-jlink
--enable-ft2232_libftdi
===

Andrew
2010-12-29 22:16:28 +01:00
Øyvind Harboe 4f9a9b8eba warnings: use more 'const' for char *
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-12-29 22:07:39 +01:00
Øyvind Harboe c9544e411d script: support only Tcl comments
Only Tcl comments are now supported. For classic style
commands comments were supported at the end of the line.

Move in the direction of letting the script language
decide syntax, rather than have special rules for some
commands.

Before this patch goes in, the scripts should be updated
to use ;# instead of # for end of line comments.

> mdw 0 1 2
mdw ['phys'] address [count]
  zy1000.cpu mdw address [count]
Command handler execution failed
in procedure 'mdw'
> mdw 0 1 #2
mdw ['phys'] address [count]
  zy1000.cpu mdw address [count]
Command handler execution failed
in procedure 'mdw'
> mdw 0 1 ;#2
0x00000000: ffffffff
> mdw 0 1
0x00000000: ffffffff
> mdw 0
0x00000000: ffffffff

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-12-18 21:04:22 +01:00
Spencer Oliver 838cd58e24 build: add common.mk
Rather than specifying common makefile variables move
them all to a common.mk.

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
2010-11-18 14:05:56 +00:00
Antonio Borneo 4747af362d JIM: document "echo" command
Document "-n" option in manual;
Modify "echo" command definition as COMMAND_HANDLER to
easily add help message
Add help message aligned with manual.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-11-09 08:12:51 +01:00
Antonio Borneo d220e22e63 JIM: Add "-n" option to "echo"
With the new JIMTCL, "puts" only writes to stdout.
To write on telnet port too, "echo" must be used.
This patch gives to "echo" similar commandline option of "puts".

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-11-09 08:12:51 +01:00
Øyvind Harboe 559d08c19e jim tests: use installed
Delete obsolete jim that comes with OpenOCD.
2010-10-29 15:10:51 +02:00
Øyvind Harboe 2ff1adfa79 help: help now works on configuration commands
help would not show help for commands when the command
interpreter was in the wrong mode, which means that
e.g. "help newtap" didn't work, it wouldn't show the
"jtag newtap" help as it was a configuration command.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-27 08:50:45 +02:00
Spencer Oliver ebe431879d gdbderver: fix gdb pipe startup overflow
When usng gdb pipes we need to keep openocd output at a minimum,
otherwise the gdb stdin will overflow and fail.
Make the calls to gdb_port and log_output synchronous to stop this.

Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
2010-10-05 15:00:40 +01:00
Øyvind Harboe 50d5441e2a server: add support for pipes
-p/--pipe is now deprecated. Use '-c "gdb_port pipe;log_output openocd.log"'
instead. Warning logged.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:26:08 +02:00
Øyvind Harboe d623832685 log: remove hack to redirect logs when pipes are in use
There is an explicit command "log_output" that can
be used to redirect log output to a file, no need
for a hack in the first place.

Before enabling pipes, use "log_output foo" to redirect
log output to the "foo" files.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-10-01 10:21:33 +02:00
Øyvind Harboe 3931b99d14 fileio: fileio_size() can now fail
Part of making the fileio API more robust.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-09-29 18:56:07 +02:00
Ø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