From 940c0c5fa638fe369b79e0fe42f949678da4d722 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Wed, 8 Aug 2012 10:03:47 +0000 Subject: [PATCH] Completion of the new SIS900 driver. -cleanup of used packets after they are sent -transmit function now checks first if the descriptor is free git-svn-id: svn://kolibrios.org@2912 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/net/drivers/sis900.asm | 32 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/kernel/branches/net/drivers/sis900.asm b/kernel/branches/net/drivers/sis900.asm index 5ea622ebe6..f6133548b1 100644 --- a/kernel/branches/net/drivers/sis900.asm +++ b/kernel/branches/net/drivers/sis900.asm @@ -574,6 +574,7 @@ reset: out dx, eax mov [device.cur_tx], 0 ; Set current tx descriptor to 0 + mov [device.last_tx], 0 DEBUGF 1, "Initialising RX Descriptors\n" @@ -991,8 +992,8 @@ transmit: shl ecx, 4 ; *16 lea ecx, [device.txd + ecx] -;; TODO: check if desc is empty (for example: check for eax, 0x6200000 at [ecx+4] -;;; or: count number of available descriptors + test dword [ecx + 4], 0x80000000 ; card owns descriptor ? + jnz .error mov eax, [esp + 4] mov dword [ecx + 12], eax @@ -1121,13 +1122,6 @@ int_handler: inc [device.cur_rx] ; get next descriptor and [device.cur_rx], NUM_RX_DESC-1 ; only 4 descriptors 0-3 -; Enable Receiver CHECKME -; set_io 0 -; set_io cr ; Command Register offset -; in eax, dx ; Get current Command Register -; or eax, RxENA ; Enable Receiver -; out dx, eax - pop ax .no_rx: @@ -1136,8 +1130,24 @@ int_handler: DEBUGF 1, "TX ok!\n" - ;;; TODO: free all unused buffers - ;; stdcall KernelFree, eax + .tx_loop: + movzx ecx, [device.last_tx] + shl ecx, 4 ; *16 + lea ecx, [device.txd + ecx] + + test dword [ecx + 4], 0x80000000 ; card owns descr + jnz .no_tx + cmp dword [ecx + 12], 0 + je .no_tx + + DEBUGF 1, "Freeing packet = %x\n", [ecx + 12]:8 + push dword [ecx + 12] + mov dword [ecx + 12], 0 + call KernelFree + + inc [device.last_tx] + and [device.last_tx], NUM_TX_DESC-1 + jmp .tx_loop .no_tx: