From ebbd5e810639fe13c6e85eb358b34997253244d8 Mon Sep 17 00:00:00 2001 From: Grant Pannell <300992+DigitalDJ@users.noreply.github.com> Date: Sun, 31 Dec 2023 01:57:30 +1030 Subject: i386-ports: Add support for OpenBSD --- README | 2 +- lib/configure | 6 ++++++ lib/i386-io-openbsd.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/i386-ports.c | 2 ++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 lib/i386-io-openbsd.h 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 + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include +#include +#include + +#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 -- cgit 1.2.3-korg