Subversion Repositories Kolibri OS

Rev

Rev 5363 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5363 Rev 5522
Line 471... Line 471...
471
        ; - Remove device from local list (device_list)
471
        ; - Remove device from local list (device_list)
472
        ; - call unregister function in kernel
472
        ; - call unregister function in kernel
473
        ; - Remove all allocated structures and buffers the card used
473
        ; - Remove all allocated structures and buffers the card used
Line 474... Line 474...
474
 
474
 
475
        or      eax, -1
-
 
476
 
475
        or      eax, -1
Line 477... Line 476...
477
ret
476
        ret
478
 
477
 
479
 
478
 
Line 625... Line 624...
625
        xor     eax, eax
624
        xor     eax, eax
626
        inc     eax
625
        inc     eax
627
        out     dx, eax
626
        out     dx, eax
Line 628... Line 627...
628
 
627
 
-
 
628
        call    init_ring
-
 
629
        test    eax, eax
Line 629... Line 630...
629
        call    init_ring
630
        jnz     .err
630
 
631
 
631
; Initialize other registers.
632
; Initialize other registers.
632
; Configure the PCI bus bursts and FIFO thresholds.
633
; Configure the PCI bus bursts and FIFO thresholds.
Line 633... Line 634...
633
        mov     [ebx + device.bcrvalue], 0x10         ; little-endian, 8 burst length
634
        mov     [ebx + device.bcrvalue], 0x10         ; little-endian, 8 burst length
634
        mov     [ebx + device.crvalue], 0xa00         ; 128 burst length
635
        mov     [ebx + device.crvalue], 0xa00         ; 128 burst length
635
 
636
 
636
        cmp     [ebx + device.dev_id], 0x891
637
        cmp     [ebx + device.dev_id], 0x891
637
        jne     @f
638
        jne     @f
638
        or      [ebx + device.bcrvalue], 0x200       ; set PROG bit
639
        or      [ebx + device.bcrvalue], 0x200       ; set PROG bit
Line 639... Line 640...
639
        or      [ebx + device.crvalue], 0x02000000   ; set enhanced bit
640
        or      [ebx + device.crvalue], 0x02000000   ; set enhanced bit
Line 640... Line 641...
640
       @@:
641
  @@:
Line 674... Line 675...
674
 
675
 
675
        mov     [ebx + device.mtu], 1514
676
        mov     [ebx + device.mtu], 1514
676
        xor     eax, eax
677
        xor     eax, eax
Line -... Line 678...
-
 
678
        ret
-
 
679
 
-
 
680
  .err:
-
 
681
        DEBUGF  2, "Error!\n"
-
 
682
        or      eax, -1
Line 677... Line 683...
677
        ret
683
        ret
678
 
684
 
Line 679... Line 685...
679
 
685
 
Line 680... Line 686...
680
 
686
 
681
 
687
 
682
align 4
688
align 4
683
init_ring:
689
init_ring:
684
 
690
 
685
        DEBUGF  1,"initializing rx and tx ring\n"
691
        DEBUGF  1, "initializing rx and tx ring\n"
686
 
692
 
Line 687... Line 693...
687
; Initialize all Rx descriptors
693
; Initialize all Rx descriptors
688
        lea     esi, [ebx + device.rx_desc]
694
        lea     esi, [ebx + device.rx_desc]
689
        mov     [ebx + device.cur_rx], esi
695
        mov     [ebx + device.cur_rx], esi
690
        mov     ecx, NUM_RX_DESC
696
        mov     ecx, NUM_RX_DESC
691
  .rx_desc_loop:
697
  .rx_desc_loop:
Line 692... Line 698...
692
        mov     [esi + descriptor.status], RXOWN
698
        mov     [esi + descriptor.status], RXOWN
693
        mov     [esi + descriptor.control], 1536 shl RBSShift
699
        mov     [esi + descriptor.control], 1514 shl RBSShift
-
 
700
 
-
 
701
        lea     eax, [esi + sizeof.descriptor]
694
 
702
        mov     [esi + descriptor.next_desc_logical], eax
695
        lea     eax, [esi + sizeof.descriptor]
703
        push    ecx esi
696
        mov     [esi + descriptor.next_desc_logical], eax
704
        invoke  GetPhysAddr
-
 
705
        mov     [esi + descriptor.next_desc], eax
697
        push    ecx esi
706
 
698
        invoke  GetPhysAddr
707
        invoke  NetAlloc, 1514+NET_BUFF.data
Line 699... Line 708...
699
        mov     [esi + descriptor.next_desc], eax
708
        pop     esi ecx
700
 
709
        test    eax, eax
Line 744... Line 753...
744
        push    esi
753
        push    esi
745
        invoke  GetPhysAddr
754
        invoke  GetPhysAddr
746
        pop     esi
755
        pop     esi
747
        mov     [esi - sizeof.descriptor + descriptor.next_desc], eax
756
        mov     [esi - sizeof.descriptor + descriptor.next_desc], eax
Line 748... Line 757...
748
 
757
 
749
        set_io  [ebx + device.io_addr],   0
758
        set_io  [ebx + device.io_addr], 0
750
        set_io  [ebx + device.io_addr],   TXLBA
759
        set_io  [ebx + device.io_addr], TXLBA
Line -... Line 760...
-
 
760
        out     dx, eax
-
 
761
 
-
 
762
        xor     eax, eax
-
 
763
        ret
-
 
764
 
751
        out     dx, eax
765
  .out_of_mem:
Line 752... Line 766...
752
 
766
        or      eax, -1
753
        ret
767
        ret
Line 922... Line 936...
922
;;     size of buffer in [esp+8]           ;;
936
;;     size of buffer in [esp+8]           ;;
923
;;     pointer to device structure in ebx  ;;
937
;;     pointer to device structure in ebx  ;;
924
;;                                         ;;
938
;;                                         ;;
925
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
939
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 926... Line 940...
926
 
940
 
Line 927... Line 941...
927
proc transmit stdcall bufferptr, buffersize
941
proc transmit stdcall bufferptr
928
 
942
 
Line -... Line 943...
-
 
943
        pushf
929
        pushf
944
        cli
930
        cli
945
 
931
 
946
        mov     esi, [bufferptr]
932
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
947
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
933
        mov     eax, [bufferptr]
948
        lea     eax, [esi + NET_BUFF.data]
934
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
949
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
Line 935... Line 950...
935
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
950
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
936
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
951
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
937
        [eax+13]:2,[eax+12]:2
952
        [eax+13]:2,[eax+12]:2
938
 
953
 
Line 939... Line 954...
939
        cmp     [buffersize], 1514
954
        cmp     [esi + NET_BUFF.length], 1514
940
        ja      .fail
-
 
941
        cmp     [buffersize], 60
955
        ja      .fail
942
        jb      .fail
956
        cmp     [esi + NET_BUFF.length], 60
Line 943... Line 957...
943
 
957
        jb      .fail
944
        mov     esi, [ebx + device.cur_tx]
958
 
Line 945... Line 959...
945
 
959
        mov     esi, [ebx + device.cur_tx]
946
        test    [esi + descriptor.status], TXOWN
960
        test    [esi + descriptor.status], TXOWN
-
 
961
        jnz     .fail
947
        jnz     .fail
962
 
948
 
963
        push    [esi + descriptor.next_desc_logical]
Line 949... Line 964...
949
        push    [esi + descriptor.next_desc_logical]
964
        pop     [ebx + device.cur_tx]
-
 
965
 
950
        pop     [ebx + device.cur_tx]
966
        mov     eax, [bufferptr]
951
 
967
        mov     [esi + descriptor.skbuff], eax
952
        mov     eax, [bufferptr]
968
        add     eax, [eax + NET_BUFF.offset]
953
        mov     [esi + descriptor.skbuff], eax
969
        invoke  GetPhysAddr
954
        invoke  GetPhysAddr
970
        mov     [esi + descriptor.buffer], eax
955
        mov     [esi + descriptor.buffer], eax
971
 
956
 
972
        mov     eax, [bufferptr]
Line 957... Line 973...
957
        mov     eax, [buffersize]
973
        mov     eax, [eax + NET_BUFF.length]
958
        mov     ecx, eax
974
        mov     ecx, eax
959
        shl     eax, PKTSShift               ; packet size
975
        shl     eax, PKTSShift               ; packet size
-
 
976
        shl     ecx, TBSShift
960
        shl     ecx, TBSShift
977
        or      eax, ecx
961
        or      eax, ecx
978
        or      eax, TXIC + TXLD + TXFD + CRCEnable + PADEnable
Line 962... Line 979...
962
        or      eax, TXIC + TXLD + TXFD + CRCEnable + PADEnable
979
        mov     [esi + descriptor.control], eax
963
        mov     [esi + descriptor.control], eax
980
        mov     [esi + descriptor.status], TXOWN
964
        mov     [esi + descriptor.status], TXOWN
981
 
Line 980... Line 997...
980
        xor     eax, eax
997
        xor     eax, eax
981
        ret
998
        ret
Line 982... Line 999...
982
 
999
 
983
  .fail:
1000
  .fail:
984
        DEBUGF  2,"Transmit failed\n"
1001
        DEBUGF  2,"Transmit failed\n"
985
        invoke  KernelFree, [bufferptr]
1002
        invoke  NetFree, [bufferptr]
986
        popf
1003
        popf
987
        or      eax, -1
1004
        or      eax, -1
Line 988... Line 1005...
988
        ret
1005
        ret
Line 1066... Line 1083...
1066
        push    .rx_complete
1083
        push    .rx_complete
Line 1067... Line 1084...
1067
 
1084
 
1068
        mov     ecx, [esi + descriptor.status]
1085
        mov     ecx, [esi + descriptor.status]
1069
        shr     ecx, FLNGShift
1086
        shr     ecx, FLNGShift
1070
        sub     ecx, 4                  ; we dont need CRC
-
 
1071
        push    ecx
1087
        sub     ecx, 4                  ; we dont need CRC
-
 
1088
        DEBUGF  1,"Received %u bytes\n", ecx
-
 
1089
        mov     eax, [esi + descriptor.skbuff]
-
 
1090
        push    eax
-
 
1091
        mov     [eax + NET_BUFF.length], ecx
-
 
1092
        mov     [eax + NET_BUFF.device], ebx
Line 1072... Line 1093...
1072
        DEBUGF  1,"Received %u bytes\n", ecx
1093
        mov     [eax + NET_BUFF.offset], NET_BUFF.data
1073
 
1094
 
1074
; Update stats
1095
; Update stats
1075
        add     dword[ebx + device.bytes_rx], ecx
1096
        add     dword[ebx + device.bytes_rx], ecx
Line 1076... Line -...
1076
        adc     dword[ebx + device.bytes_rx + 4], 0
-
 
1077
        inc     [ebx + device.packets_rx]
1097
        adc     dword[ebx + device.bytes_rx + 4], 0
Line 1078... Line 1098...
1078
 
1098
        inc     [ebx + device.packets_rx]
1079
        push    [esi + descriptor.skbuff]
1099
 
1080
        jmp     [Eth_input]
1100
        jmp     [EthInput]
1081
 
1101
 
1082
  .rx_complete:
1102
  .rx_complete:
1083
        pop     ebx
1103
        pop     ebx
1084
        mov     esi, [ebx + device.cur_rx]
1104
        mov     esi, [ebx + device.cur_rx]
-
 
1105
        mov     [esi + descriptor.control], 1514 shl RBSShift
-
 
1106
        push    esi
1085
        mov     [esi + descriptor.control], 1536 shl RBSShift
1107
        invoke  NetAlloc, 1514+NET_BUFF.data
1086
        push    esi
1108
        pop     esi
-
 
1109
;        test    eax, eax
1087
        invoke  KernelAlloc, 1536
1110
;        jz      .rx_loop
1088
        pop     esi
1111
        mov     [esi + descriptor.skbuff], eax
Line 1089... Line 1112...
1089
        mov     [esi + descriptor.skbuff], eax
1112
        invoke  GetPhysAddr
1090
        invoke  GetPgAddr
1113
        add     eax, NET_BUFF.data
Line 1120... Line 1143...
1120
        mov     eax, [esi + descriptor.skbuff]
1143
        mov     eax, [esi + descriptor.skbuff]
1121
        test    eax, eax
1144
        test    eax, eax
1122
        je      .skip_this_one
1145
        je      .skip_this_one
1123
        mov     [esi + descriptor.skbuff], 0
1146
        mov     [esi + descriptor.skbuff], 0
1124
        DEBUGF  1,"freeing buffer: 0x%x\n", eax
1147
        DEBUGF  1,"freeing buffer: 0x%x\n", eax
1125
        invoke  KernelFree, eax
1148
        invoke  NetFree, eax
1126
  .skip_this_one:
1149
  .skip_this_one:
1127
        mov     esi, [esi + descriptor.next_desc_logical]
1150
        mov     esi, [esi + descriptor.next_desc_logical]
1128
        loop    .tx_loop
1151
        loop    .tx_loop
1129
        pop     ax
1152
        pop     ax
1130
  .no_tx:
1153
  .no_tx: