Subversion Repositories Kolibri OS

Rev

Rev 2465 | Rev 3626 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2465 Rev 3500
Line 19... Line 19...
19
;;                                                              ;;
19
;;                                                              ;;
20
;;  See file COPYING for details                                ;;
20
;;  See file COPYING for details                                ;;
21
;;                                                              ;;
21
;;                                                              ;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 23... Line 23...
23
 
23
 
Line 24... Line 24...
24
$Revision: 2465 $
24
$Revision: 3500 $
25
 
25
 
26
;***************************************************************************
26
;***************************************************************************
27
;   Function
27
;   Function
Line 153... Line 153...
153
;***************************************************************************
153
;***************************************************************************
Line 154... Line 154...
154
 
154
 
Line 155... Line 155...
155
align 4
155
align 4
-
 
156
 
156
 
157
pci_read_reg:
157
pci_read_reg:
158
        push    ebx esi
Line 158... Line 159...
158
        cmp     byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
159
        cmp     byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
159
        je      pci_read_reg_2
160
        je      pci_read_reg_2
160
 
-
 
161
                ; mechanism 1
161
 
Line 162... Line 162...
162
        push    esi   ; save register size into ESI
162
                ; mechanism 1
163
        mov     esi, eax
163
        mov     esi, eax ; save register size into ESI
164
        and     esi, 3
164
        and     esi, 3
Line 200... Line 200...
200
        xchg    eax, [esp]
200
        xchg    eax, [esp]
201
        mov     dx, 0xcf8
201
        mov     dx, 0xcf8
202
        out     dx, eax
202
        out     dx, eax
Line 203... Line 203...
203
 
203
 
204
        pop     eax
204
        pop     eax
205
        pop     esi
205
        pop     esi ebx
206
        ret
206
        ret
Line 207... Line 207...
207
pci_read_reg_2:
207
pci_read_reg_2:
208
 
208
 
Line 209... Line 209...
209
        test    bh, 128 ;mech#2 only supports 16 devices per bus
209
        test    bh, 128 ;mech#2 only supports 16 devices per bus
210
        jnz     pci_read_reg_err
-
 
211
 
210
        jnz     pci_read_reg_err
Line 212... Line 211...
212
        push    esi; save register size into ESI
211
 
213
        mov     esi, eax
212
        mov     esi, eax ; save register size into ESI
214
        and     esi, 3
213
        and     esi, 3
Line 260... Line 259...
260
        mov     dl, 0xf8
259
        mov     dl, 0xf8
261
        mov     al, ah
260
        mov     al, ah
262
        out     dx, al
261
        out     dx, al
Line 263... Line 262...
263
 
262
 
264
        pop     eax
263
        pop     eax
265
        pop     esi
264
        pop     esi ebx
Line 266... Line 265...
266
        ret
265
        ret
267
 
266
 
268
pci_read_reg_err:
267
pci_read_reg_err:
-
 
268
        xor     eax, eax
269
        xor     eax, eax
269
        dec     eax
Line 270... Line 270...
270
        dec     eax
270
        pop     esi ebx
271
        ret
271
        ret
Line 284... Line 284...
284
;***************************************************************************
284
;***************************************************************************
Line 285... Line 285...
285
 
285
 
Line 286... Line 286...
286
align 4
286
align 4
-
 
287
 
287
 
288
pci_write_reg:
288
pci_write_reg:
289
        push    esi ebx
Line 289... Line 290...
289
        cmp     byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
290
        cmp     byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
290
        je      pci_write_reg_2
291
        je      pci_write_reg_2
291
 
-
 
292
                ; mechanism 1
292
 
Line 293... Line 293...
293
        push    esi   ; save register size into ESI
293
                ; mechanism 1
294
        mov     esi, eax
294
        mov     esi, eax ; save register size into ESI
295
        and     esi, 3
295
        and     esi, 3
Line 333... Line 333...
333
        pop     eax
333
        pop     eax
334
        mov     dl, 0xf8
334
        mov     dl, 0xf8
335
        out     dx, eax
335
        out     dx, eax
Line 336... Line 336...
336
 
336
 
337
        xor     eax, eax
337
        xor     eax, eax
Line 338... Line 338...
338
        pop     esi
338
        pop     ebx esi
339
 
339
 
Line 340... Line 340...
340
        ret
340
        ret
341
pci_write_reg_2:
341
pci_write_reg_2:
Line 342... Line 342...
342
 
342
 
343
        test    bh, 128 ;mech#2 only supports 16 devices per bus
-
 
344
        jnz     pci_write_reg_err
343
        test    bh, 128 ;mech#2 only supports 16 devices per bus
Line 345... Line 344...
345
 
344
        jnz     pci_write_reg_err
346
 
345
 
347
        push    esi; save register size into ESI
346
 
Line 395... Line 394...
395
        mov     dl, 0xf8
394
        mov     dl, 0xf8
396
        mov     al, ah
395
        mov     al, ah
397
        out     dx, al
396
        out     dx, al
Line 398... Line 397...
398
 
397
 
399
        xor     eax, eax
398
        xor     eax, eax
400
        pop     esi
399
        pop     ebx esi
Line 401... Line 400...
401
        ret
400
        ret
402
 
401
 
403
pci_write_reg_err:
402
pci_write_reg_err:
-
 
403
        xor     eax, eax
404
        xor     eax, eax
404
        dec     eax
Line 405... Line 405...
405
        dec     eax
405
        pop     ebx esi
406
        ret
406
        ret
407
 
407
 
Line 656... Line 656...
656
.return_ab:
656
.return_ab:
657
        mov     dword[esp + 20], ebx
657
        mov     dword[esp + 20], ebx
658
.return_a:
658
.return_a:
659
        mov     dword[esp + 32], eax
659
        mov     dword[esp + 32], eax
660
        ret
660
        ret
-
 
661
 
-
 
662
proc pci_enum
-
 
663
        push    ebp
-
 
664
        mov     ebp, esp
-
 
665
        push    0
-
 
666
virtual at ebp-4
-
 
667
.devfn          db      ?
-
 
668
.bus            db      ?
-
 
669
end virtual
-
 
670
.loop:
-
 
671
        mov     ah, [.bus]
-
 
672
        mov     al, 2
-
 
673
        mov     bh, [.devfn]
-
 
674
        mov     bl, 0
-
 
675
        call    pci_read_reg
-
 
676
        cmp     eax, 0xFFFFFFFF
-
 
677
        jnz     .has_device
-
 
678
        test    byte [.devfn], 7
-
 
679
        jnz     .next_func
-
 
680
        jmp     .no_device
-
 
681
.has_device:
-
 
682
        push    eax
-
 
683
        push    sizeof.PCIDEV
-
 
684
        pop     eax
-
 
685
        call    malloc
-
 
686
        pop     ecx
-
 
687
        test    eax, eax
-
 
688
        jz      .nomemory
-
 
689
        mov     edi, eax
-
 
690
        mov     [edi+PCIDEV.vendor_device_id], ecx
-
 
691
        mov     eax, pcidev_list
-
 
692
        mov     ecx, [eax+PCIDEV.bk]
-
 
693
        mov     [edi+PCIDEV.bk], ecx
-
 
694
        mov     [edi+PCIDEV.fd], eax
-
 
695
        mov     [ecx+PCIDEV.fd], edi
-
 
696
        mov     [eax+PCIDEV.bk], edi
-
 
697
        mov     eax, dword [.devfn]
-
 
698
        mov     word [edi+PCIDEV.devfn], ax
-
 
699
        mov     bh, al
-
 
700
        mov     al, 2
-
 
701
        mov     bl, 8
-
 
702
        call    pci_read_reg
-
 
703
        shr     eax, 8
-
 
704
        mov     [edi+PCIDEV.class], eax
-
 
705
        test    byte [.devfn], 7
-
 
706
        jnz     .next_func
-
 
707
        mov     ah, [.bus]
-
 
708
        mov     al, 0
-
 
709
        mov     bh, [.devfn]
-
 
710
        mov     bl, 0Eh
-
 
711
        call    pci_read_reg
-
 
712
        test    al, al
-
 
713
        js      .next_func
-
 
714
.no_device:
-
 
715
        or      byte [.devfn], 7
-
 
716
.next_func:
-
 
717
        inc     dword [.devfn]
-
 
718
        mov     ah, [.bus]
-
 
719
        cmp     ah, [BOOT_VAR+0x9021]
-
 
720
        jbe     .loop
-
 
721
.nomemory:
-
 
722
        leave
-
 
723
        ret
-
 
724
endp