From e867e6e73fcf90e38b2426dbad2002e32b43faf5 Mon Sep 17 00:00:00 2001 From: briggs Date: Sat, 5 Apr 1997 16:22:06 +0000 Subject: [PATCH] Implement a bus_space_bad_addr() function to aid in some device probing with the bus_space universe. --- sys/arch/mac68k/include/bus.h | 5 ++++- sys/arch/mac68k/mac68k/machdep.c | 38 +++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/sys/arch/mac68k/include/bus.h b/sys/arch/mac68k/include/bus.h index 684e193fe47..0ae55d75867 100644 --- a/sys/arch/mac68k/include/bus.h +++ b/sys/arch/mac68k/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.1 1997/02/26 05:38:12 gene Exp $ */ +/* $OpenBSD: bus.h,v 1.2 1997/04/05 16:22:06 briggs Exp $ */ /* $NetBSD: bus.h,v 1.6 1997/02/24 05:55:14 scottr Exp $ */ /* @@ -52,6 +52,7 @@ typedef u_long bus_size_t; typedef int bus_space_tag_t; typedef u_long bus_space_handle_t; +/* in machdep.c */ int bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t, int, bus_space_handle_t *)); void bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t, @@ -65,6 +66,8 @@ int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart, bus_space_handle_t *bshp)); void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)); +int bus_space_bad_addr __P((bus_space_tag_t tag, bus_space_handle_t hand, + bus_size_t offset, int byte_size)); /* * u_intN_t bus_space_read_N __P((bus_space_tag_t tag, diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index ee99de35e36..99ee8550463 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.35 1997/04/05 15:29:10 briggs Exp $ */ +/* $OpenBSD: machdep.c,v 1.36 1997/04/05 16:22:07 briggs Exp $ */ /* $NetBSD: machdep.c,v 1.134 1997/02/14 06:15:30 scottr Exp $ */ /* @@ -883,6 +883,42 @@ int *nofault; int badaddr __P((caddr_t)); +int +bus_space_bad_addr(t, h, o, sz) + bus_space_tag_t t; + bus_space_handle_t h; + bus_size_t o; + int sz; +{ + register int i; + label_t faultbuf; + +#ifdef lint + i = *addr; + if (i) + return (0); +#endif + nofault = (int *) &faultbuf; + if (setjmp((label_t *) nofault)) { + nofault = (int *) 0; + return (1); + } + switch (sz) { + default: + case 1: + i = bus_space_read_1(t, h, o); + break; + case 2: + i = bus_space_read_2(t, h, o); + break; + case 4: + i = bus_space_read_4(t, h, o); + break; + } + nofault = (int *) 0; + return (0); +} + int badaddr(addr) register caddr_t addr; -- 2.20.1