Home | History | Annotate | Line # | Download | only in include
pcb.h revision 1.2
      1 /*
      2  * Copyright (c) 1992, 1993
      3  *	The Regents of the University of California.  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  * Redistribution and use in source and binary forms, with or without
     15  * modification, are permitted provided that the following conditions
     16  * are met:
     17  * 1. Redistributions of source code must retain the above copyright
     18  *    notice, this list of conditions and the following disclaimer.
     19  * 2. Redistributions in binary form must reproduce the above copyright
     20  *    notice, this list of conditions and the following disclaimer in the
     21  *    documentation and/or other materials provided with the distribution.
     22  * 3. All advertising materials mentioning features or use of this software
     23  *    must display the following acknowledgement:
     24  *	This product includes software developed by the University of
     25  *	California, Berkeley and its contributors.
     26  * 4. Neither the name of the University nor the names of its contributors
     27  *    may be used to endorse or promote products derived from this software
     28  *    without specific prior written permission.
     29  *
     30  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     31  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     33  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     34  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     35  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     36  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     37  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     38  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     39  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     40  * SUCH DAMAGE.
     41  *
     42  *	@(#)pcb.h	8.1 (Berkeley) 6/11/93
     43  *
     44  * from: Header: pcb.h,v 1.6 92/11/26 02:04:39 torek Exp
     45  * $Id: pcb.h,v 1.2 1994/05/19 08:23:36 deraadt Exp $
     46  */
     47 
     48 #include <machine/reg.h>
     49 
     50 #ifdef notyet
     51 #define	PCB_MAXWIN	32	/* architectural limit */
     52 #else
     53 #define	PCB_MAXWIN	8	/* worried about u area sizes ... */
     54 #endif
     55 
     56 /*
     57  * SPARC Process Control Block.
     58  *
     59  * pcb_uw is positive if there are any user windows that are
     60  * are currently in the CPU windows rather than on the user
     61  * stack.  Whenever we are running in the kernel with traps
     62  * enabled, we decrement pcb_uw for each ``push'' of a CPU
     63  * register window into the stack, and we increment it for
     64  * each ``pull'' from the stack into the CPU.  (If traps are
     65  * disabled, or if we are in user mode, pcb_uw is junk.)
     66  *
     67  * To ease computing pcb_uw on traps from user mode, we keep track
     68  * of the log base 2 of the single bit that is set in %wim.
     69  *
     70  * If an overflow occurs while the associated user stack pages
     71  * are invalid (paged out), we have to store the registers
     72  * in a page that is locked in core while the process runs,
     73  * i.e., right here in the pcb.  We also need the stack pointer
     74  * for the last such window (but only the last, as the others
     75  * are in each window) and the count of windows saved.  We
     76  * cheat by having a whole window structure for that one %sp.
     77  * Thus, to save window pcb_rw[i] to memory, we write it at
     78  * pcb_rw[i + 1].rw_in[6].
     79  *
     80  * pcb_nsaved has three `kinds' of values.  If 0, it means no
     81  * registers are in the PCB (though if pcb_uw is positive,
     82  * there may be the next time you look).  If positive, it means
     83  * there are no user registers in the CPU, but there are some
     84  * saved in pcb_rw[].  As a special case, traps that needed
     85  * assistance to pull user registers from the stack also store
     86  * the registers in pcb_rw[], and set pcb_nsaved to -1.  This
     87  * special state is normally short-term: it can only last until the
     88  * trap returns, and it can never persist across entry to user code.
     89  */
     90 struct pcb {
     91 	int	pcb_sp;		/* sp (%o6) when switch() was called */
     92 	int	pcb_pc;		/* pc (%o7) when switch() was called */
     93 	int	pcb_psr;	/* %psr when switch() was called */
     94 
     95 	caddr_t	pcb_onfault;	/* for copyin/out */
     96 
     97 	int	pcb_uw;		/* user windows inside CPU */
     98 	int	pcb_wim;	/* log2(%wim) */
     99 	int	pcb_nsaved;	/* number of windows saved in pcb */
    100 
    101 #ifdef notdef
    102 	int	pcb_winof;	/* number of window overflow traps */
    103 	int	pcb_winuf;	/* number of window underflow traps */
    104 #endif
    105 	int	pcb_pad;	/* pad to doubleword boundary */
    106 
    107 	/* the following MUST be aligned on a doubleword boundary */
    108 	struct	rwindow pcb_rw[PCB_MAXWIN];	/* saved windows */
    109 };
    110 
    111 /*
    112  * The pcb is augmented with machine-dependent additional data for
    113  * core dumps.  Note that the trapframe here is a copy of the one
    114  * from the top of the kernel stack (included here so that the kernel
    115  * stack itself need not be dumped).
    116  */
    117 struct md_coredump {
    118 	struct	trapframe md_tf;
    119 	struct	fpstate md_fpstate;
    120 };
    121 
    122 #ifdef KERNEL
    123 extern struct pcb *cpcb;
    124 #endif /* KERNEL */
    125