diff -Nru 915resolution-0.5.3/915resolution.c 915resolution-0.5.3-new/915resolution.c --- 915resolution-0.5.3/915resolution.c 2007-04-21 12:40:51 +0000 +++ 915resolution-0.5.3-new/915resolution.c 2007-04-21 12:40:51 +0000 @@ -22,7 +22,17 @@ #include #include #include + +#if defined(__NetBSD__) +#include +#include +#include "bsd_io.h" +#elif defined(__FreeBSD__) +#include "bsd_io.h" +#elif defined(linux) #include +#endif + #include #include @@ -163,12 +173,26 @@ void initialize_system(char * filename) { - if (!filename) { +#if defined(__FreeBSD__) + int iofd = open("/dev/io", O_RDONLY); + if (iofd == -1) { + perror("Unable to obtain the proper IO permissions"); + exit(2); + } +#elif defined(__NetBSD__) + if (i386_iopl(3) < 0) { + perror("Unable to obtain the proper IO permissions"); + exit(2); + } +#elif defined(linux) if (iopl(3) < 0) { perror("Unable to obtain the proper IO permissions"); exit(2); } +#else +#error Not ported to this operating system +#endif } } diff -Nru 915resolution-0.5.3/bsd_io.h 915resolution-0.5.3-new/bsd_io.h --- 915resolution-0.5.3/bsd_io.h 1970-01-01 00:00:00 +0000 +++ 915resolution-0.5.3-new/bsd_io.h 2007-04-21 12:40:51 +0000 @@ -0,0 +1,42 @@ +#include + +#ifndef _BSD_IO_H_ +#define _BSD_IO_H_ + +/* Ripped out of cpufunc.h, changed args to match Linux. */ +static __inline u_int +inl(u_int port) +{ + u_int data; + + __asm __volatile("inl %%dx,%0" : "=a" (data) : "d" (port)); + return (data); +} + +static __inline u_char +inb(u_int port) +{ + u_char data; + + __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port)); + return (data); +} + +static __inline void +outl(u_int data, u_int port) +{ + /* + * outl() and outw() aren't used much so we haven't looked at + * possible micro-optimizations such as the unnecessary + * assignment for them. + */ + __asm __volatile("outl %0,%%dx" : : "a" (data), "d" (port)); +} + +static __inline void +outb(u_char data, u_int port) +{ + __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port))); +} + +#endif