2 * Boot-time memory management functions.
3 * This is a very simple allocator working on a continuous memory block.
4 * Its purpose is to help to set up initial boot-time data for your kernel,
5 * until it can do more serious thing.
6 * A popular usage is to store away boot information.
9 #include <aros/macros.h>
12 #include "kernel_base.h"
13 #include "kernel_bootmem.h"
14 #include "kernel_debug.h"
16 void *krnAllocBootMem(unsigned long size
)
18 return krnAllocBootMemAligned(size
, sizeof(void *));
21 void *krnAllocBootMemAligned(unsigned long size
, unsigned int align
)
23 void *addr
= (void *)AROS_ROUNDUP2((unsigned long)BootMemPtr
, align
);
24 void *end
= addr
+ size
;
27 /* FIXME: Only x86-64 currently sets BootMemLimit */
28 if (end
> BootMemLimit
)
30 /* Our allocation must succeed. We can't continue without it. */
31 krnPanic(NULL
, "Not enough memory for boot information\n"
32 "Increase reserved space in bootstrap");
37 /* Clear the allocated memory. In many places we expect it. */
38 memset(addr
, 0, size
);