#include "jtag.h"
 #include "breakpoints.h"
 #include "flash.h"
+#include "target.h"
 #include "target_request.h"
 #include "configuration.h"
 
                        break;
                if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
                        return retval;
-        if( reply == '$' ){
+               if( reply == '$' ){
                        // fix a problem with some IAR tools
                        gdb_putback_char( connection, reply );
                        LOG_DEBUG("Unexpected start of new packet");
        return ERROR_OK;
 }
 
-void gdb_connection_closed(connection_t *connection)
+int gdb_connection_closed(connection_t *connection)
 {
        gdb_service_t *gdb_service = connection->service->priv;
        gdb_connection_t *gdb_connection = connection->priv;
        log_remove_callback(gdb_log_callback, connection);
 
        target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_DETACH );
+
+       return ERROR_OK;
 }
 
 void gdb_send_error(connection_t *connection, u8 the_error)
 
        
        if((retval = jtag_execute_queue()) != ERROR_OK)
        {
-               return retval;
+               return;
        }
        
        /* fix program counter:
 
        u16 erase_check_code[] =
        {
                                                        /* loop: */
-                0xF810, 0x3B01,        /* ldrb         r3, [r0], #1 */
-                0xEA02, 0x0203,        /* and  r2, r2, r3 */
-                0x3901,                        /* subs         r1, r1, #1 */
-                0xD1F9,                        /* bne          loop */
-                                                       /* end: */
-                0xE7FE,                        /* b            end */
+               0xF810, 0x3B01,         /* ldrb         r3, [r0], #1 */
+               0xEA02, 0x0203,         /* and  r2, r2, r3 */
+               0x3901,                         /* subs         r1, r1, #1 */
+               0xD1F9,                         /* bne          loop */
+                                                       /* end: */
+               0xE7FE,                         /* b            end */
        };
 
        /* make sure we have a working area */
 
        mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
        
        LOG_DEBUG("target->state: %s", 
-                 Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
+               Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
        
        if (!(jtag_reset_config & RESET_HAS_SRST))
        {
 
        mips32_invalidate_core_regs(target);
 
-    if (target->reset_halt)
-    {
-       int retval;
+       if (target->reset_halt)
+       {
+               int retval;
                if ((retval = target_halt(target))!=ERROR_OK)
                        return retval;
-    }
+       }
        
        
        return ERROR_OK;
 int mips_m4k_deassert_reset(target_t *target)
 {
        LOG_DEBUG("target->state: %s", 
-                 Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
+               Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
        
        /* deassert reset lines */
        jtag_add_reset(0, 0);
        }
        
        /* current = 1: continue on current pc, otherwise continue at <address> */
-       if (!current) 
+       if (!current)
        {
                buf_set_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32, address);
                mips32->core_cache->reg_list[MIPS32_PC].dirty = 1;
        /* initialize mips4k specific info */
        mips32_init_arch_info(target, mips32, chain_pos, variant);
        mips32->arch_info = mips_m4k;
-               
+       
        return ERROR_OK;
 }
 
 
 extern int target_init(struct command_context_s *cmd_ctx);
 extern int target_examine(void);
 extern int handle_target(void *priv);
+extern int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mode reset_mode);
 
 extern int target_register_event_callback(int (*callback)(struct target_s *target, enum target_event event, void *priv), void *priv);
 extern int target_unregister_event_callback(int (*callback)(struct target_s *target, enum target_event event, void *priv), void *priv);
 
-# Test script to check that syntax error in reset\r
-# script is reported properly.\r
-\r
-# at91eb40a target\r
-\r
-#jtag scan chain\r
-jtag_device 4 0x1 0xf 0xe\r
-\r
-#target configuration\r
-target arm7tdmi little 0 arm7tdmi-s_r4\r
-\r
-[new_target_name] configure -event reset-init { \r
-\r
-       syntax error\r
-}\r
+# Test script to check that syntax error in reset
+# script is reported properly.
+
+# at91eb40a target
+
+#jtag scan chain
+jtag_device 4 0x1 0xf 0xe
+
+#target configuration
+target arm7tdmi little 0 arm7tdmi-s_r4
+
+[new_target_name] configure -event reset-init { 
+
+       syntax error
+}
 
-# This script tests a syntax error in the startup \r
-# config script\r
-\r
+# This script tests a syntax error in the startup 
+# config script
+
 syntax error here
\ No newline at end of file