diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-05-18 16:00:18 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-05-18 16:00:18 +0000 |
commit | a06007bfb72ecaf2aa6f6df71ab16879352536bf (patch) | |
tree | afe37b5acde0e900dd09cab9a45a8ae66351fdff | |
parent | 25cb5436d2a68b77ac734021c63bab6dbdf6ea40 (diff) |
Fix io space access.
tested by krw@, miod@, ok deraadt@
-rw-r--r-- | sys/arch/hppa/dev/dino.c | 79 |
1 files changed, 29 insertions, 50 deletions
diff --git a/sys/arch/hppa/dev/dino.c b/sys/arch/hppa/dev/dino.c index fd805848d8c..8bae9d1d76e 100644 --- a/sys/arch/hppa/dev/dino.c +++ b/sys/arch/hppa/dev/dino.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dino.c,v 1.20 2007/01/11 21:59:52 miod Exp $ */ +/* $OpenBSD: dino.c,v 1.21 2007/05/18 16:00:17 kettenis Exp $ */ /* * Copyright (c) 2003-2005 Michael Shalayeff @@ -645,7 +645,7 @@ dino_r1(void *v, bus_space_handle_t h, bus_size_t o) volatile struct dino_regs *r = sc->sc_regs; u_int8_t data; - r->pci_addr = h & ~3; + r->pci_addr = h; data = *((volatile u_int8_t *)&r->pci_io_data + (h & 3)); return (data); } @@ -663,7 +663,7 @@ dino_r2(void *v, bus_space_handle_t h, bus_size_t o) struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -715,7 +715,7 @@ dino_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv) struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; *((volatile u_int8_t *)&r->pci_io_data + (h & 3)) = vv; } } @@ -732,7 +732,7 @@ dino_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -780,7 +780,7 @@ dino_rm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); } @@ -800,7 +800,7 @@ dino_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -848,7 +848,7 @@ dino_wm_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_si struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); } @@ -868,7 +868,7 @@ dino_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_s struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -916,7 +916,7 @@ dino_sm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); } @@ -936,7 +936,7 @@ dino_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -987,7 +987,7 @@ dino_rrm_2(void *v, bus_space_handle_t h, bus_size_t o, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -1041,7 +1041,7 @@ dino_wrm_2(void *v, bus_space_handle_t h, bus_size_t o, struct dino_softc *sc = v; volatile struct dino_regs *r = sc->sc_regs; - r->pci_addr = h & ~3; + r->pci_addr = h; p = (volatile u_int16_t *)&r->pci_io_data; if (h & 2) p++; @@ -1096,12 +1096,10 @@ dino_rr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c 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 u_int8_t *)&r->pci_io_data + (h & 3); *a++ = *p; - if (!(++h & 3)) - r->pci_addr = h; } } } @@ -1122,16 +1120,13 @@ dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t 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 u_int16_t *)&r->pci_io_data; if (h & 2) p++; data = *p; *a++ = letoh16(data); - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } @@ -1180,12 +1175,10 @@ dino_wr_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_si 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 u_int8_t *)&r->pci_io_data + (h & 3); *p = *a++; - if (!(++h & 3)) - r->pci_addr = h; } } } @@ -1206,16 +1199,13 @@ dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_s 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 u_int16_t *)&r->pci_io_data; if (h & 2) p++; data = *a++; *p = htole16(data); - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } @@ -1266,15 +1256,12 @@ dino_rrr_2(void *v, bus_space_handle_t h, bus_size_t o, 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 u_int16_t *)&r->pci_io_data; if (h & 2) p++; *q++ = *p; - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } @@ -1326,15 +1313,12 @@ dino_wrr_2(void *v, bus_space_handle_t h, bus_size_t o, 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 u_int16_t *)&r->pci_io_data; if (h & 2) p++; *p = *q++; - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } @@ -1384,12 +1368,10 @@ dino_sr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c 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 u_int8_t *)&r->pci_io_data + (h & 3); *p = vv; - if (!(++h & 3)) - r->pci_addr = h; } } } @@ -1409,15 +1391,12 @@ dino_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t 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 u_int16_t *)&r->pci_io_data; if (h & 2) p++; *p = vv; - h += 2; - if (!(h & 2)) - r->pci_addr = h; } } } |