Subversion Repositories Kolibri OS

Rev

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

Rev 8997 Rev 9148
Line 1025... Line 1025...
1025
;   Function
1025
;   Function
1026
;      transmit
1026
;      transmit
1027
;   Description
1027
;   Description
1028
;      Transmits a packet of data via the ethernet card
1028
;      Transmits a packet of data via the ethernet card
1029
;
1029
;
1030
;   Destroyed registers
1030
; In: pointer to device structure in ebx
1031
;      eax, edx, esi, edi
1031
; Out: eax = 0 on success
1032
;
1032
;
1033
;***************************************************************************
1033
;***************************************************************************
1034
 
1034
align 16
1035
proc transmit stdcall bufferptr
1035
proc transmit stdcall bufferptr
Line 1036... Line 1036...
1036
 
1036
 
1037
        pushf
-
 
Line 1038... Line 1037...
1038
        cli
1037
        spin_lock_irqsave
1039
 
1038
 
1040
        mov     esi, [bufferptr]
1039
        mov     esi, [bufferptr]
1041
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
1040
        DEBUGF  1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
Line 1105... Line 1104...
1105
 
1104
 
1106
        inc     [ebx + device.packets_tx]
1105
        inc     [ebx + device.packets_tx]
1107
        add     dword [ebx + device.bytes_tx], ecx
1106
        add     dword [ebx + device.bytes_tx], ecx
Line 1108... Line 1107...
1108
        adc     dword [ebx + device.bytes_tx + 4], 0
1107
        adc     dword [ebx + device.bytes_tx + 4], 0
1109
 
1108
 
1110
        popf
1109
        spin_unlock_irqrestore
Line 1111... Line 1110...
1111
        xor     eax, eax
1110
        xor     eax, eax
1112
        ret
1111
        ret
1113
 
1112
 
1114
  .error:
1113
  .error:
Line 1115... Line 1114...
1115
        DEBUGF  2, "TX packet error\n"
1114
        DEBUGF  2, "TX packet error\n"
1116
        inc     [ebx + device.packets_tx_err]
1115
        inc     [ebx + device.packets_tx_err]
1117
        invoke  NetFree, [bufferptr]
1116
        invoke  NetFree, [bufferptr]
Line 1118... Line 1117...
1118
 
1117
 
1119
        popf
1118
        spin_unlock_irqrestore
1120
        or      eax, -1
1119
        or      eax, -1
1121
        ret
1120
        ret
Line 1122... Line 1121...
1122
 
1121
 
1123
  .overrun:
1122
  .overrun:
1124
        DEBUGF  2, "TX overrun\n"
1123
        DEBUGF  2, "TX overrun\n"
Line 1125... Line 1124...
1125
        inc     [ebx + device.packets_tx_ovr]
1124
        inc     [ebx + device.packets_tx_ovr]
Line 1136... Line 1135...
1136
;;;;;;;;;;;;;;;;;;;;;;;
1135
;;;;;;;;;;;;;;;;;;;;;;;
1137
;;                   ;;
1136
;;                   ;;
1138
;; Interrupt handler ;;
1137
;; Interrupt handler ;;
1139
;;                   ;;
1138
;;                   ;;
1140
;;;;;;;;;;;;;;;;;;;;;;;
1139
;;;;;;;;;;;;;;;;;;;;;;;
1141
 
-
 
1142
align 4
1140
align 16
1143
int_handler:
1141
int_handler:
Line 1144... Line 1142...
1144
 
1142
 
Line -... Line 1143...
-
 
1143
        push    ebx esi edi
1145
        push    ebx esi edi
1144
 
Line 1146... Line -...
1146
 
-
 
1147
        DEBUGF  1,"INT\n"
-
 
1148
 
-
 
1149
; find pointer of device wich made IRQ occur
-
 
1150
 
-
 
1151
        mov     ecx, [devices]
1145
        mov     ebx, [esp+4*4]
1152
        test    ecx, ecx
-
 
1153
        jz      .nothing
-
 
Line 1154... Line 1146...
1154
        mov     esi, device_list
1146
        DEBUGF  1,"INT for 0x%x\n", ebx
1155
  .nextdevice:
1147
 
1156
        mov     ebx, [esi]
1148
; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list
-
 
1149
 
1157
 
1150
        set_io  [ebx + device.io_addr], 0
1158
        set_io  [ebx + device.io_addr], 0
1151
        set_io  [ebx + device.io_addr], REG_IntrStatus
1159
        set_io  [ebx + device.io_addr], REG_IntrStatus
1152
        in      ax, dx
1160
        in      ax, dx
1153
        test    ax, ax
1161
        out     dx, ax                                  ; ACK all interrupts
1154
        jz      .nothing
1162
        cmp     ax, 0xffff                              ; if so, hardware is no longer present
-
 
1163
        je      .nothing
-
 
1164
        test    ax, ax
-
 
1165
        jnz     .got_it
-
 
1166
  .continue:
-
 
1167
        add     esi, 4
1155
        cmp     ax, 0xffff              ; if so, hardware is no longer present
1168
        dec     ecx
-
 
1169
        jnz     .nextdevice
-
 
1170
  .nothing:
-
 
Line 1171... Line -...
1171
        pop     edi esi ebx
-
 
1172
        xor     eax, eax
1156
        je      .nothing                ;
Line 1173... Line 1157...
1173
 
1157
        test    ax, ax
1174
        ret                                             ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
1158
        jz      .nothing
1175
 
1159
        out     dx, ax                  ; ACK all interrupts
1176
  .got_it:
1160
 
Line 1324... Line 1308...
1324
        xor     eax, eax
1308
        xor     eax, eax
1325
        inc     eax
1309
        inc     eax
Line 1326... Line 1310...
1326
 
1310
 
Line -... Line 1311...
-
 
1311
        ret
-
 
1312
 
-
 
1313
  .nothing:
-
 
1314
        pop     edi esi ebx
-
 
1315
        xor     eax, eax
-
 
1316
 
Line 1327... Line 1317...
1327
        ret
1317
        ret
1328
 
1318