Copyright clean-up (part 1):
[AROS.git] / arch / arm-native / ceboot / bootmem.c
blob6836dfac5872d5d4d324bfa97d61e8374463e399
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <windows.h>
8 #include <runtime.h>
9 #include "bootmem.h"
10 #include "winapi.h"
12 /* Size of bootinfo buffer - one page */
13 #define BOOTMEM_SIZE 4096
15 static void *bootmem_Virt;
16 static void *bootmem_Limit;
17 ULONG_PTR bootmem_Phys;
19 ULONG_PTR InitBootMem(void)
21 bootmem_Virt = AllocPhysMem(BOOTMEM_SIZE, PAGE_READWRITE, 0, 0, &bootmem_Phys);
23 if (bootmem_Virt)
25 bootmem_Limit = bootmem_Virt + BOOTMEM_SIZE;
26 /* This routine returns PHYSICAL address */
27 return bootmem_Phys;
29 else
30 return 0;
33 void *AllocBootMem(unsigned int size)
35 void *ptr = bootmem_Virt;
37 /* Align size at pointer boundary */
38 size = (size + sizeof(void *) - 1) & (~(sizeof(void *) - 1));
39 if (bootmem_Limit - ptr < size)
41 DisplayError("Not enough memory to build boot information (%d bytes requested)", size);
42 exit(0); /* I'm tired to write those if's... */
45 bootmem_Virt += size;
46 bootmem_Phys += size;
48 return ptr;
51 void *AddTag(unsigned int tag, ULONG_PTR data)
53 ULONG_PTR *ptr = AllocBootMem(sizeof(ULONG_PTR) * 2);
55 ptr[0] = tag;
56 ptr[1] = data;
58 return ptr;