xref: /freebsd/sys/powerpc/include/bus.h (revision 2b743a9e9ddc6736208dc8ca1ce06ce64ad20a19)
1 /*-
2  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
7  * NASA Ames Research Center.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by the NetBSD
20  *	Foundation, Inc. and its contributors.
21  * 4. Neither the name of The NetBSD Foundation nor the names of its
22  *    contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 /*-
39  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
40  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
41  *
42  * Redistribution and use in source and binary forms, with or without
43  * modification, are permitted provided that the following conditions
44  * are met:
45  * 1. Redistributions of source code must retain the above copyright
46  *    notice, this list of conditions and the following disclaimer.
47  * 2. Redistributions in binary form must reproduce the above copyright
48  *    notice, this list of conditions and the following disclaimer in the
49  *    documentation and/or other materials provided with the distribution.
50  * 3. All advertising materials mentioning features or use of this software
51  *    must display the following acknowledgement:
52  *      This product includes software developed by Christopher G. Demetriou
53  *	for the NetBSD Project.
54  * 4. The name of the author may not be used to endorse or promote products
55  *    derived from this software without specific prior written permission
56  *
57  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
61  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
62  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
63  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
64  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
65  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
66  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67  *
68  *	$NetBSD: bus.h,v 1.9.4.1 2000/06/30 16:27:30 simonb Exp $
69  * $FreeBSD$
70  */
71 
72 #ifndef	_MACPPC_BUS_H_
73 #define	_MACPPC_BUS_H_
74 
75 #include <machine/_bus.h>
76 #include <machine/pio.h>
77 
78 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
79 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
80 #define BUS_SPACE_MAXSIZE       0xFFFFFFFF
81 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
82 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
83 #define BUS_SPACE_MAXADDR       0xFFFFFFFF
84 
85 #define BUS_SPACE_UNRESTRICTED  (~0)
86 
87 /*
88  * Values for the macppc bus space tag, not to be used directly by MI code.
89  */
90 
91 #define	__BUS_SPACE_HAS_STREAM_METHODS 1
92 
93 /*
94  * Define the PPC tag values
95  */
96 #define PPC_BUS_SPACE_MEM	1	/* space is mem space */
97 #define PPC_BUS_SPACE_IO	2	/* space is io space */
98 
99 static __inline void *
100 __ppc_ba(bus_space_tag_t tag __unused, bus_space_handle_t handle,
101     bus_size_t offset)
102 {
103 	return ((void *)(handle + offset));
104 }
105 
106 /*
107  *	int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
108  *	    bus_size_t size, int flags, bus_space_handle_t *bshp));
109  *
110  * Map a region of bus space.
111  */
112 
113 static __inline int
114 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
115 	      bus_size_t size __unused, int flags __unused,
116 	      bus_space_handle_t *bshp)
117 {
118 
119 	*bshp = addr;
120 	return (0);
121 }
122 
123 /*
124  *	int bus_space_unmap(bus_space_tag_t t,
125  *	    bus_space_handle_t bsh, bus_size_t size));
126  *
127  * Unmap a region of bus space.
128  */
129 
130 static __inline void
131 bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
132                 bus_size_t size __unused)
133 {
134 }
135 
136 /*
137  *	int bus_space_subregion(bus_space_tag_t t,
138  *	    bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
139  *	    bus_space_handle_t *nbshp));
140  *
141  * Get a new handle for a subregion of an already-mapped area of bus space.
142  */
143 
144 static __inline int
145 bus_space_subregion(bus_space_tag_t t __unused, bus_space_handle_t bsh,
146     bus_size_t offset, bus_size_t size __unused, bus_space_handle_t *nbshp)
147 {
148 	*nbshp = bsh + offset;
149 	return (0);
150 }
151 
152 /*
153  *	int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
154  *	    bus_addr_t rend, bus_size_t size, bus_size_t align,
155  *	    bus_size_t boundary, int flags, bus_addr_t *addrp,
156  *	    bus_space_handle_t *bshp));
157  *
158  * Allocate a region of bus space.
159  */
160 
161 #if 0
162 #define	bus_space_alloc(t, rs, re, s, a, b, f, ap, hp)	!!! unimplemented !!!
163 #endif
164 
165 /*
166  *	int bus_space_free(bus_space_tag_t t,
167  *	    bus_space_handle_t bsh, bus_size_t size));
168  *
169  * Free a region of bus space.
170  */
171 #if 0
172 #define	bus_space_free(t, h, s)		!!! unimplemented !!!
173 #endif
174 
175 /*
176  *	u_intN_t bus_space_read_N(bus_space_tag_t tag,
177  *	    bus_space_handle_t bsh, bus_size_t offset));
178  *
179  * Read a 1, 2, 4, or 8 byte quantity from bus space
180  * described by tag/handle/offset.
181  */
182 
183 static __inline u_int8_t
184 bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
185 {
186 	return (in8(__ppc_ba(t, h, o)));
187 }
188 
189 static __inline u_int16_t
190 bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
191 {
192 	return (in16rb(__ppc_ba(t, h, o)));
193 }
194 
195 static __inline u_int32_t
196 bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
197 {
198 	return (in32rb(__ppc_ba(t, h, o)));
199 }
200 
201 #if 0	/* Cause a link error for bus_space_read_8 */
202 #define	bus_space_read_8(t, h, o)	!!! unimplemented !!!
203 #endif
204 
205 static __inline u_int8_t
206 bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
207 {
208 	return (in8(__ppc_ba(t, h, o)));
209 }
210 
211 static __inline u_int16_t
212 bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
213 {
214 	return (in16(__ppc_ba(t, h, o)));
215 }
216 
217 static __inline u_int32_t
218 bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
219 {
220 	return (in32(__ppc_ba(t, h, o)));
221 }
222 
223 #if 0	/* Cause a link error for bus_space_read_stream_8 */
224 #define	bus_space_read_stream_8(t, h, o)	!!! unimplemented !!!
225 #endif
226 
227 /*
228  *	void bus_space_read_multi_N(bus_space_tag_t tag,
229  *	    bus_space_handle_t bsh, bus_size_t offset,
230  *	    u_intN_t *addr, size_t count));
231  *
232  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
233  * described by tag/handle/offset and copy into buffer provided.
234  */
235 
236 static __inline void
237 bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
238     u_int8_t *a, size_t c)
239 {
240 	ins8(__ppc_ba(t, h, o), a, c);
241 }
242 
243 static __inline void
244 bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
245     u_int16_t *a, size_t c)
246 {
247 	ins16rb(__ppc_ba(t, h, o), a, c);
248 }
249 
250 static __inline void
251 bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
252     u_int32_t *a, size_t c)
253 {
254 	ins32rb(__ppc_ba(t, h, o), a, c);
255 }
256 
257 #if 0	/* Cause a link error for bus_space_read_multi_8 */
258 #define	bus_space_read_multi_8		!!! unimplemented !!!
259 #endif
260 
261 static __inline void
262 bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
263     bus_size_t o, u_int8_t *a, size_t c)
264 {
265 	ins8(__ppc_ba(t, h, o), a, c);
266 }
267 
268 static __inline void
269 bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
270     bus_size_t o, u_int16_t *a, size_t c)
271 {
272 	ins16(__ppc_ba(t, h, o), a, c);
273 }
274 
275 static __inline void
276 bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
277     bus_size_t o, u_int32_t *a, size_t c)
278 {
279 	ins32(__ppc_ba(t, h, o), a, c);
280 }
281 
282 #if 0	/* Cause a link error for bus_space_read_multi_stream_8 */
283 #define	bus_space_read_multi_stream_8	!!! unimplemented !!!
284 #endif
285 
286 /*
287  *	void bus_space_read_region_N(bus_space_tag_t tag,
288  *	    bus_space_handle_t bsh, bus_size_t offset,
289  *	    u_intN_t *addr, size_t count));
290  *
291  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
292  * described by tag/handle and starting at `offset' and copy into
293  * buffer provided.
294  */
295 
296 static __inline void
297 bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
298     bus_size_t offset, u_int8_t *addr, size_t count)
299 {
300 	volatile u_int8_t *s = __ppc_ba(tag, bsh, offset);
301 
302 	while (count--)
303 		*addr++ = *s++;
304 	__asm __volatile("eieio; sync");
305 }
306 
307 static __inline void
308 bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
309     bus_size_t offset, u_int16_t *addr, size_t count)
310 {
311 	volatile u_int16_t *s = __ppc_ba(tag, bsh, offset);
312 
313 	while (count--)
314 		__asm __volatile("lhbrx %0, 0, %1" :
315 			"=r"(*addr++) : "r"(s++));
316 	__asm __volatile("eieio; sync");
317 }
318 
319 static __inline void
320 bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
321     bus_size_t offset, u_int32_t *addr, size_t count)
322 {
323 	volatile u_int32_t *s = __ppc_ba(tag, bsh, offset);
324 
325 	while (count--)
326 		__asm __volatile("lwbrx %0, 0, %1" :
327 			"=r"(*addr++) : "r"(s++));
328 	__asm __volatile("eieio; sync");
329 }
330 
331 #if 0	/* Cause a link error for bus_space_read_region_8 */
332 #define	bus_space_read_region_8		!!! unimplemented !!!
333 #endif
334 
335 static __inline void
336 bus_space_read_region_stream_2(bus_space_tag_t tag, bus_space_handle_t bsh,
337     bus_size_t offset, u_int16_t *addr, size_t count)
338 {
339 	volatile u_int16_t *s = __ppc_ba(tag, bsh, offset);
340 
341 	while (count--)
342 		*addr++ = *s++;
343 	__asm __volatile("eieio; sync");
344 }
345 
346 static __inline void
347 bus_space_read_region_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
348     bus_size_t offset, u_int32_t *addr, size_t count)
349 {
350 	volatile u_int32_t *s = __ppc_ba(tag, bsh, offset);
351 
352 	while (count--)
353 		*addr++ = *s++;
354 	__asm __volatile("eieio; sync");
355 }
356 
357 #if 0	/* Cause a link error */
358 #define	bus_space_read_region_stream_8		!!! unimplemented !!!
359 #endif
360 
361 /*
362  *	void bus_space_write_N(bus_space_tag_t tag,
363  *	    bus_space_handle_t bsh, bus_size_t offset,
364  *	    u_intN_t value));
365  *
366  * Write the 1, 2, 4, or 8 byte value `value' to bus space
367  * described by tag/handle/offset.
368  */
369 
370 static __inline void
371 bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
372     uint8_t v)
373 {
374 	out8(__ppc_ba(t, h, o), v);
375 }
376 
377 static __inline void
378 bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
379     uint16_t v)
380 {
381 	out16rb(__ppc_ba(t, h, o), v);
382 }
383 
384 static __inline void
385 bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
386     uint32_t v)
387 {
388 	out32rb(__ppc_ba(t, h, o), v);
389 }
390 
391 #if 0	/* Cause a link error for bus_space_write_8 */
392 #define bus_space_write_8		!!! unimplemented !!!
393 #endif
394 
395 static __inline void
396 bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
397     uint8_t v)
398 {
399 	out8(__ppc_ba(t, h, o), v);
400 }
401 
402 static __inline void
403 bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
404     uint16_t v)
405 {
406 	out16(__ppc_ba(t, h, o), v);
407 }
408 
409 static __inline void
410 bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
411     uint32_t v)
412 {
413 	out32(__ppc_ba(t, h, o), v);
414 }
415 
416 #if 0	/* Cause a link error for bus_space_write_stream_8 */
417 #define bus_space_write_stream_8       	!!! unimplemented !!!
418 #endif
419 
420 
421 /*
422  *	void bus_space_write_multi_N(bus_space_tag_t tag,
423  *	    bus_space_handle_t bsh, bus_size_t offset,
424  *	    const u_intN_t *addr, size_t count));
425  *
426  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
427  * provided to bus space described by tag/handle/offset.
428  */
429 
430 static __inline void
431 bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
432     uint8_t *a, size_t c)
433 {
434 	outsb(__ppc_ba(t, h, o), a, c);
435 }
436 
437 static __inline void
438 bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
439     uint16_t *a, size_t c)
440 {
441 	outsw(__ppc_ba(t, h, o), a, c);
442 }
443 
444 static __inline void
445 bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
446     uint32_t *a, size_t c)
447 {
448 	outsl(__ppc_ba(t, h, o), a, c);
449 }
450 
451 #if 0
452 #define bus_space_write_multi_8		!!! unimplemented !!!
453 #endif
454 
455 static __inline void
456 bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
457     bus_size_t o, const u_int8_t *a, size_t c)
458 {
459 	outsb(__ppc_ba(t, h, o), a, c);
460 }
461 
462 static __inline void
463 bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
464     bus_size_t o, const u_int16_t *a, size_t c)
465 {
466 	outsw(__ppc_ba(t, h, o), a, c);
467 }
468 
469 static __inline void
470 bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
471     bus_size_t o, const u_int32_t *a, size_t c)
472 {
473 	outsl(__ppc_ba(t, h, o), a, c);
474 }
475 
476 #if 0
477 #define bus_space_write_multi_stream_8	!!! unimplemented !!!
478 #endif
479 
480 /*
481  *	void bus_space_write_region_N(bus_space_tag_t tag,
482  *	    bus_space_handle_t bsh, bus_size_t offset,
483  *	    const u_intN_t *addr, size_t count));
484  *
485  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
486  * to bus space described by tag/handle starting at `offset'.
487  */
488 
489 static __inline void
490 bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
491     bus_size_t offset, const u_int8_t *addr, size_t count)
492 {
493 	volatile u_int8_t *d = __ppc_ba(tag, bsh, offset);
494 
495 	while (count--)
496 		*d++ = *addr++;
497 	__asm __volatile("eieio; sync");
498 }
499 
500 static __inline void
501 bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
502     bus_size_t offset, const u_int16_t *addr, size_t count)
503 {
504 	volatile u_int16_t *d = __ppc_ba(tag, bsh, offset);
505 
506 	while (count--)
507 		__asm __volatile("sthbrx %0, 0, %1" ::
508 			"r"(*addr++), "r"(d++));
509 	__asm __volatile("eieio; sync");
510 }
511 
512 static __inline void
513 bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
514     bus_size_t offset, const u_int32_t *addr, size_t count)
515 {
516 	volatile u_int32_t *d = __ppc_ba(tag, bsh, offset);
517 
518 	while (count--)
519 		__asm __volatile("stwbrx %0, 0, %1" ::
520 			"r"(*addr++), "r"(d++));
521 	__asm __volatile("eieio; sync");
522 }
523 
524 #if 0
525 #define	bus_space_write_region_8 !!! bus_space_write_region_8 unimplemented !!!
526 #endif
527 
528 static __inline void
529 bus_space_write_region_stream_2(bus_space_tag_t tag, bus_space_handle_t bsh,
530     bus_size_t offset, const u_int16_t *addr, size_t count)
531 {
532 	volatile u_int16_t *d = __ppc_ba(tag, bsh, offset);
533 
534 	while (count--)
535 		*d++ = *addr++;
536 	__asm __volatile("eieio; sync");
537 }
538 
539 static __inline void
540 bus_space_write_region_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
541     bus_size_t offset, const u_int32_t *addr, size_t count)
542 {
543 	volatile u_int32_t *d = __ppc_ba(tag, bsh, offset);
544 
545 	while (count--)
546 		*d++ = *addr++;
547 	__asm __volatile("eieio; sync");
548 }
549 
550 #if 0
551 #define	bus_space_write_region_stream_8	!!! unimplemented !!!
552 #endif
553 
554 /*
555  *	void bus_space_set_multi_N(bus_space_tag_t tag,
556  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
557  *	    size_t count));
558  *
559  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
560  * by tag/handle/offset `count' times.
561  */
562 
563 static __inline void
564 bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
565     bus_size_t offset, u_int8_t val, size_t count)
566 {
567 	volatile u_int8_t *d = __ppc_ba(tag, bsh, offset);
568 
569 	while (count--)
570 		*d = val;
571 	__asm __volatile("eieio; sync");
572 }
573 
574 static __inline void
575 bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
576     bus_size_t offset, u_int16_t val, size_t count)
577 {
578 	volatile u_int16_t *d = __ppc_ba(tag, bsh, offset);
579 
580 	while (count--)
581 		__asm __volatile("sthbrx %0, 0, %1" ::
582 			"r"(val), "r"(d));
583 	__asm __volatile("eieio; sync");
584 }
585 
586 static __inline void
587 bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
588     bus_size_t offset, u_int32_t val, size_t count)
589 {
590 	volatile u_int32_t *d = __ppc_ba(tag, bsh, offset);
591 
592 	while (count--)
593 		__asm __volatile("stwbrx %0, 0, %1" ::
594 			"r"(val), "r"(d));
595 	__asm __volatile("eieio; sync");
596 }
597 
598 #if 0
599 #define	bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
600 #endif
601 
602 static __inline void
603 bus_space_set_multi_stream_2(bus_space_tag_t tag, bus_space_handle_t bsh,
604     bus_size_t offset, u_int16_t val, size_t count)
605 {
606 	volatile u_int16_t *d = __ppc_ba(tag, bsh, offset);
607 
608 	while (count--)
609 		*d = val;
610 	__asm __volatile("eieio; sync");
611 }
612 
613 static __inline void
614 bus_space_set_multi_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
615     bus_size_t offset, u_int32_t val, size_t count)
616 {
617 	volatile u_int32_t *d = __ppc_ba(tag, bsh, offset);
618 
619 	while (count--)
620 		*d = val;
621 	__asm __volatile("eieio; sync");
622 }
623 
624 #if 0
625 #define	bus_space_set_multi_stream_8	!!! unimplemented !!!
626 #endif
627 
628 /*
629  *	void bus_space_set_region_N(bus_space_tag_t tag,
630  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
631  *	    size_t count));
632  *
633  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
634  * by tag/handle starting at `offset'.
635  */
636 
637 static __inline void
638 bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
639     bus_size_t offset, u_int8_t val, size_t count)
640 {
641 	volatile u_int8_t *d = __ppc_ba(tag, bsh, offset);
642 
643 	while (count--)
644 		*d++ = val;
645 	__asm __volatile("eieio; sync");
646 }
647 
648 static __inline void
649 bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
650     bus_size_t offset, u_int16_t val, size_t count)
651 {
652 	volatile u_int16_t *d = __ppc_ba(tag, bsh, offset);
653 
654 	while (count--)
655 		__asm __volatile("sthbrx %0, 0, %1" ::
656 			"r"(val), "r"(d++));
657 	__asm __volatile("eieio; sync");
658 }
659 
660 static __inline void
661 bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
662     bus_size_t offset, u_int32_t val, size_t count)
663 {
664 	volatile u_int32_t *d = __ppc_ba(tag, bsh, offset);
665 
666 	while (count--)
667 		__asm __volatile("stwbrx %0, 0, %1" ::
668 			"r"(val), "r"(d++));
669 	__asm __volatile("eieio; sync");
670 }
671 
672 #if 0
673 #define	bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
674 #endif
675 
676 static __inline void
677 bus_space_set_region_stream_2(bus_space_tag_t tag, bus_space_handle_t bsh,
678     bus_size_t offset, u_int16_t val, size_t count)
679 {
680 	volatile u_int16_t *d = __ppc_ba(tag, bsh, offset);
681 
682 	while (count--)
683 		*d++ = val;
684 	__asm __volatile("eieio; sync");
685 }
686 
687 static __inline void
688 bus_space_set_region_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
689     bus_size_t offset, u_int32_t val, size_t count)
690 {
691 	volatile u_int32_t *d = __ppc_ba(tag, bsh, offset);
692 
693 	while (count--)
694 		*d++ = val;
695 	__asm __volatile("eieio; sync");
696 }
697 
698 #if 0
699 #define	bus_space_set_region_stream_8	!!! unimplemented !!!
700 #endif
701 
702 /*
703  *	void bus_space_copy_region_N(bus_space_tag_t tag,
704  *	    bus_space_handle_t bsh1, bus_size_t off1,
705  *	    bus_space_handle_t bsh2, bus_size_t off2,
706  *	    size_t count));
707  *
708  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
709  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
710  */
711 
712 	/* XXX IMPLEMENT bus_space_copy_N() XXX */
713 
714 /*
715  * Bus read/write barrier methods.
716  *
717  *	void bus_space_barrier(bus_space_tag_t tag,
718  *	    bus_space_handle_t bsh, bus_size_t offset,
719  *	    bus_size_t len, int flags));
720  *
721  * Note: the macppc does not currently require barriers, but we must
722  * provide the flags to MI code.
723  */
724 
725 #define	BUS_SPACE_BARRIER_READ	0x01		/* force read barrier */
726 #define	BUS_SPACE_BARRIER_WRITE	0x02		/* force write barrier */
727 
728 static __inline void
729 bus_space_barrier(bus_space_tag_t tag __unused,
730     bus_space_handle_t bsh __unused, bus_size_t offset __unused,
731     bus_size_t len __unused, int flags __unused)
732 {
733 	__asm __volatile("" : : : "memory");
734 }
735 
736 
737 #define	BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
738 
739 #include <machine/bus_dma.h>
740 
741 #endif /* _MACPPC_BUS_H_ */
742