Humble script for creating the port's snapshots.
[AROS.git] / test / kernel / mmap.c
blob98e8a69c9a0e242a592f0bd0656731ead08fba9b
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/kernel.h>
7 #include <aros/multiboot.h>
8 #include <proto/exec.h>
9 #include <proto/kernel.h>
10 #include <proto/utility.h>
11 #include <proto/kernel.h>
13 #include <stdio.h>
15 int __nocommandline = 1;
17 static const char *types[] =
19 "Unknown ",
20 "Avalable ",
21 "Reserved ",
22 "ACPI Data",
23 "ACPI NVS "
26 int main(void)
28 struct TagItem *tags;
29 struct mb_mmap *mmap;
30 IPTR len;
31 APTR KernelBase = OpenResource("kernel.resource");
33 if (!KernelBase)
35 printf("Failed to open kernel.resource!\n");
36 return 20;
39 tags = KrnGetBootInfo();
40 if (!tags)
42 printf("No boot information from the bootstrap!\n");
43 return 20;
46 mmap = (struct mb_mmap *)GetTagData(KRN_MMAPAddress, 0, tags);
47 len = GetTagData(KRN_MMAPLength, 0, tags);
49 if (!mmap || !len)
51 printf("No memory map provided by the bootstrap!\n");
52 return 20;
55 printf("Memory map at 0x%p, length %lu:\n", mmap, len);
56 while (len >= sizeof(struct mb_mmap))
58 unsigned int type = mmap->type;
59 unsigned long long memaddr = mmap->addr;
60 unsigned long long memlen = mmap->len;
62 if (type > MMAP_TYPE_ACPINVS)
63 type = 0;
65 #if __WORDSIZE < 64
66 memaddr |= (unsigned long long)mmap->addr_high << 32;
67 memlen |= (unsigned long long)mmap->len_high << 32;
68 #endif
70 printf("Entry size %d type %d <%s> addr 0x%016llx len 0x%016llx\n", mmap->size, mmap->type, types[type], memaddr, memlen);
72 len -= mmap->size + 4;
73 mmap = (struct mb_mmap *)(mmap->size + (unsigned long)mmap + 4);
76 return 0;