]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
i386-ports: Add support for OpenBSD
authorGrant Pannell <300992+DigitalDJ@users.noreply.github.com>
Sat, 30 Dec 2023 15:27:30 +0000 (01:57 +1030)
committerGrant Pannell <300992+DigitalDJ@users.noreply.github.com>
Sat, 30 Dec 2023 15:27:30 +0000 (01:57 +1030)
README
lib/configure
lib/i386-io-openbsd.h [new file with mode: 0644]
lib/i386-ports.c

diff --git a/README b/README
index 04e9348f5b5a601b31bce336e016d4f13d42dced..fce2f6151abc9df61334d3c7a417c0e4561257ad 100644 (file)
--- a/README
+++ b/README
@@ -20,7 +20,7 @@ In runs on the following systems:
        Linux           (via /sys/bus/pci, /proc/bus/pci or i386 ports)
        FreeBSD         (via /dev/pci)
        NetBSD          (via libpci)
-       OpenBSD         (via /dev/pci)
+       OpenBSD         (via /dev/pci or i386 ports)
        GNU/kFreeBSD    (via /dev/pci)
        Solaris/i386    (direct port access)
        Aix             (via /dev/pci and odmget)
index 158cc0a71bd9bc5552c244c35ca1633e0198a51c..2479deff45c56660b1a692e287db347534daa787 100755 (executable)
@@ -121,6 +121,12 @@ case $sys in
                echo >>$c '#define PCI_PATH_DEVMEM_DEVICE "/dev/mem"'
                echo >>$c '#define PCI_PATH_ACPI_MCFG "/var/db/acpi/MCFG.*"'
                echo >>$c '#define PCI_PATH_EFI_SYSTAB ""'
+               case $cpu in
+                               i386|amd64)     echo_n " i386-ports"
+                                               echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
+                                               echo >>$m 'WITH_LIBS+=-l'$cpu
+                                               ;;
+               esac
                LIBRESOLV=
                ;;
 
diff --git a/lib/i386-io-openbsd.h b/lib/i386-io-openbsd.h
new file mode 100644 (file)
index 0000000..8a9b4a4
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *     The PCI Library -- Access to i386 I/O ports on OpenBSD
+ *
+ *     Copyright (c) 2023 Grant Pannell <grant@pannell.net.au>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include <sys/types.h>
+#include <machine/sysarch.h>
+#include <machine/pio.h>
+
+#include "i386-io-access.h"
+
+#if defined(__amd64__)
+  #define obsd_iopl amd64_iopl
+#else
+  #define obsd_iopl i386_iopl
+#endif
+
+static int iopl_enabled;
+
+static int
+intel_setup_io(struct pci_access *a UNUSED)
+{
+  if (iopl_enabled)
+    return 1;
+
+  if (obsd_iopl(3) < 0)
+    {
+      return 0;
+    }
+
+  iopl_enabled = 1;
+  return 1;
+}
+
+static inline void
+intel_cleanup_io(struct pci_access *a UNUSED)
+{
+  if (iopl_enabled)
+    {
+      obsd_iopl(0);
+      iopl_enabled = 0;
+    }
+}
+
+static inline void intel_io_lock(void)
+{
+}
+
+static inline void intel_io_unlock(void)
+{
+}
index 687dd48451f2b6fd04cab03cc40a4bd16efd7135..5f8aea437a1f2d0ff7849f6dafd26839f1e0191b 100644 (file)
@@ -30,6 +30,8 @@
 #include "i386-io-beos.h"
 #elif defined(PCI_OS_DJGPP)
 #include "i386-io-djgpp.h"
+#elif defined(PCI_OS_OPENBSD)
+#include "i386-io-openbsd.h"
 #else
 #error Do not know how to access I/O ports on this OS.
 #endif