aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Pannell <300992+DigitalDJ@users.noreply.github.com>2023-12-31 01:57:30 +1030
committerGrant Pannell <300992+DigitalDJ@users.noreply.github.com>2023-12-31 01:57:30 +1030
commitebbd5e810639fe13c6e85eb358b34997253244d8 (patch)
treefa0d07d540c22e514f186f0a3a5631ca1d804083
parentcf930fa5ec551e2842a607cd299dd3c061b69d63 (diff)
downloadpciutils-ebbd5e810639fe13c6e85eb358b34997253244d8.tar.gz
i386-ports: Add support for OpenBSD
-rw-r--r--README2
-rwxr-xr-xlib/configure6
-rw-r--r--lib/i386-io-openbsd.h54
-rw-r--r--lib/i386-ports.c2
4 files changed, 63 insertions, 1 deletions
diff --git a/README b/README
index 04e9348..fce2f61 100644
--- 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)
diff --git a/lib/configure b/lib/configure
index 158cc0a..2479def 100755
--- a/lib/configure
+++ b/lib/configure
@@ -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
index 0000000..8a9b4a4
--- /dev/null
+++ b/lib/i386-io-openbsd.h
@@ -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)
+{
+}
diff --git a/lib/i386-ports.c b/lib/i386-ports.c
index 687dd48..5f8aea4 100644
--- a/lib/i386-ports.c
+++ b/lib/i386-ports.c
@@ -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