>From cc42ae54e07dd0ea0bb8b448253730e88e737a23 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Fri, 2 Nov 2018 06:33:57 -0400 Subject: [PATCH] Autodetect hurd access method && re-add i386 method for hurd as fallback --- lib/configure | 2 ++ lib/hurd.c | 3 ++- lib/i386-io-hurd.h | 35 +++++++++++++++++++++++++++++++++++ lib/i386-ports.c | 2 ++ lib/init.c | 1 + 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 lib/i386-io-hurd.h diff --git a/lib/configure b/lib/configure index a1541ac..7e12e6f 100755 --- a/lib/configure +++ b/lib/configure @@ -127,6 +127,8 @@ case $sys in gnu) echo_n " hurd" echo >>$c '#define PCI_HAVE_PM_HURD_CONF' + echo_n " i386-ports" + echo >>$c '#define PCI_HAVE_PM_INTEL_CONF' ;; djgpp) echo_n " i386-ports" diff --git a/lib/hurd.c b/lib/hurd.c index c9581df..6f46902 100644 --- a/lib/hurd.c +++ b/lib/hurd.c @@ -50,7 +50,7 @@ hurd_detect (struct pci_access *a) err = lstat (_SERVERS_BUS_PCI, &st); if (err) { - a->error ("Could not open file `%s'", _SERVERS_BUS_PCI); + a->warning ("Could not open file `%s'", _SERVERS_BUS_PCI); return 0; } @@ -187,6 +187,7 @@ hurd_scan (struct pci_access *a) { int err; + assert (hurd_detect(a) != 0); err = enum_devices (_SERVERS_BUS_PCI, a, -1, -1, -1, -1, LEVEL_DOMAIN); assert (err == 0); } diff --git a/lib/i386-io-hurd.h b/lib/i386-io-hurd.h new file mode 100644 index 0000000..261f681 --- /dev/null +++ b/lib/i386-io-hurd.h @@ -0,0 +1,35 @@ +/* + * The PCI Library -- Access to i386 I/O ports on GNU Hurd + * + * Copyright (c) 2003 Marco Gerards + * Copyright (c) 2003 Martin Mares + * Copyright (c) 2006 Samuel Thibault and + * Thomas Schwinge + * Copyright (c) 2007 Thomas Schwinge + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include + +static inline int +intel_setup_io(struct pci_access *a UNUSED) +{ + return (ioperm (0, 65535, 1) == -1) ? 0 : 1; +} + +static inline int +intel_cleanup_io(struct pci_access *a UNUSED) +{ + ioperm (0, 65535, 0); + + return -1; +} + +static inline void intel_io_lock(void) +{ +} + +static inline void intel_io_unlock(void) +{ +} diff --git a/lib/i386-ports.c b/lib/i386-ports.c index 85515ca..c3502d9 100644 --- a/lib/i386-ports.c +++ b/lib/i386-ports.c @@ -24,6 +24,8 @@ #include "i386-io-beos.h" #elif defined(PCI_OS_DJGPP) #include "i386-io-djgpp.h" +#elif defined(PCI_OS_GNU) +#include "i386-io-hurd.h" #else #error Do not know how to access I/O ports on this OS. #endif diff --git a/lib/init.c b/lib/init.c index e067f0a..d543301 100644 --- a/lib/init.c +++ b/lib/init.c @@ -85,6 +85,7 @@ static int probe_sequence[] = { PCI_ACCESS_OBSD_DEVICE, PCI_ACCESS_DARWIN, PCI_ACCESS_SYLIXOS_DEVICE, + PCI_ACCESS_GNU, // Low-level methods poking the hardware directly PCI_ACCESS_I386_TYPE1, PCI_ACCESS_I386_TYPE2, -- 2.17.1