Subversion Repositories Kolibri OS

Rev

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

Rev 5363 Rev 5522
Line 412... Line 412...
412
        ; - Remove device from local list
412
        ; - Remove device from local list
413
        ; - call unregister function in kernel
413
        ; - call unregister function in kernel
414
        ; - Remove all allocated structures and buffers the card used
414
        ; - Remove all allocated structures and buffers the card used
Line 415... Line 415...
415
 
415
 
416
        or      eax, -1
-
 
417
 
416
        or      eax, -1
Line 418... Line 417...
418
ret
417
        ret
419
 
418
 
420
;***************************************************************************
419
;***************************************************************************
Line 610... Line 609...
610
        invoke  GetPhysAddr
609
        invoke  GetPhysAddr
611
        mov     dword [esi], eax
610
        mov     dword [esi], eax
612
        mov     dword [esi + 4], RX_BUFF_SZ             ; size
611
        mov     dword [esi + 4], RX_BUFF_SZ             ; size
Line 613... Line 612...
613
 
612
 
614
        push    ecx esi
613
        push    ecx esi
615
        invoke  KernelAlloc, RX_BUFF_SZ
614
        invoke  NetAlloc, RX_BUFF_SZ+NET_BUFF.data
616
        pop     esi ecx
615
        pop     esi ecx
617
        test    eax, eax
616
        test    eax, eax
618
        jz      .fail
617
        jz      .fail
619
        mov     dword [esi + 12], eax                   ; address
618
        mov     dword [esi + 12], eax                   ; address
-
 
619
        invoke  GetPhysAddr
620
        invoke  GetPhysAddr
620
        add     eax, NET_BUFF.data
621
        mov     dword [esi + 8], eax                    ; real address
621
        mov     dword [esi + 8], eax                    ; real address
622
        add     esi, 16
622
        add     esi, 16
623
        dec     ecx
623
        dec     ecx
Line 1004... Line 1004...
1004
;         pointer to device structure in ebx
1004
;         pointer to device structure in ebx
1005
;
1005
;
1006
;***************************************************************************
1006
;***************************************************************************
1007
align 4
1007
align 4
Line 1008... Line 1008...
1008
 
1008
 
Line 1009... Line 1009...
1009
proc transmit stdcall bufferptr, buffersize
1009
proc transmit stdcall bufferptr
1010
 
1010
 
Line -... Line 1011...
-
 
1011
        pushf
1011
        pushf
1012
        cli
1012
        cli
1013
 
1013
 
1014
        mov     esi, [bufferptr]
1014
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [buffersize]
1015
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
1015
        mov     eax, [bufferptr]
1016
        lea     eax, [esi + NET_BUFF.data]
1016
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
1017
        DEBUGF  1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
Line 1017... Line 1018...
1017
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
1018
        [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
1018
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
1019
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
1019
        [eax+13]:2,[eax+12]:2
1020
        [eax+13]:2,[eax+12]:2
1020
 
1021
 
Line 1021... Line 1022...
1021
        cmp     [buffersize], 1514
1022
        cmp     [esi + NET_BUFF.length], 1514
1022
        ja      .fail
1023
        ja      .fail
1023
        cmp     [buffersize], 60
1024
        cmp     [esi + NET_BUFF.length], 60
Line 1024... Line 1025...
1024
        jb      .fail
1025
        jb      .fail
1025
 
1026
 
Line 1026... Line 1027...
1026
        movzx   ecx, [ebx + device.cur_tx]
1027
        movzx   ecx, [ebx + device.cur_tx]
1027
        shl     ecx, 4                                  ; *16
1028
        shl     ecx, 4                                  ; *16
-
 
1029
        lea     ecx, [ebx + device.txd + ecx]
1028
        lea     ecx, [ebx + device.txd + ecx]
1030
 
1029
 
1031
        test    dword[ecx + 4], 0x80000000              ; card owns descriptor ?
Line 1030... Line 1032...
1030
        test    dword[ecx + 4], 0x80000000              ; card owns descriptor ?
1032
        jnz     .fail
1031
        jnz     .fail
1033
 
1032
 
1034
        mov     eax, esi
1033
        mov     eax, [bufferptr]
1035
        mov     dword[ecx + 12], eax
Line 1034... Line 1036...
1034
        mov     dword[ecx + 12], eax
1036
        add     eax, [eax + NET_BUFF.offset]
Line 1048... Line 1050...
1048
 
1050
 
1049
        inc     [ebx + device.cur_tx]
1051
        inc     [ebx + device.cur_tx]
Line 1050... Line 1052...
1050
        and     [ebx + device.cur_tx], NUM_TX_DESC-1
1052
        and     [ebx + device.cur_tx], NUM_TX_DESC-1
1051
 
1053
 
1052
; update stats
1054
; update stats
1053
        mov     ecx, [buffersize]
1055
        mov     ecx, [esi + NET_BUFF.length]
1054
        inc     [ebx + device.packets_tx]
1056
        inc     [ebx + device.packets_tx]
Line 1055... Line 1057...
1055
        add     dword [ebx + device.bytes_tx], ecx
1057
        add     dword [ebx + device.bytes_tx], ecx
Line 1060... Line 1062...
1060
        xor     eax, eax
1062
        xor     eax, eax
1061
        ret
1063
        ret
Line 1062... Line 1064...
1062
 
1064
 
1063
  .fail:
1065
  .fail:
1064
        DEBUGF  2,"Transmit failed\n"
1066
        DEBUGF  2,"Transmit failed\n"
1065
        invoke  KernelFree, [bufferptr]
1067
        invoke  NetFree, [bufferptr]
1066
        popf
1068
        popf
1067
        or      eax, -1
1069
        or      eax, -1
Line 1068... Line 1070...
1068
        ret
1070
        ret
Line 1149... Line 1151...
1149
        inc     dword [ebx + device.packets_rx]
1151
        inc     dword [ebx + device.packets_rx]
1150
        add     dword [ebx + device.bytes_rx], ecx
1152
        add     dword [ebx + device.bytes_rx], ecx
1151
        adc     dword [ebx + device.bytes_rx + 4], 0
1153
        adc     dword [ebx + device.bytes_rx + 4], 0
Line 1152... Line 1154...
1152
 
1154
 
-
 
1155
        push    ebx
1153
        push    ebx
1156
        push    .return                                 ; return addr
1154
        push    .return
1157
        mov     eax, [ebx + device.rxd + eax + 12]
-
 
1158
        push    eax                                     ; packet ptr
-
 
1159
        mov     [eax + NET_BUFF.length], ecx
1155
        push    ecx                                     ; packet size
1160
        mov     [eax + NET_BUFF.device], ebx
1156
        pushd   [ebx + device.rxd + eax + 12]           ; packet ptr
1161
        mov     [eax + NET_BUFF.offset], NET_BUFF.data
1157
        DEBUGF  1, "Packet received OK\n"
1162
        DEBUGF  1, "Packet received OK\n"
1158
        jmp     [Eth_input]
1163
        jmp     [EthInput]
1159
  .return:
1164
  .return:
Line 1160... Line 1165...
1160
        pop     ebx
1165
        pop     ebx
1161
 
1166
 
1162
; Reset status, allow ethernet card access to descriptor
1167
; Reset status, allow ethernet card access to descriptor
1163
        invoke  KernelAlloc, RX_BUFF_SZ
1168
        invoke  NetAlloc, RX_BUFF_SZ + NET_BUFF.data
1164
        test    eax, eax
1169
        test    eax, eax
1165
        jz      .fail
1170
        jz      .fail
1166
        movzx   ecx, [ebx + device.cur_rx]
1171
        movzx   ecx, [ebx + device.cur_rx]
1167
        shl     ecx, 4                                  ; *16
1172
        shl     ecx, 4                                  ; *16
1168
        lea     ecx, [ebx + device.rxd + ecx]
1173
        lea     ecx, [ebx + device.rxd + ecx]
-
 
1174
        mov     dword [ecx + 12], eax
1169
        mov     dword [ecx + 12], eax
1175
        invoke  GetPhysAddr
1170
        invoke  GetPhysAddr
1176
        add     eax, NET_BUFF.data
Line 1171... Line 1177...
1171
        mov     dword [ecx + 8], eax
1177
        mov     dword [ecx + 8], eax
1172
        mov     dword [ecx + 4], RX_BUFF_SZ
1178
        mov     dword [ecx + 4], RX_BUFF_SZ
Line 1202... Line 1208...
1202
        je      .no_tx
1208
        je      .no_tx
Line 1203... Line 1209...
1203
 
1209
 
1204
        DEBUGF  1, "Freeing packet = %x\n", [ecx + 12]:8
1210
        DEBUGF  1, "Freeing packet = %x\n", [ecx + 12]:8
1205
        push    dword[ecx + 12]
1211
        push    dword[ecx + 12]
1206
        mov     dword[ecx + 12], 0
1212
        mov     dword[ecx + 12], 0
Line 1207... Line 1213...
1207
        invoke  KernelFree
1213
        invoke  NetFree
1208
 
1214
 
1209
        inc     [ebx + device.last_tx]
1215
        inc     [ebx + device.last_tx]