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