]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * HISTORY | |
30 | * | |
31 | * Revision 1.2 1998/09/30 21:20:45 wsanchez | |
32 | * Merged in IntelMerge1 (mburg: Intel support) | |
33 | * | |
34 | * Revision 1.1.2.1 1998/09/30 18:18:50 mburg | |
35 | * Changes for Intel port | |
36 | * | |
37 | * Revision 1.1.1.1 1998/03/07 02:25:38 wsanchez | |
38 | * Import of OSF Mach kernel (~mburg) | |
39 | * | |
40 | * Revision 1.1.8.2 1996/07/31 09:46:36 paire | |
41 | * Merged with nmk20b7_shared (1.1.11.2 -> 1.1.11.1) | |
42 | * [96/06/10 paire] | |
43 | * | |
44 | * Revision 1.1.11.2 1996/06/13 12:38:25 bernadat | |
45 | * Do not use inline macros when MACH_ASSERT is configured. | |
46 | * [96/05/24 bernadat] | |
47 | * | |
48 | * Revision 1.1.11.1 1996/05/14 13:50:23 paire | |
49 | * Added new linl and loutl __inline__. | |
50 | * Added conditional compilation for [l]{in|oub}[bwl]() __inline__. | |
51 | * [95/11/24 paire] | |
52 | * | |
53 | * Revision 1.1.8.1 1994/09/23 02:00:28 ezf | |
54 | * change marker to not FREE | |
55 | * [1994/09/22 21:25:52 ezf] | |
56 | * | |
57 | * Revision 1.1.4.5 1993/08/09 19:40:41 dswartz | |
58 | * Add ANSI prototypes - CR#9523 | |
59 | * [1993/08/06 17:45:57 dswartz] | |
60 | * | |
61 | * Revision 1.1.4.4 1993/06/11 15:17:37 jeffc | |
62 | * CR9176 - ANSI C violations: inb/outb macros must be changed from | |
63 | * ({ ... }) to inline functions, with proper type definitions. Callers | |
64 | * must pass proper types to these functions: 386 I/O port addresses | |
65 | * are unsigned shorts (not pointers). | |
66 | * [1993/06/10 14:26:10 jeffc] | |
67 | * | |
68 | * Revision 1.1.4.3 1993/06/07 22:09:28 jeffc | |
69 | * CR9176 - ANSI C violations: trailing tokens on CPP | |
70 | * directives, extra semicolons after decl_ ..., asm keywords | |
71 | * [1993/06/07 19:00:26 jeffc] | |
72 | * | |
73 | * Revision 1.1.4.2 1993/06/04 15:28:45 jeffc | |
74 | * CR9176 - ANSI problems - | |
75 | * Added casts to get macros to take caddr_t as an I/O space address. | |
76 | * [1993/06/04 13:45:55 jeffc] | |
77 | * | |
78 | * Revision 1.1 1992/09/30 02:25:51 robert | |
79 | * Initial revision | |
80 | * | |
81 | * $EndLog$ | |
82 | */ | |
83 | /* CMU_HIST */ | |
84 | /* | |
85 | * Revision 2.5 91/05/14 16:14:20 mrt | |
86 | * Correcting copyright | |
87 | * | |
88 | * Revision 2.4 91/02/05 17:13:56 mrt | |
89 | * Changed to new Mach copyright | |
90 | * [91/02/01 17:37:08 mrt] | |
91 | * | |
92 | * Revision 2.3 90/12/20 16:36:37 jeffreyh | |
93 | * changes for __STDC__ | |
94 | * [90/12/07 jeffreyh] | |
95 | * | |
96 | * Revision 2.2 90/11/26 14:48:41 rvb | |
97 | * Pulled from 2.5 | |
98 | * [90/11/22 10:09:38 rvb] | |
99 | * | |
100 | * [90/08/14 mg32] | |
101 | * | |
102 | * Now we know how types are factor in. | |
103 | * Cleaned up a bunch: eliminated ({ for output and flushed unused | |
104 | * output variables. | |
105 | * [90/08/14 rvb] | |
106 | * | |
107 | * This is how its done in gcc: | |
108 | * Created. | |
109 | * [90/03/26 rvb] | |
110 | * | |
111 | */ | |
112 | /* CMU_ENDHIST */ | |
113 | /* | |
114 | * Mach Operating System | |
115 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
116 | * All Rights Reserved. | |
117 | * | |
118 | * Permission to use, copy, modify and distribute this software and its | |
119 | * documentation is hereby granted, provided that both the copyright | |
120 | * notice and this permission notice appear in all copies of the | |
121 | * software, derivative works or modified versions, and any portions | |
122 | * thereof, and that both notices appear in supporting documentation. | |
123 | * | |
124 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
125 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
126 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
127 | * | |
128 | * Carnegie Mellon requests users of this software to return to | |
129 | * | |
130 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
131 | * School of Computer Science | |
132 | * Carnegie Mellon University | |
133 | * Pittsburgh PA 15213-3890 | |
134 | * | |
135 | * any improvements or extensions that they make and grant Carnegie Mellon | |
136 | * the rights to redistribute these changes. | |
137 | */ | |
138 | /* | |
139 | */ | |
140 | #ifndef I386_PIO_H | |
141 | #define I386_PIO_H | |
142 | ||
143 | typedef unsigned short i386_ioport_t; | |
144 | ||
145 | /* read a longword */ | |
146 | extern unsigned long inl( | |
147 | i386_ioport_t port); | |
148 | /* read a shortword */ | |
149 | extern unsigned short inw( | |
150 | i386_ioport_t port); | |
151 | /* read a byte */ | |
152 | extern unsigned char inb( | |
153 | i386_ioport_t port); | |
154 | /* write a longword */ | |
155 | extern void outl( | |
156 | i386_ioport_t port, | |
157 | unsigned long datum); | |
158 | /* write a word */ | |
159 | extern void outw( | |
160 | i386_ioport_t port, | |
161 | unsigned short datum); | |
162 | /* write a longword */ | |
163 | extern void outb( | |
164 | i386_ioport_t port, | |
165 | unsigned char datum); | |
166 | ||
167 | /* input an array of longwords */ | |
168 | extern void linl( | |
169 | i386_ioport_t port, | |
170 | int * data, | |
171 | int count); | |
172 | /* output an array of longwords */ | |
173 | extern void loutl( | |
174 | i386_ioport_t port, | |
175 | int * data, | |
176 | int count); | |
177 | ||
178 | /* input an array of words */ | |
179 | extern void linw( | |
180 | i386_ioport_t port, | |
181 | int * data, | |
182 | int count); | |
183 | /* output an array of words */ | |
184 | extern void loutw( | |
185 | i386_ioport_t port, | |
186 | int * data, | |
187 | int count); | |
188 | ||
189 | /* input an array of bytes */ | |
190 | extern void linb( | |
191 | i386_ioport_t port, | |
192 | char * data, | |
193 | int count); | |
194 | /* output an array of bytes */ | |
195 | extern void loutb( | |
196 | i386_ioport_t port, | |
197 | char * data, | |
198 | int count); | |
199 | ||
200 | extern __inline__ unsigned long inl( | |
201 | i386_ioport_t port) | |
202 | { | |
203 | unsigned long datum; | |
204 | __asm__ volatile("inl %1, %0" : "=a" (datum) : "d" (port)); | |
205 | return(datum); | |
206 | } | |
207 | ||
208 | extern __inline__ unsigned short inw( | |
209 | i386_ioport_t port) | |
210 | { | |
211 | unsigned short datum; | |
212 | __asm__ volatile(".byte 0x66; inl %1, %0" : "=a" (datum) : "d" (port)); | |
213 | return(datum); | |
214 | } | |
215 | ||
216 | extern __inline__ unsigned char inb( | |
217 | i386_ioport_t port) | |
218 | { | |
219 | unsigned char datum; | |
220 | __asm__ volatile("inb %1, %0" : "=a" (datum) : "d" (port)); | |
221 | return(datum); | |
222 | } | |
223 | ||
224 | extern __inline__ void outl( | |
225 | i386_ioport_t port, | |
226 | unsigned long datum) | |
227 | { | |
228 | __asm__ volatile("outl %0, %1" : : "a" (datum), "d" (port)); | |
229 | } | |
230 | ||
231 | extern __inline__ void outw( | |
232 | i386_ioport_t port, | |
233 | unsigned short datum) | |
234 | { | |
235 | __asm__ volatile(".byte 0x66; outl %0, %1" : : "a" (datum), "d" (port)); | |
236 | } | |
237 | ||
238 | extern __inline__ void outb( | |
239 | i386_ioport_t port, | |
240 | unsigned char datum) | |
241 | { | |
242 | __asm__ volatile("outb %0, %1" : : "a" (datum), "d" (port)); | |
243 | } | |
244 | ||
245 | #endif /* I386_PIO_H */ |