$NetBSD: patch-ab,v 1.6 2008/10/01 22:12:01 joerg Exp $ --- libcqcam/port.C.orig 2000-08-23 20:03:19.000000000 +0200 +++ libcqcam/port.C @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include #ifdef LOCKING @@ -47,6 +48,10 @@ #include #elif defined(FREEBSD) #include +#elif defined(NETBSD) +#include +#include +#include /* XXX */ #elif defined(BSDI) #include #elif defined(OPENBSD) @@ -90,6 +95,28 @@ port_t::port_t(int iport) { perror("fopen /dev/io"); return; } +#elif defined(NETBSD) +# if defined(__alpha__) + if (alpha_pci_io_enable(1) != 0) { + perror("alpha_pci_io_enable"); + return; + } +# elif defined(__i386__) + if (i386_iopl(3) != 0) { + perror("i386_iopl"); + return; + } +# elif defined(__x86_64__) + if (x86_64_iopl(3) != 0) { + perror("x86_64_iopl"); + return; + } +# else +# error Not supported on this CPU. +# endif +#elif defined(LYNX) + if (io_access() < 0) { + perror("io_access"); #elif defined(OPENBSD) if (i386_iopl(1) == -1) { perror("i386_iopl"); @@ -196,3 +223,19 @@ void port_t::unlock(int portnum) { #endif /* DEBUG */ } #endif /* LOCKING */ + +#if defined(NETBSD) +void +outb(unsigned port, uint8_t data) +{ + __asm volatile("outb %0,%w1" : : "a" (data), "d" (port)); +} + +uint8_t +inb(unsigned port) +{ + uint8_t data; + __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port)); + return data; +} +#endif