1 /* $NetBSD: pio.h,v 1.5 2006/02/16 20:17:14 perry Exp $ */
2 /* $OpenBSD: pio.h,v 1.1 1997/10/13 10:53:47 pefo Exp $ */
5 * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed under OpenBSD by
18 * Per Fogelstrom Opsycon AB for RTMX Inc, North Carolina, USA.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
23 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #ifndef _POWERPC_PIO_H_
37 #define _POWERPC_PIO_H_
42 static __inline
void __outb(volatile u_int8_t
*a
, u_int8_t v
);
43 static __inline
void __outw(volatile u_int16_t
*a
, u_int16_t v
);
44 static __inline
void __outl(volatile u_int32_t
*a
, u_int32_t v
);
45 static __inline
void __outwrb(volatile u_int16_t
*a
, u_int16_t v
);
46 static __inline
void __outlrb(volatile u_int32_t
*a
, u_int32_t v
);
47 static __inline u_int8_t
__inb(volatile u_int8_t
*a
);
48 static __inline u_int16_t
__inw(volatile u_int16_t
*a
);
49 static __inline u_int32_t
__inl(volatile u_int32_t
*a
);
50 static __inline u_int16_t
__inwrb(volatile u_int16_t
*a
);
51 static __inline u_int32_t
__inlrb(volatile u_int32_t
*a
);
52 static __inline
void __outsb(volatile u_int8_t
*, const u_int8_t
*,
54 static __inline
void __outsw(volatile u_int16_t
*, const u_int16_t
*,
56 static __inline
void __outsl(volatile u_int32_t
*, const u_int32_t
*,
58 static __inline
void __outswrb(volatile u_int16_t
*, const u_int16_t
*,
60 static __inline
void __outslrb(volatile u_int32_t
*, const u_int32_t
*,
62 static __inline
void __insb(volatile u_int8_t
*, u_int8_t
*, size_t);
63 static __inline
void __insw(volatile u_int16_t
*, u_int16_t
*, size_t);
64 static __inline
void __insl(volatile u_int32_t
*, u_int32_t
*, size_t);
65 static __inline
void __inswrb(volatile u_int16_t
*, u_int16_t
*, size_t);
66 static __inline
void __inslrb(volatile u_int32_t
*, u_int32_t
*, size_t);
74 __asm
volatile("eieio; sync");
79 volatile u_int16_t
*a
;
83 __asm
volatile("eieio; sync");
88 volatile u_int32_t
*a
;
92 __asm
volatile("eieio; sync");
97 volatile u_int16_t
*a
;
100 __asm
volatile("sthbrx %0, 0, %1" :: "r"(v
), "r"(a
));
101 __asm
volatile("eieio; sync");
106 volatile u_int32_t
*a
;
109 __asm
volatile("stwbrx %0, 0, %1" :: "r"(v
), "r"(a
));
110 __asm
volatile("eieio; sync");
113 static __inline u_int8_t
115 volatile u_int8_t
*a
;
120 __asm
volatile("eieio; sync");
124 static __inline u_int16_t
126 volatile u_int16_t
*a
;
131 __asm
volatile("eieio; sync");
135 static __inline u_int32_t
137 volatile u_int32_t
*a
;
142 __asm
volatile("eieio; sync");
146 static __inline u_int16_t
148 volatile u_int16_t
*a
;
152 __asm
volatile("lhbrx %0, 0, %1" : "=r"(_v_
) : "r"(a
));
153 __asm
volatile("eieio; sync");
157 static __inline u_int32_t
159 volatile u_int32_t
*a
;
163 __asm
volatile("lwbrx %0, 0, %1" : "=r"(_v_
) : "r"(a
));
164 __asm
volatile("eieio; sync");
168 #define outb(a,v) (__outb((volatile u_int8_t *)(a), v))
169 #define out8(a,v) outb(a,v)
170 #define outw(a,v) (__outw((volatile u_int16_t *)(a), v))
171 #define out16(a,v) outw(a,v)
172 #define outl(a,v) (__outl((volatile u_int32_t *)(a), v))
173 #define out32(a,v) outl(a,v)
174 #define inb(a) (__inb((volatile u_int8_t *)(a)))
175 #define in8(a) inb(a)
176 #define inw(a) (__inw((volatile u_int16_t *)(a)))
177 #define in16(a) inw(a)
178 #define inl(a) (__inl((volatile u_int32_t *)(a)))
179 #define in32(a) inl(a)
181 #define out8rb(a,v) outb(a,v)
182 #define outwrb(a,v) (__outwrb((volatile u_int16_t *)(a), v))
183 #define out16rb(a,v) outwrb(a,v)
184 #define outlrb(a,v) (__outlrb((volatile u_int32_t *)(a), v))
185 #define out32rb(a,v) outlrb(a,v)
186 #define in8rb(a) inb(a)
187 #define inwrb(a) (__inwrb((volatile u_int16_t *)(a)))
188 #define in16rb(a) inwrb(a)
189 #define inlrb(a) (__inlrb((volatile u_int32_t *)(a)))
190 #define in32rb(a) inlrb(a)
195 volatile u_int8_t
*a
;
201 __asm
volatile("eieio; sync");
206 volatile u_int16_t
*a
;
212 __asm
volatile("eieio; sync");
217 volatile u_int32_t
*a
;
223 __asm
volatile("eieio; sync");
228 volatile u_int16_t
*a
;
233 __asm
volatile("sthbrx %0, 0, %1" :: "r"(*s
++), "r"(a
));
234 __asm
volatile("eieio; sync");
239 volatile u_int32_t
*a
;
244 __asm
volatile("stwbrx %0, 0, %1" :: "r"(*s
++), "r"(a
));
245 __asm
volatile("eieio; sync");
250 volatile u_int8_t
*a
;
256 __asm
volatile("eieio; sync");
261 volatile u_int16_t
*a
;
267 __asm
volatile("eieio; sync");
272 volatile u_int32_t
*a
;
278 __asm
volatile("eieio; sync");
283 volatile u_int16_t
*a
;
288 __asm
volatile("lhbrx %0, 0, %1" : "=r"(*d
++) : "r"(a
));
289 __asm
volatile("eieio; sync");
294 volatile u_int32_t
*a
;
299 __asm
volatile("lwbrx %0, 0, %1" : "=r"(*d
++) : "r"(a
));
300 __asm
volatile("eieio; sync");
303 #define outsb(a,s,c) (__outsb((volatile u_int8_t *)(a), s, c))
304 #define outs8(a,s,c) outsb(a,s,c)
305 #define outsw(a,s,c) (__outsw((volatile u_int16_t *)(a), s, c))
306 #define outs16(a,s,c) outsw(a,s,c)
307 #define outsl(a,s,c) (__outsl((volatile u_int32_t *)(a), s, c))
308 #define outs32(a,s,c) outsl(a,s,c)
309 #define insb(a,d,c) (__insb((volatile u_int8_t *)(a), d, c))
310 #define ins8(a,d,c) insb(a,d,c)
311 #define insw(a,d,c) (__insw((volatile u_int16_t *)(a), d, c))
312 #define ins16(a,d,c) insw(a,d,c)
313 #define insl(a,d,c) (__insl((volatile u_int32_t *)(a), d, c))
314 #define ins32(a,d,c) insl(a,d,c)
316 #define outs8rb(a,s,c) outsb(a,s,c)
317 #define outswrb(a,s,c) (__outswrb((volatile u_int16_t *)(a), s, c))
318 #define outs16rb(a,s,c) outswrb(a,s,c)
319 #define outslrb(a,s,c) (__outslrb((volatile u_int32_t *)(a), s, c))
320 #define outs32rb(a,s,c) outslrb(a,s,c)
321 #define ins8rb(a,d,c) insb(a,d,c)
322 #define inswrb(a,d,c) (__inswrb((volatile u_int16_t *)(a), d, c))
323 #define ins16rb(a,d,c) inswrb(a,d,c)
324 #define inslrb(a,d,c) (__inslrb((volatile u_int32_t *)(a), d, c))
325 #define ins32rb(a,d,c) inslrb(a,d,c)
327 #endif /*_POWERPC_PIO_H_*/