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