update Sun Jun 20 06:37:00 PDT 2010
[pkgsrc.git] / sysutils / 915resolution / patches / patch-aa
1 $NetBSD: patch-aa,v 1.4 2010/06/20 11:06:03 wiz Exp $
2
3 --- 915resolution.c.orig        2007-04-15 10:46:56.000000000 +0000
4 +++ 915resolution.c
5 @@ -22,11 +22,57 @@
6  #include <string.h>
7  #include <sys/mman.h>
8  #include <fcntl.h>
9 +#ifdef __linux__
10  #include <sys/io.h>
11 +#endif
12 +#ifdef __NetBSD__
13 +#include <machine/pio.h>
14 +#include <machine/sysarch.h>
15 +# if defined(__i386__)
16 +#define iopl(a) i386_iopl(a)
17 +# elif defined(__x86_64__)
18 +#define iopl(a) x86_64_iopl(a)
19 +# endif
20 +#endif
21  #include <unistd.h>
22  #include <assert.h>
23  
24 +static uint8_t
25 +asm_inb(unsigned port)
26 +{
27 +       uint8_t data;
28 +       __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
29 +       return data;
30 +}
31 +
32 +static __inline void
33 +asm_outb(uint8_t data, unsigned port)
34 +{
35 +       __asm volatile("outb %0,%w1" : : "a" (data), "d" (port));
36 +}
37 +
38 +static uint32_t
39 +asm_inl(unsigned port)
40 +{
41 +       uint32_t data;
42 +       __asm volatile("inl %w1,%0" : "=a" (data) : "d" (port));
43 +       return data;
44 +}
45  
46 +static __inline void
47 +asm_outl(uint32_t data, unsigned port)
48 +{
49 +       __asm volatile("outl %0,%w1" : : "a" (data), "d" (port));
50 +}
51 +
52 +#undef inb
53 +#undef outb
54 +#define        inb asm_inb
55 +#define        outb asm_outb
56 +#undef inl
57 +#undef outl
58 +#define        inl asm_inl
59 +#define        outl asm_outl
60  
61  #define NEW(a) ((a *)(calloc(1, sizeof(a))))
62  #define FREE(a) (free(a))
63 @@ -165,7 +211,12 @@ typedef struct {
64  void initialize_system(char * filename) {
65  
66      if (!filename) {
67 +#if !defined(__FreeBSD__) & !defined(__DragonFly__)
68          if (iopl(3) < 0) {
69 +#else
70 +        FILE *iof = fopen("/dev/io", "r");
71 +        if(iof == NULL) {
72 +#endif
73              perror("Unable to obtain the proper IO permissions");
74              exit(2);
75          }