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