Xen Test Framework
pagetable.h
Go to the documentation of this file.
1#ifndef XTF_X86_PAGETABLE_H
2#define XTF_X86_PAGETABLE_H
3
4#include <arch/mm.h>
5
6#if CONFIG_PAGING_LEVELS > 0
7
8static inline paddr_t pte_to_paddr(intpte_t pte)
9{
10 return pte & PADDR_MASK & PAGE_MASK;
11}
12
13static inline intpte_t pte_from_paddr(paddr_t paddr, uint64_t flags)
14{
15 return ((paddr & (PADDR_MASK & PAGE_MASK)) |
16 (flags & ~(PADDR_MASK & PAGE_MASK)));
17}
18
19static inline intpte_t pte_from_gfn(unsigned long gfn, uint64_t flags)
20{
21 return pte_from_paddr((paddr_t)gfn << PAGE_SHIFT, flags);
22}
23
24static inline intpte_t pte_from_virt(const void *va, uint64_t flags)
25{
26 return pte_from_paddr((paddr_t)virt_to_gfn(va) << PAGE_SHIFT, flags);
27}
28
29#else /* CONFIG_PAGING_LEVELS > 0 */
30
31/* Enough compatibility to compile in unpaged environments. */
34intpte_t pte_from_gfn(unsigned long gfn, uint64_t flags);
35intpte_t pte_from_virt(const void *va, uint64_t flags);
36
37#endif
38
39#endif /* XTF_X86_PAGETABLE_H */
40
41/*
42 * Local variables:
43 * mode: C
44 * c-file-style: "BSD"
45 * c-basic-offset: 4
46 * tab-width: 4
47 * indent-tabs-mode: nil
48 * End:
49 */
static unsigned long virt_to_gfn(const void *va)
Definition: mm.h:100
uint64_t paddr_t
Definition: page.h:96
#define PADDR_MASK
Definition: page.h:15
#define PAGE_SHIFT
Definition: page.h:10
unsigned long intpte_t
Definition: page.h:152
#define PAGE_MASK
Definition: page.h:12
intpte_t pte_from_paddr(paddr_t paddr, uint64_t flags)
intpte_t pte_from_gfn(unsigned long gfn, uint64_t flags)
intpte_t pte_from_virt(const void *va, uint64_t flags)
paddr_t pte_to_paddr(intpte_t pte)
__UINT64_TYPE__ uint64_t
Definition: stdint.h:17