Module Name: src Committed By: jmcneill Date: Fri Feb 11 23:08:39 UTC 2011
Modified Files: src/sys/arch/x86/include: pmap.h src/sys/arch/x86/x86: bus_space.c pmap.c Log Message: add bus_space_mmap support for BUS_SPACE_MAP_PREFETCHABLE, ok matt@ To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/include/pmap.h cvs rdiff -u -r1.32 -r1.33 src/sys/arch/x86/x86/bus_space.c cvs rdiff -u -r1.117 -r1.118 src/sys/arch/x86/x86/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/include/pmap.h diff -u src/sys/arch/x86/include/pmap.h:1.34 src/sys/arch/x86/include/pmap.h:1.35 --- src/sys/arch/x86/include/pmap.h:1.34 Tue Feb 1 20:19:32 2011 +++ src/sys/arch/x86/include/pmap.h Fri Feb 11 23:08:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.34 2011/02/01 20:19:32 chuck Exp $ */ +/* $NetBSD: pmap.h,v 1.35 2011/02/11 23:08:38 jmcneill Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -198,9 +198,18 @@ #define pmap_is_modified(pg) pmap_test_attrs(pg, PG_M) #define pmap_is_referenced(pg) pmap_test_attrs(pg, PG_U) #define pmap_move(DP,SP,D,L,S) -#define pmap_phys_address(ppn) x86_ptob(ppn) +#define pmap_phys_address(ppn) (x86_ptob(ppn) & ~X86_MMAP_FLAG_MASK) +#define pmap_mmap_flags(ppn) x86_mmap_flags(ppn) #define pmap_valid_entry(E) ((E) & PG_V) /* is PDE or PTE valid? */ +#if defined(__x86_64__) || defined(PAE) +#define X86_MMAP_FLAG_SHIFT (64 - PGSHIFT) +#else +#define X86_MMAP_FLAG_SHIFT (32 - PGSHIFT) +#endif + +#define X86_MMAP_FLAG_MASK 0xf +#define X86_MMAP_FLAG_PREFETCH 0x1 /* * prototypes @@ -229,6 +238,8 @@ int pmap_pdes_invalid(vaddr_t, pd_entry_t * const *, pd_entry_t *); +u_int x86_mmap_flags(paddr_t); + vaddr_t reserve_dumppages(vaddr_t); /* XXX: not a pmap fn */ void pmap_tlb_shootdown(pmap_t, vaddr_t, vaddr_t, pt_entry_t); Index: src/sys/arch/x86/x86/bus_space.c diff -u src/sys/arch/x86/x86/bus_space.c:1.32 src/sys/arch/x86/x86/bus_space.c:1.33 --- src/sys/arch/x86/x86/bus_space.c:1.32 Mon Jan 10 16:59:09 2011 +++ src/sys/arch/x86/x86/bus_space.c Fri Feb 11 23:08:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_space.c,v 1.32 2011/01/10 16:59:09 jruoho Exp $ */ +/* $NetBSD: bus_space.c,v 1.33 2011/02/11 23:08:38 jmcneill Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.32 2011/01/10 16:59:09 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.33 2011/02/11 23:08:38 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -484,6 +484,7 @@ bus_space_mmap(bus_space_tag_t t, bus_addr_t addr, off_t off, int prot, int flags) { + paddr_t pflags = 0; /* Can't mmap I/O space. */ if (x86_bus_space_is_io(t)) @@ -496,7 +497,10 @@ * Note we are called for each "page" in the device that * the upper layers want to map. */ - return (x86_btop(addr + off)); + if (flags & BUS_SPACE_MAP_PREFETCHABLE) + pflags |= X86_MMAP_FLAG_PREFETCH; + + return x86_btop(addr + off) | (pflags << X86_MMAP_FLAG_SHIFT); } void Index: src/sys/arch/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.117 src/sys/arch/x86/x86/pmap.c:1.118 --- src/sys/arch/x86/x86/pmap.c:1.117 Thu Feb 10 00:23:14 2011 +++ src/sys/arch/x86/x86/pmap.c Fri Feb 11 23:08:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.117 2011/02/10 00:23:14 jym Exp $ */ +/* $NetBSD: pmap.c,v 1.118 2011/02/11 23:08:38 jmcneill Exp $ */ /* * Copyright (c) 2007 Manuel Bouyer. @@ -142,7 +142,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.117 2011/02/10 00:23:14 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.118 2011/02/11 23:08:38 jmcneill Exp $"); #include "opt_user_ldt.h" #include "opt_lockdebug.h" @@ -4781,3 +4781,15 @@ return x86_tmp_pml_paddr[PTP_LEVELS - 1]; } + +u_int +x86_mmap_flags(paddr_t mdpgno) +{ + u_int nflag = (mdpgno >> X86_MMAP_FLAG_SHIFT) & X86_MMAP_FLAG_MASK; + u_int pflag = 0; + + if (nflag & X86_MMAP_FLAG_PREFETCH) + pflag |= PMAP_WRITE_COMBINE; + + return pflag; +}