Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hp700/dev io / mem space access fixes. Mostly from ...
details: https://anonhg.NetBSD.org/src/rev/508f8c2bad85
branches: trunk
changeset: 749781:508f8c2bad85
user: skrll <skrll%NetBSD.org@localhost>
date: Tue Dec 08 07:32:45 2009 +0000
description:
io / mem space access fixes. Mostly from OpenBSD.
diffstat:
sys/arch/hp700/dev/dino.c | 163 +++++++++++++++++++++++----------------------
1 files changed, 82 insertions(+), 81 deletions(-)
diffs (truncated from 492 to 300 lines):
diff -r 44b58eb63bcf -r 508f8c2bad85 sys/arch/hp700/dev/dino.c
--- a/sys/arch/hp700/dev/dino.c Tue Dec 08 06:56:54 2009 +0000
+++ b/sys/arch/hp700/dev/dino.c Tue Dec 08 07:32:45 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dino.c,v 1.19 2009/12/08 06:56:54 skrll Exp $ */
+/* $NetBSD: dino.c,v 1.20 2009/12/08 07:32:45 skrll Exp $ */
/* $OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.19 2009/12/08 06:56:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.20 2009/12/08 07:32:45 skrll Exp $");
/* #include "cardbus.h" */
@@ -604,7 +604,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
return *((volatile uint8_t *)&r->pci_io_data + (h & 3));
}
}
@@ -613,24 +613,20 @@
dino_r2(void *v, bus_space_handle_t h, bus_size_t o)
{
volatile uint16_t *p;
- volatile uint16_t d;
h += o;
- if (h & 0xf0000000) {
+ if (h & 0xf0000000)
p = (volatile uint16_t *)h;
- d = le16toh(*p);
- } else {
+ else {
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
- d = le16toh(*p);
}
-
- return d;
+ return le16toh(*p);
}
uint32_t
@@ -655,11 +651,15 @@
uint64_t
dino_r8(void *v, bus_space_handle_t h, bus_size_t o)
{
+ uint64_t data;
+
h += o;
- if (h & 0xf0000000)
- return *(volatile uint64_t *)h;
+ if (h & 0xf0000000) {
+ data = *(volatile uint64_t *)h;
else
panic("dino_r8: not implemented");
+
+ return le64toh(data);
}
void
@@ -672,7 +672,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
*((volatile uint8_t *)&r->pci_io_data + (h & 3)) = vv;
}
}
@@ -689,7 +689,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
@@ -719,7 +719,7 @@
{
h += o;
if (h & 0xf0000000)
- *(volatile uint64_t *)h = vv;
+ *(volatile uint64_t *)h = htole64(vv);
else
panic("dino_w8: not implemented");
}
@@ -737,7 +737,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint8_t *)&r->pci_io_data + (h & 3);
}
@@ -757,7 +757,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
@@ -805,7 +805,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint8_t *)&r->pci_io_data + (h & 3);
}
@@ -825,7 +825,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
@@ -873,7 +873,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint8_t *)&r->pci_io_data + (h & 3);
}
@@ -893,7 +893,7 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
@@ -942,12 +942,13 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
}
+ c /= 2;
while (c--)
*a++ = *p;
}
@@ -969,6 +970,7 @@
p = (volatile uint32_t *)&r->pci_io_data;
}
+ c /= 4;
while (c--)
*a++ = *p;
}
@@ -993,12 +995,13 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
}
+ c /= 2;
while (c--)
*p = *a++;
}
@@ -1020,6 +1023,7 @@
p = (volatile uint32_t *)&r->pci_io_data;
}
+ c /= 4;
while (c--)
*p = *a++;
}
@@ -1045,12 +1049,10 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
- while (c--) {
+ for (; c--; h++) {
+ r->pci_addr = h;
p = (volatile uint8_t *)&r->pci_io_data + (h & 3);
*a++ = *p;
- if (!(++h & 3))
- r->pci_addr = h;
}
}
}
@@ -1058,26 +1060,26 @@
void
dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, uint16_t *a, bus_size_t c)
{
- volatile uint16_t *p;
+ volatile uint16_t *p, data;
h += o;
if (h & 0xf0000000) {
p = (volatile uint16_t *)h;
- while (c--)
- *a++ = le16toh(*p++);
+ while (c--) {
+ data = *p++;
+ *a++ = le16toh(data);
+ }
} else {
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
- while (c--) {
+ for (; c--; h += 2) {
+ r->pci_addr = h;
p = (volatile uint16_t *)&r->pci_io_data;
if (h & 2)
p++;
- *a++ = le16toh(*p);
- h += 2;
- if (!(h & 2))
- r->pci_addr = h;
+ data = *p;
+ *a++ = le16toh(data);
}
}
}
@@ -1085,20 +1087,23 @@
void
dino_rr_4(void *v, bus_space_handle_t h, bus_size_t o, uint32_t *a, bus_size_t c)
{
- volatile uint32_t *p;
+ volatile uint32_t *p, data;
h += o;
if (h & 0xf0000000) {
p = (volatile uint32_t *)h;
- while (c--)
- *a++ = le32toh(*p++);
+ while (c--) {
+ data = *p++;
+ *a++ = le32toh(data);
+ }
} else {
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
for (; c--; h += 4) {
r->pci_addr = h;
- *a++ = le32toh(r->pci_io_data);
+ data = r->pci_io_data;
+ *a++ = le32toh(data);
}
}
}
@@ -1123,12 +1128,10 @@
struct dino_softc *sc = v;
volatile struct dino_regs *r = sc->sc_regs;
- r->pci_addr = h & ~3;
- while (c--) {
+ for (; c--; h++) {
+ r->pci_addr = h;
p = (volatile uint8_t *)&r->pci_io_data + (h & 3);
*p = *a++;
- if (!(++h & 3))
- r->pci_addr = h;
}
}
}
@@ -1136,26 +1139,26 @@
void
dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const uint16_t *a, bus_size_t c)
{
- volatile uint16_t *p;
Home |
Main Index |
Thread Index |
Old Index