Clean up jtag command queue handling:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 2 Jun 2009 05:47:00 +0000 (05:47 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 2 Jun 2009 05:47:00 +0000 (05:47 +0000)
- Rename last_command_pointer as next_command_pointer, because this variable
  stores the address where jtag_queue_command() will store a command pointer.
- Make that variable static, since it is only used internally in jtag.c.
- Remove superfluous accessor for that now-static variable.
- Deobfuscate use of variables in jtag_command_queue.
- Add jtag_command_queue_reset helper function.
- Use it in interface_jtag_execute_queue.

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

src/jtag/jtag.c

index 64a168cbbc70c4bf8ccc5245fd33960c3825b3b8..d55888ca8dc2f7561b7028bc264d7b52baad80d5 100644 (file)
@@ -91,7 +91,7 @@ static struct jtag_callback_entry *jtag_callback_queue_tail = NULL;
 
 
 jtag_command_t *jtag_command_queue = NULL;
-jtag_command_t **last_command_pointer = &jtag_command_queue;
+static jtag_command_t **next_command_pointer = &jtag_command_queue;
 static jtag_tap_t *jtag_all_taps = NULL;
 
 enum reset_types jtag_reset_config = RESET_NONE;
@@ -423,40 +423,20 @@ int jtag_call_event_callbacks(enum jtag_event event)
        return ERROR_OK;
 }
 
-/* returns a pointer to the pointer of the last command in queue
- * this may be a pointer to the root pointer (jtag_command_queue)
- * or to the next member of the last but one command
- */
-jtag_command_t** jtag_get_last_command_p(void)
-{
-/*     jtag_command_t *cmd = jtag_command_queue;
-
-       if (cmd)
-               while (cmd->next)
-                       cmd = cmd->next;
-       else
-               return &jtag_command_queue;
-
-       return &cmd->next;*/
-
-       return last_command_pointer;
-}
-
-
 void jtag_queue_command(jtag_command_t * cmd)
 {
-       jtag_command_t **last_cmd;
-
-       last_cmd = jtag_get_last_command_p();
+       // this command goes on the end, so ensure the queue terminates
+       cmd->next = NULL;
 
+       jtag_command_t **last_cmd = next_command_pointer;
+       assert(NULL != last_cmd);
+       assert(NULL == *last_cmd);
        *last_cmd = cmd;
 
-       (*last_cmd)->next = NULL;
-
-       last_command_pointer = &((*last_cmd)->next);
+       // store location where the next command pointer will be stored
+       next_command_pointer = &cmd->next;
 }
 
-
 void* cmd_queue_alloc(size_t size)
 {
        cmd_queue_page_t **p_page = &cmd_queue_pages;
@@ -533,6 +513,14 @@ void cmd_queue_free(void)
        cmd_queue_pages = NULL;
 }
 
+void jtag_command_queue_reset(void)
+{
+       cmd_queue_free();
+
+       jtag_command_queue = NULL;
+       next_command_pointer = &jtag_command_queue;
+}
+
 /**
  * Copy a scan_field_t for insertion into the queue.
  *
@@ -1595,13 +1583,10 @@ int interface_jtag_execute_queue(void)
                }
        }
 
-       cmd_queue_free();
-
        jtag_callback_queue_head = NULL;
        jtag_callback_queue_tail = NULL;
 
-       jtag_command_queue = NULL;
-       last_command_pointer = &jtag_command_queue;
+       jtag_command_queue_reset();
 
        return retval;
 }

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)