diff options
Diffstat (limited to 'arch/arm/kernel/head.S')
-rw-r--r-- | arch/arm/kernel/head.S | 57 |
1 files changed, 17 insertions, 40 deletions
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 539626351348..8d8748407cbe 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/procinfo.h> | 21 | #include <asm/procinfo.h> |
22 | #include <asm/ptrace.h> | 22 | #include <asm/ptrace.h> |
23 | #include <asm/asm-offsets.h> | 23 | #include <asm/asm-offsets.h> |
24 | #include <asm/memory.h> | ||
24 | #include <asm/thread_info.h> | 25 | #include <asm/thread_info.h> |
25 | #include <asm/system.h> | 26 | #include <asm/system.h> |
26 | 27 | ||
@@ -33,52 +34,28 @@ | |||
33 | #define MACHINFO_PGOFFIO 12 | 34 | #define MACHINFO_PGOFFIO 12 |
34 | #define MACHINFO_NAME 16 | 35 | #define MACHINFO_NAME 16 |
35 | 36 | ||
36 | #ifndef CONFIG_XIP_KERNEL | ||
37 | /* | 37 | /* |
38 | * We place the page tables 16K below TEXTADDR. Therefore, we must make sure | 38 | * swapper_pg_dir is the virtual address of the initial page table. |
39 | * that TEXTADDR is correctly set. Currently, we expect the least significant | 39 | * We place the page tables 16K below KERNEL_RAM_ADDR. Therefore, we must |
40 | * 16 bits to be 0x8000, but we could probably relax this restriction to | 40 | * make sure that KERNEL_RAM_ADDR is correctly set. Currently, we expect |
41 | * TEXTADDR >= PAGE_OFFSET + 0x4000 | 41 | * the least significant 16 bits to be 0x8000, but we could probably |
42 | * | 42 | * relax this restriction to KERNEL_RAM_ADDR >= PAGE_OFFSET + 0x4000. |
43 | * Note that swapper_pg_dir is the virtual address of the page tables, and | ||
44 | * pgtbl gives us a position-independent reference to these tables. We can | ||
45 | * do this because stext == TEXTADDR | ||
46 | */ | 43 | */ |
47 | #if (TEXTADDR & 0xffff) != 0x8000 | 44 | #if (KERNEL_RAM_ADDR & 0xffff) != 0x8000 |
48 | #error TEXTADDR must start at 0xXXXX8000 | 45 | #error KERNEL_RAM_ADDR must start at 0xXXXX8000 |
49 | #endif | 46 | #endif |
50 | 47 | ||
51 | .globl swapper_pg_dir | 48 | .globl swapper_pg_dir |
52 | .equ swapper_pg_dir, TEXTADDR - 0x4000 | 49 | .equ swapper_pg_dir, KERNEL_RAM_ADDR - 0x4000 |
53 | 50 | ||
54 | .macro pgtbl, rd, phys | 51 | .macro pgtbl, rd |
55 | adr \rd, stext | 52 | ldr \rd, =(__virt_to_phys(KERNEL_RAM_ADDR - 0x4000)) |
56 | sub \rd, \rd, #0x4000 | ||
57 | .endm | 53 | .endm |
58 | #else | ||
59 | /* | ||
60 | * XIP Kernel: | ||
61 | * | ||
62 | * We place the page tables 16K below DATAADDR. Therefore, we must make sure | ||
63 | * that DATAADDR is correctly set. Currently, we expect the least significant | ||
64 | * 16 bits to be 0x8000, but we could probably relax this restriction to | ||
65 | * DATAADDR >= PAGE_OFFSET + 0x4000 | ||
66 | * | ||
67 | * Note that pgtbl is meant to return the physical address of swapper_pg_dir. | ||
68 | * We can't make it relative to the kernel position in this case since | ||
69 | * the kernel can physically be anywhere. | ||
70 | */ | ||
71 | #if (DATAADDR & 0xffff) != 0x8000 | ||
72 | #error DATAADDR must start at 0xXXXX8000 | ||
73 | #endif | ||
74 | |||
75 | .globl swapper_pg_dir | ||
76 | .equ swapper_pg_dir, DATAADDR - 0x4000 | ||
77 | 54 | ||
78 | .macro pgtbl, rd, phys | 55 | #ifdef CONFIG_XIP_KERNEL |
79 | ldr \rd, =((DATAADDR - 0x4000) - VIRT_OFFSET) | 56 | #define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) |
80 | add \rd, \rd, \phys | 57 | #else |
81 | .endm | 58 | #define TEXTADDR KERNEL_RAM_ADDR |
82 | #endif | 59 | #endif |
83 | 60 | ||
84 | /* | 61 | /* |
@@ -279,7 +256,7 @@ __turn_mmu_on: | |||
279 | .type __create_page_tables, %function | 256 | .type __create_page_tables, %function |
280 | __create_page_tables: | 257 | __create_page_tables: |
281 | ldr r5, [r8, #MACHINFO_PHYSRAM] @ physram | 258 | ldr r5, [r8, #MACHINFO_PHYSRAM] @ physram |
282 | pgtbl r4, r5 @ page table address | 259 | pgtbl r4 @ page table address |
283 | 260 | ||
284 | /* | 261 | /* |
285 | * Clear the 16K level 1 swapper page table | 262 | * Clear the 16K level 1 swapper page table |
@@ -324,7 +301,7 @@ __create_page_tables: | |||
324 | /* | 301 | /* |
325 | * Then map first 1MB of ram in case it contains our boot params. | 302 | * Then map first 1MB of ram in case it contains our boot params. |
326 | */ | 303 | */ |
327 | add r0, r4, #VIRT_OFFSET >> 18 | 304 | add r0, r4, #PAGE_OFFSET >> 18 |
328 | orr r6, r5, r7 | 305 | orr r6, r5, r7 |
329 | str r6, [r0] | 306 | str r6, [r0] |
330 | 307 | ||