Allow to unref unrefered page
This commit is contained in:
parent
4aa093034b
commit
2c6ffe34a1
@ -1,8 +1,9 @@
|
|||||||
#include "mem.h"
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
#include "errno.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "klibc.h"
|
#include "klibc.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "mem.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
static struct phyMemDesc *pageDesc = (struct phyMemDesc *)&__ld_kernel_end;
|
static struct phyMemDesc *pageDesc = (struct phyMemDesc *)&__ld_kernel_end;
|
||||||
@ -139,9 +140,10 @@ int unrefPhyPage(paddr_t addr)
|
|||||||
{
|
{
|
||||||
struct phyMemDesc *mem = addr2memDesc(addr);
|
struct phyMemDesc *mem = addr2memDesc(addr);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
return -1;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
assert(mem->ref > 0);
|
if(mem->ref <= 0)
|
||||||
|
return -EINVAL;
|
||||||
mem->ref--;
|
mem->ref--;
|
||||||
if (mem->ref == 0) {
|
if (mem->ref == 0) {
|
||||||
allocatedPage--;
|
allocatedPage--;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#define PAGE_SHIFT 12U
|
#define PAGE_SHIFT 12U
|
||||||
#define PAGE_SIZE (1U << PAGE_SHIFT)
|
#define PAGE_SIZE (1U << PAGE_SHIFT)
|
||||||
|
#define PAGE_MASK (PAGE_SIZE - 1)
|
||||||
|
|
||||||
|
|
||||||
// Defined in linker.ld script
|
// Defined in linker.ld script
|
||||||
extern uint32_t __ld_kernel_begin;
|
extern uint32_t __ld_kernel_begin;
|
||||||
|
Loading…
Reference in New Issue
Block a user