aboutsummaryrefslogtreecommitdiff
path: root/src/helper/binarybuffer.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-08helper: Code cleanup for hexify()Marc Schink1-8/+29
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-10-17helper: Make unhexify() robust on invalid dataMarc Schink1-7/+32
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-05-24Remove FSF address from GPL noticesMarc Schink1-3/+1
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>
2014-10-06helper: constify log_stringsSpencer Oliver1-1/+1
Change-Id: I5bdd8958e79b754d56bb7aee2892856e557eed76 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/2296 Tested-by: jenkins
2013-10-31binarybuffer: Remove unnecessary cast and fix hidden "bug"Andreas Fritiofson1-2/+2
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-09-26Add new target type: OpenRISCFranck Jullien1-0/+21
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-06-05update files to correct FSF addressSpencer Oliver1-1/+1
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-01-31helper: hexify correctly handle signed charsSpencer Oliver1-1/+1
The current implementation of hexify was not correctly handling signed chars. This function is currently used by the ti-icdi driver and as such was causing random write issues. As a note perhaps a better long term fix would be to change to using uint8_t buffers rather than char. This will require changes to the ti-icdi driver aswell. Change-Id: I572e69ff2b99227a7d412de056458c0393794b03 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/1124 Tested-by: jenkins Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
2012-12-23icdi: add TI icdi interfaceSpencer Oliver1-0/+27
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-07-06Add a bit-level transfer queueAndreas Fritiofson1-0/+43
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-02-06doxygen: use correct comment syntaxSpencer Oliver1-1/+1
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-06build: cleanup src/helper directorySpencer Oliver1-81/+64
Change-Id: I71a312df783995e9083c345c25e73902d5aef59e Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/415 Tested-by: jenkins
2011-12-01binarybuffer: use strndup to allocate stringSpencer Oliver1-4/+2
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-02-08performance: committed wrong version of buf_set_buf optimizationMathias K1-4/+18
oops... Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2011-02-08buf_set_buf around 30% speed increaseMathias K1-7/+22
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
2010-04-10BINARYBUFFER: review scope of data and functionsAntonio Borneo1-2/+2
Add "static" qualifier to private data and functions. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2009-11-16rename CEIL as DIV_ROUND_UPZachary T Welch1-4/+4
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-16improve buf_set_buf helperZachary T Welch1-3/+6
Use void * and unsigned types for buffer and their sizes. Allows it to be used with more than uint8_t * without casts.
2009-11-16improve buf_set_onesZachary T Welch1-9/+9
Use memset instead of loop. Improve types, using void * and unsigned.
2009-11-16improve buf_cpy helperZachary T Welch1-8/+9
Use memcpy for bulk of copy, improve final byte handling. Improve types by using void * for buffers and unsigned for size.
2009-11-16improve buf_cmp and buf_cmp_mask helpersZachary T Welch1-36/+37
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-16improve str_to_buf and buf_to_str helpersZachary T Welch1-62/+64
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-16binarybuffer: move variables to point of first useZachary T Welch1-24/+7
Reduce some noise from subsequent patches.
2009-11-16binarybuffer: fix whitespace related issuesZachary T Welch1-3/+3
Add inter-operator whitespace. Improve existing documentation.
2009-11-14remove unused buf_to_u32_handlerZachary T Welch1-9/+0
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-14struct scan_field_s -> struct scan_fieldZachary T Welch1-1/+1
Remove obsolete suffix from struct scan_field. Somehow, these definitions did not get updated but did not cause any errors.
2009-07-17Andreas Fritiofson <andreas.fritiofson@gmail.com> UTF8 fixesoharboe1-1/+1
git-svn-id: svn://svn.berlios.de/openocd/trunk@2549 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-23Remove whitespace that occurs before ')'.zwelch1-2/+2
- Replace '[ \t]*[)]' with ')'. git-svn-id: svn://svn.berlios.de/openocd/trunk@2377 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-06-18Finish transforming 'u32' to 'uint32_t'.zwelch1-9/+9
- 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-18Transform 'u8' to 'uint8_t'zwelch1-11/+11
- 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-05-11Audit and eliminate redundant helper #include directives.zwelch1-5/+0
git-svn-id: svn://svn.berlios.de/openocd/trunk@1706 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-05-09Michael Bruck <mbruck@digenius.de> use more constoharboe1-4/+4
git-svn-id: svn://svn.berlios.de/openocd/trunk@1686 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-04-22Fix str_to_buf problem, thanks Andy Cheneemlu1-2/+2
git-svn-id: svn://svn.berlios.de/openocd/trunk@1505 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-04-19Zach Welch <zw@superlucidity.net> fix -Werror warningsoharboe1-2/+2
git-svn-id: svn://svn.berlios.de/openocd/trunk@1472 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2009-02-03- Cable driver helper API courtesy of Dick Hollenbeck <dick@softplc.com>kc8apf1-45/+45
- Formatting changes from uncrustify git-svn-id: svn://svn.berlios.de/openocd/trunk@1366 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-12-13- remove target specific variant and use target->variant memberntfreak1-27/+27
- fix build warning in cortex_m3 - code cleanup - remove trailing lf and convert c++ comments git-svn-id: svn://svn.berlios.de/openocd/trunk@1238 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-09-20- added myself to copyright on files i remember adding large contributions ↵ntfreak1-1/+1
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-07-25added yours sincerely for files where I feel that I've made non-trivial ↵oharboe1-0/+3
contributions. git-svn-id: svn://svn.berlios.de/openocd/trunk@872 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-07-11Charles Hardin ckhardin at gmail.com oharboe1-2/+2
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-05-07This matters for embedded devices, but is probably not observably better for ↵oharboe1-37/+0
PC hosted OpenOCD. git-svn-id: svn://svn.berlios.de/openocd/trunk@647 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-04-10- single core context used, removed debug context as thought unnecessary.ntfreak1-4/+0
- DCRDR now used to access special core registers - info is currently omitted from the cortex_m3 TRM ARM have told me this is the preferred access method and the docs will be updated soon. - now checks for User Thread Mode and Thread mode when halted. - removed repeated function declarations from command.c - cortex_m3_prepare_reset_halt removed, updated cortex_m3_assert_reset to suit git-svn-id: svn://svn.berlios.de/openocd/trunk@558 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-03-25- rename log functions to stop conflicts under win32 (wingdi)ntfreak1-1/+1
git-svn-id: svn://svn.berlios.de/openocd/trunk@523 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2008-01-20- added patch "remove error handler as planned"mifi1-1/+1
https://lists.berlios.de/pipermail/openocd-development/2008-January/000665.html (thanks to oyvind Harboe for the patch) git-svn-id: svn://svn.berlios.de/openocd/trunk@260 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2007-05-05- further work on ETB decoding (not yet functional)drath1-1/+6
- fixed several uses of uninitialized bits (Thanks to Vincent Palatin for finding and fixing these bugs) git-svn-id: svn://svn.berlios.de/openocd/trunk@145 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2007-04-12- correctly mask out bits that aren't part of a copied bufferdrath1-0/+6
- fixed arm926ej-s CP15 register access handling - correctly identify SYSCLK source in LPC3180 NAND flash controller driver git-svn-id: svn://svn.berlios.de/openocd/trunk@139 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2006-11-22- added a PLD (programmable logic device) subsystem for FPGA, CPLD etc. ↵drath1-2/+2
configuration - added support for loading .bit files into Xilinx Virtex-II devices - added support for the Gateworks GW16012 JTAG dongle - merged CFI fixes from XScale branch - a few minor fixes git-svn-id: svn://svn.berlios.de/openocd/trunk@116 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2006-09-28- str9x flash support (Thanks to Spencer Oliver)drath1-35/+135
- str75x flash support (Thanks to Spencer Oliver) - correct reporting of T-Bit in CPSR (Thanks to John Hartman for reporting this) - core-state (ARM/Thumb) can be switched by modifying CPSR - fixed bug in gdb_server register handling - register values > 32-bit should now be supported - several minor fixes and enhancements git-svn-id: svn://svn.berlios.de/openocd/trunk@100 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2006-07-17- Added support for native MinGW builds (thanks to Spencer Oliver and ↵drath1-4/+28
Michael Fischer) - you still need to install GiveIO (not part of OpenOCD) - Added state-move support to ftd2xx and bitbang JTAG drivers (required for XScale, possibly useful for other targets, too) - various fixes git-svn-id: svn://svn.berlios.de/openocd/trunk@78 b42882b7-edfa-0310-969c-e2dbd0fdcd60
2006-06-02- prepare OpenOCD for branching, created ./trunk/drath1-0/+246
git-svn-id: svn://svn.berlios.de/openocd/trunk@64 b42882b7-edfa-0310-969c-e2dbd0fdcd60