2 * arch/ppc64/kernel/head.S
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
8 * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
9 * Adapted for Power Macintosh by Paul Mackerras.
10 * Low-level exception handlers and MMU support
11 * rewritten by Paul Mackerras.
12 * Copyright (C) 1996 Paul Mackerras.
14 * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
15 * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
17 * This file contains the low-level support and setup for the
18 * PowerPC-64 platform, including trap and interrupt dispatch.
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version
23 * 2 of the License, or (at your option) any later version.
26 #include <linux/config.h>
27 #include <linux/threads.h>
31 #include <asm/systemcfg.h>
32 #include <asm/ppc_asm.h>
33 #include <asm/asm-offsets.h>
35 #include <asm/cputable.h>
36 #include <asm/setup.h>
37 #include <asm/hvcall.h>
38 #include <asm/iseries/lpar_map.h>
39 #include <asm/thread_info.h>
41 #ifdef CONFIG_PPC_ISERIES
42 #define DO_SOFT_DISABLE
46 * We layout physical memory as follows:
47 * 0x0000 - 0x00ff : Secondary processor spin code
48 * 0x0100 - 0x2fff : pSeries Interrupt prologs
49 * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs
50 * 0x6000 - 0x6fff : Initial (CPU0) segment table
51 * 0x7000 - 0x7fff : FWNMI data area
52 * 0x8000 - : Early init and support code
60 * SPRG0 reserved for hypervisor
61 * SPRG1 temp - used to save gpr
62 * SPRG2 temp - used to save gpr
63 * SPRG3 virt addr of paca
67 * Entering into this code we make the following assumptions:
69 * 1. The MMU is off & open firmware is running in real mode.
70 * 2. The kernel is entered at __start
73 * 1. The MMU is on (as it always is for iSeries)
74 * 2. The kernel is entered at system_reset_iSeries
80 #ifdef CONFIG_PPC_MULTIPLATFORM
82 /* NOP this out unconditionally */
84 b .__start_initialization_multiplatform
86 #endif /* CONFIG_PPC_MULTIPLATFORM */
88 /* Catch branch to 0 in real mode */
91 #ifdef CONFIG_PPC_ISERIES
93 * At offset 0x20, there is a pointer to iSeries LPAR data.
94 * This is required by the hypervisor
97 .llong hvReleaseData-KERNELBASE
100 * At offset 0x28 and 0x30 are offsets to the mschunks_map
101 * array (used by the iSeries LPAR debugger to do translation
102 * between physical addresses and absolute addresses) and
103 * to the pidhash table (also used by the debugger)
105 .llong mschunks_map-KERNELBASE
106 .llong 0 /* pidhash-KERNELBASE SFRXXX */
108 /* Offset 0x38 - Pointer to start of embedded System.map */
109 .globl embedded_sysmap_start
110 embedded_sysmap_start:
112 /* Offset 0x40 - Pointer to end of embedded System.map */
113 .globl embedded_sysmap_end
117 #endif /* CONFIG_PPC_ISERIES */
119 /* Secondary processors spin on this value until it goes to 1. */
120 .globl __secondary_hold_spinloop
121 __secondary_hold_spinloop:
124 /* Secondary processors write this value with their cpu # */
125 /* after they enter the spin loop immediately below. */
126 .globl __secondary_hold_acknowledge
127 __secondary_hold_acknowledge:
132 * The following code is used on pSeries to hold secondary processors
133 * in a spin loop after they have been freed from OpenFirmware, but
134 * before the bulk of the kernel has been relocated. This code
135 * is relocated to physical address 0x60 before prom_init is run.
136 * All of it must fit below the first exception vector at 0x100.
138 _GLOBAL(__secondary_hold)
141 mtmsrd r24 /* RI on */
143 /* Grab our linux cpu number */
146 /* Tell the master cpu we're here */
147 /* Relocation is off & we are located at an address less */
148 /* than 0x100, so only need to grab low order offset. */
149 std r24,__secondary_hold_acknowledge@l(0)
152 /* All secondary cpus wait here until told to start. */
153 100: ld r4,__secondary_hold_spinloop@l(0)
162 b .pSeries_secondary_smp_init
168 /* This value is used to mark exception frames on the stack. */
171 .tc ID_72656773_68657265[TC],0x7265677368657265
175 * The following macros define the code that appears as
176 * the prologue to each of the exception handlers. They
177 * are split into two parts to allow a single kernel binary
178 * to be used for pSeries and iSeries.
179 * LOL. One day... - paulus
183 * We make as much of the exception code common between native
184 * exception handlers (including pSeries LPAR) and iSeries LPAR
185 * implementations as possible.
189 * This is the start of the interrupt handlers for pSeries
190 * This code runs with relocation off.
198 #define EX_R3 40 /* SLB miss saves R3, but not SRR0 */
200 #define EX_LR 48 /* SLB miss saves LR, but not DAR */
204 #define EXCEPTION_PROLOG_PSERIES(area, label) \
205 mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \
206 std r9,area+EX_R9(r13); /* save r9 - r12 */ \
207 std r10,area+EX_R10(r13); \
208 std r11,area+EX_R11(r13); \
209 std r12,area+EX_R12(r13); \
210 mfspr r9,SPRN_SPRG1; \
211 std r9,area+EX_R13(r13); \
213 clrrdi r12,r13,32; /* get high part of &label */ \
215 mfspr r11,SPRN_SRR0; /* save SRR0 */ \
216 ori r12,r12,(label)@l; /* virt addr of handler */ \
217 ori r10,r10,MSR_IR|MSR_DR|MSR_RI; \
218 mtspr SPRN_SRR0,r12; \
219 mfspr r12,SPRN_SRR1; /* and SRR1 */ \
220 mtspr SPRN_SRR1,r10; \
222 b . /* prevent speculative execution */
225 * This is the start of the interrupt handlers for iSeries
226 * This code runs with relocation on.
228 #define EXCEPTION_PROLOG_ISERIES_1(area) \
229 mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \
230 std r9,area+EX_R9(r13); /* save r9 - r12 */ \
231 std r10,area+EX_R10(r13); \
232 std r11,area+EX_R11(r13); \
233 std r12,area+EX_R12(r13); \
234 mfspr r9,SPRN_SPRG1; \
235 std r9,area+EX_R13(r13); \
238 #define EXCEPTION_PROLOG_ISERIES_2 \
240 ld r11,PACALPPACA+LPPACASRR0(r13); \
241 ld r12,PACALPPACA+LPPACASRR1(r13); \
242 ori r10,r10,MSR_RI; \
246 * The common exception prolog is used for all except a few exceptions
247 * such as a segment miss on a kernel address. We have to be prepared
248 * to take another exception from the point where we first touch the
249 * kernel stack onwards.
251 * On entry r13 points to the paca, r9-r13 are saved in the paca,
252 * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and
253 * SRR1, and relocation is on.
255 #define EXCEPTION_PROLOG_COMMON(n, area) \
256 andi. r10,r12,MSR_PR; /* See if coming from user */ \
257 mr r10,r1; /* Save r1 */ \
258 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \
260 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \
261 1: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \
262 bge- cr1,bad_stack; /* abort if it is */ \
263 std r9,_CCR(r1); /* save CR in stackframe */ \
264 std r11,_NIP(r1); /* save SRR0 in stackframe */ \
265 std r12,_MSR(r1); /* save SRR1 in stackframe */ \
266 std r10,0(r1); /* make stack chain pointer */ \
267 std r0,GPR0(r1); /* save r0 in stackframe */ \
268 std r10,GPR1(r1); /* save r1 in stackframe */ \
269 std r2,GPR2(r1); /* save r2 in stackframe */ \
270 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \
271 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
272 ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \
273 ld r10,area+EX_R10(r13); \
276 ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \
277 ld r10,area+EX_R12(r13); \
278 ld r11,area+EX_R13(r13); \
282 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \
283 mflr r9; /* save LR in stackframe */ \
285 mfctr r10; /* save CTR in stackframe */ \
287 mfspr r11,SPRN_XER; /* save XER in stackframe */ \
290 std r9,_TRAP(r1); /* set trap number */ \
292 ld r11,exception_marker@toc(r2); \
293 std r10,RESULT(r1); /* clear regs->result */ \
294 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */
299 #define STD_EXCEPTION_PSERIES(n, label) \
301 .globl label##_pSeries; \
304 mtspr SPRN_SPRG1,r13; /* save r13 */ \
306 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
308 #define STD_EXCEPTION_ISERIES(n, label, area) \
309 .globl label##_iSeries; \
312 mtspr SPRN_SPRG1,r13; /* save r13 */ \
314 EXCEPTION_PROLOG_ISERIES_1(area); \
315 EXCEPTION_PROLOG_ISERIES_2; \
318 #define MASKABLE_EXCEPTION_ISERIES(n, label) \
319 .globl label##_iSeries; \
322 mtspr SPRN_SPRG1,r13; /* save r13 */ \
324 EXCEPTION_PROLOG_ISERIES_1(PACA_EXGEN); \
325 lbz r10,PACAPROCENABLED(r13); \
327 beq- label##_iSeries_masked; \
328 EXCEPTION_PROLOG_ISERIES_2; \
331 #ifdef DO_SOFT_DISABLE
332 #define DISABLE_INTS \
333 lbz r10,PACAPROCENABLED(r13); \
337 stb r11,PACAPROCENABLED(r13); \
338 ori r10,r10,MSR_EE; \
341 #define ENABLE_INTS \
342 lbz r10,PACAPROCENABLED(r13); \
345 ori r11,r11,MSR_EE; \
348 #else /* hard enable/disable interrupts */
351 #define ENABLE_INTS \
354 rlwimi r11,r12,0,MSR_EE; \
359 #define STD_EXCEPTION_COMMON(trap, label, hdlr) \
361 .globl label##_common; \
363 EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \
366 addi r3,r1,STACK_FRAME_OVERHEAD; \
370 #define STD_EXCEPTION_COMMON_LITE(trap, label, hdlr) \
372 .globl label##_common; \
374 EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN); \
376 addi r3,r1,STACK_FRAME_OVERHEAD; \
378 b .ret_from_except_lite
381 * Start of pSeries system interrupt routines
384 .globl __start_interrupts
387 STD_EXCEPTION_PSERIES(0x100, system_reset)
390 _machine_check_pSeries:
392 mtspr SPRN_SPRG1,r13 /* save r13 */
394 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
397 .globl data_access_pSeries
406 rlwimi r13,r12,16,0x20
409 beq .do_stab_bolted_pSeries
412 END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
413 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common)
416 .globl data_access_slb_pSeries
417 data_access_slb_pSeries:
421 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
422 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
423 std r10,PACA_EXSLB+EX_R10(r13)
424 std r11,PACA_EXSLB+EX_R11(r13)
425 std r12,PACA_EXSLB+EX_R12(r13)
426 std r3,PACA_EXSLB+EX_R3(r13)
428 std r9,PACA_EXSLB+EX_R13(r13)
430 mfspr r12,SPRN_SRR1 /* and SRR1 */
432 b .do_slb_miss /* Rel. branch works in real mode */
434 STD_EXCEPTION_PSERIES(0x400, instruction_access)
437 .globl instruction_access_slb_pSeries
438 instruction_access_slb_pSeries:
442 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
443 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
444 std r10,PACA_EXSLB+EX_R10(r13)
445 std r11,PACA_EXSLB+EX_R11(r13)
446 std r12,PACA_EXSLB+EX_R12(r13)
447 std r3,PACA_EXSLB+EX_R3(r13)
449 std r9,PACA_EXSLB+EX_R13(r13)
451 mfspr r12,SPRN_SRR1 /* and SRR1 */
452 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
453 b .do_slb_miss /* Rel. branch works in real mode */
455 STD_EXCEPTION_PSERIES(0x500, hardware_interrupt)
456 STD_EXCEPTION_PSERIES(0x600, alignment)
457 STD_EXCEPTION_PSERIES(0x700, program_check)
458 STD_EXCEPTION_PSERIES(0x800, fp_unavailable)
459 STD_EXCEPTION_PSERIES(0x900, decrementer)
460 STD_EXCEPTION_PSERIES(0xa00, trap_0a)
461 STD_EXCEPTION_PSERIES(0xb00, trap_0b)
464 .globl system_call_pSeries
473 oris r12,r12,system_call_common@h
474 ori r12,r12,system_call_common@l
476 ori r10,r10,MSR_IR|MSR_DR|MSR_RI
480 b . /* prevent speculative execution */
482 STD_EXCEPTION_PSERIES(0xd00, single_step)
483 STD_EXCEPTION_PSERIES(0xe00, trap_0e)
485 /* We need to deal with the Altivec unavailable exception
486 * here which is at 0xf20, thus in the middle of the
487 * prolog code of the PerformanceMonitor one. A little
488 * trickery is thus necessary
491 b performance_monitor_pSeries
493 STD_EXCEPTION_PSERIES(0xf20, altivec_unavailable)
495 STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint)
496 STD_EXCEPTION_PSERIES(0x1700, altivec_assist)
500 /*** pSeries interrupt support ***/
502 /* moved from 0xf00 */
503 STD_EXCEPTION_PSERIES(., performance_monitor)
506 _GLOBAL(do_stab_bolted_pSeries)
509 EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted)
512 * Vectors for the FWNMI option. Share common code.
514 .globl system_reset_fwnmi
517 mtspr SPRN_SPRG1,r13 /* save r13 */
519 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common)
521 .globl machine_check_fwnmi
524 mtspr SPRN_SPRG1,r13 /* save r13 */
526 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
528 #ifdef CONFIG_PPC_ISERIES
529 /*** ISeries-LPAR interrupt handlers ***/
531 STD_EXCEPTION_ISERIES(0x200, machine_check, PACA_EXMC)
533 .globl data_access_iSeries
541 rlwimi r13,r12,16,0x20
544 beq .do_stab_bolted_iSeries
547 END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
548 EXCEPTION_PROLOG_ISERIES_1(PACA_EXGEN)
549 EXCEPTION_PROLOG_ISERIES_2
552 .do_stab_bolted_iSeries:
555 EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB)
556 EXCEPTION_PROLOG_ISERIES_2
559 .globl data_access_slb_iSeries
560 data_access_slb_iSeries:
561 mtspr SPRN_SPRG1,r13 /* save r13 */
562 EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB)
563 std r3,PACA_EXSLB+EX_R3(r13)
564 ld r12,PACALPPACA+LPPACASRR1(r13)
568 STD_EXCEPTION_ISERIES(0x400, instruction_access, PACA_EXGEN)
570 .globl instruction_access_slb_iSeries
571 instruction_access_slb_iSeries:
572 mtspr SPRN_SPRG1,r13 /* save r13 */
573 EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB)
574 std r3,PACA_EXSLB+EX_R3(r13)
575 ld r12,PACALPPACA+LPPACASRR1(r13)
576 ld r3,PACALPPACA+LPPACASRR0(r13)
579 MASKABLE_EXCEPTION_ISERIES(0x500, hardware_interrupt)
580 STD_EXCEPTION_ISERIES(0x600, alignment, PACA_EXGEN)
581 STD_EXCEPTION_ISERIES(0x700, program_check, PACA_EXGEN)
582 STD_EXCEPTION_ISERIES(0x800, fp_unavailable, PACA_EXGEN)
583 MASKABLE_EXCEPTION_ISERIES(0x900, decrementer)
584 STD_EXCEPTION_ISERIES(0xa00, trap_0a, PACA_EXGEN)
585 STD_EXCEPTION_ISERIES(0xb00, trap_0b, PACA_EXGEN)
587 .globl system_call_iSeries
591 EXCEPTION_PROLOG_ISERIES_2
594 STD_EXCEPTION_ISERIES( 0xd00, single_step, PACA_EXGEN)
595 STD_EXCEPTION_ISERIES( 0xe00, trap_0e, PACA_EXGEN)
596 STD_EXCEPTION_ISERIES( 0xf00, performance_monitor, PACA_EXGEN)
598 .globl system_reset_iSeries
599 system_reset_iSeries:
600 mfspr r13,SPRN_SPRG3 /* Get paca address */
603 mtmsrd r24 /* RI on */
604 lhz r24,PACAPACAINDEX(r13) /* Get processor # */
605 cmpwi 0,r24,0 /* Are we processor 0? */
606 beq .__start_initialization_iSeries /* Start up the first processor */
608 li r5,CTRL_RUNLATCH /* Turn off the run light */
615 lbz r23,PACAPROCSTART(r13) /* Test if this processor
618 LOADADDR(r3,current_set)
619 sldi r28,r24,3 /* get current_set[cpu#] */
621 addi r1,r3,THREAD_SIZE
622 subi r1,r1,STACK_FRAME_OVERHEAD
625 beq iSeries_secondary_smp_loop /* Loop until told to go */
626 bne .__secondary_start /* Loop until told to go */
627 iSeries_secondary_smp_loop:
628 /* Let the Hypervisor know we are alive */
629 /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
631 rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */
632 #else /* CONFIG_SMP */
633 /* Yield the processor. This is required for non-SMP kernels
634 which are running on multi-threaded machines. */
636 rldicr r3,r3,32,15 /* r3 = (r3 << 32) & 0xffff000000000000 */
637 addi r3,r3,18 /* r3 = 0x8000000000000012 which is "yield" */
638 li r4,0 /* "yield timed" */
639 li r5,-1 /* "yield forever" */
640 #endif /* CONFIG_SMP */
641 li r0,-1 /* r0=-1 indicates a Hypervisor call */
642 sc /* Invoke the hypervisor via a system call */
643 mfspr r13,SPRN_SPRG3 /* Put r13 back ???? */
644 b 1b /* If SMP not configured, secondaries
647 .globl decrementer_iSeries_masked
648 decrementer_iSeries_masked:
650 stb r11,PACALPPACA+LPPACADECRINT(r13)
651 lwz r12,PACADEFAULTDECR(r13)
655 .globl hardware_interrupt_iSeries_masked
656 hardware_interrupt_iSeries_masked:
657 mtcrf 0x80,r9 /* Restore regs */
658 ld r11,PACALPPACA+LPPACASRR0(r13)
659 ld r12,PACALPPACA+LPPACASRR1(r13)
662 ld r9,PACA_EXGEN+EX_R9(r13)
663 ld r10,PACA_EXGEN+EX_R10(r13)
664 ld r11,PACA_EXGEN+EX_R11(r13)
665 ld r12,PACA_EXGEN+EX_R12(r13)
666 ld r13,PACA_EXGEN+EX_R13(r13)
668 b . /* prevent speculative execution */
669 #endif /* CONFIG_PPC_ISERIES */
671 /*** Common interrupt handlers ***/
673 STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
676 * Machine check is different because we use a different
677 * save area: PACA_EXMC instead of PACA_EXGEN.
680 .globl machine_check_common
681 machine_check_common:
682 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
685 addi r3,r1,STACK_FRAME_OVERHEAD
686 bl .machine_check_exception
689 STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt)
690 STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception)
691 STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
692 STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
693 STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
694 STD_EXCEPTION_COMMON(0xf00, performance_monitor, .performance_monitor_exception)
695 STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
696 #ifdef CONFIG_ALTIVEC
697 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
699 STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
703 * Here we have detected that the kernel stack pointer is bad.
704 * R9 contains the saved CR, r13 points to the paca,
705 * r10 contains the (bad) kernel stack pointer,
706 * r11 and r12 contain the saved SRR0 and SRR1.
707 * We switch to using an emergency stack, save the registers there,
708 * and call kernel_bad_stack(), which panics.
711 ld r1,PACAEMERGSP(r13)
712 subi r1,r1,64+INT_FRAME_SIZE
733 addi r11,r1,INT_FRAME_SIZE
738 1: addi r3,r1,STACK_FRAME_OVERHEAD
743 * Return from an exception with minimal checks.
744 * The caller is assumed to have done EXCEPTION_PROLOG_COMMON.
745 * If interrupts have been enabled, or anything has been
746 * done that might have changed the scheduling status of
747 * any task or sent any task a signal, you should use
748 * ret_from_except or ret_from_except_lite instead of this.
750 .globl fast_exception_return
751 fast_exception_return:
754 andi. r3,r12,MSR_RI /* check if RI is set */
768 clrrdi r10,r10,2 /* clear RI (LE is 0 already) */
776 b . /* prevent speculative execution */
780 1: addi r3,r1,STACK_FRAME_OVERHEAD
781 bl .unrecoverable_exception
785 * Here r13 points to the paca, r9 contains the saved CR,
786 * SRR0 and SRR1 are saved in r11 and r12,
787 * r9 - r13 are saved in paca->exgen.
790 .globl data_access_common
792 RUNLATCH_ON(r10) /* It wont fit in the 0x300 handler */
794 std r10,PACA_EXGEN+EX_DAR(r13)
796 stw r10,PACA_EXGEN+EX_DSISR(r13)
797 EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
798 ld r3,PACA_EXGEN+EX_DAR(r13)
799 lwz r4,PACA_EXGEN+EX_DSISR(r13)
801 b .do_hash_page /* Try to handle as hpte fault */
804 .globl instruction_access_common
805 instruction_access_common:
806 EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
810 b .do_hash_page /* Try to handle as hpte fault */
813 .globl hardware_interrupt_common
814 .globl hardware_interrupt_entry
815 hardware_interrupt_common:
816 EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN)
817 hardware_interrupt_entry:
819 addi r3,r1,STACK_FRAME_OVERHEAD
821 b .ret_from_except_lite
824 .globl alignment_common
827 std r10,PACA_EXGEN+EX_DAR(r13)
829 stw r10,PACA_EXGEN+EX_DSISR(r13)
830 EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
831 ld r3,PACA_EXGEN+EX_DAR(r13)
832 lwz r4,PACA_EXGEN+EX_DSISR(r13)
836 addi r3,r1,STACK_FRAME_OVERHEAD
838 bl .alignment_exception
842 .globl program_check_common
843 program_check_common:
844 EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
846 addi r3,r1,STACK_FRAME_OVERHEAD
848 bl .program_check_exception
852 .globl fp_unavailable_common
853 fp_unavailable_common:
854 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
855 bne .load_up_fpu /* if from user, just load it up */
857 addi r3,r1,STACK_FRAME_OVERHEAD
859 bl .kernel_fp_unavailable_exception
863 .globl altivec_unavailable_common
864 altivec_unavailable_common:
865 EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
866 #ifdef CONFIG_ALTIVEC
868 bne .load_up_altivec /* if from user, just load it up */
869 END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
872 addi r3,r1,STACK_FRAME_OVERHEAD
874 bl .altivec_unavailable_exception
877 #ifdef CONFIG_ALTIVEC
879 * load_up_altivec(unused, unused, tsk)
880 * Disable VMX for the task which had it previously,
881 * and save its vector registers in its thread_struct.
882 * Enables the VMX for use in the kernel on return.
883 * On SMP we know the VMX is free, since we give it up every
884 * switch (ie, no lazy save of the vector registers).
885 * On entry: r13 == 'current' && last_task_used_altivec != 'current'
887 _STATIC(load_up_altivec)
888 mfmsr r5 /* grab the current MSR */
890 mtmsrd r5 /* enable use of VMX now */
894 * For SMP, we don't do lazy VMX switching because it just gets too
895 * horrendously complex, especially when a task switches from one CPU
896 * to another. Instead we call giveup_altvec in switch_to.
897 * VRSAVE isn't dealt with here, that is done in the normal context
898 * switch code. Note that we could rely on vrsave value to eventually
899 * avoid saving all of the VREGs here...
902 ld r3,last_task_used_altivec@got(r2)
906 /* Save VMX state to last_task_used_altivec's THREAD struct */
912 /* Disable VMX for last_task_used_altivec */
914 ld r4,_MSR-STACK_FRAME_OVERHEAD(r5)
917 std r4,_MSR-STACK_FRAME_OVERHEAD(r5)
919 #endif /* CONFIG_SMP */
920 /* Hack: if we get an altivec unavailable trap with VRSAVE
921 * set to all zeros, we assume this is a broken application
922 * that fails to set it properly, and thus we switch it to
931 /* enable use of VMX after return */
932 ld r4,PACACURRENT(r13)
933 addi r5,r4,THREAD /* Get THREAD */
934 oris r12,r12,MSR_VEC@h
938 stw r4,THREAD_USED_VR(r5)
943 /* Update last_task_used_math to 'current' */
944 subi r4,r5,THREAD /* Back to 'current' */
946 #endif /* CONFIG_SMP */
947 /* restore registers and return */
948 b fast_exception_return
949 #endif /* CONFIG_ALTIVEC */
955 _GLOBAL(do_hash_page)
959 andis. r0,r4,0xa450 /* weird error? */
960 bne- .handle_page_fault /* if not, try to insert a HPTE */
962 andis. r0,r4,0x0020 /* Is it a segment table fault? */
963 bne- .do_ste_alloc /* If so handle it */
964 END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
967 * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
968 * accessing a userspace segment (even from the kernel). We assume
969 * kernel addresses always have the high bit set.
971 rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
972 rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
973 orc r0,r12,r0 /* MSR_PR | ~high_bit */
974 rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
975 ori r4,r4,1 /* add _PAGE_PRESENT */
976 rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
979 * On iSeries, we soft-disable interrupts here, then
980 * hard-enable interrupts so that the hash_page code can spin on
981 * the hash_table_lock without problems on a shared processor.
986 * r3 contains the faulting address
987 * r4 contains the required access permissions
988 * r5 contains the trap number
990 * at return r3 = 0 for success
992 bl .hash_page /* build HPTE if possible */
993 cmpdi r3,0 /* see if hash_page succeeded */
995 #ifdef DO_SOFT_DISABLE
997 * If we had interrupts soft-enabled at the point where the
998 * DSI/ISI occurred, and an interrupt came in during hash_page,
1000 * We jump to ret_from_except_lite rather than fast_exception_return
1001 * because ret_from_except_lite will check for and handle pending
1002 * interrupts if necessary.
1004 beq .ret_from_except_lite
1005 /* For a hash failure, we don't bother re-enabling interrupts */
1009 * hash_page couldn't handle it, set soft interrupt enable back
1010 * to what it was before the trap. Note that .local_irq_restore
1011 * handles any interrupts pending at this point.
1014 bl .local_irq_restore
1017 beq fast_exception_return /* Return from exception on success */
1018 ble- 12f /* Failure return from hash_page */
1023 /* Here we have a page fault that hash_page can't handle. */
1024 _GLOBAL(handle_page_fault)
1028 addi r3,r1,STACK_FRAME_OVERHEAD
1031 beq+ .ret_from_except_lite
1034 addi r3,r1,STACK_FRAME_OVERHEAD
1039 /* We have a page fault that hash_page could handle but HV refused
1043 addi r3,r1,STACK_FRAME_OVERHEAD
1048 /* here we have a segment miss */
1049 _GLOBAL(do_ste_alloc)
1050 bl .ste_allocate /* try to insert stab entry */
1052 beq+ fast_exception_return
1053 b .handle_page_fault
1056 * r13 points to the PACA, r9 contains the saved CR,
1057 * r11 and r12 contain the saved SRR0 and SRR1.
1058 * r9 - r13 are saved in paca->exslb.
1059 * We assume we aren't going to take any exceptions during this procedure.
1060 * We assume (DAR >> 60) == 0xc.
1063 _GLOBAL(do_stab_bolted)
1064 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
1065 std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
1067 /* Hash to the primary group */
1068 ld r10,PACASTABVIRT(r13)
1071 rldimi r10,r11,7,52 /* r10 = first ste of the group */
1073 /* Calculate VSID */
1074 /* This is a kernel address, so protovsid = ESID */
1075 ASM_VSID_SCRAMBLE(r11, r9)
1076 rldic r9,r11,12,16 /* r9 = vsid << 12 */
1078 /* Search the primary group for a free entry */
1079 1: ld r11,0(r10) /* Test valid bit of the current ste */
1086 /* Stick for only searching the primary group for now. */
1087 /* At least for now, we use a very simple random castout scheme */
1088 /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
1090 rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
1093 /* r10 currently points to an ste one past the group of interest */
1094 /* make it point to the randomly selected entry */
1096 or r10,r10,r11 /* r10 is the entry to invalidate */
1098 isync /* mark the entry invalid */
1100 rldicl r11,r11,56,1 /* clear the valid bit */
1105 clrrdi r11,r11,28 /* Get the esid part of the ste */
1108 2: std r9,8(r10) /* Store the vsid part of the ste */
1111 mfspr r11,SPRN_DAR /* Get the new esid */
1112 clrrdi r11,r11,28 /* Permits a full 32b of ESID */
1113 ori r11,r11,0x90 /* Turn on valid and kp */
1114 std r11,0(r10) /* Put new entry back into the stab */
1118 /* All done -- return from exception. */
1119 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
1120 ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
1122 andi. r10,r12,MSR_RI
1125 mtcrf 0x80,r9 /* restore CR */
1133 ld r9,PACA_EXSLB+EX_R9(r13)
1134 ld r10,PACA_EXSLB+EX_R10(r13)
1135 ld r11,PACA_EXSLB+EX_R11(r13)
1136 ld r12,PACA_EXSLB+EX_R12(r13)
1137 ld r13,PACA_EXSLB+EX_R13(r13)
1139 b . /* prevent speculative execution */
1142 * r13 points to the PACA, r9 contains the saved CR,
1143 * r11 and r12 contain the saved SRR0 and SRR1.
1144 * r3 has the faulting address
1145 * r9 - r13 are saved in paca->exslb.
1146 * r3 is saved in paca->slb_r3
1147 * We assume we aren't going to take any exceptions during this procedure.
1149 _GLOBAL(do_slb_miss)
1152 stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
1153 std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
1155 bl .slb_allocate /* handle it */
1157 /* All done -- return from exception. */
1159 ld r10,PACA_EXSLB+EX_LR(r13)
1160 ld r3,PACA_EXSLB+EX_R3(r13)
1161 lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
1162 #ifdef CONFIG_PPC_ISERIES
1163 ld r11,PACALPPACA+LPPACASRR0(r13) /* get SRR0 value */
1164 #endif /* CONFIG_PPC_ISERIES */
1168 andi. r10,r12,MSR_RI /* check for unrecoverable exception */
1174 mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
1177 #ifdef CONFIG_PPC_ISERIES
1180 #endif /* CONFIG_PPC_ISERIES */
1181 ld r9,PACA_EXSLB+EX_R9(r13)
1182 ld r10,PACA_EXSLB+EX_R10(r13)
1183 ld r11,PACA_EXSLB+EX_R11(r13)
1184 ld r12,PACA_EXSLB+EX_R12(r13)
1185 ld r13,PACA_EXSLB+EX_R13(r13)
1187 b . /* prevent speculative execution */
1190 EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
1193 1: addi r3,r1,STACK_FRAME_OVERHEAD
1194 bl .unrecoverable_exception
1198 * Space for CPU0's segment table.
1200 * On iSeries, the hypervisor must fill in at least one entry before
1201 * we get control (with relocate on). The address is give to the hv
1202 * as a page number (see xLparMap in lpardata.c), so this must be at a
1203 * fixed address (the linker can't compute (u64)&initial_stab >>
1206 . = STAB0_PHYS_ADDR /* 0x6000 */
1212 * Data area reserved for FWNMI option.
1213 * This address (0x7000) is fixed by the RPA.
1216 .globl fwnmi_data_area
1219 /* iSeries does not use the FWNMI stuff, so it is safe to put
1220 * this here, even if we later allow kernels that will boot on
1221 * both pSeries and iSeries */
1222 #ifdef CONFIG_PPC_ISERIES
1224 #include "lparmap.s"
1226 * This ".text" is here for old compilers that generate a trailing
1227 * .note section when compiling .c files to .s
1230 #endif /* CONFIG_PPC_ISERIES */
1235 * On pSeries, secondary processors spin in the following code.
1236 * At entry, r3 = this processor's number (physical cpu id)
1238 _GLOBAL(pSeries_secondary_smp_init)
1241 /* turn on 64-bit mode */
1245 /* Copy some CPU settings from CPU 0 */
1246 bl .__restore_cpu_setup
1248 /* Set up a paca value for this processor. Since we have the
1249 * physical cpu id in r24, we need to search the pacas to find
1250 * which logical id maps to our physical one.
1252 LOADADDR(r13, paca) /* Get base vaddr of paca array */
1253 li r5,0 /* logical cpu id */
1254 1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */
1255 cmpw r6,r24 /* Compare to our id */
1257 addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */
1262 mr r3,r24 /* not found, copy phys to r3 */
1263 b .kexec_wait /* next kernel might do better */
1265 2: mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
1266 /* From now on, r24 is expected to be logical cpuid */
1269 lbz r23,PACAPROCSTART(r13) /* Test if this processor should */
1273 /* Create a temp kernel stack for use before relocation is on. */
1274 ld r1,PACAEMERGSP(r13)
1275 subi r1,r1,STACK_FRAME_OVERHEAD
1279 bne .__secondary_start
1281 b 3b /* Loop until told to go */
1283 #ifdef CONFIG_PPC_ISERIES
1284 _STATIC(__start_initialization_iSeries)
1285 /* Clear out the BSS */
1286 LOADADDR(r11,__bss_stop)
1287 LOADADDR(r8,__bss_start)
1288 sub r11,r11,r8 /* bss size */
1289 addi r11,r11,7 /* round up to an even double word */
1290 rldicl. r11,r11,61,3 /* shift right by 3 */
1294 mtctr r11 /* zero this many doublewords */
1298 LOADADDR(r1,init_thread_union)
1299 addi r1,r1,THREAD_SIZE
1301 stdu r0,-STACK_FRAME_OVERHEAD(r1)
1303 LOADADDR(r3,cpu_specs)
1304 LOADADDR(r4,cur_cpu_spec)
1308 LOADADDR(r2,__toc_start)
1312 bl .iSeries_early_setup
1315 /* relocation is on at this point */
1317 b .start_here_common
1318 #endif /* CONFIG_PPC_ISERIES */
1320 #ifdef CONFIG_PPC_MULTIPLATFORM
1324 andi. r0,r3,MSR_IR|MSR_DR
1331 b . /* prevent speculative execution */
1335 * Here is our main kernel entry point. We support currently 2 kind of entries
1336 * depending on the value of r5.
1338 * r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content
1341 * r5 == NULL -> kexec style entry. r3 is a physical pointer to the
1342 * DT block, r4 is a physical pointer to the kernel itself
1345 _GLOBAL(__start_initialization_multiplatform)
1347 * Are we booted from a PROM Of-type client-interface ?
1350 bne .__boot_from_prom /* yes -> prom */
1352 /* Save parameters */
1356 /* Make sure we are running in 64 bits mode */
1359 /* Setup some critical 970 SPRs before switching MMU off */
1360 bl .__970_cpu_preinit
1365 /* Switch off MMU if not already */
1366 LOADADDR(r4, .__after_prom_start - KERNELBASE)
1369 b .__after_prom_start
1371 _STATIC(__boot_from_prom)
1372 /* Save parameters */
1379 /* Make sure we are running in 64 bits mode */
1382 /* put a relocation offset into r3 */
1385 LOADADDR(r2,__toc_start)
1389 /* Relocate the TOC from a virt addr to a real addr */
1392 /* Restore parameters */
1399 /* Do all of the interaction with OF client interface */
1401 /* We never return */
1405 * At this point, r3 contains the physical address we are running at,
1406 * returned by prom_init()
1408 _STATIC(__after_prom_start)
1411 * We need to run with __start at physical address 0.
1412 * This will leave some code in the first 256B of
1413 * real memory, which are reserved for software use.
1414 * The remainder of the first page is loaded with the fixed
1415 * interrupt vectors. The next two pages are filled with
1416 * unknown exception placeholders.
1418 * Note: This process overwrites the OF exception vectors.
1419 * r26 == relocation offset
1424 SET_REG_TO_CONST(r27,KERNELBASE)
1426 li r3,0 /* target addr */
1428 // XXX FIXME: Use phys returned by OF (r30)
1429 add r4,r27,r26 /* source addr */
1430 /* current address of _start */
1431 /* i.e. where we are running */
1432 /* the source addr */
1434 LOADADDR(r5,copy_to_here) /* # bytes of memory to copy */
1437 li r6,0x100 /* Start offset, the first 0x100 */
1438 /* bytes were copied earlier. */
1440 bl .copy_and_flush /* copy the first n bytes */
1441 /* this includes the code being */
1442 /* executed here. */
1444 LOADADDR(r0, 4f) /* Jump to the copy of this code */
1445 mtctr r0 /* that we just made/relocated */
1448 4: LOADADDR(r5,klimit)
1450 ld r5,0(r5) /* get the value of klimit */
1452 bl .copy_and_flush /* copy the rest */
1453 b .start_here_multiplatform
1455 #endif /* CONFIG_PPC_MULTIPLATFORM */
1458 * Copy routine used to copy the kernel to start at physical address 0
1459 * and flush and invalidate the caches as needed.
1460 * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset
1461 * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5.
1463 * Note: this routine *only* clobbers r0, r6 and lr
1465 _GLOBAL(copy_and_flush)
1468 4: li r0,16 /* Use the least common */
1469 /* denominator cache line */
1470 /* size. This results in */
1471 /* extra cache line flushes */
1472 /* but operation is correct. */
1473 /* Can't get cache line size */
1474 /* from NACA as it is being */
1477 mtctr r0 /* put # words/line in ctr */
1478 3: addi r6,r6,8 /* copy a cache line */
1482 dcbst r6,r3 /* write it to memory */
1484 icbi r6,r3 /* flush the icache line */
1496 #ifdef CONFIG_PPC_PMAC
1498 * On PowerMac, secondary processors starts from the reset vector, which
1499 * is temporarily turned into a call to one of the functions below.
1504 .globl __secondary_start_pmac_0
1505 __secondary_start_pmac_0:
1506 /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */
1516 _GLOBAL(pmac_secondary_start)
1517 /* turn on 64-bit mode */
1521 /* Copy some CPU settings from CPU 0 */
1522 bl .__restore_cpu_setup
1524 /* pSeries do that early though I don't think we really need it */
1527 mtmsrd r3 /* RI on */
1529 /* Set up a paca value for this processor. */
1530 LOADADDR(r4, paca) /* Get base vaddr of paca array */
1531 mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */
1532 add r13,r13,r4 /* for this processor. */
1533 mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
1535 /* Create a temp kernel stack for use before relocation is on. */
1536 ld r1,PACAEMERGSP(r13)
1537 subi r1,r1,STACK_FRAME_OVERHEAD
1539 b .__secondary_start
1541 #endif /* CONFIG_PPC_PMAC */
1544 * This function is called after the master CPU has released the
1545 * secondary processors. The execution environment is relocation off.
1546 * The paca for this processor has the following fields initialized at
1548 * 1. Processor number
1549 * 2. Segment table pointer (virtual address)
1550 * On entry the following are set:
1551 * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries
1552 * r24 = cpu# (in Linux terms)
1553 * r13 = paca virtual address
1554 * SPRG3 = paca virtual address
1556 _GLOBAL(__secondary_start)
1558 HMT_MEDIUM /* Set thread priority to MEDIUM */
1562 stb r6,PACAPROCENABLED(r13)
1564 #ifndef CONFIG_PPC_ISERIES
1565 /* Initialize the page table pointer register. */
1567 ld r6,0(r6) /* get the value of _SDR1 */
1568 mtspr SPRN_SDR1,r6 /* set the htab location */
1570 /* Initialize the first segment table (or SLB) entry */
1571 ld r3,PACASTABVIRT(r13) /* get addr of segment table */
1574 /* Initialize the kernel stack. Just a repeat for iSeries. */
1575 LOADADDR(r3,current_set)
1576 sldi r28,r24,3 /* get current_set[cpu#] */
1578 addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
1579 std r1,PACAKSAVE(r13)
1581 ld r3,PACASTABREAL(r13) /* get raddr of segment table */
1582 ori r4,r3,1 /* turn on valid bit */
1584 #ifdef CONFIG_PPC_ISERIES
1585 li r0,-1 /* hypervisor call */
1587 sldi r3,r3,63 /* 0x8000000000000000 */
1588 ori r3,r3,4 /* 0x8000000000000004 */
1589 sc /* HvCall_setASR */
1592 ld r3,systemcfg@got(r2) /* r3 = ptr to systemcfg */
1594 lwz r3,PLATFORM(r3) /* r3 = platform flags */
1595 andi. r3,r3,PLATFORM_LPAR /* Test if bit 0 is set (LPAR bit) */
1596 beq 98f /* branch if result is 0 */
1599 cmpwi r3,0x37 /* SStar */
1601 cmpwi r3,0x36 /* IStar */
1603 cmpwi r3,0x34 /* Pulsar */
1605 97: li r3,H_SET_ASR /* hcall = H_SET_ASR */
1606 HVSC /* Invoking hcall */
1608 98: /* !(rpa hypervisor) || !(star) */
1609 mtasr r4 /* set the stab location */
1615 /* enable MMU and jump to start_secondary */
1616 LOADADDR(r3,.start_secondary_prolog)
1617 SET_REG_TO_CONST(r4, MSR_KERNEL)
1618 #ifdef DO_SOFT_DISABLE
1624 b . /* prevent speculative execution */
1627 * Running with relocation on at this point. All we want to do is
1628 * zero the stack back-chain pointer before going into C code.
1630 _GLOBAL(start_secondary_prolog)
1632 std r3,0(r1) /* Zero the stack frame pointer */
1637 * This subroutine clobbers r11 and r12
1639 _GLOBAL(enable_64b_mode)
1640 mfmsr r11 /* grab the current MSR */
1642 rldicr r12,r12,MSR_SF_LG,(63-MSR_SF_LG)
1645 rldicr r12,r12,MSR_ISF_LG,(63-MSR_ISF_LG)
1651 #ifdef CONFIG_PPC_MULTIPLATFORM
1653 * This is where the main kernel code starts.
1655 _STATIC(start_here_multiplatform)
1656 /* get a new offset, now that the kernel has moved. */
1660 /* Clear out the BSS. It may have been done in prom_init,
1661 * already but that's irrelevant since prom_init will soon
1662 * be detached from the kernel completely. Besides, we need
1663 * to clear it now for kexec-style entry.
1665 LOADADDR(r11,__bss_stop)
1666 LOADADDR(r8,__bss_start)
1667 sub r11,r11,r8 /* bss size */
1668 addi r11,r11,7 /* round up to an even double word */
1669 rldicl. r11,r11,61,3 /* shift right by 3 */
1673 mtctr r11 /* zero this many doublewords */
1680 mtmsrd r6 /* RI on */
1683 /* Start up the second thread on cpu 0 */
1686 cmpwi r3,0x34 /* Pulsar */
1688 cmpwi r3,0x36 /* Icestar */
1690 cmpwi r3,0x37 /* SStar */
1692 b 91f /* HMT not supported */
1694 bl .hmt_start_secondary
1698 /* The following gets the stack and TOC set up with the regs */
1699 /* pointing to the real addr of the kernel stack. This is */
1700 /* all done to support the C function call below which sets */
1701 /* up the htab. This is done because we have relocated the */
1702 /* kernel but are still running in real mode. */
1704 LOADADDR(r3,init_thread_union)
1707 /* set up a stack pointer (physical address) */
1708 addi r1,r3,THREAD_SIZE
1710 stdu r0,-STACK_FRAME_OVERHEAD(r1)
1712 /* set up the TOC (physical address) */
1713 LOADADDR(r2,__toc_start)
1718 LOADADDR(r3,cpu_specs)
1720 LOADADDR(r4,cur_cpu_spec)
1725 /* Save some low level config HIDs of CPU0 to be copied to
1726 * other CPUs later on, or used for suspend/resume
1728 bl .__save_cpu_setup
1731 /* Setup a valid physical PACA pointer in SPRG3 for early_setup
1732 * note that boot_cpuid can always be 0 nowadays since there is
1733 * nowhere it can be initialized differently before we reach this
1736 LOADADDR(r27, boot_cpuid)
1740 LOADADDR(r24, paca) /* Get base vaddr of paca array */
1741 mulli r13,r27,PACA_SIZE /* Calculate vaddr of right paca */
1742 add r13,r13,r24 /* for this processor. */
1743 add r13,r13,r26 /* convert to physical addr */
1744 mtspr SPRN_SPRG3,r13 /* PPPBBB: Temp... -Peter */
1746 /* Do very early kernel initializations, including initial hash table,
1747 * stab and slb setup before we turn on relocation. */
1749 /* Restore parameters passed from prom_init/kexec */
1754 ld r3,PACASTABREAL(r13)
1755 ori r4,r3,1 /* turn on valid bit */
1756 ld r3,systemcfg@got(r2) /* r3 = ptr to systemcfg */
1758 lwz r3,PLATFORM(r3) /* r3 = platform flags */
1759 andi. r3,r3,PLATFORM_LPAR /* Test if bit 0 is set (LPAR bit) */
1760 beq 98f /* branch if result is 0 */
1763 cmpwi r3,0x37 /* SStar */
1765 cmpwi r3,0x36 /* IStar */
1767 cmpwi r3,0x34 /* Pulsar */
1769 97: li r3,H_SET_ASR /* hcall = H_SET_ASR */
1770 HVSC /* Invoking hcall */
1772 98: /* !(rpa hypervisor) || !(star) */
1773 mtasr r4 /* set the stab location */
1775 /* Set SDR1 (hash table pointer) */
1776 ld r3,systemcfg@got(r2) /* r3 = ptr to systemcfg */
1778 lwz r3,PLATFORM(r3) /* r3 = platform flags */
1779 /* Test if bit 0 is set (LPAR bit) */
1780 andi. r3,r3,PLATFORM_LPAR
1781 bne 98f /* branch if result is !0 */
1782 LOADADDR(r6,_SDR1) /* Only if NOT LPAR */
1784 ld r6,0(r6) /* get the value of _SDR1 */
1785 mtspr SPRN_SDR1,r6 /* set the htab location */
1787 LOADADDR(r3,.start_here_common)
1788 SET_REG_TO_CONST(r4, MSR_KERNEL)
1792 b . /* prevent speculative execution */
1793 #endif /* CONFIG_PPC_MULTIPLATFORM */
1795 /* This is where all platforms converge execution */
1796 _STATIC(start_here_common)
1797 /* relocation is on at this point */
1799 /* The following code sets up the SP and TOC now that we are */
1800 /* running with translation enabled. */
1802 LOADADDR(r3,init_thread_union)
1804 /* set up the stack */
1805 addi r1,r3,THREAD_SIZE
1807 stdu r0,-STACK_FRAME_OVERHEAD(r1)
1809 /* Apply the CPUs-specific fixups (nop out sections not relevant
1813 bl .do_cpu_ftr_fixups
1815 LOADADDR(r26, boot_cpuid)
1818 LOADADDR(r24, paca) /* Get base vaddr of paca array */
1819 mulli r13,r26,PACA_SIZE /* Calculate vaddr of right paca */
1820 add r13,r13,r24 /* for this processor. */
1821 mtspr SPRN_SPRG3,r13
1823 /* ptr to current */
1824 LOADADDR(r4,init_task)
1825 std r4,PACACURRENT(r13)
1829 std r1,PACAKSAVE(r13)
1833 /* Load up the kernel context */
1835 #ifdef DO_SOFT_DISABLE
1837 stb r5,PACAPROCENABLED(r13) /* Soft Disabled */
1839 ori r5,r5,MSR_EE /* Hard Enabled */
1847 LOADADDR(r5, hmt_thread_data)
1850 cmpwi r7,0x34 /* Pulsar */
1852 cmpwi r7,0x36 /* Icestar */
1854 cmpwi r7,0x37 /* SStar */
1857 90: mfspr r6,SPRN_PIR
1860 91: mfspr r6,SPRN_PIR
1864 bl .hmt_start_secondary
1867 __hmt_secondary_hold:
1868 LOADADDR(r5, hmt_thread_data)
1878 93: andi. r6,r6,0x3f
1892 b .pSeries_secondary_smp_init
1895 _GLOBAL(hmt_start_secondary)
1896 LOADADDR(r4,__hmt_secondary_hold)
1898 mtspr SPRN_NIADORM, r4
1899 mfspr r4, SPRN_MSRDORM
1902 mtspr SPRN_MSRDORM, r4
1911 mfspr r4, SPRN_CTRLF
1913 mtspr SPRN_CTRLT, r4
1918 * We put a few things here that have to be page-aligned.
1919 * This stuff goes at the beginning of the bss, which is page-aligned.
1925 .globl empty_zero_page
1929 .globl swapper_pg_dir
1934 * This space gets a copy of optional info passed to us by the bootstrap
1935 * Used to pass parameters into the kernel like root=/dev/sda1, etc.
1939 .space COMMAND_LINE_SIZE