* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
-#ifndef BINARYBUFFER_H
-#define BINARYBUFFER_H
+#ifndef OPENOCD_HELPER_BINARYBUFFER_H
+#define OPENOCD_HELPER_BINARYBUFFER_H
#include "list.h"
* @param num The number of bits from @c value to copy (1-32).
* @param value Up to 32 bits that will be copied to _buffer.
*/
-static inline void buf_set_u32(void *_buffer,
+static inline void buf_set_u32(uint8_t *_buffer,
unsigned first, unsigned num, uint32_t value)
{
- uint8_t *buffer = (uint8_t *)_buffer;
+ uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
buffer[3] = (value >> 24) & 0xff;
* @param num The number of bits from @c value to copy (1-64).
* @param value Up to 64 bits that will be copied to _buffer.
*/
-static inline void buf_set_u64(void *_buffer,
+static inline void buf_set_u64(uint8_t *_buffer,
unsigned first, unsigned num, uint64_t value)
{
- uint8_t *buffer = (uint8_t *)_buffer;
+ uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
buffer[3] = (value >> 24) & 0xff;
* @param num The number of bits from @c _buffer to read (1-32).
* @returns Up to 32-bits that were read from @c _buffer.
*/
-static inline uint32_t buf_get_u32(const void *_buffer,
+static inline uint32_t buf_get_u32(const uint8_t *_buffer,
unsigned first, unsigned num)
{
- uint8_t *buffer = (uint8_t *)_buffer;
+ const uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
return (((uint32_t)buffer[3]) << 24) |
* @param num The number of bits from @c _buffer to read (1-64).
* @returns Up to 64-bits that were read from @c _buffer.
*/
-static inline uint64_t buf_get_u64(const void *_buffer,
+static inline uint64_t buf_get_u64(const uint8_t *_buffer,
unsigned first, unsigned num)
{
- uint8_t *buffer = (uint8_t *)_buffer;
+ const uint8_t *buffer = _buffer;
if ((num == 32) && (first == 0)) {
return 0 + ((((uint32_t)buffer[3]) << 24) | /* Note - zero plus is to avoid a checkpatch bug */
/* functions to convert to/from hex encoded buffer
* used in ti-icdi driver and gdb server */
-int unhexify(char *bin, const char *hex, int count);
-int hexify(char *hex, const char *bin, int count, int out_maxlen);
+size_t unhexify(uint8_t *bin, const char *hex, size_t count);
+size_t hexify(char *hex, const uint8_t *bin, size_t count, size_t out_maxlen);
void buffer_shr(void *_buf, unsigned buf_len, unsigned count);
-#endif /* BINARYBUFFER_H */
+#endif /* OPENOCD_HELPER_BINARYBUFFER_H */