Commit 93f5fa44 authored by Vikram Narayanan's avatar Vikram Narayanan

lcd/liblcd: Define page alloc/free helpers

Define helpers for __get_free_page(s) and free_page(s)
Signed-off-by: Vikram Narayanan's avatarVikram Narayanan <vikram186@gmail.com>
parent b7af9840
......@@ -302,6 +302,12 @@ static inline void force_up_write(void *x)
#undef __pa
#define __pa(vaddr) gpa_val(lcd_gva2gpa(__gva((unsigned long)vaddr)))
#undef free_page
#define free_page(addr) __lcd_free_pages(addr, 0)
#undef __get_free_page
#define __get_free_page(gfp_mask) __lcd_get_free_pages(gfp_mask, 0)
/* The "real" get_current tries to read a percpu variable that using
* the %gs segment register. */
#undef get_current
......
......@@ -183,6 +183,9 @@ void _lcd_munmap(cptr_t mo, gpa_t base);
*/
struct page *lcd_alloc_pages_exact_node(int nid, unsigned int flags,
unsigned int order);
struct page *lcd_alloc_pages_node(int nid, unsigned int flags,
unsigned int order);
/**
* lcd_alloc_pages -- Get free pages from the heap
* @flags: GFP flags to control allocation
......@@ -191,6 +194,11 @@ struct page *lcd_alloc_pages_exact_node(int nid, unsigned int flags,
* Similar to lcd_alloc_pages_exact_node.
*/
struct page *lcd_alloc_pages(unsigned int flags, unsigned int order);
void *__lcd_get_free_pages(gfp_t mask, unsigned int order);
void __lcd_free_pages(unsigned long addr, unsigned int order);
/**
* lcd_free_pages -- Free pages allocated via lcd_alloc_pages
* @base: pointer to first struct page in the chunk
......
......@@ -331,6 +331,15 @@ static inline struct lcd_page_block *heap_struct_page_to_page_block(
/* PAGE ALLOC INTERFACE ---------------------------------------- */
struct page *lcd_alloc_pages_node(int nid, unsigned int flags,
unsigned int order)
{
/*
* For now, we ignore the node id (not numa aware).
*/
return lcd_alloc_pages(flags, order);
}
struct page *lcd_alloc_pages_exact_node(int nid, unsigned int flags,
unsigned int order)
{
......@@ -551,3 +560,15 @@ fail2:
fail1:
return ret;
}
void *__lcd_get_free_pages(gfp_t mask, unsigned int order)
{
struct page *p = lcd_alloc_pages(mask, order);
return p ? lcd_page_address(p) : NULL;
}
void __lcd_free_pages(unsigned long addr, unsigned int order)
{
if (addr)
lcd_free_pages(heap_addr_to_struct_page(__gva(addr)), order);
}
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