]> git.sur5r.net Git - openocd/commitdiff
- allow building for MinGW using either -mno-cygwin or the MinGW gcc
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 1 Aug 2006 09:45:22 +0000 (09:45 +0000)
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 1 Aug 2006 09:45:22 +0000 (09:45 +0000)
- added GiveIO support to the amt_jtagaccel driver
- explicitly disable loopback mode for FT2232 devices
- changed configuration options n[st]rst_delay to jtag_n[st]rst_delay
- shutdown network services on exit

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

configure.in
src/jtag/amt_jtagaccel.c
src/jtag/ftd2xx.c
src/jtag/jtag.c
src/openocd.c
src/server/server.c
src/server/server.h

index 2cf08cf40110a1dca02aab958a5f257b111e071a..3518b38d74a6340108f2b14e05305e6a7086dd52 100644 (file)
@@ -48,14 +48,22 @@ AC_ARG_WITH(ftd2xx,
 
 case $host in 
   *-*-cygwin*) 
-    is_cygwin=yes
     is_win32=yes
 
     AC_ARG_ENABLE(parport_giveio,
     AS_HELP_STRING([--enable-parport_giveio], [Enable use of giveio for parport instead of ioperm]), 
     [parport_use_giveio=$enableval], [parport_use_giveio=no])
-
-    AC_DEFINE(IS_CYGWIN, 1, [1 if building for Cygwin.])
+       
+       AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[return __MINGW32__;]),[is_mingw=yes],[is_mingw=no])
+       if test $is_mingw = yes; then
+               AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
+               parport_use_giveio=yes
+               is_cygwin=no
+       else
+               is_cygwin=yes
+               AC_DEFINE(IS_CYGWIN, 1, [1 if building for Cygwin.])
+       fi
+       
     AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
     ;; 
   *-*-mingw*) 
index 113aee664ada372eb13a2b9249e736829df76eaf..d788728b1e624a121022ca077860c4b9195039a3 100644 (file)
 #include "config.h"
 #endif
 
-#include "log.h"
+#include "replacements.h"
+
 #include "jtag.h"
 
 /* system includes */
+
+#ifndef _WIN32
 #include <sys/io.h>
+#else
+#include "errno.h"
+#endif /* _WIN32 */
+
 #include <string.h>
 #include <stdlib.h>
 
 #include <unistd.h>
 #endif
 
+#if PARPORT_USE_GIVEIO == 1
+#if IS_CYGWIN == 1
+#include <windows.h>
+#include <errno.h>
+#undef ERROR
+#endif
+#endif
+
+#include "log.h"
+
 /* configuration */
 unsigned long amt_jtagaccel_port;
 
@@ -382,6 +399,32 @@ int amt_jtagaccel_execute_queue(void)
        return ERROR_OK;
 }
 
+#if PARPORT_USE_GIVEIO == 1
+int amt_jtagaccel_get_giveio_access()
+{
+    HANDLE h;
+    OSVERSIONINFO version;
+
+    version.dwOSVersionInfoSize = sizeof version;
+    if (!GetVersionEx( &version )) {
+        errno = EINVAL;
+        return -1;
+    }
+    if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
+        return 0;
+
+    h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
+    if (h == INVALID_HANDLE_VALUE) {
+        errno = ENODEV;
+        return -1;
+    }
+
+    CloseHandle( h );
+
+    return 0;
+}
+#endif
+
 int amt_jtagaccel_init(void)
 {
 #if PARPORT_USE_PPDEV == 1
@@ -435,8 +478,12 @@ int amt_jtagaccel_init(void)
                amt_jtagaccel_port = 0x378;
                WARNING("No parport port specified, using default '0x378' (LPT1)");
        }
-       
+
+#if PARPORT_USE_GIVEIO == 1
+       if (amt_jtagaccel_get_giveio_access() != 0) {
+#else /* PARPORT_USE_GIVEIO */ 
        if (ioperm(amt_jtagaccel_port, 5, 1) != 0) {
+#endif /* PARPORT_USE_GIVEIO */
                ERROR("missing privileges for direct i/o");
                return ERROR_JTAG_INIT_FAILED;
        }
index e8d29a88ad8c92a0c9b9ef2064e7b1602f268c51..050f9c04d9c01d48885bc55db87449807e6bf05b 100644 (file)
@@ -799,6 +799,8 @@ int ftd2xx_init(void)
        u8 latency_timer;
        FT_STATUS status;
        DWORD num_devices;
+       u8 buf[1];
+       DWORD bytes_written;
        
        ftd2xx_layout_t *cur_layout = ftd2xx_layouts;
        
@@ -900,6 +902,13 @@ int ftd2xx_init(void)
                return ERROR_JTAG_INIT_FAILED;
 
        ftd2xx_speed(jtag_speed);
+
+       buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
+       if (((status = FT_Write(ftdih, buf, 1, &bytes_written)) != FT_OK) || (bytes_written != 1))
+       {
+               ERROR("couldn't write to ftdi device: %i", status);
+               return ERROR_JTAG_INIT_FAILED;
+       }
        
        if ((status = FT_Purge(ftdih, FT_PURGE_RX | FT_PURGE_TX)) != FT_OK)
        {
index b8846f17b8cb0c046694816ee75ed0504c187eda..7c6c911a1024bce9d2c74ba9ba2f46ed51be9877 100644 (file)
@@ -1147,9 +1147,9 @@ int jtag_register_commands(struct command_context_s *cmd_ctx)
                COMMAND_CONFIG, NULL);
        register_command(cmd_ctx, NULL, "reset_config", handle_reset_config_command,
                COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "nsrst_delay", handle_jtag_nsrst_delay_command,
+       register_command(cmd_ctx, NULL, "jtag_nsrst_delay", handle_jtag_nsrst_delay_command,
                COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "ntrst_delay", handle_jtag_ntrst_delay_command,
+       register_command(cmd_ctx, NULL, "jtag_ntrst_delay", handle_jtag_ntrst_delay_command,
                COMMAND_CONFIG, NULL);
                
        register_command(cmd_ctx, NULL, "scan_chain", handle_scan_chain_command,
@@ -1375,7 +1375,7 @@ int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd
 {
        if (argc < 1)
        {
-               ERROR("nsrst_delay <ms> command takes one required argument");
+               ERROR("jtag_nsrst_delay <ms> command takes one required argument");
                exit(-1);
        }
        else
@@ -1390,7 +1390,7 @@ int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd
 {
        if (argc < 1)
        {
-               ERROR("ntrst_delay <ms> command takes one required argument");
+               ERROR("jtag_ntrst_delay <ms> command takes one required argument");
                exit(-1);
        }
        else
index 53ff45485a506d376112ab1b7b9f0922d325455c..b078958e0cdace0fc375fb419475e037adf69305 100644 (file)
@@ -18,7 +18,7 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#define OPENOCD_VERSION "Open On-Chip Debugger (2006-07-30 13:30 CEST)"
+#define OPENOCD_VERSION "Open On-Chip Debugger (2006-08-01 12:00 CEST)"
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -115,6 +115,9 @@ int main(int argc, char *argv[])
        /* handle network connections */
        server_loop(cmd_ctx);
        
+       /* shut server down */
+       server_quit();
+       
        /* free commandline interface */
        command_done(cmd_ctx);
        
index 5d7df1af11491a766d4826f35d7c88ef30bdb09e..951be45053b4159764affb5985a50da7863f3318 100644 (file)
@@ -417,7 +417,7 @@ int server_init()
        return ERROR_OK;
 }
 
-int server_close()
+int server_quit()
 {
        remove_services();
 
index ddf0b97d5e472b510e3607ce37106711f3943112..811e26ecdd2b80d28c47f3d54140bedbd0ad936b 100644 (file)
@@ -65,6 +65,7 @@ typedef struct service_s
 
 extern int add_service(char *name, enum connection_type type, unsigned short port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, void *priv);
 extern int server_init();
+extern int server_quit();
 extern int server_loop(command_context_t *command_context);
 extern int server_register_commands(command_context_t *context);