18aa34ab8SBenjamin Herrenschmidt #ifndef _ASM_POWERPC_EXCEPTION_H
28aa34ab8SBenjamin Herrenschmidt #define _ASM_POWERPC_EXCEPTION_H
38aa34ab8SBenjamin Herrenschmidt /*
48aa34ab8SBenjamin Herrenschmidt  * Extracted from head_64.S
58aa34ab8SBenjamin Herrenschmidt  *
68aa34ab8SBenjamin Herrenschmidt  *  PowerPC version
78aa34ab8SBenjamin Herrenschmidt  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
88aa34ab8SBenjamin Herrenschmidt  *
98aa34ab8SBenjamin Herrenschmidt  *  Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
108aa34ab8SBenjamin Herrenschmidt  *    Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
118aa34ab8SBenjamin Herrenschmidt  *  Adapted for Power Macintosh by Paul Mackerras.
128aa34ab8SBenjamin Herrenschmidt  *  Low-level exception handlers and MMU support
138aa34ab8SBenjamin Herrenschmidt  *  rewritten by Paul Mackerras.
148aa34ab8SBenjamin Herrenschmidt  *    Copyright (C) 1996 Paul Mackerras.
158aa34ab8SBenjamin Herrenschmidt  *
168aa34ab8SBenjamin Herrenschmidt  *  Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
178aa34ab8SBenjamin Herrenschmidt  *    Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
188aa34ab8SBenjamin Herrenschmidt  *
198aa34ab8SBenjamin Herrenschmidt  *  This file contains the low-level support and setup for the
208aa34ab8SBenjamin Herrenschmidt  *  PowerPC-64 platform, including trap and interrupt dispatch.
218aa34ab8SBenjamin Herrenschmidt  *
228aa34ab8SBenjamin Herrenschmidt  *  This program is free software; you can redistribute it and/or
238aa34ab8SBenjamin Herrenschmidt  *  modify it under the terms of the GNU General Public License
248aa34ab8SBenjamin Herrenschmidt  *  as published by the Free Software Foundation; either version
258aa34ab8SBenjamin Herrenschmidt  *  2 of the License, or (at your option) any later version.
268aa34ab8SBenjamin Herrenschmidt  */
278aa34ab8SBenjamin Herrenschmidt /*
288aa34ab8SBenjamin Herrenschmidt  * The following macros define the code that appears as
298aa34ab8SBenjamin Herrenschmidt  * the prologue to each of the exception handlers.  They
308aa34ab8SBenjamin Herrenschmidt  * are split into two parts to allow a single kernel binary
318aa34ab8SBenjamin Herrenschmidt  * to be used for pSeries and iSeries.
328aa34ab8SBenjamin Herrenschmidt  *
338aa34ab8SBenjamin Herrenschmidt  * We make as much of the exception code common between native
348aa34ab8SBenjamin Herrenschmidt  * exception handlers (including pSeries LPAR) and iSeries LPAR
358aa34ab8SBenjamin Herrenschmidt  * implementations as possible.
368aa34ab8SBenjamin Herrenschmidt  */
378aa34ab8SBenjamin Herrenschmidt 
388aa34ab8SBenjamin Herrenschmidt #define EX_R9		0
398aa34ab8SBenjamin Herrenschmidt #define EX_R10		8
408aa34ab8SBenjamin Herrenschmidt #define EX_R11		16
418aa34ab8SBenjamin Herrenschmidt #define EX_R12		24
428aa34ab8SBenjamin Herrenschmidt #define EX_R13		32
438aa34ab8SBenjamin Herrenschmidt #define EX_SRR0		40
448aa34ab8SBenjamin Herrenschmidt #define EX_DAR		48
458aa34ab8SBenjamin Herrenschmidt #define EX_DSISR	56
468aa34ab8SBenjamin Herrenschmidt #define EX_CCR		60
478aa34ab8SBenjamin Herrenschmidt #define EX_R3		64
488aa34ab8SBenjamin Herrenschmidt #define EX_LR		72
498aa34ab8SBenjamin Herrenschmidt 
508aa34ab8SBenjamin Herrenschmidt /*
518aa34ab8SBenjamin Herrenschmidt  * We're short on space and time in the exception prolog, so we can't
528aa34ab8SBenjamin Herrenschmidt  * use the normal SET_REG_IMMEDIATE macro. Normally we just need the
538aa34ab8SBenjamin Herrenschmidt  * low halfword of the address, but for Kdump we need the whole low
548aa34ab8SBenjamin Herrenschmidt  * word.
558aa34ab8SBenjamin Herrenschmidt  */
568aa34ab8SBenjamin Herrenschmidt #define LOAD_HANDLER(reg, label)					\
578aa34ab8SBenjamin Herrenschmidt 	addi	reg,reg,(label)-_stext;	/* virt addr of handler ... */
588aa34ab8SBenjamin Herrenschmidt 
598aa34ab8SBenjamin Herrenschmidt #define EXCEPTION_PROLOG_1(area)				\
60ee43eb78SBenjamin Herrenschmidt 	mfspr	r13,SPRN_SPRG_PACA;	/* get paca address into r13 */	\
618aa34ab8SBenjamin Herrenschmidt 	std	r9,area+EX_R9(r13);	/* save r9 - r12 */		\
628aa34ab8SBenjamin Herrenschmidt 	std	r10,area+EX_R10(r13);					\
638aa34ab8SBenjamin Herrenschmidt 	std	r11,area+EX_R11(r13);					\
648aa34ab8SBenjamin Herrenschmidt 	std	r12,area+EX_R12(r13);					\
65ee43eb78SBenjamin Herrenschmidt 	mfspr	r9,SPRN_SPRG_SCRATCH0;					\
668aa34ab8SBenjamin Herrenschmidt 	std	r9,area+EX_R13(r13);					\
678aa34ab8SBenjamin Herrenschmidt 	mfcr	r9
688aa34ab8SBenjamin Herrenschmidt 
69c5a8c0c9SBenjamin Herrenschmidt #define EXCEPTION_PROLOG_PSERIES_1(label)				\
708aa34ab8SBenjamin Herrenschmidt 	ld	r12,PACAKBASE(r13);	/* get high part of &label */	\
718aa34ab8SBenjamin Herrenschmidt 	ld	r10,PACAKMSR(r13);	/* get MSR value for kernel */	\
728aa34ab8SBenjamin Herrenschmidt 	mfspr	r11,SPRN_SRR0;		/* save SRR0 */			\
738aa34ab8SBenjamin Herrenschmidt 	LOAD_HANDLER(r12,label)						\
748aa34ab8SBenjamin Herrenschmidt 	mtspr	SPRN_SRR0,r12;						\
758aa34ab8SBenjamin Herrenschmidt 	mfspr	r12,SPRN_SRR1;		/* and SRR1 */			\
768aa34ab8SBenjamin Herrenschmidt 	mtspr	SPRN_SRR1,r10;						\
778aa34ab8SBenjamin Herrenschmidt 	rfid;								\
788aa34ab8SBenjamin Herrenschmidt 	b	.	/* prevent speculative execution */
798aa34ab8SBenjamin Herrenschmidt 
80c5a8c0c9SBenjamin Herrenschmidt #define EXCEPTION_PROLOG_PSERIES(area, label)				\
81c5a8c0c9SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_1(area);					\
82c5a8c0c9SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_PSERIES_1(label);
83c5a8c0c9SBenjamin Herrenschmidt 
848aa34ab8SBenjamin Herrenschmidt /*
858aa34ab8SBenjamin Herrenschmidt  * The common exception prolog is used for all except a few exceptions
868aa34ab8SBenjamin Herrenschmidt  * such as a segment miss on a kernel address.  We have to be prepared
878aa34ab8SBenjamin Herrenschmidt  * to take another exception from the point where we first touch the
888aa34ab8SBenjamin Herrenschmidt  * kernel stack onwards.
898aa34ab8SBenjamin Herrenschmidt  *
908aa34ab8SBenjamin Herrenschmidt  * On entry r13 points to the paca, r9-r13 are saved in the paca,
918aa34ab8SBenjamin Herrenschmidt  * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and
928aa34ab8SBenjamin Herrenschmidt  * SRR1, and relocation is on.
938aa34ab8SBenjamin Herrenschmidt  */
948aa34ab8SBenjamin Herrenschmidt #define EXCEPTION_PROLOG_COMMON(n, area)				   \
958aa34ab8SBenjamin Herrenschmidt 	andi.	r10,r12,MSR_PR;		/* See if coming from user	*/ \
968aa34ab8SBenjamin Herrenschmidt 	mr	r10,r1;			/* Save r1			*/ \
978aa34ab8SBenjamin Herrenschmidt 	subi	r1,r1,INT_FRAME_SIZE;	/* alloc frame on kernel stack	*/ \
988aa34ab8SBenjamin Herrenschmidt 	beq-	1f;							   \
998aa34ab8SBenjamin Herrenschmidt 	ld	r1,PACAKSAVE(r13);	/* kernel stack to use		*/ \
1008aa34ab8SBenjamin Herrenschmidt 1:	cmpdi	cr1,r1,0;		/* check if r1 is in userspace	*/ \
1018aa34ab8SBenjamin Herrenschmidt 	bge-	cr1,2f;			/* abort if it is		*/ \
1028aa34ab8SBenjamin Herrenschmidt 	b	3f;							   \
1038aa34ab8SBenjamin Herrenschmidt 2:	li	r1,(n);			/* will be reloaded later	*/ \
1048aa34ab8SBenjamin Herrenschmidt 	sth	r1,PACA_TRAP_SAVE(r13);					   \
1058aa34ab8SBenjamin Herrenschmidt 	b	bad_stack;						   \
1068aa34ab8SBenjamin Herrenschmidt 3:	std	r9,_CCR(r1);		/* save CR in stackframe	*/ \
1078aa34ab8SBenjamin Herrenschmidt 	std	r11,_NIP(r1);		/* save SRR0 in stackframe	*/ \
1088aa34ab8SBenjamin Herrenschmidt 	std	r12,_MSR(r1);		/* save SRR1 in stackframe	*/ \
1098aa34ab8SBenjamin Herrenschmidt 	std	r10,0(r1);		/* make stack chain pointer	*/ \
1108aa34ab8SBenjamin Herrenschmidt 	std	r0,GPR0(r1);		/* save r0 in stackframe	*/ \
1118aa34ab8SBenjamin Herrenschmidt 	std	r10,GPR1(r1);		/* save r1 in stackframe	*/ \
1128aa34ab8SBenjamin Herrenschmidt 	ACCOUNT_CPU_USER_ENTRY(r9, r10);				   \
1138aa34ab8SBenjamin Herrenschmidt 	std	r2,GPR2(r1);		/* save r2 in stackframe	*/ \
1148aa34ab8SBenjamin Herrenschmidt 	SAVE_4GPRS(3, r1);		/* save r3 - r6 in stackframe	*/ \
1158aa34ab8SBenjamin Herrenschmidt 	SAVE_2GPRS(7, r1);		/* save r7, r8 in stackframe	*/ \
1168aa34ab8SBenjamin Herrenschmidt 	ld	r9,area+EX_R9(r13);	/* move r9, r10 to stackframe	*/ \
1178aa34ab8SBenjamin Herrenschmidt 	ld	r10,area+EX_R10(r13);					   \
1188aa34ab8SBenjamin Herrenschmidt 	std	r9,GPR9(r1);						   \
1198aa34ab8SBenjamin Herrenschmidt 	std	r10,GPR10(r1);						   \
1208aa34ab8SBenjamin Herrenschmidt 	ld	r9,area+EX_R11(r13);	/* move r11 - r13 to stackframe	*/ \
1218aa34ab8SBenjamin Herrenschmidt 	ld	r10,area+EX_R12(r13);					   \
1228aa34ab8SBenjamin Herrenschmidt 	ld	r11,area+EX_R13(r13);					   \
1238aa34ab8SBenjamin Herrenschmidt 	std	r9,GPR11(r1);						   \
1248aa34ab8SBenjamin Herrenschmidt 	std	r10,GPR12(r1);						   \
1258aa34ab8SBenjamin Herrenschmidt 	std	r11,GPR13(r1);						   \
1268aa34ab8SBenjamin Herrenschmidt 	ld	r2,PACATOC(r13);	/* get kernel TOC into r2	*/ \
1278aa34ab8SBenjamin Herrenschmidt 	mflr	r9;			/* save LR in stackframe	*/ \
1288aa34ab8SBenjamin Herrenschmidt 	std	r9,_LINK(r1);						   \
1298aa34ab8SBenjamin Herrenschmidt 	mfctr	r10;			/* save CTR in stackframe	*/ \
1308aa34ab8SBenjamin Herrenschmidt 	std	r10,_CTR(r1);						   \
1318aa34ab8SBenjamin Herrenschmidt 	lbz	r10,PACASOFTIRQEN(r13);				   \
1328aa34ab8SBenjamin Herrenschmidt 	mfspr	r11,SPRN_XER;		/* save XER in stackframe	*/ \
1338aa34ab8SBenjamin Herrenschmidt 	std	r10,SOFTE(r1);						   \
1348aa34ab8SBenjamin Herrenschmidt 	std	r11,_XER(r1);						   \
1358aa34ab8SBenjamin Herrenschmidt 	li	r9,(n)+1;						   \
1368aa34ab8SBenjamin Herrenschmidt 	std	r9,_TRAP(r1);		/* set trap number		*/ \
1378aa34ab8SBenjamin Herrenschmidt 	li	r10,0;							   \
1388aa34ab8SBenjamin Herrenschmidt 	ld	r11,exception_marker@toc(r2);				   \
1398aa34ab8SBenjamin Herrenschmidt 	std	r10,RESULT(r1);		/* clear regs->result		*/ \
140cf9efce0SPaul Mackerras 	std	r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame	*/ \
141cf9efce0SPaul Mackerras 	ACCOUNT_STOLEN_TIME
1428aa34ab8SBenjamin Herrenschmidt 
1438aa34ab8SBenjamin Herrenschmidt /*
1448aa34ab8SBenjamin Herrenschmidt  * Exception vectors.
1458aa34ab8SBenjamin Herrenschmidt  */
1468aa34ab8SBenjamin Herrenschmidt #define STD_EXCEPTION_PSERIES(n, label)			\
1478aa34ab8SBenjamin Herrenschmidt 	. = n;						\
1488aa34ab8SBenjamin Herrenschmidt 	.globl label##_pSeries;				\
1498aa34ab8SBenjamin Herrenschmidt label##_pSeries:					\
1508aa34ab8SBenjamin Herrenschmidt 	HMT_MEDIUM;					\
151842f2fedSAlexander Graf 	DO_KVM	n;					\
152ee43eb78SBenjamin Herrenschmidt 	mtspr	SPRN_SPRG_SCRATCH0,r13;		/* save r13 */	\
1538aa34ab8SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
1548aa34ab8SBenjamin Herrenschmidt 
1558aa34ab8SBenjamin Herrenschmidt #define HSTD_EXCEPTION_PSERIES(n, label)		\
1568aa34ab8SBenjamin Herrenschmidt 	. = n;						\
1578aa34ab8SBenjamin Herrenschmidt 	.globl label##_pSeries;				\
1588aa34ab8SBenjamin Herrenschmidt label##_pSeries:					\
1598aa34ab8SBenjamin Herrenschmidt 	HMT_MEDIUM;					\
160ee43eb78SBenjamin Herrenschmidt 	mtspr	SPRN_SPRG_SCRATCH0,r20;	/* save r20 */	\
1618aa34ab8SBenjamin Herrenschmidt 	mfspr	r20,SPRN_HSRR0;		/* copy HSRR0 to SRR0 */ \
1628aa34ab8SBenjamin Herrenschmidt 	mtspr	SPRN_SRR0,r20;				\
1638aa34ab8SBenjamin Herrenschmidt 	mfspr	r20,SPRN_HSRR1;		/* copy HSRR0 to SRR0 */ \
1648aa34ab8SBenjamin Herrenschmidt 	mtspr	SPRN_SRR1,r20;				\
165ee43eb78SBenjamin Herrenschmidt 	mfspr	r20,SPRN_SPRG_SCRATCH0;	/* restore r20 */ \
166ee43eb78SBenjamin Herrenschmidt 	mtspr	SPRN_SPRG_SCRATCH0,r13;		/* save r13 */	\
1678aa34ab8SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
1688aa34ab8SBenjamin Herrenschmidt 
1698aa34ab8SBenjamin Herrenschmidt 
1708aa34ab8SBenjamin Herrenschmidt #define MASKABLE_EXCEPTION_PSERIES(n, label)				\
1718aa34ab8SBenjamin Herrenschmidt 	. = n;								\
1728aa34ab8SBenjamin Herrenschmidt 	.globl label##_pSeries;						\
1738aa34ab8SBenjamin Herrenschmidt label##_pSeries:							\
1748aa34ab8SBenjamin Herrenschmidt 	HMT_MEDIUM;							\
175842f2fedSAlexander Graf 	DO_KVM	n;							\
176ee43eb78SBenjamin Herrenschmidt 	mtspr	SPRN_SPRG_SCRATCH0,r13;	/* save r13 */			\
177ee43eb78SBenjamin Herrenschmidt 	mfspr	r13,SPRN_SPRG_PACA;	/* get paca address into r13 */	\
1788aa34ab8SBenjamin Herrenschmidt 	std	r9,PACA_EXGEN+EX_R9(r13);	/* save r9, r10 */	\
1798aa34ab8SBenjamin Herrenschmidt 	std	r10,PACA_EXGEN+EX_R10(r13);				\
1808aa34ab8SBenjamin Herrenschmidt 	lbz	r10,PACASOFTIRQEN(r13);					\
1818aa34ab8SBenjamin Herrenschmidt 	mfcr	r9;							\
1828aa34ab8SBenjamin Herrenschmidt 	cmpwi	r10,0;							\
1838aa34ab8SBenjamin Herrenschmidt 	beq	masked_interrupt;					\
184ee43eb78SBenjamin Herrenschmidt 	mfspr	r10,SPRN_SPRG_SCRATCH0;					\
1858aa34ab8SBenjamin Herrenschmidt 	std	r10,PACA_EXGEN+EX_R13(r13);				\
1868aa34ab8SBenjamin Herrenschmidt 	std	r11,PACA_EXGEN+EX_R11(r13);				\
1878aa34ab8SBenjamin Herrenschmidt 	std	r12,PACA_EXGEN+EX_R12(r13);				\
1888aa34ab8SBenjamin Herrenschmidt 	ld	r12,PACAKBASE(r13);	/* get high part of &label */	\
1898aa34ab8SBenjamin Herrenschmidt 	ld	r10,PACAKMSR(r13);	/* get MSR value for kernel */	\
1908aa34ab8SBenjamin Herrenschmidt 	mfspr	r11,SPRN_SRR0;		/* save SRR0 */			\
1918aa34ab8SBenjamin Herrenschmidt 	LOAD_HANDLER(r12,label##_common)				\
1928aa34ab8SBenjamin Herrenschmidt 	mtspr	SPRN_SRR0,r12;						\
1938aa34ab8SBenjamin Herrenschmidt 	mfspr	r12,SPRN_SRR1;		/* and SRR1 */			\
1948aa34ab8SBenjamin Herrenschmidt 	mtspr	SPRN_SRR1,r10;						\
1958aa34ab8SBenjamin Herrenschmidt 	rfid;								\
1968aa34ab8SBenjamin Herrenschmidt 	b	.	/* prevent speculative execution */
1978aa34ab8SBenjamin Herrenschmidt 
1988aa34ab8SBenjamin Herrenschmidt #ifdef CONFIG_PPC_ISERIES
1998aa34ab8SBenjamin Herrenschmidt #define DISABLE_INTS				\
2008aa34ab8SBenjamin Herrenschmidt 	li	r11,0;				\
2018aa34ab8SBenjamin Herrenschmidt 	stb	r11,PACASOFTIRQEN(r13);		\
2028aa34ab8SBenjamin Herrenschmidt BEGIN_FW_FTR_SECTION;				\
2038aa34ab8SBenjamin Herrenschmidt 	stb	r11,PACAHARDIRQEN(r13);		\
2048aa34ab8SBenjamin Herrenschmidt END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES);	\
2058aa34ab8SBenjamin Herrenschmidt 	TRACE_DISABLE_INTS;			\
2068aa34ab8SBenjamin Herrenschmidt BEGIN_FW_FTR_SECTION;				\
2078aa34ab8SBenjamin Herrenschmidt 	mfmsr	r10;				\
2088aa34ab8SBenjamin Herrenschmidt 	ori	r10,r10,MSR_EE;			\
2098aa34ab8SBenjamin Herrenschmidt 	mtmsrd	r10,1;				\
2108aa34ab8SBenjamin Herrenschmidt END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
2118aa34ab8SBenjamin Herrenschmidt #else
2128aa34ab8SBenjamin Herrenschmidt #define DISABLE_INTS				\
2138aa34ab8SBenjamin Herrenschmidt 	li	r11,0;				\
2148aa34ab8SBenjamin Herrenschmidt 	stb	r11,PACASOFTIRQEN(r13);		\
2158aa34ab8SBenjamin Herrenschmidt 	stb	r11,PACAHARDIRQEN(r13);		\
2168aa34ab8SBenjamin Herrenschmidt 	TRACE_DISABLE_INTS
2178aa34ab8SBenjamin Herrenschmidt #endif /* CONFIG_PPC_ISERIES */
2188aa34ab8SBenjamin Herrenschmidt 
2198aa34ab8SBenjamin Herrenschmidt #define ENABLE_INTS				\
2208aa34ab8SBenjamin Herrenschmidt 	ld	r12,_MSR(r1);			\
2218aa34ab8SBenjamin Herrenschmidt 	mfmsr	r11;				\
2228aa34ab8SBenjamin Herrenschmidt 	rlwimi	r11,r12,0,MSR_EE;		\
2238aa34ab8SBenjamin Herrenschmidt 	mtmsrd	r11,1
2248aa34ab8SBenjamin Herrenschmidt 
2258aa34ab8SBenjamin Herrenschmidt #define STD_EXCEPTION_COMMON(trap, label, hdlr)		\
2268aa34ab8SBenjamin Herrenschmidt 	.align	7;					\
2278aa34ab8SBenjamin Herrenschmidt 	.globl label##_common;				\
2288aa34ab8SBenjamin Herrenschmidt label##_common:						\
2298aa34ab8SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN);	\
2308aa34ab8SBenjamin Herrenschmidt 	DISABLE_INTS;					\
2318aa34ab8SBenjamin Herrenschmidt 	bl	.save_nvgprs;				\
2328aa34ab8SBenjamin Herrenschmidt 	addi	r3,r1,STACK_FRAME_OVERHEAD;		\
2338aa34ab8SBenjamin Herrenschmidt 	bl	hdlr;					\
2348aa34ab8SBenjamin Herrenschmidt 	b	.ret_from_except
2358aa34ab8SBenjamin Herrenschmidt 
2368aa34ab8SBenjamin Herrenschmidt /*
2378aa34ab8SBenjamin Herrenschmidt  * Like STD_EXCEPTION_COMMON, but for exceptions that can occur
2388aa34ab8SBenjamin Herrenschmidt  * in the idle task and therefore need the special idle handling.
2398aa34ab8SBenjamin Herrenschmidt  */
2408aa34ab8SBenjamin Herrenschmidt #define STD_EXCEPTION_COMMON_IDLE(trap, label, hdlr)	\
2418aa34ab8SBenjamin Herrenschmidt 	.align	7;					\
2428aa34ab8SBenjamin Herrenschmidt 	.globl label##_common;				\
2438aa34ab8SBenjamin Herrenschmidt label##_common:						\
2448aa34ab8SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN);	\
2458aa34ab8SBenjamin Herrenschmidt 	FINISH_NAP;					\
2468aa34ab8SBenjamin Herrenschmidt 	DISABLE_INTS;					\
2478aa34ab8SBenjamin Herrenschmidt 	bl	.save_nvgprs;				\
2488aa34ab8SBenjamin Herrenschmidt 	addi	r3,r1,STACK_FRAME_OVERHEAD;		\
2498aa34ab8SBenjamin Herrenschmidt 	bl	hdlr;					\
2508aa34ab8SBenjamin Herrenschmidt 	b	.ret_from_except
2518aa34ab8SBenjamin Herrenschmidt 
2528aa34ab8SBenjamin Herrenschmidt #define STD_EXCEPTION_COMMON_LITE(trap, label, hdlr)	\
2538aa34ab8SBenjamin Herrenschmidt 	.align	7;					\
2548aa34ab8SBenjamin Herrenschmidt 	.globl label##_common;				\
2558aa34ab8SBenjamin Herrenschmidt label##_common:						\
2568aa34ab8SBenjamin Herrenschmidt 	EXCEPTION_PROLOG_COMMON(trap, PACA_EXGEN);	\
2578aa34ab8SBenjamin Herrenschmidt 	FINISH_NAP;					\
2588aa34ab8SBenjamin Herrenschmidt 	DISABLE_INTS;					\
2598aa34ab8SBenjamin Herrenschmidt BEGIN_FTR_SECTION					\
2608aa34ab8SBenjamin Herrenschmidt 	bl	.ppc64_runlatch_on;			\
2618aa34ab8SBenjamin Herrenschmidt END_FTR_SECTION_IFSET(CPU_FTR_CTRL)			\
2628aa34ab8SBenjamin Herrenschmidt 	addi	r3,r1,STACK_FRAME_OVERHEAD;		\
2638aa34ab8SBenjamin Herrenschmidt 	bl	hdlr;					\
2648aa34ab8SBenjamin Herrenschmidt 	b	.ret_from_except_lite
2658aa34ab8SBenjamin Herrenschmidt 
2668aa34ab8SBenjamin Herrenschmidt /*
2678aa34ab8SBenjamin Herrenschmidt  * When the idle code in power4_idle puts the CPU into NAP mode,
2688aa34ab8SBenjamin Herrenschmidt  * it has to do so in a loop, and relies on the external interrupt
2698aa34ab8SBenjamin Herrenschmidt  * and decrementer interrupt entry code to get it out of the loop.
2708aa34ab8SBenjamin Herrenschmidt  * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags
2718aa34ab8SBenjamin Herrenschmidt  * to signal that it is in the loop and needs help to get out.
2728aa34ab8SBenjamin Herrenschmidt  */
2738aa34ab8SBenjamin Herrenschmidt #ifdef CONFIG_PPC_970_NAP
2748aa34ab8SBenjamin Herrenschmidt #define FINISH_NAP				\
2758aa34ab8SBenjamin Herrenschmidt BEGIN_FTR_SECTION				\
2768aa34ab8SBenjamin Herrenschmidt 	clrrdi	r11,r1,THREAD_SHIFT;		\
2778aa34ab8SBenjamin Herrenschmidt 	ld	r9,TI_LOCAL_FLAGS(r11);		\
2788aa34ab8SBenjamin Herrenschmidt 	andi.	r10,r9,_TLF_NAPPING;		\
2798aa34ab8SBenjamin Herrenschmidt 	bnel	power4_fixup_nap;		\
2808aa34ab8SBenjamin Herrenschmidt END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP)
2818aa34ab8SBenjamin Herrenschmidt #else
2828aa34ab8SBenjamin Herrenschmidt #define FINISH_NAP
2838aa34ab8SBenjamin Herrenschmidt #endif
2848aa34ab8SBenjamin Herrenschmidt 
2858aa34ab8SBenjamin Herrenschmidt #endif	/* _ASM_POWERPC_EXCEPTION_H */
286