multiboot1: account for memory that crosses 1MB when summing up sizes

This commit is contained in:
Kacper Słomiński 2021-06-30 20:59:59 +02:00
parent 78ec547086
commit 6d47bf9d81

View File

@ -225,10 +225,17 @@ void multiboot1_load(char *config, char *cmdline) {
memmap[i].type = MEMMAP_USABLE;
if (memmap[i].type == MEMMAP_USABLE) {
if (memmap[i].base < 0x100000)
memory_lower += memmap[i].length;
else
if (memmap[i].base < 0x100000) {
if (memmap[i].base + memmap[i].length > 0x100000) {
size_t low_len = 0x100000 - memmap[i].base;
memory_lower += low_len;
memory_upper += memmap[i].length - low_len;
} else {
memory_lower += memmap[i].length;
}
} else {
memory_upper += memmap[i].length;
}
}
}