summaryrefslogtreecommitdiff
path: root/kernel/mboot/mmap.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-18 21:18:59 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-18 21:20:49 -0400
commit3516b8a69087c31d45d06329ab79e9017301f6b8 (patch)
treef03aedcf40daf9c72a31e8d8b8c22e37aa6dee4a /kernel/mboot/mmap.c
parentmore pci devices (diff)
downloadcomus-3516b8a69087c31d45d06329ab79e9017301f6b8.tar.gz
comus-3516b8a69087c31d45d06329ab79e9017301f6b8.tar.bz2
comus-3516b8a69087c31d45d06329ab79e9017301f6b8.zip
set mmap limit
Diffstat (limited to 'kernel/mboot/mmap.c')
-rw-r--r--kernel/mboot/mmap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/mboot/mmap.c b/kernel/mboot/mmap.c
index e0963ca..d1d3d9a 100644
--- a/kernel/mboot/mmap.c
+++ b/kernel/mboot/mmap.c
@@ -1,3 +1,5 @@
+#include "comus/memory.h"
+#include "lib/klib.h"
#include <lib.h>
#include <comus/mboot.h>
@@ -32,6 +34,8 @@ int mboot_get_mmap(struct memory_map *res)
uintptr_t i = (uintptr_t)mmap->entries;
for (; i < (uintptr_t)mmap->entries + mmap->size;
i += mmap->entry_size, idx++) {
+ if (idx >= N_MMAP_ENTRY)
+ panic("Too many mmap entries: limit is %d", N_MMAP_ENTRY);
struct multiboot_mmap_entry *seg = (struct multiboot_mmap_entry *)i;
res->entries[idx].addr = seg->addr;
res->entries[idx].len = seg->len;