On Tue, 2009-04-21 at 23:30 -0700, Zach Welch wrote:
> On Tue, 2009-04-21 at 21:27 -0700, Zach Welch wrote:
> > Hi all,
> > 
> > This patch factors the massive switch in jlink_execute_queue into a much
> > more manageable set of static functions.  I have a few others small
> > cleanups left in mind, but this should be the last really big one.
> 
> Yes, I did forget to attach the patch. :)  And here, I was wondering
> what was taking so long.... ;)

Oi...  I need to do something about my changes to the str912.cfg file;
it keeps slipping into my patches accidentally.  Correct patch attached.
Sorry for the noise.

Cheers,

Zach


Index: src/jtag/jlink.c
===================================================================
--- src/jtag/jlink.c	(revision 1498)
+++ src/jtag/jlink.c	(working copy)
@@ -130,95 +130,113 @@
 	.quit = jlink_quit
 };
 
-static int jlink_execute_queue(void)
+static void jlink_execute_end_state(jtag_command_t *cmd)
 {
-	jtag_command_t *cmd = jtag_command_queue;
-	int scan_size;
-	enum scan_type type;
-	u8 *buffer;
+	DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state);
 
-	while (cmd != NULL)
-	{
-		switch (cmd->type)
-		{
-			case JTAG_END_STATE:
-				DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state);
+	if (cmd->cmd.end_state->end_state != TAP_INVALID)
+		jlink_end_state(cmd->cmd.end_state->end_state);
+}
 
-				if (cmd->cmd.end_state->end_state != TAP_INVALID)
-				{
-					jlink_end_state(cmd->cmd.end_state->end_state);
-				}
-				break;
+static void jlink_execute_runtest(jtag_command_t *cmd)
+{
+	DEBUG_JTAG_IO("runtest %i cycles, end in %i",
+			cmd->cmd.runtest->num_cycles,
+			cmd->cmd.runtest->end_state);
 
-			case JTAG_RUNTEST:
-				DEBUG_JTAG_IO( "runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
-					cmd->cmd.runtest->end_state);
+	if (cmd->cmd.runtest->end_state != TAP_INVALID)
+		jlink_end_state(cmd->cmd.runtest->end_state);
 
-				if (cmd->cmd.runtest->end_state != TAP_INVALID)
-				{
-					jlink_end_state(cmd->cmd.runtest->end_state);
-				}
-				jlink_runtest(cmd->cmd.runtest->num_cycles);
-				break;
+	jlink_runtest(cmd->cmd.runtest->num_cycles);
+}
 
-			case JTAG_STATEMOVE:
-				DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
+static void jlink_execute_statemove(jtag_command_t *cmd)
+{
+	DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
 
-				if (cmd->cmd.statemove->end_state != TAP_INVALID)
-				{
-					jlink_end_state(cmd->cmd.statemove->end_state);
-				}
-				jlink_state_move();
-				break;
+	if (cmd->cmd.statemove->end_state != TAP_INVALID)
+	{
+		jlink_end_state(cmd->cmd.statemove->end_state);
+	}
+	jlink_state_move();
+}
 
-			case JTAG_PATHMOVE:
-				DEBUG_JTAG_IO("pathmove: %i states, end in %i", \
-					cmd->cmd.pathmove->num_states, \
-					cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
+static void jlink_execute_pathmove(jtag_command_t *cmd)
+{
+	DEBUG_JTAG_IO("pathmove: %i states, end in %i",
+		cmd->cmd.pathmove->num_states,
+		cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]);
 
-				jlink_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path);
-				break;
+	jlink_path_move(cmd->cmd.pathmove->num_states,
+			cmd->cmd.pathmove->path);
+}
 
-			case JTAG_SCAN:
-				DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
+static void jlink_execute_scan(jtag_command_t *cmd)
+{
+	int scan_size;
+	enum scan_type type;
+	u8 *buffer;
 
-				if (cmd->cmd.scan->end_state != TAP_INVALID)
-				{
-					jlink_end_state(cmd->cmd.scan->end_state);
-				}
+	DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
 
-				scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
-				DEBUG_JTAG_IO("scan input, length = %d", scan_size);
+	if (cmd->cmd.scan->end_state != TAP_INVALID)
+		jlink_end_state(cmd->cmd.scan->end_state);
 
+	scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
+	DEBUG_JTAG_IO("scan input, length = %d", scan_size);
+
 #ifdef _DEBUG_USB_COMMS_
-				jlink_debug_buffer(buffer, (scan_size + 7) / 8);
+	jlink_debug_buffer(buffer, (scan_size + 7) / 8);
 #endif
-				type = jtag_scan_type(cmd->cmd.scan);
-				jlink_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size, cmd->cmd.scan);
-				break;
+	type = jtag_scan_type(cmd->cmd.scan);
+	jlink_scan(cmd->cmd.scan->ir_scan,
+			type, buffer, scan_size, cmd->cmd.scan);
+}
 
-			case JTAG_RESET:
-				DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
+static void jlink_execute_reset(jtag_command_t *cmd)
+{
+	DEBUG_JTAG_IO("reset trst: %i srst %i",
+			cmd->cmd.reset->trst, cmd->cmd.reset->srst);
 
-				jlink_tap_execute();
+	jlink_tap_execute();
 
-				if (cmd->cmd.reset->trst == 1)
-				{
-					tap_set_state(TAP_RESET);
-				}
-				jlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
-				break;
+	if (cmd->cmd.reset->trst == 1)
+		tap_set_state(TAP_RESET);
 
-			case JTAG_SLEEP:
-				DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
-				jlink_tap_execute();
-				jtag_sleep(cmd->cmd.sleep->us);
-				break;
+	jlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
+}
 
-			default:
-				LOG_ERROR("BUG: unknown JTAG command type encountered");
-				exit(-1);
-		}
+static void jlink_execute_sleep(jtag_command_t *cmd)
+{
+	DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us);
+	jlink_tap_execute();
+	jtag_sleep(cmd->cmd.sleep->us);
+}
+
+static void jlink_execute_command(jtag_command_t *cmd)
+{
+	switch (cmd->type)
+	{
+	case JTAG_END_STATE: jlink_execute_end_state(cmd); break;
+	case JTAG_RUNTEST:   jlink_execute_runtest(cmd); break;
+	case JTAG_STATEMOVE: jlink_execute_statemove(cmd); break;
+	case JTAG_PATHMOVE:  jlink_execute_pathmove(cmd); break;
+	case JTAG_SCAN:      jlink_execute_scan(cmd); break;
+	case JTAG_RESET:     jlink_execute_reset(cmd); break;
+	case JTAG_SLEEP:     jlink_execute_sleep(cmd); break;
+	default:
+		LOG_ERROR("BUG: unknown JTAG command type encountered");
+		exit(-1);
+	}
+}
+
+static int jlink_execute_queue(void)
+{
+	jtag_command_t *cmd = jtag_command_queue;
+
+	while (cmd != NULL)
+	{
+		jlink_execute_command(cmd);
 		cmd = cmd->next;
 	}
 
Index: src/target/target/str912.cfg
===================================================================
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to