Index: src/target/target.c
===================================================================
--- src/target/target.c	(revision 769)
+++ src/target/target.c	(working copy)
@@ -49,7 +49,6 @@
 
 int cli_target_callback_event_handler(struct target_s *target, enum target_event event, void *priv);
 
-
 int handle_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
 
@@ -225,9 +224,20 @@
 	if (event == TARGET_EVENT_HALTED)
 	{
 		target_unregister_event_callback(target_init_handler, priv);
-
 		target_invoke_script(cmd_ctx, target, "post_reset");
+		jtag_execute_queue();
+	}
+	
+	return ERROR_OK;
+}
 
+int target_event_handler(struct target_s *target, enum target_event event, void *priv)
+{
+	struct command_context_s *cmd_ctx = priv;
+	
+	if (event == TARGET_EVENT_RESUMED)
+	{
+		target_invoke_script(cmd_ctx, target, "pre_resume");
 		jtag_execute_queue();
 	}
 	
@@ -273,6 +283,7 @@
 		LOG_ERROR("Target not examined yet");
 		return ERROR_FAIL;
 	}
+	
 	return target->type->resume(target, current, address, handle_breakpoints, debug_execution);
 }
 
@@ -460,7 +471,6 @@
 		target = target->next;
 	}
 	target_unregister_event_callback(target_init_handler, cmd_ctx);
-				
 	
 	jtag->speed(jtag_speed_post_reset);
 	
@@ -592,6 +602,7 @@
 	{
 		target_register_user_commands(cmd_ctx);
 		target_register_timer_callback(handle_target, 100, 1, NULL);
+		target_register_event_callback(target_event_handler, cmd_ctx);
 	}
 		
 	return ERROR_OK;
@@ -783,7 +794,6 @@
 	return target_call_timer_callbacks(0);
 }
 
-
 int target_alloc_working_area(struct target_s *target, u32 size, working_area_t **area)
 {
 	working_area_t *c = target->working_areas;
@@ -1472,7 +1482,6 @@
 	name, get_num_by_target(target));
 }
 
-
 int handle_target_script_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
 	target_t *target = NULL;
@@ -1818,7 +1827,6 @@
 	return handle_wait_halt_command(cmd_ctx, cmd, args, argc);
 }
 
-		
 int handle_soft_reset_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
 	target_t *target = get_current_target(cmd_ctx);
@@ -2010,8 +2018,7 @@
 	value = strtoul(args[1], NULL, 0);
 	if (argc == 3)
 		count = strtoul(args[2], NULL, 0);
-
-
+	
 	switch (cmd[2])
 	{
 		case 'w':
Index: src/target/target.h
===================================================================
--- src/target/target.h	(revision 769)
+++ src/target/target.h	(working copy)
@@ -201,8 +201,7 @@
 	enum target_reset_mode reset_mode;	/* what to do after a reset */
 	int run_and_halt_time;				/* how long the target should run after a run_and_halt reset */
 	u32 working_area;					/* working area (initialized RAM). Evaluated 
-										   upon first allocation from virtual/physical address.
-										  */
+										   upon first allocation from virtual/physical address. */
 	u32 working_area_virt;				/* virtual address */
 	u32 working_area_phys;				/* physical address */
 	u32 working_area_size;				/* size in bytes */
@@ -299,7 +298,6 @@
 extern int target_free_all_working_areas(struct target_s *target);
 extern int target_free_all_working_areas_restore(struct target_s *target, int restore);
 
-
 extern target_t *targets;
 
 extern target_event_callback_t *target_event_callbacks;
@@ -322,7 +320,6 @@
 
 int target_invoke_script(struct command_context_s *cmd_ctx, target_t *target, char *name);
 
-
 #define ERROR_TARGET_INVALID	(-300)
 #define ERROR_TARGET_INIT_FAILED (-301)
 #define ERROR_TARGET_TIMEOUT	(-302)

