xref: /kvm-unit-tests/lib/vmalloc.h (revision 9f0ae3012430ed7072d04247fb674125c616a6b4)
1*9f0ae301SCornelia Huck #ifndef _VMALLOC_H_
2*9f0ae301SCornelia Huck #define _VMALLOC_H_
3efd8e5aaSPaolo Bonzini 
4dcda215bSPaolo Bonzini #include <asm/page.h>
5dcda215bSPaolo Bonzini 
6dee4223bSClaudio Imbrenda /* Allocate consecutive virtual pages (without backing) */
7efd8e5aaSPaolo Bonzini extern void *alloc_vpages(ulong nr);
80d622fcbSClaudio Imbrenda /* Allocate consecutive and aligned virtual pages (without backing) */
90d622fcbSClaudio Imbrenda extern void *alloc_vpages_aligned(ulong nr, unsigned int alignment_order);
100d622fcbSClaudio Imbrenda 
11dee4223bSClaudio Imbrenda /* Allocate one virtual page (without backing) */
12efd8e5aaSPaolo Bonzini extern void *alloc_vpage(void);
13dee4223bSClaudio Imbrenda /* Set the top of the virtual address space */
14efd8e5aaSPaolo Bonzini extern void init_alloc_vpage(void *top);
15dee4223bSClaudio Imbrenda /* Set up the virtual allocator; also sets up the page allocator if needed */
16da7eceb3SThomas Huth extern void setup_vm(void);
17937e2392SPaolo Bonzini 
18dee4223bSClaudio Imbrenda /* Set up paging */
19937e2392SPaolo Bonzini extern void *setup_mmu(phys_addr_t top);
20dee4223bSClaudio Imbrenda /* Walk the page table and resolve the virtual address to a physical address */
21c41e032aSPaolo Bonzini extern phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *virt);
22dee4223bSClaudio Imbrenda /* Map the virtual address to the physical address for the given page tables */
23dcda215bSPaolo Bonzini extern pteval_t *install_page(pgd_t *pgtable, phys_addr_t phys, void *virt);
24dcda215bSPaolo Bonzini 
25dee4223bSClaudio Imbrenda /* Map consecutive physical pages */
26dcda215bSPaolo Bonzini void *vmap(phys_addr_t phys, size_t size);
27efd8e5aaSPaolo Bonzini 
28efd8e5aaSPaolo Bonzini #endif
29