Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / fm / lib / sparc / dfill.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: dfill.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\ dfill.fth 2.5 94/05/30
43\ Copyright 1985-1990 Bradley Forthware
44
45\ Doubleword fill. This is the fastest way of filling memory on a SPARC.
46\ This is primarily used for clearing memory to initialize the parity.
47
48headers
49code cfill (s start-addr count char -- )
50 \ char in tos
51 sp 0 /n* scr nget \ count in scr
52 sp 1 /n* sc1 nget \ start in sc1
53
54 ahead \ jump to the until branch
55 nop
56 begin
57 tos sc1 scr stb
58 but then
59 scr 1 scr subcc
60 0< until
61 nop \ Delay slot
62
63 sp 2 /n* tos nget
64 sp 3 /n* sp add
65c;
66
67code wfill (s start-addr count shortword -- )
68 \ char in tos
69 sp 0 /n* scr nget \ count in scr
70 sp 1 /n* sc1 nget \ start in sc1
71
72 ahead \ jump to the until branch
73 nop
74 begin
75 tos sc1 scr sth
76 but then
77 scr 2 scr subcc
78 0< until
79 nop \ Delay slot
80
81 sp 2 /n* tos nget
82 sp 3 /n* sp add
83c;
84
85code lfill (s start-addr count longword -- )
86 \ char in tos
87 sp 0 /n* scr nget \ count in scr
88 sp 1 /n* sc1 nget \ start in sc1
89
90 ahead \ jump to the until branch
91 nop
92 begin
93 tos sc1 scr st
94 but then
95 scr 4 scr subcc
96 0< until
97 nop \ Delay slot
98
99 sp 2 /n* tos nget
100 sp 3 /n* sp add
101c;
102headerless
103here lastacf - constant /lfill
104
105\ For this implementation, count must be a multiple of 32 bytes, and
106\ start-addr must be aligned on an 8-byte boundary.
107
108headers
109code dfill (s start-addr count odd-word even-word -- )
110 tos sc2 move \ even-word in sc2
111 sp sc3 pop \ odd-word in sc3
112 sp scr pop \ count in scr
113 sp sc1 pop \ start in sc1
114 sp tos pop \ fix stack
115
11664\ \ XXXX merge sc2 and sc3 into sc2 XXXXX
117
118 scr 0 cmp
119 <> if
120 nop
121 begin
12232\ sc2 sc1 0 std
12364\ sc2 sc1 0 stx
124 scr d# 32 scr subcc \ Try to fill pipeline interlocks
12532\ sc2 sc1 8 std
12664\ sc2 sc1 8 stx
127 sc1 d# 32 sc1 add
12832\ sc2 sc1 d# -16 std
12964\ sc2 sc1 d# -16 stx
130 0<= until
13132\ sc2 sc1 d# -08 std
13264\ sc2 sc1 d# -08 stx
133 then
134c;
135headerless
136here lastacf - constant /dfill
137
138\ We can also scrub parity errors by reading and writing memory.
139\ This is slower than just clearing it, but it preserves the previous
140\ contents, which is nice after Unix has crashed
141
142code ltouch ( adr len -- )
143 tos sc1 move \ count in sc1
144 sp sc2 pop \ adr in sc2
145 sp tos pop
146
147 sc1 0 cmp
148 <> if
149 nop
150
151 begin
152 sc1 4 sc1 subcc
153 sc2 sc1 sc4 ld
154 0<= until
155 sc4 sc2 sc1 st
156
157 then
158c;
159here lastacf - constant /ltouch
160
161code dtouch ( adr len -- )
162 tos sc1 move \ count in sc1
163 sp sc2 pop \ adr in sc2
164 sp tos pop
165
166 sc1 0 cmp
167 <> if
168 nop
169
170 begin
171 sc1 8 sc1 subcc
17232\ sc2 sc1 sc4 ldd
17364\ sc2 sc1 sc4 ldx
174 0<= until
17532\ sc4 sc2 sc1 std
17664\ sc4 sc2 sc1 stx
177
178 then
179c;
180here lastacf - constant /dtouch
181headers