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