blob: 14bc053c53d8a4efb49dfca43c7f4116099b1f85 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Dave Hansen22a98352006-03-27 01:16:04 -08002#ifndef _LINUX_PFN_H_
3#define _LINUX_PFN_H_
4
Jeremy Fitzhardinge947d0492008-09-11 01:31:48 -07005#ifndef __ASSEMBLY__
6#include <linux/types.h>
Dan Williams34c0fd52016-01-15 16:56:14 -08007
8/*
9 * pfn_t: encapsulates a page-frame number that is optionally backed
10 * by memmap (struct page). Whether a pfn_t has a 'struct page'
11 * backing is indicated by flags in the high bits of the value.
12 */
13typedef struct {
Dan Williamsdb78c222016-02-11 16:13:17 -080014 u64 val;
Dan Williams34c0fd52016-01-15 16:56:14 -080015} pfn_t;
Jeremy Fitzhardinge947d0492008-09-11 01:31:48 -070016#endif
17
Dave Hansen22a98352006-03-27 01:16:04 -080018#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)
Jeremy Fitzhardinge947d0492008-09-11 01:31:48 -070021#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
Chen Gang8f235d12016-01-14 15:18:33 -080022#define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT))
Dave Hansen22a98352006-03-27 01:16:04 -080023
24#endif