PMM - alloc returns freed page
This commit is contained in:
parent
80cc165957
commit
776fd87862
13
src/kernel/memory/pmm.c
Normal file
13
src/kernel/memory/pmm.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <memory.h>
|
||||||
|
|
||||||
|
uintptr_t *first = 0;
|
||||||
|
|
||||||
|
void pmm_free(void *c)
|
||||||
|
{
|
||||||
|
first = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *pmm_alloc()
|
||||||
|
{
|
||||||
|
return first;
|
||||||
|
}
|
15
src/kernel/memory/pmm.tt
Normal file
15
src/kernel/memory/pmm.tt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// vim: ft=c
|
||||||
|
#include <ttest.h>
|
||||||
|
|
||||||
|
#include "pmm.c"
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint8_t data[PAGE_SIZE];
|
||||||
|
}__attribute__((packed)) mem[4];
|
||||||
|
|
||||||
|
TEST(alloc_returns_freed_page)
|
||||||
|
{
|
||||||
|
pmm_free(&mem[0]);
|
||||||
|
void *a = pmm_alloc();
|
||||||
|
ASSERT_EQ_PTR(a, &mem[0]);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user