Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pmm_init(struct mb_info_t *mb_info)
- {
- uint32_t i;
- struct mb_mmap_t* mmap = mb_info->mmap_addr;
- struct mb_mmap_t* mmap_end = (void*)((uintptr_t)mb_info->mmap_addr +
- mb_info->mmap_length);
- struct mb_module_t *modules = mb_info->mods_addr;
- // mark everything as used
- for (i = 0; i<BITMAP_SIZE; i ++)
- bitmap[i] = 0x0;
- // mark every RAM address as free
- while (mmap < mmap_end) {
- if (mmap->type == 1) {
- uintptr_t addr = mmap->base;
- uintptr_t end_addr = addr + mmap->length;
- while (addr < end_addr) {
- pmm_free((void*) addr);
- addr += 0x1000;
- }
- }
- mmap++;
- }
- /* mark structs from above space as used */
- pmm_mark_used(mb_info);
- pmm_mark_used(modules);
- /* mark kernel used memory space as used */
- uintptr_t addr = (uintptr_t) &kernel_start;
- while (addr < (uintptr_t) &kernel_end) {
- pmm_mark_used((void*) addr);
- addr += 0x1000;
- }
- /* mark modules used memory space as used */
- for (i=0; i<mb_info->mods_count; i++) {
- addr = modules[i].mod_start;
- while (addr < modules[i].mod_end) {
- pmm_mark_used((void*)addr);
- addr += 0x1000;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment