Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/uebayasi-xip]: src/sys/uvm Implement device page struct vm_page * handling.
details: https://anonhg.NetBSD.org/src/rev/2c3251971049
branches: uebayasi-xip
changeset: 751549:2c3251971049
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Tue Feb 09 13:06:16 2010 +0000
description:
Implement device page struct vm_page * handling.
diffstat:
sys/uvm/uvm_page.c | 61 +++++++++++++++++++++++++++++++++++++----------------
sys/uvm/uvm_page.h | 11 +++++++--
2 files changed, 50 insertions(+), 22 deletions(-)
diffs (133 lines):
diff -r f90a28baaa0f -r 2c3251971049 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c Tue Feb 09 09:07:34 2010 +0000
+++ b/sys/uvm/uvm_page.c Tue Feb 09 13:06:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_page.c,v 1.153.2.7 2010/02/09 09:07:34 uebayasi Exp $ */
+/* $NetBSD: uvm_page.c,v 1.153.2.8 2010/02/09 13:06:16 uebayasi Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.153.2.7 2010/02/09 09:07:34 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.153.2.8 2010/02/09 13:06:16 uebayasi Exp $");
#include "opt_ddb.h"
#include "opt_uvmhist.h"
@@ -1033,6 +1033,36 @@
* 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.
*/
+
+#ifdef XIP
+#define VM_PAGE_DEVICE_MAGIC 0x2
+#define VM_PAGE_DEVICE_MAGIC_MASK 0x3
+#define VM_PAGE_DEVICE_MAGIC_SHIFT 2
+
+static inline struct vm_page *
+VM_PAGE_DEVICE_PA_TO_PG(paddr_t pa)
+{
+ paddr_t pf = pa >> PAGE_SHIFT;
+ uintptr_t cookie = pf << VM_PAGE_DEVICE_MAGIC_SHIFT;
+ return (void *)(cookie | VM_PAGE_DEVICE_MAGIC);
+}
+
+static inline paddr_t
+VM_PAGE_DEVICE_PG_TO_PA(const struct vm_page *pg)
+{
+ uintptr_t cookie = (uintptr_t)pg & ~VM_PAGE_DEVICE_MAGIC_MASK;
+ paddr_t pf = cookie >> VM_PAGE_DEVICE_MAGIC_SHIFT;
+ return pf << PAGE_SHIFT;
+}
+
+bool
+uvm_pageisdevice_p(const struct vm_page *pg)
+{
+
+ return ((uintptr_t)pg & VM_PAGE_DEVICE_MAGIC_MASK) == VM_PAGE_DEVICE_MAGIC;
+}
+#endif
+
struct vm_page *
uvm_phys_to_vm_page(paddr_t pa)
{
@@ -1040,35 +1070,28 @@
int off;
int psi;
+#ifdef XIP
+ psi = vm_physseg_find_device(pf, &off);
+ if (psi != -1)
+ return(VM_PAGE_DEVICE_PA_TO_PG(pa));
+#endif
psi = vm_physseg_find(pf, &off);
if (psi != -1)
return(&vm_physmem[psi].pgs[off]);
return(NULL);
}
-#if 0
-#ifdef XIP
-struct vm_page *
-uvm_phys_to_vm_page_device(paddr_t pa)
-{
- paddr_t pf = atop(pa);
- int off;
- int psi;
-
- psi = vm_physseg_find_device(pf, &off);
- if (psi != -1)
- return(&vm_physdev[psi].pgs[off]);
- return(NULL);
-}
-#endif
-#endif
-
paddr_t
uvm_vm_page_to_phys(const struct vm_page *pg)
{
const struct vm_physseg *seg;
int psi;
+#ifdef XIP
+ if (uvm_pageisdevice_p(pg)) {
+ return VM_PAGE_DEVICE_PG_TO_PA(pg);
+ }
+#endif
psi = VM_PHYSSEG_FIND(vm_physmem, vm_nphysmem, VM_PHYSSEG_OP_PG, 0, pg, NULL);
KASSERT(psi != -1);
seg = &vm_physmem[psi];
diff -r f90a28baaa0f -r 2c3251971049 sys/uvm/uvm_page.h
--- a/sys/uvm/uvm_page.h Tue Feb 09 09:07:34 2010 +0000
+++ b/sys/uvm/uvm_page.h Tue Feb 09 13:06:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_page.h,v 1.59.2.5 2010/02/09 09:07:34 uebayasi Exp $ */
+/* $NetBSD: uvm_page.h,v 1.59.2.6 2010/02/09 13:06:17 uebayasi Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -291,15 +291,20 @@
void uvm_pagewire(struct vm_page *);
void uvm_pagezero(struct vm_page *);
bool uvm_pageismanaged(paddr_t);
+#ifdef XIP
+bool uvm_pageisdevice_p(const struct vm_page *);
+#endif
int uvm_page_lookup_freelist(struct vm_page *);
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 *);
#ifdef XIP
int vm_physseg_find_device(paddr_t, int *);
+struct vm_page *uvm_phys_to_vm_page_device(paddr_t);
+paddr_t uvm_vm_page_to_phys_device(const struct vm_page *);
#endif
-struct vm_page *uvm_phys_to_vm_page(paddr_t);
-paddr_t uvm_vm_page_to_phys(const struct vm_page *);
/*
* macros
Home |
Main Index |
Thread Index |
Old Index