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-20 20:54:31 -0400
commit8f346ab6d960c03826d4a03292c3ff22c9d5911a (patch)
tree17879d01b8742dc7243acea323bda01ab4e503fa /kernel/mboot/mmap.c
parentmore pci devices (diff)
downloadcomus-8f346ab6d960c03826d4a03292c3ff22c9d5911a.tar.gz
comus-8f346ab6d960c03826d4a03292c3ff22c9d5911a.tar.bz2
comus-8f346ab6d960c03826d4a03292c3ff22c9d5911a.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;