xref: /kvm-unit-tests/lib/vmalloc.h (revision dbd3800490429358367c717669aab76678429ef1)
1 #ifndef _VMALLOC_H_
2 #define _VMALLOC_H_
3 
4 #include <asm/page.h>
5 
6 /* Allocate consecutive virtual pages (without backing) */
7 extern void *alloc_vpages(ulong nr);
8 /* Allocate consecutive and aligned virtual pages (without backing) */
9 extern void *alloc_vpages_aligned(ulong nr, unsigned int alignment_order);
10 
11 /* Allocate one virtual page (without backing) */
12 extern void *alloc_vpage(void);
13 /* Set the top of the virtual address space */
14 extern void init_alloc_vpage(void *top);
15 /* Set up the virtual allocator; also sets up the page allocator if needed */
16 extern void setup_vm(void);
17 /* As above, plus passes an opaque value to setup_mmu(). */
18 extern void __setup_vm(void *opaque);
19 
20 /* Set up paging */
21 extern void *setup_mmu(phys_addr_t top, void *opaque);
22 /* Walk the page table and resolve the virtual address to a physical address */
23 extern phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *virt);
24 /* Map the virtual address to the physical address for the given page tables */
25 extern pteval_t *install_page(pgd_t *pgtable, phys_addr_t phys, void *virt);
26 
27 /* Map consecutive physical pages */
28 void *vmap(phys_addr_t phys, size_t size);
29 
30 #endif
31