2 * Low level routines for legacy iSeries support.
4 * Extracted from head_64.S
7 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
9 * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
10 * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
11 * Adapted for Power Macintosh by Paul Mackerras.
12 * Low-level exception handlers and MMU support
13 * rewritten by Paul Mackerras.
14 * Copyright (C) 1996 Paul Mackerras.
16 * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
17 * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
19 * This file contains the low-level support and setup for the
20 * PowerPC-64 platform, including trap and interrupt dispatch.
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * as published by the Free Software Foundation; either version
25 * 2 of the License, or (at your option) any later version.
29 #include <asm/ppc_asm.h>
30 #include <asm/asm-offsets.h>
31 #include <asm/thread_info.h>
32 #include <asm/ptrace.h>
33 #include <asm/cputable.h>
35 #include "exception.h"
39 .globl system_reset_iSeries
41 mfspr r13,SPRN_SPRG3 /* Get paca address */
44 mtmsrd r24 /* RI on */
45 lhz r24,PACAPACAINDEX(r13) /* Get processor # */
46 cmpwi 0,r24,0 /* Are we processor 0? */
48 b .__start_initialization_iSeries /* Start up the first processor */
49 1: mfspr r4,SPRN_CTRLF
50 li r5,CTRL_RUNLATCH /* Turn off the run light */
57 lbz r23,PACAPROCSTART(r13) /* Test if this processor
60 LOAD_REG_IMMEDIATE(r3,current_set)
61 sldi r28,r24,3 /* get current_set[cpu#] */
63 addi r1,r3,THREAD_SIZE
64 subi r1,r1,STACK_FRAME_OVERHEAD
67 beq iSeries_secondary_smp_loop /* Loop until told to go */
68 b __secondary_start /* Loop until told to go */
69 iSeries_secondary_smp_loop:
70 /* Let the Hypervisor know we are alive */
71 /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
73 rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */
74 #else /* CONFIG_SMP */
75 /* Yield the processor. This is required for non-SMP kernels
76 which are running on multi-threaded machines. */
78 rldicr r3,r3,32,15 /* r3 = (r3 << 32) & 0xffff000000000000 */
79 addi r3,r3,18 /* r3 = 0x8000000000000012 which is "yield" */
80 li r4,0 /* "yield timed" */
81 li r5,-1 /* "yield forever" */
82 #endif /* CONFIG_SMP */
83 li r0,-1 /* r0=-1 indicates a Hypervisor call */
84 sc /* Invoke the hypervisor via a system call */
85 mfspr r13,SPRN_SPRG3 /* Put r13 back ???? */
86 b 1b /* If SMP not configured, secondaries
89 /*** ISeries-LPAR interrupt handlers ***/
91 STD_EXCEPTION_ISERIES(machine_check, PACA_EXMC)
93 .globl data_access_iSeries
101 rlwimi r13,r12,16,0x20
104 beq .do_stab_bolted_iSeries
107 END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
108 EXCEPTION_PROLOG_1(PACA_EXGEN)
109 EXCEPTION_PROLOG_ISERIES_1
112 .do_stab_bolted_iSeries:
115 EXCEPTION_PROLOG_1(PACA_EXSLB)
116 EXCEPTION_PROLOG_ISERIES_1
119 .globl data_access_slb_iSeries
120 data_access_slb_iSeries:
121 mtspr SPRN_SPRG1,r13 /* save r13 */
122 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
123 std r3,PACA_EXSLB+EX_R3(r13)
125 std r9,PACA_EXSLB+EX_R9(r13)
129 bge slb_miss_user_iseries
131 std r10,PACA_EXSLB+EX_R10(r13)
132 std r11,PACA_EXSLB+EX_R11(r13)
133 std r12,PACA_EXSLB+EX_R12(r13)
135 std r10,PACA_EXSLB+EX_R13(r13)
136 ld r12,PACALPPACAPTR(r13)
137 ld r12,LPPACASRR1(r12)
140 STD_EXCEPTION_ISERIES(instruction_access, PACA_EXGEN)
142 .globl instruction_access_slb_iSeries
143 instruction_access_slb_iSeries:
144 mtspr SPRN_SPRG1,r13 /* save r13 */
145 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
146 std r3,PACA_EXSLB+EX_R3(r13)
147 ld r3,PACALPPACAPTR(r13)
148 ld r3,LPPACASRR0(r3) /* get SRR0 value */
149 std r9,PACA_EXSLB+EX_R9(r13)
153 bge slb_miss_user_iseries
155 std r10,PACA_EXSLB+EX_R10(r13)
156 std r11,PACA_EXSLB+EX_R11(r13)
157 std r12,PACA_EXSLB+EX_R12(r13)
159 std r10,PACA_EXSLB+EX_R13(r13)
160 ld r12,PACALPPACAPTR(r13)
161 ld r12,LPPACASRR1(r12)
165 slb_miss_user_iseries:
166 std r10,PACA_EXGEN+EX_R10(r13)
167 std r11,PACA_EXGEN+EX_R11(r13)
168 std r12,PACA_EXGEN+EX_R12(r13)
170 ld r11,PACA_EXSLB+EX_R9(r13)
171 ld r12,PACA_EXSLB+EX_R3(r13)
172 std r10,PACA_EXGEN+EX_R13(r13)
173 std r11,PACA_EXGEN+EX_R9(r13)
174 std r12,PACA_EXGEN+EX_R3(r13)
175 EXCEPTION_PROLOG_ISERIES_1
176 b slb_miss_user_common
179 MASKABLE_EXCEPTION_ISERIES(hardware_interrupt)
180 STD_EXCEPTION_ISERIES(alignment, PACA_EXGEN)
181 STD_EXCEPTION_ISERIES(program_check, PACA_EXGEN)
182 STD_EXCEPTION_ISERIES(fp_unavailable, PACA_EXGEN)
183 MASKABLE_EXCEPTION_ISERIES(decrementer)
184 STD_EXCEPTION_ISERIES(trap_0a, PACA_EXGEN)
185 STD_EXCEPTION_ISERIES(trap_0b, PACA_EXGEN)
187 .globl system_call_iSeries
191 EXCEPTION_PROLOG_ISERIES_1
194 STD_EXCEPTION_ISERIES(single_step, PACA_EXGEN)
195 STD_EXCEPTION_ISERIES(trap_0e, PACA_EXGEN)
196 STD_EXCEPTION_ISERIES(performance_monitor, PACA_EXGEN)
198 decrementer_iSeries_masked:
199 /* We may not have a valid TOC pointer in here. */
201 ld r12,PACALPPACAPTR(r13)
202 stb r11,LPPACADECRINT(r12)
203 LOAD_REG_IMMEDIATE(r12, tb_ticks_per_jiffy)
208 hardware_interrupt_iSeries_masked:
209 mtcrf 0x80,r9 /* Restore regs */
210 ld r12,PACALPPACAPTR(r13)
211 ld r11,LPPACASRR0(r12)
212 ld r12,LPPACASRR1(r12)
215 ld r9,PACA_EXGEN+EX_R9(r13)
216 ld r10,PACA_EXGEN+EX_R10(r13)
217 ld r11,PACA_EXGEN+EX_R11(r13)
218 ld r12,PACA_EXGEN+EX_R12(r13)
219 ld r13,PACA_EXGEN+EX_R13(r13)
221 b . /* prevent speculative execution */
223 _INIT_STATIC(__start_initialization_iSeries)
224 /* Clear out the BSS */
225 LOAD_REG_IMMEDIATE(r11,__bss_stop)
226 LOAD_REG_IMMEDIATE(r8,__bss_start)
227 sub r11,r11,r8 /* bss size */
228 addi r11,r11,7 /* round up to an even double word */
229 rldicl. r11,r11,61,3 /* shift right by 3 */
233 mtctr r11 /* zero this many doublewords */
237 LOAD_REG_IMMEDIATE(r1,init_thread_union)
238 addi r1,r1,THREAD_SIZE
240 stdu r0,-STACK_FRAME_OVERHEAD(r1)
242 LOAD_REG_IMMEDIATE(r2,__toc_start)
246 bl .iSeries_early_setup
249 /* relocation is on at this point */