virtconvert.h 1009 字节
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
L
Linus Torvalds 已提交
2 3 4 5 6 7 8 9 10 11
#ifndef __VIRT_CONVERT__
#define __VIRT_CONVERT__

/*
 * Macros used for converting between virtual and physical mappings.
 */

#ifdef __KERNEL__

#include <linux/compiler.h>
12
#include <linux/mmzone.h>
L
Linus Torvalds 已提交
13 14 15 16 17 18
#include <asm/setup.h>
#include <asm/page.h>

/*
 * Change virtual addresses to physical addresses and vv.
 */
19
#define virt_to_phys virt_to_phys
L
Linus Torvalds 已提交
20 21
static inline unsigned long virt_to_phys(void *address)
{
22
	return __pa(address);
L
Linus Torvalds 已提交
23 24
}

25
#define phys_to_virt phys_to_virt
L
Linus Torvalds 已提交
26 27
static inline void *phys_to_virt(unsigned long address)
{
28
	return __va(address);
L
Linus Torvalds 已提交
29 30 31
}

/* Permanent address of a page. */
32
#if defined(CONFIG_MMU) && !defined(CONFIG_DISCONTIGMEM)
33 34 35
#define page_to_phys(page) \
	__pa(PAGE_OFFSET + (((page) - pg_data_map[0].node_mem_map) << PAGE_SHIFT))
#else
36
#define page_to_phys(page)	(page_to_pfn(page) << PAGE_SHIFT)
37
#endif
L
Linus Torvalds 已提交
38 39 40 41 42 43 44 45 46

/*
 * IO bus memory addresses are 1:1 with the physical address,
 */
#define virt_to_bus virt_to_phys
#define bus_to_virt phys_to_virt

#endif
#endif