0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <linux/init.h>
0018 #include <linux/magic.h>
0019 #include <linux/pgtable.h>
0020 #include <linux/sizes.h>
0021 #include <asm/processor.h>
0022 #include <asm/page.h>
0023 #include <asm/mmu.h>
0024 #include <asm/cache.h>
0025 #include <asm/cputable.h>
0026 #include <asm/thread_info.h>
0027 #include <asm/ppc_asm.h>
0028 #include <asm/asm-offsets.h>
0029 #include <asm/ptrace.h>
0030 #include <asm/export.h>
0031 #include <asm/code-patching-asm.h>
0032 #include <asm/interrupt.h>
0033
0034
0035
0036
0037
0038 #define RPN_PATTERN 0x00f0
0039
0040 #include "head_32.h"
0041
0042 .macro compare_to_kernel_boundary scratch, addr
0043 #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000
0044
0045 not. \scratch, \addr
0046 #else
0047 rlwinm \scratch, \addr, 16, 0xfff8
0048 cmpli cr0, \scratch, PAGE_OFFSET@h
0049 #endif
0050 .endm
0051
0052 #define PAGE_SHIFT_512K 19
0053 #define PAGE_SHIFT_8M 23
0054
0055 __HEAD
0056 _GLOBAL(_stext);
0057 _GLOBAL(_start);
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 .globl __start
0083 __start:
0084 mr r31,r3
0085
0086
0087
0088
0089 bl initial_mmu
0090
0091
0092
0093
0094
0095 turn_on_mmu:
0096 mfmsr r0
0097 ori r0,r0,MSR_DR|MSR_IR
0098 mtspr SPRN_SRR1,r0
0099 lis r0,start_here@h
0100 ori r0,r0,start_here@l
0101 mtspr SPRN_SRR0,r0
0102 rfi
0103
0104
0105 #ifdef CONFIG_PERF_EVENTS
0106 .align 4
0107
0108 .globl itlb_miss_counter
0109 itlb_miss_counter:
0110 .space 4
0111
0112 .globl dtlb_miss_counter
0113 dtlb_miss_counter:
0114 .space 4
0115
0116 .globl instruction_counter
0117 instruction_counter:
0118 .space 4
0119 #endif
0120
0121
0122 EXCEPTION(INTERRUPT_SYSTEM_RESET, Reset, system_reset_exception)
0123
0124
0125 START_EXCEPTION(INTERRUPT_MACHINE_CHECK, MachineCheck)
0126 EXCEPTION_PROLOG INTERRUPT_MACHINE_CHECK MachineCheck handle_dar_dsisr=1
0127 prepare_transfer_to_handler
0128 bl machine_check_exception
0129 b interrupt_return
0130
0131
0132 EXCEPTION(INTERRUPT_EXTERNAL, HardwareInterrupt, do_IRQ)
0133
0134
0135 START_EXCEPTION(INTERRUPT_ALIGNMENT, Alignment)
0136 EXCEPTION_PROLOG INTERRUPT_ALIGNMENT Alignment handle_dar_dsisr=1
0137 prepare_transfer_to_handler
0138 bl alignment_exception
0139 REST_NVGPRS(r1)
0140 b interrupt_return
0141
0142
0143 START_EXCEPTION(INTERRUPT_PROGRAM, ProgramCheck)
0144 EXCEPTION_PROLOG INTERRUPT_PROGRAM ProgramCheck
0145 prepare_transfer_to_handler
0146 bl program_check_exception
0147 REST_NVGPRS(r1)
0148 b interrupt_return
0149
0150
0151 EXCEPTION(INTERRUPT_DECREMENTER, Decrementer, timer_interrupt)
0152
0153
0154 START_EXCEPTION(INTERRUPT_SYSCALL, SystemCall)
0155 SYSCALL_ENTRY INTERRUPT_SYSCALL
0156
0157
0158 EXCEPTION(INTERRUPT_TRACE, SingleStep, single_step_exception)
0159
0160
0161
0162
0163 START_EXCEPTION(INTERRUPT_SOFT_EMU_8xx, SoftEmu)
0164 EXCEPTION_PROLOG INTERRUPT_SOFT_EMU_8xx SoftEmu
0165 prepare_transfer_to_handler
0166 bl emulation_assist_interrupt
0167 REST_NVGPRS(r1)
0168 b interrupt_return
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181 #ifdef CONFIG_8xx_CPU15
0182 #define INVALIDATE_ADJACENT_PAGES_CPU15(addr, tmp) \
0183 addi tmp, addr, PAGE_SIZE; \
0184 tlbie tmp; \
0185 addi tmp, addr, -PAGE_SIZE; \
0186 tlbie tmp
0187 #else
0188 #define INVALIDATE_ADJACENT_PAGES_CPU15(addr, tmp)
0189 #endif
0190
0191 START_EXCEPTION(INTERRUPT_INST_TLB_MISS_8xx, InstructionTLBMiss)
0192 mtspr SPRN_SPRG_SCRATCH2, r10
0193 mtspr SPRN_M_TW, r11
0194
0195
0196
0197
0198 mfspr r10, SPRN_SRR0
0199 INVALIDATE_ADJACENT_PAGES_CPU15(r10, r11)
0200 mtspr SPRN_MD_EPN, r10
0201 #ifdef CONFIG_MODULES
0202 mfcr r11
0203 compare_to_kernel_boundary r10, r10
0204 #endif
0205 mfspr r10, SPRN_M_TWB
0206 #ifdef CONFIG_MODULES
0207 blt+ 3f
0208 rlwinm r10, r10, 0, 20, 31
0209 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
0210 3:
0211 mtcr r11
0212 #endif
0213 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10)
0214 mtspr SPRN_MD_TWC, r11
0215 mfspr r10, SPRN_MD_TWC
0216 lwz r10, 0(r10)
0217 rlwimi r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED
0218 rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K
0219 mtspr SPRN_MI_TWC, r11
0220
0221
0222
0223
0224
0225
0226 rlwinm r10, r10, 0, ~0x0f00
0227 rlwimi r10, r10, 4, 0x0400
0228 ori r10, r10, RPN_PATTERN | 0x200
0229 mtspr SPRN_MI_RPN, r10
0230
0231
0232 0: mfspr r10, SPRN_SPRG_SCRATCH2
0233 mfspr r11, SPRN_M_TW
0234 rfi
0235 patch_site 0b, patch__itlbmiss_exit_1
0236
0237 #ifdef CONFIG_PERF_EVENTS
0238 patch_site 0f, patch__itlbmiss_perf
0239 0: lwz r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)
0240 addi r10, r10, 1
0241 stw r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)
0242 mfspr r10, SPRN_SPRG_SCRATCH2
0243 mfspr r11, SPRN_M_TW
0244 rfi
0245 #endif
0246
0247 START_EXCEPTION(INTERRUPT_DATA_TLB_MISS_8xx, DataStoreTLBMiss)
0248 mtspr SPRN_SPRG_SCRATCH2, r10
0249 mtspr SPRN_M_TW, r11
0250 mfcr r11
0251
0252
0253
0254
0255 mfspr r10, SPRN_MD_EPN
0256 compare_to_kernel_boundary r10, r10
0257 mfspr r10, SPRN_M_TWB
0258 blt+ 3f
0259 rlwinm r10, r10, 0, 20, 31
0260 oris r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
0261 3:
0262 mtcr r11
0263 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10)
0264
0265 mtspr SPRN_MD_TWC, r11
0266 mfspr r10, SPRN_MD_TWC
0267 lwz r10, 0(r10)
0268
0269
0270
0271
0272
0273
0274
0275 rlwimi r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED
0276 rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K
0277 mtspr SPRN_MD_TWC, r11
0278
0279
0280
0281
0282
0283
0284 li r11, RPN_PATTERN
0285 rlwimi r10, r11, 0, 24, 27
0286 mtspr SPRN_MD_RPN, r10
0287 mtspr SPRN_DAR, r11
0288
0289
0290
0291 0: mfspr r10, SPRN_SPRG_SCRATCH2
0292 mfspr r11, SPRN_M_TW
0293 rfi
0294 patch_site 0b, patch__dtlbmiss_exit_1
0295
0296 #ifdef CONFIG_PERF_EVENTS
0297 patch_site 0f, patch__dtlbmiss_perf
0298 0: lwz r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0)
0299 addi r10, r10, 1
0300 stw r10, (dtlb_miss_counter - PAGE_OFFSET)@l(0)
0301 mfspr r10, SPRN_SPRG_SCRATCH2
0302 mfspr r11, SPRN_M_TW
0303 rfi
0304 #endif
0305
0306
0307
0308
0309
0310 START_EXCEPTION(INTERRUPT_INST_TLB_ERROR_8xx, InstructionTLBError)
0311
0312 EXCEPTION_PROLOG INTERRUPT_INST_STORAGE InstructionTLBError
0313 andis. r5,r9,DSISR_SRR1_MATCH_32S@h
0314 andis. r10,r9,SRR1_ISI_NOPT@h
0315 beq+ .Litlbie
0316 tlbie r12
0317 .Litlbie:
0318 stw r12, _DAR(r11)
0319 stw r5, _DSISR(r11)
0320 prepare_transfer_to_handler
0321 bl do_page_fault
0322 b interrupt_return
0323
0324
0325
0326
0327
0328 START_EXCEPTION(INTERRUPT_DATA_TLB_ERROR_8xx, DataTLBError)
0329 EXCEPTION_PROLOG_0 handle_dar_dsisr=1
0330 mfspr r11, SPRN_DAR
0331 cmpwi cr1, r11, RPN_PATTERN
0332 beq- cr1, FixupDAR
0333 DARFixed:
0334 EXCEPTION_PROLOG_1
0335
0336 EXCEPTION_PROLOG_2 INTERRUPT_DATA_STORAGE DataTLBError handle_dar_dsisr=1
0337 lwz r4, _DAR(r11)
0338 lwz r5, _DSISR(r11)
0339 andis. r10,r5,DSISR_NOHPTE@h
0340 beq+ .Ldtlbie
0341 tlbie r4
0342 .Ldtlbie:
0343 prepare_transfer_to_handler
0344 bl do_page_fault
0345 b interrupt_return
0346
0347 #ifdef CONFIG_VMAP_STACK
0348 vmap_stack_overflow_exception
0349 #endif
0350
0351
0352
0353
0354
0355 START_EXCEPTION(INTERRUPT_DATA_BREAKPOINT_8xx, DataBreakpoint)
0356 EXCEPTION_PROLOG_0 handle_dar_dsisr=1
0357 mfspr r11, SPRN_SRR0
0358 cmplwi cr1, r11, (.Ldtlbie - PAGE_OFFSET)@l
0359 cmplwi cr7, r11, (.Litlbie - PAGE_OFFSET)@l
0360 cror 4*cr1+eq, 4*cr1+eq, 4*cr7+eq
0361 bne cr1, 1f
0362 mtcr r10
0363 mfspr r10, SPRN_SPRG_SCRATCH0
0364 mfspr r11, SPRN_SPRG_SCRATCH1
0365 rfi
0366
0367 1: EXCEPTION_PROLOG_1
0368 EXCEPTION_PROLOG_2 INTERRUPT_DATA_BREAKPOINT_8xx DataBreakpoint handle_dar_dsisr=1
0369 mfspr r4,SPRN_BAR
0370 stw r4,_DAR(r11)
0371 prepare_transfer_to_handler
0372 bl do_break
0373 REST_NVGPRS(r1)
0374 b interrupt_return
0375
0376 #ifdef CONFIG_PERF_EVENTS
0377 START_EXCEPTION(INTERRUPT_INST_BREAKPOINT_8xx, InstructionBreakpoint)
0378 mtspr SPRN_SPRG_SCRATCH0, r10
0379 lwz r10, (instruction_counter - PAGE_OFFSET)@l(0)
0380 addi r10, r10, -1
0381 stw r10, (instruction_counter - PAGE_OFFSET)@l(0)
0382 lis r10, 0xffff
0383 ori r10, r10, 0x01
0384 mtspr SPRN_COUNTA, r10
0385 mfspr r10, SPRN_SPRG_SCRATCH0
0386 rfi
0387 #else
0388 EXCEPTION(INTERRUPT_INST_BREAKPOINT_8xx, Trap_1d, unknown_exception)
0389 #endif
0390 EXCEPTION(0x1e00, Trap_1e, unknown_exception)
0391 EXCEPTION(0x1f00, Trap_1f, unknown_exception)
0392
0393 __HEAD
0394 . = 0x2000
0395
0396
0397
0398
0399
0400 FixupDAR:
0401 mtspr SPRN_M_TW, r10
0402
0403 mfspr r10, SPRN_SRR0
0404 mtspr SPRN_MD_EPN, r10
0405 rlwinm r11, r10, 16, 0xfff8
0406 cmpli cr1, r11, PAGE_OFFSET@h
0407 mfspr r11, SPRN_M_TWB
0408 blt+ cr1, 3f
0409
0410
0411 tophys(r11, r10)
0412 mfspr r11, SPRN_M_TWB
0413 rlwinm r11, r11, 0, 20, 31
0414 oris r11, r11, (swapper_pg_dir - PAGE_OFFSET)@ha
0415 3:
0416 lwz r11, (swapper_pg_dir-PAGE_OFFSET)@l(r11)
0417 mtspr SPRN_MD_TWC, r11
0418 mtcrf 0x01, r11
0419 mfspr r11, SPRN_MD_TWC
0420 lwz r11, 0(r11)
0421 bt 28,200f
0422
0423 rlwimi r11, r10, 0, 32 - PAGE_SHIFT, 31
0424 201: lwz r11,0(r11)
0425
0426
0427
0428 xoris r10, r11, 0x7c00
0429 rlwinm r10, r10, 0, 21, 5
0430 cmpwi cr1, r10, 2028
0431 beq+ cr1, 142f
0432 cmpwi cr1, r10, 940
0433 beq+ cr1, 142f
0434 cmpwi cr1, r10, 108
0435 beq+ cr1, 144f
0436 cmpwi cr1, r10, 172
0437 beq+ cr1, 142f
0438 cmpwi cr1, r10, 1964
0439 beq+ cr1, 142f
0440 141: mfspr r10,SPRN_M_TW
0441 b DARFixed
0442
0443 200:
0444
0445 rlwimi r11, r10, 0, 32 - PAGE_SHIFT_8M, 31
0446 b 201b
0447
0448 144: mfspr r10, SPRN_DSISR
0449 rlwinm r10, r10,0,7,5
0450 mtspr SPRN_DSISR, r10
0451 142:
0452 mfctr r10
0453 mtdar r10
0454 rlwinm r10, r11, 24, 24, 28
0455 addi r10, r10, 150f@l
0456 mtctr r10
0457 xor r10, r10, r10
0458 bctr
0459 150:
0460 add r10, r10, r0 ;b 151f
0461 add r10, r10, r1 ;b 151f
0462 add r10, r10, r2 ;b 151f
0463 add r10, r10, r3 ;b 151f
0464 add r10, r10, r4 ;b 151f
0465 add r10, r10, r5 ;b 151f
0466 add r10, r10, r6 ;b 151f
0467 add r10, r10, r7 ;b 151f
0468 add r10, r10, r8 ;b 151f
0469 add r10, r10, r9 ;b 151f
0470 mtctr r11 ;b 154f
0471 mtctr r11 ;b 153f
0472 add r10, r10, r12 ;b 151f
0473 add r10, r10, r13 ;b 151f
0474 add r10, r10, r14 ;b 151f
0475 add r10, r10, r15 ;b 151f
0476 add r10, r10, r16 ;b 151f
0477 add r10, r10, r17 ;b 151f
0478 add r10, r10, r18 ;b 151f
0479 add r10, r10, r19 ;b 151f
0480 add r10, r10, r20 ;b 151f
0481 add r10, r10, r21 ;b 151f
0482 add r10, r10, r22 ;b 151f
0483 add r10, r10, r23 ;b 151f
0484 add r10, r10, r24 ;b 151f
0485 add r10, r10, r25 ;b 151f
0486 add r10, r10, r26 ;b 151f
0487 add r10, r10, r27 ;b 151f
0488 add r10, r10, r28 ;b 151f
0489 add r10, r10, r29 ;b 151f
0490 add r10, r10, r30 ;b 151f
0491 add r10, r10, r31
0492 151:
0493 rlwinm r11,r11,19,24,28
0494 cmpwi cr1, r11, 0
0495 beq cr1, 152f
0496 addi r11, r11, 150b@l
0497 mtctr r11
0498 rlwinm r11,r11,0,16,10
0499 bctr
0500 152:
0501 mfdar r11
0502 mtctr r11
0503 mfspr r11, SPRN_SPRG_THREAD
0504 stw r10, DAR(r11)
0505 mfspr r10, SPRN_DSISR
0506 stw r10, DSISR(r11)
0507 mfspr r10,SPRN_M_TW
0508 b DARFixed
0509
0510
0511 153: mfspr r11, SPRN_SPRG_SCRATCH1
0512 add r10, r10, r11
0513 mfctr r11
0514 b 151b
0515 154: mfspr r11, SPRN_SPRG_SCRATCH0
0516 add r10, r10, r11
0517 mfctr r11
0518 b 151b
0519
0520
0521
0522
0523 start_here:
0524
0525 lis r2,init_task@h
0526 ori r2,r2,init_task@l
0527
0528
0529 tophys(r4,r2)
0530 addi r4,r4,THREAD
0531 mtspr SPRN_SPRG_THREAD,r4
0532
0533
0534 lis r1,init_thread_union@ha
0535 addi r1,r1,init_thread_union@l
0536 lis r0, STACK_END_MAGIC@h
0537 ori r0, r0, STACK_END_MAGIC@l
0538 stw r0, 0(r1)
0539 li r0,0
0540 stwu r0,THREAD_SIZE-STACK_FRAME_OVERHEAD(r1)
0541
0542 lis r6, swapper_pg_dir@ha
0543 tophys(r6,r6)
0544 mtspr SPRN_M_TWB, r6
0545
0546 bl early_init
0547
0548
0549
0550
0551 #ifdef CONFIG_KASAN
0552 bl kasan_early_init
0553 #endif
0554 li r3,0
0555 mr r4,r31
0556 bl machine_init
0557 bl MMU_init
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569 lis r4,2f@h
0570 ori r4,r4,2f@l
0571 tophys(r4,r4)
0572 li r3,MSR_KERNEL & ~(MSR_IR|MSR_DR)
0573 mtspr SPRN_SRR0,r4
0574 mtspr SPRN_SRR1,r3
0575 rfi
0576
0577 2:
0578 #ifdef CONFIG_PIN_TLB_IMMR
0579 lis r0, MD_TWAM@h
0580 oris r0, r0, 0x1f00
0581 mtspr SPRN_MD_CTR, r0
0582 LOAD_REG_IMMEDIATE(r0, VIRT_IMMR_BASE | MD_EVALID)
0583 tlbie r0
0584 mtspr SPRN_MD_EPN, r0
0585 LOAD_REG_IMMEDIATE(r0, MD_SVALID | MD_PS512K | MD_GUARDED)
0586 mtspr SPRN_MD_TWC, r0
0587 mfspr r0, SPRN_IMMR
0588 rlwinm r0, r0, 0, 0xfff80000
0589 ori r0, r0, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \
0590 _PAGE_NO_CACHE | _PAGE_PRESENT
0591 mtspr SPRN_MD_RPN, r0
0592 lis r0, (MD_TWAM | MD_RSV4I)@h
0593 mtspr SPRN_MD_CTR, r0
0594 #endif
0595 #if !defined(CONFIG_PIN_TLB_DATA) && !defined(CONFIG_PIN_TLB_IMMR)
0596 lis r0, MD_TWAM@h
0597 mtspr SPRN_MD_CTR, r0
0598 #endif
0599 tlbia
0600 sync
0601
0602
0603
0604 lis r5, abatron_pteptrs@h
0605 ori r5, r5, abatron_pteptrs@l
0606 stw r5, 0xf0(0)
0607 tophys(r5,r5)
0608 lis r6, swapper_pg_dir@h
0609 ori r6, r6, swapper_pg_dir@l
0610 stw r6, 0(r5)
0611
0612
0613 li r4,MSR_KERNEL
0614 lis r3,start_kernel@h
0615 ori r3,r3,start_kernel@l
0616 mtspr SPRN_SRR0,r3
0617 mtspr SPRN_SRR1,r4
0618 rfi
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628 initial_mmu:
0629 li r8, 0
0630 mtspr SPRN_MI_CTR, r8
0631 lis r10, MD_TWAM@h
0632 mtspr SPRN_MD_CTR, r10
0633
0634 tlbia
0635
0636 lis r8, MI_APG_INIT@h
0637 ori r8, r8, MI_APG_INIT@l
0638 mtspr SPRN_MI_AP, r8
0639 lis r8, MD_APG_INIT@h
0640 ori r8, r8, MD_APG_INIT@l
0641 mtspr SPRN_MD_AP, r8
0642
0643
0644 lis r8, MI_RSV4I@h
0645 ori r8, r8, 0x1c00
0646 oris r12, r10, MD_RSV4I@h
0647 ori r12, r12, 0x1c00
0648 li r9, 4
0649 mtctr r9
0650 lis r9, KERNELBASE@h
0651 li r10, MI_PS8MEG | _PMD_ACCESSED | MI_SVALID
0652 li r11, MI_BOOTINIT
0653 1:
0654 mtspr SPRN_MI_CTR, r8
0655 addi r8, r8, 0x100
0656 ori r0, r9, MI_EVALID
0657 mtspr SPRN_MI_EPN, r0
0658 mtspr SPRN_MI_TWC, r10
0659 mtspr SPRN_MI_RPN, r11
0660 mtspr SPRN_MD_CTR, r12
0661 addi r12, r12, 0x100
0662 mtspr SPRN_MD_EPN, r0
0663 mtspr SPRN_MD_TWC, r10
0664 mtspr SPRN_MD_RPN, r11
0665 addis r9, r9, 0x80
0666 addis r11, r11, 0x80
0667
0668 bdnz 1b
0669
0670
0671
0672
0673
0674 lis r8, IDC_INVALL@h
0675 mtspr SPRN_IC_CST, r8
0676 mtspr SPRN_DC_CST, r8
0677 lis r8, IDC_ENABLE@h
0678 mtspr SPRN_IC_CST, r8
0679 mtspr SPRN_DC_CST, r8
0680
0681 mfspr r8, SPRN_DER
0682 #ifdef CONFIG_PERF_EVENTS
0683 rlwinm r8, r8, 0, ~0xc
0684 #else
0685 rlwinm r8, r8, 0, ~0x8
0686 #endif
0687 mtspr SPRN_DER, r8
0688 blr
0689
0690 _GLOBAL(mmu_pin_tlb)
0691 lis r9, (1f - PAGE_OFFSET)@h
0692 ori r9, r9, (1f - PAGE_OFFSET)@l
0693 mfmsr r10
0694 mflr r11
0695 li r12, MSR_KERNEL & ~(MSR_IR | MSR_DR | MSR_RI)
0696 rlwinm r0, r10, 0, ~MSR_RI
0697 rlwinm r0, r0, 0, ~MSR_EE
0698 mtmsr r0
0699 isync
0700 .align 4
0701 mtspr SPRN_SRR0, r9
0702 mtspr SPRN_SRR1, r12
0703 rfi
0704 1:
0705 li r5, 0
0706 lis r6, MD_TWAM@h
0707 mtspr SPRN_MI_CTR, r5
0708 mtspr SPRN_MD_CTR, r6
0709 tlbia
0710
0711 LOAD_REG_IMMEDIATE(r5, 28 << 8)
0712 LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)
0713 LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)
0714 LOAD_REG_IMMEDIATE(r8, 0xf0 | _PAGE_RO | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT)
0715 LOAD_REG_ADDR(r9, _sinittext)
0716 li r0, 4
0717 mtctr r0
0718
0719 2: ori r0, r6, MI_EVALID
0720 mtspr SPRN_MI_CTR, r5
0721 mtspr SPRN_MI_EPN, r0
0722 mtspr SPRN_MI_TWC, r7
0723 mtspr SPRN_MI_RPN, r8
0724 addi r5, r5, 0x100
0725 addis r6, r6, SZ_8M@h
0726 addis r8, r8, SZ_8M@h
0727 cmplw r6, r9
0728 bdnzt lt, 2b
0729 lis r0, MI_RSV4I@h
0730 mtspr SPRN_MI_CTR, r0
0731
0732 LOAD_REG_IMMEDIATE(r5, 28 << 8 | MD_TWAM)
0733 #ifdef CONFIG_PIN_TLB_DATA
0734 LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)
0735 LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)
0736 li r8, 0
0737 #ifdef CONFIG_PIN_TLB_IMMR
0738 li r0, 3
0739 #else
0740 li r0, 4
0741 #endif
0742 mtctr r0
0743 cmpwi r4, 0
0744 beq 4f
0745 LOAD_REG_ADDR(r9, _sinittext)
0746
0747 2: ori r0, r6, MD_EVALID
0748 ori r12, r8, 0xf0 | _PAGE_RO | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT
0749 mtspr SPRN_MD_CTR, r5
0750 mtspr SPRN_MD_EPN, r0
0751 mtspr SPRN_MD_TWC, r7
0752 mtspr SPRN_MD_RPN, r12
0753 addi r5, r5, 0x100
0754 addis r6, r6, SZ_8M@h
0755 addis r8, r8, SZ_8M@h
0756 cmplw r6, r9
0757 bdnzt lt, 2b
0758 4:
0759 2: ori r0, r6, MD_EVALID
0760 ori r12, r8, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT
0761 mtspr SPRN_MD_CTR, r5
0762 mtspr SPRN_MD_EPN, r0
0763 mtspr SPRN_MD_TWC, r7
0764 mtspr SPRN_MD_RPN, r12
0765 addi r5, r5, 0x100
0766 addis r6, r6, SZ_8M@h
0767 addis r8, r8, SZ_8M@h
0768 cmplw r6, r3
0769 bdnzt lt, 2b
0770 #endif
0771 #ifdef CONFIG_PIN_TLB_IMMR
0772 LOAD_REG_IMMEDIATE(r0, VIRT_IMMR_BASE | MD_EVALID)
0773 LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED | _PMD_ACCESSED)
0774 mfspr r8, SPRN_IMMR
0775 rlwinm r8, r8, 0, 0xfff80000
0776 ori r8, r8, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \
0777 _PAGE_NO_CACHE | _PAGE_PRESENT
0778 mtspr SPRN_MD_CTR, r5
0779 mtspr SPRN_MD_EPN, r0
0780 mtspr SPRN_MD_TWC, r7
0781 mtspr SPRN_MD_RPN, r8
0782 #endif
0783 #if defined(CONFIG_PIN_TLB_IMMR) || defined(CONFIG_PIN_TLB_DATA)
0784 lis r0, (MD_RSV4I | MD_TWAM)@h
0785 mtspr SPRN_MD_CTR, r0
0786 #endif
0787 mtspr SPRN_SRR1, r10
0788 mtspr SPRN_SRR0, r11
0789 rfi