1
2
3
4
5
6
7
8
9 #include <linux/init.h>
10
11 #include <asm/page.h>
12 #include <asm/cache.h>
13 #include <asm/tlb.h>
14 #include <cpu/registers.h>
15 #include <cpu/mmu_context.h>
16 #include <asm/thread_info.h>
17
18
19
20
21
22 #define MMUIR_FIRST ITLB_FIXED
23 #define MMUIR_END ITLB_LAST_VAR_UNRESTRICTED+TLB_STEP
24 #define MMUIR_STEP TLB_STEP
25
26 #define MMUDR_FIRST DTLB_FIXED
27 #define MMUDR_END DTLB_LAST_VAR_UNRESTRICTED+TLB_STEP
28 #define MMUDR_STEP TLB_STEP
29
30
31 #if (CONFIG_PAGE_OFFSET & ((1UL<<29)-1))
32 #error "CONFIG_PAGE_OFFSET must be a multiple of 512Mb"
33 #endif
34
35
36
37
38
39
40 #define ALIGN_512M_MASK (0xffffffffe0000000)
41 #define ALIGNED_EFFECTIVE ((CONFIG_PAGE_OFFSET + CONFIG_MEMORY_START) & ALIGN_512M_MASK)
42 #define ALIGNED_PHYSICAL (CONFIG_MEMORY_START & ALIGN_512M_MASK)
43
44 #define MMUIR_TEXT_H (0x0000000000000003 | ALIGNED_EFFECTIVE)
45
46
47 #define MMUIR_TEXT_L (0x000000000000009a | ALIGNED_PHYSICAL)
48
49
50 #define MMUDR_CACHED_H 0x0000000000000003 | ALIGNED_EFFECTIVE
51
52 #define MMUDR_CACHED_L 0x000000000000015a | ALIGNED_PHYSICAL
53
54
55 #ifdef CONFIG_CACHE_OFF
56 #define ICCR0_INIT_VAL ICCR0_OFF
57 #else
58 #define ICCR0_INIT_VAL ICCR0_ON | ICCR0_ICI
59 #endif
60 #define ICCR1_INIT_VAL ICCR1_NOLOCK
61
62 #if defined (CONFIG_CACHE_OFF)
63 #define OCCR0_INIT_VAL OCCR0_OFF
64 #elif defined (CONFIG_CACHE_WRITETHROUGH)
65 #define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WT
66
67 #elif defined (CONFIG_CACHE_WRITEBACK)
68 #define OCCR0_INIT_VAL OCCR0_ON | OCCR0_OCI | OCCR0_WB
69
70 #else
71 #error preprocessor flag CONFIG_CACHE_... not recognized!
72 #endif
73
74 #define OCCR1_INIT_VAL OCCR1_NOLOCK
75
76 .section .empty_zero_page, "aw"
77 .global empty_zero_page
78
79 empty_zero_page:
80 .long 1
81 .long 0
82 .long 0x0200
83 .long 1
84 .long 0x00800000
85 .long 0x00800000
86 .long 0
87
88 .text
89 .balign 4096,0,4096
90
91 .section .data, "aw"
92 .balign PAGE_SIZE
93
94 .section .data, "aw"
95 .balign PAGE_SIZE
96
97 .global mmu_pdtp_cache
98 mmu_pdtp_cache:
99 .space PAGE_SIZE, 0
100
101 .global fpu_in_use
102 fpu_in_use: .quad 0
103
104
105 __HEAD
106 .balign L1_CACHE_BYTES
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 .global _stext
138 _stext:
139
140
141
142
143 ptabs/u ZERO, tr0
144 ptabs/u ZERO, tr1
145 ptabs/u ZERO, tr2
146 ptabs/u ZERO, tr3
147 ptabs/u ZERO, tr4
148 ptabs/u ZERO, tr5
149 ptabs/u ZERO, tr6
150 ptabs/u ZERO, tr7
151 synci
152
153
154
155
156
157 getcon SR, r29
158 movi SR_HARMLESS, r20
159 putcon r20, SR
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177 pta clear_ITLB, tr1
178 movi MMUIR_FIRST, r21
179 movi MMUIR_END, r22
180 clear_ITLB:
181 putcfg r21, 0, ZERO
182 addi r21, MMUIR_STEP, r21
183 bne r21, r22, tr1
184
185
186 pta clear_DTLB, tr1
187 movi MMUDR_FIRST, r21
188 movi MMUDR_END, r22
189 clear_DTLB:
190 putcfg r21, 0, ZERO
191 addi r21, MMUDR_STEP, r21
192 bne r21, r22, tr1
193
194
195 movi MMUIR_FIRST, r21
196 movi MMUIR_TEXT_L, r22
197 add.l r22, r63, r22
198 putcfg r21, 1, r22
199 movi MMUIR_TEXT_H, r22
200 add.l r22, r63, r22
201 putcfg r21, 0, r22
202
203
204 movi MMUDR_FIRST, r21
205 movi MMUDR_CACHED_L, r22
206 add.l r22, r63, r22
207 putcfg r21, 1, r22
208 movi MMUDR_CACHED_H, r22
209 add.l r22, r63, r22
210 putcfg r21, 0, r22
211
212
213
214
215 addi r21, MMUDR_STEP, r21
216 movi 0x0a03, r22
217 shori 0x0148, r22
218 putcfg r21, 1, r22
219 movi 0xfa03, r22
220 shori 0x0003, r22
221 putcfg r21, 0, r22
222
223
224
225
226
227 movi ICCR_BASE, r21
228 movi ICCR0_INIT_VAL, r22
229 movi ICCR1_INIT_VAL, r23
230 putcfg r21, ICCR_REG0, r22
231 putcfg r21, ICCR_REG1, r23
232
233
234 movi OCCR_BASE, r21
235 movi OCCR0_INIT_VAL, r22
236 movi OCCR1_INIT_VAL, r23
237 putcfg r21, OCCR_REG0, r22
238 putcfg r21, OCCR_REG1, r23
239
240
241
242
243
244
245
246 getcon SR, r21
247 movi SR_ENABLE_MMU, r22
248 or r21, r22, r21
249 putcon r21, SSR
250 movi hyperspace, r22
251 ori r22, 1, r22
252 putcon r22, SPC
253 synco
254 rte
255 hyperspace:
256
257
258
259
260
261
262 movi start_kernel, r32
263 ori r32, 1, r32
264
265 ptabs r32, tr0
266 pta/u hopeless, tr1
267 pta/u hopeless, tr2
268 pta/u hopeless, tr3
269 pta/u hopeless, tr4
270 pta/u hopeless, tr5
271 pta/u hopeless, tr6
272 pta/u hopeless, tr7
273 gettr tr1, r28
274
275
276 movi init_thread_union, SP
277 putcon SP, KCR0
278 movi THREAD_SIZE, r22
279 add SP, r22, SP
280
281
282
283
284
285
286 movi fpu_in_use, r31
287
288 #ifdef CONFIG_SH_FPU
289 getcon SR, r21
290 movi SR_ENABLE_FPU, r22
291 and r21, r22, r22
292 putcon r22, SR
293 getcon SR, r22
294 xor r21, r22, r21
295 shlri r21, 15, r21
296 st.q r31, 0 , r21
297 #else
298 movi 0, r21
299 st.q r31, 0 , r21
300 #endif
301 or r21, ZERO, r31
302
303 #ifndef CONFIG_SH_NO_BSS_INIT
304
305
306
307
308
309
310 pta clear_quad, tr1
311 movi __bss_start, r22
312 movi _end, r23
313 clear_quad:
314 st.q r22, 0, ZERO
315 addi r22, 8, r22
316 bne r22, r23, tr1
317 #endif
318 pta/u hopeless, tr1
319
320
321 blink tr0, LINK
322
323
324 pta/u hopeless, tr7
325
326 hopeless:
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346 blink tr7, ZERO