xref: /kvm-unit-tests/lib/arm/asm/page.h (revision 09121d03360499b8bebac30b314b35d55325be51)
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 #include "const.h"
10 
11 #define PAGE_SHIFT		12
12 #define PAGE_SIZE		(_AC(1,UL) << PAGE_SHIFT)
13 #define PAGE_MASK		(~(PAGE_SIZE-1))
14 
15 #ifndef __ASSEMBLY__
16 
17 #define PAGE_ALIGN(addr)	ALIGN(addr, PAGE_SIZE)
18 
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 
32 #endif /* __ASSEMBLY__ */
33 
34 #endif /* _ASMARM_PAGE_H_ */
35