Commit Graph

55 Commits

Author SHA1 Message Date
Antonio Borneo 533f0f1b87 openocd: src/helper: 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: I7851617e2682f97ccc3927e3941aadef2df63b54
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7068
Tested-by: jenkins
2022-07-23 13:54:09 +00:00
Samuel Obuch 3ac010bb9f Fix debug prints when loading to flash
While loading to flash with debug level at least 3,
OpenOCD tries to print the whole loaded bitstream.
This will be very-very-slow due to implementation of
conversion from buffer to string.

* fix condition on selected debug level in jtag/core.c
* replace slow buf_to_str function from helper/binarybuffer.c
  with faster but_to_hex_str function

Change-Id: I3dc01d5846941ca80736f2ed12e3a54114d2b6dd
Signed-off-by: Samuel Obuch <sobuch@codasip.com>
Reviewed-on: http://openocd.zylin.com/5800
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-09-05 16:48:08 +01:00
Tomas Vanek a2e822834d helper/binarybuffer: fix clang static analyzer warnings
Writing bits to an uninitialized buffer generated false warnings.
Zero buffers before setting them by buf_set_u32|64()
(do it only if bit-by-bit copy loop is used,
zeroed buffer is not necessary if a fast path write is used)

Change-Id: I2f7f8ddb45b0cbd08d3e249534fc51f4b5cc6694
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5383
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2020-03-07 15:30:05 +00:00
Mete Balci 5b263d7b0c fix for sanitizer errors in left shifts
The modified lines cause "runtime error: left shift of <X> by <Y>
places cannot be represented in type 'int'", because integer
literal is cast to int by default.

Change-Id: Ie38119b5eb46ee470e0d149959e523b48ac4d66d
Signed-off-by: Mete Balci <metebalci@gmail.com>
Reviewed-on: http://openocd.zylin.com/5005
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-10 16:37:51 +01:00
Marc Schink 69ff7354d9 helper: Code cleanup for hexify()
Simplify hexify() and do not longer use 0 as special case for the
parameter 'count' to determine the string length of the binary input.
Instead, use strlen() outside of the function if needed.
Additionally, fix the return value and return the length of the
converted string. The old function always returned 2 * count.

Also, use more appropriate data types for the function parameters and
add a small documentation.

Change-Id: I133a8ab786b8f7c1296afcaf9c0a0b43881e5112
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3793
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2016-12-08 12:34:53 +00:00
Marc Schink 674141e8a7 helper: Make unhexify() robust on invalid data
The current implementation is not suitable for user provided data
because it does not detect invalid inputs in many cases. For example,
the string "aa0xbb" is successfully converted to the 3 bytes: 0xaa,
0x00 and 0xbb. An other example is "aabi" which is successfully
converted to the 2 bytes: 0xaa and 0x0b. Both are obviously incorrect.

Make unhexify() robust on invalid data and use more appropriate data
types for its parameters. Also, add a small documentation for the
function.

Change-Id: Idb799beb86fc608b066c8a76365021ed44c7f890
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3792
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2016-10-17 09:28:05 +01: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
Paul Fertser 355f4cadbb Use (uint8_t *) for buf_(set|get)_u(32|64) instead of (void *)
This helps to uncover incorrect usage when a pointer to uint32_t is
passed to those functions which leads to subtle bugs on BE systems.

The reason is that it's normally assumed that any uint32_t variable
holds its value in host byte order, but using but_set_u32 on it
silently does implicit pointer conversion to (void *) and the
assumption ends up broken without any indication.

Change-Id: I48ffd190583d8aa32ec1fef8f1cdc0b4184e4546
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2467
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-30 08:56:54 +00:00
Andreas Fritiofson 01298ca2c8 binarybuffer: Remove unnecessary cast and fix hidden "bug"
Because of the cast, the const decoration on the parameter provided no
guarantee against modification since it was silently discarded.

Change-Id: Ib83ade955e1a61ee2175c690620437b5e19cbb6a
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1776
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-10-31 20:45:26 +00:00
Franck Jullien 4e79b48e2c Add new target type: OpenRISC
Add support for OpenRISC target. This implementation
supports the adv_debug_sys debug unit core. The mohor
dbg_if is not supported. Support for mohor TAP core
and Altera Virtual JTAG core are also provided.

Change-Id: I3b1cfab1bbb28e497c4fca6ed1bd3a4362609b72
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-on: http://openocd.zylin.com/1547
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2013-09-26 09:52:56 +00:00
Evan Hunter 7641fb6ac6 Add support for 64 bit parameter to irscan
Change-Id: I89e0422456c59ee86c4b6d9bd3b3ad32051b31ac
Signed-off-by: Evan Hunter <ehunter@broadcom.com>
Reviewed-on: http://openocd.zylin.com/831
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2013-07-01 08:37:14 +00: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 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
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 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
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
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
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 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
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 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
dbrownell f64e924ba9 Updates to the initial scanchain validation code:
- minor bug fixes
  - code cleanup
  - update comments
  - improve diagnostics
  - etc


git-svn-id: svn://svn.berlios.de/openocd/trunk@2759 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-09-26 19:18:42 +00:00
oharboe 8b994145b8 Andreas Fritiofson <andreas.fritiofson@gmail.com> UTF8 fixes
git-svn-id: svn://svn.berlios.de/openocd/trunk@2549 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-07-17 19:54:25 +00:00
zwelch c97caebccd Remove whitespace at end of lines, step 2.
- Replace '\s*$' with ''.


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


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


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


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


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


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


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


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


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


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


git-svn-id: svn://svn.berlios.de/openocd/trunk@2276 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18 07:07:12 +00:00
oharboe 79d515c347 Michael Bruck <mbruck@digenius.de> use more const
git-svn-id: svn://svn.berlios.de/openocd/trunk@1686 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-09 09:30:00 +00:00
ntfreak 68c598e88d - added myself to copyright on files i remember adding large contributions for over the years
- cleaned up headers to match rest of code
- added missing svn props for previously added files

git-svn-id: svn://svn.berlios.de/openocd/trunk@987 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-09-20 10:50:53 +00:00
oharboe 526fe3d83e added yours sincerely for files where I feel that I've made non-trivial contributions.
git-svn-id: svn://svn.berlios.de/openocd/trunk@872 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-07-25 06:54:17 +00:00
oharboe b06f254b24 Charles Hardin ckhardin at gmail.com
This address the >32 bit problem with drscan
also added a check for bypass in the execute since this will manifest itself
as a memory corruption when this check helps to debug the problem alot easier


git-svn-id: svn://svn.berlios.de/openocd/trunk@794 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-07-11 17:40:15 +00:00
ntfreak 655e4f88a6 - fixed build issues with win32
- fixed build warnings for last commit
- set svn props for last commit

git-svn-id: svn://svn.berlios.de/openocd/trunk@760 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-07-06 23:22:17 +00:00