diff --git a/core/mem.c b/core/mem.c index 8e1bdc7..685fddd 100644 --- a/core/mem.c +++ b/core/mem.c @@ -34,7 +34,7 @@ int memSetup(unsigned long upper_mem) return 0; } -struct mem_desc *addr2memDesc(unsigned long addr) +struct mem_desc *addr2memDesc(paddr_t addr) { if (addr > top_mem || addr < bottom_mem) return NULL; @@ -43,7 +43,7 @@ struct mem_desc *addr2memDesc(unsigned long addr) return page_desc + idx; } -unsigned long allocPhyPage(void) +paddr_t allocPhyPage(void) { if (list_is_empty(free_page)) { return (unsigned long)NULL; @@ -54,7 +54,7 @@ unsigned long allocPhyPage(void) return mem->phy_addr; } -int unrefPhyPage(unsigned long addr) +int unrefPhyPage(paddr_t addr) { struct mem_desc *mem = addr2memDesc(addr); if (!mem) { @@ -69,7 +69,7 @@ int unrefPhyPage(unsigned long addr) return 0; } -int refPhyPage(unsigned long addr) +int refPhyPage(paddr_t addr) { struct mem_desc *mem = addr2memDesc(addr); if (!mem) { diff --git a/core/mem.h b/core/mem.h index 1249c0d..bdba9f8 100644 --- a/core/mem.h +++ b/core/mem.h @@ -1,4 +1,5 @@ #pragma once +#include "types.h" #include "stdarg.h" @@ -10,13 +11,13 @@ extern uint32_t __ld_kernel_begin; extern uint32_t __ld_kernel_end; struct mem_desc{ - unsigned long phy_addr; + paddr_t phy_addr; unsigned long ref; struct mem_desc *next, *prev; }; int memSetup(unsigned long upper_mem); -unsigned long allocPhyPage(void); -int unrefPhyPage(unsigned long addr); -int refPhyPage(unsigned long addr); +paddr_t allocPhyPage(void); +int unrefPhyPage(paddr_t addr); +int refPhyPage(paddr_t addr); diff --git a/core/types.h b/core/types.h new file mode 100644 index 0000000..44b9fca --- /dev/null +++ b/core/types.h @@ -0,0 +1,7 @@ +#pragma once + +// Virtual address +typedef unsigned long vaddr_t; + +// Physical address +typedef unsigned long paddr_t;