print stivale2 memmap always

This commit is contained in:
Quinten Kock 2020-12-04 21:43:29 +01:00
parent d20c7723bf
commit 353adb0800
5 changed files with 23 additions and 1 deletions

View File

@ -25,6 +25,7 @@ struct stivale2_header header2 = {
void stivale2_main(struct stivale2_struct *info) { void stivale2_main(struct stivale2_struct *info) {
parse_stivale2(info); parse_stivale2(info);
print_stivale2_memmap(info);
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version}; char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
kmain(3, argv); kmain(3, argv);

View File

@ -153,3 +153,22 @@ void parse_stivale2(struct stivale2_struct *info) {
} }
putchar('\n'); putchar('\n');
} }
void print_stivale2_memmap(struct stivale2_struct *info) {
struct stivale2_tag *tag = (struct stivale2_tag*)(info->tags);
while(tag != 0) {
switch(tag->identifier) {
case STIVALE2_STRUCT_TAG_MEMMAP_ID: {
struct stivale2_struct_tag_memmap *m = (struct stivale2_struct_tag_memmap *)tag;
printf("Memmap (%d entries):\n", m->entries);
for (size_t i = 0; i < m->entries; i++) {
struct stivale2_mmap_entry me = m->memmap[i];
printf("\t[%x+%h] %x\n", (size_t)me.base, (size_t)me.length, me.type);
}
break;
}
}
tag = (struct stivale2_tag *)tag->next;
}
}

View File

@ -1,2 +1,3 @@
void print_stivale2(struct stivale2_struct *info); void print_stivale2(struct stivale2_struct *info);
void parse_stivale2(struct stivale2_struct *info); void parse_stivale2(struct stivale2_struct *info);
void print_stivale2_memmap(struct stivale2_struct *info);

View File

@ -26,6 +26,7 @@ struct stivale2_header header2 = {
void stivale2_main(struct stivale2_struct *info) { void stivale2_main(struct stivale2_struct *info) {
parse_stivale2(info); parse_stivale2(info);
print_stivale2_memmap(info);
char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version}; char *argv[3] = {"stivale2", info->bootloader_brand, info->bootloader_version};
kmain(3, argv); kmain(3, argv);

View File

@ -59,7 +59,7 @@ static void printdec(size_t num) {
static void printhuman(size_t num) { static void printhuman(size_t num) {
const char *unit = UNITS; const char *unit = UNITS;
while(num >= 2048 && *(unit+1)) { while(num >= 10240 && *(unit+1)) {
num /= 1024; num /= 1024;
unit++; unit++;
} }