pfn.h 722 B

12345678910111213141516171819202122232425262728
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #pragma once
  3. #ifndef _LINUX_PFN_H_
  4. #define _LINUX_PFN_H_
  5. #include "page_types.h"
  6. #include "const.h"
  7. #ifndef __ASSEMBLY__
  8. #include "../types.h"
  9. /*
  10. * pfn_t: encapsulates a page-frame number that is optionally backed
  11. * by memmap (struct page). Whether a pfn_t has a 'struct page'
  12. * backing is indicated by flags in the high bits of the value.
  13. */
  14. typedef struct {
  15. u64 val;
  16. } pfn_t;
  17. #endif
  18. #define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
  19. #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
  20. #define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
  21. #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
  22. #define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT))
  23. #endif