Module Name:    src
Committed By:   uebayasi
Date:           Fri Nov 12 05:23:41 UTC 2010

Modified Files:
        src/sys/rump/librump/rumpkern: vm.c
        src/sys/uvm: uvm_page.c uvm_page.h

Log Message:
Abstraction fix; move physical address -> per-page metadata (struct
vm_page *) "reverse" lookup code from uvm_page.h to uvm_page.c, to
help migration to not do that.

Likewise move per-page metadata (struct vm_page *) -> physical
address "forward" conversion code into *.c too.  This is called
only low-layer VM and MD code.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/rump/librump/rumpkern/vm.c
cvs rdiff -u -r1.162 -r1.163 src/sys/uvm/uvm_page.c
cvs rdiff -u -r1.64 -r1.65 src/sys/uvm/uvm_page.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/librump/rumpkern/vm.c
diff -u src/sys/rump/librump/rumpkern/vm.c:1.98 src/sys/rump/librump/rumpkern/vm.c:1.99
--- src/sys/rump/librump/rumpkern/vm.c:1.98	Wed Oct 27 20:44:49 2010
+++ src/sys/rump/librump/rumpkern/vm.c	Fri Nov 12 05:23:41 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm.c,v 1.98 2010/10/27 20:44:49 pooka Exp $	*/
+/*	$NetBSD: vm.c,v 1.99 2010/11/12 05:23:41 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.98 2010/10/27 20:44:49 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.99 2010/11/12 05:23:41 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -799,6 +799,24 @@
 }
 
 /*
+ * Physical address accessors.
+ */
+
+struct vm_page *
+uvm_phys_to_vm_page(paddr_t pa)
+{
+
+	return NULL;
+}
+
+paddr_t
+uvm_vm_page_to_phys(const struct vm_page *pg)
+{
+
+	return 0;
+}
+
+/*
  * Routines related to the Page Baroness.
  */
 

Index: src/sys/uvm/uvm_page.c
diff -u src/sys/uvm/uvm_page.c:1.162 src/sys/uvm/uvm_page.c:1.163
--- src/sys/uvm/uvm_page.c:1.162	Fri Nov 12 03:21:04 2010
+++ src/sys/uvm/uvm_page.c	Fri Nov 12 05:23:41 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.c,v 1.162 2010/11/12 03:21:04 uebayasi Exp $	*/
+/*	$NetBSD: uvm_page.c,v 1.163 2010/11/12 05:23:41 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.162 2010/11/12 03:21:04 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.163 2010/11/12 05:23:41 uebayasi Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -978,6 +978,30 @@
 #endif
 
 /*
+ * PHYS_TO_VM_PAGE: find vm_page for a PA.   used by MI code to get vm_pages
+ * back from an I/O mapping (ugh!).   used in some MD code as well.
+ */
+struct vm_page *
+uvm_phys_to_vm_page(paddr_t pa)
+{
+	paddr_t pf = atop(pa);
+	int	off;
+	int	psi;
+
+	psi = vm_physseg_find(pf, &off);
+	if (psi != -1)
+		return(&VM_PHYSMEM_PTR(psi)->pgs[off]);
+	return(NULL);
+}
+
+paddr_t
+uvm_vm_page_to_phys(const struct vm_page *pg)
+{
+
+	return pg->phys_addr;
+}
+
+/*
  * uvm_page_recolor: Recolor the pages if the new bucket count is
  * larger than the old one.
  */

Index: src/sys/uvm/uvm_page.h
diff -u src/sys/uvm/uvm_page.h:1.64 src/sys/uvm/uvm_page.h:1.65
--- src/sys/uvm/uvm_page.h:1.64	Fri Nov 12 03:21:04 2010
+++ src/sys/uvm/uvm_page.h	Fri Nov 12 05:23:41 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_page.h,v 1.64 2010/11/12 03:21:04 uebayasi Exp $	*/
+/*	$NetBSD: uvm_page.h,v 1.65 2010/11/12 05:23:41 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -294,8 +294,9 @@
 
 int uvm_page_lookup_freelist(struct vm_page *);
 
-static struct vm_page *PHYS_TO_VM_PAGE(paddr_t);
 int vm_physseg_find(paddr_t, int *);
+struct vm_page *uvm_phys_to_vm_page(paddr_t);
+paddr_t uvm_vm_page_to_phys(const struct vm_page *);
 
 /*
  * macros
@@ -303,7 +304,7 @@
 
 #define UVM_PAGE_TREE_PENALTY	4	/* XXX: a guess */
 
-#define VM_PAGE_TO_PHYS(entry)	((entry)->phys_addr)
+#define VM_PAGE_TO_PHYS(entry)	uvm_vm_page_to_phys(entry)
 
 /*
  * Compute the page color bucket for a given page.
@@ -311,23 +312,7 @@
 #define	VM_PGCOLOR_BUCKET(pg) \
 	(atop(VM_PAGE_TO_PHYS((pg))) & uvmexp.colormask)
 
-
-/*
- * PHYS_TO_VM_PAGE: find vm_page for a PA.   used by MI code to get vm_pages
- * back from an I/O mapping (ugh!).   used in some MD code as well.
- */
-static inline struct vm_page *
-PHYS_TO_VM_PAGE(paddr_t pa)
-{
-	paddr_t pf = atop(pa);
-	int	off;
-	int	psi;
-
-	psi = vm_physseg_find(pf, &off);
-	if (psi != -1)
-		return(&vm_physmem[psi].pgs[off]);
-	return(NULL);
-}
+#define	PHYS_TO_VM_PAGE(pa)	uvm_phys_to_vm_page(pa)
 
 #define VM_PAGE_IS_FREE(entry)  ((entry)->pqflags & PQ_FREE)
 #define	VM_FREE_PAGE_TO_CPU(pg)	((struct uvm_cpu *)((uintptr_t)pg->offset))

Reply via email to