$NetBSD: patch-aa,v 1.4 2010/06/20 11:06:03 wiz Exp $ --- 915resolution.c.orig 2007-04-15 10:46:56.000000000 +0000 +++ 915resolution.c @@ -22,11 +22,57 @@ #include #include #include +#ifdef __linux__ #include +#endif +#ifdef __NetBSD__ +#include +#include +# if defined(__i386__) +#define iopl(a) i386_iopl(a) +# elif defined(__x86_64__) +#define iopl(a) x86_64_iopl(a) +# endif +#endif #include #include +static uint8_t +asm_inb(unsigned port) +{ + uint8_t data; + __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port)); + return data; +} + +static __inline void +asm_outb(uint8_t data, unsigned port) +{ + __asm volatile("outb %0,%w1" : : "a" (data), "d" (port)); +} + +static uint32_t +asm_inl(unsigned port) +{ + uint32_t data; + __asm volatile("inl %w1,%0" : "=a" (data) : "d" (port)); + return data; +} +static __inline void +asm_outl(uint32_t data, unsigned port) +{ + __asm volatile("outl %0,%w1" : : "a" (data), "d" (port)); +} + +#undef inb +#undef outb +#define inb asm_inb +#define outb asm_outb +#undef inl +#undef outl +#define inl asm_inl +#define outl asm_outl #define NEW(a) ((a *)(calloc(1, sizeof(a)))) #define FREE(a) (free(a)) @@ -165,7 +211,12 @@ typedef struct { void initialize_system(char * filename) { if (!filename) { +#if !defined(__FreeBSD__) & !defined(__DragonFly__) if (iopl(3) < 0) { +#else + FILE *iof = fopen("/dev/io", "r"); + if(iof == NULL) { +#endif perror("Unable to obtain the proper IO permissions"); exit(2); }