summaryrefslogtreecommitdiff
path: root/arch/arm/kernel/head.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/kernel/head.S')
-rw-r--r--arch/arm/kernel/head.S31
1 files changed, 23 insertions, 8 deletions
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 21e17dc94cb5..7d8d4b0ce66e 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -22,12 +22,14 @@
#include <asm/thread_info.h>
#include <asm/system.h>
+#if !defined(CONFIG_RUNTIME_PHYS_OFFSET)
#if (PHYS_OFFSET & 0x001fffff)
#error "PHYS_OFFSET must be at an even 2MiB boundary!"
#endif
+#define KERNEL_RAM_PADDR (PHYS_OFFSET + TEXT_OFFSET)
+#endif
#define KERNEL_RAM_VADDR (PAGE_OFFSET + TEXT_OFFSET)
-#define KERNEL_RAM_PADDR (PHYS_OFFSET + TEXT_OFFSET)
/*
@@ -44,8 +46,8 @@
.globl swapper_pg_dir
.equ swapper_pg_dir, KERNEL_RAM_VADDR - 0x4000
- .macro pgtbl, rd
- ldr \rd, =(KERNEL_RAM_PADDR - 0x4000)
+ .macro pgtbl, rd, phys_offset
+ add \rd, \phys_offset, #(TEXT_OFFSET - 0x4000)
.endm
#ifdef CONFIG_XIP_KERNEL
@@ -210,9 +212,25 @@ ENDPROC(__turn_mmu_on)
* Returns:
* r0, r3, r6, r7 corrupted
* r4 = physical page table address
+ * r5 = physical start address of (the first bank of) RAM (PHYS_OFFSET)
*/
__create_page_tables:
- pgtbl r4 @ page table address
+#if defined(CONFIG_RUNTIME_PHYS_OFFSET)
+ @ stext is at PHYS_OFFSET + TEXT_OFFSET. As PHYS_OFFSET has to be
+ @ 2MiB-aligned and assuming that TEXT_OFFSET < 2MiB
+ @ stext & 0xffe00000 yields PHYS_OFFSET
+ adr r5, stext
+ ldr r4, =0xffe00000
+ and r5, r5, r4
+
+ @ save phys_offset
+ ldr r4, =(phys_offset - PAGE_OFFSET)
+ str r5, [r4, r5]
+#else
+ ldr r5, =PHYS_OFFSET
+#endif
+
+ pgtbl r4, r5 @ r4 = page table address
/*
* Clear the 16K level 1 swapper page table
@@ -276,10 +294,7 @@ __create_page_tables:
* Then map first 1MB of ram in case it contains our boot params.
*/
add r0, r4, #PAGE_OFFSET >> 18
- orr r6, r7, #(PHYS_OFFSET & 0xff000000)
- .if (PHYS_OFFSET & 0x00f00000)
- orr r6, r6, #(PHYS_OFFSET & 0x00f00000)
- .endif
+ orr r6, r7, r5
str r6, [r0]
#ifdef CONFIG_DEBUG_LL