/** * \file */ #include "cpu/arch_consts.h" #include "cpu/halt.h" #include "vga_err.h" #include #include #include #define BMAP_LEN (NUM_FRAMES/8) //!< The size of the physical memory manager's bitmap static char bmap[BMAP_LEN]; //!< Bitmap of allocated/non-present page frames /** * Get a bit in the bitmap * \param index The bit to get * \return the bit */ static char get_bmap_bit(int index) { int byte=index/8; int bit=index%8; char entry=bmap[byte]; return (entry&(1<0; } /** * Set a bit in the heap bitmap * \param index The bit to set */ static void set_bmap_bit(int index) { int byte=index/8; int bit=index%8; bmap[byte]=bmap[byte]|(1<type!=0) { switch (tag->type) { case MULTIBOOT_TAG_TYPE_MMAP: { found_mmap=1; struct multiboot_mmap_entry* orig_ptr=(struct multiboot_mmap_entry*)(((char*)tag)+16); for (struct multiboot_mmap_entry* ptr=orig_ptr;(char*)ptr<((char*)orig_ptr)+tag->size;ptr++) { if (ptr->type!=MULTIBOOT_MEMORY_AVAILABLE) continue; size_t start=ptr->addr; if (start<0x100000) continue; size_t end=start+ptr->len-1; if (start&(FRAME_SZ-1)) { start+=FRAME_SZ; } start=start>>FRAME_NO_OFFSET; end=end>>FRAME_NO_OFFSET; for (size_t i=start;isize+7)&0xFFFFFFF8)); } if (!found_mmap) { vga_write_string("[PANIC] No memory map supplied by bootloader!"); halt(); } for (size_t i=0;i>FRAME_NO_OFFSET; for (int i=start_page;i