cleans up a bit, adds a pmm panic

This commit is contained in:
2025-06-13 12:58:50 -04:00
parent af596cd43a
commit 99a842df7e
2 changed files with 14 additions and 6 deletions

View File

@ -2,10 +2,7 @@
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#ifdef __TESTING__
#include <stdio.h>
#endif
#include <kernel/_kernel.h>
#include <kernel/pmm.h>
@ -50,6 +47,12 @@ void pmm_init(void);
void* pmm_alloc_block(void);
void pmm_free_block(void* p);
void pmm_panic(const char* str)
{
printf("PMM: ");
panic(str);
}
void __pmm_set(uint32_t bit, struct pmm_mem_info* mem_block)
{
(mem_block->bitmap)[bit / 32] |= (1 << (bit % 32));
@ -131,10 +134,10 @@ void __pmm_free_block(void* p, struct pmm_mem_info* mem_block)
// TODO this might still be a little flaky
// should we be able to free any pointer? or just ones that we've given out?
if (idx == 0)
panic("Trying to free reserved memory!");
pmm_panic("Trying to free reserved memory!");
if (pmm_test(idx) == 0)
panic("Trying to free a block that was already free!");
pmm_panic("Trying to free a block that was already free!");
__pmm_unset(idx, mem_block);
}