diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-03 22:19:32 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-03 22:19:32 -0400 |
commit | 876970bcfd69ed3742d1a47640aa551578f22919 (patch) | |
tree | 2dddbc00f9ffccf687f1e5f1055e19b3939a73a3 /kernel/mboot/mboot.c | |
parent | add 64-bit idt/pic and fix paging (diff) | |
download | comus-876970bcfd69ed3742d1a47640aa551578f22919.tar.gz comus-876970bcfd69ed3742d1a47640aa551578f22919.tar.bz2 comus-876970bcfd69ed3742d1a47640aa551578f22919.zip |
load multiboot memory map, heap is done!!!
Diffstat (limited to 'kernel/mboot/mboot.c')
-rw-r--r-- | kernel/mboot/mboot.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/kernel/mboot/mboot.c b/kernel/mboot/mboot.c new file mode 100644 index 0000000..08a0f37 --- /dev/null +++ b/kernel/mboot/mboot.c @@ -0,0 +1,26 @@ + +#include "mboot.h" + +void *locate_mboot_table(volatile void *mboot, uint32_t type) +{ + struct mboot_info *info = (struct mboot_info *) mboot; + const char *mboot_end = ((char *) info) + info->total_size; + + char *tag_ptr = info->tags; + + while (tag_ptr < mboot_end) { + struct mboot_tag *tag = (struct mboot_tag *) tag_ptr; + + if (tag->type == type) + return tag; + + // goto next + int size = tag->size; + if (size % 8 != 0) { + size += 8 - (size % 8); + } + tag_ptr += size; + } + + return NULL; +} |