diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index fb1cffbd..3f46279b 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -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 * data/Makefile.am, data/broadcom/bcm6348/bcm6348, diff --git a/urjtag/include/urjtag/tap_register.h b/urjtag/include/urjtag/tap_register.h index 3027cf51..aa0bb0af 100644 --- a/urjtag/include/urjtag/tap_register.h +++ b/urjtag/include/urjtag/tap_register.h @@ -26,6 +26,7 @@ #define URJ_TAP_REGISTER_H #include "types.h" +#include 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, diff --git a/urjtag/src/tap/detect.c b/urjtag/src/tap/detect.c index 3f990b7f..c23a0bd1 100644 --- a/urjtag/src/tap/detect.c +++ b/urjtag/src/tap/detect.c @@ -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")); diff --git a/urjtag/src/tap/register.c b/urjtag/src/tap/register.c index a7a40b1a..269bbee9 100644 --- a/urjtag/src/tap/register.c +++ b/urjtag/src/tap/register.c @@ -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) {