xref: /onnv-gate/usr/src/uts/sparc/v9/sys/privregs.h (revision 9351:f85876ac403e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57718SJason.Beloro@Sun.COM  * Common Development and Distribution License (the "License").
67718SJason.Beloro@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*9351SPrashanth.Sreenivasa@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_PRIVREGS_H
270Sstevel@tonic-gate #define	_SYS_PRIVREGS_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate /*
340Sstevel@tonic-gate  * This file is kernel isa dependent.
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <sys/fsr.h>
380Sstevel@tonic-gate #include <v9/sys/asi.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * This file describes the cpu's privileged register set, and
420Sstevel@tonic-gate  * how the machine state is saved on the stack when a trap occurs.
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #ifndef	_ASM
460Sstevel@tonic-gate 
470Sstevel@tonic-gate struct regs {
480Sstevel@tonic-gate 	long long	r_tstate;
490Sstevel@tonic-gate 	long long	r_g1;		/* user global regs */
500Sstevel@tonic-gate 	long long	r_g2;
510Sstevel@tonic-gate 	long long	r_g3;
520Sstevel@tonic-gate 	long long	r_g4;
530Sstevel@tonic-gate 	long long	r_g5;
540Sstevel@tonic-gate 	long long	r_g6;
550Sstevel@tonic-gate 	long long	r_g7;
560Sstevel@tonic-gate 	long long	r_o0;
570Sstevel@tonic-gate 	long long	r_o1;
580Sstevel@tonic-gate 	long long	r_o2;
590Sstevel@tonic-gate 	long long	r_o3;
600Sstevel@tonic-gate 	long long	r_o4;
610Sstevel@tonic-gate 	long long	r_o5;
620Sstevel@tonic-gate 	long long	r_o6;
630Sstevel@tonic-gate 	long long	r_o7;
640Sstevel@tonic-gate 	/*
650Sstevel@tonic-gate 	 * These are still 32b in 4u's v8/v9 hybrid
660Sstevel@tonic-gate 	 */
670Sstevel@tonic-gate 	long	r_pc;		/* program counter */
680Sstevel@tonic-gate 	long	r_npc;		/* next program counter */
690Sstevel@tonic-gate 	int	r_y;		/* the y register */
700Sstevel@tonic-gate };
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #define	r_ps	r_tstate
730Sstevel@tonic-gate #define	r_sp	r_o6
740Sstevel@tonic-gate 
750Sstevel@tonic-gate #endif	/* _ASM */
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #ifdef _KERNEL
780Sstevel@tonic-gate 
790Sstevel@tonic-gate #define	lwptoregs(lwp)	((struct regs *)((lwp)->lwp_regs))
800Sstevel@tonic-gate #define	lwptofpu(lwp)	((kfpu_t *)((lwp)->lwp_fpu))
810Sstevel@tonic-gate 
820Sstevel@tonic-gate /*
830Sstevel@tonic-gate  * Macros for saving/restoring registers.
840Sstevel@tonic-gate  */
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #define	SAVE_GLOBALS(RP) \
870Sstevel@tonic-gate 	stx	%g1, [RP + G1_OFF]; \
880Sstevel@tonic-gate 	stx	%g2, [RP + G2_OFF]; \
890Sstevel@tonic-gate 	stx	%g3, [RP + G3_OFF]; \
900Sstevel@tonic-gate 	stx	%g4, [RP + G4_OFF]; \
910Sstevel@tonic-gate 	stx	%g5, [RP + G5_OFF]; \
920Sstevel@tonic-gate 	stx	%g6, [RP + G6_OFF]; \
930Sstevel@tonic-gate 	stx	%g7, [RP + G7_OFF]; \
940Sstevel@tonic-gate 	mov	%y, %g1; \
950Sstevel@tonic-gate 	st	%g1, [RP + Y_OFF];
960Sstevel@tonic-gate 
970Sstevel@tonic-gate #define	RESTORE_GLOBALS(RP) \
980Sstevel@tonic-gate 	ld	[RP + Y_OFF], %g1; \
990Sstevel@tonic-gate 	mov	%g1, %y; \
1000Sstevel@tonic-gate 	ldx	[RP + G1_OFF], %g1; \
1010Sstevel@tonic-gate 	ldx	[RP + G2_OFF], %g2; \
1020Sstevel@tonic-gate 	ldx	[RP + G3_OFF], %g3; \
1030Sstevel@tonic-gate 	ldx	[RP + G4_OFF], %g4; \
1040Sstevel@tonic-gate 	ldx	[RP + G5_OFF], %g5; \
1050Sstevel@tonic-gate 	ldx	[RP + G6_OFF], %g6; \
1060Sstevel@tonic-gate 	ldx	[RP + G7_OFF], %g7;
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate #define	SAVE_OUTS(RP) \
1090Sstevel@tonic-gate 	stx	%i0, [RP + O0_OFF]; \
1100Sstevel@tonic-gate 	stx	%i1, [RP + O1_OFF]; \
1110Sstevel@tonic-gate 	stx	%i2, [RP + O2_OFF]; \
1120Sstevel@tonic-gate 	stx	%i3, [RP + O3_OFF]; \
1130Sstevel@tonic-gate 	stx	%i4, [RP + O4_OFF]; \
1140Sstevel@tonic-gate 	stx	%i5, [RP + O5_OFF]; \
1150Sstevel@tonic-gate 	stx	%i6, [RP + O6_OFF]; \
1160Sstevel@tonic-gate 	stx	%i7, [RP + O7_OFF];
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate #define	RESTORE_OUTS(RP) \
1190Sstevel@tonic-gate 	ldx	[RP + O0_OFF], %i0; \
1200Sstevel@tonic-gate 	ldx	[RP + O1_OFF], %i1; \
1210Sstevel@tonic-gate 	ldx	[RP + O2_OFF], %i2; \
1220Sstevel@tonic-gate 	ldx	[RP + O3_OFF], %i3; \
1230Sstevel@tonic-gate 	ldx	[RP + O4_OFF], %i4; \
1240Sstevel@tonic-gate 	ldx	[RP + O5_OFF], %i5; \
1250Sstevel@tonic-gate 	ldx	[RP + O6_OFF], %i6; \
1260Sstevel@tonic-gate 	ldx	[RP + O7_OFF], %i7;
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate #define	SAVE_V8WINDOW(SBP) \
1290Sstevel@tonic-gate 	st	%l0, [SBP + (0*4)]; \
1300Sstevel@tonic-gate 	st	%l1, [SBP + (1*4)]; \
1310Sstevel@tonic-gate 	st	%l2, [SBP + (2*4)]; \
1320Sstevel@tonic-gate 	st	%l3, [SBP + (3*4)]; \
1330Sstevel@tonic-gate 	st	%l4, [SBP + (4*4)]; \
1340Sstevel@tonic-gate 	st	%l5, [SBP + (5*4)]; \
1350Sstevel@tonic-gate 	st	%l6, [SBP + (6*4)]; \
1360Sstevel@tonic-gate 	st	%l7, [SBP + (7*4)]; \
1370Sstevel@tonic-gate 	st	%i0, [SBP + (8*4)]; \
1380Sstevel@tonic-gate 	st	%i1, [SBP + (9*4)]; \
1390Sstevel@tonic-gate 	st	%i2, [SBP + (10*4)]; \
1400Sstevel@tonic-gate 	st	%i3, [SBP + (11*4)]; \
1410Sstevel@tonic-gate 	st	%i4, [SBP + (12*4)]; \
1420Sstevel@tonic-gate 	st	%i5, [SBP + (13*4)]; \
1430Sstevel@tonic-gate 	st	%i6, [SBP + (14*4)]; \
1440Sstevel@tonic-gate 	st	%i7, [SBP + (15*4)];
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate #define	SAVE_V8WINDOW_ASI(SBP) \
1470Sstevel@tonic-gate 	sta	%l0, [SBP + (0*4)]%asi; \
1480Sstevel@tonic-gate 	sta	%l1, [SBP + (1*4)]%asi; \
1490Sstevel@tonic-gate 	sta	%l2, [SBP + (2*4)]%asi; \
1500Sstevel@tonic-gate 	sta	%l3, [SBP + (3*4)]%asi; \
1510Sstevel@tonic-gate 	sta	%l4, [SBP + (4*4)]%asi; \
1520Sstevel@tonic-gate 	sta	%l5, [SBP + (5*4)]%asi; \
1530Sstevel@tonic-gate 	sta	%l6, [SBP + (6*4)]%asi; \
1540Sstevel@tonic-gate 	sta	%l7, [SBP + (7*4)]%asi; \
1550Sstevel@tonic-gate 	sta	%i0, [SBP + (8*4)]%asi; \
1560Sstevel@tonic-gate 	sta	%i1, [SBP + (9*4)]%asi; \
1570Sstevel@tonic-gate 	sta	%i2, [SBP + (10*4)]%asi; \
1580Sstevel@tonic-gate 	sta	%i3, [SBP + (11*4)]%asi; \
1590Sstevel@tonic-gate 	sta	%i4, [SBP + (12*4)]%asi; \
1600Sstevel@tonic-gate 	sta	%i5, [SBP + (13*4)]%asi; \
1610Sstevel@tonic-gate 	sta	%i6, [SBP + (14*4)]%asi; \
1620Sstevel@tonic-gate 	sta	%i7, [SBP + (15*4)]%asi;
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate #define	RESTORE_V8WINDOW(SBP) \
1650Sstevel@tonic-gate 	ld	[SBP + (0*4)], %l0; \
1660Sstevel@tonic-gate 	ld	[SBP + (1*4)], %l1; \
1670Sstevel@tonic-gate 	ld	[SBP + (2*4)], %l2; \
1680Sstevel@tonic-gate 	ld	[SBP + (3*4)], %l3; \
1690Sstevel@tonic-gate 	ld	[SBP + (4*4)], %l4; \
1700Sstevel@tonic-gate 	ld	[SBP + (5*4)], %l5; \
1710Sstevel@tonic-gate 	ld	[SBP + (6*4)], %l6; \
1720Sstevel@tonic-gate 	ld	[SBP + (7*4)], %l7; \
1730Sstevel@tonic-gate 	ld	[SBP + (8*4)], %i0; \
1740Sstevel@tonic-gate 	ld	[SBP + (9*4)], %i1; \
1750Sstevel@tonic-gate 	ld	[SBP + (10*4)], %i2; \
1760Sstevel@tonic-gate 	ld	[SBP + (11*4)], %i3; \
1770Sstevel@tonic-gate 	ld	[SBP + (12*4)], %i4; \
1780Sstevel@tonic-gate 	ld	[SBP + (13*4)], %i5; \
1790Sstevel@tonic-gate 	ld	[SBP + (14*4)], %i6; \
1800Sstevel@tonic-gate 	ld	[SBP + (15*4)], %i7;
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate #define	SAVE_V9WINDOW(SBP) \
1830Sstevel@tonic-gate 	stx	%l0, [SBP + (0*8)]; \
1840Sstevel@tonic-gate 	stx	%l1, [SBP + (1*8)]; \
1850Sstevel@tonic-gate 	stx	%l2, [SBP + (2*8)]; \
1860Sstevel@tonic-gate 	stx	%l3, [SBP + (3*8)]; \
1870Sstevel@tonic-gate 	stx	%l4, [SBP + (4*8)]; \
1880Sstevel@tonic-gate 	stx	%l5, [SBP + (5*8)]; \
1890Sstevel@tonic-gate 	stx	%l6, [SBP + (6*8)]; \
1900Sstevel@tonic-gate 	stx	%l7, [SBP + (7*8)]; \
1910Sstevel@tonic-gate 	stx	%i0, [SBP + (8*8)]; \
1920Sstevel@tonic-gate 	stx	%i1, [SBP + (9*8)]; \
1930Sstevel@tonic-gate 	stx	%i2, [SBP + (10*8)]; \
1940Sstevel@tonic-gate 	stx	%i3, [SBP + (11*8)]; \
1950Sstevel@tonic-gate 	stx	%i4, [SBP + (12*8)]; \
1960Sstevel@tonic-gate 	stx	%i5, [SBP + (13*8)]; \
1970Sstevel@tonic-gate 	stx	%i6, [SBP + (14*8)]; \
1980Sstevel@tonic-gate 	stx	%i7, [SBP + (15*8)];
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate #define	SAVE_V9WINDOW_ASI(SBP) \
2010Sstevel@tonic-gate 	stxa	%l0, [SBP + (0*8)]%asi; \
2020Sstevel@tonic-gate 	stxa	%l1, [SBP + (1*8)]%asi; \
2030Sstevel@tonic-gate 	stxa	%l2, [SBP + (2*8)]%asi; \
2040Sstevel@tonic-gate 	stxa	%l3, [SBP + (3*8)]%asi; \
2050Sstevel@tonic-gate 	stxa	%l4, [SBP + (4*8)]%asi; \
2060Sstevel@tonic-gate 	stxa	%l5, [SBP + (5*8)]%asi; \
2070Sstevel@tonic-gate 	stxa	%l6, [SBP + (6*8)]%asi; \
2080Sstevel@tonic-gate 	stxa	%l7, [SBP + (7*8)]%asi; \
2090Sstevel@tonic-gate 	stxa	%i0, [SBP + (8*8)]%asi; \
2100Sstevel@tonic-gate 	stxa	%i1, [SBP + (9*8)]%asi; \
2110Sstevel@tonic-gate 	stxa	%i2, [SBP + (10*8)]%asi; \
2120Sstevel@tonic-gate 	stxa	%i3, [SBP + (11*8)]%asi; \
2130Sstevel@tonic-gate 	stxa	%i4, [SBP + (12*8)]%asi; \
2140Sstevel@tonic-gate 	stxa	%i5, [SBP + (13*8)]%asi; \
2150Sstevel@tonic-gate 	stxa	%i6, [SBP + (14*8)]%asi; \
2160Sstevel@tonic-gate 	stxa	%i7, [SBP + (15*8)]%asi;
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate #define	RESTORE_V9WINDOW(SBP) \
2190Sstevel@tonic-gate 	ldx	[SBP + (0*8)], %l0; \
2200Sstevel@tonic-gate 	ldx	[SBP + (1*8)], %l1; \
2210Sstevel@tonic-gate 	ldx	[SBP + (2*8)], %l2; \
2220Sstevel@tonic-gate 	ldx	[SBP + (3*8)], %l3; \
2230Sstevel@tonic-gate 	ldx	[SBP + (4*8)], %l4; \
2240Sstevel@tonic-gate 	ldx	[SBP + (5*8)], %l5; \
2250Sstevel@tonic-gate 	ldx	[SBP + (6*8)], %l6; \
2260Sstevel@tonic-gate 	ldx	[SBP + (7*8)], %l7; \
2270Sstevel@tonic-gate 	ldx	[SBP + (8*8)], %i0; \
2280Sstevel@tonic-gate 	ldx	[SBP + (9*8)], %i1; \
2290Sstevel@tonic-gate 	ldx	[SBP + (10*8)], %i2; \
2300Sstevel@tonic-gate 	ldx	[SBP + (11*8)], %i3; \
2310Sstevel@tonic-gate 	ldx	[SBP + (12*8)], %i4; \
2320Sstevel@tonic-gate 	ldx	[SBP + (13*8)], %i5; \
2330Sstevel@tonic-gate 	ldx	[SBP + (14*8)], %i6; \
2340Sstevel@tonic-gate 	ldx	[SBP + (15*8)], %i7;
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate #define	STORE_FPREGS(FP) \
2370Sstevel@tonic-gate 	std	%f0, [FP]; \
2380Sstevel@tonic-gate 	std	%f2, [FP + 8]; \
2390Sstevel@tonic-gate 	std	%f4, [FP + 16]; \
2400Sstevel@tonic-gate 	std	%f6, [FP + 24]; \
2410Sstevel@tonic-gate 	std	%f8, [FP + 32]; \
2420Sstevel@tonic-gate 	std	%f10, [FP + 40]; \
2430Sstevel@tonic-gate 	std	%f12, [FP + 48]; \
2440Sstevel@tonic-gate 	std	%f14, [FP + 56]; \
2450Sstevel@tonic-gate 	std	%f16, [FP + 64]; \
2460Sstevel@tonic-gate 	std	%f18, [FP + 72]; \
2470Sstevel@tonic-gate 	std	%f20, [FP + 80]; \
2480Sstevel@tonic-gate 	std	%f22, [FP + 88]; \
2490Sstevel@tonic-gate 	std	%f24, [FP + 96]; \
2500Sstevel@tonic-gate 	std	%f26, [FP + 104]; \
2510Sstevel@tonic-gate 	std	%f28, [FP + 112]; \
2520Sstevel@tonic-gate 	std	%f30, [FP + 120]; \
2530Sstevel@tonic-gate 	std	%d32, [FP + 128]; \
2540Sstevel@tonic-gate 	std	%d34, [FP + 136]; \
2550Sstevel@tonic-gate 	std	%d36, [FP + 144]; \
2560Sstevel@tonic-gate 	std	%d38, [FP + 152]; \
2570Sstevel@tonic-gate 	std	%d40, [FP + 160]; \
2580Sstevel@tonic-gate 	std	%d42, [FP + 168]; \
2590Sstevel@tonic-gate 	std	%d44, [FP + 176]; \
2600Sstevel@tonic-gate 	std	%d46, [FP + 184]; \
2610Sstevel@tonic-gate 	std	%d48, [FP + 192]; \
2620Sstevel@tonic-gate 	std	%d50, [FP + 200]; \
2630Sstevel@tonic-gate 	std	%d52, [FP + 208]; \
2640Sstevel@tonic-gate 	std	%d54, [FP + 216]; \
2650Sstevel@tonic-gate 	std	%d56, [FP + 224]; \
2660Sstevel@tonic-gate 	std	%d58, [FP + 232]; \
2670Sstevel@tonic-gate 	std	%d60, [FP + 240]; \
2680Sstevel@tonic-gate 	std	%d62, [FP + 248];
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate #define	LOAD_FPREGS(FP) \
2710Sstevel@tonic-gate 	ldd	[FP], %f0; \
2720Sstevel@tonic-gate 	ldd	[FP + 8], %f2; \
2730Sstevel@tonic-gate 	ldd	[FP + 16], %f4; \
2740Sstevel@tonic-gate 	ldd	[FP + 24], %f6; \
2750Sstevel@tonic-gate 	ldd	[FP + 32], %f8; \
2760Sstevel@tonic-gate 	ldd	[FP + 40], %f10; \
2770Sstevel@tonic-gate 	ldd	[FP + 48], %f12; \
2780Sstevel@tonic-gate 	ldd	[FP + 56], %f14; \
2790Sstevel@tonic-gate 	ldd	[FP + 64], %f16; \
2800Sstevel@tonic-gate 	ldd	[FP + 72], %f18; \
2810Sstevel@tonic-gate 	ldd	[FP + 80], %f20; \
2820Sstevel@tonic-gate 	ldd	[FP + 88], %f22; \
2830Sstevel@tonic-gate 	ldd	[FP + 96], %f24; \
2840Sstevel@tonic-gate 	ldd	[FP + 104], %f26; \
2850Sstevel@tonic-gate 	ldd	[FP + 112], %f28; \
2860Sstevel@tonic-gate 	ldd	[FP + 120], %f30; \
2870Sstevel@tonic-gate 	ldd	[FP + 128], %d32; \
2880Sstevel@tonic-gate 	ldd	[FP + 136], %d34; \
2890Sstevel@tonic-gate 	ldd	[FP + 144], %d36; \
2900Sstevel@tonic-gate 	ldd	[FP + 152], %d38; \
2910Sstevel@tonic-gate 	ldd	[FP + 160], %d40; \
2920Sstevel@tonic-gate 	ldd	[FP + 168], %d42; \
2930Sstevel@tonic-gate 	ldd	[FP + 176], %d44; \
2940Sstevel@tonic-gate 	ldd	[FP + 184], %d46; \
2950Sstevel@tonic-gate 	ldd	[FP + 192], %d48; \
2960Sstevel@tonic-gate 	ldd	[FP + 200], %d50; \
2970Sstevel@tonic-gate 	ldd	[FP + 208], %d52; \
2980Sstevel@tonic-gate 	ldd	[FP + 216], %d54; \
2990Sstevel@tonic-gate 	ldd	[FP + 224], %d56; \
3000Sstevel@tonic-gate 	ldd	[FP + 232], %d58; \
3010Sstevel@tonic-gate 	ldd	[FP + 240], %d60; \
3020Sstevel@tonic-gate 	ldd	[FP + 248], %d62;
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate #define	STORE_DL_FPREGS(FP) \
3050Sstevel@tonic-gate 	std	%f0, [FP]; \
3060Sstevel@tonic-gate 	std	%f2, [FP + 8]; \
3070Sstevel@tonic-gate 	std	%f4, [FP + 16]; \
3080Sstevel@tonic-gate 	std	%f6, [FP + 24]; \
3090Sstevel@tonic-gate 	std	%f8, [FP + 32]; \
3100Sstevel@tonic-gate 	std	%f10, [FP + 40]; \
3110Sstevel@tonic-gate 	std	%f12, [FP + 48]; \
3120Sstevel@tonic-gate 	std	%f14, [FP + 56]; \
3130Sstevel@tonic-gate 	std	%f16, [FP + 64]; \
3140Sstevel@tonic-gate 	std	%f18, [FP + 72]; \
3150Sstevel@tonic-gate 	std	%f20, [FP + 80]; \
3160Sstevel@tonic-gate 	std	%f22, [FP + 88]; \
3170Sstevel@tonic-gate 	std	%f24, [FP + 96]; \
3180Sstevel@tonic-gate 	std	%f26, [FP + 104]; \
3190Sstevel@tonic-gate 	std	%f28, [FP + 112]; \
3200Sstevel@tonic-gate 	std	%f30, [FP + 120];
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate #define	STORE_DU_FPREGS(FP) \
3230Sstevel@tonic-gate 	std	%d32, [FP + 128]; \
3240Sstevel@tonic-gate 	std	%d34, [FP + 136]; \
3250Sstevel@tonic-gate 	std	%d36, [FP + 144]; \
3260Sstevel@tonic-gate 	std	%d38, [FP + 152]; \
3270Sstevel@tonic-gate 	std	%d40, [FP + 160]; \
3280Sstevel@tonic-gate 	std	%d42, [FP + 168]; \
3290Sstevel@tonic-gate 	std	%d44, [FP + 176]; \
3300Sstevel@tonic-gate 	std	%d46, [FP + 184]; \
3310Sstevel@tonic-gate 	std	%d48, [FP + 192]; \
3320Sstevel@tonic-gate 	std	%d50, [FP + 200]; \
3330Sstevel@tonic-gate 	std	%d52, [FP + 208]; \
3340Sstevel@tonic-gate 	std	%d54, [FP + 216]; \
3350Sstevel@tonic-gate 	std	%d56, [FP + 224]; \
3360Sstevel@tonic-gate 	std	%d58, [FP + 232]; \
3370Sstevel@tonic-gate 	std	%d60, [FP + 240]; \
3380Sstevel@tonic-gate 	std	%d62, [FP + 248];
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate #define	LOAD_DL_FPREGS(FP) \
3410Sstevel@tonic-gate 	ldd	[FP], %f0; \
3420Sstevel@tonic-gate 	ldd	[FP + 8], %f2; \
3430Sstevel@tonic-gate 	ldd	[FP + 16], %f4; \
3440Sstevel@tonic-gate 	ldd	[FP + 24], %f6; \
3450Sstevel@tonic-gate 	ldd	[FP + 32], %f8; \
3460Sstevel@tonic-gate 	ldd	[FP + 40], %f10; \
3470Sstevel@tonic-gate 	ldd	[FP + 48], %f12; \
3480Sstevel@tonic-gate 	ldd	[FP + 56], %f14; \
3490Sstevel@tonic-gate 	ldd	[FP + 64], %f16; \
3500Sstevel@tonic-gate 	ldd	[FP + 72], %f18; \
3510Sstevel@tonic-gate 	ldd	[FP + 80], %f20; \
3520Sstevel@tonic-gate 	ldd	[FP + 88], %f22; \
3530Sstevel@tonic-gate 	ldd	[FP + 96], %f24; \
3540Sstevel@tonic-gate 	ldd	[FP + 104], %f26; \
3550Sstevel@tonic-gate 	ldd	[FP + 112], %f28; \
3560Sstevel@tonic-gate 	ldd	[FP + 120], %f30;
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate #define	LOAD_DU_FPREGS(FP) \
3590Sstevel@tonic-gate 	ldd	[FP + 128], %d32; \
3600Sstevel@tonic-gate 	ldd	[FP + 136], %d34; \
3610Sstevel@tonic-gate 	ldd	[FP + 144], %d36; \
3620Sstevel@tonic-gate 	ldd	[FP + 152], %d38; \
3630Sstevel@tonic-gate 	ldd	[FP + 160], %d40; \
3640Sstevel@tonic-gate 	ldd	[FP + 168], %d42; \
3650Sstevel@tonic-gate 	ldd	[FP + 176], %d44; \
3660Sstevel@tonic-gate 	ldd	[FP + 184], %d46; \
3670Sstevel@tonic-gate 	ldd	[FP + 192], %d48; \
3680Sstevel@tonic-gate 	ldd	[FP + 200], %d50; \
3690Sstevel@tonic-gate 	ldd	[FP + 208], %d52; \
3700Sstevel@tonic-gate 	ldd	[FP + 216], %d54; \
3710Sstevel@tonic-gate 	ldd	[FP + 224], %d56; \
3720Sstevel@tonic-gate 	ldd	[FP + 232], %d58; \
3730Sstevel@tonic-gate 	ldd	[FP + 240], %d60; \
3740Sstevel@tonic-gate 	ldd	[FP + 248], %d62;
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate #endif /* _KERNEL */
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate /*
3790Sstevel@tonic-gate  * V9 privileged registers
3800Sstevel@tonic-gate  */
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate /*
3830Sstevel@tonic-gate  * Condition Codes Register (CCR)
3840Sstevel@tonic-gate  *
3850Sstevel@tonic-gate  *	|-------------------------------|
3860Sstevel@tonic-gate  *	|	XCC	|	ICC	|
3870Sstevel@tonic-gate  *	| N | Z | V | C | N | Z | V | C |
3880Sstevel@tonic-gate  *	|---|---|---|---|---|---|---|---|
3890Sstevel@tonic-gate  *	7   6   5   4   3   2   1   0
3900Sstevel@tonic-gate  */
3910Sstevel@tonic-gate #define	CCR_IC		0x01	/* 32b carry */
3920Sstevel@tonic-gate #define	CCR_IV		0x02	/* 32b overflow */
3930Sstevel@tonic-gate #define	CCR_IZ		0x04	/* 32b zero */
3940Sstevel@tonic-gate #define	CCR_IN		0x08	/* 32b negative */
3950Sstevel@tonic-gate #define	CCR_XC		0x10	/* 64b carry */
3960Sstevel@tonic-gate #define	CCR_XV		0x20	/* 64b overflow */
3970Sstevel@tonic-gate #define	CCR_XZ		0x40	/* 64b zero */
3980Sstevel@tonic-gate #define	CCR_XN		0x80	/* 64b negative */
3990Sstevel@tonic-gate #define	CCR_ICC		0x0F
4000Sstevel@tonic-gate #define	CCR_XCC		0xF0
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate /*
4040Sstevel@tonic-gate  * Processor State Register (PSTATE)
4050Sstevel@tonic-gate  *
4060Sstevel@tonic-gate  *   |-------------------------------------------------------------|
4070Sstevel@tonic-gate  *   |  IG | MG | CLE | TLE | MM | RED | PEF | AM | PRIV | IE | AG |
4080Sstevel@tonic-gate  *   |-----|----|-----|-----|----|-----|-----|----|------|----|----|
4090Sstevel@tonic-gate  *	11   10    9     8   7  6   5     4     3     2     1    0
4100Sstevel@tonic-gate  *
4110Sstevel@tonic-gate  * Note that the IG, MG, RED and AG fields are not applicable to sun4v
4120Sstevel@tonic-gate  * compliant processors.
4130Sstevel@tonic-gate  */
4140Sstevel@tonic-gate #ifndef GLREG
4150Sstevel@tonic-gate #define	PSTATE_AG	0x001		/* alternate globals */
4160Sstevel@tonic-gate #endif /* GLREG */
4170Sstevel@tonic-gate 
4180Sstevel@tonic-gate #define	PSTATE_IE	0x002		/* interrupt enable */
4190Sstevel@tonic-gate #define	PSTATE_PRIV	0x004		/* privileged mode */
4200Sstevel@tonic-gate #define	PSTATE_AM	0x008		/* use 32b address mask */
4210Sstevel@tonic-gate #define	PSTATE_PEF	0x010		/* fp enable */
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate #ifndef GLREG
4240Sstevel@tonic-gate #define	PSTATE_RED	0x020		/* red mode */
4250Sstevel@tonic-gate #endif /* GLREG */
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate #define	PSTATE_MM	0x0C0		/* memory model */
4280Sstevel@tonic-gate #define	PSTATE_TLE	0x100		/* trap little endian */
4290Sstevel@tonic-gate #define	PSTATE_CLE	0x200		/* current little endian */
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate #ifndef GLREG
4320Sstevel@tonic-gate #define	PSTATE_MG	0x400		/* MMU globals */
4330Sstevel@tonic-gate #define	PSTATE_IG	0x800		/* interrupt globals */
4340Sstevel@tonic-gate #endif /* GLREG */
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate #define	PSTATE_BITS \
4370Sstevel@tonic-gate "\020\014IG\013MG\012CLE\011TLE\010MM-RMO\
4380Sstevel@tonic-gate \07MM-PSO\06RED\05PEF\04AM\03PRIV\02IE\01AG"
4390Sstevel@tonic-gate 
4400Sstevel@tonic-gate /*
4410Sstevel@tonic-gate  * Definition of MM (Memory Mode) bit field of pstate.
4420Sstevel@tonic-gate  */
443*9351SPrashanth.Sreenivasa@Sun.COM #define	PSTATE_MM_TSO	0x00		/* total store ordering */
444*9351SPrashanth.Sreenivasa@Sun.COM #define	PSTATE_MM_PSO	0x40		/* partial store ordering */
4450Sstevel@tonic-gate #define	PSTATE_MM_RMO	0x80		/* relaxed memory ordering */
446*9351SPrashanth.Sreenivasa@Sun.COM #define	PSTATE_MM_WC	0xC0		/* weak consistency */
4470Sstevel@tonic-gate 
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate /*
4500Sstevel@tonic-gate  * Trap State Register (TSTATE)
4510Sstevel@tonic-gate  *
4520Sstevel@tonic-gate  *	|------------------------------------------|
4530Sstevel@tonic-gate  *	| GL | CCR | ASI | --- | PSTATE | -- | CWP |
4540Sstevel@tonic-gate  *	|----|-----|-----|-----|--------|----|-----|
4550Sstevel@tonic-gate  *	42 40 39 32 31 24 23 20 19	  8 7  5 4   0
4560Sstevel@tonic-gate  *
4570Sstevel@tonic-gate  * Note that the GL field is applicable to sun4v compliant processors only.
4580Sstevel@tonic-gate  */
4590Sstevel@tonic-gate #define	TSTATE_CWP_MASK		0x01F
4600Sstevel@tonic-gate #define	TSTATE_CWP_SHIFT	0
4610Sstevel@tonic-gate #define	TSTATE_PSTATE_MASK	0xFFF
4620Sstevel@tonic-gate #define	TSTATE_PSTATE_SHIFT	8
4630Sstevel@tonic-gate #define	TSTATE_ASI_MASK		0x0FF
4640Sstevel@tonic-gate #define	TSTATE_ASI_SHIFT	24
4650Sstevel@tonic-gate #define	TSTATE_CCR_MASK		0x0FF
4660Sstevel@tonic-gate #define	TSTATE_CCR_SHIFT	32
4670Sstevel@tonic-gate 
4680Sstevel@tonic-gate #ifdef GLREG
4690Sstevel@tonic-gate #define	TSTATE_GL_MASK		0x7
4700Sstevel@tonic-gate #define	TSTATE_GL_SHIFT		40
4710Sstevel@tonic-gate #endif /* GLREG */
4720Sstevel@tonic-gate 
4730Sstevel@tonic-gate /*
4740Sstevel@tonic-gate  * Some handy tstate macros
4750Sstevel@tonic-gate  */
4760Sstevel@tonic-gate #define	TSTATE_AG	(PSTATE_AG << TSTATE_PSTATE_SHIFT)
4770Sstevel@tonic-gate #define	TSTATE_IE	(PSTATE_IE << TSTATE_PSTATE_SHIFT)
4780Sstevel@tonic-gate #define	TSTATE_PRIV	(PSTATE_PRIV << TSTATE_PSTATE_SHIFT)
4790Sstevel@tonic-gate #define	TSTATE_AM	(PSTATE_AM << TSTATE_PSTATE_SHIFT)
4800Sstevel@tonic-gate #define	TSTATE_PEF	(PSTATE_PEF << TSTATE_PSTATE_SHIFT)
481*9351SPrashanth.Sreenivasa@Sun.COM #define	TSTATE_MM	(PSTATE_MM << TSTATE_PSTATE_SHIFT)
482*9351SPrashanth.Sreenivasa@Sun.COM #define	TSTATE_MM_TSO	(PSTATE_MM_TSO << TSTATE_PSTATE_SHIFT)
483*9351SPrashanth.Sreenivasa@Sun.COM #define	TSTATE_MM_WC	(PSTATE_MM_WC << TSTATE_PSTATE_SHIFT)
4840Sstevel@tonic-gate #define	TSTATE_MG	(PSTATE_MG << TSTATE_PSTATE_SHIFT)
4850Sstevel@tonic-gate #define	TSTATE_IG	(PSTATE_IG << TSTATE_PSTATE_SHIFT)
4860Sstevel@tonic-gate #define	TSTATE_CWP	TSTATE_CWP_MASK
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate /*
4890Sstevel@tonic-gate  * as is 64b, but cc is 32b, so we need this hack.
4900Sstevel@tonic-gate  */
4910Sstevel@tonic-gate #ifndef _ASM
4920Sstevel@tonic-gate #define	TSTATE_ICC	((long long)CCR_ICC << TSTATE_CCR_SHIFT)
4937718SJason.Beloro@Sun.COM #define	TSTATE_XCC	((long long)CCR_XCC << TSTATE_CCR_SHIFT)
4940Sstevel@tonic-gate #define	TSTATE_IC	((long long)CCR_IC << TSTATE_CCR_SHIFT)
4957Sdf157793 #define	TSTATE_IV	((long long)CCR_IV << TSTATE_CCR_SHIFT)
4967718SJason.Beloro@Sun.COM #define	TSTATE_IN	((long long)CCR_IN << TSTATE_CCR_SHIFT)
4977Sdf157793 #define	TSTATE_XV	((long long)CCR_XV << TSTATE_CCR_SHIFT)
4987718SJason.Beloro@Sun.COM #define	TSTATE_XZ	((long long)CCR_XZ << TSTATE_CCR_SHIFT)
4990Sstevel@tonic-gate #else
5000Sstevel@tonic-gate #define	TSTATE_ICC	(CCR_ICC << TSTATE_CCR_SHIFT)
5017718SJason.Beloro@Sun.COM #define	TSTATE_XCC	(CCR_XCC << TSTATE_CCR_SHIFT)
5020Sstevel@tonic-gate #define	TSTATE_IC	(CCR_IC << TSTATE_CCR_SHIFT)
5037Sdf157793 #define	TSTATE_IV	(CCR_IV << TSTATE_CCR_SHIFT)
5047718SJason.Beloro@Sun.COM #define	TSTATE_IN	(CCR_IN << TSTATE_CCR_SHIFT)
5057Sdf157793 #define	TSTATE_XV	(CCR_XV << TSTATE_CCR_SHIFT)
5067718SJason.Beloro@Sun.COM #define	TSTATE_XZ	(CCR_XZ << TSTATE_CCR_SHIFT)
5070Sstevel@tonic-gate #endif
5080Sstevel@tonic-gate #define	TSTATE_V8_UBITS (TSTATE_ICC | TSTATE_PEF)
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate /*
5110Sstevel@tonic-gate  * Initial kernel and user %tstate.
5120Sstevel@tonic-gate  */
5130Sstevel@tonic-gate #define	PTSTATE_KERN_COMMON \
5140Sstevel@tonic-gate 	(PSTATE_PRIV | PSTATE_PEF | PSTATE_MM_TSO)
5150Sstevel@tonic-gate 
5160Sstevel@tonic-gate #define	TSTATE_KERN	\
5170Sstevel@tonic-gate 	(PTSTATE_KERN_COMMON << TSTATE_PSTATE_SHIFT)
5180Sstevel@tonic-gate 
5190Sstevel@tonic-gate #define	PSTATE_KERN	\
5200Sstevel@tonic-gate 	(PTSTATE_KERN_COMMON | PSTATE_PRIV | PSTATE_IE)
5210Sstevel@tonic-gate 
5220Sstevel@tonic-gate #define	TSTATE_USER32	\
523*9351SPrashanth.Sreenivasa@Sun.COM 	(((PSTATE_IE | PSTATE_PEF | PSTATE_AM) << TSTATE_PSTATE_SHIFT) | \
5240Sstevel@tonic-gate 	    ((long long)ASI_PNF << TSTATE_ASI_SHIFT))
5250Sstevel@tonic-gate 
5260Sstevel@tonic-gate #define	TSTATE_USER64	\
527*9351SPrashanth.Sreenivasa@Sun.COM 	(((PSTATE_IE | PSTATE_PEF) << TSTATE_PSTATE_SHIFT) | \
5280Sstevel@tonic-gate 	    ((long long)ASI_PNF << TSTATE_ASI_SHIFT))
5290Sstevel@tonic-gate 
5300Sstevel@tonic-gate #define	USERMODE(x)	(!((x) & TSTATE_PRIV))
5310Sstevel@tonic-gate 
5320Sstevel@tonic-gate /*
5330Sstevel@tonic-gate  * Window State Register (WSTATE)
5340Sstevel@tonic-gate  *
5350Sstevel@tonic-gate  *   |------------|
5360Sstevel@tonic-gate  *   |OTHER|NORMAL|
5370Sstevel@tonic-gate  *   |-----|------|
5380Sstevel@tonic-gate  *    5	  3 2    0
5390Sstevel@tonic-gate  */
5400Sstevel@tonic-gate #define	WSTATE_BAD	0	/* unused */
5410Sstevel@tonic-gate #define	WSTATE_U32	1	/* 32b stack */
5420Sstevel@tonic-gate #define	WSTATE_U64	2	/* 64b stack */
5430Sstevel@tonic-gate #define	WSTATE_CLEAN32	3	/* cleanwin workaround, 32b stack */
5440Sstevel@tonic-gate #define	WSTATE_CLEAN64	4	/* cleanwin workaround, 64b stack */
5450Sstevel@tonic-gate #define	WSTATE_K32	5	/* priv 32b stack */
5460Sstevel@tonic-gate #define	WSTATE_K64	6	/* priv 64b stack */
5470Sstevel@tonic-gate #define	WSTATE_KMIX	7	/* priv mixed stack */
5480Sstevel@tonic-gate 
5490Sstevel@tonic-gate #define	WSTATE_CLEAN_OFFSET	2
5500Sstevel@tonic-gate #define	WSTATE_SHIFT	3	/* normal-to-other shift */
5510Sstevel@tonic-gate #define	WSTATE_MASK	7	/* mask for each set */
5520Sstevel@tonic-gate #define	WSTATE(o, n)	(((o) << WSTATE_SHIFT) | (n))
5530Sstevel@tonic-gate 
5540Sstevel@tonic-gate #define	WSTATE_USER32	WSTATE(WSTATE_BAD, WSTATE_U32)
5550Sstevel@tonic-gate #define	WSTATE_USER64	WSTATE(WSTATE_BAD, WSTATE_U64)
5560Sstevel@tonic-gate #define	WSTATE_KERN	WSTATE(WSTATE_U32, WSTATE_K64)
5570Sstevel@tonic-gate 
5580Sstevel@tonic-gate /*
5590Sstevel@tonic-gate  * Processor Interrupt Level Register (PIL)
5600Sstevel@tonic-gate  *
5610Sstevel@tonic-gate  *   |-----|
5620Sstevel@tonic-gate  *   | PIL |
5630Sstevel@tonic-gate  *   |-----|
5640Sstevel@tonic-gate  *    3   0
5650Sstevel@tonic-gate  */
5660Sstevel@tonic-gate 
5670Sstevel@tonic-gate /*
5680Sstevel@tonic-gate  * Version Register (VER)
5690Sstevel@tonic-gate  *
5700Sstevel@tonic-gate  *   |-------------------------------------------------|
5710Sstevel@tonic-gate  *   | manuf | impl | mask | ---- | maxtl | - | maxwin |
5720Sstevel@tonic-gate  *   |-------|------|------|------|-------|---|--------|
5730Sstevel@tonic-gate  *    63   48 47  32 31  24 23  16 15	8  7 5	4    0
5740Sstevel@tonic-gate  */
5750Sstevel@tonic-gate #define	VER_MANUF	0xFFFF000000000000
5760Sstevel@tonic-gate #define	VER_IMPL	0x0000FFFF00000000
5770Sstevel@tonic-gate #define	VER_MASK	0x00000000FF000000
5780Sstevel@tonic-gate #define	VER_MAXTL	0x000000000000FF00
5790Sstevel@tonic-gate #define	VER_MAXWIN	0x000000000000001F
5801270Sbs21162 #define	VER_MAXTL_SHIFT	8
5811270Sbs21162 #define	VER_MAXTL_MASK	(VER_MAXTL >> VER_MAXTL_SHIFT)
5820Sstevel@tonic-gate 
5830Sstevel@tonic-gate /*
5840Sstevel@tonic-gate  * Tick Register (TICK)
5850Sstevel@tonic-gate  *
5860Sstevel@tonic-gate  *   |---------------|
5870Sstevel@tonic-gate  *   | npt | counter |
5880Sstevel@tonic-gate  *   |-----|---------|
5890Sstevel@tonic-gate  *     63   62      0
5900Sstevel@tonic-gate  *
5910Sstevel@tonic-gate  * Note: UltraSparc III Stick register has the same layout. When
5920Sstevel@tonic-gate  * present, we clear it too.
5930Sstevel@tonic-gate  */
5940Sstevel@tonic-gate 
5950Sstevel@tonic-gate #define	TICK_NPT	0x8000000000000000
5960Sstevel@tonic-gate #define	TICK_COUNTER	0x7FFFFFFFFFFFFFFF
5970Sstevel@tonic-gate 
5980Sstevel@tonic-gate #ifdef	__cplusplus
5990Sstevel@tonic-gate }
6000Sstevel@tonic-gate #endif
6010Sstevel@tonic-gate 
6020Sstevel@tonic-gate #endif	/* _SYS_PRIVREGS_H */
603