Path: blob/master/arch/powerpc/platforms/iseries/exception.S
10820 views
/*1* Low level routines for legacy iSeries support.2*3* Extracted from head_64.S4*5* PowerPC version6* Copyright (C) 1995-1996 Gary Thomas ([email protected])7*8* Rewritten by Cort Dougan ([email protected]) for PReP9* Copyright (C) 1996 Cort Dougan <[email protected]>10* Adapted for Power Macintosh by Paul Mackerras.11* Low-level exception handlers and MMU support12* rewritten by Paul Mackerras.13* Copyright (C) 1996 Paul Mackerras.14*15* Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and16* Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com17*18* This file contains the low-level support and setup for the19* PowerPC-64 platform, including trap and interrupt dispatch.20*21* This program is free software; you can redistribute it and/or22* modify it under the terms of the GNU General Public License23* as published by the Free Software Foundation; either version24* 2 of the License, or (at your option) any later version.25*/2627#include <asm/reg.h>28#include <asm/ppc_asm.h>29#include <asm/asm-offsets.h>30#include <asm/thread_info.h>31#include <asm/ptrace.h>32#include <asm/cputable.h>33#include <asm/mmu.h>3435#include "exception.h"3637.text3839.globl system_reset_iSeries40system_reset_iSeries:41bl .relative_toc42mfspr r13,SPRN_SPRG3 /* Get alpaca address */43LOAD_REG_ADDR(r23, alpaca)44li r0,ALPACA_SIZE45sub r23,r13,r2346divdu r24,r23,r0 /* r24 has cpu number */47cmpwi 0,r24,0 /* Are we processor 0? */48bne 1f49LOAD_REG_ADDR(r13, boot_paca)50mtspr SPRN_SPRG_PACA,r13 /* Save it away for the future */51mfmsr r2352ori r23,r23,MSR_RI53mtmsrd r23 /* RI on */54b .__start_initialization_iSeries /* Start up the first processor */551: mfspr r4,SPRN_CTRLF56li r5,CTRL_RUNLATCH /* Turn off the run light */57andc r4,r4,r558mtspr SPRN_CTRLT,r45960/* Spin on __secondary_hold_spinloop until it is updated by the boot cpu. */61/* In the UP case we'll yield() later, and we will not access the paca anyway */62#ifdef CONFIG_SMP63iSeries_secondary_wait_paca:64HMT_LOW65LOAD_REG_ADDR(r23, __secondary_hold_spinloop)66ld r23,0(r23)6768cmpdi 0,r23,069bne 2f /* go on when the master is ready */7071/* Keep poking the Hypervisor until we're released */72/* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */73lis r3,0x800274rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */75li r0,-1 /* r0=-1 indicates a Hypervisor call */76sc /* Invoke the hypervisor via a system call */77b iSeries_secondary_wait_paca78792:80HMT_MEDIUM81sync8283LOAD_REG_ADDR(r3, nr_cpu_ids) /* get number of pacas allocated */84lwz r3,0(r3) /* nr_cpus= or NR_CPUS can limit */85cmpld 0,r24,r3 /* is our cpu number allocated? */86bge iSeries_secondary_yield /* no, yield forever */8788/* Load our paca now that it's been allocated */89LOAD_REG_ADDR(r13, paca)90ld r13,0(r13)91mulli r0,r24,PACA_SIZE92add r13,r13,r093mtspr SPRN_SPRG_PACA,r13 /* Save it away for the future */94mfmsr r2395ori r23,r23,MSR_RI96mtmsrd r23 /* RI on */9798iSeries_secondary_smp_loop:99lbz r23,PACAPROCSTART(r13) /* Test if this processor100* should start */101cmpwi 0,r23,0102bne 3f /* go on when we are told */103104HMT_LOW105/* Let the Hypervisor know we are alive */106/* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */107lis r3,0x8002108rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */109li r0,-1 /* r0=-1 indicates a Hypervisor call */110sc /* Invoke the hypervisor via a system call */111mfspr r13,SPRN_SPRG_PACA /* Put r13 back ???? */112b iSeries_secondary_smp_loop /* wait for signal to start */1131143:115HMT_MEDIUM116sync117LOAD_REG_ADDR(r3,current_set)118sldi r28,r24,3 /* get current_set[cpu#] */119ldx r3,r3,r28120addi r1,r3,THREAD_SIZE121subi r1,r1,STACK_FRAME_OVERHEAD122123b __secondary_start /* Loop until told to go */124#endif /* CONFIG_SMP */125126iSeries_secondary_yield:127/* Yield the processor. This is required for non-SMP kernels128which are running on multi-threaded machines. */129HMT_LOW130lis r3,0x8000131rldicr r3,r3,32,15 /* r3 = (r3 << 32) & 0xffff000000000000 */132addi r3,r3,18 /* r3 = 0x8000000000000012 which is "yield" */133li r4,0 /* "yield timed" */134li r5,-1 /* "yield forever" */135li r0,-1 /* r0=-1 indicates a Hypervisor call */136sc /* Invoke the hypervisor via a system call */137mfspr r13,SPRN_SPRG_PACA /* Put r13 back ???? */138b iSeries_secondary_yield /* If SMP not configured, secondaries139* loop forever */140141/*** ISeries-LPAR interrupt handlers ***/142143STD_EXCEPTION_ISERIES(machine_check, PACA_EXMC)144145.globl data_access_iSeries146data_access_iSeries:147mtspr SPRN_SPRG_SCRATCH0,r13148BEGIN_FTR_SECTION149mfspr r13,SPRN_SPRG_PACA150std r9,PACA_EXSLB+EX_R9(r13)151std r10,PACA_EXSLB+EX_R10(r13)152mfspr r10,SPRN_DAR153mfspr r9,SPRN_DSISR154srdi r10,r10,60155rlwimi r10,r9,16,0x20156mfcr r9157cmpwi r10,0x2c158beq .do_stab_bolted_iSeries159ld r10,PACA_EXSLB+EX_R10(r13)160std r11,PACA_EXGEN+EX_R11(r13)161ld r11,PACA_EXSLB+EX_R9(r13)162std r12,PACA_EXGEN+EX_R12(r13)163mfspr r12,SPRN_SPRG_SCRATCH0164std r10,PACA_EXGEN+EX_R10(r13)165std r11,PACA_EXGEN+EX_R9(r13)166std r12,PACA_EXGEN+EX_R13(r13)167EXCEPTION_PROLOG_ISERIES_1168FTR_SECTION_ELSE169EXCEPTION_PROLOG_1(PACA_EXGEN)170EXCEPTION_PROLOG_ISERIES_1171ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_SLB)172b data_access_common173174.do_stab_bolted_iSeries:175std r11,PACA_EXSLB+EX_R11(r13)176std r12,PACA_EXSLB+EX_R12(r13)177mfspr r10,SPRN_SPRG_SCRATCH0178std r10,PACA_EXSLB+EX_R13(r13)179EXCEPTION_PROLOG_ISERIES_1180b .do_stab_bolted181182.globl data_access_slb_iSeries183data_access_slb_iSeries:184mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */185mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */186std r3,PACA_EXSLB+EX_R3(r13)187mfspr r3,SPRN_DAR188std r9,PACA_EXSLB+EX_R9(r13)189mfcr r9190#ifdef __DISABLED__191cmpdi r3,0192bge slb_miss_user_iseries193#endif194std r10,PACA_EXSLB+EX_R10(r13)195std r11,PACA_EXSLB+EX_R11(r13)196std r12,PACA_EXSLB+EX_R12(r13)197mfspr r10,SPRN_SPRG_SCRATCH0198std r10,PACA_EXSLB+EX_R13(r13)199ld r12,PACALPPACAPTR(r13)200ld r12,LPPACASRR1(r12)201b .slb_miss_realmode202203STD_EXCEPTION_ISERIES(instruction_access, PACA_EXGEN)204205.globl instruction_access_slb_iSeries206instruction_access_slb_iSeries:207mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */208mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */209std r3,PACA_EXSLB+EX_R3(r13)210ld r3,PACALPPACAPTR(r13)211ld r3,LPPACASRR0(r3) /* get SRR0 value */212std r9,PACA_EXSLB+EX_R9(r13)213mfcr r9214#ifdef __DISABLED__215cmpdi r3,0216bge slb_miss_user_iseries217#endif218std r10,PACA_EXSLB+EX_R10(r13)219std r11,PACA_EXSLB+EX_R11(r13)220std r12,PACA_EXSLB+EX_R12(r13)221mfspr r10,SPRN_SPRG_SCRATCH0222std r10,PACA_EXSLB+EX_R13(r13)223ld r12,PACALPPACAPTR(r13)224ld r12,LPPACASRR1(r12)225b .slb_miss_realmode226227#ifdef __DISABLED__228slb_miss_user_iseries:229std r10,PACA_EXGEN+EX_R10(r13)230std r11,PACA_EXGEN+EX_R11(r13)231std r12,PACA_EXGEN+EX_R12(r13)232mfspr r10,SPRG_SCRATCH0233ld r11,PACA_EXSLB+EX_R9(r13)234ld r12,PACA_EXSLB+EX_R3(r13)235std r10,PACA_EXGEN+EX_R13(r13)236std r11,PACA_EXGEN+EX_R9(r13)237std r12,PACA_EXGEN+EX_R3(r13)238EXCEPTION_PROLOG_ISERIES_1239b slb_miss_user_common240#endif241242MASKABLE_EXCEPTION_ISERIES(hardware_interrupt)243STD_EXCEPTION_ISERIES(alignment, PACA_EXGEN)244STD_EXCEPTION_ISERIES(program_check, PACA_EXGEN)245STD_EXCEPTION_ISERIES(fp_unavailable, PACA_EXGEN)246MASKABLE_EXCEPTION_ISERIES(decrementer)247STD_EXCEPTION_ISERIES(trap_0a, PACA_EXGEN)248STD_EXCEPTION_ISERIES(trap_0b, PACA_EXGEN)249250.globl system_call_iSeries251system_call_iSeries:252mr r9,r13253mfspr r13,SPRN_SPRG_PACA254EXCEPTION_PROLOG_ISERIES_1255b system_call_common256257STD_EXCEPTION_ISERIES(single_step, PACA_EXGEN)258STD_EXCEPTION_ISERIES(trap_0e, PACA_EXGEN)259STD_EXCEPTION_ISERIES(performance_monitor, PACA_EXGEN)260261decrementer_iSeries_masked:262/* We may not have a valid TOC pointer in here. */263li r11,1264ld r12,PACALPPACAPTR(r13)265stb r11,LPPACADECRINT(r12)266li r12,-1267clrldi r12,r12,33 /* set DEC to 0x7fffffff */268mtspr SPRN_DEC,r12269/* fall through */270271hardware_interrupt_iSeries_masked:272mtcrf 0x80,r9 /* Restore regs */273ld r12,PACALPPACAPTR(r13)274ld r11,LPPACASRR0(r12)275ld r12,LPPACASRR1(r12)276mtspr SPRN_SRR0,r11277mtspr SPRN_SRR1,r12278ld r9,PACA_EXGEN+EX_R9(r13)279ld r10,PACA_EXGEN+EX_R10(r13)280ld r11,PACA_EXGEN+EX_R11(r13)281ld r12,PACA_EXGEN+EX_R12(r13)282ld r13,PACA_EXGEN+EX_R13(r13)283rfid284b . /* prevent speculative execution */285286_INIT_STATIC(__start_initialization_iSeries)287/* Clear out the BSS */288LOAD_REG_ADDR(r11,__bss_stop)289LOAD_REG_ADDR(r8,__bss_start)290sub r11,r11,r8 /* bss size */291addi r11,r11,7 /* round up to an even double word */292rldicl. r11,r11,61,3 /* shift right by 3 */293beq 4f294addi r8,r8,-8295li r0,0296mtctr r11 /* zero this many doublewords */2973: stdu r0,8(r8)298bdnz 3b2994:300LOAD_REG_ADDR(r1,init_thread_union)301addi r1,r1,THREAD_SIZE302li r0,0303stdu r0,-STACK_FRAME_OVERHEAD(r1)304305bl .iSeries_early_setup306bl .early_setup307308/* relocation is on at this point */309310b .start_here_common311312313