Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcsh Move macros _BUS_SPACE_WRITE(), _BUS_SPACE_WR...
details: https://anonhg.NetBSD.org/src/rev/20d393dd7914
branches: trunk
changeset: 767520:20d393dd7914
user: dyoung <dyoung%NetBSD.org@localhost>
date: Wed Jul 20 20:46:49 2011 +0000
description:
Move macros _BUS_SPACE_WRITE(), _BUS_SPACE_WRITE_MULTI(), et
cetera, into <hpcsh/bus_util.h> for both hpcsh/bus_space.c and
dev/hd64461/hd64461pcmcia.c to use them.
(I haven't had a close look at what hd64461pcmcia.c is doing, but I have
a hunch that it is a good use for bus_space_tag_create(9).)
diffstat:
sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c | 6 +-
sys/arch/hpcsh/hpcsh/bus_space.c | 135 +----------------------------
sys/arch/hpcsh/include/bus_util.h | 133 ++++++++++++++++++++++++++++
3 files changed, 140 insertions(+), 134 deletions(-)
diffs (truncated from 320 to 300 lines):
diff -r 68e80738a9cc -r 20d393dd7914 sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c
--- a/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c Wed Jul 20 20:38:29 2011 +0000
+++ b/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c Wed Jul 20 20:46:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hd64461pcmcia.c,v 1.47 2011/07/19 15:30:52 dyoung Exp $ */
+/* $NetBSD: hd64461pcmcia.c,v 1.48 2011/07/20 20:46:49 dyoung Exp $ */
/*-
* Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.47 2011/07/19 15:30:52 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.48 2011/07/20 20:46:49 dyoung Exp $");
#include "opt_hd64461pcmcia.h"
@@ -57,6 +57,8 @@
#include <hpcsh/dev/hd64461/hd64461pcmciavar.h>
#include <hpcsh/dev/hd64461/hd64461pcmciareg.h>
+#include <hpcsh/bus_util.h> /* for _BUS_SPACE_WRITE(), et cetera */
+
#include "locators.h"
#ifdef HD64461PCMCIA_DEBUG
diff -r 68e80738a9cc -r 20d393dd7914 sys/arch/hpcsh/hpcsh/bus_space.c
--- a/sys/arch/hpcsh/hpcsh/bus_space.c Wed Jul 20 20:38:29 2011 +0000
+++ b/sys/arch/hpcsh/hpcsh/bus_space.c Wed Jul 20 20:46:49 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.17 2011/07/19 15:30:53 dyoung Exp $ */
+/* $NetBSD: bus_space.c,v 1.18 2011/07/20 20:46:49 dyoung Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.17 2011/07/19 15:30:53 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.18 2011/07/20 20:46:49 dyoung Exp $");
#include "debug_hpcsh.h"
@@ -44,136 +44,7 @@
#endif
#include <machine/debug.h>
-/*
- * Utility macros; INTERNAL USE ONLY.
- */
-
-#define __TYPENAME(BITS) u_int##BITS##_t
-
-#define _BUS_SPACE_READ(PREFIX, BYTES, BITS) \
-__TYPENAME(BITS) \
-PREFIX##_read_##BYTES(void *, bus_space_handle_t, bus_size_t); \
-__TYPENAME(BITS) \
-PREFIX##_read_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset) \
-{ \
- _BUS_SPACE_ACCESS_HOOK(); \
- return *(volatile __TYPENAME(BITS) *)(bsh + offset); \
-}
-
-#define _BUS_SPACE_READ_MULTI(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_read_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- __TYPENAME(BITS) *, bus_size_t); \
-void \
-PREFIX##_read_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset, __TYPENAME(BITS) *addr, \
- bus_size_t count) \
-{ \
- volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
- _BUS_SPACE_ACCESS_HOOK(); \
- while (count--) \
- *addr++ = *p; \
-}
-
-#define _BUS_SPACE_READ_REGION(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_read_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- __TYPENAME(BITS) *, bus_size_t); \
-void \
-PREFIX##_read_region_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset, __TYPENAME(BITS) *addr, \
- bus_size_t count) \
-{ \
- volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
- _BUS_SPACE_ACCESS_HOOK(); \
- while (count--) \
- *addr++ = *p++; \
-}
-
-#define _BUS_SPACE_WRITE(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_write_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- __TYPENAME(BITS)); \
-void \
-PREFIX##_write_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset, __TYPENAME(BITS) value) \
-{ \
- _BUS_SPACE_ACCESS_HOOK(); \
- *(volatile __TYPENAME(BITS) *)(bsh + offset) = value; \
-}
-
-#define _BUS_SPACE_WRITE_MULTI(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_write_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- const __TYPENAME(BITS) *, bus_size_t); \
-void \
-PREFIX##_write_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset, \
- const __TYPENAME(BITS) *addr, \
- bus_size_t count) \
-{ \
- volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
- _BUS_SPACE_ACCESS_HOOK(); \
- while (count--) \
- *p = *addr++; \
-}
-
-#define _BUS_SPACE_WRITE_REGION(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_write_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- const __TYPENAME(BITS) *, bus_size_t); \
-void \
-PREFIX##_write_region_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset, \
- const __TYPENAME(BITS) *addr, \
- bus_size_t count) \
-{ \
- volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
- _BUS_SPACE_ACCESS_HOOK(); \
- while (count--) \
- *p++ = *addr++; \
-}
-
-#define _BUS_SPACE_SET_MULTI(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_set_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- __TYPENAME(BITS), bus_size_t); \
-void \
-PREFIX##_set_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
- bus_size_t offset, __TYPENAME(BITS) value, \
- bus_size_t count) \
-{ \
- volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
- _BUS_SPACE_ACCESS_HOOK(); \
- while (count--) \
- *p = value; \
-}
-
-#define _BUS_SPACE_COPY_REGION(PREFIX, BYTES, BITS) \
-void \
-PREFIX##_copy_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
- bus_space_handle_t, bus_size_t, \
- bus_size_t); \
-void \
-PREFIX##_copy_region_##BYTES(void *t, bus_space_handle_t h1, \
- bus_size_t o1, bus_space_handle_t h2, \
- bus_size_t o2, bus_size_t c) \
-{ \
- volatile __TYPENAME(BITS) *addr1 = (void *)(h1 + o1); \
- volatile __TYPENAME(BITS) *addr2 = (void *)(h2 + o2); \
- _BUS_SPACE_ACCESS_HOOK(); \
- \
- if (addr1 >= addr2) { /* src after dest: copy forward */ \
- while (c--) \
- *addr2++ = *addr1++; \
- } else { /* dest after src: copy backwards */ \
- addr1 += c - 1; \
- addr2 += c - 1; \
- while (c--) \
- *addr2-- = *addr1--; \
- } \
-}
+#include <hpcsh/bus_util.h>
#define _BUS_SPACE_ACCESS_HOOK() ((void)0)
_BUS_SPACE_READ(_bus_space, 1, 8)
diff -r 68e80738a9cc -r 20d393dd7914 sys/arch/hpcsh/include/bus_util.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcsh/include/bus_util.h Wed Jul 20 20:46:49 2011 +0000
@@ -0,0 +1,133 @@
+#ifndef _SH3_BUS_UTIL_H_
+#define _SH3_BUS_UTIL_H_
+/*
+ * Utility macros; INTERNAL USE ONLY.
+ */
+
+#define __TYPENAME(BITS) u_int##BITS##_t
+
+#define _BUS_SPACE_READ(PREFIX, BYTES, BITS) \
+__TYPENAME(BITS) \
+PREFIX##_read_##BYTES(void *, bus_space_handle_t, bus_size_t); \
+__TYPENAME(BITS) \
+PREFIX##_read_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset) \
+{ \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ return *(volatile __TYPENAME(BITS) *)(bsh + offset); \
+}
+
+#define _BUS_SPACE_READ_MULTI(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_read_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ __TYPENAME(BITS) *, bus_size_t); \
+void \
+PREFIX##_read_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset, __TYPENAME(BITS) *addr, \
+ bus_size_t count) \
+{ \
+ volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ while (count--) \
+ *addr++ = *p; \
+}
+
+#define _BUS_SPACE_READ_REGION(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_read_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ __TYPENAME(BITS) *, bus_size_t); \
+void \
+PREFIX##_read_region_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset, __TYPENAME(BITS) *addr, \
+ bus_size_t count) \
+{ \
+ volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ while (count--) \
+ *addr++ = *p++; \
+}
+
+#define _BUS_SPACE_WRITE(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_write_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ __TYPENAME(BITS)); \
+void \
+PREFIX##_write_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset, __TYPENAME(BITS) value) \
+{ \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ *(volatile __TYPENAME(BITS) *)(bsh + offset) = value; \
+}
+
+#define _BUS_SPACE_WRITE_MULTI(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_write_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ const __TYPENAME(BITS) *, bus_size_t); \
+void \
+PREFIX##_write_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset, \
+ const __TYPENAME(BITS) *addr, \
+ bus_size_t count) \
+{ \
+ volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ while (count--) \
+ *p = *addr++; \
+}
+
+#define _BUS_SPACE_WRITE_REGION(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_write_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ const __TYPENAME(BITS) *, bus_size_t); \
+void \
+PREFIX##_write_region_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset, \
+ const __TYPENAME(BITS) *addr, \
+ bus_size_t count) \
+{ \
+ volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ while (count--) \
+ *p++ = *addr++; \
+}
+
+#define _BUS_SPACE_SET_MULTI(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_set_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ __TYPENAME(BITS), bus_size_t); \
+void \
+PREFIX##_set_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
+ bus_size_t offset, __TYPENAME(BITS) value, \
+ bus_size_t count) \
+{ \
+ volatile __TYPENAME(BITS) *p = (void *)(bsh + offset); \
+ _BUS_SPACE_ACCESS_HOOK(); \
+ while (count--) \
+ *p = value; \
+}
+
+#define _BUS_SPACE_COPY_REGION(PREFIX, BYTES, BITS) \
+void \
+PREFIX##_copy_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
+ bus_space_handle_t, bus_size_t, \
+ bus_size_t); \
Home |
Main Index |
Thread Index |
Old Index