xref: /titanic_41/usr/src/cmd/mdb/sun4u/v9/kmdb/mach_asmutil.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _MACH_ASMUTIL_H
28 #define	_MACH_ASMUTIL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef _ASM
37 
38 #define	GET_NWIN(scr1, reg1)	\
39 	rdpr	%ver, reg1;\
40 	and	reg1, VER_MAXWIN, reg1
41 
42 #define	SET_GL(x)
43 
44 #define	SWITCH_TO_NORMAL_GLOBALS()	\
45 	mov	%o5, %g3	/* save %o5 in %g3 */;\
46 	mov	%o4, %g2	/* save %o4 in %g2 */;\
47 	mov	%g5, %o5	/* set %o5 = gregs pointer */;\
48 	mov	%g4, %o4	/* set %o4 = return %pstate value */;\
49 	wrpr	%g0, PTSTATE_KERN_COMMON, %pstate	/* AG = 0 */
50 
51 #define	SWITCH_TO_TL1_GLOBALS_AND_RET()	\
52 	wrpr	%o4, %pstate	/* use TL1 globals, set %pstate from %o4 */;\
53 	mov	%g3, %o5	/* restore saved %o5 from %g3 */;\
54 	jmp	%g7;\
55 	mov	%g2, %o4	/* restore saved %o4 from %g2 */
56 
57 #define	KAIF_SAVE_TL1_STATE()	\
58 	ba	kaif_save_tl1_state;\
59 	mov	PTSTATE_KERN_COMMON|PSTATE_AG, %g4
60 
61 #define	KAIF_SAVE_TL1_STATE_SLAVE()	\
62 	ba	kaif_save_tl1_state;\
63 	mov	PTSTATE_KERN_COMMON|PSTATE_IG, %g4
64 
65 #define	SET_PSTATE_COMMON_AG(reg1)	\
66 	or	%g0, PTSTATE_KERN_COMMON | PSTATE_AG, reg1;\
67 	wrpr	reg1, %pstate
68 
69 #define	KAIF_DEMAP_TLB_ALL(scr)			\
70 	mov	DEMAP_ALL_TYPE, scr;		\
71 	stxa	%g0, [scr]ASI_DTLB_DEMAP;	\
72 	sethi	%hi(FLUSH_ADDR), scr;		\
73 	flush	scr
74 
75 #endif
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* _MACH_ASMUTIL_H */
82