Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcmips Added bus probing to avoid bus error.
details: https://anonhg.NetBSD.org/src/rev/a6760f9eca95
branches: trunk
changeset: 525630:a6760f9eca95
user: takemura <takemura%NetBSD.org@localhost>
date: Sun Apr 14 07:59:56 2002 +0000
description:
Added bus probing to avoid bus error.
diffstat:
sys/arch/hpcmips/dev/com_hpcio.c | 6 +-
sys/arch/hpcmips/hpcmips/bus_space.c | 76 ++++++++++++++++++++++++---
sys/arch/hpcmips/hpcmips/bus_space_notimpl.c | 4 +-
sys/arch/hpcmips/hpcmips/bus_space_through.c | 20 +++++++-
sys/arch/hpcmips/include/bus.h | 26 +++++++++-
sys/arch/hpcmips/vr/vrc4172pci.c | 21 ++++---
6 files changed, 130 insertions(+), 23 deletions(-)
diffs (truncated from 317 to 300 lines):
diff -r f3bf848aea99 -r a6760f9eca95 sys/arch/hpcmips/dev/com_hpcio.c
--- a/sys/arch/hpcmips/dev/com_hpcio.c Sun Apr 14 07:53:46 2002 +0000
+++ b/sys/arch/hpcmips/dev/com_hpcio.c Sun Apr 14 07:59:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com_hpcio.c,v 1.2 2002/01/05 00:40:38 takemura Exp $ */
+/* $NetBSD: com_hpcio.c,v 1.3 2002/04/14 07:59:56 takemura Exp $ */
/*-
* Copyright (c) 2002 TAKEMRUA Shin. All rights reserved.
@@ -101,6 +101,10 @@
/* barrier */
bs_through_bs_barrier,
+ /* probe */
+ bs_through_bs_peek,
+ bs_through_bs_poke,
+
/* read (single) */
com_hpcio_bs_r_1,
bs_notimpl_bs_r_2,
diff -r f3bf848aea99 -r a6760f9eca95 sys/arch/hpcmips/hpcmips/bus_space.c
--- a/sys/arch/hpcmips/hpcmips/bus_space.c Sun Apr 14 07:53:46 2002 +0000
+++ b/sys/arch/hpcmips/hpcmips/bus_space.c Sun Apr 14 07:59:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.17 2001/12/02 10:37:53 uch Exp $ */
+/* $NetBSD: bus_space.c,v 1.18 2002/04/14 07:59:57 takemura Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -88,6 +88,10 @@
/* barrier */
__bs_barrier,
+ /* probe */
+ __bs_peek,
+ __bs_poke,
+
/* read (single) */
__bs_r_1,
__bs_r_2,
@@ -266,9 +270,12 @@
int err;
int cacheable = flags & BUS_SPACE_MAP_CACHEABLE;
+ DPRINTF(("\tbus_space_map:%#lx(%#lx)+%#lx\n",
+ bpa, bpa - t->base, size));
+
if (!t->extent) { /* Before autoconfiguration, can't use extent */
DPRINTF(("bus_space_map: map temporary region:"
- "0x%08x-0x%08x\n", bpa, bpa+size));
+ "0x%08lx-0x%08lx\n", bpa, bpa+size));
bpa += t->base;
} else {
bpa += t->base;
@@ -279,9 +286,6 @@
}
*bshp = __hpcmips_cacheable(t, bpa, size, cacheable);
- DPRINTF(("\tbus_space_map:%#x(%#x)+%#x\n",
- bpa, bpa - t->base, size));
-
return (0);
}
@@ -304,7 +308,7 @@
}
if ((err = extent_free(t->extent, addr, size, EX_NOWAIT))) {
- DPRINTF(("warning: %#x-%#x of %s space lost\n",
+ DPRINTF(("warning: %#lx-%#lx of %s space lost\n",
bsh, bsh+size, t->name));
}
}
@@ -334,6 +338,9 @@
if (!t->extent)
panic("bus_space_alloc: no extent");
+ DPRINTF(("\tbus_space_alloc:%#lx(%#lx)+%#lx\n", bpa,
+ bpa - t->base, size));
+
rstart += t->base;
rend += t->base;
if ((err = extent_alloc_subregion(t->extent, rstart, rend, size,
@@ -347,9 +354,6 @@
*bpap = bpa;
}
- DPRINTF(("\tbus_space_alloc:%#x(%#x)+%#x\n", (unsigned)bpa,
- (unsigned)(bpa - t->base), size));
-
return (0);
}
@@ -368,6 +372,60 @@
wbflush();
}
+int
+__bs_peek(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
+ size_t size, void *ptr)
+{
+ u_int32_t tmp;
+
+ if (badaddr((void *)(bsh + offset), size))
+ return (-1);
+
+ if (ptr == NULL)
+ ptr = &tmp;
+
+ switch(size) {
+ case 1:
+ *((u_int8_t *)ptr) = bus_space_read_1(t, bsh, offset);
+ break;
+ case 2:
+ *((u_int16_t *)ptr) = bus_space_read_2(t, bsh, offset);
+ break;
+ case 4:
+ *((u_int32_t *)ptr) = bus_space_read_4(t, bsh, offset);
+ break;
+ default:
+ panic("bus_space_peek: bad size, %d\n", size);
+ }
+
+ return (0);
+}
+
+int
+__bs_poke(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset,
+ size_t size, u_int32_t val)
+{
+
+ if (badaddr((void *)(bsh + offset), size))
+ return (-1);
+
+ switch(size) {
+ case 1:
+ bus_space_write_1(t, bsh, offset, val);
+ break;
+ case 2:
+ bus_space_write_2(t, bsh, offset, val);
+ break;
+ case 4:
+ bus_space_write_4(t, bsh, offset, val);
+ break;
+ default:
+ panic("bus_space_poke: bad size, %d\n", size);
+ }
+
+ return (0);
+}
+
u_int8_t
__bs_r_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t offset)
{
diff -r f3bf848aea99 -r a6760f9eca95 sys/arch/hpcmips/hpcmips/bus_space_notimpl.c
--- a/sys/arch/hpcmips/hpcmips/bus_space_notimpl.c Sun Apr 14 07:53:46 2002 +0000
+++ b/sys/arch/hpcmips/hpcmips/bus_space_notimpl.c Sun Apr 14 07:59:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space_notimpl.c,v 1.2 2002/01/02 13:11:02 uch Exp $ */
+/* $NetBSD: bus_space_notimpl.c,v 1.3 2002/04/14 07:59:59 takemura Exp $ */
/*-
* Copyright (c) 2001 TAKEMURA Shin. All rights reserved.
@@ -48,6 +48,8 @@
__NOTIMPL(vaddr)
__NOTIMPL(mmap)
__NOTIMPL(barrier)
+__NOTIMPL(peek)
+__NOTIMPL(poke)
__NOTIMPL(r_1)
__NOTIMPL(r_2)
__NOTIMPL(r_4)
diff -r f3bf848aea99 -r a6760f9eca95 sys/arch/hpcmips/hpcmips/bus_space_through.c
--- a/sys/arch/hpcmips/hpcmips/bus_space_through.c Sun Apr 14 07:53:46 2002 +0000
+++ b/sys/arch/hpcmips/hpcmips/bus_space_through.c Sun Apr 14 07:59:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space_through.c,v 1.1 2001/12/23 13:32:34 takemura Exp $ */
+/* $NetBSD: bus_space_through.c,v 1.2 2002/04/14 07:59:59 takemura Exp $ */
/*-
* Copyright (c) 2001 TAKEMRUA Shin. All rights reserved.
@@ -109,6 +109,24 @@
/*
+ * Bus probe operations.
+ */
+int
+bs_through_bs_peek(bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t offset, size_t size, void *ptr)
+{
+ return bus_space_peek(t->bs_base, bsh, offset, size, ptr);
+}
+
+int
+bs_through_bs_poke(bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t offset, size_t size, u_int32_t val)
+{
+ return bus_space_poke(t->bs_base, bsh, offset, size, val);
+}
+
+
+/*
* Bus read (single) operations.
*/
u_int8_t
diff -r f3bf848aea99 -r a6760f9eca95 sys/arch/hpcmips/include/bus.h
--- a/sys/arch/hpcmips/include/bus.h Sun Apr 14 07:53:46 2002 +0000
+++ b/sys/arch/hpcmips/include/bus.h Sun Apr 14 07:59:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.14 2001/11/18 08:19:40 takemura Exp $ */
+/* $NetBSD: bus.h,v 1.15 2002/04/14 07:59:59 takemura Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -117,6 +117,12 @@
void (*bs_barrier)(bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_size_t, int);
+ /* probe */
+ int (*bs_peek)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, size_t, void *);
+ int (*bs_poke)(bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, size_t, u_int32_t);
+
/* read (single) */
u_int8_t (*bs_r_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
u_int16_t (*bs_r_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
@@ -331,6 +337,15 @@
/*
+ * Bus probe operations.
+ */
+#define bus_space_peek(t, h, o, s, p) \
+ (*__bs_ops(t).bs_peek)(t, (h), (o), (s), (p))
+#define bus_space_poke(t, h, o, s, v) \
+ (*__bs_ops(t).bs_poke)(t, (h), (o), (s), (v))
+
+
+/*
* Bus read (single) operations.
*/
#define bus_space_read_1(t, h, o) __bs_rs(1,(t),(h),(o))
@@ -576,6 +591,13 @@
void __bs_c(f,_bs_barrier)(bus_space_tag_t t, bus_space_handle_t bsh,\
bus_size_t offset, bus_size_t len, int flags)
+#define bs_peek_proto(f) \
+int __bs_c(f,_bs_peek)(bus_space_tag_t t, bus_space_handle_t bsh, \
+ bus_size_t offset, size_t len, void *ptr)
+#define bs_poke_proto(f) \
+int __bs_c(f,_bs_poke)(bus_space_tag_t t, bus_space_handle_t bsh, \
+ bus_size_t offset, size_t len, u_int32_t val)
+
#define bs_r_1_proto(f) \
u_int8_t __bs_c(f,_bs_r_1)(bus_space_tag_t t, \
bus_space_handle_t bsh, bus_size_t offset)
@@ -812,6 +834,8 @@
bs_vaddr_proto(f); \
bs_mmap_proto(f); \
bs_barrier_proto(f); \
+bs_peek_proto(f); \
+bs_poke_proto(f); \
bs_r_1_proto(f); \
bs_r_2_proto(f); \
bs_r_4_proto(f); \
diff -r f3bf848aea99 -r a6760f9eca95 sys/arch/hpcmips/vr/vrc4172pci.c
--- a/sys/arch/hpcmips/vr/vrc4172pci.c Sun Apr 14 07:53:46 2002 +0000
+++ b/sys/arch/hpcmips/vr/vrc4172pci.c Sun Apr 14 07:59:56 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vrc4172pci.c,v 1.1 2002/03/22 09:18:09 takemura Exp $ */
+/* $NetBSD: vrc4172pci.c,v 1.2 2002/04/14 08:00:00 takemura Exp $ */
/*-
* Copyright (c) 2002 TAKEMURA Shin
@@ -103,8 +103,13 @@
static inline u_int32_t
vrc4172pci_read(struct vrc4172pci_softc *sc, int offset)
{
+ u_int32_t res;
- return (bus_space_read_4(sc->sc_iot, sc->sc_ioh, offset));
+ if (bus_space_peek(sc->sc_iot, sc->sc_ioh, offset, 4, &res) < 0) {
+ res = 0xffffffff;
+ }
+
+ return (res);
}
static int
@@ -245,10 +250,8 @@
vrc4172pci_write(sc, VRC4172PCI_CONFAREG, tag | reg);
val = vrc4172pci_read(sc, VRC4172PCI_CONFDREG);
-#if 0
- printf("%s: conf_read: tag = 0x%08x, reg = 0x%x, val = 0x%08x\n",
- sc->sc_dev.dv_xname, (u_int32_t)tag, reg, val);
-#endif
+ DPRINTF(("%s: conf_read: tag = 0x%08x, reg = 0x%x, val = 0x%08x\n",
Home |
Main Index |
Thread Index |
Old Index