Hello,
I have prepared patch that add to Openocd ability to use InpOut32 library
instead on GiveIO for parallel jtag in Windows.
GiveIO doesn't support 64-bit Windows while InpOut32 does. Library and driver
for it can be downloaded from http://www.highrez.co.uk/Downloads/InpOut32/.
I have tested my changes on Windows 7 with 32-bit and 64-bit Openocd that was
build using Mingw compilers and it seems to work in both cases.
Right now my patch requires to use only one library giveio or inpout32, so I
modified configure.ac so only one of this option could be selected (inpout32 is
preferred library). If you think adding another --enable-parallel-inpout isn't
the best solution I could try to modify giveio code in such a way that if
loading of giveio driver fails (always on 64-bit Windows and when giveio.sys
isn't installed) then as a fallback inpout32 is loaded.
What do you think about this?
Regards,
Jarek
diff --git a/configure.ac b/configure.ac
index ec51bd7..f6d26bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -380,6 +380,11 @@ AC_ARG_ENABLE(parport_giveio,
[Enable use of giveio for parport (for CygWin only)]),
[parport_use_giveio=$enableval], [parport_use_giveio=])
+AC_ARG_ENABLE(parport_inpout,
+ AS_HELP_STRING([--enable-parport-inpout],
+ [Enable use of inpout for parport (for Windows only)]),
+ [parport_use_inpout=$enableval], [parport_use_inpout=no])
+
AC_ARG_ENABLE(ft2232_libftdi,
AS_HELP_STRING([--enable-ft2232_libftdi], [Enable building support for
FT2232 based devices using the libftdi driver, opensource alternate of FTD2XX]),
[build_ft2232_libftdi=$enableval], [build_ft2232_libftdi=no])
@@ -544,10 +549,19 @@ case $host in
[is_mingw=yes],[is_mingw=no])
if test $is_mingw = yes; then
AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
- if test x$parport_use_giveio = xno; then
- AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32
hosts])
+ if test x$parport_use_inpout = xyes; then
+ if test x$parport_use_giveio = xyes; then
+ AC_MSG_WARN([--enable-parport-giveio is not supported when
--enable-parport-inpout is active])
+ fi
+ parport_use_giveio=no
+ parport_use_inpout=yes
+ else
+ if test x$parport_use_giveio = xno; then
+ AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32
hosts])
+ fi
+ parport_use_giveio=yes
+ parport_use_inpout=no
fi
- parport_use_giveio=yes
is_cygwin=no
else
is_cygwin=yes
@@ -566,10 +580,19 @@ case $host in
is_win32=yes
parport_use_ppdev=no
- if test x$parport_use_giveio = xno; then
- AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
+ if test x$parport_use_inpout = xyes; then
+ if test x$parport_use_giveio = xyes; then
+ AC_MSG_WARN([--enable-parport-giveio is not supported when
--enable-parport-inpout is active])
+ fi
+ parport_use_giveio=no
+ parport_use_inpout=yes
+ else
+ if test x$parport_use_giveio = xno; then
+ AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32
hosts])
+ fi
+ parport_use_giveio=yes
+ parport_use_inpout=no
fi
- parport_use_giveio=yes
if test x$build_buspirate = xyes; then
AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
@@ -588,6 +611,10 @@ case $host in
AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
fi
parport_use_giveio=no
+ if test x$parport_use_inpout = xyes; then
+ AC_MSG_WARN([--enable-parport-inpout cannot be used by Darwin hosts])
+ fi
+ parport_use_inpout=no
AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
@@ -598,6 +625,11 @@ case $host in
AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
fi
parport_use_giveio=no
+ if test x$parport_use_inpout = xyes; then
+ AC_MSG_WARN([--enable-parport-inpout cannot be used by ]$host[ hosts])
+ fi
+ parport_use_inpout=no
+
AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
@@ -662,6 +694,12 @@ else
AC_DEFINE(PARPORT_USE_GIVEIO, 0, [0 if you don't want parport to use
giveio.])
fi
+if test x$parport_use_inpout = xyes; then
+ AC_DEFINE(PARPORT_USE_INPOUT, 1, [1 if you want parport to use inpout
library.])
+else
+ AC_DEFINE(PARPORT_USE_INPOUT, 0, [0 if you don't want parport to use inpout
library.])
+fi
+
if test $build_bitbang = yes; then
AC_DEFINE(BUILD_BITBANG, 1, [1 if you want a bitbang interface.])
else
@@ -1064,6 +1102,7 @@ AM_CONDITIONAL(RELEASE, test $build_release = yes)
AM_CONDITIONAL(PARPORT, test $build_parport = yes)
AM_CONDITIONAL(DUMMY, test $build_dummy = yes)
AM_CONDITIONAL(GIVEIO, test x$parport_use_giveio = xyes)
+AM_CONDITIONAL(INPOUT, test x$parport_use_inpout = xyes)
AM_CONDITIONAL(EP93XX, test $build_ep93xx = yes)
AM_CONDITIONAL(ECOSBOARD, test $build_ecosboard = yes)
AM_CONDITIONAL(ZY1000, test $build_zy1000 = yes)
diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c
index ad07791..81a5b43 100644
--- a/src/jtag/drivers/parport.c
+++ b/src/jtag/drivers/parport.c
@@ -52,11 +52,10 @@
#endif
#endif
-#if PARPORT_USE_GIVEIO == 1 && IS_CYGWIN == 1
+#if (PARPORT_USE_GIVEIO == 1 || PARPORT_USE_INPOUT == 1) && IS_CYGWIN == 1
#include <windows.h>
#endif
-
/* parallel port cable description
*/
struct cable {
@@ -118,12 +117,24 @@ static unsigned long dataport;
static unsigned long statusport;
#endif
+#if PARPORT_USE_INPOUT == 1
+typedef void (__stdcall *func_out32)(short, short);
+typedef short (__stdcall *func_inp32)(short);
+typedef BOOL (__stdcall *func_is_driver_open)(void);
+
+func_out32 out32;
+func_inp32 inp32;
+func_is_driver_open is_driver_open;
+#endif
+
static int parport_read(void)
{
int data = 0;
#if PARPORT_USE_PPDEV == 1
ioctl(device_handle, PPRSTATUS, & data);
+#elif PARPORT_USE_INPOUT == 1
+ data = inp32(statusport);
#else
data = inb(statusport);
#endif
@@ -144,6 +155,8 @@ static __inline__ void parport_write_data(void)
#else
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
outb(dataport, output);
+#elif PARPORT_USE_INPOUT == 1
+ out32(dataport, output);
#else
outb(output, dataport);
#endif
@@ -253,6 +266,45 @@ static int parport_get_giveio_access(void)
}
#endif
+#if PARPORT_USE_INPOUT == 1
+static int parport_get_inpout_access(void)
+{
+ HINSTANCE dll;
+
+ if (sizeof(void*) == 8) { //64-bit windows
+ dll = LoadLibrary("InpOutx64.dll");
+ }
+ else { //32-bit windows
+ dll = LoadLibrary("InpOut32.dll") ;
+ }
+
+ if ( dll != NULL ) {
+ out32 = (func_out32)GetProcAddress(dll, "Out32");
+ inp32 = (func_inp32)GetProcAddress(dll, "Inp32");
+ is_driver_open = (func_is_driver_open)GetProcAddress(dll,
"IsInpOutDriverOpen");
+
+ if (out32 == NULL || inp32 == NULL || is_driver_open == NULL) {
+ LOG_ERROR("InpOut library seems to be in wrong version.
"
+ "Check
http://www.highrez.co.uk/Downloads/InpOut32/");
+ return -1;
+ }
+
+ if (is_driver_open() == FALSE) {
+ LOG_ERROR("InpOut driver is not installed. "
+ "Check
http://www.highrez.co.uk/Downloads/InpOut32/");
+ return -1;
+ }
+ }
+ else {
+ LOG_ERROR("Could not load InpOut32.dll (32-bit OpenOCD) or
InpOutx64.dll (64-bit OpenOCD). "
+ "Check
http://www.highrez.co.uk/Downloads/InpOut32/");
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
static struct bitbang_interface parport_bitbang = {
.read = &parport_read,
.write = &parport_write,
@@ -360,6 +412,8 @@ static int parport_init(void)
LOG_DEBUG("requesting privileges for parallel port 0x%lx...", dataport);
#if PARPORT_USE_GIVEIO == 1
if (parport_get_giveio_access() != 0)
+#elif PARPORT_USE_INPOUT == 1
+ if (parport_get_inpout_access() != 0)
#else /* PARPORT_USE_GIVEIO */
if (ioperm(dataport, 3, 1) != 0)
#endif /* PARPORT_USE_GIVEIO */
@@ -372,6 +426,8 @@ static int parport_init(void)
/* make sure parallel port is in right mode (clear tristate and
interrupt */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
outb(parport_port + 2, 0x0);
+ #elif PARPORT_USE_INPOUT == 1
+ out32(parport_port + 2, 0x0);
#else
outb(0x0, parport_port + 2);
#endif
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development