summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-09-04 21:10:20 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-09-05 00:57:59 +0200
commit1b810de65b7ebdfc0d554bf7da0ee87250b2dc52 (patch)
treea9fbc8c19f424d685b8a4f11e3c5a7f1ca200dc3
parentc405e5ecfa016a069c854353b4435c38398cf507 (diff)
Free memory used by boot modules
* vm/vm_resident.c (pmap_startup): Warn when some pages could not be included in the allocator due to bad estimation. * kern/bootstrap.c: Include <vm/pmap.h>. (bootstrap_create): Call vm_page_create on bootstrap modules content.
-rw-r--r--kern/bootstrap.c11
-rw-r--r--vm/vm_resident.c5
2 files changed, 13 insertions, 3 deletions
diff --git a/kern/bootstrap.c b/kern/bootstrap.c
index c07b032..7819553 100644
--- a/kern/bootstrap.c
+++ b/kern/bootstrap.c
@@ -47,6 +47,7 @@
#include <kern/lock.h>
#include <vm/vm_kern.h>
#include <vm/vm_user.h>
+#include <vm/pmap.h>
#include <device/device_port.h>
#if MACH_KDB
@@ -107,10 +108,10 @@ task_insert_send_right(
void bootstrap_create()
{
int compat;
+ int n = 0;
#ifdef MACH_XEN
struct multiboot_module *bmods = ((struct multiboot_module *)
boot_info.mod_start);
- int n = 0;
if (bmods)
for (n = 0; bmods[n].mod_start; n++) {
bmods[n].mod_start = kvtophys(bmods[n].mod_start + (vm_offset_t) bmods);
@@ -263,8 +264,12 @@ void bootstrap_create()
panic ("ERROR in executing boot script: %s",
boot_script_error_string (losers));
}
- /* XXX at this point, we could free all the memory used
- by the boot modules and the boot loader's descriptors and such. */
+ /* XXX we could free the memory used
+ by the boot loader's descriptors and such. */
+ for (n = 0; n < boot_info.mods_count; n++) {
+ printf("freeing %dMiB\n", (bmods[n].mod_end - bmods[n].mod_start) >> 20);
+ vm_page_create(bmods[n].mod_start, bmods[n].mod_end);
+ }
}
static void
diff --git a/vm/vm_resident.c b/vm/vm_resident.c
index a633498..96354a4 100644
--- a/vm/vm_resident.c
+++ b/vm/vm_resident.c
@@ -393,6 +393,11 @@ void pmap_startup(
vm_page_init(&pages[i], paddr);
pages_initialized++;
}
+ i = 0;
+ while (pmap_next_page(&paddr))
+ i++;
+ if (i)
+ printf("%d memory page(s) left away\n", i);
/*
* Release pages in reverse order so that physical pages