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