Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/uebayasi-xip]: src/sys Factor out the part which lookups physical page "...
details: https://anonhg.NetBSD.org/src/rev/546ec9b02f4f
branches: uebayasi-xip
changeset: 751860:546ec9b02f4f
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Nov 16 07:44:24 2010 +0000
description:
Factor out the part which lookups physical page "identity" from
UVM object, into sys/uvm/uvm_vnode.c:uvn_findpage_xip(). Eventually
this will become a call to cdev UVM object pager.
diffstat:
sys/miscfs/genfs/genfs_io.c | 25 ++++++++-----------------
sys/uvm/uvm_extern.h | 3 ++-
sys/uvm/uvm_vnode.c | 40 ++++++++++++++++++++++++++++++++++++++--
3 files changed, 48 insertions(+), 20 deletions(-)
diffs (129 lines):
diff -r 00996a328fc9 -r 546ec9b02f4f sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c Tue Nov 16 03:03:28 2010 +0000
+++ b/sys/miscfs/genfs/genfs_io.c Tue Nov 16 07:44:24 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_io.c,v 1.36.2.31 2010/11/15 17:32:01 uebayasi Exp $ */
+/* $NetBSD: genfs_io.c,v 1.36.2.32 2010/11/16 07:44:25 uebayasi Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.31 2010/11/15 17:32:01 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.32 2010/11/16 07:44:25 uebayasi Exp $");
#include "opt_xip.h"
@@ -869,29 +869,20 @@
* XIP page metadata assignment
* - Unallocated block is redirected to the dedicated zero'ed
* page.
- * - Assume that struct vm_page *[] array of this segment is
- * allocated and linearly ordered by physical address.
*/
if (blkno < 0) {
zero_page = uvm_page_zeropage_alloc();
KASSERT(zero_page != NULL);
pps[i] = zero_page;
} else {
- struct vm_physseg *seg;
- daddr_t seg_off;
- struct vm_page *pg;
+ daddr_t blk_off, fs_off;
- seg = devvp->v_physseg;
- KASSERT(seg != NULL);
- /* bus_space_mmap cookie -> paddr_t */
- seg_off = (blkno << dev_bshift) +
- (off - (lbn << fs_bshift));
- KASSERT((seg_off & PAGE_MASK) == 0);
- pg = seg->pgs + (seg_off >> PAGE_SHIFT);
- KASSERT(pg->phys_addr ==
- (seg->start << PAGE_SHIFT) + seg_off);
+ blk_off = blkno << dev_bshift;
+ fs_off = off - (lbn << fs_bshift);
- pps[i] = pg;
+ pps[i] = uvn_findpage_xip(&devvp->v_uobj,
+ blk_off + fs_off);
+ KASSERT(pps[i] != NULL);
}
UVMHIST_LOG(ubchist, "xip pgs %d => phys_addr=0x%lx (%p)",
diff -r 00996a328fc9 -r 546ec9b02f4f sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Tue Nov 16 03:03:28 2010 +0000
+++ b/sys/uvm/uvm_extern.h Tue Nov 16 07:44:24 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.161.2.11 2010/11/15 08:41:44 uebayasi Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.161.2.12 2010/11/16 07:44:24 uebayasi Exp $ */
/*
*
@@ -763,6 +763,7 @@
bool uvn_text_p(struct uvm_object *);
bool uvn_clean_p(struct uvm_object *);
bool uvn_needs_writefault_p(struct uvm_object *);
+struct vm_page *uvn_findpage_xip(struct uvm_object *, off_t);
/* kern_malloc.c */
void kmeminit_nkmempages(void);
diff -r 00996a328fc9 -r 546ec9b02f4f sys/uvm/uvm_vnode.c
--- a/sys/uvm/uvm_vnode.c Tue Nov 16 03:03:28 2010 +0000
+++ b/sys/uvm/uvm_vnode.c Tue Nov 16 07:44:24 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_vnode.c,v 1.93.2.2 2010/08/25 14:21:23 uebayasi Exp $ */
+/* $NetBSD: uvm_vnode.c,v 1.93.2.3 2010/11/16 07:44:25 uebayasi Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.93.2.2 2010/08/25 14:21:23 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.93.2.3 2010/11/16 07:44:25 uebayasi Exp $");
#include "opt_uvmhist.h"
#include "opt_xip.h"
@@ -404,3 +404,39 @@
return uvn_clean_p(uobj) ||
(vp->v_iflag & (VI_WRMAP|VI_WRMAPDIRTY)) == VI_WRMAP;
}
+
+/*
+ * uvn_findpage_xip
+ * Lookup a physical page identity (== struct vm_page * in
+ * the current UVM design) within the given vnode, at the
+ * given offset.
+ */
+struct vm_page *
+uvn_findpage_xip(struct uvm_object *uobj, off_t off)
+{
+ struct vnode *vp = (struct vnode *)uobj;
+ struct vm_physseg *seg;
+ struct vm_page *pg;
+
+ KASSERT((vp->v_vflag & VV_XIP) != 0);
+ KASSERT((off & PAGE_MASK) == 0);
+
+ /*
+ * Lookup a physical page identity from the underlying physical
+ * segment.
+ *
+ * Eventually, this will be replaced by a call of character
+ * device pager method, which is a generalized version of
+ * cdev_mmap(). Which means that v_physseg will become struct
+ * uvm_object *, and this will call cdev_page(uobj, off).
+ */
+
+ seg = vp->v_physseg;
+ KASSERT(seg != NULL);
+
+ pg = seg->pgs + (off >> PAGE_SHIFT);
+
+ KASSERT(pg->phys_addr == (seg->start << PAGE_SHIFT) + off);
+
+ return pg;
+}
Home |
Main Index |
Thread Index |
Old Index