Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: mmuregs.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: @(#)mmuregs.fth 1.1 06/02/22 | |
43 | purpose: | |
44 | copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | hex | |
48 | headerless | |
49 | ||
50 | 1 d# 57 lshift 1- d# 26 >> d# 26 << constant afsr-mask | |
51 | ||
52 | : mmureg!: ( adr asi -- ) \ name ( n -- ) | |
53 | create c, c, ;code | |
54 | \itc sc1 /token scr add \ >body | |
55 | scr 1 sc1 ldub \ c@ ( adr ) | |
56 | scr 0 sc2 ldub \ c@ ( asi ) | |
57 | %r3 sc3 rdasr \ save %asi in sc3 | |
58 | sc2 0 %r3 wrasr \ set %asi | |
59 | #Sync membar | |
60 | tos sc1 0 %asi stxa | |
61 | #Sync membar | |
62 | sc3 0 %r3 wrasr \ restore %asi | |
63 | sp tos pop | |
64 | c; | |
65 | ||
66 | : mmureg@: ( adr asi -- ) \ name ( -- n ) | |
67 | create c, c, | |
68 | ;code | |
69 | tos sp push | |
70 | \itc sc1 /token scr add \ >body | |
71 | scr 1 sc1 ldub \ c@ ( adr ) | |
72 | scr 0 sc2 ldub \ c@ ( asi ) | |
73 | %r3 sc3 rdasr \ save %asi in sc3 | |
74 | sc2 0 %r3 wrasr \ set %asi | |
75 | #Sync membar | |
76 | sc1 0 %asi tos ldxa | |
77 | #Sync membar | |
78 | sc3 0 %r3 wrasr \ restore %asi | |
79 | c; | |
80 | ||
81 | ||
82 | hex | |
83 | headers | |
84 | ||
85 | 38 20 mmureg@: scratch7@ \ RA of cpu struct | |
86 | 38 20 mmureg!: scratch7! | |
87 | ||
88 | alias lsucr@ 0 | |
89 | alias lsucr! drop | |
90 | ||
91 | alias cpu-error-enable@ 0 ( -- n ) | |
92 | alias cpu-error-enable! drop ( n -- ) | |
93 | ||
94 | alias cpu-afsr@ 0 ( -- n ) | |
95 | alias cpu-afsr! drop ( n -- ) | |
96 | ||
97 | also assembler definitions | |
98 | ||
99 | : get-mid ( reg -- ) | |
100 | >r %g0 h# 08 r@ add | |
101 | r@ %g0 h# 20 r@ ldxa | |
102 | r@ h# ff r@ and | |
103 | r> drop | |
104 | ; | |
105 | ||
106 | previous definitions | |
107 | ||
108 | code mid@ ( -- upa-mid ) | |
109 | tos sp push | |
110 | tos get-mid | |
111 | c; | |
112 | ||
113 | code pcr@ ( -- n ) | |
114 | tos sp push | |
115 | %r16 tos rdasr | |
116 | c; | |
117 | ||
118 | code pcr! ( n -- ) | |
119 | tos 0 %r16 wrasr | |
120 | sp tos pop | |
121 | c; | |
122 | ||
123 | code pic@ ( -- n ) | |
124 | tos sp push | |
125 | %r17 tos rdasr | |
126 | c; | |
127 | ||
128 | code pic! ( n -- ) | |
129 | tos 0 %r17 wrasr | |
130 | sp tos pop | |
131 | c; | |
132 | ||
133 | code gsr@ ( -- n ) | |
134 | tos sp push | |
135 | %r19 tos rdasr | |
136 | c; | |
137 | ||
138 | code gsr! ( n -- ) | |
139 | tos 0 %r19 wrasr | |
140 | sp tos pop | |
141 | c; | |
142 | ||
143 | code set-softint! ( n -- ) | |
144 | tos 0 %r20 wrasr | |
145 | sp tos pop | |
146 | c; | |
147 | ||
148 | code clear-softint! ( n -- ) | |
149 | tos 0 %r21 wrasr | |
150 | sp tos pop | |
151 | c; | |
152 | ||
153 | code softint@ ( -- n ) | |
154 | tos sp push | |
155 | %r22 tos rdasr | |
156 | c; | |
157 | ||
158 | code tick-compare@ ( -- n ) | |
159 | tos sp push | |
160 | %r23 tos rdasr | |
161 | c; | |
162 | ||
163 | code stick@ ( -- n ) | |
164 | tos sp push | |
165 | %r24 tos rdasr | |
166 | c; | |
167 | ||
168 | code stick! ( -- n ) | |
169 | tos 0 %r24 wrasr | |
170 | sp tos pop | |
171 | c; | |
172 | ||
173 | code tick-compare! ( n -- ) | |
174 | tos 0 %r23 wrasr | |
175 | sp tos pop | |
176 | c; | |
177 | ||
178 | code stick-compare@ ( -- n ) | |
179 | tos sp push | |
180 | %r25 tos rdasr | |
181 | c; | |
182 | ||
183 | code stick-compare! ( n -- ) | |
184 | tos 0 %r25 wrasr | |
185 | sp tos pop | |
186 | c; | |
187 | ||
188 | : init-cpu-errs ( -- ) | |
189 | exit | |
190 | afsr-mask cpu-afsr! \ CPU AFSR | |
191 | ; | |
192 | ||
193 | headerless | |
194 | ||
195 | : clr-cpu-error-enable ( bit -- ) | |
196 | drop exit | |
197 | 1 swap << invert cpu-error-enable@ and cpu-error-enable! | |
198 | ; | |
199 | ||
200 | : set-cpu-error-enable ( bit -- ) | |
201 | drop exit | |
202 | 1 swap << cpu-error-enable@ or cpu-error-enable! | |
203 | ; | |
204 | ||
205 | headers | |
206 | : ce-off ( -- ) 0 clr-cpu-error-enable ; | |
207 | : ce-on ( -- ) 0 set-cpu-error-enable ; | |
208 | : ecache-ecc-on ( -- ) 3 set-cpu-error-enable ; | |
209 | : ecache-ecc-off ( -- ) 3 clr-cpu-error-enable ; | |
210 | : ecc-off ( -- ) 1 clr-cpu-error-enable ; | |
211 | : ecc-on ( -- ) init-cpu-errs 1 set-cpu-error-enable ; | |
212 | ||
213 | \ berr cannot disable ECC, because doind so means we don't take the probe traps | |
214 | \ we do need to disable bit 21 or the machine will take a fatal reset though | |
215 | \ | |
216 | : berr-off ( -- ) d# 21 clr-cpu-error-enable ; | |
217 | : berr-on ( -- ) ecc-on d# 21 set-cpu-error-enable ; | |
218 | ||
219 | : disable-cpu-errors ( -- ) | |
220 | ecache-ecc-off ce-off ecc-off berr-off | |
221 | ; | |
222 | ||
223 | \ XXX | |
224 | : enable-cpu-errors ( -- ) | |
225 | exit | |
226 | init-cpu-errs \ start with a clean slate | |
227 | ecc-on ce-on berr-on | |
228 | cpu-error-enable@ | |
229 | h# 1.00d0.0014 \ Enable All errors! | |
230 | or cpu-error-enable! | |
231 | ; | |
232 | ||
233 | headerless | |
234 | : 1bits ( mask #bits -- mask' bits ) 1 bits ; | |
235 | : 8bits ( mask #bits -- mask' bits ) 8 bits ; | |
236 | ||
237 | \ XXXX THIS FILE IS NOT REALLY THE BEST PLACE FOR THIS XXXX | |
238 | \ XXXX BUT FORM NOW IT'LL HAVE TO DO I GUESS XXXX | |
239 | ||
240 | \ Secondary Asi DUMP and DIS | |
241 | ||
242 | \ The dump utility gives you a formatted hex dump with the ascii | |
243 | \ text corresponding to the bytes on the right hand side of the | |
244 | \ screen. | |
245 | ||
246 | [ifexist] disassembler | |
247 | only forth also hidden also definitions | |
248 | ||
249 | headerless | |
250 | : (asi-secondary-c@) ( padr -- byte ) h# 81 spacec@ ; | |
251 | forth definitions | |
252 | headers | |
253 | : sdump (s addr len -- ) ['] (asi-secondary-c@) is dc@ (dump) ; | |
254 | : sdu (s addr -- addr+64 ) dup d# 64 sdump d# 64 + ; | |
255 | previous previous definitions | |
256 | ||
257 | also disassembler also definitions | |
258 | headerless | |
259 | : (sinst@ ( adr -- opcode ) h# 81 spacel@ ; | |
260 | ||
261 | forth definitions | |
262 | headers | |
263 | : sdis1 ( -- ) | |
264 | ??cr ['] (sinst@ is inst@ | |
265 | pc@ +offset udis. 4 spaces #out @ start-column ! | |
266 | pc@l@ disasm cr | |
267 | /l pc@ + pc! | |
268 | ; | |
269 | : +sdis ( -- ) | |
270 | base @ >r hex | |
271 | end-found off | |
272 | begin sdis1 end-found @ exit? or until | |
273 | sdis1 \ Disassemble the delay instruction too | |
274 | r> base ! | |
275 | ; | |
276 | : sdis ( adr -- ) pc! +sdis ; | |
277 | previous previous also definitions | |
278 | [then] |