summaryrefslogtreecommitdiff
path: root/sysutils/915resolution/patches/patch-aa
blob: f40626f99e4ae46f90e2259aa09e4fb6649fd86a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$NetBSD: patch-aa,v 1.3 2008/08/25 15:11:47 joerg Exp $

--- 915resolution.c.orig	2006-02-02 15:28:34.000000000 +0100
+++ 915resolution.c
@@ -22,11 +22,57 @@
 #include <string.h>
 #include <sys/mman.h>
 #include <fcntl.h>
+#ifdef __linux__
 #include <sys/io.h>
+#endif
+#ifdef __NetBSD__
+#include <machine/pio.h>
+#include <machine/sysarch.h>
+# if defined(__i386__)
+#define iopl(a) i386_iopl(a)
+# elif defined(__x86_64__)
+#define iopl(a) x86_64_iopl(a)
+# endif
+#endif
 #include <unistd.h>
 #include <assert.h>
 
-
+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))