From 550d67d1ce6e71f6461efc71ca481655da8de763 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 26 Aug 2008 17:10:20 +0200 Subject: [PATCH] Added a Cygwin port. Patch by Christopher Voltz, ported to the current tree by me. --- README | 1 + lib/Makefile | 2 +- lib/configure | 9 +++++++++ lib/i386-io-cygwin.h | 22 ++++++++++++++++++++++ lib/i386-ports.c | 2 ++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lib/i386-io-cygwin.h diff --git a/README b/README index d111b91..4b3cb1a 100644 --- a/README +++ b/README @@ -23,6 +23,7 @@ In runs on the following systems: Aix (via /dev/pci and odmget) GNU Hurd (direct port access) Windows (direct port access) + CYGWIN (direct port access) It should be very easy to add support for other systems as well (volunteers wanted; if you want to try that, I'll be very glad to see the patches and diff --git a/lib/Makefile b/lib/Makefile index acbd420..31ca1c1 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -66,7 +66,7 @@ $(PCILIBPC): libpci.pc.in init.o: init.c $(INCL) access.o: access.c $(INCL) params.o: params.c $(INCL) -i386-ports.o: i386-ports.c $(INCL) i386-io-hurd.h i386-io-linux.h i386-io-sunos.h i386-io-windows.h +i386-ports.o: i386-ports.c $(INCL) i386-io-hurd.h i386-io-linux.h i386-io-sunos.h i386-io-windows.h i386-io-cygwin.h proc.o: proc.c $(INCL) pread.h sysfs.o: sysfs.c $(INCL) pread.h generic.o: generic.c $(INCL) diff --git a/lib/configure b/lib/configure index 4861be1..521cd71 100755 --- a/lib/configure +++ b/lib/configure @@ -32,6 +32,10 @@ if [ -z "$HOST" ] ; then then sys=freebsd fi + if [ "$sys" = "CYGWIN_NT-5.1" ] + then + sys=cygwin + fi HOST=${3:-$cpu-$sys} fi # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless. @@ -108,6 +112,11 @@ case $sys in echo_n " i386-ports" echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' ;; + cygwin) + echo_n " i386-ports" + echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' + echo >>$m 'LDLIBS+=-lioperm' + ;; *) echo " Unfortunately, your OS is not supported by the PCI Library" exit 1 diff --git a/lib/i386-io-cygwin.h b/lib/i386-io-cygwin.h new file mode 100644 index 0000000..4af2f81 --- /dev/null +++ b/lib/i386-io-cygwin.h @@ -0,0 +1,22 @@ +/* + * The PCI Library -- Access to i386 I/O ports under Windows with CYGWIN + * + * Copyright (c) 1997--2006 Martin Mares + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include + +static int +intel_setup_io(struct pci_access *a UNUSED) +{ + return (iopl(3) < 0) ? 0 : 1; +} + +static inline int +intel_cleanup_io(struct pci_access *a UNUSED) +{ + iopl(3); + return -1; +} diff --git a/lib/i386-ports.c b/lib/i386-ports.c index 041e47f..666b749 100644 --- a/lib/i386-ports.c +++ b/lib/i386-ports.c @@ -20,6 +20,8 @@ #include "i386-io-sunos.h" #elif defined(PCI_OS_WINDOWS) #include "i386-io-windows.h" +#elif defined(PCI_OS_CYGWIN) +#include "i386-io-cygwin.h" #else #error Do not know how to access I/O ports on this OS. #endif -- 2.39.5