change init code to support multiple cards. small fixes and corrections to code.
[AROS.git] / test / kernel / mmap.c
blob04db40a6b9ffc90ac2fe84837f6d4f33f214623e
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;
54 if (type > MMAP_TYPE_ACPINVS)
55 type = 0;
57 printf("Entry type %d <%s> addr 0x%016llx len 0x%016llx\n", mmap->type, types[type], (unsigned long long)mmap->addr, (unsigned long long)mmap->len);
59 len -= mmap->size + 4;
60 mmap = (struct mb_mmap *)(mmap->size + (unsigned long)mmap + 4);
63 return 0;