Factoring of jtag_examine_chain for maintainability:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 7 Jun 2009 05:23:13 +0000 (05:23 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 7 Jun 2009 05:23:13 +0000 (05:23 +0000)
- Factor initial chain examination check into new static helper.

git-svn-id: svn://svn.berlios.de/openocd/trunk@2084 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/jtag.c

index a3d86adead05ad03ce3f0216aee72c1ea7a18597..03462d6bada297c48ce4073778b4ecd6442a4bf3 100644 (file)
@@ -963,32 +963,41 @@ static int jtag_examine_chain_execute(u8 *idcode_buffer, unsigned num_idcode)
        return jtag_execute_queue();
 }
 
+static bool jtag_examine_chain_check(u8 *idcodes, unsigned count)
+{
+       u8 zero_check = 0x0;
+       u8 one_check = 0xff;
+
+       for (unsigned i = 0; i < count * 4; i++)
+       {
+               zero_check |= idcodes[i];
+               one_check &= idcodes[i];
+       }
+
+       /* if there wasn't a single non-zero bit or if all bits were one,
+        * the scan is not valid */
+       if (zero_check == 0x00 || one_check == 0xff)
+       {
+               LOG_ERROR("JTAG communication failure: check connection, "
+                       "JTAG interface, target power etc.");
+               return false;
+       }
+       return true;
+}
+
 /* Try to examine chain layout according to IEEE 1149.1 ยง12
  */
 static int jtag_examine_chain(void)
 {
        jtag_tap_t *tap;
        u8 idcode_buffer[JTAG_MAX_CHAIN_SIZE * 4];
-       int i;
        int bit_count;
        int device_count = 0;
-       u8 zero_check = 0x0;
-       u8 one_check = 0xff;
 
        jtag_examine_chain_execute(idcode_buffer, JTAG_MAX_CHAIN_SIZE);
 
-       for (i = 0; i < JTAG_MAX_CHAIN_SIZE * 4; i++)
-       {
-               zero_check |= idcode_buffer[i];
-               one_check &= idcode_buffer[i];
-       }
-
-       /* if there wasn't a single non-zero bit or if all bits were one, the scan isn't valid */
-       if ((zero_check == 0x00) || (one_check == 0xff))
-       {
-               LOG_ERROR("JTAG communication failure, check connection, JTAG interface, target power etc.");
+       if (!jtag_examine_chain_check(idcode_buffer, JTAG_MAX_CHAIN_SIZE))
                return ERROR_JTAG_INIT_FAILED;
-       }
 
        /* point at the 1st tap */
        tap = jtag_tap_next_enabled(NULL);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)