convert the local bits_to_uint64() to a proper exported urj_tap_register_get_value() like the urj_tap_register_get_string() function

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1613 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 16 years ago
parent 0ca7bfc9f5
commit 1eef94ea87

@ -12,6 +12,10 @@
* src/cmd/cmd_idcode.c: update usage to reflect reality
* include/urjtag/tap_register.h, src/tap/detect.c, src/tap/register.c:
convert the local bits_to_uint64() to a proper urj_tap_register_get_value()
so everyone can use it
2009-05-19 Arnim Laeuger <arniml>
* data/Makefile.am, data/broadcom/bcm6348/bcm6348,

@ -26,6 +26,7 @@
#define URJ_TAP_REGISTER_H
#include "types.h"
#include <stdint.h>
struct urj_tap_register
{
@ -39,6 +40,7 @@ urj_tap_register_t *urj_tap_register_duplicate (const urj_tap_register_t *tr);
void urj_tap_register_free (urj_tap_register_t *tr);
urj_tap_register_t *urj_tap_register_fill (urj_tap_register_t *tr, int val);
const char *urj_tap_register_get_string (const urj_tap_register_t *tr);
uint64_t urj_tap_register_get_value (const urj_tap_register_t *tr);
/** @return 0 or 1 on success; -1 on error */
int urj_tap_register_all_bits_same_value (const urj_tap_register_t *tr);
urj_tap_register_t *urj_tap_register_init (urj_tap_register_t *tr,

@ -171,23 +171,6 @@ find_record (char *filename, urj_tap_register_t *key, struct id_record *idr)
return r;
}
static uint64_t
bits_to_uint64 (urj_tap_register_t *t)
{
int i;
uint64_t l, b;
l = 0;
b = 1;
for (i = 0; i < t->len; i++)
{
if (t->data[i] & 1)
l |= b;
b <<= 1;
}
return l;
}
int
urj_tap_detect_parts (urj_chain_t *chain, const char *db_path)
{
@ -279,7 +262,7 @@ urj_tap_detect_parts (urj_chain_t *chain, const char *db_path)
did = id;
urj_log (URJ_LOG_LEVEL_NORMAL, _("Device Id: %s (0x%016" PRIX64 ")\n"),
urj_tap_register_get_string (did), bits_to_uint64 (did));
urj_tap_register_get_string (did), urj_tap_register_get_value (did));
} else
urj_log (URJ_LOG_LEVEL_NORMAL, _("Device Id: unknown as bit 0 was not a 1\n"));

@ -122,6 +122,27 @@ urj_tap_register_get_string (const urj_tap_register_t *tr)
return tr->string;
}
uint64_t
urj_tap_register_get_value (const urj_tap_register_t *tr)
{
int i;
uint64_t l, b;
if (!tr)
return 0;
l = 0;
b = 1;
for (i = 0; i < tr->len; ++i)
{
if (tr->data[i] & 1)
l |= b;
b <<= 1;
}
return l;
}
int
urj_tap_register_all_bits_same_value (const urj_tap_register_t *tr)
{

Loading…
Cancel
Save