diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-07-21 19:54:09 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-07-21 19:54:09 +0000 |
commit | f00925d0479f2871523e25475380cf06ab54222b (patch) | |
tree | 9790acf7f23dc75a329c5672bee64719dca9c086 /sys | |
parent | de9e69d94f4862961c25e1fdcd31c373b07dc688 (diff) |
swapped byte swapping in raw vs non-raw funcs and missed swapping in rw8; from jkunz@ pr3861
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/hppa/dev/dino.c | 90 |
1 files changed, 55 insertions, 35 deletions
diff --git a/sys/arch/hppa/dev/dino.c b/sys/arch/hppa/dev/dino.c index 88f6da40048..b74547d675b 100644 --- a/sys/arch/hppa/dev/dino.c +++ b/sys/arch/hppa/dev/dino.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dino.c,v 1.8 2004/06/30 15:25:36 mickey Exp $ */ +/* $OpenBSD: dino.c,v 1.9 2004/07/21 19:54:08 mickey Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -480,11 +480,15 @@ dino_r4(void *v, bus_space_handle_t h, bus_size_t o) u_int64_t dino_r8(void *v, bus_space_handle_t h, bus_size_t o) { + u_int64_t data; + h += o; if (h & 0xf0000000) - return *(volatile u_int64_t *)h; + data = *(volatile u_int64_t *)h; else panic("dino_r8: not implemented"); + + return (letoh64(data)); } void @@ -544,7 +548,7 @@ dino_w8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv) { h += o; if (h & 0xf0000000) - *(volatile u_int64_t *)h = vv; + *(volatile u_int64_t *)h = htole64(vv); else panic("dino_w8: not implemented"); } @@ -589,7 +593,7 @@ dino_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t } while (c--) - *a++ = *p; + *a++ = letoh16(*p); } void @@ -609,7 +613,7 @@ dino_rm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t } while (c--) - *a++ = *p; + *a++ = letoh32(*p); } void @@ -657,7 +661,7 @@ dino_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_s } while (c--) - *p = *a++; + *p = htole16(*a++); } void @@ -677,7 +681,7 @@ dino_wm_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_s } while (c--) - *p = *a++; + *p = htole32(*a++); } void @@ -724,6 +728,7 @@ dino_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t p++; } + vv = htole16(vv); while (c--) *p = vv; } @@ -744,6 +749,7 @@ dino_sm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t p = (volatile u_int32_t *)&r->pci_io_data; } + vv = htole32(vv); while (c--) *p = vv; } @@ -774,7 +780,7 @@ dino_rrm_2(void *v, bus_space_handle_t h, bus_size_t o, } while (c--) - *a++ = swap16(*p); + *a++ = *p; } void @@ -795,7 +801,7 @@ dino_rrm_4(void *v, bus_space_handle_t h, bus_size_t o, } while (c--) - *a++ = swap32(*p); + *a++ = *p; } void @@ -825,7 +831,7 @@ dino_wrm_2(void *v, bus_space_handle_t h, bus_size_t o, } while (c--) - *p = swap16(*a++); + *p = *a++; } void @@ -846,7 +852,7 @@ dino_wrm_4(void *v, bus_space_handle_t h, bus_size_t o, } while (c--) - *p = swap32(*a++); + *p = *a++; } void @@ -883,13 +889,15 @@ dino_rr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c void dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) { - volatile u_int16_t *p; + volatile u_int16_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile u_int16_t *)h; - while (c--) - *a++ = *p++; + while (c--) { + data = *p++; + *a++ = letoh16(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; @@ -899,7 +907,8 @@ dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; - *a++ = *p; + data = *p; + *a++ = letoh16(data); h += 2; if (!(h & 2)) r->pci_addr = h; @@ -910,20 +919,23 @@ dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t void dino_rr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) { - volatile u_int32_t *p; + volatile u_int32_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile u_int32_t *)h; - while (c--) - *a++ = *p++; + while (c--) { + data = *p++; + *a++ = letoh32(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - *a++ = r->pci_io_data; + data = r->pci_io_data; + *a++ = letoh32(data); } } } @@ -961,13 +973,15 @@ dino_wr_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_si void dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) { - volatile u_int16_t *p; + volatile u_int16_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile u_int16_t *)h; - while (c--) - *p++ = *a++; + while (c--) { + data = *a++; + *p++ = htole16(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; @@ -977,7 +991,8 @@ dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_s p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; - *p = *a++; + data = *a++; + *p = htole16(data); h += 2; if (!(h & 2)) r->pci_addr = h; @@ -988,20 +1003,23 @@ dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_s void dino_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) { - volatile u_int32_t *p; + volatile u_int32_t *p, data; h += o; if (h & 0xf0000000) { p = (volatile u_int32_t *)h; - while (c--) - *p++ = *a++; + while (c--) { + data = *a++; + *p++ = htole32(data); + } } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - r->pci_io_data = *a++; + data = *a++; + r->pci_io_data = htole32(data); } } } @@ -1022,7 +1040,7 @@ dino_rrr_2(void *v, bus_space_handle_t h, bus_size_t o, if (h & 0xf0000000) { p = (volatile u_int16_t *)h; while (c--) - *a++ = swap16(*p++); + *a++ = *p++; } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; @@ -1032,7 +1050,7 @@ dino_rrr_2(void *v, bus_space_handle_t h, bus_size_t o, p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; - *a++ = swap16(*p); + *a++ = *p; h += 2; if (!(h & 2)) r->pci_addr = h; @@ -1050,14 +1068,14 @@ dino_rrr_4(void *v, bus_space_handle_t h, bus_size_t o, if (h & 0xf0000000) { p = (volatile u_int32_t *)h; while (c--) - *a++ = swap32(*p++); + *a++ = *p++; } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - *a++ = swap32(r->pci_io_data); + *a++ = r->pci_io_data; } } } @@ -1079,7 +1097,7 @@ dino_wrr_2(void *v, bus_space_handle_t h, bus_size_t o, if (h & 0xf0000000) { p = (volatile u_int16_t *)h; while (c--) - *p++ = swap16(*a++); + *p++ = *a++; } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; @@ -1089,7 +1107,7 @@ dino_wrr_2(void *v, bus_space_handle_t h, bus_size_t o, p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; - *p = swap16(*a++); + *p = *a++; h += 2; if (!(h & 2)) r->pci_addr = h; @@ -1107,14 +1125,14 @@ dino_wrr_4(void *v, bus_space_handle_t h, bus_size_t o, if (h & 0xf0000000) { p = (volatile u_int32_t *)h; while (c--) - *p++ = swap32(*a++); + *p++ = *a++; } else { struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; for (; c--; h += 4) { r->pci_addr = h; - r->pci_io_data = swap32(*a++); + r->pci_io_data = *a++; } } } @@ -1156,6 +1174,7 @@ dino_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t volatile u_int16_t *p; h += o; + vv = htole16(vv); if (h & 0xf0000000) { p = (volatile u_int16_t *)h; while (c--) @@ -1183,6 +1202,7 @@ dino_sr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t volatile u_int32_t *p; h += o; + vv = htole32(vv); if (h & 0xf0000000) { p = (volatile u_int32_t *)h; while (c--) |