Fixed spacing in debug message.
[AROS.git] / test / kernel / mmap.c
blob649df300da32497732696842be21fe5bdbf907cf
1 #include <aros/kernel.h>
2 #include <aros/multiboot.h>
3 #include <proto/exec.h>
4 #include <proto/kernel.h>
5 #include <proto/utility.h>
7 #include <stdio.h>
9 int __nocommandline = 1;
11 static const char *types[] =
13 "Unknown ",
14 "Avalable ",
15 "Reserved ",
16 "ACPI Data",
17 "ACPI NVS "
20 int main(void)
22 struct TagItem *tags;
23 struct mb_mmap *mmap;
24 IPTR len;
25 APTR KernelBase = OpenResource("kernel.resource");
27 if (!KernelBase)
29 printf("Failed to open kernel.resource!\n");
30 return 20;
33 tags = KrnGetBootInfo();
34 if (!tags)
36 printf("No boot information from the bootstrap!\n");
37 return 20;
40 mmap = (struct mb_mmap *)GetTagData(KRN_MMAPAddress, 0, tags);
41 len = GetTagData(KRN_MMAPLength, 0, tags);
43 if (!mmap || !len)
45 printf("No memory map provided by the bootstrap!\n");
46 return 20;
49 printf("Memory map at 0x%p, length %lu:\n", mmap, len);
50 while (len >= sizeof(struct mb_mmap))
52 unsigned int type = mmap->type;
53 unsigned long long memaddr = mmap->addr;
54 unsigned long long memlen = mmap->len;
56 if (type > MMAP_TYPE_ACPINVS)
57 type = 0;
59 #if __WORDSIZE < 64
60 memaddr |= (unsigned long long)mmap->addr_high << 32;
61 memlen |= (unsigned long long)mmap->len_high << 32;
62 #endif
64 printf("Entry size %d type %d <%s> addr 0x%016llx len 0x%016llx\n", mmap->size, mmap->type, types[type], memaddr, memlen);
66 len -= mmap->size + 4;
67 mmap = (struct mb_mmap *)(mmap->size + (unsigned long)mmap + 4);
70 return 0;