Add types.h to distinguish physical/virt mem
This commit is contained in:
parent
149b197a65
commit
93c8c87285
@ -34,7 +34,7 @@ int memSetup(unsigned long upper_mem)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mem_desc *addr2memDesc(unsigned long addr)
|
struct mem_desc *addr2memDesc(paddr_t addr)
|
||||||
{
|
{
|
||||||
if (addr > top_mem || addr < bottom_mem)
|
if (addr > top_mem || addr < bottom_mem)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -43,7 +43,7 @@ struct mem_desc *addr2memDesc(unsigned long addr)
|
|||||||
return page_desc + idx;
|
return page_desc + idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long allocPhyPage(void)
|
paddr_t allocPhyPage(void)
|
||||||
{
|
{
|
||||||
if (list_is_empty(free_page)) {
|
if (list_is_empty(free_page)) {
|
||||||
return (unsigned long)NULL;
|
return (unsigned long)NULL;
|
||||||
@ -54,7 +54,7 @@ unsigned long allocPhyPage(void)
|
|||||||
return mem->phy_addr;
|
return mem->phy_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unrefPhyPage(unsigned long addr)
|
int unrefPhyPage(paddr_t addr)
|
||||||
{
|
{
|
||||||
struct mem_desc *mem = addr2memDesc(addr);
|
struct mem_desc *mem = addr2memDesc(addr);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
@ -69,7 +69,7 @@ int unrefPhyPage(unsigned long addr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int refPhyPage(unsigned long addr)
|
int refPhyPage(paddr_t addr)
|
||||||
{
|
{
|
||||||
struct mem_desc *mem = addr2memDesc(addr);
|
struct mem_desc *mem = addr2memDesc(addr);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "types.h"
|
||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
|
|
||||||
|
|
||||||
@ -10,13 +11,13 @@ extern uint32_t __ld_kernel_begin;
|
|||||||
extern uint32_t __ld_kernel_end;
|
extern uint32_t __ld_kernel_end;
|
||||||
|
|
||||||
struct mem_desc{
|
struct mem_desc{
|
||||||
unsigned long phy_addr;
|
paddr_t phy_addr;
|
||||||
unsigned long ref;
|
unsigned long ref;
|
||||||
struct mem_desc *next, *prev;
|
struct mem_desc *next, *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int memSetup(unsigned long upper_mem);
|
int memSetup(unsigned long upper_mem);
|
||||||
unsigned long allocPhyPage(void);
|
paddr_t allocPhyPage(void);
|
||||||
int unrefPhyPage(unsigned long addr);
|
int unrefPhyPage(paddr_t addr);
|
||||||
int refPhyPage(unsigned long addr);
|
int refPhyPage(paddr_t addr);
|
||||||
|
7
core/types.h
Normal file
7
core/types.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Virtual address
|
||||||
|
typedef unsigned long vaddr_t;
|
||||||
|
|
||||||
|
// Physical address
|
||||||
|
typedef unsigned long paddr_t;
|
Loading…
Reference in New Issue
Block a user