xref: /csrg-svn/sys/sparc/include/pcb.h (revision 59210)
155122Storek /*
255122Storek  * Copyright (c) 1992 The Regents of the University of California.
355122Storek  * All rights reserved.
455122Storek  *
555122Storek  * This software was developed by the Computer Systems Engineering group
655122Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
755122Storek  * contributed to Berkeley.
855122Storek  *
955501Sbostic  * All advertising materials mentioning features or use of this software
1055501Sbostic  * must display the following acknowledgement:
1155501Sbostic  *	This product includes software developed by the University of
12*59210Storek  *	California, Lawrence Berkeley Laboratory.
1355501Sbostic  *
1455122Storek  * %sccs.include.redist.c%
1555122Storek  *
16*59210Storek  *	@(#)pcb.h	7.3 (Berkeley) 04/20/93
1755122Storek  *
18*59210Storek  * from: $Header: pcb.h,v 1.6 92/11/26 02:04:39 torek Exp $
1955122Storek  */
2055122Storek 
2155122Storek #include <machine/reg.h>
2255122Storek 
2355122Storek #ifdef notyet
2455122Storek #define	PCB_MAXWIN	32	/* architectural limit */
2555122Storek #else
2655122Storek #define	PCB_MAXWIN	8	/* worried about u area sizes ... */
2755122Storek #endif
2855122Storek 
2955122Storek /*
3055122Storek  * SPARC Process Control Block.
3155122Storek  *
3255122Storek  * pcb_uw is positive if there are any user windows that are
3355122Storek  * are currently in the CPU windows rather than on the user
3455122Storek  * stack.  Whenever we are running in the kernel with traps
3555122Storek  * enabled, we decrement pcb_uw for each ``push'' of a CPU
3655122Storek  * register window into the stack, and we increment it for
3755122Storek  * each ``pull'' from the stack into the CPU.  (If traps are
3855122Storek  * disabled, or if we are in user mode, pcb_uw is junk.)
3955122Storek  *
4055122Storek  * To ease computing pcb_uw on traps from user mode, we keep track
4155122Storek  * of the log base 2 of the single bit that is set in %wim.
4255122Storek  *
4355122Storek  * If an overflow occurs while the associated user stack pages
4455122Storek  * are invalid (paged out), we have to store the registers
4555122Storek  * in a page that is locked in core while the process runs,
4655122Storek  * i.e., right here in the pcb.  We also need the stack pointer
4755122Storek  * for the last such window (but only the last, as the others
4855122Storek  * are in each window) and the count of windows saved.  We
4955122Storek  * cheat by having a whole window structure for that one %sp.
5055122Storek  * Thus, to save window pcb_rw[i] to memory, we write it at
5155122Storek  * pcb_rw[i + 1].rw_in[6].
5255122Storek  *
5355122Storek  * pcb_nsaved has three `kinds' of values.  If 0, it means no
5455122Storek  * registers are in the PCB (though if pcb_uw is positive,
5555122Storek  * there may be the next time you look).  If positive, it means
5655122Storek  * there are no user registers in the CPU, but there are some
5755122Storek  * saved in pcb_rw[].  As a special case, traps that needed
5855122Storek  * assistance to pull user registers from the stack also store
5955122Storek  * the registers in pcb_rw[], and set pcb_nsaved to -1.  This
6055122Storek  * special state is normally short-term: it can only last until the
6155122Storek  * trap returns, and it can never persist across entry to user code.
6255122Storek  */
6355122Storek struct pcb {
6455122Storek 	int	pcb_sp;		/* sp (%o6) when swtch() was called */
6555122Storek 	int	pcb_pc;		/* pc (%o7) when swtch() was called */
6655122Storek 	int	pcb_psr;	/* %psr when swtch() was called */
6755122Storek 
6855122Storek 	caddr_t	pcb_onfault;	/* for copyin/out */
6955122Storek 
7055122Storek 	int	pcb_uw;		/* user windows inside CPU */
7155122Storek 	int	pcb_wim;	/* log2(%wim) */
7255122Storek 	int	pcb_nsaved;	/* number of windows saved in pcb */
7355122Storek 
7455122Storek #ifdef notdef
7555122Storek 	int	pcb_winof;	/* number of window overflow traps */
7655122Storek 	int	pcb_winuf;	/* number of window underflow traps */
7755122Storek #endif
7855122Storek 	int	pcb_pad;	/* pad to doubleword boundary */
7955122Storek 
8055122Storek 	/* the following MUST be aligned on a doubleword boundary */
8155122Storek 	struct	rwindow pcb_rw[PCB_MAXWIN];	/* saved windows */
8255122Storek };
8355122Storek 
8455122Storek /*
8555122Storek  * The pcb is augmented with machine-dependent additional data for
8655122Storek  * core dumps.  Note that the trapframe here is a copy of the one
8755122Storek  * from the top of the kernel stack (included here so that the kernel
8855122Storek  * stack itself need not be dumped).
8955122Storek  */
9055122Storek struct md_coredump {
9155122Storek 	struct	trapframe md_tf;
9255122Storek 	struct	fpstate md_fpstate;
9355122Storek };
9455122Storek 
9555122Storek #ifdef KERNEL
9655122Storek extern struct pcb *cpcb;
9755122Storek #endif /* KERNEL */
98