Module Name: src
Committed By: dyoung
Date: Sun Jul 17 01:36:51 UTC 2011
Modified Files:
src/sys/arch/arc/arc: bus_space.c
src/sys/arch/arc/include: types.h
src/sys/arch/cobalt/cobalt: bus.c
src/sys/arch/cobalt/include: types.h
src/sys/arch/evbmips/include: Makefile types.h
src/sys/arch/sgimips/include: types.h
src/sys/arch/sgimips/sgimips: bus.c
Removed Files:
src/sys/arch/arc/include: bus.h
src/sys/arch/cobalt/include: bus.h
src/sys/arch/evbmips/include: bus.h
src/sys/arch/mips/include: bus_space.h
src/sys/arch/sgimips/include: bus.h
Log Message:
Switch MIPS and MIPS-ish architectures to new-style <sys/bus.h>. This
involves moving some inline bus_space(9) implementation into .c files.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arc/arc/bus_space.c
cvs rdiff -u -r1.26 -r0 src/sys/arch/arc/include/bus.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arc/include/types.h
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/cobalt/cobalt/bus.c
cvs rdiff -u -r1.23 -r0 src/sys/arch/cobalt/include/bus.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/cobalt/include/types.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbmips/include/Makefile
cvs rdiff -u -r1.4 -r0 src/sys/arch/evbmips/include/bus.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/evbmips/include/types.h
cvs rdiff -u -r1.5 -r0 src/sys/arch/mips/include/bus_space.h
cvs rdiff -u -r1.28 -r0 src/sys/arch/sgimips/include/bus.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sgimips/include/types.h
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/sgimips/sgimips/bus.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arc/arc/bus_space.c
diff -u src/sys/arch/arc/arc/bus_space.c:1.10 src/sys/arch/arc/arc/bus_space.c:1.11
--- src/sys/arch/arc/arc/bus_space.c:1.10 Mon Apr 28 20:23:13 2008
+++ src/sys/arch/arc/arc/bus_space.c Sun Jul 17 01:36:50 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.10 2008/04/28 20:23:13 martin Exp $ */
+/* $NetBSD: bus_space.c,v 1.11 2011/07/17 01:36:50 dyoung Exp $ */
/* NetBSD: bus_machdep.c,v 1.1 2000/01/26 18:48:00 drochner Exp */
/*-
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.10 2008/04/28 20:23:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.11 2011/07/17 01:36:50 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -41,7 +41,274 @@
#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: src/sys/arch/arc/include/types.h
diff -u src/sys/arch/arc/include/types.h:1.22 src/sys/arch/arc/include/types.h:1.23
--- src/sys/arch/arc/include/types.h:1.22 Sun Jan 20 18:09:04 2008
+++ src/sys/arch/arc/include/types.h Sun Jul 17 01:36:51 2011
@@ -1,9 +1,9 @@
-/* $NetBSD: types.h,v 1.22 2008/01/20 18:09:04 joerg Exp $ */
+/* $NetBSD: types.h,v 1.23 2011/07/17 01:36:51 dyoung Exp $ */
#define _MIPS_PADDR_T_64BIT
#include <mips/types.h>
-#define __HAVE_DEVICE_REGISTER
+#define __HAVE_NEW_STYLE_BUS_H
#define __HAVE_MIPS_MACHDEP_CACHE_CONFIG
Index: src/sys/arch/cobalt/cobalt/bus.c
diff -u src/sys/arch/cobalt/cobalt/bus.c:1.41 src/sys/arch/cobalt/cobalt/bus.c:1.42
--- src/sys/arch/cobalt/cobalt/bus.c:1.41 Sat Jul 9 16:09:01 2011
+++ src/sys/arch/cobalt/cobalt/bus.c Sun Jul 17 01:36:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.c,v 1.41 2011/07/09 16:09:01 matt Exp $ */
+/* $NetBSD: bus.c,v 1.42 2011/07/17 01:36:51 dyoung Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.41 2011/07/09 16:09:01 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.42 2011/07/17 01:36:51 dyoung Exp $");
#define _COBALT_BUS_DMA_PRIVATE
@@ -50,6 +50,12 @@
#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 @@
_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: src/sys/arch/cobalt/include/types.h
diff -u src/sys/arch/cobalt/include/types.h:1.10 src/sys/arch/cobalt/include/types.h:1.11
--- src/sys/arch/cobalt/include/types.h:1.10 Sun Jan 20 18:09:05 2008
+++ src/sys/arch/cobalt/include/types.h Sun Jul 17 01:36:51 2011
@@ -1,5 +1,5 @@
-/* $NetBSD: types.h,v 1.10 2008/01/20 18:09:05 joerg Exp $ */
+/* $NetBSD: types.h,v 1.11 2011/07/17 01:36:51 dyoung Exp $ */
#include <mips/types.h>
-#define __HAVE_DEVICE_REGISTER
+#define __HAVE_NEW_STYLE_BUS_H
Index: src/sys/arch/evbmips/include/Makefile
diff -u src/sys/arch/evbmips/include/Makefile:1.12 src/sys/arch/evbmips/include/Makefile:1.13
--- src/sys/arch/evbmips/include/Makefile:1.12 Wed Aug 12 23:29:19 2009
+++ src/sys/arch/evbmips/include/Makefile Sun Jul 17 01:36:51 2011
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.12 2009/08/12 23:29:19 matt Exp $
+# $NetBSD: Makefile,v 1.13 2011/07/17 01:36:51 dyoung Exp $
INCSDIR=/usr/include/evbmips
INCS= ansi.h asm.h \
- bswap.h bus.h \
+ bswap.h \
cdefs.h cpu.h \
disklabel.h \
ecoff_machdep.h elf_machdep.h endian.h endian_machdep.h \
Index: src/sys/arch/evbmips/include/types.h
diff -u src/sys/arch/evbmips/include/types.h:1.8 src/sys/arch/evbmips/include/types.h:1.9
--- src/sys/arch/evbmips/include/types.h:1.8 Sun Jan 20 18:09:06 2008
+++ src/sys/arch/evbmips/include/types.h Sun Jul 17 01:36:51 2011
@@ -1,7 +1,7 @@
-/* $NetBSD: types.h,v 1.8 2008/01/20 18:09:06 joerg Exp $ */
+/* $NetBSD: types.h,v 1.9 2011/07/17 01:36:51 dyoung Exp $ */
#define _MIPS_PADDR_T_64BIT
#include <mips/types.h>
-#define __HAVE_DEVICE_REGISTER
+#define __HAVE_NEW_STYLE_BUS_H
Index: src/sys/arch/sgimips/include/types.h
diff -u src/sys/arch/sgimips/include/types.h:1.15 src/sys/arch/sgimips/include/types.h:1.16
--- src/sys/arch/sgimips/include/types.h:1.15 Sun Jan 20 18:09:09 2008
+++ src/sys/arch/sgimips/include/types.h Sun Jul 17 01:36:50 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: types.h,v 1.15 2008/01/20 18:09:09 joerg Exp $ */
+/* $NetBSD: types.h,v 1.16 2011/07/17 01:36:50 dyoung Exp $ */
#define _MIPS_PADDR_T_64BIT
#include <mips/types.h>
-#define __HAVE_DEVICE_REGISTER
+#define __HAVE_NEW_STYLE_BUS_H
/* MIPS specific options */
#define __HAVE_BOOTINFO_H
Index: src/sys/arch/sgimips/sgimips/bus.c
diff -u src/sys/arch/sgimips/sgimips/bus.c:1.62 src/sys/arch/sgimips/sgimips/bus.c:1.63
--- src/sys/arch/sgimips/sgimips/bus.c:1.62 Sun Feb 20 07:59:51 2011
+++ src/sys/arch/sgimips/sgimips/bus.c Sun Jul 17 01:36:50 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.c,v 1.62 2011/02/20 07:59:51 matt Exp $ */
+/* $NetBSD: bus.c,v 1.63 2011/07/17 01:36:50 dyoung Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.62 2011/02/20 07:59:51 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.63 2011/07/17 01:36:50 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -44,7 +44,7 @@
#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 @@
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
+