Skip to content

Commit

Permalink
kernel/vm: Add page_get and make _page_get static
Browse files Browse the repository at this point in the history
  • Loading branch information
astalke committed May 16, 2024
1 parent 509945e commit 388288c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
5 changes: 3 additions & 2 deletions vm/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,9 @@ void vm_mapDestroy(process_t *p, vm_map_t *map)
rbnode_t *n;
int i = 0;

while ((a = pmap_destroy(&map->pmap, &i)))
vm_pageFree(_page_get(a));
while ((a = pmap_destroy(&map->pmap, &i))) {
vm_pageFree(page_get(a));
}

vm_munmap(map_common.kmap, map->pmap.pmapv, SIZE_PDIR);
vm_pageFree(map->pmap.pmapp);
Expand Down
5 changes: 3 additions & 2 deletions vm/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ page_t *vm_objectPage(vm_map_t *map, amap_t **amap, vm_object_t *o, void *vaddr,
if (o == NULL)
return vm_pageAlloc(SIZE_PAGE, PAGE_OWNER_APP);

if (o == (void *)-1)
return _page_get(offs);
if (o == (void *)-1) {
return page_get(offs);
}

proc_lockSet(&object_common.lock);

Expand Down
8 changes: 7 additions & 1 deletion vm/page-nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ int page_map(pmap_t *pmap, void *vaddr, addr_t pa, int attr)
}


page_t *_page_get(addr_t addr)
static page_t *_page_get(addr_t addr)
{
return NULL;
}


page_t *page_get(addr_t addr)
{
return NULL;
}
Expand Down
12 changes: 11 additions & 1 deletion vm/page.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int _page_get_cmp(void *key, void *item)
}


page_t *_page_get(addr_t addr)
static page_t *_page_get(addr_t addr)
{
page_t *p;
size_t np = (pages.freesz + pages.allocsz) / SIZE_PAGE;
Expand All @@ -186,6 +186,16 @@ page_t *_page_get(addr_t addr)
}


page_t *page_get(addr_t addr)
{
page_t *p;
proc_lockSet(&pages.lock);
p = _page_get(addr);
proc_lockClear(&pages.lock);
return p;
}


void vm_pageFreeAt(pmap_t *pmap, void *vaddr)
{
proc_lockSet(&pages.lock);
Expand Down
2 changes: 1 addition & 1 deletion vm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern void _page_free(page_t *lh);
extern void vm_pageFree(page_t *lh);


extern page_t *_page_get(addr_t addr);
extern page_t *page_get(addr_t addr);


extern void vm_pageFreeAt(pmap_t *pmap, void *vaddr);
Expand Down

0 comments on commit 388288c

Please sign in to comment.