#include #include "../halt.h" #include #include #include static char bmap[131072]; static char get_bmap_bit(int index) { int byte=index/8; int bit=index%8; char entry=bmap[byte]; return (entry&(1<0; } static void set_bmap_bit(int index) { int byte=index/8; int bit=index%8; bmap[byte]=bmap[byte]|(1<flags&&MULTIBOOT_INFO_MEM_MAP) { klog("PANIC","No memory map supplied by bootloader!"); halt(); } for (int i=0;i<131072;i++) { bmap[i]=0xFF; } uint32_t mmap_length=mbd->mmap_length; struct multiboot_mmap_entry* mmap_addr=(struct multiboot_mmap_entry*)(mbd->mmap_addr+0xC0000000); struct multiboot_mmap_entry* mmap_entry=mmap_addr; uint32_t size; for (int i=0;(uint32_t)mmap_entry<((uint32_t)mmap_addr+mmap_length);mmap_entry=(struct multiboot_mmap_entry*)((uint32_t)mmap_entry+size+4)) { size=mmap_entry->size; uint32_t start=mmap_entry->addr; uint32_t end=start+mmap_entry->len-1; uint32_t type=mmap_entry->type; if (type!=1 || start<0x100000) { continue; } if (start&0xFFF) { start+=0x1000; } start=start>>12; end=end>>12; for (uint32_t i=start;i