xref: /original-bsd/sys/sparc/include/pcb.h (revision 92a0c623)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratory.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)pcb.h	7.3 (Berkeley) 04/20/93
17  *
18  * from: $Header: pcb.h,v 1.6 92/11/26 02:04:39 torek Exp $
19  */
20 
21 #include <machine/reg.h>
22 
23 #ifdef notyet
24 #define	PCB_MAXWIN	32	/* architectural limit */
25 #else
26 #define	PCB_MAXWIN	8	/* worried about u area sizes ... */
27 #endif
28 
29 /*
30  * SPARC Process Control Block.
31  *
32  * pcb_uw is positive if there are any user windows that are
33  * are currently in the CPU windows rather than on the user
34  * stack.  Whenever we are running in the kernel with traps
35  * enabled, we decrement pcb_uw for each ``push'' of a CPU
36  * register window into the stack, and we increment it for
37  * each ``pull'' from the stack into the CPU.  (If traps are
38  * disabled, or if we are in user mode, pcb_uw is junk.)
39  *
40  * To ease computing pcb_uw on traps from user mode, we keep track
41  * of the log base 2 of the single bit that is set in %wim.
42  *
43  * If an overflow occurs while the associated user stack pages
44  * are invalid (paged out), we have to store the registers
45  * in a page that is locked in core while the process runs,
46  * i.e., right here in the pcb.  We also need the stack pointer
47  * for the last such window (but only the last, as the others
48  * are in each window) and the count of windows saved.  We
49  * cheat by having a whole window structure for that one %sp.
50  * Thus, to save window pcb_rw[i] to memory, we write it at
51  * pcb_rw[i + 1].rw_in[6].
52  *
53  * pcb_nsaved has three `kinds' of values.  If 0, it means no
54  * registers are in the PCB (though if pcb_uw is positive,
55  * there may be the next time you look).  If positive, it means
56  * there are no user registers in the CPU, but there are some
57  * saved in pcb_rw[].  As a special case, traps that needed
58  * assistance to pull user registers from the stack also store
59  * the registers in pcb_rw[], and set pcb_nsaved to -1.  This
60  * special state is normally short-term: it can only last until the
61  * trap returns, and it can never persist across entry to user code.
62  */
63 struct pcb {
64 	int	pcb_sp;		/* sp (%o6) when swtch() was called */
65 	int	pcb_pc;		/* pc (%o7) when swtch() was called */
66 	int	pcb_psr;	/* %psr when swtch() was called */
67 
68 	caddr_t	pcb_onfault;	/* for copyin/out */
69 
70 	int	pcb_uw;		/* user windows inside CPU */
71 	int	pcb_wim;	/* log2(%wim) */
72 	int	pcb_nsaved;	/* number of windows saved in pcb */
73 
74 #ifdef notdef
75 	int	pcb_winof;	/* number of window overflow traps */
76 	int	pcb_winuf;	/* number of window underflow traps */
77 #endif
78 	int	pcb_pad;	/* pad to doubleword boundary */
79 
80 	/* the following MUST be aligned on a doubleword boundary */
81 	struct	rwindow pcb_rw[PCB_MAXWIN];	/* saved windows */
82 };
83 
84 /*
85  * The pcb is augmented with machine-dependent additional data for
86  * core dumps.  Note that the trapframe here is a copy of the one
87  * from the top of the kernel stack (included here so that the kernel
88  * stack itself need not be dumped).
89  */
90 struct md_coredump {
91 	struct	trapframe md_tf;
92 	struct	fpstate md_fpstate;
93 };
94 
95 #ifdef KERNEL
96 extern struct pcb *cpcb;
97 #endif /* KERNEL */
98