PERFORCE change 109868 for review
Sam Leffler
sam at FreeBSD.org
Mon Nov 13 18:58:42 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=109868
Change 109868 by sam at sam_ebb on 2006/11/13 18:55:35
Workaround ata driver: create bus_space stream read/write multi
ops that byte swap and undo change to the driver. When the
driver is fixed we can undo this damage.
Affected files ...
.. //depot/projects/arm/src/sys/arm/xscale/ixp425/avila_ata.c#9 edit
.. //depot/projects/arm/src/sys/dev/ata/ata-all.c#14 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/xscale/ixp425/avila_ata.c#9 (text+ko) ====
@@ -45,6 +45,7 @@
#include <sys/resource.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
+#include <sys/endian.h>
#include <machine/bus.h>
#include <machine/cpu.h>
@@ -83,6 +84,10 @@
static void ata_avila_intr(void *);
bs_protos(ata);
+static void ata_bs_rm_2_s(void *, bus_space_handle_t, bus_size_t,
+ u_int16_t *, bus_size_t);
+static void ata_bs_wm_2_s(void *, bus_space_handle_t, bus_size_t,
+ const u_int16_t *, bus_size_t);
static int
ata_avila_probe(device_t dev)
@@ -116,25 +121,17 @@
*/
sc->sc_expbus_tag.bs_cookie = sc; /* NB: backpointer */
/* read single */
- sc->sc_expbus_tag.bs_r_1_s = ata_bs_r_1,
- sc->sc_expbus_tag.bs_r_2_s = ata_bs_r_2,
sc->sc_expbus_tag.bs_r_1 = ata_bs_r_1,
sc->sc_expbus_tag.bs_r_2 = ata_bs_r_2,
/* read multiple */
- sc->sc_expbus_tag.bs_rm_1 = ata_bs_rm_1,
- sc->sc_expbus_tag.bs_rm_1_s = ata_bs_rm_1,
sc->sc_expbus_tag.bs_rm_2 = ata_bs_rm_2,
- sc->sc_expbus_tag.bs_rm_2_s = ata_bs_rm_2,
+ sc->sc_expbus_tag.bs_rm_2_s = ata_bs_rm_2_s,
/* write (single) */
- sc->sc_expbus_tag.bs_w_1_s = ata_bs_w_1,
- sc->sc_expbus_tag.bs_w_2_s = ata_bs_w_2,
sc->sc_expbus_tag.bs_w_1 = ata_bs_w_1,
sc->sc_expbus_tag.bs_w_2 = ata_bs_w_2,
/* write multiple */
- sc->sc_expbus_tag.bs_wm_1 = ata_bs_wm_1,
- sc->sc_expbus_tag.bs_wm_1_s = ata_bs_wm_1,
sc->sc_expbus_tag.bs_wm_2 = ata_bs_wm_2,
- sc->sc_expbus_tag.bs_wm_2_s = ata_bs_wm_2,
+ sc->sc_expbus_tag.bs_wm_2_s = ata_bs_wm_2_s,
rman_set_bustag(&sc->sc_ata, &sc->sc_expbus_tag);
rman_set_bushandle(&sc->sc_ata, sc->sc_ioh);
@@ -311,42 +308,63 @@
}
void
-ata_bs_rm_1(void *t, bus_space_handle_t h, bus_size_t o,
- u_int8_t *d, bus_size_t c)
+ata_bs_rm_2(void *t, bus_space_handle_t h, bus_size_t o,
+ u_int16_t *d, bus_size_t c)
{
struct ata_avila_softc *sc = t;
- bus_space_read_multi_1(sc->sc_iot, h, o, d, c);
+ enable_16(sc);
+ bus_space_read_multi_2(sc->sc_iot, h, o, d, c);
+ disable_16(sc);
}
void
-ata_bs_wm_1(void *t, bus_space_handle_t h, bus_size_t o,
- const u_int8_t *d, bus_size_t c)
+ata_bs_wm_2(void *t, bus_space_handle_t h, bus_size_t o,
+ const u_int16_t *d, bus_size_t c)
{
struct ata_avila_softc *sc = t;
- bus_space_write_multi_1(sc->sc_iot, h, o, d, c);
+ enable_16(sc);
+ bus_space_write_multi_2(sc->sc_iot, h, o, d, c);
+ disable_16(sc);
}
+/* XXX workaround ata driver by (incorrectly) byte swapping stream cases */
+
void
-ata_bs_rm_2(void *t, bus_space_handle_t h, bus_size_t o,
+ata_bs_rm_2_s(void *t, bus_space_handle_t h, bus_size_t o,
u_int16_t *d, bus_size_t c)
{
struct ata_avila_softc *sc = t;
+ uint16_t v;
+ bus_size_t i;
enable_16(sc);
- bus_space_read_multi_2(sc->sc_iot, h, o, d, c);
+#if 1
+ for (i = 0; i < c; i++) {
+ v = bus_space_read_2(sc->sc_iot, h, o);
+ d[i] = bswap16(v);
+ }
+#else
+ bus_space_read_multi_stream_2(sc->sc_iot, h, o, d, c);
+#endif
disable_16(sc);
}
void
-ata_bs_wm_2(void *t, bus_space_handle_t h, bus_size_t o,
+ata_bs_wm_2_s(void *t, bus_space_handle_t h, bus_size_t o,
const u_int16_t *d, bus_size_t c)
{
struct ata_avila_softc *sc = t;
+ bus_size_t i;
enable_16(sc);
- bus_space_write_multi_2(sc->sc_iot, h, o, d, c);
+#if 1
+ for (i = 0; i < c; i++)
+ bus_space_write_2(sc->sc_iot, h, o, bswap16(d[i]));
+#else
+ bus_space_write_multi_stream_2(sc->sc_iot, h, o, d, c);
+#endif
disable_16(sc);
}
==== //depot/projects/arm/src/sys/dev/ata/ata-all.c#14 (text+ko) ====
@@ -601,8 +601,6 @@
isprint(atadev->param.model[1]))) {
struct ata_params *atacap = &atadev->param;
char buffer[64];
-#if 0
-/* XXX not right on xscale; ditch for now */
#if BYTE_ORDER == BIG_ENDIAN
int16_t *ptr;
@@ -611,7 +609,6 @@
*ptr = bswap16(*ptr);
}
#endif
-#endif
if (!(!strncmp(atacap->model, "FX", 2) ||
!strncmp(atacap->model, "NEC", 3) ||
!strncmp(atacap->model, "Pioneer", 7) ||
More information about the p4-projects
mailing list