Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode/usermode Implement switch to have a sparse...
details: https://anonhg.NetBSD.org/src/rev/e1d763e2ada4
branches: trunk
changeset: 769301:e1d763e2ada4
user: reinoud <reinoud%NetBSD.org@localhost>
date: Tue Sep 06 09:37:41 2011 +0000
description:
Implement switch to have a sparse memory file or to fill it beforehand.
diffstat:
sys/arch/usermode/usermode/pmap.c | 38 +++++++++++++++++++++++++++++++-------
1 files changed, 31 insertions(+), 7 deletions(-)
diffs (80 lines):
diff -r 38fe8a3fa0c0 -r e1d763e2ada4 sys/arch/usermode/usermode/pmap.c
--- a/sys/arch/usermode/usermode/pmap.c Tue Sep 06 08:44:39 2011 +0000
+++ b/sys/arch/usermode/usermode/pmap.c Tue Sep 06 09:37:41 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.56 2011/09/06 08:44:39 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.57 2011/09/06 09:37:41 reinoud Exp $ */
/*-
* Copyright (c) 2011 Reinoud Zandijk <reinoud%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.56 2011/09/06 08:44:39 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.57 2011/09/06 09:37:41 reinoud Exp $");
#include "opt_memsize.h"
#include "opt_kmempages.h"
@@ -104,6 +104,8 @@
vaddr_t kmem_user_start, kmem_user_end;
vaddr_t kmem_ext_cur_start, kmem_ext_cur_end;
+#define SPARSE_MEMFILE
+
void
pmap_bootstrap(void)
{
@@ -119,7 +121,6 @@
vaddr_t va;
uintptr_t pg;
void *addr;
- char dummy;
int err;
extern void _init(void); /* start of kernel */
@@ -188,7 +189,7 @@
aprint_debug("\tkmem_ext_end\t%p\n", (void *) kmem_ext_end);
aprint_debug("\tkmem_user_start\t%p\n", (void *) kmem_user_start);
aprint_debug("\tkmem_user_end\t%p\n", (void *) kmem_user_end);
- aprint_debug("\n\n\n");
+ aprint_debug("\n\n");
aprint_debug("Creating memory mapped backend\n");
@@ -203,9 +204,32 @@
/* file_len is the backing store length, nothing to do with placement */
file_len = 1024 * MEMSIZE;
- wlen = thunk_pwrite(mem_fh, &dummy, 1, file_len - 1);
- if (wlen != 1)
- panic("pmap_bootstrap: can't grow file\n");
+
+#ifdef SPARSE_MEMFILE
+ {
+ char dummy;
+
+ wlen = thunk_pwrite(mem_fh, &dummy, 1, file_len - 1);
+ if (wlen != 1)
+ panic("pmap_bootstrap: can't grow file\n");
+ }
+#else
+ {
+ void *block;
+
+ printf("Creating memory file\r");
+ block = thunk_malloc(PAGE_SIZE);
+ if (!block)
+ panic("pmap_bootstrap: can't malloc writeout block");
+
+ for (pg = 0; pg < file_len; pg += PAGE_SIZE) {
+ wlen = thunk_pwrite(mem_fh, block, PAGE_SIZE, pg);
+ if (wlen != PAGE_SIZE)
+ panic("pmap_bootstrap: write fails, disc full?");
+ }
+ thunk_free(block);
+ }
+#endif
/* protect the current kernel section */
/* XXX kernel stack? */
Home |
Main Index |
Thread Index |
Old Index