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.... ;)

Z
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
===================================================================
--- src/target/target/str912.cfg	(revision 1498)
+++ src/target/target/str912.cfg	(working copy)
@@ -1,4 +1,6 @@
 # script for str9
+# For more information about the configuration files, take a look at:
+# openocd.texi
 
 if { [info exists CHIPNAME] } {	
    set  _CHIPNAME $CHIPNAME    
@@ -13,7 +15,8 @@
 }
 
 # jtag speed. We need to stick to 16kHz until we've finished reset.
-jtag_rclk 16
+jtag_speed 32
+#jtag_speed 0
 
 jtag_nsrst_delay 100
 jtag_ntrst_delay 100
@@ -46,25 +49,25 @@
 set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
 target create $_TARGETNAME arm966e -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm966e
 
-$_TARGETNAME configure -event reset-start { jtag_rclk 16 }
+proc str9x_init { } {
+	# reset and halt target
+	soft_reset_halt
 
-$_TARGETNAME configure -event reset-init {
-	# We can increase speed now that we know the target is halted.
-	#jtag_rclk 3000
-	
 	# -- Enable 96K RAM
 	# PFQBC enabled / DTCM & AHB wait-states disabled
-	mww 0x5C002034 0x0191 
+	mww 0x5C002034 0x0191
+	# PFQBC disabled / DTCM & AHB wait-states enabled
+	#mww 0x5C002034 0x0196
 
-	str9x flash_config 0 4 2 0 0x80000
-	flash protect 0 0 7 off
+	# 256K/32k
+	str9x flash_config 0 3 2 0 0x40000
+	# 512K/32K 
+	#str9x flash_config 0 4 2 0 0x80000
 }
 
 $_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x50000000 -work-area-size 16384 -work-area-backup 0
 
 #flash bank str9x <base> <size> 0 0 <target#> <variant>
-flash bank str9x 0x00000000 0x00080000 0 0 0
-flash bank str9x 0x00080000 0x00008000 0 0 0
+flash bank str9x 0x00000000 0x00040000 0 0 0
+flash bank str9x 0x00040000 0x00008000 0 0 0
 
-# For more information about the configuration files, take a look at:
-# openocd.texi
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to