put memory map detection into paging.c (grub_memory_map function)

This commit is contained in:
2025-05-10 15:48:10 +03:00
parent 745d85f413
commit 65f543fa92
3 changed files with 34 additions and 29 deletions
+1 -28
View File
@@ -153,34 +153,7 @@ void kmain(unsigned int magic, unsigned int info)
printf("bootloader: %s\n", mbi.boot_loader_name);
}
/* Check bit 6 to see if we have a valid memory map */
if(!(mbi.flags >> 6 & 0x1)) {
printf("invalid memory map given by GRUB bootloader\n");
while(1){}
}
/* Loop through the memory map and display the values */
int i;
for(i = 0; i < mbi.mmap_length;
i += sizeof(multiboot_memory_map_t))
{
multiboot_memory_map_t* mmmt =
(multiboot_memory_map_t*) (mbi.mmap_addr + i);
printf("Start Addr: %x | Length: %x | Size: %x | Type: %x\n",
mmmt->addr, mmmt->len, mmmt->size, mmmt->type);
if(mmmt->type == MULTIBOOT_MEMORY_AVAILABLE) {
/*
* Do something with this memory block!
* BE WARNED that some of memory shown as availiable is actually
* actively being used by the kernel! You'll need to take that
* into account before writing to memory!
*/
printf("available\n");
}
}
grub_memory_map(magic, &mbi);
isr_install();
pic_remap(0x20, 0x28);