Copyright clean-up (part 1):
[AROS.git] / arch / all-native / kernel / kernel_bootmem.c
blobb24c1de8d9c450d4198e6a819a9bb4c179a26791
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*
7 * Boot-time memory management functions.
8 * This is a very simple allocator working on a continuous memory block.
9 * Its purpose is to help to set up initial boot-time data for your kernel,
10 * until it can do more serious thing.
11 * A popular usage is to store away boot information.
14 #include <aros/macros.h>
15 #include <string.h>
17 #include "kernel_base.h"
18 #include "kernel_bootmem.h"
19 #include "kernel_debug.h"
21 void *krnAllocBootMem(unsigned long size)
23 return krnAllocBootMemAligned(size, sizeof(void *));
26 void *krnAllocBootMemAligned(unsigned long size, unsigned int align)
28 void *addr = (void *)AROS_ROUNDUP2((unsigned long)BootMemPtr, align);
29 void *end = addr + size;
31 #ifdef __x86_64__
32 /* FIXME: Only x86-64 currently sets BootMemLimit */
33 if (end > BootMemLimit)
35 /* Our allocation must succeed. We can't continue without it. */
36 krnPanic(NULL, "Not enough memory for boot information\n"
37 "Increase reserved space in bootstrap");
39 #endif
41 BootMemPtr = end;
42 /* Clear the allocated memory. In many places we expect it. */
43 memset(addr, 0, size);
45 return addr;
48 void *BootMemPtr;
49 void *BootMemLimit;