Commit 93c8c872 authored by Mathieu Maret's avatar Mathieu Maret

Add types.h to distinguish physical/virt mem

parent 149b197a
......@@ -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) {
......
#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);
#pragma once
// Virtual address
typedef unsigned long vaddr_t;
// Physical address
typedef unsigned long paddr_t;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment