Rev 129 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
129 | mikedld | 1 | ;----------------------------------------------------------------------------- |
2 | ;///// PART OF ATi RADEON 9000 DRIVER //////////////////////////////////////// |
||
3 | ;----------------------------------------------------------------------------- |
||
4 | ; Copyright (c) 2004, mike.dld |
||
5 | ; Using BeOS driver - Copyright (c) 2002, Thomas Kurschel |
||
6 | ;----------------------------------------------------------------------------- |
||
7 | ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
8 | ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
9 | ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
10 | ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
11 | ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||
12 | ; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
13 | ; DEALINGS IN THE SOFTWARE. |
||
14 | ;----------------------------------------------------------------------------- |
||
15 | |||
16 | macro __include_debug_strings dummy,[_id,_fmt,_len] { |
||
17 | common |
||
18 | local c1,a1,a2 |
||
19 | forward |
||
20 | _id rb _len+1 |
||
21 | db 0 |
||
22 | a1 = 0 |
||
23 | a2 = 0 |
||
24 | if ~ _len eq |
||
25 | repeat _len-1 |
||
26 | virtual at 0 |
||
27 | db _fmt,13,10,0,0 |
||
28 | load c1 word from %+a2-1 |
||
29 | end virtual |
||
30 | if (c1='%s')|(c1='%x')|(c1='%d') |
||
31 | store byte 0 at _id+%+a1-1 |
||
32 | a2 = a2 + 1 |
||
33 | else if (c1='\n') |
||
34 | store word $0A0D at _id+%+a1-1 |
||
35 | a1 = a1 + 1 |
||
36 | a2 = a2 + 1 |
||
37 | else |
||
38 | store word c1 at _id+%+a1-1 |
||
39 | end if |
||
40 | end repeat |
||
41 | end if |
||
42 | common |
||
43 | } |
||
44 | |||
45 | macro include_debug_strings { __include_debug_strings __debug_strings } |
||
46 | |||
47 | SHINFO0 fix SHINFO |
||
48 | |||
49 | macro SHINFO _num,_format,[_arg] { |
||
50 | common |
||
51 | SHFLOW _format,_arg |
||
52 | } |
||
53 | |||
54 | macro SHFLOW _format,[_arg] { |
||
55 | common |
||
56 | if __DEBUG__ = 1 |
||
57 | local ..f1,f2,a1,a2,c1,c2,..lbl |
||
58 | _debug_str_ fix __debug_str_ # a1 |
||
59 | a1 = 0 |
||
60 | c2 = 0 |
||
61 | f2 = 0 |
||
62 | repeat ..lbl-..f1-1 |
||
63 | virtual at 0 |
||
64 | db _format,13,10,0 |
||
65 | load c1 word from %-1 |
||
66 | end virtual |
||
67 | if c1 = '%s' |
||
68 | virtual at 0 |
||
69 | db _format,13,10,0 |
||
70 | store word 0 at %-1 |
||
71 | load c1 from f2-c2 |
||
72 | end virtual |
||
73 | if c1 <> 0 |
||
74 | DEBUGS _debug_str_+f2-c2 |
||
75 | end if |
||
76 | c2 = c2 + 1 |
||
77 | f2 = %+1 |
||
78 | a2 = 0 |
||
79 | forward |
||
80 | if a2 = a1 |
||
81 | DEBUGS _arg |
||
82 | end if |
||
83 | a2 = a2+1 |
||
84 | common |
||
85 | a1 = a1+1 |
||
86 | else if c1 = '%x' |
||
87 | virtual at 0 |
||
88 | db _format,13,10,0 |
||
89 | store word 0 at %-1 |
||
90 | load c1 from f2-c2 |
||
91 | end virtual |
||
92 | if c1 <> 0 |
||
93 | DEBUGS _debug_str_+f2-c2 |
||
94 | end if |
||
95 | c2 = c2 + 1 |
||
96 | f2 = %+1 |
||
97 | a2 = 0 |
||
98 | forward |
||
99 | if a2 = a1 |
||
100 | DEBUGH _arg |
||
101 | end if |
||
102 | a2 = a2+1 |
||
103 | common |
||
104 | a1 = a1+1 |
||
105 | else if c1 = '%d' |
||
106 | virtual at 0 |
||
107 | db _format,13,10,0 |
||
108 | store word 0 at %-1 |
||
109 | load c1 from f2-c2 |
||
110 | end virtual |
||
111 | if c1 <> 0 |
||
112 | DEBUGS _debug_str_+f2-c2 |
||
113 | end if |
||
114 | c2 = c2 + 1 |
||
115 | f2 = %+1 |
||
116 | a2 = 0 |
||
117 | forward |
||
118 | if a2 = a1 |
||
119 | DEBUGD _arg |
||
120 | end if |
||
121 | a2 = a2+1 |
||
122 | common |
||
123 | a1 = a1+1 |
||
124 | end if |
||
125 | end repeat |
||
126 | virtual at 0 |
||
127 | db _format,13,10,0 |
||
128 | load c1 from f2-c2 |
||
129 | end virtual |
||
130 | if c1 <> 0 |
||
131 | DEBUGS _debug_str_+f2-c2 |
||
132 | end if |
||
133 | virtual at 0 |
||
134 | ..f1 db _format,13,10,0 |
||
135 | ..lbl: |
||
136 | __debug_strings fix __debug_strings,_debug_str_,_format,..lbl-..f1-1-c2 |
||
137 | end virtual |
||
138 | end if |
||
139 | pushad |
||
140 | mov edi,sys_delay |
||
141 | mov eax,1 |
||
142 | call sys_int |
||
143 | popad |
||
144 | } |
||
145 | |||
146 | ;----------------------------------------------------------------------------- |
||
147 | |||
148 | macro jif _op1,_cond,_op2,_label,_op { |
||
149 | if _op eq |
||
150 | cmp _op1,_op2 |
||
151 | else |
||
152 | if _op2 eq |
||
153 | _op _op1 |
||
154 | else |
||
155 | _op _op1,_op2 |
||
156 | end if |
||
157 | end if |
||
158 | j#_cond _label |
||
159 | } |
||
160 | |||
161 | macro m2m op1,op2 { |
||
162 | pushd op2 |
||
163 | popd op1 |
||
164 | } |
||
165 | |||
166 | macro BITFIELD _bfnum,_size,[_name,_nbits] { |
||
167 | common |
||
168 | local _shift,_mask |
||
169 | _shift = 0 |
||
170 | .bit_field#_bfnum rb _size |
||
171 | if B_HOST eq HOST_BENDIAN |
||
172 | forward |
||
173 | _mask = 0 |
||
174 | repeat _nbits |
||
175 | _mask = (_mask shl 1) or 1 |
||
176 | end repeat |
||
177 | _name = _mask shl _shift |
||
178 | _name#_shift = _shift |
||
179 | _shift = _shift + _nbits |
||
180 | common |
||
181 | else |
||
182 | forward |
||
183 | _mask = 0 |
||
184 | repeat _nbits |
||
185 | _mask = (_mask shl 1) or 1 |
||
186 | end repeat |
||
187 | _name = _mask shl (_size-_shift-_nbits) |
||
188 | _name#_shift = _size-_shift-_nbits |
||
189 | _shift = _shift + _nbits |
||
190 | common |
||
191 | end if |
||
192 | } |
||
193 | |||
194 | ;----------------------------------------------------------------------------- |
||
195 | |||
196 | sys_delay = 5*4 |
||
197 | sys_pci = 62*4 |
||
198 | sys_debug_board = 63*4 |
||
199 | |||
200 | ;----------------------------------------------------------------------------- |
||
201 | |||
202 | func sys_int |
||
203 | begin |
||
204 | pushad |
||
205 | push eax |
||
206 | add edi,[systlb] |
||
207 | call dword[edi] |
||
208 | pop eax |
||
209 | popad |
||
210 | ret |
||
211 | endf |
||
212 | |||
213 | func debug_outstr |
||
214 | begin |
||
215 | mov eax,1 |
||
216 | .l1: |
||
217 | mov bl,[edx] |
||
218 | test bl,bl |
||
219 | jz .l2 |
||
220 | mov edi,sys_debug_board |
||
221 | call sys_int |
||
222 | inc edx |
||
223 | jmp .l1 |
||
224 | .l2: |
||
225 | ret |
||
226 | endf |
||
227 | |||
228 | macro DEBUGS [_str] { |
||
229 | common |
||
230 | pushf |
||
231 | pushad |
||
232 | local ..str,..label,..is_str |
||
233 | ..is_str = 0 |
||
234 | forward |
||
235 | if _str eqtype '' |
||
236 | ..is_str = 1 |
||
237 | end if |
||
238 | common |
||
239 | if ..is_str = 1 |
||
240 | jmp ..label |
||
241 | ..str db _str,0 |
||
242 | ..label: |
||
243 | mov edx,..str |
||
244 | call debug_outstr |
||
245 | else |
||
246 | mov edx,_str |
||
247 | call debug_outstr |
||
248 | end if |
||
249 | popad |
||
250 | popf |
||
251 | } |
||
252 | |||
253 | macro DEBUGF [_str] { |
||
254 | common |
||
255 | DEBUGS _str,13,10 |
||
256 | } |
||
257 | |||
258 | func debug_outchar |
||
259 | begin |
||
260 | pushad |
||
261 | mov bl,al |
||
262 | mov eax,1 |
||
263 | mov edi,sys_debug_board |
||
264 | call sys_int |
||
265 | popad |
||
266 | ret |
||
267 | endf |
||
268 | |||
269 | func debug_outdec |
||
270 | begin |
||
271 | mov ecx,10 |
||
272 | push -'0' |
||
273 | .l1: |
||
274 | xor edx,edx |
||
275 | div ecx |
||
276 | push edx |
||
277 | test eax,eax |
||
278 | jnz .l1 |
||
279 | .l2: |
||
280 | pop eax |
||
281 | add al,'0' |
||
282 | jz .l3 |
||
283 | call debug_outchar |
||
284 | jmp .l2 |
||
285 | .l3: |
||
286 | ret |
||
287 | endf |
||
288 | |||
289 | macro DEBUGD _dec { |
||
290 | pushf |
||
291 | pushad |
||
292 | if _dec eqtype eax |
||
293 | if _dec in |
||
294 | mov eax,_dec |
||
295 | else if _dec in |
||
296 | movzx eax,_dec |
||
297 | end if |
||
298 | else |
||
299 | if (_dec eqtype word[])|(_dec eqtype byte[]) |
||
300 | movzx eax,_dec |
||
301 | else |
||
302 | mov eax,_dec |
||
303 | end if |
||
304 | end if |
||
305 | call debug_outdec |
||
306 | popad |
||
307 | popf |
||
308 | } |
||
309 | |||
310 | func debug_outhex |
||
311 | __hexdigits db '0123456789ABCDEF' |
||
312 | begin |
||
313 | mov edx,8 |
||
314 | .l1: |
||
315 | rol eax,4 |
||
316 | push eax |
||
317 | and eax,0x0000000F |
||
318 | mov al,[__hexdigits+eax] |
||
319 | call debug_outchar |
||
320 | pop eax |
||
321 | dec edx |
||
322 | jnz .l1 |
||
323 | ret |
||
324 | endf |
||
325 | |||
326 | macro DEBUGH _hex { |
||
327 | pushf |
||
328 | pushad |
||
329 | if ~_hex eq eax |
||
330 | mov eax,_hex |
||
331 | end if |
||
332 | call debug_outhex |
||
333 | popad |
||
334 | popf |
||
335 | } |
||
336 | |||
337 | macro diff16 title,l1,l2 |
||
338 | { |
||
339 | local s,d |
||
340 | s = l2-l1 |
||
341 | display title,': 0x' |
||
342 | repeat 8 |
||
343 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
344 | if d > '9' |
||
345 | d = d + 'A'-'9'-1 |
||
346 | end if |
||
347 | display d |
||
348 | end repeat |
||
349 | display 13,10 |
||
350 | } |
||
351 | |||
352 | macro diff10 title,l1,l2 |
||
353 | { |
||
354 | local s,d,z,m |
||
355 | s = l2-l1 |
||
356 | z = 0 |
||
357 | m = 1000000000 |
||
358 | display title,': ' |
||
359 | repeat 10 |
||
360 | d = '0' + s / m |
||
361 | s = s - (s/m)*m |
||
362 | m = m / 10 |
||
363 | if d <> '0' |
||
364 | z = 1 |
||
365 | end if |
||
366 | if z <> 0 |
||
367 | display d |
||
368 | end if |
||
369 | end repeat |
||
370 | display 13,10 |
||
371 | } |
||
372 | |||
373 | ;----------------------------------------------------------------------------- |
||
374 | ;///// END /////////////////////////////////////////////////////////////////// |
||
375 | ;----------------------------------------------------------------------------->>>>>> |