xref: /titanic_41/usr/src/uts/sparc/v9/sys/machpcb.h (revision eb86370ff1b2ecb55b4bf522c5c7537a00195636)
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 2009 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 #include <sys/stack.h>
30 #include <sys/regset.h>
31 #include <v9/sys/privregs.h>
32 #if defined(__lint)
33 #include <sys/thread.h>
34 #endif /* __lint */
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * This file is machine dependent.
42  */
43 
44 /*
45  * Machine dependent per-thread data.
46  */
47 #define	MAXWIN	8	/* max # of windows currently supported */
48 
49 /*
50  * The system actually supports one more than the above number.
51  * There is always one window reserved for trap handlers that
52  * never has to be saved into the pcb struct.
53  */
54 
55 /*
56  * Distance from beginning of thread stack (t_stk) to saved regs struct.
57  */
58 #define	REGOFF	SA(MINFRAME)
59 
60 #ifndef _ASM
61 
62 /*
63  * The struct machpcb is always allocated stack aligned.
64  */
65 typedef struct machpcb {
66 	char	mpcb_frame[REGOFF];
67 	struct	regs mpcb_regs;	/* user's saved registers */
68 	caddr_t	mpcb_wbuf;	/* pointer to wbuf */
69 	caddr_t	mpcb_spbuf[MAXWIN]; /* sp's for each wbuf */
70 	struct	rwindow mpcb_rwin[2]; /* windows used while doing watchpoints */
71 	caddr_t	mpcb_rsp[2];	/* sp's for pcb_rwin[]  */
72 	int	mpcb_wbcnt;	/* number of saved windows in pcb_wbuf */
73 	uint_t	mpcb_wstate;	/* per-lwp %wstate */
74 	kfpu_t	*mpcb_fpu; /* fpu state */
75 	struct	fq mpcb_fpu_q[MAXFPQ]; /* fpu exception queue */
76 	caddr_t	mpcb_illexcaddr; /* address of last illegal instruction */
77 	uint_t	mpcb_illexcinsn; /* last illegal instruction */
78 	uint_t	mpcb_illexccnt; /* count of illegal instruction attempts */
79 	int	mpcb_flags;	/* various state flags */
80 	int	mpcb_wocnt;	/* window overflow count */
81 	int	mpcb_wucnt;	/* window underflow count */
82 	kthread_t *mpcb_thread;	/* associated thread */
83 	uint64_t mpcb_pa;	/* pcb physical */
84 	uint64_t mpcb_wbuf_pa;	/* pointer to wbuf - physical */
85 } machpcb_t;
86 #endif /* ! _ASM */
87 
88 /* mpcb_flags */
89 #define	FP_TRAPPED	0x04	/* fp_traps call caused by fp queue */
90 
91 /*
92  * We can use lwp_regs to find the mpcb base.
93  */
94 #ifndef _ASM
95 #define	lwptompcb(lwp)	((struct machpcb *) \
96 	    ((caddr_t)(lwp)->lwp_regs - REGOFF))
97 #endif
98 
99 #ifndef	_ASM
100 struct kmem_cache;
101 extern struct kmem_cache *wbuf32_cache;
102 extern struct kmem_cache *wbuf64_cache;
103 #endif
104 
105 #ifdef	__cplusplus
106 }
107 #endif
108 
109 #endif	/* _SYS_MACHPCB_H */
110