summaryrefslogtreecommitdiff
path: root/audio/rio/patches/patch-ab
blob: 7c782f773de1c90d69c61455eca5f4c64603249a (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
$NetBSD: patch-ab,v 1.4 2008/08/02 18:32:15 dholland Exp $

Add NetBSD and Solaris platforms
Add inb() and outb() from XFree86 sources.
Add NetBSD/x86_64 support.

--- rio.cpp.orig	1999-06-11 12:26:46.000000000 -0400
+++ rio.cpp	2008-08-02 14:16:07.000000000 -0400
@@ -109,11 +109,101 @@
 	#define		CLOCK_SECOND			((int)CLOCKS_PER_SEC)
 	#define		DELETEARRAY				delete
 
+#elif defined(__NetBSD__)
+	// NetBSD/i386,amd64 g++
+	#include	<fcntl.h>
+	#include	<unistd.h>
+	#include	<machine/sysarch.h>
+	//#include	<machine/cpufunc.h>
+	#define		OUTPORT(p,v)			outb( p, v )
+	#define		INPORT(p)				inb( p )
+	#define		CLOCK_SECOND			CLOCKS_PER_SEC
+	#define		DELETEARRAY				delete[]
+
+#elif defined(__sun__) && defined(__svr4__)
+	// Solaris/i386 g++
+	#include	<fcntl.h>
+	#include	<unistd.h>
+	#include	<sys/cpupart.h>
+	#include	<sys/cpuvar.h>
+	#include	<sys/ddi.h>
+	#include	<sys/sunddi.h>
+	#define		OUTPORT(p,v)			outb( p, v )
+	#define		INPORT(p)				inb( p )
+	#define		CLOCK_SECOND			CLOCKS_PER_SEC
+	#define		DELETEARRAY				delete[]
+
 #else
 	// not supported
 	#error ! ! compiler/platform not supported ! !
 #endif
 
+#if defined(__NetBSD__)
+/* copied from the XFree86 sources */
+/* xc/programs/Xserver/hw/xfree86/common/compiler.h */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.4 1998/10/18 20:42:10 hohndel Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
+/* also hacked by agc to do i386_iopl, and by dholland for x86_64_iopl */
+static int ports_enabled;
+
+static __inline__ unsigned int
+inb(unsigned short int port)
+{
+	unsigned char	ret;
+
+	if (!ports_enabled) {
+#ifdef __i386__
+		i386_iopl(1);
+#endif
+#ifdef __x86_64__
+		x86_64_iopl(1);
+#endif
+		ports_enabled = 1;
+	}
+	__asm__ __volatile__("inb %1,%0" :
+		"=a" (ret) :
+		"d" (port));
+	return ret;
+}
+
+static __inline__ void
+outb(unsigned short int port, unsigned char val)
+{
+	if (!ports_enabled) {
+#ifdef __i386__
+		i386_iopl(1);
+#endif
+#ifdef __x86_64__
+		x86_64_iopl(1);
+#endif
+		ports_enabled = 1;
+	}
+	__asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+#endif
+
 // port offset constants
 #define		OFFSET_PORT_DATA		0
 #define		OFFSET_PORT_STATUS		1