xref: /openbmc/linux/arch/arm/include/asm/memory.h (revision 9443076e)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
24baa9922SRussell King /*
34baa9922SRussell King  *  arch/arm/include/asm/memory.h
44baa9922SRussell King  *
54baa9922SRussell King  *  Copyright (C) 2000-2002 Russell King
64baa9922SRussell King  *  modification for nommu, Hyok S. Choi, 2004
74baa9922SRussell King  *
84baa9922SRussell King  *  Note: this file should not be included by non-asm/.h files
94baa9922SRussell King  */
104baa9922SRussell King #ifndef __ASM_ARM_MEMORY_H
114baa9922SRussell King #define __ASM_ARM_MEMORY_H
124baa9922SRussell King 
138d5796d2SLennert Buytenhek #include <linux/compiler.h>
148d5796d2SLennert Buytenhek #include <linux/const.h>
153a6b1676SWill Deacon #include <linux/types.h>
16158e8bfeSAlessandro Rubini #include <linux/sizes.h>
178d5796d2SLennert Buytenhek 
180cdc8b92SNicolas Pitre #ifdef CONFIG_NEED_MACH_MEMORY_H
191b9f95f8SNicolas Pitre #include <mach/memory.h>
201b9f95f8SNicolas Pitre #endif
211b9f95f8SNicolas Pitre 
22006fa259SRussell King /* PAGE_OFFSET - the virtual address of the start of the kernel image */
23006fa259SRussell King #define PAGE_OFFSET		UL(CONFIG_PAGE_OFFSET)
24006fa259SRussell King 
254baa9922SRussell King #ifdef CONFIG_MMU
264baa9922SRussell King 
274baa9922SRussell King /*
284baa9922SRussell King  * TASK_SIZE - the maximum size of a user space task.
294baa9922SRussell King  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
304baa9922SRussell King  */
315d1c20bcSWill Deacon #define TASK_SIZE		(UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M))
3279d1f5c9SWill Deacon #define TASK_UNMAPPED_BASE	ALIGN(TASK_SIZE / 3, SZ_16M)
334baa9922SRussell King 
344baa9922SRussell King /*
354baa9922SRussell King  * The maximum size of a 26-bit user space task.
364baa9922SRussell King  */
375d1c20bcSWill Deacon #define TASK_SIZE_26		(UL(1) << 26)
384baa9922SRussell King 
394baa9922SRussell King /*
404baa9922SRussell King  * The module space lives between the addresses given by TASK_SIZE
414baa9922SRussell King  * and PAGE_OFFSET - it must be within 32MB of the kernel text.
424baa9922SRussell King  */
43adca6dc2SCatalin Marinas #ifndef CONFIG_THUMB2_KERNEL
445d1c20bcSWill Deacon #define MODULES_VADDR		(PAGE_OFFSET - SZ_16M)
45adca6dc2SCatalin Marinas #else
46adca6dc2SCatalin Marinas /* smaller range for Thumb-2 symbols relocation (2^24)*/
475d1c20bcSWill Deacon #define MODULES_VADDR		(PAGE_OFFSET - SZ_8M)
48adca6dc2SCatalin Marinas #endif
49adca6dc2SCatalin Marinas 
50ab4f2ee1SRussell King #if TASK_SIZE > MODULES_VADDR
514baa9922SRussell King #error Top of user space clashes with start of module space
524baa9922SRussell King #endif
534baa9922SRussell King 
544baa9922SRussell King /*
55d73cd428SNicolas Pitre  * The highmem pkmap virtual space shares the end of the module area.
56d73cd428SNicolas Pitre  */
57d73cd428SNicolas Pitre #ifdef CONFIG_HIGHMEM
58d73cd428SNicolas Pitre #define MODULES_END		(PAGE_OFFSET - PMD_SIZE)
59d73cd428SNicolas Pitre #else
60d73cd428SNicolas Pitre #define MODULES_END		(PAGE_OFFSET)
61d73cd428SNicolas Pitre #endif
62d73cd428SNicolas Pitre 
63d73cd428SNicolas Pitre /*
644baa9922SRussell King  * The XIP kernel gets mapped at the bottom of the module vm area.
654baa9922SRussell King  * Since we use sections to map it, this macro replaces the physical address
664baa9922SRussell King  * with its virtual address while keeping offset from the base section.
674baa9922SRussell King  */
68ab4f2ee1SRussell King #define XIP_VIRT_ADDR(physaddr)  (MODULES_VADDR + ((physaddr) & 0x000fffff))
694baa9922SRussell King 
70803e3dbcSSergey Dyasly #if !defined(CONFIG_SMP) && !defined(CONFIG_ARM_LPAE)
714baa9922SRussell King /*
724baa9922SRussell King  * Allow 16MB-aligned ioremap pages
734baa9922SRussell King  */
744baa9922SRussell King #define IOREMAP_MAX_ORDER	24
75803e3dbcSSergey Dyasly #endif
764baa9922SRussell King 
7758c16709SAfzal Mohammed #define VECTORS_BASE		UL(0xffff0000)
7858c16709SAfzal Mohammed 
794baa9922SRussell King #else /* CONFIG_MMU */
804baa9922SRussell King 
8158c16709SAfzal Mohammed #ifndef __ASSEMBLY__
8262d1c95dSVladimir Murzin extern unsigned long setup_vectors_base(void);
8358c16709SAfzal Mohammed extern unsigned long vectors_base;
8458c16709SAfzal Mohammed #define VECTORS_BASE		vectors_base
8558c16709SAfzal Mohammed #endif
8658c16709SAfzal Mohammed 
874baa9922SRussell King /*
884baa9922SRussell King  * The limitation of user task size can grow up to the end of free ram region.
894baa9922SRussell King  * It is difficult to define and perhaps will never meet the original meaning
904baa9922SRussell King  * of this define that was meant to.
914baa9922SRussell King  * Fortunately, there is no reference for this in noMMU mode, for now.
924baa9922SRussell King  */
9303eca200SUwe Kleine-König #define TASK_SIZE		UL(0xffffffff)
944baa9922SRussell King 
954baa9922SRussell King #ifndef TASK_UNMAPPED_BASE
964baa9922SRussell King #define TASK_UNMAPPED_BASE	UL(0x00000000)
974baa9922SRussell King #endif
984baa9922SRussell King 
994baa9922SRussell King #ifndef END_MEM
100c931b4f6SFenkart/Bostandzhyan #define END_MEM     		(UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE)
1014baa9922SRussell King #endif
1024baa9922SRussell King 
1034baa9922SRussell King /*
1044baa9922SRussell King  * The module can be at any place in ram in nommu mode.
1054baa9922SRussell King  */
106ab4f2ee1SRussell King #define MODULES_END		(END_MEM)
107b713aa0bSRussell King #define MODULES_VADDR		PAGE_OFFSET
1084baa9922SRussell King 
10938b4205aSUwe Kleine-König #define XIP_VIRT_ADDR(physaddr)  (physaddr)
11038b4205aSUwe Kleine-König 
1114baa9922SRussell King #endif /* !CONFIG_MMU */
1124baa9922SRussell King 
113a09975bfSFlorian Fainelli #ifdef CONFIG_XIP_KERNEL
114a09975bfSFlorian Fainelli #define KERNEL_START		_sdata
115a09975bfSFlorian Fainelli #else
116a09975bfSFlorian Fainelli #define KERNEL_START		_stext
117a09975bfSFlorian Fainelli #endif
118a09975bfSFlorian Fainelli #define KERNEL_END		_end
119a09975bfSFlorian Fainelli 
1204baa9922SRussell King /*
1211dbd30e9SLinus Walleij  * We fix the TCM memories max 32 KiB ITCM resp DTCM at these
1221dbd30e9SLinus Walleij  * locations
1231dbd30e9SLinus Walleij  */
1241dbd30e9SLinus Walleij #ifdef CONFIG_HAVE_TCM
1251dbd30e9SLinus Walleij #define ITCM_OFFSET	UL(0xfffe0000)
1261dbd30e9SLinus Walleij #define DTCM_OFFSET	UL(0xfffe8000)
1271dbd30e9SLinus Walleij #endif
1281dbd30e9SLinus Walleij 
1291dbd30e9SLinus Walleij /*
130719301ffSRussell King  * Convert a page to/from a physical address
131719301ffSRussell King  */
132719301ffSRussell King #define page_to_phys(page)	(__pfn_to_phys(page_to_pfn(page)))
133719301ffSRussell King #define phys_to_page(phys)	(pfn_to_page(__phys_to_pfn(phys)))
134719301ffSRussell King 
1354756dcbfSCyril Chemparathy /*
136b713aa0bSRussell King  * PLAT_PHYS_OFFSET is the offset (from zero) of the start of physical
137c6f54a9bSUwe Kleine-König  * memory.  This is used for XIP and NoMMU kernels, and on platforms that don't
138c6f54a9bSUwe Kleine-König  * have CONFIG_ARM_PATCH_PHYS_VIRT. Assembly code must always use
139b713aa0bSRussell King  * PLAT_PHYS_OFFSET and not PHYS_OFFSET.
140b713aa0bSRussell King  */
141b713aa0bSRussell King #define PLAT_PHYS_OFFSET	UL(CONFIG_PHYS_OFFSET)
142b713aa0bSRussell King 
143d7811455SNicolas Pitre #ifdef CONFIG_XIP_KERNEL
1448ff97fa3SRussell King /*
1458ff97fa3SRussell King  * When referencing data in RAM from the XIP region in a relative manner
1468ff97fa3SRussell King  * with the MMU off, we need the relative offset between the two physical
1478ff97fa3SRussell King  * addresses.  The macro below achieves this, which is:
1488ff97fa3SRussell King  *    __pa(v_data) - __xip_pa(v_text)
1498ff97fa3SRussell King  */
1508ff97fa3SRussell King #define PHYS_RELATIVE(v_data, v_text) \
1518ff97fa3SRussell King 	(((v_data) - PAGE_OFFSET + PLAT_PHYS_OFFSET) - \
1528ff97fa3SRussell King 	 ((v_text) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + \
1538ff97fa3SRussell King           CONFIG_XIP_PHYS_ADDR))
154d7811455SNicolas Pitre #else
1558ff97fa3SRussell King #define PHYS_RELATIVE(v_data, v_text) ((v_data) - (v_text))
156d7811455SNicolas Pitre #endif
157d7811455SNicolas Pitre 
1584baa9922SRussell King #ifndef __ASSEMBLY__
1594baa9922SRussell King 
1604baa9922SRussell King /*
161dc21af99SRussell King  * Physical vs virtual RAM address space conversion.  These are
162dc21af99SRussell King  * private definitions which should NOT be used outside memory.h
163dc21af99SRussell King  * files.  Use virt_to_phys/phys_to_virt/__pa/__va instead.
164e26a9e00SRussell King  *
165e26a9e00SRussell King  * PFNs are used to describe any physical page; this means
166e26a9e00SRussell King  * PFN 0 == physical address 0.
167dc21af99SRussell King  */
168e26a9e00SRussell King 
1697d281b62SNicolas Pitre #if defined(CONFIG_ARM_PATCH_PHYS_VIRT)
170dc21af99SRussell King 
171cada3c08SRussell King /*
172cada3c08SRussell King  * Constants used to force the right instruction encodings and shifts
173cada3c08SRussell King  * so that all we need to do is modify the 8-bit constant field.
174cada3c08SRussell King  */
175cada3c08SRussell King #define __PV_BITS_31_24	0x81000000
176*9443076eSArd Biesheuvel #define __PV_BITS_23_16	0x810000
177f52bb722SSricharan R #define __PV_BITS_7_0	0x81
178cada3c08SRussell King 
179e26a9e00SRussell King extern unsigned long __pv_phys_pfn_offset;
180f52bb722SSricharan R extern u64 __pv_offset;
181f52bb722SSricharan R extern void fixup_pv_table(const void *, unsigned long);
182f52bb722SSricharan R extern const void *__pv_table_begin, *__pv_table_end;
183f52bb722SSricharan R 
184e26a9e00SRussell King #define PHYS_OFFSET	((phys_addr_t)__pv_phys_pfn_offset << PAGE_SHIFT)
185e26a9e00SRussell King #define PHYS_PFN_OFFSET	(__pv_phys_pfn_offset)
186e26a9e00SRussell King 
187e8e00f5aSArd Biesheuvel #ifndef CONFIG_THUMB2_KERNEL
1880869f3b9SArd Biesheuvel #define __pv_stub(from,to,instr)			\
189dc21af99SRussell King 	__asm__("@ __pv_stub\n"				\
190dc21af99SRussell King 	"1:	" instr "	%0, %1, %2\n"		\
191*9443076eSArd Biesheuvel 	"2:	" instr "	%0, %0, %3\n"		\
192dc21af99SRussell King 	"	.pushsection .pv_table,\"a\"\n"		\
193*9443076eSArd Biesheuvel 	"	.long	1b - ., 2b - .\n"		\
194dc21af99SRussell King 	"	.popsection\n"				\
195dc21af99SRussell King 	: "=r" (to)					\
196*9443076eSArd Biesheuvel 	: "r" (from), "I" (__PV_BITS_31_24),		\
197*9443076eSArd Biesheuvel 	  "I"(__PV_BITS_23_16))
198dc21af99SRussell King 
199f52bb722SSricharan R #define __pv_add_carry_stub(x, y)			\
200e8e00f5aSArd Biesheuvel 	__asm__("@ __pv_add_carry_stub\n"		\
201e8e00f5aSArd Biesheuvel 	"0:	movw	%R0, #0\n"			\
202*9443076eSArd Biesheuvel 	"	adds	%Q0, %1, %R0, lsl #20\n"	\
203e8e00f5aSArd Biesheuvel 	"1:	mov	%R0, %2\n"			\
204f52bb722SSricharan R 	"	adc	%R0, %R0, #0\n"			\
205f52bb722SSricharan R 	"	.pushsection .pv_table,\"a\"\n"		\
206e8e00f5aSArd Biesheuvel 	"	.long	0b - ., 1b - .\n"		\
207f52bb722SSricharan R 	"	.popsection\n"				\
208e8e00f5aSArd Biesheuvel 	: "=&r" (y)					\
209e8e00f5aSArd Biesheuvel 	: "r" (x), "I" (__PV_BITS_7_0)			\
210f52bb722SSricharan R 	: "cc")
211f52bb722SSricharan R 
212e8e00f5aSArd Biesheuvel #else
213e8e00f5aSArd Biesheuvel #define __pv_stub(from,to,instr)			\
214e8e00f5aSArd Biesheuvel 	__asm__("@ __pv_stub\n"				\
215e8e00f5aSArd Biesheuvel 	"0:	movw	%0, #0\n"			\
216*9443076eSArd Biesheuvel 	"	lsl	%0, #21\n"			\
217e8e00f5aSArd Biesheuvel 	"	" instr " %0, %1, %0\n"			\
218e8e00f5aSArd Biesheuvel 	"	.pushsection .pv_table,\"a\"\n"		\
219e8e00f5aSArd Biesheuvel 	"	.long	0b - .\n"			\
220e8e00f5aSArd Biesheuvel 	"	.popsection\n"				\
221e8e00f5aSArd Biesheuvel 	: "=&r" (to)					\
222e8e00f5aSArd Biesheuvel 	: "r" (from))
223e8e00f5aSArd Biesheuvel 
224e8e00f5aSArd Biesheuvel #define __pv_add_carry_stub(x, y)			\
225e8e00f5aSArd Biesheuvel 	__asm__("@ __pv_add_carry_stub\n"		\
226e8e00f5aSArd Biesheuvel 	"0:	movw	%R0, #0\n"			\
227*9443076eSArd Biesheuvel 	"	lsls	%R0, #21\n"			\
228e8e00f5aSArd Biesheuvel 	"	adds	%Q0, %1, %R0\n"			\
229e8e00f5aSArd Biesheuvel 	"1:	mvn	%R0, #0\n"			\
230e8e00f5aSArd Biesheuvel 	"	adc	%R0, %R0, #0\n"			\
231e8e00f5aSArd Biesheuvel 	"	.pushsection .pv_table,\"a\"\n"		\
232e8e00f5aSArd Biesheuvel 	"	.long	0b - ., 1b - .\n"		\
233e8e00f5aSArd Biesheuvel 	"	.popsection\n"				\
234e8e00f5aSArd Biesheuvel 	: "=&r" (y)					\
235e8e00f5aSArd Biesheuvel 	: "r" (x)					\
236e8e00f5aSArd Biesheuvel 	: "cc")
237e8e00f5aSArd Biesheuvel #endif
238e8e00f5aSArd Biesheuvel 
239e377cd82SFlorian Fainelli static inline phys_addr_t __virt_to_phys_nodebug(unsigned long x)
240dc21af99SRussell King {
241f52bb722SSricharan R 	phys_addr_t t;
242f52bb722SSricharan R 
243f52bb722SSricharan R 	if (sizeof(phys_addr_t) == 4) {
2440869f3b9SArd Biesheuvel 		__pv_stub(x, t, "add");
245f52bb722SSricharan R 	} else {
246f52bb722SSricharan R 		__pv_add_carry_stub(x, t);
247f52bb722SSricharan R 	}
248dc21af99SRussell King 	return t;
249dc21af99SRussell King }
250dc21af99SRussell King 
251ca5a45c0SSantosh Shilimkar static inline unsigned long __phys_to_virt(phys_addr_t x)
252dc21af99SRussell King {
253dc21af99SRussell King 	unsigned long t;
254139cc2baSVictor Kamensky 
255139cc2baSVictor Kamensky 	/*
256139cc2baSVictor Kamensky 	 * 'unsigned long' cast discard upper word when
257139cc2baSVictor Kamensky 	 * phys_addr_t is 64 bit, and makes sure that inline
258139cc2baSVictor Kamensky 	 * assembler expression receives 32 bit argument
259139cc2baSVictor Kamensky 	 * in place where 'r' 32 bit operand is expected.
260139cc2baSVictor Kamensky 	 */
2610869f3b9SArd Biesheuvel 	__pv_stub((unsigned long) x, t, "sub");
262dc21af99SRussell King 	return t;
263dc21af99SRussell King }
264ca5a45c0SSantosh Shilimkar 
265dc21af99SRussell King #else
266ca5a45c0SSantosh Shilimkar 
267b713aa0bSRussell King #define PHYS_OFFSET	PLAT_PHYS_OFFSET
268e26a9e00SRussell King #define PHYS_PFN_OFFSET	((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT))
269b713aa0bSRussell King 
270e377cd82SFlorian Fainelli static inline phys_addr_t __virt_to_phys_nodebug(unsigned long x)
271ca5a45c0SSantosh Shilimkar {
272ca5a45c0SSantosh Shilimkar 	return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET;
273ca5a45c0SSantosh Shilimkar }
274ca5a45c0SSantosh Shilimkar 
275ca5a45c0SSantosh Shilimkar static inline unsigned long __phys_to_virt(phys_addr_t x)
276ca5a45c0SSantosh Shilimkar {
277ca5a45c0SSantosh Shilimkar 	return x - PHYS_OFFSET + PAGE_OFFSET;
278ca5a45c0SSantosh Shilimkar }
279ca5a45c0SSantosh Shilimkar 
2807d281b62SNicolas Pitre #endif
2817d281b62SNicolas Pitre 
282e26a9e00SRussell King #define virt_to_pfn(kaddr) \
283e26a9e00SRussell King 	((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \
284e26a9e00SRussell King 	 PHYS_PFN_OFFSET)
285b4ad5155SStephen Boyd 
286e377cd82SFlorian Fainelli #define __pa_symbol_nodebug(x)	__virt_to_phys_nodebug((x))
287e377cd82SFlorian Fainelli 
288e377cd82SFlorian Fainelli #ifdef CONFIG_DEBUG_VIRTUAL
289e377cd82SFlorian Fainelli extern phys_addr_t __virt_to_phys(unsigned long x);
290e377cd82SFlorian Fainelli extern phys_addr_t __phys_addr_symbol(unsigned long x);
291e377cd82SFlorian Fainelli #else
292e377cd82SFlorian Fainelli #define __virt_to_phys(x)	__virt_to_phys_nodebug(x)
293e377cd82SFlorian Fainelli #define __phys_addr_symbol(x)	__pa_symbol_nodebug(x)
294e377cd82SFlorian Fainelli #endif
295e377cd82SFlorian Fainelli 
2964baa9922SRussell King /*
2974baa9922SRussell King  * These are *only* valid on the kernel direct mapped RAM memory.
2984baa9922SRussell King  * Note: Drivers should NOT use these.  They are the wrong
2994baa9922SRussell King  * translation for translating DMA addresses.  Use the driver
3004baa9922SRussell King  * DMA support - see dma-mapping.h.
3014baa9922SRussell King  */
30284c4d3a6SThierry Reding #define virt_to_phys virt_to_phys
3033a6b1676SWill Deacon static inline phys_addr_t virt_to_phys(const volatile void *x)
3044baa9922SRussell King {
3054baa9922SRussell King 	return __virt_to_phys((unsigned long)(x));
3064baa9922SRussell King }
3074baa9922SRussell King 
30884c4d3a6SThierry Reding #define phys_to_virt phys_to_virt
3093a6b1676SWill Deacon static inline void *phys_to_virt(phys_addr_t x)
3104baa9922SRussell King {
311ca5a45c0SSantosh Shilimkar 	return (void *)__phys_to_virt(x);
3124baa9922SRussell King }
3134baa9922SRussell King 
3144baa9922SRussell King /*
3154baa9922SRussell King  * Drivers should NOT use these either.
3164baa9922SRussell King  */
3174baa9922SRussell King #define __pa(x)			__virt_to_phys((unsigned long)(x))
318e377cd82SFlorian Fainelli #define __pa_symbol(x)		__phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0))
319ca5a45c0SSantosh Shilimkar #define __va(x)			((void *)__phys_to_virt((phys_addr_t)(x)))
320e4886664SVitaly Andrianov #define pfn_to_kaddr(pfn)	__va((phys_addr_t)(pfn) << PAGE_SHIFT)
3214baa9922SRussell King 
322981b6714SRussell King extern long long arch_phys_to_idmap_offset;
3235e4432d3SRussell King 
3244baa9922SRussell King /*
325981b6714SRussell King  * These are for systems that have a hardware interconnect supported alias
326981b6714SRussell King  * of physical memory for idmap purposes.  Most cases should leave these
32728410293SRussell King  * untouched.  Note: this can only return addresses less than 4GiB.
3284dc9a817SSantosh Shilimkar  */
32907a7056cSRussell King static inline bool arm_has_idmap_alias(void)
33007a7056cSRussell King {
33107a7056cSRussell King 	return IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset != 0;
33207a7056cSRussell King }
33307a7056cSRussell King 
334981b6714SRussell King #define IDMAP_INVALID_ADDR ((u32)~0)
335981b6714SRussell King 
336981b6714SRussell King static inline unsigned long phys_to_idmap(phys_addr_t addr)
337981b6714SRussell King {
338981b6714SRussell King 	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset) {
339981b6714SRussell King 		addr += arch_phys_to_idmap_offset;
340981b6714SRussell King 		if (addr > (u32)~0)
341981b6714SRussell King 			addr = IDMAP_INVALID_ADDR;
342981b6714SRussell King 	}
343981b6714SRussell King 	return addr;
344981b6714SRussell King }
345981b6714SRussell King 
346981b6714SRussell King static inline phys_addr_t idmap_to_phys(unsigned long idmap)
347981b6714SRussell King {
348981b6714SRussell King 	phys_addr_t addr = idmap;
349981b6714SRussell King 
350981b6714SRussell King 	if (IS_ENABLED(CONFIG_MMU) && arch_phys_to_idmap_offset)
351981b6714SRussell King 		addr -= arch_phys_to_idmap_offset;
352981b6714SRussell King 
353981b6714SRussell King 	return addr;
354981b6714SRussell King }
355981b6714SRussell King 
35628410293SRussell King static inline unsigned long __virt_to_idmap(unsigned long x)
3574dc9a817SSantosh Shilimkar {
358981b6714SRussell King 	return phys_to_idmap(__virt_to_phys(x));
3594dc9a817SSantosh Shilimkar }
3604dc9a817SSantosh Shilimkar 
3614dc9a817SSantosh Shilimkar #define virt_to_idmap(x)	__virt_to_idmap((unsigned long)(x))
3624dc9a817SSantosh Shilimkar 
3634dc9a817SSantosh Shilimkar /*
3644baa9922SRussell King  * Virtual <-> DMA view memory address translations
3654baa9922SRussell King  * Again, these are *only* valid on the kernel direct mapped RAM
3664baa9922SRussell King  * memory.  Use of these is *deprecated* (and that doesn't mean
3674baa9922SRussell King  * use the __ prefixed forms instead.)  See dma-mapping.h.
3684baa9922SRussell King  */
369b5ee9002SNicolas Pitre #ifndef __virt_to_bus
370b5ee9002SNicolas Pitre #define __virt_to_bus	__virt_to_phys
371b5ee9002SNicolas Pitre #define __bus_to_virt	__phys_to_virt
3721c4a4f48SRussell King #define __pfn_to_bus(x)	__pfn_to_phys(x)
3731c4a4f48SRussell King #define __bus_to_pfn(x)	__phys_to_pfn(x)
374b5ee9002SNicolas Pitre #endif
375b5ee9002SNicolas Pitre 
3764baa9922SRussell King /*
3774baa9922SRussell King  * Conversion between a struct page and a physical address.
3784baa9922SRussell King  *
3794baa9922SRussell King  *  page_to_pfn(page)	convert a struct page * to a PFN number
3804baa9922SRussell King  *  pfn_to_page(pfn)	convert a _valid_ PFN number to struct page *
3814baa9922SRussell King  *
3824baa9922SRussell King  *  virt_to_page(k)	convert a _valid_ virtual address to struct page *
3834baa9922SRussell King  *  virt_addr_valid(k)	indicates whether a virtual address is valid
3844baa9922SRussell King  */
3854baa9922SRussell King #define ARCH_PFN_OFFSET		PHYS_PFN_OFFSET
3864baa9922SRussell King 
387e26a9e00SRussell King #define virt_to_page(kaddr)	pfn_to_page(virt_to_pfn(kaddr))
388efea3403SLaura Abbott #define virt_addr_valid(kaddr)	(((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \
389e26a9e00SRussell King 					&& pfn_valid(virt_to_pfn(kaddr)))
3904baa9922SRussell King 
3914baa9922SRussell King #endif
3924baa9922SRussell King 
3934baa9922SRussell King #include <asm-generic/memory_model.h>
3944baa9922SRussell King 
3954baa9922SRussell King #endif
396