Commit Graph

103 Commits

Author SHA1 Message Date
Antonio Borneo b86f296ac6 openocd: src: replace the GPL-2.0-or-later license tag
Replace the FSF boilerplate with the SPDX tag.

The SPDX tag on files *.c is incorrect, as it should use the C99
single line comment using '//'. But current checkpatch doesn't
allow C99 comments, so keep using standard C comments, by now.

Change-Id: I30cd66ac7d737f1973c68fdbb841ffcf00e917c4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7072
Tested-by: jenkins
2022-07-23 13:59:13 +00:00
Antonio Borneo 96202cda19 openocd: build: add SPDX tag
Add the SPDX tag to makefiles, configuration scripts and tcl files
present in the folders under src/

Change-Id: I1e4552aafe46ef4893d510da9d732c5f181784a4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7051
Tested-by: jenkins
2022-07-23 13:06:38 +00:00
Antonio Borneo b5d1b719e5 openocd: use single line for register_commands*()
Do not split in multiple lines the calls to register_commands*().
No change in code behaviour, just make it easy to grep in the code
and identify the commands that can be registered.
This would help detecting undocumented commands.

Change-Id: Id654e107cdabf7ee31fc3d227c1d2a59acc5669e
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6716
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-11-23 11:03:38 +00:00
Antonio Borneo 08ee7bb982 openocd: fix simple cases of NULL comparison
There are more than 1000 NULL comparisons to be aligned to the
coding style.
For recurrent NULL comparison it's preferable using trivial
scripts in order to minimize the review effort.

Patch generated automatically with the command:
	sed -i PATTERN $(find src/ -type f)
where PATTERN is in the list:
	's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
	's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
	's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'

	's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g'
	's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g'
	's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g'

	's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g'
	's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g'
	's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g'

	's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g'
	's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g'
	's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g'

Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6350
Tested-by: jenkins
2021-07-24 10:37:49 +01:00
Antonio Borneo 28c24a5c41 openocd: fix simple cases of Yoda condition
There are ~900 Yoda conditions to be aligned to the coding style.
For recurrent Yoda conditions it's preferable using a trivial
script in order to minimize the review effort.
E.g. comparison of uppercase macro/enum with lowercase variable:
	- ...(ERROR_OK == retval)...
	+ ...(retval == ERROR_OK)...

Patch generated automatically with the command:
	sed -i \
	's/(\([A-Z][A-Z0-9_]*\) \([=!]=\) \([a-z][a-z0-9_]*\))/(\3 \2 \1)/g' \
	$(find src/ -type f)

While there, remove the braces {} around a single statement block
to prevent warning from checkpatch.

Change-Id: If585b0a4b4578879c87b2dd74d9e0025e275ec6b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6354
Tested-by: jenkins
Reviewed-by: Xiang W <wxjstz@126.com>
2021-07-20 14:55:24 +01:00
Tim Newsome 87c90393fe Cleanup of config/includes.
Remove a use of AH_BOTTOM from configure.ac. This macro is used by
autoheader to add '#include' of some include file to the end of
config.h.in and then to config.h. OpenOCD can be built with a custom
config.h, so it's preferable to move these '#include' statement directly
in the C files that need them dropping this unneeded dependency.

It also causes problems when I want to use the gnulib library (which
comes with its own Makefile, and does not have the same include path as
the top-level Makefile).

So this change touches a lot of files, but is actually really simple. It
does not affect functionality at all.

Change-Id: I52c70bf15eb2edc1dd10e0fde23b2bcd4caec000
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/6171
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-05-01 14:35:09 +01:00
Antonio Borneo 41c95aa4ea helper/command: pass command prefix to command registration
Replace the "struct command *parent" parameter with a string that
contains the command prefix.
This abstracts the openocd code from the knowledge of the tree of
struct command.
This also makes unused the function command_find_in_context(), so
remove it.

Change-Id: I598d60719cfdc1811ee6f6edfff8a116f82c7ed6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5668
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18 15:33:30 +01:00
Antonio Borneo d3249fd45a openocd: use proper format with uint32_t
Modify the format strings to properly handle uint32_t data types.

Change-Id: I4de49bf02c9e37b72240224c23fc83abe8a4fa83
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5819
Tested-by: jenkins
2020-09-05 17:12:44 +01:00
Antonio Borneo 6cb5ba6f11 helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.

Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
	sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
	's/\(command_print(cmd\)->ctx,/\1,/'
	's/\(command_print(CMD\)_CTX,/\1,/'
	's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
	's/\(command_print_sameline(cmd\)->ctx,/\1,/'
	's/\(command_print_sameline(CMD\)_CTX,/\1,/'
	's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'

This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.

Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-05-14 19:37:11 +01:00
Antonio Borneo b61e454869 Set empty usage field for commands that do not need parameters
The missing field causes runtime debug message
	BUG: command '%s' does not have the '.usage' field filled out

While there, fix some minor typo in the help messages:
	s/deasert/deassert/
	s/Deasert/Deassert/

Change-Id: If3dd18265cda103ca0d05609f67f4ca58e7cbb27
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5024
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-07 08:19:34 +01:00
Andreas Fritiofson 5be455a710 Convert to non-recursive make
Change-Id: I11f8bc8553957e2ff083c09e72e16881e4d3bb6f
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/3865
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2016-12-08 16:23:10 +00:00
Marc Schink d4b7cbff88 Make #include guard naming consistent
Change-Id: Ie13e8af0bb74ed290f811dcad64ad06c9d8cb4fa
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/2956
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2016-05-24 22:30:55 +01:00
Marc Schink d0e763ac7e Remove FSF address from GPL notices
Also make GPL notices consistent according to:
https://www.gnu.org/licenses/gpl-howto.html

Change-Id: I84c9df40a774958a7ed91460c5d931cfab9f45ba
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3488
Tested-by: jenkins
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2016-05-24 22:30:01 +01:00
Robert Jordens 2d99a0defa cpld/virtex2: allow JSTART to be disabled
This adds an option to disable the use of the JSTART instruction
when loading bitstreams to xilinx fpgas. JSTART apparently prevents
configuration if the startup clock is not set to the jtag clock in
the bitstream.

xc3sprog is omitting JSTART for all devices. Problems with loading a bitstream
that does not have StartupClk:JTAGClk are described here:
http://www.xilinx.com/support/answers/56151.html

Change-Id: I8137c0bae05a8c3c6f8e2611869f70a770d1651d
Signed-off-by: Robert Jordens <jordens@gmail.com>
Reviewed-on: http://openocd.zylin.com/2860
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-08-06 13:14:01 +01:00
Spencer Oliver 08d4411b59 update files to correct FSF address
Change-Id: I429f7fd51f77b0e7c86d7a7f110ca31afd76c173
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1426
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2013-06-05 19:52:42 +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 c4f2a018a5 build: cleanup src/pld directory
Change-Id: I9edb027c76e5d7fe21d557a11e6a9691fa581e86
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/408
Tested-by: jenkins
2012-02-06 10:42:40 +00:00
Spencer Oliver 0c2f8b6eb8 cmd: add missing usage vars
we should have caught them all - hopefully.

Change-Id: I35435317fccaf5ad0216244d69f76db6857bb582
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/381
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-01-18 21:45:02 +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
Freddie Chopin f6315d5e5b Fix "unused variable" warnings (errors) detected with GCC 4.7.0 - trivial fixes 2011-06-04 09:35:13 +02: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
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
Ø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
Antonio Borneo 4678108034 PLD: review scope of functions
Add "static" qualifier to private functions.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2010-04-10 17:06:16 +08:00
Øyvind Harboe 96949890ee jtag: move towards making out_value const
These were relatively straightforward fixes which are
backwards compatible.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-03-20 11:16:49 +01:00
Øyvind Harboe 7f6bab0c4c jtag: retire jtag_get/set_end_state()
Voila! This get rids of mysteries about what what
state the TAP is in.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-03-19 08:31:44 +01:00
Øyvind Harboe 36df240cea jtag: cut down on usage of unintended modification of global end state
jtag_get/set_end_state() is now deprecated.

There were lots of places in the code where the end state was
unintentionally modified.

The big Q is whether there were any places where the intention
was to modify the end state. 0.5 is a long way off, so we'll
get a fair amount of testing.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-03-18 08:43:19 +01:00
Øyvind Harboe 57d7743639 jtag: jtag_add_ir_scan() now takes a single field
In the code a single field was all that was ever used. Makes
jtag_add_ir_scan() simpler and leaves more complicated stuff
to jtag_add_plain_ir_scan().

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-03-08 08:12:25 +01:00
Øyvind Harboe e018c7c1d2 jtag: retire tap field
jtag_add_dr/ir_scan() now takes the tap as the first
argument, rather than for each of the fields passed
in.

The code never exercised the path where there was
more than one tap being scanned, who knows if it even
worked.

This simplifies the implementation and reduces clutter
in the calling code.

use jtag_add_ir/dr_plain_scan() for more fancy situations.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2010-03-08 08:12:25 +01:00
David Brownell 973cd9a299 PLD: 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.
Remove a couple instances of pointless whitespace, shrink
a few overlong lines.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-08 23:23:55 -08: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
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 cb4a475f6c change #include "jtag.h" to <jtag/jtag.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "jtag.h"

the following form should be used.

	#include <jtag/jtag.h>

The exception is from .c files in the same directory.
2009-12-03 04:24:33 -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 6512e5e36b change #include "time_support.h" to <helper/time_support.h>
Changes from the flat namespace to heirarchical one.  Instead of writing:

	#include "time_support.h"

the following form should be used.

	#include <helper/time_support.h>

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

	#include "log.h"

the following form should be used.

	#include <helper/log.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
Zachary T Welch 682910fdc2 pld: factor init to 'pld init'
Split PLD initialization into 'pld init', which gets called from 'init'.
2009-12-02 13:26:22 -08:00
Zachary T Welch e2f23c5437 pld: use static registration instead of callback
Remove register_callbacks from pld_device structure, using an array
of command_registration records instead.
2009-11-24 21:37:33 -08:00
Zachary T Welch 76b89755c9 pld: use register_commands()
Updates core PLD and virtex2 commands to use register_commands().
2009-11-24 21:37:33 -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 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 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 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 95bf461c0a pld_device_t -> struct pld_device
Remove misleading typedef and redundant suffix from struct pld_device.
2009-11-13 11:58:08 -08:00