diff options
author | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-05-06 15:14:11 -0400 |
---|---|---|
committer | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-05-06 15:14:11 -0400 |
commit | da396afa8b612b8f8ff07d71c57761a627b158eb (patch) | |
tree | b4935b29aca686c6ee17a583cffe149d7bb3c819 /kernel/mboot/mboot.c | |
parent | update forkman with spinlock (diff) | |
parent | start docs (diff) | |
download | comus-da396afa8b612b8f8ff07d71c57761a627b158eb.tar.gz comus-da396afa8b612b8f8ff07d71c57761a627b158eb.tar.bz2 comus-da396afa8b612b8f8ff07d71c57761a627b158eb.zip |
merge main into forkmanforkman
Diffstat (limited to '')
-rw-r--r-- | kernel/mboot/mboot.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/mboot/mboot.c b/kernel/mboot/mboot.c index e4547e7..8163f04 100644 --- a/kernel/mboot/mboot.c +++ b/kernel/mboot/mboot.c @@ -5,6 +5,8 @@ static volatile void *mboot = NULL; +extern char kernel_end[]; + void mboot_init(long magic, volatile void *ptr) { if (magic != MULTIBOOT2_BOOTLOADER_MAGIC) @@ -12,6 +14,23 @@ void mboot_init(long magic, volatile void *ptr) mboot = ptr; } +void *mboot_end(void) +{ + if (mboot == NULL) + return NULL; + + struct multiboot *info = (struct multiboot *)mboot; + uintptr_t mboot_end, initrd_end; + size_t initrd_len; + + mboot_end = (uintptr_t)info + info->total_size; + initrd_end = (uintptr_t)mboot_get_initrd_phys(&initrd_len); + if (initrd_end) + initrd_end += initrd_len; + + return (void *)MAX(mboot_end, initrd_end); +} + void *locate_mboot_table(uint32_t type) { if (mboot == NULL) |