Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: savestate.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)savestate.fth 1.1 06/02/16 | |
43 | purpose: Saves CPU state for later retrieval | |
44 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headers | |
48 | transient | |
49 | also forth definitions | |
50 | : offset-of \ name ( -- offset ) | |
51 | parse-word ['] forth $vfind if | |
52 | >body w@ 1 | |
53 | else | |
54 | ." offset-of can't find " type cr | |
55 | where | |
56 | then | |
57 | do-literal | |
58 | ; immediate | |
59 | previous definitions | |
60 | resident | |
61 | ||
62 | ||
63 | \ input: %o7 return address | |
64 | \ output: %o0 ptr to cpu struct | |
65 | \ %o7, %asi and %g7 in GL2 are trashed and not saved | |
66 | label save-reset-state | |
67 | ||
68 | %g0 2 wrgl | |
69 | ||
70 | \ Get cpu struct stashed in SCRATCH7 | |
71 | %g0 h# 20 wrasi | |
72 | %g0 h# 38 %asi %g7 ldxa | |
73 | ||
74 | %g0 memory-asi wrasi | |
75 | ||
76 | %g1 rdpil %g1 %g7 offset-of %pil %asi stxa | |
77 | %g1 rdcwp %g1 %g7 offset-of %cwp %asi stxa | |
78 | %g1 rdcansave %g1 %g7 offset-of %cansave %asi stxa | |
79 | %g1 rdcanrestore %g1 %g7 offset-of %canrestore %asi stxa | |
80 | %g1 rdcleanwin %g1 %g7 offset-of %cleanwin %asi stxa | |
81 | %g1 rdotherwin %g1 %g7 offset-of %otherwin %asi stxa | |
82 | %g1 rdwstate %g1 %g7 offset-of %wstate %asi stxa | |
83 | %g1 rdpstate %g1 %g7 offset-of %pstate %asi stxa | |
84 | %g1 rdgl %g1 %g7 offset-of %gl %asi stxa | |
85 | ||
86 | %g1 rdy %g1 %g7 offset-of %y %asi stxa | |
87 | %g1 rdccr %g1 %g7 offset-of %ccr %asi stxa | |
88 | %g1 rdasi %g1 %g7 offset-of %asi %asi stxa | |
89 | %g1 rdfprs %g1 %g7 offset-of %fprs %asi stxa | |
90 | ||
91 | %g1 rdtpc %g1 %g7 offset-of %pc %asi stxa | |
92 | %g1 rdtnpc %g1 %g7 offset-of %npc %asi stxa | |
93 | %g1 rdtba %g1 %g7 offset-of %tba %asi stxa | |
94 | %g1 rdtl %g1 %g7 offset-of %tl-c %asi stxa | |
95 | ||
96 | %g1 rdtt %g1 %g7 offset-of %tt-c %asi stxa | |
97 | %g1 rdtpc %g1 %g7 offset-of %tpc-c %asi stxa | |
98 | %g1 rdtnpc %g1 %g7 offset-of %tnpc-c %asi stxa | |
99 | %g1 rdtstate %g1 %g7 offset-of %tstate-c %asi stxa | |
100 | ||
101 | %g0 1 %g1 sub | |
102 | %g0 %g7 offset-of %restartable? %asi stxa | |
103 | %o7 %g6 move \ return address in %g6, GL=2 | |
104 | ||
105 | \ Save all of the Trap State Registers | |
106 | ||
107 | %g3 rdtl | |
108 | ||
109 | %g0 2 wrtl | |
110 | %g1 rdtt %g1 %g7 offset-of %tt-2 %asi stxa | |
111 | %g1 rdtpc %g1 %g7 offset-of %tpc-2 %asi stxa | |
112 | %g1 rdtnpc %g1 %g7 offset-of %tnpc-2 %asi stxa | |
113 | %g1 rdtstate %g1 %g7 offset-of %tstate-2 %asi stxa | |
114 | ||
115 | %g0 1 wrtl | |
116 | %g1 rdtt %g1 %g7 offset-of %tt-1 %asi stxa | |
117 | %g1 rdtpc %g1 %g7 offset-of %tpc-1 %asi stxa | |
118 | %g1 rdtnpc %g1 %g7 offset-of %tnpc-1 %asi stxa | |
119 | %g1 rdtstate %g1 %g7 offset-of %tstate-1 %asi stxa | |
120 | ||
121 | %g3 0 wrtl | |
122 | ||
123 | %g0 window-registers %g1 add | |
124 | %g1 %g7 %g1 add | |
125 | ||
126 | %o0 %g1 0 /n* %asi stxa \ %o0 | |
127 | %o1 %g1 1 /n* %asi stxa \ %o1 | |
128 | %o2 %g1 2 /n* %asi stxa \ %o2 | |
129 | %o3 %g1 3 /n* %asi stxa \ %o3 | |
130 | %o4 %g1 4 /n* %asi stxa \ %o4 | |
131 | %o5 %g1 5 /n* %asi stxa \ %o5 | |
132 | %o6 %g1 6 /n* %asi stxa \ %o6 | |
133 | %o7 %g1 7 /n* %asi stxa \ %o7 | |
134 | ||
135 | %g1 8 /n* %g1 add | |
136 | ||
137 | %l0 %g1 0 /n* %asi stxa \ %l0 | |
138 | %l1 %g1 1 /n* %asi stxa \ %l1 | |
139 | %l2 %g1 2 /n* %asi stxa \ %l2 | |
140 | %l3 %g1 3 /n* %asi stxa \ %l3 | |
141 | %l4 %g1 4 /n* %asi stxa \ %l4 | |
142 | %l5 %g1 5 /n* %asi stxa \ %l5 | |
143 | %l6 %g1 6 /n* %asi stxa \ %l6 | |
144 | %l7 %g1 7 /n* %asi stxa \ %l7 | |
145 | ||
146 | %g1 8 /n* %g1 add | |
147 | ||
148 | %i0 %g1 0 /n* %asi stxa \ %i0 | |
149 | %i1 %g1 1 /n* %asi stxa \ %i1 | |
150 | %i2 %g1 2 /n* %asi stxa \ %i2 | |
151 | %i3 %g1 3 /n* %asi stxa \ %i3 | |
152 | %i4 %g1 4 /n* %asi stxa \ %i4 | |
153 | %i5 %g1 5 /n* %asi stxa \ %i5 | |
154 | %i6 %g1 6 /n* %asi stxa \ %i6 | |
155 | %i7 %g1 7 /n* %asi stxa \ %i7 | |
156 | ||
157 | %g1 8 /n* %g1 add | |
158 | ||
159 | %g4 rdcwp %g4 1 %g3 sub %g3 0 wrcwp | |
160 | ||
161 | begin | |
162 | ||
163 | %l0 %g1 0 /n* %asi stxa \ %l0 | |
164 | %l1 %g1 1 /n* %asi stxa \ %l1 | |
165 | %l2 %g1 2 /n* %asi stxa \ %l2 | |
166 | %l3 %g1 3 /n* %asi stxa \ %l3 | |
167 | %l4 %g1 4 /n* %asi stxa \ %l4 | |
168 | %l5 %g1 5 /n* %asi stxa \ %l5 | |
169 | %l6 %g1 6 /n* %asi stxa \ %l6 | |
170 | %l7 %g1 7 /n* %asi stxa \ %l7 | |
171 | ||
172 | %g1 8 /n* %g1 add | |
173 | ||
174 | %i0 %g1 0 /n* %asi stxa \ %i0 | |
175 | %i1 %g1 1 /n* %asi stxa \ %i1 | |
176 | %i2 %g1 2 /n* %asi stxa \ %i2 | |
177 | %i3 %g1 3 /n* %asi stxa \ %i3 | |
178 | %i4 %g1 4 /n* %asi stxa \ %i4 | |
179 | %i5 %g1 5 /n* %asi stxa \ %i5 | |
180 | %i6 %g1 6 /n* %asi stxa \ %i6 | |
181 | %i7 %g1 7 /n* %asi stxa \ %i7 | |
182 | ||
183 | %g3 1 %g3 sub | |
184 | %g3 0 wrcwp | |
185 | %g3 rdcwp | |
186 | %g4 %g3 %g0 subcc | |
187 | ||
188 | = until %g1 8 /n* %g1 add | |
189 | ||
190 | %g7 %l0 move | |
191 | %g6 %o7 move \ restore return address | |
192 | ||
193 | \ Save GL=1 Globals | |
194 | %g0 1 wrgl | |
195 | ||
196 | %g0 %l0 offset-of %a0 %asi stxa | |
197 | %g1 %l0 offset-of %a1 %asi stxa | |
198 | %g2 %l0 offset-of %a2 %asi stxa | |
199 | %g3 %l0 offset-of %a3 %asi stxa | |
200 | %g4 %l0 offset-of %a4 %asi stxa | |
201 | %g5 %l0 offset-of %a5 %asi stxa | |
202 | %g6 %l0 offset-of %a6 %asi stxa | |
203 | %g7 %l0 offset-of %a7 %asi stxa | |
204 | ||
205 | \ Save GL=0 Globals | |
206 | ||
207 | %g0 0 wrgl | |
208 | ||
209 | %g0 %l0 offset-of %g0 %asi stxa | |
210 | %g1 %l0 offset-of %g1 %asi stxa | |
211 | %g2 %l0 offset-of %g2 %asi stxa | |
212 | %g3 %l0 offset-of %g3 %asi stxa | |
213 | %g4 %l0 offset-of %g4 %asi stxa | |
214 | %g5 %l0 offset-of %g5 %asi stxa | |
215 | %g6 %l0 offset-of %g6 %asi stxa | |
216 | %g7 %l0 offset-of %g7 %asi stxa | |
217 | ||
218 | %g0 1 %g1 sub | |
219 | %g1 %l0 offset-of %state-valid %asi stxa | |
220 | ||
221 | %g0 7 wrcleanwin %g0 0 wrotherwin | |
222 | %g0 0 wrwstate %g0 0 wrcwp | |
223 | %g0 0 wrcanrestore %g0 6 wrcansave | |
224 | ||
225 | %l0 %o0 move \ %o0 contains cpu struct ptr | |
226 | %o7 8 %g0 jmpl nop | |
227 | end-code |