xref: /kvm-unit-tests/lib/vmalloc.h (revision b9289d76b946dc45c5221e142c5473ebfff1ca86)
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 /* common/ tests must check availability before calling setup_vm() */
21 extern bool vm_available(void);
22 /* Set up paging */
23 extern void *setup_mmu(phys_addr_t top, void *opaque);
24 /* Walk the page table and resolve the virtual address to a physical address */
25 extern phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *virt);
26 /* Map the virtual address to the physical address for the given page tables */
27 extern pteval_t *install_page(pgd_t *pgtable, phys_addr_t phys, void *virt);
28 
29 /* Map consecutive physical pages */
30 void *vmap(phys_addr_t phys, size_t size);
31 
32 #endif
33