Subversion Repositories Kolibri OS

Rev

Rev 9232 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9232 Rev 9243
Line 226... Line 226...
226
        pci_bus         dd ?
226
        pci_bus         dd ?
227
        pci_dev         dd ?
227
        pci_dev         dd ?
228
        rx_desc         dd ?
228
        rx_desc         dd ?
229
        cur_tx          dd ?
229
        cur_tx          dd ?
230
        last_tx         dd ?
230
        last_tx         dd ?
-
 
231
        link_timer      dd ?
231
        ee_bus_width    db ?
232
        ee_bus_width    db ?
232
        irq_line        db ?
233
        irq_line        db ?
Line 233... Line 234...
233
 
234
 
234
        rb 0x100 - ($ and 0xff) ; align 256
235
        rb 0x100 - ($ and 0xff) ; align 256
Line 410... Line 411...
410
;;                                                                        ;;
411
;;                                                                        ;;
411
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
412
;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;;
Line 412... Line 413...
412
 
413
 
-
 
414
 
-
 
415
unload:
-
 
416
 
-
 
417
        cmp     [ebx + device.link_timer], 0
-
 
418
        je      @f
-
 
419
        invoke  CancelTimerHS, [ebx + device.link_timer]
413
 
420
  @@:
414
unload:
421
 
415
        ; TODO: (in this particular order)
422
        ; TODO: (in this particular order)
416
        ;
423
        ;
417
        ; - Stop the device
424
        ; - Stop the device
Line 473... Line 480...
473
;----------
480
;----------
Line 474... Line 481...
474
 
481
 
475
align 4
482
align 4
Line -... Line 483...
-
 
483
reset:
-
 
484
 
-
 
485
; Stop link check timer if it was already running
-
 
486
        cmp     [ebx + device.link_timer], 0
-
 
487
        je      @f
-
 
488
        invoke  CancelTimerHS, [ebx + device.link_timer]
-
 
489
  @@:
476
reset:
490
 
477
 
491
; attach int handler
478
        movzx   eax, [ebx + device.irq_line]
492
        movzx   eax, [ebx + device.irq_line]
479
        DEBUGF  1,"Attaching int handler to irq %x\n", eax:1
493
        DEBUGF  1,"Attaching int handler to irq %x\n", eax:1
480
        invoke  AttachIntHandler, eax, int_handler, ebx
494
        invoke  AttachIntHandler, eax, int_handler, ebx
Line 637... Line 651...
637
        set_io  [ebx + device.io_addr], REG_SCB_CMD
651
        set_io  [ebx + device.io_addr], REG_SCB_CMD
638
        mov     ax, CU_START                            ; expect Interrupts from now on
652
        mov     ax, CU_START                            ; expect Interrupts from now on
639
        out     dx, ax
653
        out     dx, ax
640
        call    cmd_wait
654
        call    cmd_wait
Line -... Line 655...
-
 
655
 
-
 
656
; Start media check timer
-
 
657
        mov     [ebx + device.state], ETH_LINK_DOWN
641
 
658
        invoke  TimerHS, 0, 50, check_media_mii, ebx
-
 
659
        mov     [ebx + device.link_timer], eax
642
        DEBUGF  1,"Reset complete\n"
660
 
Line 643... Line -...
643
        mov     [ebx + device.mtu], 1514
-
 
644
 
661
        mov     [ebx + device.mtu], 1514
Line 645... Line 662...
645
; Set link state to unknown
662
 
646
        mov     [ebx + device.state], ETH_LINK_UNKNOWN
663
        DEBUGF  1,"Reset complete\n"
Line 647... Line 664...
647
 
664
 
Line 980... Line 997...
980
        xor     eax, eax
997
        xor     eax, eax
Line 981... Line 998...
981
 
998
 
Line -... Line 999...
-
 
999
        ret
-
 
1000
 
-
 
1001
 
-
 
1002
 
-
 
1003
align 16
-
 
1004
proc check_media_mii stdcall dev:dword
-
 
1005
 
-
 
1006
        spin_lock_irqsave
-
 
1007
 
-
 
1008
        mov     ebx, [dev]
-
 
1009
 
-
 
1010
        mov     ecx, 1  ;;;
-
 
1011
        mov     edx, MII_BMSR
-
 
1012
        call    mdio_read
-
 
1013
 
-
 
1014
        mov     ecx, 1  ;;;
-
 
1015
        mov     edx, MII_BMSR
-
 
1016
        call    mdio_read
-
 
1017
 
-
 
1018
        mov     ecx, eax
-
 
1019
        and     eax, BMSR_LSTATUS
-
 
1020
        shr     eax, 2
-
 
1021
        cmp     eax, [ebx + device.state]
-
 
1022
        jne     .changed
-
 
1023
 
-
 
1024
        spin_unlock_irqrestore
-
 
1025
        ret
-
 
1026
 
-
 
1027
  .changed:
-
 
1028
        test    eax, eax
-
 
1029
        jz      .update
-
 
1030
 
-
 
1031
        test    ecx, BMSR_ANEGCOMPLETE
-
 
1032
        jz      .update
-
 
1033
 
-
 
1034
        mov     ecx, 1  ;;;
-
 
1035
        mov     edx, MII_ADVERTISE
-
 
1036
        call    mdio_read
-
 
1037
        mov     esi, eax
-
 
1038
 
-
 
1039
        mov     ecx, 1  ;;;
-
 
1040
        mov     edx, MII_LPA
-
 
1041
        call    mdio_read
-
 
1042
        and     eax, esi
-
 
1043
 
-
 
1044
        test    eax, LPA_100FULL
-
 
1045
        jz      @f
-
 
1046
        mov     eax, ETH_LINK_SPEED_100M or ETH_LINK_FULL_DUPLEX
-
 
1047
        jmp     .update
-
 
1048
  @@:
-
 
1049
 
-
 
1050
        test    eax, LPA_100HALF
-
 
1051
        jz      @f
-
 
1052
        mov     eax, ETH_LINK_SPEED_100M
-
 
1053
        jmp     .update
-
 
1054
  @@:
-
 
1055
 
-
 
1056
        test    eax, LPA_10FULL
-
 
1057
        jz      @f
-
 
1058
        mov     eax, ETH_LINK_SPEED_10M or ETH_LINK_FULL_DUPLEX
-
 
1059
        jmp     .update
-
 
1060
  @@:
-
 
1061
 
-
 
1062
        test    eax, LPA_10HALF
-
 
1063
        jz      @f
-
 
1064
        mov     eax, ETH_LINK_SPEED_10M
-
 
1065
        jmp     .update
-
 
1066
  @@:
-
 
1067
 
-
 
1068
        mov     eax, ETH_LINK_UNKNOWN
-
 
1069
 
-
 
1070
  .update:
-
 
1071
        mov     [ebx + device.state], eax
-
 
1072
        invoke  NetLinkChanged
-
 
1073
 
-
 
1074
 
-
 
1075
        spin_unlock_irqrestore
-
 
1076
        ret
-
 
1077
 
-
 
1078
 
982
        ret
1079
endp
983
 
1080
 
Line 984... Line 1081...
984
 
1081
 
985
align 4
1082
align 4