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