#include <kern/assert.h>
#include <vm/vm_kern.h>
#include <vm/vm_map.h>
+#include <vm/pmap.h>
#include <mach/vm_param.h>
/*
btlog_recordindex_t freelist;
};
+extern boolean_t vm_kernel_ready;
extern boolean_t kmem_alloc_ready;
#define lookup_btrecord(btlog, index) \
kern_return_t ret;
size_t btrecord_size;
- if (!kmem_alloc_ready)
+ if (vm_kernel_ready && !kmem_alloc_ready)
return NULL;
if (numrecords > BTLOG_MAX_RECORDS)
/* since rounding to a page size might hold more, recalculate */
numrecords = MIN(BTLOG_MAX_RECORDS,
(buffersize_needed - sizeof(btlog_t))/btrecord_size);
-
- ret = kmem_alloc(kernel_map, &buffer, buffersize_needed);
+
+ if (kmem_alloc_ready) {
+ ret = kmem_alloc(kernel_map, &buffer, buffersize_needed, VM_KERN_MEMORY_DIAG);
+ } else {
+ buffer = (vm_address_t)pmap_steal_memory(buffersize_needed);
+ ret = KERN_SUCCESS;
+ }
if (ret != KERN_SUCCESS)
return NULL;