add getting memory map from grub
This commit is contained in:
@@ -144,10 +144,43 @@ void kmain(unsigned int magic, unsigned int info)
|
|||||||
terminal_initialize();
|
terminal_initialize();
|
||||||
printf("KatauOS booting up\n");
|
printf("KatauOS booting up\n");
|
||||||
|
|
||||||
|
if(magic != MULTIBOOT_BOOTLOADER_MAGIC) {
|
||||||
|
printf("invalid magic number!\n");
|
||||||
|
while(1){}
|
||||||
|
}
|
||||||
|
|
||||||
if(mbi.flags & MULTIBOOT_INFO_BOOT_LOADER_NAME) {
|
if(mbi.flags & MULTIBOOT_INFO_BOOT_LOADER_NAME) {
|
||||||
printf("bootloader: %s\n", mbi.boot_loader_name);
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
isr_install();
|
isr_install();
|
||||||
pic_remap(0x20, 0x28);
|
pic_remap(0x20, 0x28);
|
||||||
|
|||||||
Reference in New Issue
Block a user