From 72c96117d0b3c1fb91fd19857f5f2d32ba792ea0 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sun, 8 Dec 2013 14:34:08 +0000 Subject: [PATCH] ALL ethernet drivers: return success/failed for transmit function, dump packet when failing. git-svn-id: svn://kolibrios.org@4334 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/ethernet/3c59x.asm | 14 ++++++++------ drivers/ethernet/R6040.asm | 2 ++ drivers/ethernet/RTL8029.asm | 3 +-- drivers/ethernet/RTL8169.asm | 16 ++++++++-------- drivers/ethernet/bcm57xx.asm | 3 +++ drivers/ethernet/dec21x4x.asm | 4 ++-- drivers/ethernet/forcedeth.asm | 4 ++-- drivers/ethernet/i8254x.asm | 4 +++- drivers/ethernet/mtd80x.asm | 2 +- drivers/ethernet/rhine.asm | 1 + 10 files changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/ethernet/3c59x.asm b/drivers/ethernet/3c59x.asm index 5ba3d10e80..7df6db0ae3 100644 --- a/drivers/ethernet/3c59x.asm +++ b/drivers/ethernet/3c59x.asm @@ -2228,7 +2228,7 @@ vortex_transmit: set_io REG_MASTER_STATUS in ax, dx test ah, 0x80 - jnz .finish ; no DMA for sending + jnz .fail ; no DMA for sending ; program frame address to be sent set_io REG_MASTER_ADDRESS mov eax, [esp+4] @@ -2243,12 +2243,14 @@ vortex_transmit: set_io REG_COMMAND mov ax, (10100b shl 11) + 1 ; StartDMADown out dx, ax -.finish: - call KernelFree - add esp, 4 - ret - + .finish: + xor eax, eax + ret 8 + .fail: + stdcall KernelFree, [esp+4] + or eax, -1 + ret 8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; diff --git a/drivers/ethernet/R6040.asm b/drivers/ethernet/R6040.asm index 7debf9ef8b..05acd907b1 100644 --- a/drivers/ethernet/R6040.asm +++ b/drivers/ethernet/R6040.asm @@ -823,6 +823,8 @@ transmit: dec eax .fail: DEBUGF 1,"Send failed\n" + stdcall KernelFree, [esp+4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/RTL8029.asm b/drivers/ethernet/RTL8029.asm index 3c0181a52b..a1aef5ee40 100644 --- a/drivers/ethernet/RTL8029.asm +++ b/drivers/ethernet/RTL8029.asm @@ -729,9 +729,8 @@ transmit: .err: DEBUGF 2, "Transmit error!\n" - - or eax, -1 stdcall KernelFree, [esp+4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/RTL8169.asm b/drivers/ethernet/RTL8169.asm index bf6bdef765..07b093e405 100644 --- a/drivers/ethernet/RTL8169.asm +++ b/drivers/ethernet/RTL8169.asm @@ -633,23 +633,23 @@ probe: call read_mac call PHY_config -; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n" + DEBUGF 1,"Set MAC Reg C+CR Offset 0x82h = 0x01h\n" set_io 0 set_io 0x82 mov al, 0x01 out dx, al cmp [tpc.mcfg], MCFG_METHOD_03 jae @f -; DEBUGF 1,"K : Set PCI Latency=0x40\n" -; stdcall pci_write_config_byte,PCI_LATENCY_TIMER,0x40 + DEBUGF 1,"Set PCI Latency=0x40\n" + PCI_adjust_latency 0x40 @@: cmp [tpc.mcfg], MCFG_METHOD_02 jne @f -; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n" + DEBUGF 1,"Set MAC Reg C+CR Offset 0x82h = 0x01h\n" set_io 0x82 mov al, 0x01 out dx, al -; DEBUGF 1,"K : Set PHY Reg 0x0bh = 0x00h\n" + DEBUGF 1,"Set PHY Reg 0x0bh = 0x00h\n" WRITE_GMII_REG 0x0b, 0x0000 ; w 0x0b 15 0 0 @@: ; if TBI is not enabled @@ -736,7 +736,7 @@ reset: align 4 PHY_config: - DEBUGF 1,"hw_PHY_config: priv.mcfg=%d, priv.pcfg=%d\n",[tpc.mcfg],[tpc.pcfg] + DEBUGF 1,"hw_PHY_config: priv.mcfg=%d, priv.pcfg=%d\n", [tpc.mcfg], [tpc.pcfg] cmp [tpc.mcfg], MCFG_METHOD_04 jne .not_4 @@ -1103,8 +1103,8 @@ transmit: .fail: DEBUGF 1,"transmit failed\n" - or eax, -1 stdcall KernelFree, [esp+4] + or eax, -1 ret 8 @@ -1122,7 +1122,7 @@ int_handler: push ebx esi edi - DEBUGF 1,"\n%s int\n", my_service + DEBUGF 1,"INT\n" ; find pointer of device wich made IRQ occur diff --git a/drivers/ethernet/bcm57xx.asm b/drivers/ethernet/bcm57xx.asm index 7b8f57ca55..1ad31e2cba 100644 --- a/drivers/ethernet/bcm57xx.asm +++ b/drivers/ethernet/bcm57xx.asm @@ -352,10 +352,13 @@ transmit: add dword [device.bytes_tx], eax adc dword [device.bytes_tx + 4], 0 + xor eax, eax ret 8 .fail: DEBUGF 1,"Send failed\n" + stdcall KernelFree, [esp+4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/dec21x4x.asm b/drivers/ethernet/dec21x4x.asm index bf1bbf79fc..3fd00c2743 100644 --- a/drivers/ethernet/dec21x4x.asm +++ b/drivers/ethernet/dec21x4x.asm @@ -622,7 +622,7 @@ reset: stdcall AttachIntHandler, eax, int_handler, dword 0 test eax, eax jnz @f - DEBUGF 1,"\nCould not attach int handler!\n" + DEBUGF 2,"Could not attach int handler!\n" ; or eax, -1 ; ret @@: @@ -1010,8 +1010,8 @@ transmit: .fail: DEBUGF 1,"transmit failed\n" - or eax, -1 stdcall KernelFree, [esp+4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/forcedeth.asm b/drivers/ethernet/forcedeth.asm index c9599499fc..04f49189fb 100644 --- a/drivers/ethernet/forcedeth.asm +++ b/drivers/ethernet/forcedeth.asm @@ -1843,8 +1843,8 @@ transmit: ret 8 .fail: - xor eax, eax - inc eax + stdcall KernelFree, [esp+4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/i8254x.asm b/drivers/ethernet/i8254x.asm index 6c65c1084e..30bad5d445 100644 --- a/drivers/ethernet/i8254x.asm +++ b/drivers/ethernet/i8254x.asm @@ -656,7 +656,6 @@ transmit: cmp dword [esp + 8], 60 jb .fail - ; Program the descriptor (use legacy mode) lea edi, [device.tx_desc] ; Transmit Descriptor Base Address mov dword [edi + 16], eax ; Store the data location (for driver) @@ -680,10 +679,13 @@ transmit: add dword [device.bytes_tx], eax adc dword [device.bytes_tx + 4], 0 + xor eax, eax ret 8 .fail: DEBUGF 2,"Send failed\n" + stdcall KernelFree, [esp+4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/mtd80x.asm b/drivers/ethernet/mtd80x.asm index db93d28d99..f5d1449124 100644 --- a/drivers/ethernet/mtd80x.asm +++ b/drivers/ethernet/mtd80x.asm @@ -1062,8 +1062,8 @@ transmit: .fail: DEBUGF 1,"transmit failed\n" - or eax, -1 stdcall KernelFree, [esp + 4] + or eax, -1 ret 8 diff --git a/drivers/ethernet/rhine.asm b/drivers/ethernet/rhine.asm index d4caa920c5..f6e2738784 100644 --- a/drivers/ethernet/rhine.asm +++ b/drivers/ethernet/rhine.asm @@ -1461,6 +1461,7 @@ transmit: .fail: DEBUGF 2, "Transmit Failed!\n" + stdcall KernelFree, [esp+4] or eax, -1 ; Transmit failed ret 8