Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86 add bus_space_mmap support for BUS_SPACE_MAP_PR...
details: https://anonhg.NetBSD.org/src/rev/4468cd7f0f31
branches: trunk
changeset: 761945:4468cd7f0f31
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Feb 11 23:08:38 2011 +0000
description:
add bus_space_mmap support for BUS_SPACE_MAP_PREFETCHABLE, ok matt@
diffstat:
sys/arch/x86/include/pmap.h | 15 +++++++++++++--
sys/arch/x86/x86/bus_space.c | 10 +++++++---
sys/arch/x86/x86/pmap.c | 16 ++++++++++++++--
3 files changed, 34 insertions(+), 7 deletions(-)
diffs (110 lines):
diff -r 358a5bf611c2 -r 4468cd7f0f31 sys/arch/x86/include/pmap.h
--- a/sys/arch/x86/include/pmap.h Fri Feb 11 23:05:55 2011 +0000
+++ b/sys/arch/x86/include/pmap.h Fri Feb 11 23:08:38 2011 +0000
@@ -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);
diff -r 358a5bf611c2 -r 4468cd7f0f31 sys/arch/x86/x86/bus_space.c
--- a/sys/arch/x86/x86/bus_space.c Fri Feb 11 23:05:55 2011 +0000
+++ b/sys/arch/x86/x86/bus_space.c Fri Feb 11 23:08:38 2011 +0000
@@ -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
diff -r 358a5bf611c2 -r 4468cd7f0f31 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c Fri Feb 11 23:05:55 2011 +0000
+++ b/sys/arch/x86/x86/pmap.c Fri Feb 11 23:08:38 2011 +0000
@@ -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;
+}
Home |
Main Index |
Thread Index |
Old Index