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