page.h 756 B

1234567891011121314151617181920212223242526272829
  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. #include <linux/const.h>
  12. #define PAGE_SHIFT 12
  13. #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
  14. #define PAGE_MASK (~(PAGE_SIZE-1))
  15. #ifndef __ASSEMBLY__
  16. #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
  17. #define __va(x) ((void *)((unsigned long) (x)))
  18. #define __pa(x) ((unsigned long) (x))
  19. #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
  20. #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
  21. #endif /* !__ASSEMBLY__ */
  22. #endif /* _ASM_GENERIC_PAGE_H_ */