]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/sparc64/include/wstate.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / sparc64 / include / wstate.h
1 /*-
2  * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  * 3. Berkeley Software Design Inc's name may not be used to endorse or
13  *    promote products derived from this software without specific prior
14  *    written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  *      from: BSDI: wstate.h,v 1.4 1997/09/18 13:05:51 torek Exp
29  * $FreeBSD$
30  */
31
32 #ifndef _MACHINE_WSTATE_H_
33 #define _MACHINE_WSTATE_H_
34
35 /*
36  * Window state register bits.
37  *
38  * There really are no bits per se, just the two fields WSTATE.NORMAL
39  * and WSTATE.OTHER.  The rest is up to software.
40  *
41  * We use WSTATE_NORMAL to represent user mode or kernel mode saves
42  * (whichever is currently in effect) and WSTATE_OTHER to represent
43  * user mode saves (only).
44  *
45  * We use the low bit to suggest 32-bit mode, with the next bit set
46  * once we succeed in saving in some mode.  That is, if the WSTATE_ASSUME
47  * bit is set, the spill or fill handler we use will be one that makes
48  * an assumption about the proper window-save mode.  If the spill or
49  * fill fails with an alignment fault, the spill or fill op should
50  * take the `assume' bit away retry the instruction that caused the
51  * spill or fill.  This will use the new %wstate, which will test for
52  * which mode to use.  The alignment fault code helps us out here by
53  * resuming the spill vector at offset +70, where we are allowed to
54  * execute two instructions (i.e., write to %wstate and RETRY).
55  *
56  * If the ASSUME bit is not set when the alignment fault occurs, the
57  * given stack pointer is hopelessly wrong (and the spill, if it is a
58  * spill, should be done as a sort of "panic spill") -- so those two
59  * instructions will be a branch sequence.
60  *
61  * Note that locore.s assumes this same bit layout (since the translation
62  * from "bits" to "{spill,fill}_N_{normal,other}" is done in hardware).
63  *
64  * The value 0 is preferred for unknown to make it easy to start in
65  * unknown state and continue in whichever state unknown succeeds in --
66  * a successful "other" save, for instance, can just set %wstate to
67  * ASSUMExx << USERSHIFT and thus leave the kernel state "unknown".
68  *
69  * We also need values for managing the somewhat tricky transition from
70  * user to kernel and back, so we use the one remaining free bit to mean
71  * "although this looks like kernel mode, the window(s) involved are
72  * user windows and should be saved ASI_AIUP".  Everything else is
73  * otherwise the same, but we need not bother with assumptions in this
74  * mode (we expect it to apply to at most one window spill or fill),
75  * i.e., WSTATE_TRANSITION can ignore WSTATE_ASSUME if it likes.
76  */
77
78 #define WSTATE_NORMAL_MASK      1       /* wstate normal minus transition */
79 #define WSTATE_OTHER_SHIFT      3       /* for wstate other / user */
80 #define WSTATE_OTHER_MASK               /* wstate other minus nested */ \
81         (WSTATE_NORMAL_MASK << WSTATE_OTHER_SHIFT)
82
83 #define WSTATE_KERNEL           0       /* normal kernel wstate */
84 #define WSTATE_USER_64          0       /* normal 64bit user wstate */
85 #define WSTATE_USER_32          1       /* normal 32bit user wstate */
86
87 #define WSTATE_TRANSITION       2       /* if set, force user window */
88 #define WSTATE_NESTED                   /* if set, spill must not fault */ \
89         (WSTATE_TRANSITION << WSTATE_OTHER_SHIFT)
90
91 #endif /* !_MACHINE_WSTATE_H_ */