PMM -- Convert between virtual and physical address

This commit is contained in:
Thomas Lovén 2017-12-21 16:17:55 +01:00
parent 1daf8ed47b
commit 82fbafc38e
2 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,7 @@ uintptr_t *first = 0;
void pmm_free(void *c) void pmm_free(void *c)
{ {
c = (uintptr_t *)P2V(c);
*(uintptr_t *)c = (uintptr_t)first; *(uintptr_t *)c = (uintptr_t)first;
first = c; first = c;
} }
@ -12,5 +13,6 @@ void *pmm_alloc()
{ {
void *c = first; void *c = first;
first = (uintptr_t *)(c?*(uintptr_t *)c:0); first = (uintptr_t *)(c?*(uintptr_t *)c:0);
c = (uintptr_t *)V2P(c);
return c; return c;
} }

View File

@ -1,6 +1,11 @@
// vim: ft=c // vim: ft=c
#include <ttest.h> #include <ttest.h>
#include <memory.h>
#undef P2V
#define P2V(addr) (void *)((uintptr_t)(addr))
#undef V2P
#define V2P(addr) (void *)((uintptr_t)(addr))
#include "pmm.c" #include "pmm.c"
struct { struct {