aboutsummaryrefslogtreecommitdiffstats
path: root/arch/hexagon/kernel/head.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/hexagon/kernel/head.S')
-rw-r--r--arch/hexagon/kernel/head.S107
1 files changed, 91 insertions, 16 deletions
diff --git a/arch/hexagon/kernel/head.S b/arch/hexagon/kernel/head.S
index d859402c73ba..b9b63d085db2 100644
--- a/arch/hexagon/kernel/head.S
+++ b/arch/hexagon/kernel/head.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Early kernel startup code for Hexagon 2 * Early kernel startup code for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. 4 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,9 @@
25#include <asm/mem-layout.h> 25#include <asm/mem-layout.h>
26#include <asm/vm_mmu.h> 26#include <asm/vm_mmu.h>
27#include <asm/page.h> 27#include <asm/page.h>
28#include <asm/hexagon_vm.h>
29
30#define SEGTABLE_ENTRIES #0x0e0
28 31
29 __INIT 32 __INIT
30ENTRY(stext) 33ENTRY(stext)
@@ -43,40 +46,93 @@ ENTRY(stext)
43 * Symbol is kernel segment address, but we need 46 * Symbol is kernel segment address, but we need
44 * the logical/physical address. 47 * the logical/physical address.
45 */ 48 */
46 r24 = asl(r24, #2) 49 r25 = pc;
47 r24 = lsr(r24, #2) 50 r2.h = #0xffc0;
51 r2.l = #0x0000;
52 r25 = and(r2,r25); /* R25 holds PHYS_OFFSET now */
53 r1.h = #HI(PAGE_OFFSET);
54 r1.l = #LO(PAGE_OFFSET);
55 r24 = sub(r24,r1); /* swapper_pg_dir - PAGE_OFFSET */
56 r24 = add(r24,r25); /* + PHYS_OFFSET */
48 57
49 r0 = r24 58 r0 = r24; /* aka __pa(swapper_pg_dir) */
50 59
51 /* 60 /*
52 * Initialize a 16MB PTE to make the virtual and physical 61 * Initialize page dir to make the virtual and physical
53 * addresses where the kernel was loaded be identical. 62 * addresses where the kernel was loaded be identical.
63 * Done in 4MB chunks.
54 */ 64 */
55#define PTE_BITS ( __HVM_PTE_R | __HVM_PTE_W | __HVM_PTE_X \ 65#define PTE_BITS ( __HVM_PTE_R | __HVM_PTE_W | __HVM_PTE_X \
56 | __HEXAGON_C_WB_L2 << 6 \ 66 | __HEXAGON_C_WB_L2 << 6 \
57 | __HVM_PDE_S_4MB) 67 | __HVM_PDE_S_4MB)
58 68
59 r1 = pc 69 /*
60 r2.H = #0xffc0 70 * Get number of VA=PA entries; only really needed for jump
61 r2.L = #0x0000 71 * to hyperspace; gets blown away immediately after
62 r1 = and(r1,r2) /* round PC to 4MB boundary */ 72 */
73
74 {
75 r1.l = #LO(_end);
76 r2.l = #LO(stext);
77 r3 = #1;
78 }
79 {
80 r1.h = #HI(_end);
81 r2.h = #HI(stext);
82 r3 = asl(r3, #22);
83 }
84 {
85 r1 = sub(r1, r2);
86 r3 = add(r3, #-1);
87 } /* r1 = _end - stext */
88 r1 = add(r1, r3); /* + (4M-1) */
89 r26 = lsr(r1, #22); /* / 4M = # of entries */
90
91 r1 = r25;
92 r2.h = #0xffc0;
93 r2.l = #0x0000; /* round back down to 4MB boundary */
94 r1 = and(r1,r2);
63 r2 = lsr(r1, #22) /* 4MB page number */ 95 r2 = lsr(r1, #22) /* 4MB page number */
64 r2 = asl(r2, #2) /* times sizeof(PTE) (4bytes) */ 96 r2 = asl(r2, #2) /* times sizeof(PTE) (4bytes) */
65 r0 = add(r0,r2) /* r0 = address of correct PTE */ 97 r0 = add(r0,r2) /* r0 = address of correct PTE */
66 r2 = #PTE_BITS 98 r2 = #PTE_BITS
67 r1 = add(r1,r2) /* r1 = 4MB PTE for the first entry */ 99 r1 = add(r1,r2) /* r1 = 4MB PTE for the first entry */
68 r2.h = #0x0040 100 r2.h = #0x0040
69 r2.l = #0x0000 /* 4MB */ 101 r2.l = #0x0000 /* 4MB increments */
70 memw(r0 ++ #4) = r1 102 loop0(1f,r26);
71 r1 = add(r1, r2) 1031:
72 memw(r0 ++ #4) = r1 104 memw(r0 ++ #4) = r1
105 { r1 = add(r1, r2); } :endloop0
106
107 /* Also need to overwrite the initial 0xc0000000 entries */
108 /* PAGE_OFFSET >> (4MB shift - 4 bytes per entry shift) */
109 R1.H = #HI(PAGE_OFFSET >> (22 - 2))
110 R1.L = #LO(PAGE_OFFSET >> (22 - 2))
111
112 r0 = add(r1, r24); /* advance to 0xc0000000 entry */
113 r1 = r25;
114 r2.h = #0xffc0;
115 r2.l = #0x0000; /* round back down to 4MB boundary */
116 r1 = and(r1,r2); /* for huge page */
117 r2 = #PTE_BITS
118 r1 = add(r1,r2);
119 r2.h = #0x0040
120 r2.l = #0x0000 /* 4MB increments */
73 121
74 r0 = r24 122 loop0(1f,SEGTABLE_ENTRIES);
1231:
124 memw(r0 ++ #4) = r1;
125 { r1 = add(r1,r2); } :endloop0
126
127 r0 = r24;
75 128
76 /* 129 /*
77 * The subroutine wrapper around the virtual instruction touches 130 * The subroutine wrapper around the virtual instruction touches
78 * no memory, so we should be able to use it even here. 131 * no memory, so we should be able to use it even here.
132 * Note that in this version, R1 and R2 get "clobbered"; see
133 * vm_ops.S
79 */ 134 */
135 r1 = #VM_TRANS_TYPE_TABLE
80 call __vmnewmap; 136 call __vmnewmap;
81 137
82 /* Jump into virtual address range. */ 138 /* Jump into virtual address range. */
@@ -90,17 +146,29 @@ ENTRY(stext)
90__head_s_vaddr_target: 146__head_s_vaddr_target:
91 /* 147 /*
92 * Tear down VA=PA translation now that we are running 148 * Tear down VA=PA translation now that we are running
93 * in the desgnated kernel segments. 149 * in kernel virtual space.
94 */ 150 */
95 r0 = #__HVM_PDE_S_INVALID 151 r0 = #__HVM_PDE_S_INVALID
96 r1 = r24 152
97 loop0(1f,#0x100) 153 r1.h = #0xffc0;
154 r1.l = #0x0000;
155 r2 = r25; /* phys_offset */
156 r2 = and(r1,r2);
157
158 r1.l = #lo(swapper_pg_dir)
159 r1.h = #hi(swapper_pg_dir)
160 r2 = lsr(r2, #22) /* 4MB page number */
161 r2 = asl(r2, #2) /* times sizeof(PTE) (4bytes) */
162 r1 = add(r1,r2);
163 loop0(1f,r26)
164
981: 1651:
99 { 166 {
100 memw(R1 ++ #4) = R0 167 memw(R1 ++ #4) = R0
101 }:endloop0 168 }:endloop0
102 169
103 r0 = r24 170 r0 = r24
171 r1 = #VM_TRANS_TYPE_TABLE
104 call __vmnewmap 172 call __vmnewmap
105 173
106 /* Go ahead and install the trap0 return so angel calls work */ 174 /* Go ahead and install the trap0 return so angel calls work */
@@ -143,6 +211,13 @@ __head_s_vaddr_target:
143 r2 = sub(r2,r0); 211 r2 = sub(r2,r0);
144 call memset; 212 call memset;
145 213
214 /* Set PHYS_OFFSET; should be in R25 */
215#ifdef CONFIG_HEXAGON_PHYS_OFFSET
216 r0.l = #LO(__phys_offset);
217 r0.h = #HI(__phys_offset);
218 memw(r0) = r25;
219#endif
220
146 /* Time to make the doughnuts. */ 221 /* Time to make the doughnuts. */
147 call start_kernel 222 call start_kernel
148 223