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