Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/uebayasi-xip]: src/sys/uvm Initial attempt to implement uvm_pageofzero_x...
details: https://anonhg.NetBSD.org/src/rev/9d5cd4aed739
branches: uebayasi-xip
changeset: 751553:9d5cd4aed739
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Wed Feb 10 08:12:02 2010 +0000
description:
Initial attempt to implement uvm_pageofzero_xip(), which returns a pointer
to a single read-only zeroed page. This is meant to be used for XIP now.
Only compile tested.
diffstat:
sys/uvm/uvm_km.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
sys/uvm/uvm_km.h | 7 ++++++-
2 files changed, 57 insertions(+), 3 deletions(-)
diffs (100 lines):
diff -r f9a7ab06802f -r 9d5cd4aed739 sys/uvm/uvm_km.c
--- a/sys/uvm/uvm_km.c Wed Feb 10 02:12:39 2010 +0000
+++ b/sys/uvm/uvm_km.c Wed Feb 10 08:12:02 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_km.c,v 1.104 2009/11/07 07:27:49 cegger Exp $ */
+/* $NetBSD: uvm_km.c,v 1.104.2.1 2010/02/10 08:12:02 uebayasi Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -128,15 +128,17 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.104 2009/11/07 07:27:49 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.104.2.1 2010/02/10 08:12:02 uebayasi Exp $");
#include "opt_uvmhist.h"
+#include "opt_xip.h"
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/pool.h>
+#include <sys/once.h>
#include <uvm/uvm.h>
@@ -793,3 +795,50 @@
uvm_km_free(map, addr, PAGE_SIZE, UVM_KMF_WIRED);
#endif /* PMAP_UNMAP_POOLPAGE */
}
+
+#ifdef XIP
+/*
+ * uvm_pageofzero_xip: return a read-only page filled with zeroes.
+ *
+ * XXXUEBS Need better names.
+ */
+
+static void *uvm_pageofzero_xip_vaddr;
+static paddr_t uvm_pageofzero_xip_paddr;
+static int uvm_pageofzero_xip_init(void);
+
+void *
+uvm_pageofzero_xip(void)
+{
+ static ONCE_DECL(uvm_pageofzero_xip_inited);
+
+ RUN_ONCE(&uvm_pageofzero_xip_inited, uvm_pageofzero_xip_init);
+ return uvm_pageofzero_xip_vaddr;
+}
+
+paddr_t
+uvm_pageofzero_xip_phys_addr(void)
+{
+ static ONCE_DECL(uvm_pageofzero_xip_inited);
+
+ RUN_ONCE(&uvm_pageofzero_xip_inited, uvm_pageofzero_xip_init);
+ return uvm_pageofzero_xip_paddr;
+}
+
+static int
+uvm_pageofzero_xip_init(void)
+{
+ bool rv;
+
+ ASSERT_SLEEPABLE();
+
+ uvm_pageofzero_xip_vaddr = (void *)uvm_km_alloc_poolpage(kernel_map, true);
+ KASSERT(uvm_pageofzero_xip_vaddr != NULL);
+
+ rv = pmap_extract(pmap_kernel(), (vaddr_t)uvm_pageofzero_xip_vaddr,
+ &uvm_pageofzero_xip_paddr);
+ KASSERT(rv == true && uvm_pageofzero_xip_paddr != 0);
+
+ return 0;
+}
+#endif
diff -r f9a7ab06802f -r 9d5cd4aed739 sys/uvm/uvm_km.h
--- a/sys/uvm/uvm_km.h Wed Feb 10 02:12:39 2010 +0000
+++ b/sys/uvm/uvm_km.h Wed Feb 10 08:12:02 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_km.h,v 1.18 2008/12/01 10:54:57 ad Exp $ */
+/* $NetBSD: uvm_km.h,v 1.18.6.1 2010/02/10 08:12:02 uebayasi Exp $ */
/*
*
@@ -57,6 +57,11 @@
#endif /* defined(DEBUG) */
void uvm_km_va_drain(struct vm_map *, uvm_flag_t);
+#ifdef XIP
+void *uvm_pageofzero_xip(void);
+paddr_t uvm_pageofzero_xip_phys_addr(void);
+#endif
+
#endif /* _KERNEL */
#endif /* _UVM_UVM_KM_H_ */
Home |
Main Index |
Thread Index |
Old Index