1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#include <linux/init.h>
32#include <linux/linkage.h>
33#include <asm/entry.h>
34#include <asm/thread_info.h>
35#include <asm/page.h>
36#include <linux/of_fdt.h>
37
38#ifdef CONFIG_MMU
39#include <asm/setup.h>
40#include <asm/mmu.h>
41#include <asm/processor.h>
42#include <asm/asm-offsets.h>
43
44.section .data
45.global empty_zero_page
46.align 12
47empty_zero_page:
48 .space PAGE_SIZE
49.global swapper_pg_dir
50swapper_pg_dir:
51 .space PAGE_SIZE
52#ifdef CONFIG_SMP
53temp_boot_stack:
54 .space 1024
55#define CURRENT_SAVE CURRENT_SAVE_ADDR
56#endif
57#endif
58
59.section .rodata
60.align 4
61endian_check:
62 .word 1
63
64 __HEAD
65ENTRY(_start)
66
67 brai TOPHYS(real_start)
68 .org 0x100
69real_start:
70#endif
71
72 mts rmsr, r0
73
74 mts rslr, r0
75 addi r8, r0, 0xFFFFFFFF
76 mts rshr, r8
77
78
79
80
81
82
83
84 mfs r1, rmsr
85 msrclr r8, 0
86 cmpu r8, r8, r1
87
88#ifdef CONFIG_SMP
89
90 mfs r11, rpvr0
91 andi r11, r11, 0xFF
92 bnei r11, _setup_initial_mmu
93#endif
94
95
96
97
98
99 beqi r7, no_fdt_arg
100
101
102
103 lbui r11, r0, TOPHYS(endian_check)
104 beqid r11, big_endian
105 lw r11, r0, r7
106 lwr r11, r0, r7
107big_endian:
108 rsubi r11, r11, OF_DT_HEADER
109 beqi r11, _prepare_copy_fdt
110 or r7, r0, r0
111 bnei r11, no_fdt_arg
112_prepare_copy_fdt:
113 or r11, r0, r0
114 ori r4, r0, TOPHYS(_fdt_start)
115 ori r3, r0, (0x10000 - 4)
116_copy_fdt:
117 lw r12, r7, r11
118 sw r12, r4, r11
119 addik r11, r11, 4
120 bgtid r3, _copy_fdt
121 addik r3, r3, -4
122no_fdt_arg:
123
124#ifdef CONFIG_MMU
125
126#ifndef CONFIG_CMDLINE_BOOL
127
128
129
130
131 beqid r5, skip
132 or r11, r0, r0
133 ori r4, r0, cmd_line
134 tophys(r4,r4)
135 ori r3, r0, COMMAND_LINE_SIZE - 1
136_copy_command_line:
137
138 lbu r2, r5, r11
139 beqid r2, skip
140 sb r2, r4, r11
141 addik r11, r11, 1
142 bgtid r3, _copy_command_line
143 addik r3, r3, -1
144 addik r5, r4, 0
145 tovirt(r5,r5)
146skip:
147#endif
148
149#ifdef NOT_COMPILE
150
151 or r11, r0, r0
152 ori r4, r0, TOPHYS(_bram_load_start)
153 ori r3, r0, (LMB_SIZE - 4)
154_copy_bram:
155 lw r7, r0, r11
156 sw r7, r4, r11
157 addik r11, r11, 4
158 bgtid r3, _copy_bram
159 addik r3, r3, -4
160#endif
161
162
163_setup_initial_mmu:
164
165
166
167
168
169 nop
170 addik r3, r0, MICROBLAZE_TLB_SIZE -1
171_invalidate:
172 mts rtlbx, r3
173 mts rtlbhi, r0
174 mts rtlblo, r0
175 bgtid r3, _invalidate
176 addik r3, r3, -1
177
178
179
180 mts rpid,r0
181 nop
182 bri 4
183
184
185
186
187
188
189
190
191 addik r3,r0, CONFIG_KERNEL_START
192 tophys(r4,r3)
193
194
195 addik r12, r0, _end_tlb_mapping
196 rsub r12, r3, r12
197
198 or r9, r0, r0
199 or r10, r0, r0
200
201
202
203
204
205
206 addik r11, r12, -0xc00000
207 beqi r11, GT12
208 addik r11, r12, -0x1000000
209 beqi r11, GT16
210 addik r11, r12, -0x800000
211 beqi r11, GT8
212 addik r11, r12, -0x2000000
213 beqi r11, GT32
214 addik r11, r12, -0x1800000
215 beqi r11, GT24
216 addik r11, r12, -0x1400000
217 beqi r11, GT20
218 addik r11, r12, -0x400000
219 beqi r11, GT4
220
221GT32:
222 addik r9, r0, 0x1000000
223GT16:
224 addik r10, r0, 0x1000000
225 bri tlb_end
226GT24:
227 addik r9, r0, 0x1000000
228GT8:
229 addik r10, r0, 0x800000
230 bri tlb_end
231GT20:
232 addik r9, r0, 0x1000000
233GT4:
234 addik r10, r0, 0x400000
235 bri tlb_end
236GT12:
237 addik r9, r0, 0x800000
238 addik r10, r0, 0x400000
239
240tlb_end:
241
242
243
244
245
246
247
248 andi r4,r4,0xfffffc00
249 ori r4,r4,(TLB_WR | TLB_EX)
250
251
252
253
254
255 bnei r9, tlb0_not_zero
256 add r9, r10, r0
257 add r10, r0, r0
258tlb0_not_zero:
259
260
261 ori r30, r0, 0x200
262 andi r29, r9, 0x100000
263 bneid r29, 1f
264 addik r30, r30, 0x80
265 andi r29, r9, 0x400000
266 bneid r29, 1f
267 addik r30, r30, 0x80
268 andi r29, r9, 0x1000000
269 bneid r29, 1f
270 addik r30, r30, 0x80
2711:
272 andi r3,r3,0xfffffc00
273 ori r3,r3,(TLB_VALID)
274 or r3, r3, r30
275
276
277 lwi r11, r0, TOPHYS(tlb_skip)
278 mts rtlbx,r11
279
280 mts rtlblo,r4
281 mts rtlbhi,r3
282
283
284 addik r11, r11, 1
285 swi r11, r0, TOPHYS(tlb_skip)
286
287
288 beqi r10, jump_over2
289
290
291 ori r30, r0, 0x200
292 andi r29, r10, 0x100000
293 bneid r29, 1f
294 addik r30, r30, 0x80
295 andi r29, r10, 0x400000
296 bneid r29, 1f
297 addik r30, r30, 0x80
298 andi r29, r10, 0x1000000
299 bneid r29, 1f
300 addik r30, r30, 0x80
3011:
302 addk r4, r4, r9
303 addk r3, r3, r9
304
305 andi r3,r3,0xfffffc00
306 ori r3,r3,(TLB_VALID)
307 or r3, r3, r30
308
309 lwi r11, r0, TOPHYS(tlb_skip)
310 mts rtlbx, r11
311
312 mts rtlblo,r4
313 mts rtlbhi,r3
314
315
316 addik r11, r11, 1
317 swi r11, r0, TOPHYS(tlb_skip)
318
319jump_over2:
320
321
322
323
324
325 ori r11, r0, MICROBLAZE_LMB_TLB_ID
326 mts rtlbx,r11
327
328 ori r4,r0,(TLB_WR | TLB_EX)
329 ori r3,r0,(TLB_VALID | TLB_PAGESZ(PAGESZ_4K))
330
331 mts rtlblo,r4
332 mts rtlbhi,r3
333
334
335
336
337
338turn_on_mmu:
339 ori r15,r0,start_here
340#ifdef CONFIG_SMP
341
342
343
344
345 mfs r4, rpvr0
346 andi r4, r4, 0xFF
347
348 beqi r4, finish
349 ori r15, r0, start_secondary_cpu
350finish:
351#endif
352 ori r4,r0,MSR_KERNEL_VMS
353 mts rmsr,r4
354 nop
355 rted r15,0
356 nop
357
358start_here:
359#endif
360
361
362 addik r13, r0, _KERNEL_SDA_BASE_
363 addik r2, r0, _KERNEL_SDA2_BASE_
364
365
366 addik r1, r0, init_thread_union + THREAD_SIZE - 4
367
368
369 addik r31, r0, init_task
370#ifdef CONFIG_MMU
371
372 swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE);
373#endif
374
375 addik r11, r0, machine_early_init
376 brald r15, r11
377 nop
378
379#ifndef CONFIG_MMU
380 addik r15, r0, machine_halt
381 braid start_kernel
382 nop
383#else
384
385
386
387 bralid r15, mmu_init
388 nop
389
390
391
392
393
394
395 ori r15,r0,TOPHYS(kernel_load_context)
396 ori r4,r0,MSR_KERNEL
397 mts rmsr,r4
398 nop
399 bri 4
400 rted r15,0
401 nop
402
403
404kernel_load_context:
405 ori r5, r0, MICROBLAZE_LMB_TLB_ID
406 mts rtlbx,r5
407 nop
408 mts rtlbhi,r0
409 nop
410 addi r15, r0, machine_halt
411 ori r17, r0, start_kernel
412 ori r4, r0, MSR_KERNEL_VMS
413 mts rmsr, r4
414 nop
415 rted r17, 0
416 nop
417#endif
418
419#ifdef CONFIG_SMP
420
421start_secondary_cpu:
422
423
424 addik r13, r0, _KERNEL_SDA_BASE_
425 addik r2, r0, _KERNEL_SDA2_BASE_
426
427
428 addik r1, r0, temp_boot_stack + 1024 - 4
429
430
431
432
433 addik r11, r0, secondary_machine_init
434 brald r15, r11
435 nop
436
437 lwi r1, r0, secondary_ti
438
439
440 lwi CURRENT_TASK, r1, TI_TASK
441
442 swi CURRENT_TASK, r0, PER_CPU(CURRENT_SAVE);
443
444
445 addi r1, r1, THREAD_SIZE - 4
446 swi r0, r1, 0
447
448
449 ori r11, r0, 0x10000000
450 mts rzpr, r11
451
452 ori r15, r0, TOPHYS(kernel_load_context_secondary)
453 ori r4, r0, MSR_KERNEL
454 mts rmsr, r4
455 nop
456 bri 4
457 rted r15, 0
458 nop
459
460
461kernel_load_context_secondary:
462
463 ori r5, r0, MICROBLAZE_LMB_TLB_ID
464 mts rtlbx, r5
465 nop
466 mts rtlbhi, r0
467 nop
468 addi r15, r0, machine_halt
469 ori r17, r0, start_secondary
470 ori r4, r0, MSR_KERNEL_VMS
471 mts rmsr, r4
472 nop
473 rted r17, 0
474 nop
475#endif
476