aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm/memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/include/asm/memory.h')
-rw-r--r--arch/arm/include/asm/memory.h75
1 files changed, 61 insertions, 14 deletions
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index d0ee74b7cf86..431077c5a867 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/const.h> 17#include <linux/const.h>
18#include <linux/types.h>
18#include <mach/memory.h> 19#include <mach/memory.h>
19#include <asm/sizes.h> 20#include <asm/sizes.h>
20 21
@@ -133,20 +134,10 @@
133#endif 134#endif
134 135
135/* 136/*
136 * Physical vs virtual RAM address space conversion. These are
137 * private definitions which should NOT be used outside memory.h
138 * files. Use virt_to_phys/phys_to_virt/__pa/__va instead.
139 */
140#ifndef __virt_to_phys
141#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
142#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
143#endif
144
145/*
146 * Convert a physical address to a Page Frame Number and back 137 * Convert a physical address to a Page Frame Number and back
147 */ 138 */
148#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) 139#define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT))
149#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) 140#define __pfn_to_phys(pfn) ((phys_addr_t)(pfn) << PAGE_SHIFT)
150 141
151/* 142/*
152 * Convert a page to/from a physical address 143 * Convert a page to/from a physical address
@@ -157,6 +148,62 @@
157#ifndef __ASSEMBLY__ 148#ifndef __ASSEMBLY__
158 149
159/* 150/*
151 * Physical vs virtual RAM address space conversion. These are
152 * private definitions which should NOT be used outside memory.h
153 * files. Use virt_to_phys/phys_to_virt/__pa/__va instead.
154 */
155#ifndef __virt_to_phys
156#ifdef CONFIG_ARM_PATCH_PHYS_VIRT
157
158/*
159 * Constants used to force the right instruction encodings and shifts
160 * so that all we need to do is modify the 8-bit constant field.
161 */
162#define __PV_BITS_31_24 0x81000000
163#define __PV_BITS_23_16 0x00810000
164
165extern unsigned long __pv_phys_offset;
166#define PHYS_OFFSET __pv_phys_offset
167
168#define __pv_stub(from,to,instr,type) \
169 __asm__("@ __pv_stub\n" \
170 "1: " instr " %0, %1, %2\n" \
171 " .pushsection .pv_table,\"a\"\n" \
172 " .long 1b\n" \
173 " .popsection\n" \
174 : "=r" (to) \
175 : "r" (from), "I" (type))
176
177static inline unsigned long __virt_to_phys(unsigned long x)
178{
179 unsigned long t;
180 __pv_stub(x, t, "add", __PV_BITS_31_24);
181#ifdef CONFIG_ARM_PATCH_PHYS_VIRT_16BIT
182 __pv_stub(t, t, "add", __PV_BITS_23_16);
183#endif
184 return t;
185}
186
187static inline unsigned long __phys_to_virt(unsigned long x)
188{
189 unsigned long t;
190 __pv_stub(x, t, "sub", __PV_BITS_31_24);
191#ifdef CONFIG_ARM_PATCH_PHYS_VIRT_16BIT
192 __pv_stub(t, t, "sub", __PV_BITS_23_16);
193#endif
194 return t;
195}
196#else
197#define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
198#define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
199#endif
200#endif
201
202#ifndef PHYS_OFFSET
203#define PHYS_OFFSET PLAT_PHYS_OFFSET
204#endif
205
206/*
160 * The DMA mask corresponding to the maximum bus address allocatable 207 * The DMA mask corresponding to the maximum bus address allocatable
161 * using GFP_DMA. The default here places no restriction on DMA 208 * using GFP_DMA. The default here places no restriction on DMA
162 * allocations. This must be the smallest DMA mask in the system, 209 * allocations. This must be the smallest DMA mask in the system,
@@ -188,12 +235,12 @@
188 * translation for translating DMA addresses. Use the driver 235 * translation for translating DMA addresses. Use the driver
189 * DMA support - see dma-mapping.h. 236 * DMA support - see dma-mapping.h.
190 */ 237 */
191static inline unsigned long virt_to_phys(const volatile void *x) 238static inline phys_addr_t virt_to_phys(const volatile void *x)
192{ 239{
193 return __virt_to_phys((unsigned long)(x)); 240 return __virt_to_phys((unsigned long)(x));
194} 241}
195 242
196static inline void *phys_to_virt(unsigned long x) 243static inline void *phys_to_virt(phys_addr_t x)
197{ 244{
198 return (void *)(__phys_to_virt((unsigned long)(x))); 245 return (void *)(__phys_to_virt((unsigned long)(x)));
199} 246}