1 #ifndef _ASM_GENERIC_PAGE_H_ 2 #define _ASM_GENERIC_PAGE_H_ 3 /* 4 * asm-generic/page.h 5 * adapted from the Linux kernel's include/asm-generic/page.h 6 * 7 * Copyright (C) 2017, Red Hat Inc, Andrew Jones <drjones@redhat.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2. 10 */ 11 12 #include <linux/const.h> 13 14 #define PAGE_SHIFT 12 15 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) 16 #define PAGE_MASK (~(PAGE_SIZE-1)) 17 18 #ifndef __ASSEMBLER__ 19 20 #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) 21 22 #define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) 23 24 #define __va(x) ((void *)((unsigned long) (x))) 25 #define __pa(x) ((unsigned long) (x)) 26 #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) 27 #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) 28 29 #endif /* !__ASSEMBLER__ */ 30 31 #endif /* _ASM_GENERIC_PAGE_H_ */ 32