xref: /linux-6.15/include/linux/pfn.h (revision b2441318)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
222a9835cSDave Hansen #ifndef _LINUX_PFN_H_
322a9835cSDave Hansen #define _LINUX_PFN_H_
422a9835cSDave Hansen 
5947d0496SJeremy Fitzhardinge #ifndef __ASSEMBLY__
6947d0496SJeremy Fitzhardinge #include <linux/types.h>
734c0fd54SDan Williams 
834c0fd54SDan Williams /*
934c0fd54SDan Williams  * pfn_t: encapsulates a page-frame number that is optionally backed
1034c0fd54SDan Williams  * by memmap (struct page).  Whether a pfn_t has a 'struct page'
1134c0fd54SDan Williams  * backing is indicated by flags in the high bits of the value.
1234c0fd54SDan Williams  */
1334c0fd54SDan Williams typedef struct {
14db78c222SDan Williams 	u64 val;
1534c0fd54SDan Williams } pfn_t;
16947d0496SJeremy Fitzhardinge #endif
17947d0496SJeremy Fitzhardinge 
1822a9835cSDave Hansen #define PFN_ALIGN(x)	(((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK)
1922a9835cSDave Hansen #define PFN_UP(x)	(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
2022a9835cSDave Hansen #define PFN_DOWN(x)	((x) >> PAGE_SHIFT)
21947d0496SJeremy Fitzhardinge #define PFN_PHYS(x)	((phys_addr_t)(x) << PAGE_SHIFT)
228f235d1aSChen Gang #define PHYS_PFN(x)	((unsigned long)((x) >> PAGE_SHIFT))
2322a9835cSDave Hansen 
2422a9835cSDave Hansen #endif
25