-/* $OpenBSD: bus.h,v 1.6 1997/03/21 00:16:32 niklas Exp $ */
+/* $OpenBSD: bus.h,v 1.7 1997/04/02 22:08:07 niklas Exp $ */
/* $NetBSD: bus.h,v 1.10 1996/12/02 22:19:32 cgd Exp $ */
/*
bus_space_handle_t, bus_size_t, bus_size_t));
void (*abs_c_8) __P((void *, bus_space_handle_t, bus_size_t,
bus_space_handle_t, bus_size_t, bus_size_t));
+
+ /* OpenBSD extensions follows */
+
+ /* read multiple raw */
+ void (*abs_rrm_2) __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+ void (*abs_rrm_4) __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+ void (*abs_rrm_8) __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+
+ /* write multiple raw */
+ void (*abs_wrm_2) __P((void *, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t));
+ void (*abs_wrm_4) __P((void *, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t));
+ void (*abs_wrm_8) __P((void *, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t));
};
(*(t)->__abs_opname(r,sz))((t)->abs_cookie, h, o)
#define __abs_ws(sz, t, h, o, v) \
(*(t)->__abs_opname(w,sz))((t)->abs_cookie, h, o, v)
-#ifndef DEBUG
#define __abs_nonsingle(type, sz, t, h, o, a, c) \
(*(t)->__abs_opname(type,sz))((t)->abs_cookie, h, o, a, c)
+#ifndef DEBUG
+#define __abs_aligned_nonsingle(type, sz, t, h, o, a, c) \
+ __abs_nonsingle((type), (sz), (t), (h), (o), (a), (c))
+
#else
-#define __abs_nonsingle(type, sz, t, h, o, a, c) \
+#define __abs_aligend_nonsingle(type, sz, t, h, o, a, c) \
do { \
if (((unsigned long)a & (sz - 1)) != 0) \
panic("bus non-single %d-byte unaligned (to %p) at %s:%d", \
#define __abs_copy(sz, t, h1, o1, h2, o2, cnt) \
(*(t)->__abs_opname(c,sz))((t)->abs_cookie, h1, o1, h2, o2, cnt)
-
/*
* Mapping and unmapping operations.
*/
#define bus_space_read_multi_1(t, h, o, a, c) \
__abs_nonsingle(rm,1,(t),(h),(o),(a),(c))
#define bus_space_read_multi_2(t, h, o, a, c) \
- __abs_nonsingle(rm,2,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(rm,2,(t),(h),(o),(a),(c))
#define bus_space_read_multi_4(t, h, o, a, c) \
- __abs_nonsingle(rm,4,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(rm,4,(t),(h),(o),(a),(c))
#define bus_space_read_multi_8(t, h, o, a, c) \
- __abs_nonsingle(rm,8,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(rm,8,(t),(h),(o),(a),(c))
/*
* possible byte-swapping should be done by these functions.
*/
-#define bus_space_read_raw_multi_2(t, h, o, a, c) \
- bus_space_read_multi_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
-#define bus_space_read_raw_multi_4(t, h, o, a, c) \
- bus_space_read_multi_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
-#define bus_space_read_raw_multi_8(t, h, o, a, c) \
- bus_space_read_multi_8((t), (h), (o), (u_int64_t *)(a), (c) >> 4)
+#define bus_space_read_raw_multi_2(t, h, o, a, c) \
+ __abs_nonsingle(rrm,2,(t),(h),(o),(a),(c))
+#define bus_space_read_raw_multi_4(t, h, o, a, c) \
+ __abs_nonsingle(rrm,4,(t),(h),(o),(a),(c))
+#define bus_space_read_raw_multi_8(t, h, o, a, c) \
+ __abs_nonsingle(rrm,8,(t),(h),(o),(a),(c))
/*
* Bus read region operations.
#define bus_space_read_region_1(t, h, o, a, c) \
__abs_nonsingle(rr,1,(t),(h),(o),(a),(c))
#define bus_space_read_region_2(t, h, o, a, c) \
- __abs_nonsingle(rr,2,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(rr,2,(t),(h),(o),(a),(c))
#define bus_space_read_region_4(t, h, o, a, c) \
- __abs_nonsingle(rr,4,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(rr,4,(t),(h),(o),(a),(c))
#define bus_space_read_region_8(t, h, o, a, c) \
- __abs_nonsingle(rr,8,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(rr,8,(t),(h),(o),(a),(c))
/*
#define bus_space_write_multi_1(t, h, o, a, c) \
__abs_nonsingle(wm,1,(t),(h),(o),(a),(c))
#define bus_space_write_multi_2(t, h, o, a, c) \
- __abs_nonsingle(wm,2,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(wm,2,(t),(h),(o),(a),(c))
#define bus_space_write_multi_4(t, h, o, a, c) \
- __abs_nonsingle(wm,4,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(wm,4,(t),(h),(o),(a),(c))
#define bus_space_write_multi_8(t, h, o, a, c) \
- __abs_nonsingle(wm,8,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(wm,8,(t),(h),(o),(a),(c))
/*
* void bus_space_write_raw_multi_N __P((bus_space_tag_t tag,
* possible byte-swapping should be done by these functions.
*/
-#define bus_space_write_raw_multi_2(t, h, o, a, c) \
- bus_space_write_multi_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
-#define bus_space_write_raw_multi_4(t, h, o, a, c) \
- bus_space_write_multi_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
-#define bus_space_write_raw_multi_8(t, h, o, a, c) \
- bus_space_write_multi_8((t), (h), (o), (u_int64_t *)(a), (c) >> 4)
+#define bus_space_write_raw_multi_2(t, h, o, a, c) \
+ __abs_nonsingle(wrm,2,(t),(h),(o),(a),(c))
+#define bus_space_write_raw_multi_4(t, h, o, a, c) \
+ __abs_nonsingle(wrm,4,(t),(h),(o),(a),(c))
+#define bus_space_write_raw_multi_8(t, h, o, a, c) \
+ __abs_nonsingle(wrm,8,(t),(h),(o),(a),(c))
/*
* Bus write region operations.
#define bus_space_write_region_1(t, h, o, a, c) \
__abs_nonsingle(wr,1,(t),(h),(o),(a),(c))
#define bus_space_write_region_2(t, h, o, a, c) \
- __abs_nonsingle(wr,2,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(wr,2,(t),(h),(o),(a),(c))
#define bus_space_write_region_4(t, h, o, a, c) \
- __abs_nonsingle(wr,4,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(wr,4,(t),(h),(o),(a),(c))
#define bus_space_write_region_8(t, h, o, a, c) \
- __abs_nonsingle(wr,8,(t),(h),(o),(a),(c))
+ __abs_aligned_nonsingle(wr,8,(t),(h),(o),(a),(c))
/*
-/* $OpenBSD: pcs_bus_io_common.c,v 1.5 1997/01/24 19:57:55 niklas Exp $ */
+/* $OpenBSD: pcs_bus_io_common.c,v 1.6 1997/04/02 22:08:09 niklas Exp $ */
/* $NetBSD: pcs_bus_io_common.c,v 1.14 1996/12/02 22:19:35 cgd Exp $ */
/*
void __C(CHIP,_io_copy_8) __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
+/* read multiple raw */
+void __C(CHIP,_io_read_raw_multi_2) __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+void __C(CHIP,_io_read_raw_multi_4) __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+void __C(CHIP,_io_read_raw_multi_8) __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+
+/* write multiple raw */
+void __C(CHIP,_io_write_raw_multi_2) __P((void *,
+ bus_space_handle_t, bus_size_t, const u_int8_t *,
+ bus_size_t));
+void __C(CHIP,_io_write_raw_multi_4) __P((void *,
+ bus_space_handle_t, bus_size_t, const u_int8_t *,
+ bus_size_t));
+void __C(CHIP,_io_write_raw_multi_8) __P((void *,
+ bus_space_handle_t, bus_size_t, const u_int8_t *,
+ bus_size_t));
+
static long
__C(CHIP,_io_ex_storage)[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
__C(CHIP,_io_copy_2),
__C(CHIP,_io_copy_4),
__C(CHIP,_io_copy_8),
+
+ /* read multiple raw */
+ __C(CHIP,_io_read_raw_multi_2),
+ __C(CHIP,_io_read_raw_multi_4),
+ __C(CHIP,_io_read_raw_multi_8),
+
+ /* write multiple raw*/
+ __C(CHIP,_io_write_raw_multi_2),
+ __C(CHIP,_io_write_raw_multi_4),
+ __C(CHIP,_io_write_raw_multi_8),
};
bus_space_tag_t
CHIP_io_copy_N(2)
CHIP_io_copy_N(4)
CHIP_io_copy_N(8)
+
+#define CHIP_io_read_raw_multi_N(BYTES,TYPE) \
+void \
+__C(__C(CHIP,_io_read_raw_multi_),BYTES)(v, h, o, a, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ bus_size_t o, c; \
+ u_int8_t *a; \
+{ \
+ TYPE temp; \
+ int i; \
+ \
+ while (c > 0) { \
+ __C(CHIP,_io_barrier)(v, h, o, BYTES, BUS_BARRIER_READ); \
+ temp = __C(__C(CHIP,_io_read_),BYTES)(v, h, o); \
+ for (i = 0; i < BYTES; i++) { \
+ *a++ = temp & 0xff; \
+ temp >>= 8; \
+ } \
+ c -= BYTES; \
+ } \
+}
+CHIP_io_read_raw_multi_N(2,u_int16_t)
+CHIP_io_read_raw_multi_N(4,u_int32_t)
+CHIP_io_read_raw_multi_N(8,u_int64_t)
+
+#define CHIP_io_write_raw_multi_N(BYTES,TYPE) \
+void \
+__C(__C(CHIP,_io_write_raw_multi_),BYTES)(v, h, o, a, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ bus_size_t o, c; \
+ const u_int8_t *a; \
+{ \
+ TYPE temp; \
+ int i; \
+ \
+ while (c > 0) { \
+ temp = 0; \
+ for (i = BYTES - 1; i >= 0; i--) { \
+ temp <<= 8; \
+ temp |= *(a + i); \
+ } \
+ __C(__C(CHIP,_io_write_),BYTES)(v, h, o, temp); \
+ __C(CHIP,_io_barrier)(v, h, o, BYTES, BUS_BARRIER_WRITE); \
+ c -= BYTES; \
+ a += BYTES; \
+ } \
+}
+CHIP_io_write_raw_multi_N(2,u_int16_t)
+CHIP_io_write_raw_multi_N(4,u_int32_t)
+CHIP_io_write_raw_multi_N(8,u_int64_t)
-/* $OpenBSD: pcs_bus_mem_common.c,v 1.5 1997/01/24 19:57:56 niklas Exp $ */
+/* $OpenBSD: pcs_bus_mem_common.c,v 1.6 1997/04/02 22:08:09 niklas Exp $ */
/* $NetBSD: pcs_bus_mem_common.c,v 1.15 1996/12/02 22:19:36 cgd Exp $ */
/*
void __C(CHIP,_mem_copy_8) __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
+/* read multiple raw */
+void __C(CHIP,_mem_read_raw_multi_2) __P((void *,
+ bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
+void __C(CHIP,_mem_read_raw_multi_4) __P((void *,
+ bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
+void __C(CHIP,_mem_read_raw_multi_8) __P((void *,
+ bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
+
+/* write multiple raw */
+void __C(CHIP,_mem_write_raw_multi_2) __P((void *,
+ bus_space_handle_t, bus_size_t, const u_int8_t *,
+ bus_size_t));
+void __C(CHIP,_mem_write_raw_multi_4) __P((void *,
+ bus_space_handle_t, bus_size_t, const u_int8_t *,
+ bus_size_t));
+void __C(CHIP,_mem_write_raw_multi_8) __P((void *,
+ bus_space_handle_t, bus_size_t, const u_int8_t *,
+ bus_size_t));
+
static long
__C(CHIP,_dmem_ex_storage)[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
static long
__C(CHIP,_mem_copy_2),
__C(CHIP,_mem_copy_4),
__C(CHIP,_mem_copy_8),
+
+ /* read multiple raw */
+ __C(CHIP,_mem_read_raw_multi_2),
+ __C(CHIP,_mem_read_raw_multi_4),
+ __C(CHIP,_mem_read_raw_multi_8),
+
+ /* write multiple raw*/
+ __C(CHIP,_mem_write_raw_multi_2),
+ __C(CHIP,_mem_write_raw_multi_4),
+ __C(CHIP,_mem_write_raw_multi_8),
};
bus_space_tag_t
CHIP_mem_copy_N(2)
CHIP_mem_copy_N(4)
CHIP_mem_copy_N(8)
+
+#define CHIP_mem_read_raw_multi_N(BYTES,TYPE) \
+void \
+__C(__C(CHIP,_mem_read_raw_multi_),BYTES)(v, h, o, a, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ bus_size_t o, c; \
+ u_int8_t *a; \
+{ \
+ TYPE temp; \
+ int i; \
+ \
+ while (c > 0) { \
+ __C(CHIP,_mem_barrier)(v, h, o, BYTES, BUS_BARRIER_READ); \
+ temp = __C(__C(CHIP,_mem_read_),BYTES)(v, h, o); \
+ for (i = 0; i < BYTES; i++) { \
+ *a++ = temp & 0xff; \
+ temp >>= 8; \
+ } \
+ c -= BYTES; \
+ } \
+}
+CHIP_mem_read_raw_multi_N(2,u_int16_t)
+CHIP_mem_read_raw_multi_N(4,u_int32_t)
+CHIP_mem_read_raw_multi_N(8,u_int64_t)
+
+#define CHIP_mem_write_raw_multi_N(BYTES,TYPE) \
+void \
+__C(__C(CHIP,_mem_write_raw_multi_),BYTES)(v, h, o, a, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ bus_size_t o, c; \
+ const u_int8_t *a; \
+{ \
+ TYPE temp; \
+ int i; \
+ \
+ while (c > 0) { \
+ temp = 0; \
+ for (i = BYTES - 1; i >= 0; i--) { \
+ temp <<= 8; \
+ temp |= *(a + i); \
+ } \
+ __C(__C(CHIP,_mem_write_),BYTES)(v, h, o, temp); \
+ __C(CHIP,_mem_barrier)(v, h, o, BYTES, BUS_BARRIER_WRITE); \
+ c -= BYTES; \
+ a += BYTES; \
+ } \
+}
+CHIP_mem_write_raw_multi_N(2,u_int16_t)
+CHIP_mem_write_raw_multi_N(4,u_int32_t)
+CHIP_mem_write_raw_multi_N(8,u_int64_t)
-/* $OpenBSD: tc_bus_mem.c,v 1.6 1997/01/24 19:58:19 niklas Exp $ */
+/* $OpenBSD: tc_bus_mem.c,v 1.7 1997/04/02 22:08:10 niklas Exp $ */
/* $NetBSD: tc_bus_mem.c,v 1.13 1996/12/02 22:19:34 cgd Exp $ */
/*
void tc_mem_copy_8 __P((void *, bus_space_handle_t,
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
+/* read multiple raw */
+void tc_mem_read_raw_multi_2 __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+void tc_mem_read_raw_multi_4 __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+void tc_mem_read_raw_multi_8 __P((void *, bus_space_handle_t,
+ bus_size_t, u_int8_t *, bus_size_t));
+
+/* write multiple raw */
+void tc_mem_write_raw_multi_2 __P((void *, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t));
+void tc_mem_write_raw_multi_4 __P((void *, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t));
+void tc_mem_write_raw_multi_8 __P((void *, bus_space_handle_t,
+ bus_size_t, const u_int8_t *, bus_size_t));
+
static struct alpha_bus_space tc_mem_space = {
/* cookie */
NULL,
tc_mem_copy_2,
tc_mem_copy_4,
tc_mem_copy_8,
+
+ /* write multiple raw */
+ tc_mem_read_raw_multi_2,
+ tc_mem_read_raw_multi_4,
+ tc_mem_read_raw_multi_8,
+
+ /* write multiple raw*/
+ tc_mem_write_raw_multi_2,
+ tc_mem_write_raw_multi_4,
+ tc_mem_write_raw_multi_8,
};
bus_space_tag_t
tc_mem_copy_N(2)
tc_mem_copy_N(4)
tc_mem_copy_N(8)
+
+#define tc_mem_read_raw_multi_N(BYTES,TYPE) \
+void \
+__C(tc_mem_read_raw_multi_,BYTES)(v, h, o, a, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ bus_size_t o, c; \
+ u_int8_t *a; \
+{ \
+ TYPE temp; \
+ int i; \
+ \
+ while (c > 0) { \
+ tc_mem_barrier(v, h, o, BYTES, BUS_BARRIER_READ); \
+ temp = __C(tc_mem_read_,BYTES)(v, h, o); \
+ for (i = 0; i < BYTES; i++) { \
+ *a++ = temp & 0xff; \
+ temp >>= 8; \
+ } \
+ c -= BYTES; \
+ } \
+}
+tc_mem_read_raw_multi_N(2,u_int16_t)
+tc_mem_read_raw_multi_N(4,u_int32_t)
+tc_mem_read_raw_multi_N(8,u_int64_t)
+
+#define tc_mem_write_raw_multi_N(BYTES,TYPE) \
+void \
+__C(tc_mem_write_raw_multi_,BYTES)(v, h, o, a, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ bus_size_t o, c; \
+ const u_int8_t *a; \
+{ \
+ TYPE temp; \
+ int i; \
+ \
+ while (c > 0) { \
+ temp = 0; \
+ for (i = BYTES - 1; i >= 0; i--) { \
+ temp <<= 8; \
+ temp |= *(a + i); \
+ } \
+ __C(tc_mem_write_,BYTES)(v, h, o, temp); \
+ tc_mem_barrier(v, h, o, BYTES, BUS_BARRIER_WRITE); \
+ c -= BYTES; \
+ a += BYTES; \
+ } \
+}
+tc_mem_write_raw_multi_N(2,u_int16_t)
+tc_mem_write_raw_multi_N(4,u_int32_t)
+tc_mem_write_raw_multi_N(8,u_int64_t)