$NetBSD: patch-ad,v 1.1.1.1 2003/10/05 09:16:17 cube Exp $ --- src/card_direct.c.orig 2003-05-08 17:42:44.000000000 +0200 +++ src/card_direct.c @@ -44,8 +44,12 @@ #include #ifdef HAVE_PCI +#ifdef HAVE_PCIUTILS +#include +#else #include #endif +#endif #include #include #ifdef HAVE_SYS_IO_H @@ -164,6 +168,56 @@ void unmapDevMem (CardPtr card, unsigned /* -------- Common -------- */ +#ifdef __NetBSD__ +static int +ioperm(from, num, turn_on) + unsigned long from; + unsigned long num; + int turn_on; +{ + u_long *bitmap, mask, value; + int r = -1; + int first_index, last_index, i; + + if((bitmap = (u_long *)malloc(1024*sizeof(u_long))) == NULL) + return -1; + + if(i386_get_ioperm(bitmap) != 0) + goto ioperm_fail; + + first_index = from / 32; + last_index = (from + num) / 32; + + /* First set */ + mask = 0xffffffff << (from % 32); + if(turn_on) + bitmap[first_index] |= mask; + else + bitmap[first_index] &= ~mask; + + /* Last set */ + mask = 0xffffffff >> (31 - (from + num) % 32); + if(turn_on) + bitmap[last_index] |= mask; + else + bitmap[last_index] &= ~mask; + + if(last_index > first_index + 1) { + /* Complete sets */ + value = turn_on ? 0xffffffff : 0; + + for(i = first_index+1; i