summaryrefslogtreecommitdiff
path: root/sys/arch/arm
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2004-12-30 23:24:58 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2004-12-30 23:24:58 +0000
commit99739e26db053934d480e48bb971df5258ab0895 (patch)
tree85471047c0e1b4fa6de3633f0fc27117a1703450 /sys/arch/arm
parent47664320d338d7cc36f94d1e6261780ec1f7bf00 (diff)
Fix (and de-inline) bus_space_(read|write)_raw* functions, they did
not terminate correctly on odd length, they still truncate the transfer.
Diffstat (limited to 'sys/arch/arm')
-rw-r--r--sys/arch/arm/arm/bus_dma.c43
-rw-r--r--sys/arch/arm/include/bus.h65
2 files changed, 42 insertions, 66 deletions
diff --git a/sys/arch/arm/arm/bus_dma.c b/sys/arch/arm/arm/bus_dma.c
index 81e13a54251..4e327f01ceb 100644
--- a/sys/arch/arm/arm/bus_dma.c
+++ b/sys/arch/arm/arm/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.4 2004/12/25 23:02:23 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.5 2004/12/30 23:24:57 drahn Exp $ */
/* $NetBSD: bus_dma.c,v 1.38 2003/10/30 08:44:13 scw Exp $ */
/*-
@@ -1070,3 +1070,44 @@ arm32_dma_range_intersect(struct arm32_dma_range *ranges, int nranges,
/* No intersection found. */
return (0);
}
+
+/*
+ * probably should be ppc_space_copy
+ */
+
+#define _CONCAT(A,B) A ## B
+#define __C(A,B) _CONCAT(A,B)
+
+#define BUS_SPACE_READ_RAW_MULTI_N(BYTES,SHIFT,TYPE) \
+void \
+__C(bus_space_read_raw_multi_,BYTES)(bus_space_tag_t bst, \
+ bus_space_handle_t h, bus_addr_t o, u_int8_t *dst, bus_size_t size) \
+{ \
+ TYPE *rdst = (TYPE *)dst; \
+ int i; \
+ int count = size >> SHIFT; \
+ \
+ for (i = 0; i < count; i++) { \
+ rdst[i] = __bs_rs(BYTES, bst, h, o); \
+ } \
+}
+BUS_SPACE_READ_RAW_MULTI_N(2,1,u_int16_t)
+BUS_SPACE_READ_RAW_MULTI_N(4,2,u_int32_t)
+
+#define BUS_SPACE_WRITE_RAW_MULTI_N(BYTES,SHIFT,TYPE) \
+void \
+__C(bus_space_write_raw_multi_,BYTES)( bus_space_tag_t bst, \
+ bus_space_handle_t h, bus_addr_t o, const u_int8_t *src, \
+ bus_size_t size) \
+{ \
+ int i; \
+ TYPE *rsrc = (TYPE *)src; \
+ int count = size >> SHIFT; \
+ \
+ for (i = 0; i < count; i++) { \
+ __bs_ws(BYTES, bst, h, o, rsrc[i]); \
+ } \
+}
+
+BUS_SPACE_WRITE_RAW_MULTI_N(2,1,u_int16_t)
+BUS_SPACE_WRITE_RAW_MULTI_N(4,2,u_int32_t)
diff --git a/sys/arch/arm/include/bus.h b/sys/arch/arm/include/bus.h
index b4d1713078d..d374dc7c803 100644
--- a/sys/arch/arm/include/bus.h
+++ b/sys/arch/arm/include/bus.h
@@ -985,7 +985,6 @@ int _bus_dmamem_alloc_range (bus_dma_tag_t tag, bus_size_t size,
vaddr_t low, vaddr_t high);
#endif /* _ARM32_BUS_DMA_PRIVATE */
/* These are OpenBSD extensions to the general NetBSD bus interface. */
-#if 0
void
bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
bus_addr_t ba, u_int8_t *dst, bus_size_t size);
@@ -1004,70 +1003,6 @@ bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
#define bus_space_write_raw_multi_8 \
!!! bus_space_write_raw_multi_8 not implemented !!!
-#else
-/* BLECH XXXDSR */
-static inline void
-bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, u_int8_t *dst, bus_size_t size);
-static inline void
-bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, u_int8_t *dst, bus_size_t size)
-{
- u_int16_t *datap = (u_int16_t *)dst;
- while (size > 0) {
- *datap =bus_space_read_2(bst, bsh, ba);
- datap++;
- size -= 2;
- }
-}
-static inline void
-bus_space_read_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, u_int8_t *dst, bus_size_t size);
-static inline void
-bus_space_read_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, u_int8_t *dst, bus_size_t size)
-{
- u_int32_t *datap = (u_int32_t *)dst;
- while (size > 0) {
- *datap =bus_space_read_4(bst, bsh, ba);
- datap++;
- size -= 4;
- }
-}
-
-static inline void
-bus_space_write_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, const u_int8_t *src, bus_size_t size);
-static inline void
-bus_space_write_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, const u_int8_t *src, bus_size_t size)
-{
- u_int16_t *datap = (u_int16_t *)src;
- while (size > 0) {
- bus_space_write_2(bst, bsh, ba, *datap);
- datap++;
- size -= 2;
- }
-}
-static inline void
-bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, const u_int8_t *src, bus_size_t size);
-static inline void
-bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
- bus_addr_t ba, const u_int8_t *src, bus_size_t size)
-{
- u_int32_t *datap = (u_int32_t *)src;
- while (size > 0) {
- bus_space_write_4(bst, bsh, ba, *datap);
- datap++;
- size -= 4;
- }
-}
-#define bus_space_write_raw_multi_8 \
- !!! bus_space_write_raw_multi_8 not implemented !!!
-
-#endif
-
/*
* void bus_space_read_raw_region_N(bus_space_tag_t tag,
* bus_space_handle_t bsh, bus_size_t offset,