From 6606924480109f0edf7e986b0d8a009ee711835e Mon Sep 17 00:00:00 2001 From: Jason Wright Date: Tue, 28 Sep 2004 18:37:44 +0000 Subject: use prom mappings when availavk --- sys/arch/sparc64/dev/fhc.c | 6 +++++- sys/arch/sparc64/dev/fhcvar.h | 10 ++++++---- sys/arch/sparc64/dev/zs.c | 36 +++++++++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 14 deletions(-) (limited to 'sys/arch/sparc64/dev') diff --git a/sys/arch/sparc64/dev/fhc.c b/sys/arch/sparc64/dev/fhc.c index 0d356248493..868d36fe8fb 100644 --- a/sys/arch/sparc64/dev/fhc.c +++ b/sys/arch/sparc64/dev/fhc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fhc.c,v 1.10 2004/09/28 02:01:49 jason Exp $ */ +/* $OpenBSD: fhc.c,v 1.11 2004/09/28 18:37:43 jason Exp $ */ /* * Copyright (c) 2004 Jason L. Wright (jason@thought.net) @@ -114,6 +114,8 @@ fhc_attach(struct fhc_softc *sc) &fa.fa_nreg, (void **)&fa.fa_reg); getprop(node, "interrupts", sizeof(int), &fa.fa_nintr, (void **)&fa.fa_intr); + getprop(node, "address", sizeof(*fa.fa_promvaddrs), + &fa.fa_npromvaddrs, (void **)&fa.fa_promvaddrs); (void)config_found(&sc->sc_dv, (void *)&fa, fhc_print); @@ -123,6 +125,8 @@ fhc_attach(struct fhc_softc *sc) free(fa.fa_reg, M_DEVBUF); if (fa.fa_nintr != NULL) free(fa.fa_intr, M_DEVBUF); + if (fa.fa_promvaddrs != NULL) + free(fa.fa_promvaddrs, M_DEVBUF); } if (sparc_led_blink) diff --git a/sys/arch/sparc64/dev/fhcvar.h b/sys/arch/sparc64/dev/fhcvar.h index ed2eb90a582..2e2eb92e51a 100644 --- a/sys/arch/sparc64/dev/fhcvar.h +++ b/sys/arch/sparc64/dev/fhcvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fhcvar.h,v 1.6 2004/09/27 21:12:40 jason Exp $ */ +/* $OpenBSD: fhcvar.h,v 1.7 2004/09/28 18:37:43 jason Exp $ */ /* * Copyright (c) 2004 Jason L. Wright (jason@thought.net). @@ -63,13 +63,15 @@ void fhc_attach(struct fhc_softc *); int fhc_get_string(int, char *, char **); struct fhc_attach_args { + bus_space_tag_t fa_bustag; char *fa_name; + int *fa_intr; + struct fhc_reg *fa_reg; + u_int32_t *fa_promvaddrs; int fa_node; int fa_nreg; int fa_nintr; - int *fa_intr; - struct fhc_reg *fa_reg; - bus_space_tag_t fa_bustag; + int fa_npromvaddrs; }; #define fhc_bus_map(t, slot, offset, sz, flags, hp) \ diff --git a/sys/arch/sparc64/dev/zs.c b/sys/arch/sparc64/dev/zs.c index 7184db54dc2..d468a1c7dee 100644 --- a/sys/arch/sparc64/dev/zs.c +++ b/sys/arch/sparc64/dev/zs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zs.c,v 1.15 2004/09/24 20:53:12 jason Exp $ */ +/* $OpenBSD: zs.c,v 1.16 2004/09/28 18:37:43 jason Exp $ */ /* $NetBSD: zs.c,v 1.29 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -290,7 +290,7 @@ zs_attach_fhc(parent, self, aux) int zs_unit = zsc->zsc_dev.dv_unit; bus_space_handle_t kvaddr; - if (fa->fa_nreg < 1) { + if (fa->fa_nreg < 1 && fa->fa_npromvaddrs < 1) { printf(": no registers\n"); return; } @@ -300,14 +300,32 @@ zs_attach_fhc(parent, self, aux) return; } - if (fhc_bus_map(fa->fa_bustag, fa->fa_reg[0].fbr_slot, - fa->fa_reg[0].fbr_offset, fa->fa_reg[0].fbr_size, - BUS_SPACE_MAP_LINEAR, &kvaddr) != 0) { - printf("%s @ fhc: cannot map registers\n", self->dv_xname); - return; + if (zsaddr[zs_unit] == NULL) { + if (fa->fa_npromvaddrs) { + /* + * We're converting from a 32-bit pointer to a 64-bit + * pointer. Since the 32-bit entity is negative, but + * the kernel is still mapped into the lower 4GB + * range, this needs to be zero-extended. + * + * XXXXX If we map the kernel and devices into the + * high 4GB range, this needs to be changed to + * sign-extend the address. + */ + zsaddr[zs_unit] = (struct zsdevice *) + (unsigned long int)fa->fa_promvaddrs[0]; + } else { + if (fhc_bus_map(fa->fa_bustag, fa->fa_reg[0].fbr_slot, + fa->fa_reg[0].fbr_offset, fa->fa_reg[0].fbr_size, + BUS_SPACE_MAP_LINEAR, &kvaddr) != 0) { + printf("%s @ fhc: cannot map registers\n", + self->dv_xname); + return; + } + zsaddr[zs_unit] = (struct zsdevice *) + bus_space_vaddr(fa->fa_bustag, kvaddr); + } } - zsaddr[zs_unit] = - (struct zsdevice *) bus_space_vaddr(fa->fa_bustag, kvaddr); zsc->zsc_bustag = fa->fa_bustag; zsc->zsc_dmatag = NULL; -- cgit v1.2.3