]> git.saurik.com Git - apple/xnu.git/blame - iokit/include/architecture/i386/pio.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / iokit / include / architecture / i386 / pio.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
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,
d7e50217
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.1.2.1 1998/10/13 00:40:44 ehewitt
32 * Added support for Intel.
33 *
34 * Revision 1.1.1.1 1998/09/22 21:05:37 wsanchez
35 * Import of Mac OS X kernel (~semeria)
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//#include <cpus.h>
143//#include <mach_assert.h>
144#define MACH_ASSERT 0
145
146typedef unsigned short i386_ioport_t;
147
148/* read a longword */
149extern unsigned long inl(
150 i386_ioport_t port);
151/* read a shortword */
152extern unsigned short inw(
153 i386_ioport_t port);
154/* read a byte */
155extern unsigned char inb(
156 i386_ioport_t port);
157/* write a longword */
158extern void outl(
159 i386_ioport_t port,
160 unsigned long datum);
161/* write a word */
162extern void outw(
163 i386_ioport_t port,
164 unsigned short datum);
165/* write a longword */
166extern void outb(
167 i386_ioport_t port,
168 unsigned char datum);
169
170/* input an array of longwords */
171extern void linl(
172 i386_ioport_t port,
173 int * data,
174 int count);
175/* output an array of longwords */
176extern void loutl(
177 i386_ioport_t port,
178 int * data,
179 int count);
180
181/* input an array of words */
182extern void linw(
183 i386_ioport_t port,
184 int * data,
185 int count);
186/* output an array of words */
187extern void loutw(
188 i386_ioport_t port,
189 int * data,
190 int count);
191
192/* input an array of bytes */
193extern void linb(
194 i386_ioport_t port,
195 char * data,
196 int count);
197/* output an array of bytes */
198extern void loutb(
199 i386_ioport_t port,
200 char * data,
201 int count);
202
203#if defined(__GNUC__) && (!MACH_ASSERT)
204extern __inline__ unsigned long inl(
205 i386_ioport_t port)
206{
207 unsigned long datum;
208 __asm__ volatile("inl %1, %0" : "=a" (datum) : "d" (port));
209 return(datum);
210}
211
212extern __inline__ unsigned short inw(
213 i386_ioport_t port)
214{
215 unsigned short datum;
216 __asm__ volatile(".byte 0x66; inl %1, %0" : "=a" (datum) : "d" (port));
217 return(datum);
218}
219
220extern __inline__ unsigned char inb(
221 i386_ioport_t port)
222{
223 unsigned char datum;
224 __asm__ volatile("inb %1, %0" : "=a" (datum) : "d" (port));
225 return(datum);
226}
227
228extern __inline__ void outl(
229 i386_ioport_t port,
230 unsigned long datum)
231{
232 __asm__ volatile("outl %0, %1" : : "a" (datum), "d" (port));
233}
234
235extern __inline__ void outw(
236 i386_ioport_t port,
237 unsigned short datum)
238{
239 __asm__ volatile(".byte 0x66; outl %0, %1" : : "a" (datum), "d" (port));
240}
241
242extern __inline__ void outb(
243 i386_ioport_t port,
244 unsigned char datum)
245{
246 __asm__ volatile("outb %0, %1" : : "a" (datum), "d" (port));
247}
248#endif /* defined(__GNUC__) && (!MACH_ASSERT) */
249#endif /* I386_PIO_H */