xref: /titanic_41/usr/src/uts/sparc/v9/sys/machpcb.h (revision 8d483882aa3390058094b043f3d62187b5d1de03)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_MACHPCB_H
27 #define	_SYS_MACHPCB_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/stack.h>
32 #include <sys/regset.h>
33 #include <v9/sys/privregs.h>
34 #if defined(__lint)
35 #include <sys/thread.h>
36 #endif /* __lint */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * This file is machine dependent.
44  */
45 
46 /*
47  * Machine dependent per-thread data.
48  */
49 #define	MAXWIN	8	/* max # of windows currently supported */
50 
51 /*
52  * The system actually supports one more than the above number.
53  * There is always one window reserved for trap handlers that
54  * never has to be saved into the pcb struct.
55  */
56 
57 /*
58  * Distance from beginning of thread stack (t_stk) to saved regs struct.
59  */
60 #define	REGOFF	SA(MINFRAME)
61 
62 #ifndef _ASM
63 
64 /*
65  * The struct machpcb is always allocated stack aligned.
66  */
67 typedef struct machpcb {
68 	char	mpcb_frame[REGOFF];
69 	struct	regs mpcb_regs;	/* user's saved registers */
70 	caddr_t	mpcb_wbuf;	/* pointer to wbuf */
71 	caddr_t	mpcb_spbuf[MAXWIN]; /* sp's for each wbuf */
72 	struct	rwindow mpcb_rwin[2]; /* windows used while doing watchpoints */
73 	caddr_t	mpcb_rsp[2];	/* sp's for pcb_rwin[]  */
74 	int	mpcb_wbcnt;	/* number of saved windows in pcb_wbuf */
75 	uint_t	mpcb_wstate;	/* per-lwp %wstate */
76 	kfpu_t	*mpcb_fpu; /* fpu state */
77 	struct	fq mpcb_fpu_q[MAXFPQ]; /* fpu exception queue */
78 	caddr_t	mpcb_illexcaddr; /* address of last illegal instruction */
79 	uint_t	mpcb_illexcinsn; /* last illegal instruction */
80 	int	mpcb_flags;	/* various state flags */
81 	int	mpcb_wocnt;	/* window overflow count */
82 	int	mpcb_wucnt;	/* window underflow count */
83 	kthread_t *mpcb_thread;	/* associated thread */
84 	uint64_t mpcb_pa;	/* pcb physical */
85 	uint64_t mpcb_wbuf_pa;	/* pointer to wbuf - physical */
86 } machpcb_t;
87 #endif /* ! _ASM */
88 
89 /* mpcb_flags */
90 #define	FP_TRAPPED	0x04	/* fp_traps call caused by fp queue */
91 
92 /*
93  * We can use lwp_regs to find the mpcb base.
94  */
95 #ifndef _ASM
96 #define	lwptompcb(lwp)	((struct machpcb *) \
97 	    ((caddr_t)(lwp)->lwp_regs - REGOFF))
98 #endif
99 
100 #ifndef	_ASM
101 struct kmem_cache;
102 extern struct kmem_cache *wbuf32_cache;
103 extern struct kmem_cache *wbuf64_cache;
104 #endif
105 
106 #ifdef	__cplusplus
107 }
108 #endif
109 
110 #endif	/* _SYS_MACHPCB_H */
111