Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
214 | serge | 1 | |
2 | |||
3 | |||
4 | |||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
13 | R9000 equ 0x4966 ;RV250 |
||
14 | R9200 equ 0x5961 ;RV280 |
||
15 | R9500 equ 0x4144 ;R300 |
||
16 | R9500P equ 0x4E45 ;R300 |
||
17 | R9550 equ 0x4153 ;RV350 |
||
18 | R9600 equ 0x4150 ;RV350 |
||
19 | R9600XT equ 0x4152 ;RV360 |
||
20 | R9700P equ 0x4E44 ;R300 |
||
21 | R9800 equ 0x4E49 ;R350 |
||
22 | R9800P equ 0x4E48 ;R350 |
||
23 | R9800XT equ 0x4E4A ;R360 |
||
24 | |||
25 | |||
26 | new_app_base equ 0x60400000; 0x01000000 |
||
27 | PROC_BASE equ OS_BASE+0x0080000 |
||
28 | |||
29 | |||
30 | PG_NOCACHE equ 0x018 |
||
31 | |||
32 | |||
33 | { .handle dd ? |
||
34 | .io_code dd ? |
||
35 | .input dd ? |
||
36 | .inp_size dd ? |
||
37 | .output dd ? |
||
38 | .out_size dd ? |
||
39 | } |
||
40 | |||
41 | |||
42 | IOCTL IOCTL |
||
43 | end virtual |
||
44 | |||
45 | |||
46 | RD_RB3D_CNTL equ 1c3ch |
||
47 | |||
48 | |||
49 | RD_CRTC_GEN_CNTL equ 0050h |
||
50 | RD_CRTC_CUR_EN equ 10000h |
||
51 | RD_DISPLAY_BASE_ADDR equ 023ch |
||
52 | RD_DEFAULT_OFFSET equ 16e0h |
||
53 | CUR_HORZ_VERT_OFF equ 0268h |
||
54 | CUR_HORZ_VERT_POSN equ 0264h |
||
55 | CUR_OFFSET equ 0260h |
||
56 | RD_RB3D_CNTL equ 1c3ch |
||
57 | RD_RBBM_STATUS equ 0e40h |
||
58 | RD_RBBM_FIFOCNT_MASK equ 007fh |
||
59 | RD_RBBM_ACTIVE equ 80000000h |
||
60 | RD_TIMEOUT equ 2000000 |
||
61 | |||
62 | |||
63 | RD_DP_BRUSH_BKGD_CLR equ 01478h |
||
64 | RD_DP_BRUSH_FRGD_CLR equ 0147ch |
||
65 | RD_DP_SRC_BKGD_CLR equ 015dch |
||
66 | RD_DP_SRC_FRGD_CLR equ 015d8h |
||
67 | RD_DP_CNTL equ 016c0h |
||
68 | RD_DP_DATATYPE equ 016c4h |
||
69 | RD_DP_WRITE_MASK equ 016cch |
||
70 | RD_DP_SRC_SOURCE_MEMORY equ (2 shl 24) |
||
71 | RD_DP_SRC_SOURCE_HOST_DATA equ (3 shl 24) |
||
72 | RD_DEFAULT_SC_BOTTOM_RIGHT equ 16e8h |
||
73 | RD_GMC_BRUSH_SOLID_COLOR equ (13 shl 4) |
||
74 | RD_DEFAULT_SC_RIGHT_MAX equ 1fffh |
||
75 | RD_DEFAULT_SC_BOTTOM_MAX equ 1fff0000h |
||
76 | RD_GMC_DST_DATATYPE_SHIFT equ 8 |
||
77 | |||
78 | |||
79 | RD_ROP3_P equ 00f00000h |
||
80 | |||
81 | |||
82 | RD_RB2D_DSTCACHE_CTLSTAT equ 0342ch |
||
83 | RD_RB2D_DC_FLUSH_ALL equ 000fh |
||
84 | RD_RB2D_DC_BUSY equ 80000000h |
||
85 | |||
86 | |||
87 | RD_GMC_SRC_DATATYPE_COLOR equ (3 shl 12) |
||
88 | RD_GMC_CLR_CMP_CNTL_DIS equ (1 shl 28) |
||
89 | RD_GMC_WR_MSK_DIS equ (1 shl 30) |
||
90 | |||
91 | |||
92 | |||
93 | |||
94 | RD_SRC_PITCH_OFFSET equ 1428h |
||
95 | |||
96 | |||
97 | RD_DST_Y_TOP_TO_BOTTOM equ 2 |
||
98 | RD_DST_Y_X equ 1438h |
||
99 | RD_DST_WIDTH_HEIGHT equ 1598h |
||
100 | RD_DST_LINE_START equ 1600h |
||
101 | RD_DST_LINE_END equ 1604h |
||
102 | R300_MEM_NUM_CHANNELS_MASK equ 0003h |
||
103 | |||
104 | |||
105 | { |
||
106 | mov edi, [ati_io] |
||
107 | mov op1, [edi+op2] |
||
108 | } |
||
109 | |||
110 | |||
111 | { |
||
112 | mov edi, [ati_io] |
||
113 | mov dword [edi+dest], src |
||
114 | } |
||
115 | |||
116 | |||
117 | |||
118 | public service_proc |
||
119 | |||
120 | |||
121 | extrn PciApi |
||
122 | extrn PciRead32 |
||
123 | extrn AllocKernelSpace |
||
124 | extrn MapPage |
||
125 | extrn RegService |
||
126 | extrn SetHwCursor |
||
127 | extrn LFBAddress |
||
128 | extrn LoadFile |
||
129 | |||
130 | |||
131 | |||
132 | |||
133 | DRV_EXIT equ -1 |
||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
140 | cmp eax, 1 |
||
141 | je .entry |
||
142 | jmp .exit |
||
143 | .entry: |
||
144 | if DEBUG |
||
145 | mov esi, msgInit |
||
146 | call SysMsgBoardStr |
||
147 | end if |
||
148 | |||
149 | |||
150 | test eax, eax |
||
151 | jz .fail |
||
152 | |||
153 | |||
154 | test eax, eax |
||
155 | jz @F |
||
156 | mov [user_arrow], eax |
||
157 | @@: |
||
158 | stdcall ati_init_cursor, [user_arrow] |
||
159 | |||
160 | |||
161 | test eax, eax |
||
162 | jz .fail |
||
163 | |||
164 | |||
165 | test eax, eax |
||
166 | jz .fail |
||
167 | mov ebx, SetHwCursor |
||
168 | mov dword [ebx], drvCursorPos ;enable hardware cursor |
||
169 | ret |
||
170 | .fail: |
||
171 | if DEBUG |
||
172 | mov esi, msgFail |
||
173 | call SysMsgBoardStr |
||
174 | end if |
||
175 | |||
176 | |||
177 | xor eax, eax |
||
178 | mov ebx, SetHwCursor |
||
179 | mov dword [ebx], eax ;force disable hardware cursor |
||
180 | ret |
||
181 | endp |
||
182 | |||
183 | |||
184 | io_code equ IOCTL.io_code |
||
185 | input equ IOCTL.input |
||
186 | inp_size equ IOCTL.inp_size |
||
187 | output equ IOCTL.output |
||
188 | out_size equ IOCTL.out_size |
||
189 | |||
190 | |||
191 | proc service_proc stdcall, ioctl:dword |
||
192 | |||
193 | |||
194 | ; mov eax, [edi+io_code] |
||
195 | |||
196 | |||
197 | ret |
||
198 | endp |
||
199 | |||
200 | |||
201 | restore io_code |
||
202 | restore input |
||
203 | restore inp_size |
||
204 | restore output |
||
205 | restore out_size |
||
206 | |||
207 | |||
208 | proc detect_ati |
||
209 | locals |
||
210 | last_bus dd ? |
||
211 | endl |
||
212 | |||
213 | |||
214 | mov [bus], eax |
||
215 | inc eax |
||
216 | call PciApi |
||
217 | cmp eax, -1 |
||
218 | je .err |
||
219 | |||
220 | |||
221 | |||
222 | |||
223 | and [devfn], 0 |
||
224 | .next_dev: |
||
225 | stdcall PciRead32, [bus], [devfn], dword 0 |
||
226 | test eax, eax |
||
227 | jz .next |
||
228 | cmp eax, -1 |
||
229 | je .next |
||
230 | |||
231 | |||
232 | @@: |
||
233 | mov ebx, [edi] |
||
234 | test ebx, ebx |
||
235 | jz .next |
||
236 | |||
237 | |||
238 | je .found |
||
239 | add edi, 4 |
||
240 | jmp @B |
||
241 | |||
242 | |||
243 | cmp [devfn], 256 |
||
244 | jb .next_dev |
||
245 | mov eax, [bus] |
||
246 | inc eax |
||
247 | mov [bus], eax |
||
248 | cmp eax, [last_bus] |
||
249 | jna .next_bus |
||
250 | xor eax, eax |
||
251 | ret |
||
252 | .found: |
||
253 | xor eax, eax |
||
254 | inc eax |
||
255 | ret |
||
256 | .err: |
||
257 | xor eax, eax |
||
258 | ret |
||
259 | endp |
||
260 | |||
261 | |||
262 | proc init_ati |
||
263 | |||
264 | |||
265 | test eax, eax |
||
266 | jz .fail |
||
267 | |||
268 | |||
269 | |||
270 | |||
271 | and eax, 0xFFFF0000 |
||
272 | mov esi, eax |
||
273 | |||
274 | |||
275 | mov edx, 16 |
||
276 | @@: |
||
277 | stdcall MapPage,edi,esi,PG_SW+PG_NOCACHE |
||
278 | add edi, 0x1000 |
||
279 | add esi, 0x1000 |
||
280 | dec edx |
||
281 | jnz @B |
||
282 | |||
283 | |||
284 | mov dword [edi+RD_RB3D_CNTL], 0 |
||
285 | call engRestore |
||
286 | |||
287 | |||
288 | mov eax, [edi+0x50] |
||
289 | mov ebx,3 |
||
290 | shl ebx,20 |
||
291 | not ebx |
||
292 | and eax,ebx |
||
293 | mov ebx, 2 |
||
294 | shl ebx,20 |
||
295 | or eax, ebx |
||
296 | mov [edi+0x50], eax |
||
297 | |||
298 | |||
299 | pushd 0 |
||
300 | call drvCursorPos |
||
301 | call drvShowCursor |
||
302 | xor eax, eax |
||
303 | inc eax |
||
304 | .fail: |
||
305 | ret |
||
306 | endp |
||
307 | |||
308 | |||
309 | drvShowCursor: |
||
310 | mov edi, [ati_io] |
||
311 | |||
312 | |||
313 | bts eax,16 |
||
314 | mov [edi+RD_CRTC_GEN_CNTL], eax |
||
315 | ret |
||
316 | |||
317 | |||
318 | drvCursorPos: |
||
319 | push ebp |
||
320 | mov ebp, esp |
||
321 | mov eax, 80000000h |
||
322 | wrr CUR_HORZ_VERT_OFF, eax |
||
323 | |||
324 | |||
325 | shl eax, 16 |
||
326 | or eax, [ebp+12] |
||
327 | or eax, 80000000h |
||
328 | wrr CUR_HORZ_VERT_POSN, eax |
||
329 | |||
330 | |||
331 | wrr CUR_OFFSET, eax |
||
332 | leave |
||
333 | ret 8 |
||
334 | |||
335 | |||
336 | proc ati_init_cursor stdcall, arrow:dword |
||
337 | locals |
||
338 | rBase dd ? |
||
339 | pQuad dd ? |
||
340 | pBits dd ? |
||
341 | pAnd dd ? |
||
342 | width dd ? |
||
343 | height dd ? |
||
344 | counter dd ? |
||
345 | endl |
||
346 | |||
347 | |||
348 | |||
349 | |||
350 | add esi,[esi+18d] |
||
351 | |||
352 | |||
353 | add eax, [esi] |
||
354 | mov [pQuad],eax |
||
355 | add eax,64 |
||
356 | mov [pBits],eax |
||
357 | add eax, 0x200 |
||
358 | mov [pAnd],eax |
||
359 | mov eax,[esi+4] |
||
360 | mov [width],eax |
||
361 | mov ebx,[esi+8] |
||
362 | shr ebx,1 |
||
363 | mov [height],ebx |
||
364 | |||
365 | |||
366 | add edi, 32*31*4 |
||
367 | mov [rBase],edi |
||
368 | |||
369 | |||
370 | mov ebx, [pBits] |
||
371 | .l1: |
||
372 | mov eax, [esi] |
||
373 | bswap eax |
||
374 | mov [counter], 16 |
||
375 | @@: |
||
376 | xor edx, edx |
||
377 | shl eax,1 |
||
378 | setc dl |
||
379 | dec edx |
||
380 | |||
381 | |||
382 | and ecx, 0xF0 |
||
383 | shr ecx, 2 |
||
384 | add ecx, [pQuad] |
||
385 | mov ecx, [ecx] |
||
386 | and ecx, edx |
||
387 | and edx, 0xFF000000 |
||
388 | or edx, ecx |
||
389 | mov [edi], edx |
||
390 | |||
391 | |||
392 | shl eax,1 |
||
393 | setc dl |
||
394 | dec edx |
||
395 | |||
396 | |||
397 | and ecx, 0x0F |
||
398 | shl ecx, 2 |
||
399 | add ecx, [pQuad] |
||
400 | mov ecx, [ecx] |
||
401 | and ecx, edx |
||
402 | and edx, 0xFF000000 |
||
403 | or edx, ecx |
||
404 | mov [edi+4], edx |
||
405 | |||
406 | |||
407 | add edi, 8 |
||
408 | dec [counter] |
||
409 | jnz @B |
||
410 | |||
411 | |||
412 | mov edi,[rBase] |
||
413 | sub edi,128 |
||
414 | mov [rBase],edi |
||
415 | sub [height],1 |
||
416 | jnz .l1 |
||
417 | |||
418 | |||
419 | add edi, CURSOR_IMAGE_OFFSET |
||
420 | mov ecx, 64*64 |
||
421 | xor eax,eax |
||
422 | rep stosd |
||
423 | |||
424 | |||
425 | mov edi, LFBAddress |
||
426 | add edi, CURSOR_IMAGE_OFFSET |
||
427 | mov ebx, 32 |
||
428 | lc: |
||
429 | mov ecx, 32 |
||
430 | lb: |
||
431 | mov eax, [esi] |
||
432 | mov [edi], eax |
||
433 | add esi, 4 |
||
434 | add edi, 4 |
||
435 | sub ecx, 1 |
||
436 | jnz lb |
||
437 | |||
438 | |||
439 | sub ebx, 1 |
||
440 | jnz lc |
||
441 | |||
442 | |||
443 | endp |
||
444 | |||
445 | |||
446 | proc engFlush |
||
447 | |||
448 | |||
449 | |||
450 | |||
451 | or eax,RD_RB2D_DC_FLUSH_ALL |
||
452 | mov [edi+RD_RB2D_DSTCACHE_CTLSTAT],eax |
||
453 | |||
454 | |||
455 | @@: |
||
456 | mov eax,[edi+RD_RB2D_DSTCACHE_CTLSTAT] |
||
457 | and eax, RD_RB2D_DC_BUSY |
||
458 | jz .exit |
||
459 | |||
460 | |||
461 | jnz @B |
||
462 | .exit: |
||
463 | ret |
||
464 | endp |
||
465 | |||
466 | |||
467 | engWaitForFifo: |
||
468 | cnt equ bp+8 |
||
469 | push ebp |
||
470 | mov ebp, esp |
||
471 | |||
472 | |||
473 | |||
474 | |||
475 | @@: |
||
476 | mov eax, [edi+RD_RBBM_STATUS] |
||
477 | and eax, RD_RBBM_FIFOCNT_MASK |
||
478 | cmp eax, [ebp+8] |
||
479 | jae .exit |
||
480 | |||
481 | |||
482 | jmp @B |
||
483 | |||
484 | |||
485 | leave |
||
486 | ret 4 |
||
487 | |||
488 | |||
489 | proc engWaitForIdle |
||
490 | |||
491 | |||
492 | call engWaitForFifo |
||
493 | |||
494 | |||
495 | mov ecx ,RD_TIMEOUT |
||
496 | @@: |
||
497 | mov eax, [edi+RD_RBBM_STATUS] |
||
498 | and eax,RD_RBBM_ACTIVE |
||
499 | jz .exit |
||
500 | |||
501 | |||
502 | jnz @B |
||
503 | .exit: |
||
504 | call engFlush |
||
505 | ret |
||
506 | endp |
||
507 | |||
508 | |||
509 | proc engRestore |
||
510 | |||
511 | |||
512 | ; call engWaitForFifo |
||
513 | |||
514 | |||
515 | |||
516 | |||
517 | call engWaitForFifo |
||
518 | |||
519 | |||
520 | |||
521 | |||
522 | shr eax, 10d |
||
523 | or eax,(64d shl 22d) |
||
524 | mov [edi+RD_DEFAULT_OFFSET],eax |
||
525 | mov [edi+RD_SRC_PITCH_OFFSET],eax |
||
526 | mov [edi+RD_DST_PITCH_OFFSET],eax |
||
527 | |||
528 | |||
529 | call engWaitForFifo |
||
530 | |||
531 | |||
532 | mov eax, [edi+RD_DP_DATATYPE] |
||
533 | btr eax, 29d |
||
534 | mov [edi+RD_DP_DATATYPE],eax |
||
535 | |||
536 | |||
537 | call engWaitForFifo |
||
538 | |||
539 | |||
540 | mov dword [edi+RD_DEFAULT_SC_BOTTOM_RIGHT],\ |
||
541 | (RD_DEFAULT_SC_RIGHT_MAX or RD_DEFAULT_SC_BOTTOM_MAX) |
||
542 | |||
543 | |||
544 | call engWaitForFifo |
||
545 | |||
546 | |||
547 | mov dword [edi+RD_DP_GUI_MASTER_CNTL],\ |
||
548 | (RD_GMC_BRUSH_SOLID_COLOR or \ |
||
549 | RD_GMC_SRC_DATATYPE_COLOR or \ |
||
550 | (6 shl RD_GMC_DST_DATATYPE_SHIFT) or \ |
||
551 | RD_GMC_CLR_CMP_CNTL_DIS or \ |
||
552 | RD_ROP3_P or \ |
||
553 | RD_GMC_WR_MSK_DIS) |
||
554 | |||
555 | |||
556 | |||
557 | call engWaitForFifo |
||
558 | |||
559 | |||
560 | |||
561 | |||
562 | mov dword [edi+RD_DST_LINE_END], 0 |
||
563 | mov dword [edi+RD_DP_BRUSH_FRGD_CLR], 808000ffh |
||
564 | mov dword [edi+RD_DP_BRUSH_BKGD_CLR], 002020ffh |
||
565 | mov dword [edi+RD_DP_SRC_FRGD_CLR], 808000ffh |
||
566 | mov dword [edi+RD_DP_SRC_BKGD_CLR], 004000ffh |
||
567 | mov dword [edi+RD_DP_WRITE_MASK],0ffffffffh |
||
568 | |||
569 | |||
570 | |||
571 | |||
572 | endp |
||
573 | |||
574 | |||
575 | |||
576 | engSetupSolidFill: |
||
577 | push ebp |
||
578 | mov ebp, esp |
||
579 | |||
580 | |||
581 | call engWaitForFifo |
||
582 | |||
583 | |||
584 | |||
585 | |||
586 | wrr RD_DP_BRUSH_FRGD_CLR,eax |
||
587 | |||
588 | |||
589 | mov dword [edi+RD_DP_CNTL],(RD_DST_X_LEFT_TO_RIGHT or RD_DST_Y_TOP_TO_BOTTOM) |
||
590 | leave |
||
591 | ret 4 |
||
592 | |||
593 | |||
594 | |||
595 | drvSolidFill: |
||
596 | ;x:word,y:word,w:word,h:word,color:dword |
||
597 | push ebp |
||
598 | mov ebp, esp |
||
599 | x equ ebp+8 |
||
600 | y equ ebp+12 |
||
601 | w equ ebp+16 |
||
602 | h equ ebp+20 |
||
603 | color equ ebp+24 |
||
604 | |||
605 | |||
606 | call engSetupSolidFill |
||
607 | |||
608 | |||
609 | call engWaitForFifo |
||
610 | |||
611 | |||
612 | |||
613 | |||
614 | mov ebx, [x] |
||
615 | shl eax,16 |
||
616 | or eax, ebx |
||
617 | |||
618 | |||
619 | mov edx, [h] |
||
620 | shl ecx,16 |
||
621 | or ecx, edx |
||
622 | mov [edi+RD_DST_Y_X], eax |
||
623 | mov [edi+RD_DST_WIDTH_HEIGHT], ecx |
||
624 | call engFlush |
||
625 | leave |
||
626 | ret 20 |
||
627 | |||
628 | |||
629 | devices dd (R8500 shl 16)+VID_ATI |
||
630 | dd (R9000 shl 16)+VID_ATI |
||
631 | dd (R9200 shl 16)+VID_ATI |
||
632 | dd (R9500 shl 16)+VID_ATI |
||
633 | dd (R9500P shl 16)+VID_ATI |
||
634 | dd (R9550 shl 16)+VID_ATI |
||
635 | dd (R9600 shl 16)+VID_ATI |
||
636 | dd (R9600XT shl 16)+VID_ATI |
||
637 | dd (R9700P shl 16)+VID_ATI |
||
638 | dd (R9800 shl 16)+VID_ATI |
||
639 | dd (R9800P shl 16)+VID_ATI |
||
640 | dd (R9800XT shl 16)+VID_ATI |
||
641 | dd 0 ;terminator |
||
642 | |||
643 | |||
644 | sz_ati_srv db 'ATI2D',0 |
||
645 | user_file db '/rd/1/user.cur',0 |
||
646 | |||
647 | |||
648 | |||
649 | msgPCI db 'PCI accsess not supported',13,10,0 |
||
650 | msgFail db 'device not found',13,10,0 |
||
651 | |||
652 | |||
653 | |||
654 | |||
655 | pArrow: |
||
656 | file 'arrow.cur' |
||
657 | |||
658 | |||
659 | |||
660 | |||
661 | |||
662 | |||
663 | devfn dd ? |
||
664 | ati_io dd ? |
||
665 |