summaryrefslogtreecommitdiff
path: root/graphics/cqcam/patches/patch-ab
blob: eddc0c46d7ee6eab9ee2ec78032e8887f63cf33f (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
64
65
66
67
68
69
70
71
72
$NetBSD: patch-ab,v 1.6 2008/10/01 22:12:01 joerg Exp $

--- libcqcam/port.C.orig	2000-08-23 20:03:19.000000000 +0200
+++ libcqcam/port.C
@@ -30,6 +30,7 @@
 #include "config.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 
 #ifdef LOCKING
@@ -47,6 +48,10 @@
 #include <conio.h>
 #elif defined(FREEBSD)
 #include <machine/cpufunc.h>
+#elif defined(NETBSD)
+#include <sys/types.h>
+#include <machine/sysarch.h>
+#include <machine/pio.h>	/* XXX */
 #elif defined(BSDI)
 #include <machine/inline.h>
 #elif defined(OPENBSD)
@@ -90,6 +95,28 @@ port_t::port_t(int iport) {
     perror("fopen /dev/io");
     return;
   }
+#elif defined(NETBSD)
+# if defined(__alpha__)
+  if (alpha_pci_io_enable(1) != 0) {
+    perror("alpha_pci_io_enable");
+    return;
+  }
+# elif defined(__i386__)
+  if (i386_iopl(3) != 0) {
+    perror("i386_iopl");
+    return;
+  }
+# elif defined(__x86_64__)
+  if (x86_64_iopl(3) != 0) {
+    perror("x86_64_iopl");
+    return;
+  }
+# else
+#  error Not supported on this CPU.
+# endif
+#elif defined(LYNX)
+   if (io_access() < 0) {
+     perror("io_access");
 #elif defined(OPENBSD)
   if (i386_iopl(1) == -1) {
     perror("i386_iopl");
@@ -196,3 +223,19 @@ void port_t::unlock(int portnum) {
 #endif /* DEBUG */
 }
 #endif /* LOCKING */
+
+#if defined(NETBSD)
+void
+outb(unsigned port, uint8_t data)
+{
+	__asm volatile("outb %0,%w1" : : "a" (data), "d" (port));
+}
+
+uint8_t
+inb(unsigned port)
+{
+	uint8_t data;
+	__asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
+	return data;
+}
+#endif