Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / cpu / sparc / ultra4v / mmuregs.fth
CommitLineData
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 ============================================
42id: @(#)mmuregs.fth 1.1 06/02/22
43purpose:
44copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47hex
48headerless
49
501 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
64c;
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
79c;
80
81
82hex
83headers
84
8538 20 mmureg@: scratch7@ \ RA of cpu struct
8638 20 mmureg!: scratch7!
87
88alias lsucr@ 0
89alias lsucr! drop
90
91alias cpu-error-enable@ 0 ( -- n )
92alias cpu-error-enable! drop ( n -- )
93
94alias cpu-afsr@ 0 ( -- n )
95alias cpu-afsr! drop ( n -- )
96
97also 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
106previous definitions
107
108code mid@ ( -- upa-mid )
109 tos sp push
110 tos get-mid
111c;
112
113code pcr@ ( -- n )
114 tos sp push
115 %r16 tos rdasr
116c;
117
118code pcr! ( n -- )
119 tos 0 %r16 wrasr
120 sp tos pop
121c;
122
123code pic@ ( -- n )
124 tos sp push
125 %r17 tos rdasr
126c;
127
128code pic! ( n -- )
129 tos 0 %r17 wrasr
130 sp tos pop
131c;
132
133code gsr@ ( -- n )
134 tos sp push
135 %r19 tos rdasr
136c;
137
138code gsr! ( n -- )
139 tos 0 %r19 wrasr
140 sp tos pop
141c;
142
143code set-softint! ( n -- )
144 tos 0 %r20 wrasr
145 sp tos pop
146c;
147
148code clear-softint! ( n -- )
149 tos 0 %r21 wrasr
150 sp tos pop
151c;
152
153code softint@ ( -- n )
154 tos sp push
155 %r22 tos rdasr
156c;
157
158code tick-compare@ ( -- n )
159 tos sp push
160 %r23 tos rdasr
161c;
162
163code stick@ ( -- n )
164 tos sp push
165 %r24 tos rdasr
166c;
167
168code stick! ( -- n )
169 tos 0 %r24 wrasr
170 sp tos pop
171c;
172
173code tick-compare! ( n -- )
174 tos 0 %r23 wrasr
175 sp tos pop
176c;
177
178code stick-compare@ ( -- n )
179 tos sp push
180 %r25 tos rdasr
181c;
182
183code stick-compare! ( n -- )
184 tos 0 %r25 wrasr
185 sp tos pop
186c;
187
188: init-cpu-errs ( -- )
189exit
190 afsr-mask cpu-afsr! \ CPU AFSR
191;
192
193headerless
194
195: clr-cpu-error-enable ( bit -- )
196drop exit
197 1 swap << invert cpu-error-enable@ and cpu-error-enable!
198;
199
200: set-cpu-error-enable ( bit -- )
201drop exit
202 1 swap << cpu-error-enable@ or cpu-error-enable!
203;
204
205headers
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 ( -- )
225exit
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
233headerless
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
247only forth also hidden also definitions
248
249headerless
250: (asi-secondary-c@) ( padr -- byte ) h# 81 spacec@ ;
251forth definitions
252headers
253: sdump (s addr len -- ) ['] (asi-secondary-c@) is dc@ (dump) ;
254: sdu (s addr -- addr+64 ) dup d# 64 sdump d# 64 + ;
255previous previous definitions
256
257also disassembler also definitions
258headerless
259: (sinst@ ( adr -- opcode ) h# 81 spacel@ ;
260
261forth definitions
262headers
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 ;
277previous previous also definitions
278[then]