This patch allows isapnptools to compile and work under OpenBSD, NetBSD and FreeBSD. Tested under OpenBSD 3.1-current, NetBSD-1.5.2 and FreeBSD 4.6.2-RELEASE. Configure with --disable-realtime --disable-proc --disable-pci diff -Nur isapnptools-1.26/include/isapnp/iopl.h isapnptools-1.26-pva/include/isapnp/iopl.h --- isapnptools-1.26/include/isapnp/iopl.h Wed May 9 04:14:21 2001 +++ isapnptools-1.26-pva/include/isapnp/iopl.h Mon Sep 2 09:59:06 2002 @@ -54,6 +54,12 @@ #ifndef _OS2_ # if defined __GLIBC__ && __GLIBC__ >= 2 # include +# elif defined __OpenBSD__ || defined __NetBSD__ +# include /* inb/outb */ +# include /* sysarch call */ +# elif defined __FreeBSD__ +# include +# include # else # ifdef _AXP_ # include diff -Nur isapnptools-1.26/include/isapnp/pnp.h isapnptools-1.26-pva/include/isapnp/pnp.h --- isapnptools-1.26/include/isapnp/pnp.h Fri Apr 13 00:51:19 2001 +++ isapnptools-1.26-pva/include/isapnp/pnp.h Mon Sep 2 09:57:45 2002 @@ -33,13 +33,23 @@ #else /* !_OS2_ && !__DJGPP__ */ #ifdef DEBUG static int x; +#if defined __OpenBSD__ || defined __NetBSD__ || defined __FreeBSD__ +#define ADDRESS(x) (outb(ADDRESS_ADDR, x), printf("\nAddress: %04x", x)) +#define WRITE_DATA(x) (outb(WRITEDATA_ADDR, x), printf(" WR(%02x)", x & 0xff)) +#else #define ADDRESS(x) (outb(x, ADDRESS_ADDR), printf("\nAddress: %04x", x)) #define WRITE_DATA(x) (outb(x, WRITEDATA_ADDR), printf(" WR(%02x)", x & 0xff)) +#endif /* FreeBSD, NetBSD, OpenBSD */ #define READ_DATA (x = inb(read_port), printf(" RD(%02x)", x & 0xff), x) #define READ_IOPORT(p) (x = inb(p), printf(" [%04x](%02x)", p, x & 0xff), x) #else /* !DEBUG */ +#if defined __OpenBSD__ || defined __NetBSD__ || defined __FreeBSD__ +#define ADDRESS(x) outb(ADDRESS_ADDR, x) +#define WRITE_DATA(x) outb(WRITEDATA_ADDR, x) +#else #define ADDRESS(x) outb(x, ADDRESS_ADDR) #define WRITE_DATA(x) outb(x, WRITEDATA_ADDR) +#endif /* FreeBSD, NetBSD, OpenBSD */ #define READ_DATA inb(read_port) #define READ_IOPORT(p) inb(p) #endif /* !DEBUG */ diff -Nur isapnptools-1.26/src/iopl.c isapnptools-1.26-pva/src/iopl.c --- isapnptools-1.26/src/iopl.c Wed May 9 04:14:21 2001 +++ isapnptools-1.26-pva/src/iopl.c Mon Sep 2 09:57:45 2002 @@ -48,6 +48,11 @@ #include #include +#ifdef __FreeBSD__ +#include +static int iofd = -1; +#endif /* __FreeBSD__ */ + /* Acquire I/O port privileges needed for ISA PnP configuration. ** The return value is 0 on success, or the value of errno on failure. */ @@ -65,6 +70,14 @@ /* ALPHA only has ioperm, apparently, so cover all with one permission */ ret = ioperm(MIN_READ_ADDR, WRITEDATA_ADDR - MIN_READ_ADDR + 1, 1); #endif /* HAVE_IOPERM */ +#if defined __OpenBSD__ || defined __NetBSD__ + struct i386_iopl_args iopls; + + iopls.iopl = 3; + ret = sysarch(I386_IOPL, (char *)&iopls); +#elif defined __FreeBSD__ + ret = (iofd = open("/dev/io", O_RDONLY)) < 0 ? -1 : 0; +#endif /* __OpenBSD__ || __NetBSD__ */ #endif /* !HAVE_IOPL */ if (ret < 0) { @@ -88,6 +101,14 @@ #ifdef HAVE_IOPERM ret = ioperm(MIN_READ_ADDR, WRITEDATA_ADDR - MIN_READ_ADDR + 1, 0); #endif /* HAVE_IOPERM */ +#if defined __OpenBSD__ || defined __NetBSD__ + struct i386_iopl_args iopls; + + iopls.iopl = 0; + ret = sysarch(I386_IOPL, (char *)&iopls); +#elif defined __FreeBSD__ + ret = close(iofd); +#endif /* __OpenBSD__ || __NetBSD__ */ #endif /* !HAVE_IOPL */ if (ret < 0) {