'a', 'b', 'c', 'd', 'e', 'f'
};
-void *buf_cpy(const void *from, void *_to, unsigned size)
+void *buf_cpy(const void *from, void *_to, unsigned int size)
{
if (!from || !_to)
return NULL;
memcpy(_to, from, DIV_ROUND_UP(size, 8));
/* mask out bits that don't belong to the buffer */
- unsigned trailing_bits = size % 8;
+ unsigned int trailing_bits = size % 8;
if (trailing_bits) {
uint8_t *to = _to;
to[size / 8] &= (1 << trailing_bits) - 1;
{
return (a & m) == (b & m);
}
-static bool buf_eq_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned trailing)
+static bool buf_eq_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned int trailing)
{
uint8_t mask = (1 << trailing) - 1;
return buf_eq_masked(a, b, mask & m);
}
-bool buf_eq(const void *_buf1, const void *_buf2, unsigned size)
+bool buf_eq(const void *_buf1, const void *_buf2, unsigned int size)
{
if (!_buf1 || !_buf2)
return _buf1 == _buf2;
- unsigned last = size / 8;
+ unsigned int last = size / 8;
if (memcmp(_buf1, _buf2, last) != 0)
return false;
- unsigned trailing = size % 8;
+ unsigned int trailing = size % 8;
if (!trailing)
return true;
}
bool buf_eq_mask(const void *_buf1, const void *_buf2,
- const void *_mask, unsigned size)
+ const void *_mask, unsigned int size)
{
if (!_buf1 || !_buf2)
return _buf1 == _buf2 && _buf1 == _mask;
const uint8_t *buf1 = _buf1, *buf2 = _buf2, *mask = _mask;
- unsigned last = size / 8;
- for (unsigned i = 0; i < last; i++) {
+ unsigned int last = size / 8;
+ for (unsigned int i = 0; i < last; i++) {
if (!buf_eq_masked(buf1[i], buf2[i], mask[i]))
return false;
}
- unsigned trailing = size % 8;
+ unsigned int trailing = size % 8;
if (!trailing)
return true;
return buf_eq_trailing(buf1[last], buf2[last], mask[last], trailing);
}
-void *buf_set_ones(void *_buf, unsigned size)
+void *buf_set_ones(void *_buf, unsigned int size)
{
uint8_t *buf = _buf;
if (!buf)
memset(buf, 0xff, size / 8);
- unsigned trailing_bits = size % 8;
+ unsigned int trailing_bits = size % 8;
if (trailing_bits)
buf[size / 8] = (1 << trailing_bits) - 1;
return buf;
}
-void *buf_set_buf(const void *_src, unsigned src_start,
- void *_dst, unsigned dst_start, unsigned len)
+void *buf_set_buf(const void *_src, unsigned int src_start,
+ void *_dst, unsigned int dst_start, unsigned int len)
{
const uint8_t *src = _src;
uint8_t *dst = _dst;
- unsigned i, sb, db, sq, dq, lb, lq;
+ unsigned int i, sb, db, sq, dq, lb, lq;
sb = src_start / 8;
db = dst_start / 8;
return c;
}
-char *buf_to_hex_str(const void *_buf, unsigned buf_len)
+char *buf_to_hex_str(const void *_buf, unsigned int buf_len)
{
- unsigned len_bytes = DIV_ROUND_UP(buf_len, 8);
+ unsigned int len_bytes = DIV_ROUND_UP(buf_len, 8);
char *str = calloc(len_bytes * 2 + 1, 1);
const uint8_t *buf = _buf;
- for (unsigned i = 0; i < len_bytes; i++) {
+ for (unsigned int i = 0; i < len_bytes; i++) {
uint8_t tmp = buf[len_bytes - i - 1];
if ((i == 0) && (buf_len % 8))
tmp &= (0xff >> (8 - (buf_len % 8)));
INIT_LIST_HEAD(&q->list);
}
-int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned dst_offset, const uint8_t *src,
- unsigned src_offset, unsigned bit_count)
+int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned int dst_offset, const uint8_t *src,
+ unsigned int src_offset, unsigned int bit_count)
{
struct bit_copy_queue_entry *qe = malloc(sizeof(*qe));
if (!qe)
return i;
}
-void buffer_shr(void *_buf, unsigned buf_len, unsigned count)
+void buffer_shr(void *_buf, unsigned int buf_len, unsigned int count)
{
- unsigned i;
+ unsigned int i;
unsigned char *buf = _buf;
- unsigned bytes_to_remove;
- unsigned shift;
+ unsigned int bytes_to_remove;
+ unsigned int shift;
bytes_to_remove = count / 8;
shift = count - (bytes_to_remove * 8);
* @param value Up to 32 bits that will be copied to _buffer.
*/
static inline void buf_set_u32(uint8_t *_buffer,
- unsigned first, unsigned num, uint32_t value)
+ unsigned int first, unsigned int num, uint32_t value)
{
assert(num >= 1 && num <= 32);
uint8_t *buffer = _buffer;
buffer[1] = (value >> 8) & 0xff;
buffer[0] = (value >> 0) & 0xff;
} else {
- for (unsigned i = first; i < first + num; i++) {
+ for (unsigned int i = first; i < first + num; i++) {
if (((value >> (i - first)) & 1) == 1)
buffer[i / 8] |= 1 << (i % 8);
else
* @param value Up to 64 bits that will be copied to _buffer.
*/
static inline void buf_set_u64(uint8_t *_buffer,
- unsigned first, unsigned num, uint64_t value)
+ unsigned int first, unsigned int num, uint64_t value)
{
assert(num >= 1 && num <= 64);
uint8_t *buffer = _buffer;
buffer[1] = (value >> 8) & 0xff;
buffer[0] = (value >> 0) & 0xff;
} else {
- for (unsigned i = first; i < first + num; i++) {
+ for (unsigned int i = first; i < first + num; i++) {
if (((value >> (i - first)) & 1) == 1)
buffer[i / 8] |= 1 << (i % 8);
else
* @returns Up to 32-bits that were read from @c _buffer.
*/
static inline uint32_t buf_get_u32(const uint8_t *_buffer,
- unsigned first, unsigned num)
+ unsigned int first, unsigned int num)
{
assert(num >= 1 && num <= 32);
const uint8_t *buffer = _buffer;
(((uint32_t)buffer[0]) << 0);
} else {
uint32_t result = 0;
- for (unsigned i = first; i < first + num; i++) {
+ for (unsigned int i = first; i < first + num; i++) {
if (((buffer[i / 8] >> (i % 8)) & 1) == 1)
result |= 1U << (i - first);
}
* @returns Up to 64-bits that were read from @c _buffer.
*/
static inline uint64_t buf_get_u64(const uint8_t *_buffer,
- unsigned first, unsigned num)
+ unsigned int first, unsigned int num)
{
assert(num >= 1 && num <= 64);
const uint8_t *buffer = _buffer;
(((uint64_t)buffer[0]) << 0));
} else {
uint64_t result = 0;
- for (unsigned i = first; i < first + num; i++) {
+ for (unsigned int i = first; i < first + num; i++) {
if (((buffer[i / 8] >> (i % 8)) & 1) == 1)
result = result | ((uint64_t)1 << (uint64_t)(i - first));
}
* @param width The number of bits in value (2-32).
* @returns A 32-bit word with @c value in reversed bit-order.
*/
-uint32_t flip_u32(uint32_t value, unsigned width);
+uint32_t flip_u32(uint32_t value, unsigned int width);
-bool buf_eq(const void *buf1, const void *buf2, unsigned size);
+bool buf_eq(const void *buf1, const void *buf2, unsigned int size);
bool buf_eq_mask(const void *buf1, const void *buf2,
- const void *mask, unsigned size);
+ const void *mask, unsigned int size);
/**
* Copies @c size bits out of @c from and into @c to. Any extra
* @param to The buffer that will receive the copy of @c from.
* @param size The number of bits to copy.
*/
-void *buf_cpy(const void *from, void *to, unsigned size);
+void *buf_cpy(const void *from, void *to, unsigned int size);
/**
* Set the contents of @c buf with @c count bits, all set to 1.
* @param size The number of bits.
* @returns The original buffer (@c buf).
*/
-void *buf_set_ones(void *buf, unsigned size);
+void *buf_set_ones(void *buf, unsigned int size);
-void *buf_set_buf(const void *src, unsigned src_start,
- void *dst, unsigned dst_start, unsigned len);
+void *buf_set_buf(const void *src, unsigned int src_start,
+ void *dst, unsigned int dst_start, unsigned int len);
/**
* Parse an unsigned number (provided as a zero-terminated string)
*/
int str_to_buf(const char *str, void *_buf, unsigned int buf_bitsize);
-char *buf_to_hex_str(const void *buf, unsigned size);
+char *buf_to_hex_str(const void *buf, unsigned int size);
/* read a uint32_t from a buffer in target memory endianness */
static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le)
return le ? le_to_h_u32(p) : be_to_h_u32(p);
}
-static inline void bit_copy(uint8_t *dst, unsigned dst_offset, const uint8_t *src,
- unsigned src_offset, unsigned bit_count)
+static inline void bit_copy(uint8_t *dst, unsigned int dst_offset, const uint8_t *src,
+ unsigned int src_offset, unsigned int bit_count)
{
buf_set_buf(src, src_offset, dst, dst_offset, bit_count);
}
struct bit_copy_queue_entry {
uint8_t *dst;
- unsigned dst_offset;
+ unsigned int dst_offset;
const uint8_t *src;
- unsigned src_offset;
- unsigned bit_count;
+ unsigned int src_offset;
+ unsigned int bit_count;
struct list_head list;
};
void bit_copy_queue_init(struct bit_copy_queue *q);
-int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned dst_offset, const uint8_t *src,
- unsigned src_offset, unsigned bit_count);
+int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned int dst_offset, const uint8_t *src,
+ unsigned int src_offset, unsigned int bit_count);
void bit_copy_execute(struct bit_copy_queue *q);
void bit_copy_discard(struct bit_copy_queue *q);
* used in ti-icdi driver and gdb server */
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);
+void buffer_shr(void *_buf, unsigned int buf_len, unsigned int count);
#endif /* OPENOCD_HELPER_BINARYBUFFER_H */
return cmd->isproc ? NULL : cmd->u.native.privData;
}
-static void tcl_output(void *privData, const char *file, unsigned line,
+static void tcl_output(void *privData, const char *file, unsigned int line,
const char *function, const char *string)
{
struct log_capture_state *state = privData;
return;
char *dbg = alloc_printf("command -");
- for (unsigned i = 0; i < argc; i++) {
+ for (unsigned int i = 0; i < argc; i++) {
const char *w = Jim_GetString(argv[i], NULL);
char *t = alloc_printf("%s %s", dbg, w);
free(dbg);
struct target *override_target)
{
int retval = ERROR_OK;
- unsigned i;
+ unsigned int i;
for (i = 0; cmds[i].name || cmds[i].chain; i++) {
const struct command_registration *cr = cmds + i;
}
}
if (retval != ERROR_OK) {
- for (unsigned j = 0; j < i; j++)
+ for (unsigned int j = 0; j < i; j++)
unregister_command(cmd_ctx, cmd_prefix, cmds[j].name);
}
return retval;
#define HELP_LINE_WIDTH(_n) (int)(76 - (2 * _n))
-static void command_help_show_indent(unsigned n)
+static void command_help_show_indent(unsigned int n)
{
- for (unsigned i = 0; i < n; i++)
+ for (unsigned int i = 0; i < n; i++)
LOG_USER_N(" ");
}
-static void command_help_show_wrap(const char *str, unsigned n, unsigned n2)
+static void command_help_show_wrap(const char *str, unsigned int n, unsigned int n2)
{
const char *cp = str, *last = str;
while (*cp) {
#define DEFINE_PARSE_ULONGLONG(name, type, min, max) \
DEFINE_PARSE_WRAPPER(name, type, min, max, unsigned long long, _ullong)
-DEFINE_PARSE_ULONGLONG(_uint, unsigned, 0, UINT_MAX)
+DEFINE_PARSE_ULONGLONG(_uint, unsigned int, 0, UINT_MAX)
DEFINE_PARSE_ULONGLONG(_u64, uint64_t, 0, UINT64_MAX)
DEFINE_PARSE_ULONGLONG(_u32, uint32_t, 0, UINT32_MAX)
DEFINE_PARSE_ULONGLONG(_u16, uint16_t, 0, UINT16_MAX)
struct command_context *ctx;
struct command *current;
const char *name;
- unsigned argc;
+ unsigned int argc;
const char **argv;
Jim_Obj * const *jimtcl_argv;
Jim_Obj *output;
#define DECLARE_PARSE_WRAPPER(name, type) \
int parse ## name(const char *str, type * ul)
-DECLARE_PARSE_WRAPPER(_uint, unsigned);
+DECLARE_PARSE_WRAPPER(_uint, unsigned int);
DECLARE_PARSE_WRAPPER(_u64, uint64_t);
DECLARE_PARSE_WRAPPER(_u32, uint32_t);
DECLARE_PARSE_WRAPPER(_u16, uint16_t);
static int count;
/* forward the log to the listeners */
-static void log_forward(const char *file, unsigned line, const char *function, const char *string)
+static void log_forward(const char *file, unsigned int line, const char *function, const char *string)
{
struct log_callback *cb, *next;
cb = log_callbacks;
void log_printf(enum log_levels level,
const char *file,
- unsigned line,
+ unsigned int line,
const char *function,
const char *format,
...)
va_end(ap);
}
-void log_vprintf_lf(enum log_levels level, const char *file, unsigned line,
+void log_vprintf_lf(enum log_levels level, const char *file, unsigned int line,
const char *function, const char *format, va_list args)
{
char *tmp;
void log_printf_lf(enum log_levels level,
const char *file,
- unsigned line,
+ unsigned int line,
const char *function,
const char *format,
...)
* Find the first non-printable character in the char buffer, return a pointer to it.
* If no such character exists, return NULL.
*/
-char *find_nonprint_char(char *buf, unsigned buf_len)
+char *find_nonprint_char(char *buf, unsigned int buf_len)
{
for (unsigned int i = 0; i < buf_len; i++) {
if (!isprint(buf[i]))
LOG_LVL_DEBUG_IO = 4,
};
-void log_printf(enum log_levels level, const char *file, unsigned line,
+void log_printf(enum log_levels level, const char *file, unsigned int line,
const char *function, const char *format, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
-void log_vprintf_lf(enum log_levels level, const char *file, unsigned line,
+void log_vprintf_lf(enum log_levels level, const char *file, unsigned int line,
const char *function, const char *format, va_list args);
-void log_printf_lf(enum log_levels level, const char *file, unsigned line,
+void log_printf_lf(enum log_levels level, const char *file, unsigned int line,
const char *function, const char *format, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
void log_socket_error(const char *socket_desc);
-typedef void (*log_callback_fn)(void *priv, const char *file, unsigned line,
+typedef void (*log_callback_fn)(void *priv, const char *file, unsigned int line,
const char *function, const char *string);
struct log_callback {
char *alloc_printf(const char *fmt, ...)
__attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2)));
-char *find_nonprint_char(char *buf, unsigned buf_len);
+char *find_nonprint_char(char *buf, unsigned int buf_len);
extern int debug_level;
#ifndef HAVE_USLEEP
#ifdef _WIN32
-static inline unsigned usleep(unsigned int usecs)
+static inline unsigned int usleep(unsigned int usecs)
{
Sleep((usecs/1000));
return 0;
&arm_tpiu_swo_register_commands,
NULL
};
- for (unsigned i = 0; command_registrants[i]; i++) {
+ for (unsigned int i = 0; command_registrants[i]; i++) {
int retval = (*command_registrants[i])(cmd_ctx);
if (retval != ERROR_OK) {
command_done(cmd_ctx);
rtos_reg->number = reg->number;
rtos_reg->size = reg->size;
- unsigned bytes = (reg->size + 7) / 8;
+ unsigned int bytes = (reg->size + 7) / 8;
assert(bytes <= sizeof(rtos_reg->value));
memcpy(rtos_reg->value, reg->value, bytes);
#define SVF_BUF_LOG(_lvl, _buf, _nbits, _desc) \
svf_hexbuf_print(LOG_LVL_##_lvl, __FILE__, __LINE__, __func__, _buf, _nbits, _desc)
-static void svf_hexbuf_print(int dbg_lvl, const char *file, unsigned line,
+static void svf_hexbuf_print(int dbg_lvl, const char *file, unsigned int line,
const char *function, const uint8_t *buf,
int bit_len, const char *desc)
{
int svf_add_statemove(tap_state_t state_to)
{
tap_state_t state_from = cmd_queue_cur_state;
- unsigned index_var;
+ unsigned int index_var;
/* when resetting, be paranoid and ignore current state */
if (state_to == TAP_RESET) {
COMMAND_HELPER(transport_list_parse, char ***vector)
{
char **argv;
- unsigned n = CMD_ARGC;
- unsigned j = 0;
+ unsigned int n = CMD_ARGC;
+ unsigned int j = 0;
*vector = NULL;
if (!argv)
return ERROR_FAIL;
- for (unsigned i = 0; i < n; i++) {
+ for (unsigned int i = 0; i < n; i++) {
struct transport *t;
for (t = transport_list; t; t = t->next) {
return ERROR_OK;
fail:
- for (unsigned i = 0; i < n; i++)
+ for (unsigned int i = 0; i < n; i++)
free(argv[i]);
free(argv);
return ERROR_FAIL;
bool collecting_path = false;
tap_state_t path[XSTATE_MAX_PATH];
- unsigned pathlen = 0;
+ unsigned int pathlen = 0;
/* a flag telling whether to clock TCK during waits,
* or simply sleep, controlled by virt2