Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic While am79c930 controller allows unaligned access...
details: https://anonhg.NetBSD.org/src/rev/bb58566b6501
branches: trunk
changeset: 484030:bb58566b6501
user: onoe <onoe%NetBSD.org@localhost>
date: Thu Mar 23 13:57:58 2000 +0000
description:
While am79c930 controller allows unaligned access, bus_space_read/write
must be aligned. So awi_read/write_2/4 issues multiple bsr1/bsw1 when
unaligned.
diffstat:
sys/dev/ic/am79c930.c | 44 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 5 deletions(-)
diffs (78 lines):
diff -r 56ea452eba23 -r bb58566b6501 sys/dev/ic/am79c930.c
--- a/sys/dev/ic/am79c930.c Thu Mar 23 13:49:49 2000 +0000
+++ b/sys/dev/ic/am79c930.c Thu Mar 23 13:57:58 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: am79c930.c,v 1.4 2000/03/22 11:22:22 onoe Exp $ */
+/* $NetBSD: am79c930.c,v 1.5 2000/03/23 13:57:58 onoe Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -290,7 +290,16 @@
u_int32_t off;
u_int16_t val;
{
- bus_space_write_2(sc->sc_memt, sc->sc_memh, off, val);
+ bus_space_tag_t t = sc->sc_memt;
+ bus_space_handle_t h = sc->sc_memh;
+
+ /* could be unaligned */
+ if ((off & 0x1) == 0)
+ bus_space_write_2(t, h, off, val);
+ else {
+ bus_space_write_1(t, h, off, val & 0xff);
+ bus_space_write_1(t, h, off+1, (val >> 8) & 0xff);
+ }
}
static void mem_write_4 (sc, off, val)
@@ -298,7 +307,18 @@
u_int32_t off;
u_int32_t val;
{
- bus_space_write_4(sc->sc_memt, sc->sc_memh, off, val);
+ bus_space_tag_t t = sc->sc_memt;
+ bus_space_handle_t h = sc->sc_memh;
+
+ /* could be unaligned */
+ if ((off & 0x3) == 0)
+ bus_space_write_4(t, h, off, val);
+ else {
+ bus_space_write_1(t, h, off, val & 0xff);
+ bus_space_write_1(t, h, off+1, (val >> 8) & 0xff);
+ bus_space_write_1(t, h, off+2, (val >> 16) & 0xff);
+ bus_space_write_1(t, h, off+3, (val >> 24) & 0xff);
+ }
}
static void mem_write_bytes (sc, off, ptr, len)
@@ -322,14 +342,28 @@
struct am79c930_softc *sc;
u_int32_t off;
{
- return bus_space_read_2(sc->sc_memt, sc->sc_memh, off);
+ /* could be unaligned */
+ if ((off & 0x1) == 0)
+ return bus_space_read_2(sc->sc_memt, sc->sc_memh, off);
+ else
+ return
+ bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) |
+ (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8);
}
static u_int32_t mem_read_4 (sc, off)
struct am79c930_softc *sc;
u_int32_t off;
{
- return bus_space_read_4(sc->sc_memt, sc->sc_memh, off);
+ /* could be unaligned */
+ if ((off & 0x3) == 0)
+ return bus_space_read_4(sc->sc_memt, sc->sc_memh, off);
+ else
+ return
+ bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) |
+ (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8) |
+ (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+2) <<16) |
+ (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+3) <<24);
}
Home |
Main Index |
Thread Index |
Old Index