From 19441607e782c34ece0ca0b672ca41b0757e1c01 Mon Sep 17 00:00:00 2001 From: chuck Date: Fri, 12 Jan 1996 21:43:09 +0000 Subject: [PATCH] improved handling of mapping of devices who's registers do not reside on page boundaries: - change bus_tmp() to include the offset from the start of page in the returned KVA [rather than forcing each driver to add it back in individually] - changed bus_map() to include the offset from the start of page in the the returned value if a mapping is found in the PROM's KVA area - clarified a few comments --- sys/arch/sparc/dev/obio.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/arch/sparc/dev/obio.c b/sys/arch/sparc/dev/obio.c index 858c729f7cc..f78bbcc2f37 100644 --- a/sys/arch/sparc/dev/obio.c +++ b/sys/arch/sparc/dev/obio.c @@ -163,13 +163,15 @@ busattach(parent, child, args, bustype) return (0); /* - * check if XXmatch() replaced the temporary - * mapping with a real mapping. + * check if XXmatch() replaced the temporary mapping with + * a real mapping. If not, then make sure we don't pass the + * tmp mapping to the attach routine. */ - if (tmp == oca.ca_ra.ra_vaddr) - oca.ca_ra.ra_vaddr = NULL; + if (oca.ca_ra.ra_vaddr == tmp) + oca.ca_ra.ra_vaddr = NULL; /* wipe out tmp address */ /* - * or if it has asked us to create a mapping.. + * the match routine will set "ra_len" if it wants us to + * establish a mapping for it. * (which won't be seen on future XXmatch calls, * so not as useful as it seems.) */ @@ -368,7 +370,8 @@ bus_map(pa, len, bustype) pte = getpte(va); if ((pte & PG_V) != 0 && (pte & PG_TYPE) == pgtype && (pte & PG_PFNUM) == pf) - return ((void *)va); + return ((void *)(va | ((u_long)pa & PGOFSET))); + /* note: preserve page offset */ } } rr.rr_paddr = pa; @@ -386,7 +389,7 @@ bus_tmp(pa, bustype) pmap_enter(pmap_kernel(), TMPMAP_VA, addr | pmtype | PMAP_NC, VM_PROT_READ | VM_PROT_WRITE, 1); - return ((void *)TMPMAP_VA); + return ((void *)(TMPMAP_VA | ((u_long) pa & PGOFSET)) ); } void -- 2.20.1