summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1997-09-09 22:41:44 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1997-09-09 22:41:44 +0000
commitc98e165cb31c6c98e326a9ffaa1a3d79a258a310 (patch)
tree68904e1c354932ea506ff096df3c3668df49f0eb /sys
parentaa9c49cac5f14a7bdf649403d8981d2a6c5e815c (diff)
Make the bus_addr_t shift amount in addr calculations dynamic
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amiga/include/bus.h17
-rw-r--r--sys/arch/amiga/isa/cross.c5
-rw-r--r--sys/arch/amiga/isa/ggbus.c4
3 files changed, 16 insertions, 10 deletions
diff --git a/sys/arch/amiga/include/bus.h b/sys/arch/amiga/include/bus.h
index 2bba681b4cf..87d8332a4a1 100644
--- a/sys/arch/amiga/include/bus.h
+++ b/sys/arch/amiga/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.4 1997/02/21 10:59:16 niklas Exp $ */
+/* $OpenBSD: bus.h,v 1.5 1997/09/09 22:41:42 niklas Exp $ */
/*
* Copyright (c) 1996 Niklas Hallqvist.
@@ -59,6 +59,9 @@ struct amiga_bus_space {
/* We need swapping of 16-bit entities */
int bs_swapped;
+
+ /* How much to shift an bus_addr_t */
+ int bs_shift;
};
#define bus_space_map(t, port, size, cacheable, bshp) \
@@ -77,13 +80,13 @@ swap(u_int16_t x)
static __inline u_int8_t
bus_space_read_1(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba)
{
- return *(volatile u_int8_t *)(bsh + (ba << 1));
+ return *(volatile u_int8_t *)(bsh + (ba << bst->bs_shift));
}
static __inline u_int16_t
bus_space_read_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba)
{
- register u_int16_t x = *(volatile u_int16_t *)((bsh & ~1) + (ba << 1));
+ u_int16_t x = *(volatile u_int16_t *)(bsh + (ba << bst->bs_shift));
return bst->bs_swapped ? swap(x) : x;
}
@@ -134,14 +137,14 @@ static __inline void
bus_space_write_1(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba,
u_int8_t x)
{
- *(volatile u_int8_t *)(bsh + (ba << 1)) = x;
+ *(volatile u_int8_t *)(bsh + (ba << bst->bs_shift)) = x;
}
static __inline void
bus_space_write_2(bus_space_tag_t bst, bus_space_handle_t bsh, bus_addr_t ba,
u_int16_t x)
{
- *(volatile u_int16_t *)((bsh & ~1) + (ba << 1)) =
+ *(volatile u_int16_t *)(bsh + (ba << bst->bs_shift)) =
bst->bs_swapped ? swap(x) : x;
}
@@ -197,7 +200,7 @@ bus_space_read_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
while (cnt) {
register u_int16_t x =
- *(volatile u_int16_t *)((bsh & ~1) + (ba << 1));
+ *(volatile u_int16_t *)(bsh + (ba << bst->bs_shift));
*buf16++ = bst->bs_swapped ? x : swap(x);
cnt -= 2;
@@ -222,7 +225,7 @@ bus_space_write_raw_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
register const u_int16_t *buf16 = (const u_int16_t *)buf;
while (cnt) {
- *(volatile u_int16_t *)((bsh & ~1) + (ba << 1)) =
+ *(volatile u_int16_t *)(bsh + (ba << bst->bs_shift)) =
bst->bs_swapped ? *buf16 : swap(*buf16);
buf16++;
cnt -= 2;
diff --git a/sys/arch/amiga/isa/cross.c b/sys/arch/amiga/isa/cross.c
index 826beac0d81..bdd3ffdadb9 100644
--- a/sys/arch/amiga/isa/cross.c
+++ b/sys/arch/amiga/isa/cross.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cross.c,v 1.9 1997/01/05 02:04:33 niklas Exp $ */
+/* $OpenBSD: cross.c,v 1.10 1997/09/09 22:41:43 niklas Exp $ */
/*
* Copyright (c) 1994, 1996 Niklas Hallqvist, Carsten Hammer
@@ -135,11 +135,12 @@ crossattach(parent, self, aux)
sc->sc_iot.bs_map = cross_io_map;
sc->sc_iot.bs_unmap = cross_io_unmap;
sc->sc_iot.bs_swapped = 1;
+ sc->sc_iot.bs_shift = 1;
sc->sc_memt.bs_data = sc;
sc->sc_memt.bs_map = cross_mem_map;
sc->sc_memt.bs_unmap = cross_mem_unmap;
- sc->sc_memt.bs_swapped = 1;
+ sc->sc_memt.bs_shift = 1;
sc->sc_ic.ic_data = sc;
sc->sc_ic.ic_attach_hook = cross_attach_hook;
diff --git a/sys/arch/amiga/isa/ggbus.c b/sys/arch/amiga/isa/ggbus.c
index 8a34f10dbc6..5ea6c3cafda 100644
--- a/sys/arch/amiga/isa/ggbus.c
+++ b/sys/arch/amiga/isa/ggbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ggbus.c,v 1.9 1997/01/04 12:49:24 niklas Exp $ */
+/* $OpenBSD: ggbus.c,v 1.10 1997/09/09 22:41:43 niklas Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Niklas Hallqvist
@@ -113,11 +113,13 @@ ggbusattach(parent, self, aux)
sc->sc_iot.bs_map = ggbus_io_map;
sc->sc_iot.bs_unmap = ggbus_unmap;
sc->sc_iot.bs_swapped = 0;
+ sc->sc_iot.bs_shift = 1;
if (sc->sc_zargs.serno >= 2) {
sc->sc_memt.bs_data = sc;
sc->sc_memt.bs_map = ggbus_mem_map;
sc->sc_memt.bs_unmap = ggbus_unmap;
sc->sc_memt.bs_swapped = 0;
+ sc->sc_memt.bs_shift = 1;
sc->sc_status = GG2_STATUS_ADDR(sc->sc_zargs.va);
/* XXX turn on wait states unconditionally for now. */