added pmap_bootstrap_alloc(), the "before malloc" allocator.
authorWilliam Nesheim <william@ucbvax.Berkeley.EDU>
Fri, 30 Aug 1991 07:30:40 +0000 (23:30 -0800)
committerWilliam Nesheim <william@ucbvax.Berkeley.EDU>
Fri, 30 Aug 1991 07:30:40 +0000 (23:30 -0800)
SCCS-vsn: sys/hp300/hp300/pmap.c 7.6

usr/src/sys/hp300/hp300/pmap.c

index f739fde..430f559 100644 (file)
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)pmap.c      7.5 (Berkeley) %G%
+ *     @(#)pmap.c      7.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -58,7 +58,6 @@
 #include "vm/vm.h"
 #include "vm/vm_kern.h"
 #include "vm/vm_page.h"
 #include "vm/vm.h"
 #include "vm/vm_kern.h"
 #include "vm/vm_page.h"
-#include "vm/vm_statistics.h"
 
 #include "../include/cpu.h"
 
 
 #include "../include/cpu.h"
 
@@ -296,6 +295,36 @@ pmap_bootstrap(firstaddr, loadaddr)
 #endif
 }
 
 #endif
 }
 
+/*
+ * Bootstrap memory allocator. This function allows for early dynamic
+ * memory allocation until the virtual memory system has been bootstrapped.
+ * After that point, either kmem_alloc or malloc should be used. This
+ * function works by stealing pages from the (to be) managed page pool,
+ * stealing virtual address space, then mapping the pages and zeroing them.
+ *
+ * It should be used from pmap_bootstrap till vm_page_startup, afterwards
+ * it cannot be used, and will generate a panic if tried. Note that this
+ * memory will never be freed, and in essence it is wired down.
+ */
+void *
+pmap_bootstrap_alloc(size) {
+       vm_offset_t val;
+       int i;
+       extern boolean_t vm_page_startup_initialized;
+       
+       if (vm_page_startup_initialized)
+               panic("pmap_bootstrap_alloc: called after startup initialized");
+       size = round_page(size);
+       val = virtual_avail;
+
+       virtual_avail = pmap_map(virtual_avail, avail_start,
+               avail_start + size, VM_PROT_READ|VM_PROT_WRITE);
+       avail_start += size;
+
+       blkclr ((caddr_t) val, size);
+       return ((void *) val);
+}
+
 /*
  *     Initialize the pmap module.
  *     Called by vm_init, to initialize any structures that the pmap
 /*
  *     Initialize the pmap module.
  *     Called by vm_init, to initialize any structures that the pmap