Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / pkg / termemu / sparc / fb8-ops.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: fb8-ops.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: @(#)fb8-ops.fth 2.8 95/04/19
43purpose: Optimized fb8 package support routines
44copyright: Copyright 1990 Sun Microsystems, Inc. All Rights Reserved
45
46headerless
47decimal
48
49\ Fast 8-bit cursor toggle
50\ Now tests for 32-bit alignment, uses 32-bit ops if possible
51code cfb8-invert ( adr width height bytes/line fg-color bg-color -- )
52 \ bg-color in tos
53 sp 0 /n* sc5 nget \ fg-color in sc5
54 sp 1 /n* scr nget \ bytes/lines in scr
55 sp 2 /n* sc2 nget \ height in sc2 (outer loop index, >0)
56 sp 3 /n* sc1 nget \ width in sc1 (inner loop index, >0)
57 sp 4 /n* sc3 nget \ adr in sc3 (starting address)
58
59 ahead \ Branch to the loop test at "but then"
60 nop
61 begin \ Outer loop
62
63 ahead \ Branch to the loop test at "but then"
64 nop
65 begin \ Inner loop
66
67 \ The following code is a tribute to delayed branching, a bad
68 \ idea whose time has come and gone
69 sc4 tos cmp
70 = if
71 sc4 sc5 cmp \ Delay slot, setup for possible next "if"
72 else
73 sc5 sc3 sc1 stb \ Delay slot, executed if sc4=tos
74
75 = if annul \ Executed if sc4<>tos
76 sc4 sc3 sc1 stb \ Delay slot, executed if tos<>sc4<>sc5
77
78 tos sc3 sc1 stb \ store byte, executed if sc4=sc5
79 then
80 then
81
82 but then
83 sc1 1 sc1 subcc \ decrement width until =0
84 < until annul \ End inner loop when width=0
85 sc3 sc1 sc4 ldub
86
87 sc3 scr sc3 add \ increment adr to next line
88
89 but then
90 sc2 1 sc2 subcc \ decrement height until =0
91 < until \ End outer loop when height=0
92 sp 3 /n* sc1 nget \ (delay) restore starting width value
93
94 sp 5 /n* tos nget \ Pop 6 stack items
95 sp 6 /n* sp add
96c;
97here lastacf - constant /cfb8-invert
98defer fb8-invert ' cfb8-invert is fb8-invert
99
100\ Draws a character from a 1-bit-deep font into an 8-bit-deep frame buffer
101\ Assumptions: Fontbytes is 2; 0 < width <= 16
102\ Fontadr is divisible by 2
103\ XXX - Fontbytes is 1 for touche.obf, others?
104code cfb8-paint
105( fontadr fontbytes width height screenadr bytes/line fg-color bg-color -- )
106 \ bg-color in tos
107 sp 0 /n* %o5 nget \ fg-color in %o5
108 sp 1 /n* sc2 nget \ Bytes/line - bytes per scan line
109 sp 2 /n* sc3 nget \ Screenadr - start address in frame buffer
110 sp 3 /n* sc4 nget \ Height - character height in pixels
111 sp 4 /n* sc5 nget \ Width - character width in pixels (bytes)
112 sp 5 /n* sc6 nget \ Fontbytes - bytes per font line
113 sp 6 /n* sc7 nget \ Fontadr - start address (of this char) in font table
114
115 sc2 sc5 sc2 sub \ Account for incrementing of address within inner
116
117 sc5 7 %o0 add
118 %o0 3 %o0 srl \ Number of bytes actually used for each font scan line
119 sc6 %o0 sc6 sub \ Amount to add to font byte counter at end of loop
120
121 ahead
122 nop
123 begin \ Outer loop - for all scan lines in char
124
125 ahead
126 nop
127 begin \ Middle loop - pixels on a scan line
128 > if
129 %o2 %o3 move \ (delay) - assume %o2 bits per chunk
130 8 %o3 move \ If %o3 > 8, do just 8 at a time
131 then
132
133 %o2 %o3 %o2 sub \ Reduce pixel/scan-line count
134
135 sc7 0 scr ldub \ Load one byte of font
136 sc7 1 sc7 add \ Advance to next byte
137 scr bits/cell 9 - scr slln \ Align 1 shift position below sign bit of scr
138
139 %g0 %o3 %o0 sub \ Count from (-)width up to 0
140
141 sc3 %o3 %o1 add \ Working frame addr is frame+width
142
143 scr scr scr addcc \ Test high bit
144 begin \ Inner loop - bits within one font byte
145 0< if annul
146 tos %o0 %o1 stb \ Write bg-color to (frame+width + (-)count)
147
148 %o5 %o0 %o1 stb \ Write fg-color to (frame+width + (-)count)
149 then
150
151 %o0 1 %o0 addcc \ Increment width pixel count
152 = until \ Repeat until width count = 0
153 scr scr scr addcc \ Test high bit
154
155 sc3 %o3 sc3 add \ Increment frame buffer addr to next chunk
156
157 but then
158 %o2 %g0 cmp
159 = until
160 %o2 8 cmp
161
162 sc3 sc2 sc3 add \ Increment frame buffer addr to next line
163
164 sc7 sc6 sc7 add \ Next scan line in font table
165 but then
166 sc4 1 sc4 subcc \ Decrement height counter
167 < until \ Repeat until height count = 0
168 sc5 %o2 move \ Reset pixels/scan-line counter
169
170 sp 7 /n* tos nget \ Pop 8 stack items
171 sp 8 /n* sp add
172
173c;
174here lastacf - constant /cfb8-paint
175defer fb8-paint ' cfb8-paint is fb8-paint
176
177\ Very fast window move, for scrolling
178\ Similar to 'move', but only moves #move/line out of every 'bytes/line' bytes
179\ Assumes bytes/line is divisible by 8 (for double-long load/stores)
180\ Assumes src and dst separated by n*bytes/line
181\ Called with:
182\ src-start dst-start size bytes/line #move/line fb8-move
183\ (break-lo)(cursor-y) (winbot-breaklo) (") (emu-bytes/line)
184\ src > dst, so move from start towards end
185
18632\ [ifdef] ldd-is-broken
18732\ 4 constant fbalign
18832\ [else]
18932\ 8 constant fbalign
19032\ [then]
19164\ 8 constant fbalign
192
193code cfb8-window-move ( src-start dst-start size bytes/line #move/line -- )
194 \ tos=#move/line
195 sp 0 /n* scr nget \ scr=bytes/line
196 sp 1 /n* sc1 nget \ sc1=size
197 sp 2 /n* sc2 nget \ sc2=dst-start
198 sp 3 /n* sc3 nget \ sc3=src-start
199
200\ First, force src and dst to alignment boundary, adjust #move/line
201 sc3 fbalign 1- sc4 and \ Any extra bytes at start?
202 tos sc4 tos add \ Adjust #move/line by that amount
203 sc3 fbalign 1- sc3 andn \ Lock src to alignment boundary
204 sc2 fbalign 1- sc2 andn \ Lock dst to alignment boundary
205 tos fbalign 1- tos add \ Round #move/line up to next unit
206 tos fbalign 1- tos andn
207
208 begin \ Outer loop
209 tos 0 sc4 add \ Setup inner loop index
210 begin \ Inner loop
211 sc4 fbalign sc4 subcc \ Decrement index until =0
21232\ [ifdef] ldd-is-broken
21332\ sc3 sc4 sc6 ld
21432\ <= until \ End inner loop when index=0
21532\ sc6 sc2 sc4 st \ (delay)
21632\ [else]
21732\ sc3 sc4 sc6 ldd
21832\ <= until \ End inner loop when index=0
21932\ sc6 sc2 sc4 std \ (delay)
22032\ [then]
22164\ sc3 sc4 sc6 ldx
22264\ <= until \ End inner loop when index=0
22364\ sc6 sc2 sc4 stx \ (delay)
224
225 sc1 scr sc1 subcc \ Decrement size until =0
226 sc2 scr sc2 add \ Increment src
227 <= until \ End outer loop when size=0
228 sc3 scr sc3 add \ (delay) Increment dst
229
230 sp 4 /n* tos nget \ Pop 5 stack items
231 sp 5 /n* sp add
232c;
233here lastacf - constant /cfb8-window-move
234defer fb8-window-move ' cfb8-window-move is fb8-window-move
235
236[ifdef] copy-to-ram
237: stand-init ( -- )
238 stand-init
239 ['] cfb8-paint /cfb8-paint copy-to-ram is fb8-paint
240 ['] cfb8-invert /cfb8-invert copy-to-ram is fb8-invert
241 ['] cfb8-window-move /cfb8-window-move copy-to-ram is fb8-window-move
242;
243[then] \ copy-to-ram
244headers