From 09156b3b13e4940d14d390f7cbb1fd6bdea6a9d8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 3 Sep 2007 10:47:50 +0200 Subject: [PATCH] Resurrected the Windows port. --- ChangeLog | 5 +++++ README.Windows | 9 ++++++--- lib/i386-io-windows.h | 14 +++++++++++--- lib/types.h | 7 ++++--- lspci.c | 2 +- win32/config.h | 3 ++- win32/config.mk | 10 ++++++++++ 7 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 win32/config.mk diff --git a/ChangeLog b/ChangeLog index 962d642..181074a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-03 Martin Mares + + * Resurrected the Windows port, including cross-compilation by MinGW. + Patch by Samuel Bronson . + 2007-08-31 Martin Mares * Makefile, lib/Makefile: `ar' and `ranlib' can be overriden to allow diff --git a/README.Windows b/README.Windows index 14c11e4..7a85fda 100644 --- a/README.Windows +++ b/README.Windows @@ -1,8 +1,11 @@ Since 2.1.99-test5, pciutils should also be compilable on Windows. Thanks to Alexander Stock for contributing the port. -To build this port, you need to install WinIO.dll first. You can get it +Updated after version 2.2.6 to compile again, and with MinGW, even (only?) +cross-compiling. (Hopefully it works with MSVC too.) + +To use this port, you need to install WinIO.dll first. You can get it from http://www.internals.com/. -However, you need to use win32/config.h instead of the automatically -generated lib/config.h as lib/configure does not run on Windows. +However, you need to use win32/config.{h,mk} instead of the automatically +generated lib/config.{h,mk} as lib/configure does not run on Windows. diff --git a/lib/i386-io-windows.h b/lib/i386-io-windows.h index 0e28244..6e3dec0 100644 --- a/lib/i386-io-windows.h +++ b/lib/i386-io-windows.h @@ -8,9 +8,19 @@ */ #include -#include #include +#ifndef __GNUC__ +#include +#else +int _outp(unsigned short port, int databyte); +unsigned short _outpw(unsigned short port, unsigned short dataword); +unsigned long _outpd(unsigned short port, unsigned long dataword); +int _inp(unsigned short port); +unsigned short _inpw(unsigned short port); +unsigned long _inpd(unsigned short port); +#endif + #define outb(x,y) _outp(y,x) #define outw(x,y) _outpw(y,x) #define outl(x,y) _outpd(y,x) @@ -26,8 +36,6 @@ intel_setup_io(struct pci_access *a) MYPROC InitializeWinIo; HMODULE lib; - intel_iopl_set = 0; - lib = LoadLibrary("WinIo.dll"); if (!lib) { diff --git a/lib/types.h b/lib/types.h index 5191d15..f7ab470 100644 --- a/lib/types.h +++ b/lib/types.h @@ -11,9 +11,10 @@ #ifndef PCI_HAVE_Uxx_TYPES #ifdef PCI_OS_WINDOWS -typedef unsigned __int8 u8; -typedef unsigned __int16 u16; -typedef unsigned __int32 u32; +#include +typedef BYTE u8; +typedef WORD u16; +typedef DWORD u32; #elif defined(PCI_HAVE_STDINT_H) #include typedef uint8_t u8; diff --git a/lspci.c b/lspci.c index db5a8bd..9ec1056 100644 --- a/lspci.c +++ b/lspci.c @@ -59,7 +59,7 @@ static struct pci_access *pacc; * use alloca() much. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(PCI_OS_WINDOWS) #include #else #undef alloca diff --git a/win32/config.h b/win32/config.h index 38d282d..455deac 100644 --- a/win32/config.h +++ b/win32/config.h @@ -1,5 +1,6 @@ #define PCI_ARCH_I386 #define PCI_OS_WINDOWS #define PCI_HAVE_PM_INTEL_CONF -#define PCI_PATH_IDS "pci.ids" +#define PCI_IDS "pci.ids" +#define PCI_PATH_IDS_DIR "." #define PCILIB_VERSION "@VERSION@" diff --git a/win32/config.mk b/win32/config.mk new file mode 100644 index 0000000..98240c0 --- /dev/null +++ b/win32/config.mk @@ -0,0 +1,10 @@ +# TOOLPREFIX is for cross compiling + +CC=$(TOOLPREFIX)gcc +LD=$(TOOLPREFIX)ld +AR=$(TOOLPREFIX)ar +RANLIB=$(TOOLPREFIX)ranlib + +PCI_ARCH_I386=yes +PCI_OS_WINDOWS=yes +PCI_HAVE_PM_INTEL_CONF=yes -- 2.39.5