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.
This commit is contained in:
parent
9a0d0defa9
commit
77d80f38cd
|
@ -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>
|
||||
|
@ -798,6 +798,24 @@ uvmpdpol_anfree(struct vm_anon *an)
|
|||
/* nada */
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
@ -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"
|
||||
|
@ -977,6 +977,30 @@ vm_physseg_find_linear(struct vm_physseg *segs, int nsegs, paddr_t pframe, int *
|
|||
}
|
||||
#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.
|
||||
|
|
|
@ -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 @@ bool uvm_pageismanaged(paddr_t);
|
|||
|
||||
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 @@ int vm_physseg_find(paddr_t, int *);
|
|||
|
||||
#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 @@ int vm_physseg_find(paddr_t, int *);
|
|||
#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))
|
||||
|
|
Loading…
Reference in New Issue