diff options
Diffstat (limited to 'arch/arm/include/asm/memory.h')
-rw-r--r-- | arch/arm/include/asm/memory.h | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 8756e4bcdba0..02fa2558f662 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h | |||
@@ -30,14 +30,15 @@ | |||
30 | */ | 30 | */ |
31 | #define UL(x) _AC(x, UL) | 31 | #define UL(x) _AC(x, UL) |
32 | 32 | ||
33 | /* PAGE_OFFSET - the virtual address of the start of the kernel image */ | ||
34 | #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET) | ||
35 | |||
33 | #ifdef CONFIG_MMU | 36 | #ifdef CONFIG_MMU |
34 | 37 | ||
35 | /* | 38 | /* |
36 | * PAGE_OFFSET - the virtual address of the start of the kernel image | ||
37 | * TASK_SIZE - the maximum size of a user space task. | 39 | * TASK_SIZE - the maximum size of a user space task. |
38 | * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area | 40 | * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area |
39 | */ | 41 | */ |
40 | #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET) | ||
41 | #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) | 42 | #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) |
42 | #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M) | 43 | #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M) |
43 | 44 | ||
@@ -104,10 +105,6 @@ | |||
104 | #define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE) | 105 | #define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE) |
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | #ifndef PAGE_OFFSET | ||
108 | #define PAGE_OFFSET PLAT_PHYS_OFFSET | ||
109 | #endif | ||
110 | |||
111 | /* | 108 | /* |
112 | * The module can be at any place in ram in nommu mode. | 109 | * The module can be at any place in ram in nommu mode. |
113 | */ | 110 | */ |
@@ -169,9 +166,17 @@ | |||
169 | * Physical vs virtual RAM address space conversion. These are | 166 | * Physical vs virtual RAM address space conversion. These are |
170 | * private definitions which should NOT be used outside memory.h | 167 | * private definitions which should NOT be used outside memory.h |
171 | * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. | 168 | * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. |
169 | * | ||
170 | * PFNs are used to describe any physical page; this means | ||
171 | * PFN 0 == physical address 0. | ||
172 | */ | 172 | */ |
173 | #ifndef __virt_to_phys | 173 | #if defined(__virt_to_phys) |
174 | #ifdef CONFIG_ARM_PATCH_PHYS_VIRT | 174 | #define PHYS_OFFSET PLAT_PHYS_OFFSET |
175 | #define PHYS_PFN_OFFSET ((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT)) | ||
176 | |||
177 | #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) | ||
178 | |||
179 | #elif defined(CONFIG_ARM_PATCH_PHYS_VIRT) | ||
175 | 180 | ||
176 | /* | 181 | /* |
177 | * Constants used to force the right instruction encodings and shifts | 182 | * Constants used to force the right instruction encodings and shifts |
@@ -180,12 +185,17 @@ | |||
180 | #define __PV_BITS_31_24 0x81000000 | 185 | #define __PV_BITS_31_24 0x81000000 |
181 | #define __PV_BITS_7_0 0x81 | 186 | #define __PV_BITS_7_0 0x81 |
182 | 187 | ||
183 | extern u64 __pv_phys_offset; | 188 | extern unsigned long __pv_phys_pfn_offset; |
184 | extern u64 __pv_offset; | 189 | extern u64 __pv_offset; |
185 | extern void fixup_pv_table(const void *, unsigned long); | 190 | extern void fixup_pv_table(const void *, unsigned long); |
186 | extern const void *__pv_table_begin, *__pv_table_end; | 191 | extern const void *__pv_table_begin, *__pv_table_end; |
187 | 192 | ||
188 | #define PHYS_OFFSET __pv_phys_offset | 193 | #define PHYS_OFFSET ((phys_addr_t)__pv_phys_pfn_offset << PAGE_SHIFT) |
194 | #define PHYS_PFN_OFFSET (__pv_phys_pfn_offset) | ||
195 | |||
196 | #define virt_to_pfn(kaddr) \ | ||
197 | ((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \ | ||
198 | PHYS_PFN_OFFSET) | ||
189 | 199 | ||
190 | #define __pv_stub(from,to,instr,type) \ | 200 | #define __pv_stub(from,to,instr,type) \ |
191 | __asm__("@ __pv_stub\n" \ | 201 | __asm__("@ __pv_stub\n" \ |
@@ -246,6 +256,7 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) | |||
246 | #else | 256 | #else |
247 | 257 | ||
248 | #define PHYS_OFFSET PLAT_PHYS_OFFSET | 258 | #define PHYS_OFFSET PLAT_PHYS_OFFSET |
259 | #define PHYS_PFN_OFFSET ((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT)) | ||
249 | 260 | ||
250 | static inline phys_addr_t __virt_to_phys(unsigned long x) | 261 | static inline phys_addr_t __virt_to_phys(unsigned long x) |
251 | { | 262 | { |
@@ -257,18 +268,11 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) | |||
257 | return x - PHYS_OFFSET + PAGE_OFFSET; | 268 | return x - PHYS_OFFSET + PAGE_OFFSET; |
258 | } | 269 | } |
259 | 270 | ||
260 | #endif | 271 | #define virt_to_pfn(kaddr) \ |
261 | #endif | 272 | ((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \ |
273 | PHYS_PFN_OFFSET) | ||
262 | 274 | ||
263 | /* | 275 | #endif |
264 | * PFNs are used to describe any physical page; this means | ||
265 | * PFN 0 == physical address 0. | ||
266 | * | ||
267 | * This is the PFN of the first RAM page in the kernel | ||
268 | * direct-mapped view. We assume this is the first page | ||
269 | * of RAM in the mem_map as well. | ||
270 | */ | ||
271 | #define PHYS_PFN_OFFSET ((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT)) | ||
272 | 276 | ||
273 | /* | 277 | /* |
274 | * These are *only* valid on the kernel direct mapped RAM memory. | 278 | * These are *only* valid on the kernel direct mapped RAM memory. |
@@ -346,9 +350,9 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
346 | */ | 350 | */ |
347 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET | 351 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET |
348 | 352 | ||
349 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) | 353 | #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) |
350 | #define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \ | 354 | #define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \ |
351 | && pfn_valid(__pa(kaddr) >> PAGE_SHIFT) ) | 355 | && pfn_valid(virt_to_pfn(kaddr))) |
352 | 356 | ||
353 | #endif | 357 | #endif |
354 | 358 | ||