Fixed bug wich made kernel crash when stack was used with no driver loaded.

Made some code more logical regarding stats 

git-svn-id: svn://kolibrios.org@1174 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2009-09-24 18:32:03 +00:00
parent 65fa263646
commit 698f06c417
3 changed files with 32 additions and 9 deletions

View File

@ -158,6 +158,10 @@ START: ; start of execution
; eth.read_mac MAC
mcall 75, 1337 shl 16 + 4
cmp eax, -1
je close
mov word[MAC], bx
mov dword[MAC+2], eax

View File

@ -824,8 +824,8 @@ transmit:
inc [ebx+device.packets_tx] ;
mov eax, [esp+4] ; Get packet size in eax
add dword [ebx + device.bytes_tx + 4], eax
adc dword [ebx + device.bytes_tx], 0
add dword [ebx + device.bytes_tx], eax
adc dword [ebx + device.bytes_tx + 4], 0
; or eax, (ERTXTH shl BIT_ERTXTH) ; Set descriptor size and the early tx treshold into the correct Transmission status register (TSD0, TSD1, TSD2 or TSD3)
out dx , eax ;
@ -906,8 +906,8 @@ int_handler:
jz .reset_rx
; packet is ok, copy it
movzx ecx, word [eax+2] ; packet length
add dword [ebx + device.bytes_rx + 4], ecx ; Update stats
adc dword [ebx + device.bytes_rx], 0
add dword [ebx + device.bytes_rx], ecx ; Update stats
adc dword [ebx + device.bytes_rx + 4], 0
inc dword [ebx + device.packets_rx] ;
sub ecx, 4 ; don't copy CRC
DEBUGF 1,"Received %u bytes\n", ecx

View File

@ -74,18 +74,17 @@ ETH_init:
mov ecx, (1+MAX_ETH_DEVICES)
rep stosd
mov dword [ETH_IN_QUEUE], eax
mov dword [ETH_IN_QUEUE], ETH_QUEUE_SIZE
mov dword [ETH_IN_QUEUE+4], ETH_IN_QUEUE + queue.data
mov dword [ETH_IN_QUEUE+8], ETH_IN_QUEUE + queue.data
mov dword [ETH_OUT_QUEUE], eax
mov dword [ETH_OUT_QUEUE], ETH_QUEUE_SIZE
mov dword [ETH_OUT_QUEUE+4], ETH_OUT_QUEUE + queue.data
mov dword [ETH_OUT_QUEUE+8], ETH_OUT_QUEUE + queue.data
ret
;---------------------------------------------------------
;
; ETH_Add_Device:
@ -102,9 +101,17 @@ align 4
ETH_Add_Device:
DEBUGF 1,"ETH_Add_Device: %x\n", ebx
cmp [ETH_RUNNING], MAX_ETH_DEVICES
mov eax, [ETH_RUNNING]
cmp eax, MAX_ETH_DEVICES
jge .error
test eax, eax
jnz .notfirst
mov dword [ETH_IN_QUEUE], eax
mov dword [ETH_OUT_QUEUE], eax
.notfirst:
mov eax, ebx
mov ecx, MAX_ETH_DEVICES ; We need to check whole list because a device may be removed without re-organizing list
mov edi, ETH_DRV_LIST
@ -142,6 +149,7 @@ ETH_Add_Device:
; stosw ;
inc [ETH_RUNNING] ; Indicate that one more ethernet device is up and running
; pop eax ; Output device num in eax
DEBUGF 1,"- succes: %u\n",eax
ret
@ -184,6 +192,12 @@ ETH_Remove_Device:
mov dword [edi-4], eax
dec [ETH_RUNNING]
jnz .notlast
mov dword [ETH_IN_QUEUE], ETH_QUEUE_SIZE
mov dword [ETH_OUT_QUEUE], ETH_QUEUE_SIZE
.notlast:
ret
@ -470,14 +484,19 @@ ETH_API:
add eax, ETH_DRV_LIST
mov eax, dword [eax]
mov eax, dword [eax + ETH_DEVICE.bytes_tx + 4]
mov eax, dword [eax + ETH_DEVICE.bytes_tx]
mov [esp+20+4], ebx ; TODO: fix this ugly code
ret
.bytes_rx:
add eax, ETH_DRV_LIST
mov eax, dword [eax]
mov eax, dword [eax + ETH_DEVICE.bytes_rx + 4]
mov ebx, dword [eax + ETH_DEVICE.bytes_rx + 4]
mov eax, dword [eax + ETH_DEVICE.bytes_rx]
mov [esp+20+4], ebx ; TODO: fix this ugly code
ret
.read_mac:
add eax, ETH_DRV_LIST
mov eax, [eax]