xref: /kvm-unit-tests/lib/arm/asm/page.h (revision 901c1c8dcd406d63e5fd4a0b36026749810e6397)
1 #ifndef _ASMARM_PAGE_H_
2 #define _ASMARM_PAGE_H_
3 /*
4  * Copyright (C) 2014, Red Hat Inc, Andrew Jones <drjones@redhat.com>
5  *
6  * This work is licensed under the terms of the GNU LGPL, version 2.
7  */
8 
9 #define PAGE_SHIFT		12
10 #ifndef __ASSEMBLY__
11 #define PAGE_SIZE		(1UL << PAGE_SHIFT)
12 #else
13 #define PAGE_SIZE		(1 << PAGE_SHIFT)
14 #endif
15 #define PAGE_MASK		(~(PAGE_SIZE-1))
16 #define PAGE_ALIGN(addr)	(((addr) + (PAGE_SIZE-1)) & PAGE_MASK)
17 
18 #ifndef __ASSEMBLY__
19 #include <asm/setup.h>
20 
21 #ifndef __virt_to_phys
22 #define __phys_to_virt(x)	((unsigned long) (x))
23 #define __virt_to_phys(x)	(x)
24 #endif
25 
26 #define __va(x)			((void *)__phys_to_virt((phys_addr_t)(x)))
27 #define __pa(x)			__virt_to_phys((unsigned long)(x))
28 
29 #define virt_to_pfn(kaddr)      (__pa(kaddr) >> PAGE_SHIFT)
30 #define pfn_to_virt(pfn)        __va((pfn) << PAGE_SHIFT)
31 #endif
32 
33 #endif
34