tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

switching to <sys/bus.h>: the non-trivial patches



For review, here are the remainder of the patches that switch
the architectures with PCI support from <machine/bus.h> to a
common <sys/bus.h> that includes MD <machine/bus_defs.h> and
<machine/bus_funcs.h>.

Please review, test, comment.  Thanks.

The bulk of this patch moves tons of inline bus_space(9) routines to
appropriate .c files where they are not any longer inline.  The changes
to PowerPC involving BUS_DMA_DONTCACHE need to be reviewed.

I have not included in the patch the changes to umpteen
<machine/types.h>'s that #define __HAVE_NEW_STYLE_BUS_H, or the deletion
of umpteen <machine/bus.h>'s.

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 344-0444 x24
Index: distrib/sets/lists/comp/md.alpha
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/comp/md.alpha,v
retrieving revision 1.57
diff -u -p -r1.57 md.alpha
--- distrib/sets/lists/comp/md.alpha    11 May 2010 06:20:00 -0000      1.57
+++ distrib/sets/lists/comp/md.alpha    6 Jul 2011 20:42:39 -0000
@@ -8,7 +8,8 @@
 ./usr/include/alpha/atomic.h                   comp-obsolete           obsolete
 ./usr/include/alpha/autoconf.h                 comp-c-include
 ./usr/include/alpha/bswap.h                    comp-c-include
-./usr/include/alpha/bus.h                      comp-c-include
+./usr/include/alpha/bus.h                      comp-c-include          obsolete
+./usr/include/alpha/bus_defs.h                 comp-c-include
 ./usr/include/alpha/bwx.h                      comp-c-include
 ./usr/include/alpha/cdefs.h                    comp-c-include
 ./usr/include/alpha/cfbreg.h                   comp-c-include
Index: distrib/sets/lists/comp/md.sparc
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/comp/md.sparc,v
retrieving revision 1.73
diff -u -p -r1.73 md.sparc
--- distrib/sets/lists/comp/md.sparc    20 May 2011 21:42:48 -0000      1.73
+++ distrib/sets/lists/comp/md.sparc    6 Jul 2011 20:42:39 -0000
@@ -72,7 +72,7 @@
 ./usr/include/sparc64/autoconf.h               comp-c-include
 ./usr/include/sparc64/bsd_openprom.h           comp-c-include
 ./usr/include/sparc64/bswap.h                  comp-c-include
-./usr/include/sparc64/bus.h                    comp-c-include
+./usr/include/sparc64/bus.h                    comp-obsolete           obsolete
 ./usr/include/sparc64/cdefs.h                  comp-c-include
 ./usr/include/sparc64/cgtworeg.h               comp-c-include
 ./usr/include/sparc64/conf.h                   comp-obsolete           obsolete
Index: distrib/sets/lists/comp/md.sparc64
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/comp/md.sparc64,v
retrieving revision 1.106
diff -u -p -r1.106 md.sparc64
--- distrib/sets/lists/comp/md.sparc64  3 Jul 2011 22:47:25 -0000       1.106
+++ distrib/sets/lists/comp/md.sparc64  6 Jul 2011 20:42:39 -0000
@@ -72,7 +72,7 @@
 ./usr/include/sparc64/autoconf.h               comp-c-include
 ./usr/include/sparc64/bsd_openprom.h           comp-c-include
 ./usr/include/sparc64/bswap.h                  comp-c-include
-./usr/include/sparc64/bus.h                    comp-c-include
+./usr/include/sparc64/bus.h                    comp-obsolete           obsolete
 ./usr/include/sparc64/cdefs.h                  comp-c-include
 ./usr/include/sparc64/cgtworeg.h               comp-c-include
 ./usr/include/sparc64/conf.h                   comp-obsolete           obsolete
Index: sys/arch/alpha/include/Makefile
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/include/Makefile,v
retrieving revision 1.29
diff -u -p -r1.29 Makefile
--- sys/arch/alpha/include/Makefile     10 Mar 2008 14:01:35 -0000      1.29
+++ sys/arch/alpha/include/Makefile     6 Jul 2011 20:42:39 -0000
@@ -3,7 +3,7 @@
 INCSDIR= /usr/include/alpha
 
 INCS=  alpha_cpu.h ansi.h aout_machdep.h asm.h autoconf.h \
-       bswap.h bus.h bwx.h \
+       bus_defs.h bswap.h bwx.h \
        cdefs.h cfbreg.h cpu.h cpuconf.h \
        disklabel.h \
        ecoff_machdep.h elf_machdep.h endian.h endian_machdep.h \
Index: sys/arch/alpha/include/pio.h
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/include/pio.h,v
retrieving revision 1.7
diff -u -p -r1.7 pio.h
--- sys/arch/alpha/include/pio.h        28 Apr 2008 20:23:11 -0000      1.7
+++ sys/arch/alpha/include/pio.h        6 Jul 2011 20:42:39 -0000
@@ -33,7 +33,7 @@
 #define        _ALPHA_PIO_H_
 
 #include <sys/cdefs.h>
-#include <machine/bus.h>
+#include <machine/bus_defs.h>
 
 #ifdef _KERNEL
 #error This file is for userspace only.
Index: sys/arch/alpha/include/sysarch.h
===================================================================
RCS file: /cvsroot/src/sys/arch/alpha/include/sysarch.h,v
retrieving revision 1.13
diff -u -p -r1.13 sysarch.h
--- sys/arch/alpha/include/sysarch.h    28 Apr 2008 20:23:11 -0000      1.13
+++ sys/arch/alpha/include/sysarch.h    6 Jul 2011 20:42:39 -0000
@@ -32,7 +32,7 @@
 #ifndef _ALPHA_SYSARCH_H_
 #define _ALPHA_SYSARCH_H_
 
-#include <machine/bus.h>
+#include <machine/bus_defs.h>
 #include <machine/ieeefp.h>
 
 /*
Index: sys/arch/arc/arc/bus_space.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/bus_space.c,v
retrieving revision 1.10
diff -u -p -r1.10 bus_space.c
--- sys/arch/arc/arc/bus_space.c        28 Apr 2008 20:23:13 -0000      1.10
+++ sys/arch/arc/arc/bus_space.c        6 Jul 2011 20:42:39 -0000
@@ -41,7 +41,274 @@ __KERNEL_RCSID(0, "$NetBSD: bus_space.c,
 
 #include <uvm/uvm_extern.h>
 
-#include <machine/bus.h>
+#include <sys/bus.h>
+
+/*
+ *     uintN_t bus_space_read_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset);
+ *
+ * Read a 1, 2, 4, or 8 byte quantity from bus space
+ * described by tag/handle/offset.
+ */
+
+#define bus_space_read(BYTES,BITS)                                     \
+__CONCAT3(uint,BITS,_t)                                        \
+__CONCAT(bus_space_read_,BYTES)(bus_space_tag_t bst,                   \
+    bus_space_handle_t bsh, bus_size_t offset)                         \
+{                                                                      \
+       return (*(volatile __CONCAT3(uint,BITS,_t) *)                   \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES))));       \
+}
+
+bus_space_read(1,8)
+bus_space_read(2,16)
+bus_space_read(4,32)
+bus_space_read(8,64)
+
+/*
+ *     void bus_space_read_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t *addr, size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+
+#define bus_space_read_multi(BYTES,BITS)                               \
+void                                                   \
+__CONCAT(bus_space_read_multi_,BYTES)(bus_space_tag_t bst,             \
+    bus_space_handle_t bsh, bus_size_t offset,                         \
+    __CONCAT3(uint,BITS,_t) *datap, bus_size_t count)                  \
+{                                                                      \
+       volatile __CONCAT3(uint,BITS,_t) *p =                           \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES)));        \
+                                                                       \
+       for (; count > 0; --count)                                      \
+               *datap++ = *p;                                          \
+}
+
+bus_space_read_multi(1,8)
+bus_space_read_multi(2,16)
+bus_space_read_multi(4,32)
+bus_space_read_multi(8,64)
+
+/*
+ *     void bus_space_read_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t *addr, size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle and starting at `offset' and copy into
+ * buffer provided.
+ */
+
+#define bus_space_read_region(BYTES,BITS)                              \
+void                                                   \
+__CONCAT(bus_space_read_region_,BYTES)(bus_space_tag_t bst,            \
+    bus_space_handle_t bsh, bus_size_t offset,                         \
+    __CONCAT3(uint,BITS,_t) *datap, bus_size_t count)                  \
+{                                                                      \
+       int stride = 1 << __CONCAT(bst->bs_stride_,BYTES);              \
+       volatile __CONCAT3(uint,BITS,_t) *p =                           \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES)));        \
+                                                                       \
+       for (; count > 0; --count) {                                    \
+               *datap++ = *p;                                          \
+               p += stride;                                            \
+       }                                                               \
+}
+
+bus_space_read_region(1,8)
+bus_space_read_region(2,16)
+bus_space_read_region(4,32)
+bus_space_read_region(8,64)
+
+/*
+ *     void bus_space_write_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t value);
+ *
+ * Write the 1, 2, 4, or 8 byte value `value' to bus space
+ * described by tag/handle/offset.
+ */
+
+#define bus_space_write(BYTES,BITS)                                    \
+void                                                   \
+__CONCAT(bus_space_write_,BYTES)(bus_space_tag_t bst,                  \
+    bus_space_handle_t bsh,                                            \
+    bus_size_t offset, __CONCAT3(uint,BITS,_t) data)                   \
+{                                                                      \
+       *(volatile __CONCAT3(uint,BITS,_t) *)                           \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES))) = data; \
+}
+
+bus_space_write(1,8)
+bus_space_write(2,16)
+bus_space_write(4,32)
+bus_space_write(8,64)
+
+/*
+ *     void bus_space_write_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const uintN_t *addr, size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
+ * provided to bus space described by tag/handle/offset.
+ */
+
+#define bus_space_write_multi(BYTES,BITS)                              \
+void                                                   \
+__CONCAT(bus_space_write_multi_,BYTES)(bus_space_tag_t bst,            \
+    bus_space_handle_t bsh, bus_size_t offset,                         \
+    const __CONCAT3(uint,BITS,_t) *datap, bus_size_t count)            \
+{                                                                      \
+       volatile __CONCAT3(uint,BITS,_t) *p =                           \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES)));        \
+                                                                       \
+       for (; count > 0; --count)                                      \
+               *p = *datap++;                                          \
+}
+
+bus_space_write_multi(1,8)
+bus_space_write_multi(2,16)
+bus_space_write_multi(4,32)
+bus_space_write_multi(8,64)
+
+/*
+ *     void bus_space_write_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const uintN_t *addr, size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
+ * to bus space described by tag/handle starting at `offset'.
+ */
+
+#define bus_space_write_region(BYTES,BITS)                             \
+void                                                   \
+__CONCAT(bus_space_write_region_,BYTES)(bus_space_tag_t bst,           \
+    bus_space_handle_t bsh, bus_size_t offset,                         \
+    const __CONCAT3(uint,BITS,_t) *datap, bus_size_t count)            \
+{                                                                      \
+       int stride = 1 << __CONCAT(bst->bs_stride_,BYTES);              \
+       volatile __CONCAT3(uint,BITS,_t) *p =                           \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES)));        \
+                                                                       \
+       for (; count > 0; --count) {                                    \
+               *p = *datap++;                                          \
+               p += stride;                                            \
+       }                                                               \
+}
+
+bus_space_write_region(1,8)
+bus_space_write_region(2,16)
+bus_space_write_region(4,32)
+bus_space_write_region(8,64)
+
+/*
+ *     void bus_space_set_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
+ *         size_t count);
+ *
+ * Write the 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle/offset `count' times.
+ */
+
+#define bus_space_set_multi(BYTES,BITS)                                        
\
+void                                                   \
+__CONCAT(bus_space_set_multi_,BYTES)(bus_space_tag_t bst,              \
+    bus_space_handle_t bsh, bus_size_t offset,                         \
+    const __CONCAT3(uint,BITS,_t) data, bus_size_t count)              \
+{                                                                      \
+       volatile __CONCAT3(uint,BITS,_t) *p =                           \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES)));        \
+                                                                       \
+       for (; count > 0; --count)                                      \
+               *p = data;                                              \
+}
+
+bus_space_set_multi(1,8)
+bus_space_set_multi(2,16)
+bus_space_set_multi(4,32)
+bus_space_set_multi(8,64)
+
+/*
+ *     void bus_space_set_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
+ *         size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle starting at `offset'.
+ */
+
+#define bus_space_set_region(BYTES,BITS)                               \
+void                                                   \
+__CONCAT(bus_space_set_region_,BYTES)(bus_space_tag_t bst,             \
+    bus_space_handle_t bsh, bus_size_t offset,                         \
+    __CONCAT3(uint,BITS,_t) data, bus_size_t count)                    \
+{                                                                      \
+       int stride = 1 << __CONCAT(bst->bs_stride_,BYTES);              \
+       volatile __CONCAT3(uint,BITS,_t) *p =                           \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (bsh + (offset << __CONCAT(bst->bs_stride_,BYTES)));        \
+                                                                       \
+       for (; count > 0; --count) {                                    \
+               *p = data;                                              \
+               p += stride;                                            \
+       }                                                               \
+}
+
+bus_space_set_region(1,8)
+bus_space_set_region(2,16)
+bus_space_set_region(4,32)
+bus_space_set_region(8,64)
+
+/*
+ *     void bus_space_copy_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+
+#define bus_space_copy_region(BYTES,BITS)                              \
+void                                                   \
+__CONCAT(bus_space_copy_region_,BYTES)(bus_space_tag_t bst,            \
+    bus_space_handle_t srcbsh, bus_size_t srcoffset,                   \
+    bus_space_handle_t dstbsh, bus_size_t dstoffset, bus_size_t count) \
+{                                                                      \
+       int stride = 1 << __CONCAT(bst->bs_stride_,BYTES);              \
+       volatile __CONCAT3(uint,BITS,_t) *srcp =                        \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (srcbsh + (srcoffset << __CONCAT(bst->bs_stride_,BYTES)));  \
+       volatile __CONCAT3(uint,BITS,_t) *dstp =                        \
+           (volatile __CONCAT3(uint,BITS,_t) *)                        \
+           (dstbsh + (dstoffset << __CONCAT(bst->bs_stride_,BYTES)));  \
+       bus_size_t offset;                                              \
+                                                                       \
+       if (srcp >= dstp) {                                             \
+               /* src after dest: copy forward */                      \
+               for (offset = 0; count > 0; --count, offset += stride)  \
+                       dstp[offset] = srcp[offset];                    \
+       } else {                                                        \
+               /* dest after src: copy backward */                     \
+               offset = (count << __CONCAT(bst->bs_stride_,BYTES))     \
+                   - stride;                                           \
+               for (; count > 0; --count, offset -= stride)            \
+                       dstp[offset] = srcp[offset];                    \
+       }                                                               \
+}
+
+bus_space_copy_region(1,8)
+bus_space_copy_region(2,16)
+bus_space_copy_region(4,32)
+bus_space_copy_region(8,64)
 
 void
 arc_bus_space_init(bus_space_tag_t bst, const char *name, paddr_t paddr,
Index: sys/arch/cobalt/cobalt/bus.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/bus.c,v
retrieving revision 1.40
diff -u -p -r1.40 bus.c
--- sys/arch/cobalt/cobalt/bus.c        3 May 2011 09:15:20 -0000       1.40
+++ sys/arch/cobalt/cobalt/bus.c        6 Jul 2011 20:42:41 -0000
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.40
 #include <sys/mbuf.h>
 
 #define _COBALT_BUS_DMA_PRIVATE
-#include <machine/bus.h>
+#include <sys/bus.h>
 
 #include <common/bus_dma/bus_dmamem_common.h>
 
@@ -50,6 +50,12 @@ __KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.40
 
 #include <mips/cache.h>
 
+/*
+ * Utility macros; do not use outside this file.
+ */
+#define        __PB_TYPENAME_PREFIX(BITS)      ___CONCAT(uint,BITS)
+#define        __PB_TYPENAME(BITS)             
___CONCAT(__PB_TYPENAME_PREFIX(BITS),_t)
+
 static int     _bus_dmamap_load_buffer(bus_dmamap_t, void *, bus_size_t,
                                struct vmspace *, int, vaddr_t *, int *, int);
 
@@ -69,6 +75,288 @@ struct cobalt_bus_dma_tag cobalt_default
        _bus_dmamem_mmap,
 };
 
+/*
+ *     void bus_space_read_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+
+#define __COBALT_bus_space_read_multi(BYTES,BITS)                              
\
+void __CONCAT(bus_space_read_multi_,BYTES)             \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS) *, bus_size_t);                                     
\
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_read_multi_,BYTES)(t, h, o, a, c)                   \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) *a;                                         \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o);        \
+}
+
+__COBALT_bus_space_read_multi(1,8)
+__COBALT_bus_space_read_multi(2,16)
+__COBALT_bus_space_read_multi(4,32)
+
+#if 0  /* Cause a link error for bus_space_read_multi_8 */
+#define        bus_space_read_multi_8  !!! bus_space_read_multi_8 
unimplemented !!!
+#endif
+
+#undef __COBALT_bus_space_read_multi
+
+/*
+ *     void bus_space_read_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle and starting at `offset' and copy into
+ * buffer provided.
+ */
+
+#define __COBALT_bus_space_read_region(BYTES,BITS)                     \
+void __CONCAT(bus_space_read_region_,BYTES)            \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS) *, bus_size_t);                                     
\
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_read_region_,BYTES)(t, h, o, a, c)                  \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) *a;                                         \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o);        \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__COBALT_bus_space_read_region(1,8)
+__COBALT_bus_space_read_region(2,16)
+__COBALT_bus_space_read_region(4,32)
+
+#if 0  /* Cause a link error for bus_space_read_region_8 */
+#define        bus_space_read_region_8 !!! bus_space_read_region_8 
unimplemented !!!
+#endif
+
+#undef __COBALT_bus_space_read_region
+
+/*
+ *     void bus_space_write_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const uintN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
+ * provided to bus space described by tag/handle/offset.
+ */
+
+#define __COBALT_bus_space_write_multi(BYTES,BITS)                     \
+void __CONCAT(bus_space_write_multi_,BYTES)            \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       const __PB_TYPENAME(BITS) *, bus_size_t);                               
\
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_write_multi_,BYTES)(t, h, o, a, c)                  \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       const __PB_TYPENAME(BITS) *a;                                   \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++);        \
+}
+
+__COBALT_bus_space_write_multi(1,8)
+__COBALT_bus_space_write_multi(2,16)
+__COBALT_bus_space_write_multi(4,32)
+
+#if 0  /* Cause a link error for bus_space_write_8 */
+#define        bus_space_write_multi_8(t, h, o, a, c)                          
\
+                       !!! bus_space_write_multi_8 unimplimented !!!
+#endif
+
+#undef __COBALT_bus_space_write_multi
+
+/*
+ *     void bus_space_write_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const uintN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
+ * to bus space described by tag/handle starting at `offset'.
+ */
+
+#define __COBALT_bus_space_write_region(BYTES,BITS)                    \
+void __CONCAT(bus_space_write_region_,BYTES)           \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       const __PB_TYPENAME(BITS) *, bus_size_t);                               
\
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_write_region_,BYTES)(t, h, o, a, c)                 \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       const __PB_TYPENAME(BITS) *a;                                   \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++);        \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__COBALT_bus_space_write_region(1,8)
+__COBALT_bus_space_write_region(2,16)
+__COBALT_bus_space_write_region(4,32)
+
+#if 0  /* Cause a link error for bus_space_write_region_8 */
+#define        bus_space_write_region_8                                        
\
+                       !!! bus_space_write_region_8 unimplemented !!!
+#endif
+
+#undef __COBALT_bus_space_write_region
+
+/*
+ *     void bus_space_set_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
+ *         bus_size_t count);
+ *
+ * Write the 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle/offset `count' times.
+ */
+
+#define __COBALT_bus_space_set_multi(BYTES,BITS)                               
\
+void __CONCAT(bus_space_set_multi_,BYTES)              \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS), bus_size_t);                                       
\
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_set_multi_,BYTES)(t, h, o, v, c)                    \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) v;                                          \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, v);           \
+}
+
+__COBALT_bus_space_set_multi(1,8)
+__COBALT_bus_space_set_multi(2,16)
+__COBALT_bus_space_set_multi(4,32)
+
+#if 0  /* Cause a link error for bus_space_set_multi_8 */
+#define        bus_space_set_multi_8                                           
\
+                       !!! bus_space_set_multi_8 unimplemented !!!
+#endif
+
+#undef __COBALT_bus_space_set_multi
+
+/*
+ *     void bus_space_set_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
+ *         bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle starting at `offset'.
+ */
+
+#define __COBALT_bus_space_set_region(BYTES,BITS)                              
\
+void __CONCAT(bus_space_set_region_,BYTES)             \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS), bus_size_t);                                       
\
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_set_region_,BYTES)(t, h, o, v, c)                   \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) v;                                          \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, v);           \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__COBALT_bus_space_set_region(1,8)
+__COBALT_bus_space_set_region(2,16)
+__COBALT_bus_space_set_region(4,32)
+
+#if 0  /* Cause a link error for bus_space_set_region_8 */
+#define        bus_space_set_region_8                                          
\
+                       !!! bus_space_set_region_8 unimplemented !!!
+#endif
+
+#undef __COBALT_bus_space_set_region
+
+/*
+ *     void bus_space_copy_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         bus_size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+
+#define        __COBALT_copy_region(BYTES)                                     
\
+void __CONCAT(bus_space_copy_region_,BYTES)            \
+       (bus_space_tag_t,                                               \
+           bus_space_handle_t bsh1, bus_size_t off1,                   \
+           bus_space_handle_t bsh2, bus_size_t off2,                   \
+           bus_size_t count);                                          \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c)           \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h1, h2;                                      \
+       bus_size_t o1, o2, c;                                           \
+{                                                                      \
+       bus_size_t o;                                                   \
+                                                                       \
+       if ((h1 + o1) >= (h2 + o2)) {                                   \
+               /* src after dest: copy forward */                      \
+               for (o = 0; c != 0; c--, o += BYTES)                    \
+                       __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
+                           __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
+       } else {                                                        \
+               /* dest after src: copy backwards */                    \
+               for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES)      \
+                       __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
+                           __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
+       }                                                               \
+}
+
+__COBALT_copy_region(1)
+__COBALT_copy_region(2)
+__COBALT_copy_region(4)
+
+#if 0  /* Cause a link error for bus_space_copy_region_8 */
+#define        bus_space_copy_region_8                                         
\
+                       !!! bus_space_copy_region_8 unimplemented !!!
+#endif
+
+#undef __COBALT_copy_region
+
 int
 bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags,
     bus_space_handle_t *bshp)
Index: sys/arch/powerpc/oea/ofwoea_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofwoea_machdep.c,v
retrieving revision 1.23
diff -u -p -r1.23 ofwoea_machdep.c
--- sys/arch/powerpc/oea/ofwoea_machdep.c       2 Jul 2011 00:22:06 -0000       
1.23
+++ sys/arch/powerpc/oea/ofwoea_machdep.c       6 Jul 2011 20:42:41 -0000
@@ -53,10 +53,9 @@ __KERNEL_RCSID(0, "$NetBSD: ofwoea_machd
 #include <machine/trap.h>
 #include <machine/vmparam.h>
 #include <machine/autoconf.h>
-#include <powerpc/bus.h>
+#include <sys/bus.h>
 #include <powerpc/oea/bat.h>
 #include <powerpc/oea/cpufeat.h>
-#include <powerpc/ofw_bus.h>
 #include <powerpc/ofw_cons.h>
 #include <powerpc/spr.h>
 #include <powerpc/pic/picvar.h>
Index: sys/arch/powerpc/powerpc/bus_dma.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/powerpc/bus_dma.c,v
retrieving revision 1.42
diff -u -p -r1.42 bus_dma.c
--- sys/arch/powerpc/powerpc/bus_dma.c  30 Jun 2011 00:53:00 -0000      1.42
+++ sys/arch/powerpc/powerpc/bus_dma.c  6 Jul 2011 20:42:41 -0000
@@ -631,13 +631,13 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma
                         * If we are mapping nocache, flush the page from
                         * cache before we map it.
                         */
-                       if (flags & BUS_DMA_NOCACHE)
+                       if (flags & BUS_DMA_DONTCACHE)
                                dcbf(addr, PAGE_SIZE,
                                    curcpu()->ci_ci.dcache_line_size);
                        pmap_kenter_pa(va, addr,
                            VM_PROT_READ | VM_PROT_WRITE,
                            PMAP_WIRED |
-                           ((flags & BUS_DMA_NOCACHE) ? PMAP_NOCACHE : 0));
+                           ((flags & BUS_DMA_DONTCACHE) ? PMAP_NOCACHE : 0));
                }
        }
 
Index: sys/arch/sgimips/sgimips/bus.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sgimips/sgimips/bus.c,v
retrieving revision 1.62
diff -u -p -r1.62 bus.c
--- sys/arch/sgimips/sgimips/bus.c      20 Feb 2011 07:59:51 -0000      1.62
+++ sys/arch/sgimips/sgimips/bus.c      6 Jul 2011 20:42:41 -0000
@@ -44,7 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.62
 #include <sys/mbuf.h>
 
 #define _SGIMIPS_BUS_DMA_PRIVATE
-#include <machine/bus.h>
+#include <sys/bus.h>
 #include <machine/cpu.h>
 #include <machine/machtype.h>
 
@@ -1215,3 +1215,379 @@ bus_space_mmap(bus_space_tag_t space, bu
                return mips_btop((MIPS_KSEG1_TO_PHYS(addr) + off));
 #endif
 }
+
+/*
+ * Utility macros; do not use outside this file.
+ */
+#define        __PB_TYPENAME_PREFIX(BITS)      ___CONCAT(u_int,BITS)
+#define        __PB_TYPENAME(BITS)             
___CONCAT(__PB_TYPENAME_PREFIX(BITS),_t)
+
+/*
+ *     void bus_space_read_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+
+#define __SGIMIPS_bus_space_read_multi(BYTES,BITS)                     \
+void __CONCAT(bus_space_read_multi_,BYTES)             \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS) *, bus_size_t);                             \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_read_multi_,BYTES)(t, h, o, a, c)                   \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) *a;                                         \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o);        \
+}
+
+__SGIMIPS_bus_space_read_multi(1,8)
+__SGIMIPS_bus_space_read_multi(2,16)
+__SGIMIPS_bus_space_read_multi(4,32)
+
+#undef __SGIMIPS_bus_space_read_multi
+
+#define __SGIMIPS_bus_space_read_multi_stream(BYTES,BITS)              \
+void __CONCAT(bus_space_read_multi_stream_,BYTES)      \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS) *, bus_size_t);                             \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_read_multi_stream_,BYTES)(t, h, o, a, c)            \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) *a;                                         \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               *a++ = __CONCAT(bus_space_read_stream_,BYTES)(t, h, o); \
+}
+
+
+__SGIMIPS_bus_space_read_multi_stream(2,16)
+__SGIMIPS_bus_space_read_multi_stream(4,32)
+
+#undef __SGIMIPS_bus_space_read_multi_stream
+
+/*
+ *     void bus_space_read_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle and starting at `offset' and copy into
+ * buffer provided.
+ */
+
+#define __SGIMIPS_bus_space_read_region(BYTES,BITS)                    \
+void __CONCAT(bus_space_read_region_,BYTES)            \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS) *, bus_size_t);                             \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_read_region_,BYTES)(t, h, o, a, c)                  \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) *a;                                         \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o);        \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__SGIMIPS_bus_space_read_region(1,8)
+__SGIMIPS_bus_space_read_region(2,16)
+__SGIMIPS_bus_space_read_region(4,32)
+
+#undef __SGIMIPS_bus_space_read_region
+
+/*
+ *     void bus_space_read_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle and starting at `offset' and copy into
+ * buffer provided. No byte order translation is done.
+ */
+
+#define __SGIMIPS_bus_space_read_region_stream(BYTES,BITS)             \
+void __CONCAT(bus_space_read_region_stream_,BYTES)     \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS) *, bus_size_t);                             \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_read_region_stream_,BYTES)(t, h, o, a, c)           \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) *a;                                         \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               *a++ = __CONCAT(bus_space_read_stream_,BYTES)(t, h, o); \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__SGIMIPS_bus_space_read_region_stream(2,16)
+__SGIMIPS_bus_space_read_region_stream(4,32)
+
+#undef __SGIMIPS_bus_space_read_region_stream
+
+/*
+ *     void bus_space_write_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const u_intN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
+ * provided to bus space described by tag/handle/offset.
+ */
+
+#define __SGIMIPS_bus_space_write_multi(BYTES,BITS)                    \
+void __CONCAT(bus_space_write_multi_,BYTES)            \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       const __PB_TYPENAME(BITS) *, bus_size_t);                       \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_write_multi_,BYTES)(t, h, o, a, c)                  \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       const __PB_TYPENAME(BITS) *a;                                   \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++);        \
+}
+
+__SGIMIPS_bus_space_write_multi(1,8)
+__SGIMIPS_bus_space_write_multi(2,16)
+__SGIMIPS_bus_space_write_multi(4,32)
+
+#undef __SGIMIPS_bus_space_write_multi
+
+#define __SGIMIPS_bus_space_write_multi_stream(BYTES,BITS)             \
+void __CONCAT(bus_space_write_multi_stream_,BYTES)     \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       const __PB_TYPENAME(BITS) *, bus_size_t);                       \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_write_multi_stream_,BYTES)(t, h, o, a, c)           \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       const __PB_TYPENAME(BITS) *a;                                   \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               __CONCAT(bus_space_write_stream_,BYTES)(t, h, o, *a++); \
+}
+
+__SGIMIPS_bus_space_write_multi_stream(2,16)
+__SGIMIPS_bus_space_write_multi_stream(4,32)
+
+#undef __SGIMIPS_bus_space_write_multi_stream
+
+/*
+ *     void bus_space_write_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const u_intN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
+ * to bus space described by tag/handle starting at `offset'.
+ */
+
+#define __SGIMIPS_bus_space_write_region(BYTES,BITS)                   \
+void __CONCAT(bus_space_write_region_,BYTES)           \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       const __PB_TYPENAME(BITS) *, bus_size_t);                       \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_write_region_,BYTES)(t, h, o, a, c)                 \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       const __PB_TYPENAME(BITS) *a;                                   \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++);        \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__SGIMIPS_bus_space_write_region(1,8)
+__SGIMIPS_bus_space_write_region(2,16)
+__SGIMIPS_bus_space_write_region(4,32)
+
+#undef __SGIMIPS_bus_space_write_region
+
+/*
+ *     void bus_space_write_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const u_intN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
+ * to bus space described by tag/handle starting at `offset', but without
+ * byte-order translation
+ */
+
+#define __SGIMIPS_bus_space_write_region_stream(BYTES,BITS)            \
+void __CONCAT(bus_space_write_region_stream_,BYTES)    \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       const __PB_TYPENAME(BITS) *, bus_size_t);                       \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_write_region_stream_,BYTES)(t, h, o, a, c)          \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       const __PB_TYPENAME(BITS) *a;                                   \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               __CONCAT(bus_space_write_stream_,BYTES)(t, h, o, *a++); \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__SGIMIPS_bus_space_write_region_stream(2,16)
+__SGIMIPS_bus_space_write_region_stream(4,32)
+
+#undef __SGIMIPS_bus_space_write_region_stream
+
+/*
+ *     void bus_space_set_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
+ *         bus_size_t count);
+ *
+ * Write the 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle/offset `count' times.
+ */
+
+#define __SGIMIPS_bus_space_set_multi(BYTES,BITS)                      \
+void __CONCAT(bus_space_set_multi_,BYTES)              \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS), bus_size_t);                               \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_set_multi_,BYTES)(t, h, o, v, c)                    \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) v;                                          \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--)                                                     \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, v);           \
+}
+
+__SGIMIPS_bus_space_set_multi(1,8)
+__SGIMIPS_bus_space_set_multi(2,16)
+__SGIMIPS_bus_space_set_multi(4,32)
+
+#undef __SGIMIPS_bus_space_set_multi
+
+/*
+ *     void bus_space_set_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
+ *         bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle starting at `offset'.
+ */
+
+#define __SGIMIPS_bus_space_set_region(BYTES,BITS)                     \
+void __CONCAT(bus_space_set_region_,BYTES)             \
+       (bus_space_tag_t, bus_space_handle_t, bus_size_t,               \
+       __PB_TYPENAME(BITS), bus_size_t);                               \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_set_region_,BYTES)(t, h, o, v, c)                   \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h;                                           \
+       bus_size_t o;                                                   \
+       __PB_TYPENAME(BITS) v;                                          \
+       bus_size_t c;                                                   \
+{                                                                      \
+                                                                       \
+       while (c--) {                                                   \
+               __CONCAT(bus_space_write_,BYTES)(t, h, o, v);           \
+               o += BYTES;                                             \
+       }                                                               \
+}
+
+__SGIMIPS_bus_space_set_region(1,8)
+__SGIMIPS_bus_space_set_region(2,16)
+__SGIMIPS_bus_space_set_region(4,32)
+
+#undef __SGIMIPS_bus_space_set_region
+
+/*
+ *     void bus_space_copy_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         bus_size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+
+#define        __SGIMIPS_copy_region(BYTES)                                    
\
+void __CONCAT(bus_space_copy_region_,BYTES)            \
+       (bus_space_tag_t,                                               \
+           bus_space_handle_t bsh1, bus_size_t off1,                   \
+           bus_space_handle_t bsh2, bus_size_t off2,                   \
+           bus_size_t count);                                          \
+                                                                       \
+void                                                   \
+__CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c)           \
+       bus_space_tag_t t;                                              \
+       bus_space_handle_t h1, h2;                                      \
+       bus_size_t o1, o2, c;                                           \
+{                                                                      \
+       bus_size_t o;                                                   \
+                                                                       \
+       if ((h1 + o1) >= (h2 + o2)) {                                   \
+               /* src after dest: copy forward */                      \
+               for (o = 0; c != 0; c--, o += BYTES)                    \
+                       __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
+                           __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
+       } else {                                                        \
+               /* dest after src: copy backwards */                    \
+               for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES)      \
+                       __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
+                           __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
+       }                                                               \
+}
+
+__SGIMIPS_copy_region(1)
+__SGIMIPS_copy_region(2)
+__SGIMIPS_copy_region(4)
+
+#undef __SGIMIPS_copy_region
+
+#undef __PB_TYPENAME_PREFIX
+#undef __PB_TYPENAME
+
Index: sys/arch/sparc/sparc/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc/sparc/machdep.c,v
retrieving revision 1.312
diff -u -p -r1.312 machdep.c
--- sys/arch/sparc/sparc/machdep.c      2 Jul 2011 13:10:53 -0000       1.312
+++ sys/arch/sparc/sparc/machdep.c      6 Jul 2011 20:42:41 -0000
@@ -118,7 +118,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 
 #define _SPARC_BUS_DMA_PRIVATE
 #include <machine/autoconf.h>
-#include <machine/bus.h>
+#include <sys/bus.h>
 #include <machine/frame.h>
 #include <machine/cpu.h>
 #include <machine/pcb.h>
@@ -1863,6 +1863,892 @@ static void     *sparc_mainbus_intr_establis
 static void     sparc_bus_barrier(bus_space_tag_t, bus_space_handle_t,
                                        bus_size_t, bus_size_t, int);
 
+int
+bus_space_map(t, a, s, f, hp)
+       bus_space_tag_t t;
+       bus_addr_t      a;
+       bus_size_t      s;
+       int             f;
+       bus_space_handle_t *hp;
+{
+       return (*t->sparc_bus_map)(t, a, s, f, (vaddr_t)0, hp);
+}
+
+int
+bus_space_map2(t, a, s, f, v, hp)
+       bus_space_tag_t t;
+       bus_addr_t      a;
+       bus_size_t      s;
+       int             f;
+       vaddr_t         v;
+       bus_space_handle_t *hp;
+{
+       return (*t->sparc_bus_map)(t, a, s, f, v, hp);
+}
+
+void
+bus_space_unmap(t, h, s)
+       bus_space_tag_t t;
+       bus_space_handle_t h;
+       bus_size_t      s;
+{
+       (*t->sparc_bus_unmap)(t, h, s);
+}
+
+int
+bus_space_subregion(t, h, o, s, hp)
+       bus_space_tag_t t;
+       bus_space_handle_t h;
+       bus_size_t      o;
+       bus_size_t      s;
+       bus_space_handle_t *hp;
+{
+       return (*t->sparc_bus_subregion)(t, h, o, s, hp);
+}
+
+paddr_t
+bus_space_mmap(t, a, o, p, f)
+       bus_space_tag_t t;
+       bus_addr_t      a;
+       off_t           o;
+       int             p;
+       int             f;
+{
+       return (*t->sparc_bus_mmap)(t, a, o, p, f);
+}
+
+void *
+bus_intr_establish(t, p, l, h, a)
+       bus_space_tag_t t;
+       int     p;
+       int     l;
+       int     (*h)(void *);
+       void    *a;
+{
+       return (*t->sparc_intr_establish)(t, p, l, h, a, NULL);
+}
+
+void *
+bus_intr_establish2(t, p, l, h, a, v)
+       bus_space_tag_t t;
+       int     p;
+       int     l;
+       int     (*h)(void *);
+       void    *a;
+       void    (*v)(void);
+{
+       return (*t->sparc_intr_establish)(t, p, l, h, a, v);
+}
+
+void
+bus_space_barrier(t, h, o, s, f)
+       bus_space_tag_t t;
+       bus_space_handle_t h;
+       bus_size_t o;
+       bus_size_t s;
+       int f;
+{
+       (*t->sparc_bus_barrier)(t, h, o, s, f);
+}
+
+void
+bus_space_write_multi_stream_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          *a;
+{
+       while (c-- > 0)
+               bus_space_write_2_real(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_stream_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          *a;
+{
+       while (c-- > 0)
+               bus_space_write_4_real(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_stream_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          *a;
+{
+       while (c-- > 0)
+               bus_space_write_8_real(t, h, o, *a++);
+}
+
+
+/*
+ *     void bus_space_set_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
+ *         bus_size_t count);
+ *
+ * Write the 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle/offset `count' times.
+ */
+void
+bus_space_set_multi_1(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint8_t           v;
+{
+       while (c-- > 0)
+               bus_space_write_1(t, h, o, v);
+}
+
+void
+bus_space_set_multi_2(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          v;
+{
+       while (c-- > 0)
+               bus_space_write_2(t, h, o, v);
+}
+
+void
+bus_space_set_multi_4(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          v;
+{
+       while (c-- > 0)
+               bus_space_write_4(t, h, o, v);
+}
+
+void
+bus_space_set_multi_8(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          v;
+{
+       while (c-- > 0)
+               bus_space_write_8(t, h, o, v);
+}
+
+
+/*
+ *     void bus_space_read_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_read_region_1(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint8_t         *a;
+{
+       for (; c; a++, c--, o++)
+               *a = bus_space_read_1(t, h, o);
+}
+
+void
+bus_space_read_region_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint16_t                *a;
+{
+       for (; c; a++, c--, o+=2)
+               *a = bus_space_read_2(t, h, o);
+}
+
+void
+bus_space_read_region_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint32_t                *a;
+{
+       for (; c; a++, c--, o+=4)
+               *a = bus_space_read_4(t, h, o);
+}
+
+void
+bus_space_read_region_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint64_t                *a;
+{
+       for (; c; a++, c--, o+=8)
+               *a = bus_space_read_8(t, h, o);
+}
+
+/*
+ *     void bus_space_write_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_write_region_1(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint8_t           *a;
+{
+       for (; c; a++, c--, o++)
+               bus_space_write_1(t, h, o, *a);
+}
+
+void
+bus_space_write_region_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          *a;
+{
+       for (; c; a++, c--, o+=2)
+               bus_space_write_2(t, h, o, *a);
+}
+
+void
+bus_space_write_region_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          *a;
+{
+       for (; c; a++, c--, o+=4)
+               bus_space_write_4(t, h, o, *a);
+}
+
+void
+bus_space_write_region_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          *a;
+{
+       for (; c; a++, c--, o+=8)
+               bus_space_write_8(t, h, o, *a);
+}
+
+
+/*
+ *     void bus_space_set_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_set_region_1(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint8_t           v;
+{
+       for (; c; c--, o++)
+               bus_space_write_1(t, h, o, v);
+}
+
+void
+bus_space_set_region_2(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          v;
+{
+       for (; c; c--, o+=2)
+               bus_space_write_2(t, h, o, v);
+}
+
+void
+bus_space_set_region_4(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          v;
+{
+       for (; c; c--, o+=4)
+               bus_space_write_4(t, h, o, v);
+}
+
+void
+bus_space_set_region_8(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          v;
+{
+       for (; c; c--, o+=8)
+               bus_space_write_8(t, h, o, v);
+}
+
+
+/*
+ *     void bus_space_copy_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         bus_size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+void
+bus_space_copy_region_1(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1++, o2++)
+           bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
+}
+
+void
+bus_space_copy_region_2(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1+=2, o2+=2)
+           bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
+}
+
+void
+bus_space_copy_region_4(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1+=4, o2+=4)
+           bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
+}
+
+void
+bus_space_copy_region_8(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1+=8, o2+=8)
+           bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
+}
+
+/*
+ *     void bus_space_read_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_read_region_stream_1(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint8_t                 *a;
+{
+       for (; c; a++, c--, o++)
+               *a = bus_space_read_stream_1(t, h, o);
+}
+void
+bus_space_read_region_stream_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint16_t                *a;
+{
+       for (; c; a++, c--, o+=2)
+               *a = bus_space_read_stream_2(t, h, o);
+ }
+void
+bus_space_read_region_stream_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint32_t                *a;
+{
+       for (; c; a++, c--, o+=4)
+               *a = bus_space_read_stream_4(t, h, o);
+}
+void
+bus_space_read_region_stream_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint64_t                *a;
+{
+       for (; c; a++, c--, o+=8)
+               *a = bus_space_read_stream_8(t, h, o);
+}
+
+/*
+ *     void bus_space_write_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_write_region_stream_1(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint8_t           *a;
+{
+       for (; c; a++, c--, o++)
+               bus_space_write_stream_1(t, h, o, *a);
+}
+
+void
+bus_space_write_region_stream_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          *a;
+{
+       for (; c; a++, c--, o+=2)
+               bus_space_write_stream_2(t, h, o, *a);
+}
+
+void
+bus_space_write_region_stream_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          *a;
+{
+       for (; c; a++, c--, o+=4)
+               bus_space_write_stream_4(t, h, o, *a);
+}
+
+void
+bus_space_write_region_stream_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          *a;
+{
+       for (; c; a++, c--, o+=8)
+               bus_space_write_stream_8(t, h, o, *a);
+}
+
+
+/*
+ *     void bus_space_set_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_set_region_stream_1(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint8_t           v;
+{
+       for (; c; c--, o++)
+               bus_space_write_stream_1(t, h, o, v);
+}
+
+void
+bus_space_set_region_stream_2(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          v;
+{
+       for (; c; c--, o+=2)
+               bus_space_write_stream_2(t, h, o, v);
+}
+
+void
+bus_space_set_region_stream_4(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          v;
+{
+       for (; c; c--, o+=4)
+               bus_space_write_stream_4(t, h, o, v);
+}
+
+void
+bus_space_set_region_stream_8(t, h, o, v, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          v;
+{
+       for (; c; c--, o+=8)
+               bus_space_write_stream_8(t, h, o, v);
+}
+
+/*
+ *     void bus_space_copy_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         bus_size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+
+void
+bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1++, o2++)
+           bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2, 
o2));
+}
+
+void
+bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1+=2, o2+=2)
+           bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2, 
o2));
+}
+
+void
+bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1+=4, o2+=4)
+           bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2, 
o2));
+}
+
+void
+bus_space_copy_region_stream_8(t, h1, o1, h2, o2, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h1, h2;
+       bus_size_t              o1, o2;
+       bus_size_t              c;
+{
+       for (; c; c--, o1+=8, o2+=8)
+           bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2));
+}
+
+void
+bus_space_write_1(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint8_t                 v;
+{
+       (*t->sparc_write_1)(t, h, o, v);
+}
+
+void
+bus_space_write_2(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint16_t                v;
+{
+       (*t->sparc_write_2)(t, h, o, v);
+}
+
+void
+bus_space_write_4(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint32_t                v;
+{
+       (*t->sparc_write_4)(t, h, o, v);
+}
+
+void
+bus_space_write_8(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint64_t                v;
+{
+       (*t->sparc_write_8)(t, h, o, v);
+}
+
+#if __SLIM_SPARC_BUS_SPACE
+
+void
+bus_space_write_1(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint8_t         v;
+{
+       __insn_barrier();
+       bus_space_write_1_real(t, h, o, v);
+}
+
+void
+bus_space_write_2(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint16_t                v;
+{
+       __insn_barrier();
+       bus_space_write_2_real(t, h, o, v);
+}
+
+void
+bus_space_write_4(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint32_t                v;
+{
+       __insn_barrier();
+       bus_space_write_4_real(t, h, o, v);
+}
+
+void
+bus_space_write_8(t, h, o, v)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+       uint64_t                v;
+{
+       __insn_barrier();
+       bus_space_write_8_real(t, h, o, v);
+}
+
+#endif /* __SLIM_SPARC_BUS_SPACE */
+
+uint8_t
+bus_space_read_1(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       return (*t->sparc_read_1)(t, h, o);
+}
+
+uint16_t
+bus_space_read_2(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       return (*t->sparc_read_2)(t, h, o);
+}
+
+uint32_t
+bus_space_read_4(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       return (*t->sparc_read_4)(t, h, o);
+}
+
+uint64_t
+bus_space_read_8(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       return (*t->sparc_read_8)(t, h, o);
+}
+
+#if __SLIM_SPARC_BUS_SPACE
+uint8_t
+bus_space_read_1(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       __insn_barrier();
+       return bus_space_read_1_real(t, h, o);
+}
+
+uint16_t
+bus_space_read_2(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       __insn_barrier();
+       return bus_space_read_2_real(t, h, o);
+}
+
+uint32_t
+bus_space_read_4(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       __insn_barrier();
+       return bus_space_read_4_real(t, h, o);
+}
+
+uint64_t
+bus_space_read_8(t, h, o)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o;
+{
+       __insn_barrier();
+       return bus_space_read_8_real(t, h, o);
+}
+
+#endif /* __SLIM_SPARC_BUS_SPACE */
+
+void
+bus_space_read_multi_1(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint8_t         *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_1(t, h, o);
+}
+
+void
+bus_space_read_multi_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint16_t                *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_2(t, h, o);
+}
+
+void
+bus_space_read_multi_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint32_t                *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_4(t, h, o);
+}
+
+void
+bus_space_read_multi_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint64_t                *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_8(t, h, o);
+}
+
+/*
+ *     void bus_space_read_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         u_intN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+void
+bus_space_read_multi_stream_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint16_t                *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_2_real(t, h, o);
+}
+
+void
+bus_space_read_multi_stream_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint32_t                *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_4_real(t, h, o);
+}
+
+void
+bus_space_read_multi_stream_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       uint64_t                *a;
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_8_real(t, h, o);
+}
+
+/*
+ *     void bus_space_write_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const u_intN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
+ * provided to bus space described by tag/handle/offset.
+ */
+void
+bus_space_write_multi_1(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint8_t           *a;
+{
+       while (c-- > 0)
+               bus_space_write_1(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_2(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint16_t          *a;
+{
+       while (c-- > 0)
+               bus_space_write_2(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_4(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint32_t          *a;
+{
+       while (c-- > 0)
+               bus_space_write_4(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_8(t, h, o, a, c)
+       bus_space_tag_t         t;
+       bus_space_handle_t      h;
+       bus_size_t              o, c;
+       const uint64_t          *a;
+{
+       while (c-- > 0)
+               bus_space_write_8(t, h, o, *a++);
+}
+
 /*
  * Allocate a new bus tag and have it inherit the methods of the
  * given parent.
Index: sys/arch/sparc64/include/Makefile
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/include/Makefile,v
retrieving revision 1.26
diff -u -p -r1.26 Makefile
--- sys/arch/sparc64/include/Makefile   13 Apr 2011 03:24:28 -0000      1.26
+++ sys/arch/sparc64/include/Makefile   6 Jul 2011 20:42:41 -0000
@@ -3,7 +3,7 @@
 INCSDIR= /usr/include/sparc64
 
 INCS=  ansi.h aout_machdep.h asm.h autoconf.h \
-       bswap.h bsd_openprom.h bus.h \
+       bswap.h bsd_openprom.h \
        cdefs.h cgtworeg.h cpu.h ctlreg.h \
        disklabel.h \
        eeprom.h elf_machdep.h endian.h endian_machdep.h \
Index: sys/arch/sparc64/sparc64/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/machdep.c,v
retrieving revision 1.260
diff -u -p -r1.260 machdep.c
--- sys/arch/sparc64/sparc64/machdep.c  2 Jul 2011 13:11:48 -0000       1.260
+++ sys/arch/sparc64/sparc64/machdep.c  6 Jul 2011 20:42:41 -0000
@@ -123,7 +123,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 
 #define _SPARC_BUS_DMA_PRIVATE
 #include <machine/autoconf.h>
-#include <machine/bus.h>
+#include <sys/bus.h>
 #include <machine/frame.h>
 #include <machine/cpu.h>
 #include <machine/pcb.h>
@@ -1617,6 +1617,634 @@ static void     sparc_bus_free(bus_space_tag
 
 struct extent *io_space = NULL;
 
+void
+bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, bus_size_t s, int f)
+{
+       /*
+        * We have a bit of a problem with the bus_space_barrier()
+        * interface.  It defines a read barrier and a write barrier
+        * which really don't map to the 7 different types of memory
+        * barriers in the SPARC v9 instruction set.
+        */
+       if (f == BUS_SPACE_BARRIER_READ)
+               /* A load followed by a load to the same location? */
+               __asm volatile("membar #Lookaside");
+       else if (f == BUS_SPACE_BARRIER_WRITE)
+               /* A store followed by a store? */
+               __asm volatile("membar #StoreStore");
+       else 
+               /* A store followed by a load? */
+               __asm volatile("membar #StoreLoad|#MemIssue|#Lookaside");
+}
+
+int
+bus_space_alloc(bus_space_tag_t t, bus_addr_t rs, bus_addr_t re, bus_size_t s,
+       bus_size_t a, bus_size_t b, int f, bus_addr_t *ap,
+       bus_space_handle_t *hp)
+{
+       _BS_CALL(t, sparc_bus_alloc)(t, rs, re, s, a, b, f, ap, hp);
+}
+
+void
+bus_space_free(bus_space_tag_t t, bus_space_handle_t h, bus_size_t s)
+{
+       _BS_CALL(t, sparc_bus_free)(t, h, s);
+}
+
+int
+bus_space_map(bus_space_tag_t t, bus_addr_t a, bus_size_t s, int f,
+       bus_space_handle_t *hp)
+{
+       _BS_CALL(t, sparc_bus_map)(t, a, s, f, 0, hp);
+}
+
+void
+bus_space_unmap(bus_space_tag_t t, bus_space_handle_t h, bus_size_t s)
+{
+       _BS_VOID_CALL(t, sparc_bus_unmap)(t, h, s);
+}
+
+int
+bus_space_subregion(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       bus_size_t s, bus_space_handle_t *hp)
+{
+       _BS_CALL(t, sparc_bus_subregion)(t, h, o, s, hp);
+}
+
+paddr_t
+bus_space_mmap(bus_space_tag_t t, bus_addr_t a, off_t o, int p, int f)
+{
+       _BS_CALL(t, sparc_bus_mmap)(t, a, o, p, f);
+}
+
+/*
+ *     void bus_space_read_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+void
+bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint8_t * a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_1(t, h, o);
+}
+
+void
+bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint16_t * a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_2(t, h, o);
+}
+
+void
+bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint32_t * a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_4(t, h, o);
+}
+
+void
+bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint64_t * a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_8(t, h, o);
+}
+
+/*
+ *     void bus_space_write_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const uintN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
+ * provided to bus space described by tag/handle/offset.
+ */
+void
+bus_space_write_multi_1(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint8_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_1(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_2(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint16_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_2(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_4(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint32_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_4(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_8(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint64_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_8(t, h, o, *a++);
+}
+
+/*
+ *     void bus_space_set_multi_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
+ *         bus_size_t count);
+ *
+ * Write the 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle/offset `count' times.
+ */
+void
+bus_space_set_multi_stream_1(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint8_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_1(t, h, o, v);
+}
+
+void
+bus_space_set_multi_stream_2(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint16_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_2(t, h, o, v);
+}
+
+void
+bus_space_set_multi_stream_4(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint32_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_4(t, h, o, v);
+}
+
+void
+bus_space_set_multi_stream_8(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint64_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_8(t, h, o, v);
+}
+
+/*
+ *     void bus_space_copy_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         bus_size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+void
+bus_space_copy_region_stream_1(bus_space_tag_t t, bus_space_handle_t h1,
+       bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1++, o2++)
+           bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2, 
o2));
+}
+
+void
+bus_space_copy_region_stream_2(bus_space_tag_t t, bus_space_handle_t h1,
+       bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1+=2, o2+=2)
+           bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2, 
o2));
+}
+
+void
+bus_space_copy_region_stream_4(bus_space_tag_t t, bus_space_handle_t h1,
+       bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1+=4, o2+=4)
+           bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2, 
o2));
+}
+
+void
+bus_space_copy_region_stream_8(bus_space_tag_t t, bus_space_handle_t h1,
+       bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1+=8, o2+=8)
+           bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2));
+}
+
+/*
+ *     void bus_space_set_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_set_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint8_t v, bus_size_t c)
+{
+       for (; c; c--, o++)
+               bus_space_write_stream_1(t, h, o, v);
+}
+
+void
+bus_space_set_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint16_t v, bus_size_t c)
+{
+       for (; c; c--, o+=2)
+               bus_space_write_stream_2(t, h, o, v);
+}
+
+void
+bus_space_set_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint32_t v, bus_size_t c)
+{
+       for (; c; c--, o+=4)
+               bus_space_write_stream_4(t, h, o, v);
+}
+
+void
+bus_space_set_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint64_t v, bus_size_t c)
+{
+       for (; c; c--, o+=8)
+               bus_space_write_stream_8(t, h, o, v);
+}
+
+
+/*
+ *     void bus_space_read_multi_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ * Read `count' 1, 2, 4, or 8 byte quantities from bus space
+ * described by tag/handle/offset and copy into buffer provided.
+ */
+void
+bus_space_read_multi_stream_1(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       uint8_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_stream_1(t, h, o);
+}
+
+void
+bus_space_read_multi_stream_2(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       uint16_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_stream_2(t, h, o);
+}
+
+void
+bus_space_read_multi_stream_4(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       uint32_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_stream_4(t, h, o);
+}
+
+void
+bus_space_read_multi_stream_8(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       uint64_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               *a++ = bus_space_read_stream_8(t, h, o);
+}
+
+/*
+ *     void bus_space_read_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_read_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint8_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o++)
+               *a = bus_space_read_stream_1(t, h, o);
+}
+void
+bus_space_read_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint16_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=2)
+               *a = bus_space_read_stream_2(t, h, o);
+ }
+void
+bus_space_read_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint32_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=4)
+               *a = bus_space_read_stream_4(t, h, o);
+}
+void
+bus_space_read_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, uint64_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=8)
+               *a = bus_space_read_stream_8(t, h, o);
+}
+
+/*
+ *     void bus_space_write_multi_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset,
+ *         const uintN_t *addr, bus_size_t count);
+ *
+ * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
+ * provided to bus space described by tag/handle/offset.
+ */
+void
+bus_space_write_multi_stream_1(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint8_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_1(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_stream_2(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint16_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_2(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_stream_4(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint32_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_4(t, h, o, *a++);
+}
+
+void
+bus_space_write_multi_stream_8(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o,
+       const uint64_t *a, bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_stream_8(t, h, o, *a++);
+}
+
+/*
+ *     void bus_space_copy_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh1, bus_size_t off1,
+ *         bus_space_handle_t bsh2, bus_size_t off2,
+ *         bus_size_t count);
+ *
+ * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
+ * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
+ */
+void
+bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t 
o1,
+       bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1++, o2++)
+           bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
+}
+
+void
+bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t 
o1,
+       bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1+=2, o2+=2)
+           bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
+}
+
+void
+bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t 
o1,
+       bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1+=4, o2+=4)
+           bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
+}
+
+void
+bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1, bus_size_t 
o1,
+       bus_space_handle_t h2, bus_size_t o2, bus_size_t c)
+{
+       for (; c; c--, o1+=8, o2+=8)
+           bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
+}
+
+/*
+ *     void bus_space_set_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint8_t v, bus_size_t c)
+{
+       for (; c; c--, o++)
+               bus_space_write_1(t, h, o, v);
+}
+
+void
+bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint16_t v, bus_size_t c)
+{
+       for (; c; c--, o+=2)
+               bus_space_write_2(t, h, o, v);
+}
+
+void
+bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint32_t v, bus_size_t c)
+{
+       for (; c; c--, o+=4)
+               bus_space_write_4(t, h, o, v);
+}
+
+void
+bus_space_set_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint64_t v, bus_size_t c)
+{
+       for (; c; c--, o+=8)
+               bus_space_write_8(t, h, o, v);
+}
+
+
+/*
+ *     void bus_space_set_multi_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
+ *         bus_size_t count);
+ *
+ * Write the 1, 2, 4, or 8 byte value `val' to bus space described
+ * by tag/handle/offset `count' times.
+ */
+void
+bus_space_set_multi_1(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint8_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_1(t, h, o, v);
+}
+
+void
+bus_space_set_multi_2(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint16_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_2(t, h, o, v);
+}
+
+void
+bus_space_set_multi_4(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint32_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_4(t, h, o, v);
+}
+
+void
+bus_space_set_multi_8(bus_space_tag_t t,
+       bus_space_handle_t h, bus_size_t o, uint64_t v,
+       bus_size_t c)
+{
+       while (c-- > 0)
+               bus_space_write_8(t, h, o, v);
+}
+
+/*
+ *     void bus_space_write_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint8_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o++)
+               bus_space_write_1(t, h, o, *a);
+}
+
+void
+bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint16_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=2)
+               bus_space_write_2(t, h, o, *a);
+}
+
+void
+bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint32_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=4)
+               bus_space_write_4(t, h, o, *a);
+}
+
+void
+bus_space_write_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       const uint64_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=8)
+               bus_space_write_8(t, h, o, *a);
+}
+
+
+/*
+ *     void bus_space_read_region_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       uint8_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o++)
+               *a = bus_space_read_1(t, h, o);
+}
+void
+bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       uint16_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=2)
+               *a = bus_space_read_2(t, h, o);
+ }
+void
+bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       uint32_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=4)
+               *a = bus_space_read_4(t, h, o);
+}
+void
+bus_space_read_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
+       uint64_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=8)
+               *a = bus_space_read_8(t, h, o);
+}
+
+/*
+ *     void bus_space_write_region_stream_N(bus_space_tag_t tag,
+ *         bus_space_handle_t bsh, bus_size_t off,
+ *         uintN_t *addr, bus_size_t count);
+ *
+ */
+void
+bus_space_write_region_stream_1(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint8_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o++)
+               bus_space_write_stream_1(t, h, o, *a);
+}
+
+void
+bus_space_write_region_stream_2(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint16_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=2)
+               bus_space_write_stream_2(t, h, o, *a);
+}
+
+void
+bus_space_write_region_stream_4(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint32_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=4)
+               bus_space_write_stream_4(t, h, o, *a);
+}
+
+void
+bus_space_write_region_stream_8(bus_space_tag_t t, bus_space_handle_t h,
+       bus_size_t o, const uint64_t *a, bus_size_t c)
+{
+       for (; c; a++, c--, o+=8)
+               bus_space_write_stream_8(t, h, o, *a);
+}
+
 /*
  * Allocate a new bus tag and have it inherit the methods of the
  * given parent.


Home | Main Index | Thread Index | Old Index