2 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
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.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
38 * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved.
39 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
40 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
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
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.
68 * from: NetBSD: bus.h,v 1.28 2001/07/19 15:32:19 thorpej Exp
70 * from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09
75 #ifndef _MACHINE_BUS_H_
76 #define _MACHINE_BUS_H_
78 #ifdef BUS_SPACE_DEBUG
82 #include <machine/_bus.h>
83 #include <machine/cpufunc.h>
84 #include <machine/upa.h>
87 * UPA and SBUS spaces are non-cached and big endian
88 * (except for RAM and PROM)
90 * PCI spaces are non-cached and little endian
92 #define UPA_BUS_SPACE 0
93 #define SBUS_BUS_SPACE 1
94 #define PCI_CONFIG_BUS_SPACE 2
95 #define PCI_IO_BUS_SPACE 3
96 #define PCI_MEMORY_BUS_SPACE 4
97 #define LAST_BUS_SPACE 5
99 extern int bus_type_asi[];
100 extern int bus_stream_asi[];
102 #define __BUS_SPACE_HAS_STREAM_METHODS 1
104 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
105 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
106 #define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFF
107 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
108 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
109 #define BUS_SPACE_MAXADDR 0xFFFFFFFF
111 #define BUS_SPACE_UNRESTRICTED (~0)
114 * Access methods for bus resources and address space.
116 typedef struct bus_space_tag *bus_space_tag_t;
118 struct bus_space_tag {
120 bus_space_tag_t bst_parent;
123 void (*bst_bus_barrier)(bus_space_tag_t, bus_space_handle_t,
124 bus_size_t, bus_size_t, int);
128 * Bus space function prototypes.
130 static void bus_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t,
132 static int bus_space_subregion(bus_space_tag_t, bus_space_handle_t,
133 bus_size_t, bus_size_t, bus_space_handle_t *);
136 * Map a region of device bus space into CPU virtual address space.
139 static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
140 bus_size_t size, int flags,
141 bus_space_handle_t *bshp);
144 bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
145 bus_size_t size __unused, int flags __unused,
146 bus_space_handle_t *bshp)
154 * Unmap a region of device bus space.
156 static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
160 bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
161 bus_size_t size __unused)
165 /* This macro finds the first "upstream" implementation of method `f' */
166 #define _BS_CALL(t,f) \
167 while (t->f == NULL) \
172 bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
175 _BS_CALL(t, bst_bus_barrier)(t, h, o, s, f);
179 bus_space_subregion(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
180 bus_size_t s, bus_space_handle_t *hp)
186 /* flags for bus space map functions */
187 #define BUS_SPACE_MAP_CACHEABLE 0x0001
188 #define BUS_SPACE_MAP_LINEAR 0x0002
189 #define BUS_SPACE_MAP_READONLY 0x0004
190 #define BUS_SPACE_MAP_PREFETCHABLE 0x0008
191 /* placeholders for bus functions... */
192 #define BUS_SPACE_MAP_BUS1 0x0100
193 #define BUS_SPACE_MAP_BUS2 0x0200
194 #define BUS_SPACE_MAP_BUS3 0x0400
195 #define BUS_SPACE_MAP_BUS4 0x0800
197 /* flags for bus_space_barrier() */
198 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
199 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
201 #ifdef BUS_SPACE_DEBUG
202 #define KTR_BUS KTR_CT2
203 #define BUS_HANDLE_MIN UPA_MEMSTART
204 #define __BUS_DEBUG_ACCESS(h, o, desc, sz) do { \
205 CTR4(KTR_BUS, "bus space: %s %d: handle %#lx, offset %#lx", \
206 (desc), (sz), (h), (o)); \
207 if ((h) + (o) < BUS_HANDLE_MIN) \
208 panic("bus space access at %#lx out of range", \
212 #define __BUS_DEBUG_ACCESS(h, o, desc, sz)
215 static __inline uint8_t
216 bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
219 __BUS_DEBUG_ACCESS(h, o, "read", 1);
220 return (lduba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
223 static __inline uint16_t
224 bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
227 __BUS_DEBUG_ACCESS(h, o, "read", 2);
228 return (lduha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
231 static __inline uint32_t
232 bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
235 __BUS_DEBUG_ACCESS(h, o, "read", 4);
236 return (lduwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
239 static __inline uint64_t
240 bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
243 __BUS_DEBUG_ACCESS(h, o, "read", 8);
244 return (ldxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type]));
248 bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
249 uint8_t *a, size_t c)
253 *a++ = bus_space_read_1(t, h, o);
257 bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
258 uint16_t *a, size_t c)
262 *a++ = bus_space_read_2(t, h, o);
266 bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
267 uint32_t *a, size_t c)
271 *a++ = bus_space_read_4(t, h, o);
275 bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
276 uint64_t *a, size_t c)
280 *a++ = bus_space_read_8(t, h, o);
284 bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
288 __BUS_DEBUG_ACCESS(h, o, "write", 1);
289 stba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
293 bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
297 __BUS_DEBUG_ACCESS(h, o, "write", 2);
298 stha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
302 bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
306 __BUS_DEBUG_ACCESS(h, o, "write", 4);
307 stwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
311 bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
315 __BUS_DEBUG_ACCESS(h, o, "write", 8);
316 stxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v);
320 bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
321 uint8_t *a, size_t c)
325 bus_space_write_1(t, h, o, *a++);
329 bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
330 uint16_t *a, size_t c)
334 bus_space_write_2(t, h, o, *a++);
338 bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
339 uint32_t *a, size_t c)
343 bus_space_write_4(t, h, o, *a++);
347 bus_space_write_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
348 uint64_t *a, size_t c)
352 bus_space_write_8(t, h, o, *a++);
356 bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
361 bus_space_write_1(t, h, o, v);
365 bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
366 uint16_t v, size_t c)
370 bus_space_write_2(t, h, o, v);
374 bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
375 uint32_t v, size_t c)
379 bus_space_write_4(t, h, o, v);
383 bus_space_set_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
384 uint64_t v, size_t c)
388 bus_space_write_8(t, h, o, v);
392 bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
393 u_int8_t *a, bus_size_t c)
395 for (; c; a++, c--, o++)
396 *a = bus_space_read_1(t, h, o);
400 bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
401 u_int16_t *a, bus_size_t c)
403 for (; c; a++, c--, o+=2)
404 *a = bus_space_read_2(t, h, o);
408 bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
409 u_int32_t *a, bus_size_t c)
411 for (; c; a++, c--, o+=4)
412 *a = bus_space_read_4(t, h, o);
416 bus_space_read_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
417 u_int64_t *a, bus_size_t c)
419 for (; c; a++, c--, o+=8)
420 *a = bus_space_read_8(t, h, o);
424 bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
425 const u_int8_t *a, bus_size_t c)
427 for (; c; a++, c--, o++)
428 bus_space_write_1(t, h, o, *a);
432 bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
433 const u_int16_t *a, bus_size_t c)
435 for (; c; a++, c--, o+=2)
436 bus_space_write_2(t, h, o, *a);
440 bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
441 const u_int32_t *a, bus_size_t c)
443 for (; c; a++, c--, o+=4)
444 bus_space_write_4(t, h, o, *a);
448 bus_space_write_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
449 const u_int64_t *a, bus_size_t c)
451 for (; c; a++, c--, o+=8)
452 bus_space_write_8(t, h, o, *a);
456 bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
457 const u_int8_t v, bus_size_t c)
460 bus_space_write_1(t, h, o, v);
464 bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
465 const u_int16_t v, bus_size_t c)
468 bus_space_write_2(t, h, o, v);
472 bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
473 const u_int32_t v, bus_size_t c)
476 bus_space_write_4(t, h, o, v);
480 bus_space_set_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
481 const u_int64_t v, bus_size_t c)
484 bus_space_write_8(t, h, o, v);
488 bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1,
489 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
491 for (; c; c--, o1++, o2++)
492 bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
496 bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1,
497 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
499 for (; c; c--, o1+=2, o2+=2)
500 bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
504 bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1,
505 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
507 for (; c; c--, o1+=4, o2+=4)
508 bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
512 bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1,
513 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
515 for (; c; c--, o1+=8, o2+=8)
516 bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
519 static __inline uint8_t
520 bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
523 __BUS_DEBUG_ACCESS(h, o, "read stream", 1);
524 return (lduba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
527 static __inline uint16_t
528 bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
531 __BUS_DEBUG_ACCESS(h, o, "read stream", 2);
532 return (lduha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
535 static __inline uint32_t
536 bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
539 __BUS_DEBUG_ACCESS(h, o, "read stream", 4);
540 return (lduwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
543 static __inline uint64_t
544 bus_space_read_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
547 __BUS_DEBUG_ACCESS(h, o, "read stream", 8);
548 return (ldxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type]));
552 bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
553 bus_size_t o, uint8_t *a, size_t c)
557 *a++ = bus_space_read_stream_1(t, h, o);
561 bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
562 bus_size_t o, uint16_t *a, size_t c)
566 *a++ = bus_space_read_stream_2(t, h, o);
570 bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
571 bus_size_t o, uint32_t *a, size_t c)
575 *a++ = bus_space_read_stream_4(t, h, o);
579 bus_space_read_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
580 bus_size_t o, uint64_t *a, size_t c)
584 *a++ = bus_space_read_stream_8(t, h, o);
588 bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
592 __BUS_DEBUG_ACCESS(h, o, "write stream", 1);
593 stba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
597 bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
601 __BUS_DEBUG_ACCESS(h, o, "write stream", 2);
602 stha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
606 bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
610 __BUS_DEBUG_ACCESS(h, o, "write stream", 4);
611 stwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
615 bus_space_write_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
619 __BUS_DEBUG_ACCESS(h, o, "write stream", 8);
620 stxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v);
624 bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
625 bus_size_t o, const uint8_t *a, size_t c)
629 bus_space_write_stream_1(t, h, o, *a++);
633 bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
634 bus_size_t o, const uint16_t *a, size_t c)
638 bus_space_write_stream_2(t, h, o, *a++);
642 bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
643 bus_size_t o, const uint32_t *a, size_t c)
647 bus_space_write_stream_4(t, h, o, *a++);
651 bus_space_write_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
652 bus_size_t o, const uint64_t *a, size_t c)
656 bus_space_write_stream_8(t, h, o, *a++);
660 bus_space_set_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h,
661 bus_size_t o, uint8_t v, size_t c)
665 bus_space_write_stream_1(t, h, o, v);
669 bus_space_set_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h,
670 bus_size_t o, uint16_t v, size_t c)
674 bus_space_write_stream_2(t, h, o, v);
678 bus_space_set_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h,
679 bus_size_t o, uint32_t v, size_t c)
683 bus_space_write_stream_4(t, h, o, v);
687 bus_space_set_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h,
688 bus_size_t o, uint64_t v, size_t c)
692 bus_space_write_stream_8(t, h, o, v);
696 bus_space_read_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
697 bus_size_t o, u_int8_t *a, bus_size_t c)
699 for (; c; a++, c--, o++)
700 *a = bus_space_read_stream_1(t, h, o);
704 bus_space_read_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
705 bus_size_t o, u_int16_t *a, bus_size_t c)
707 for (; c; a++, c--, o+=2)
708 *a = bus_space_read_stream_2(t, h, o);
712 bus_space_read_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
713 bus_size_t o, u_int32_t *a, bus_size_t c)
715 for (; c; a++, c--, o+=4)
716 *a = bus_space_read_stream_4(t, h, o);
720 bus_space_read_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
721 bus_size_t o, u_int64_t *a, bus_size_t c)
723 for (; c; a++, c--, o+=8)
724 *a = bus_space_read_stream_8(t, h, o);
728 bus_space_write_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
729 bus_size_t o, const u_int8_t *a, bus_size_t c)
731 for (; c; a++, c--, o++)
732 bus_space_write_stream_1(t, h, o, *a);
736 bus_space_write_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
737 bus_size_t o, const u_int16_t *a, bus_size_t c)
739 for (; c; a++, c--, o+=2)
740 bus_space_write_stream_2(t, h, o, *a);
744 bus_space_write_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
745 bus_size_t o, const u_int32_t *a, bus_size_t c)
747 for (; c; a++, c--, o+=4)
748 bus_space_write_stream_4(t, h, o, *a);
752 bus_space_write_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
753 bus_size_t o, const u_int64_t *a, bus_size_t c)
755 for (; c; a++, c--, o+=8)
756 bus_space_write_stream_8(t, h, o, *a);
760 bus_space_set_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
761 bus_size_t o, const u_int8_t v, bus_size_t c)
764 bus_space_write_stream_1(t, h, o, v);
768 bus_space_set_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
769 bus_size_t o, const u_int16_t v, bus_size_t c)
772 bus_space_write_stream_2(t, h, o, v);
776 bus_space_set_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
777 bus_size_t o, const u_int32_t v, bus_size_t c)
780 bus_space_write_stream_4(t, h, o, v);
784 bus_space_set_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
785 bus_size_t o, const u_int64_t v, bus_size_t c)
788 bus_space_write_stream_8(t, h, o, v);
792 bus_space_copy_region_stream_1(bus_space_tag_t t, bus_space_handle_t h1,
793 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
795 for (; c; c--, o1++, o2++)
796 bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2,
801 bus_space_copy_region_stream_2(bus_space_tag_t t, bus_space_handle_t h1,
802 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
804 for (; c; c--, o1+=2, o2+=2)
805 bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2,
810 bus_space_copy_region_stream_4(bus_space_tag_t t, bus_space_handle_t h1,
811 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
813 for (; c; c--, o1+=4, o2+=4)
814 bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2,
819 bus_space_copy_region_stream_8(bus_space_tag_t t, bus_space_handle_t h1,
820 bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
822 for (; c; c--, o1+=8, o2+=8)
823 bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2));
827 bus_space_peek_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
831 __BUS_DEBUG_ACCESS(h, o, "peek", 1);
832 return (fasword8(bus_type_asi[t->bst_type], (caddr_t)(h + o), a));
836 bus_space_peek_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
840 __BUS_DEBUG_ACCESS(h, o, "peek", 2);
841 return (fasword16(bus_type_asi[t->bst_type], (caddr_t)(h + o), a));
845 bus_space_peek_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
849 __BUS_DEBUG_ACCESS(h, o, "peek", 4);
850 return (fasword32(bus_type_asi[t->bst_type], (caddr_t)(h + o), a));
853 /* Back-compat functions for old ISA drivers */
854 extern bus_space_tag_t isa_io_bt;
855 extern bus_space_handle_t isa_io_hdl;
856 extern bus_space_tag_t isa_mem_bt;
857 extern bus_space_handle_t isa_mem_hdl;
859 #define inb(o) bus_space_read_1(isa_io_bt, isa_io_hdl, o)
860 #define inw(o) bus_space_read_2(isa_io_bt, isa_io_hdl, o)
861 #define inl(o) bus_space_read_4(isa_io_bt, isa_io_hdl, o)
862 #define outb(o, v) bus_space_write_1(isa_io_bt, isa_io_hdl, o, v)
863 #define outw(o, v) bus_space_write_2(isa_io_bt, isa_io_hdl, o, v)
864 #define outl(o, v) bus_space_write_4(isa_io_bt, isa_io_hdl, o, v)
866 #define readb(o) bus_space_read_1(isa_mem_bt, isa_mem_hdl, o)
867 #define readw(o) bus_space_read_2(isa_mem_bt, isa_mem_hdl, o)
868 #define readl(o) bus_space_read_4(isa_mem_bt, isa_mem_hdl, o)
869 #define writeb(o, v) bus_space_write_1(isa_mem_bt, isa_mem_hdl, o, v)
870 #define writew(o, v) bus_space_write_2(isa_mem_bt, isa_mem_hdl, o, v)
871 #define writel(o, v) bus_space_write_4(isa_mem_bt, isa_mem_hdl, o, v)
873 #define insb(o, a, c) \
874 bus_space_read_multi_1(isa_io_bt, isa_io_hdl, o, (void*)a, c)
875 #define insw(o, a, c) \
876 bus_space_read_multi_2(isa_io_bt, isa_io_hdl, o, (void*)a, c)
877 #define insl(o, a, c) \
878 bus_space_read_multi_4(isa_io_bt, isa_io_hdl, o, (void*)a, c)
879 #define outsb(o, a, c) \
880 bus_space_write_multi_1(isa_io_bt, isa_io_hdl, o, (void*)a, c)
881 #define outsw(o, a, c) \
882 bus_space_write_multi_2(isa_io_bt, isa_io_hdl, o, (void*)a, c)
883 #define outsl(o, a, c) \
884 bus_space_write_multi_4(isa_io_bt, isa_io_hdl, o, (void*)a, c)
886 #define memcpy_fromio(d, s, c) \
887 bus_space_read_region_1(isa_mem_bt, isa_mem_hdl, s, d, c)
888 #define memcpy_toio(d, s, c) \
889 bus_space_write_region_1(isa_mem_bt, isa_mem_hdl, d, s, c)
890 #define memcpy_io(d, s, c) \
891 bus_space_copy_region_1(isa_mem_bt, isa_mem_hdl, s, isa_mem_hdl, d, c)
892 #define memset_io(d, v, c) \
893 bus_space_set_region_1(isa_mem_bt, isa_mem_hdl, d, v, c)
894 #define memsetw_io(d, v, c) \
895 bus_space_set_region_2(isa_mem_bt, isa_mem_hdl, d, v, c)
898 memsetw(void *d, int val, size_t size)
906 #include <machine/bus_dma.h>
908 #endif /* !_MACHINE_BUS_H_ */