From 698f06c417383f7e185055b13c1ef5f950f65513 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Thu, 24 Sep 2009 18:32:03 +0000 Subject: [PATCH] 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 --- .../net/applications/zeroconf/zeroconf.asm | 4 +++ kernel/branches/net/drivers/RTL8139.asm | 8 ++--- kernel/branches/net/network/ethernet.inc | 29 +++++++++++++++---- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/kernel/branches/net/applications/zeroconf/zeroconf.asm b/kernel/branches/net/applications/zeroconf/zeroconf.asm index 7be01347fc..93bfd0a5c2 100644 --- a/kernel/branches/net/applications/zeroconf/zeroconf.asm +++ b/kernel/branches/net/applications/zeroconf/zeroconf.asm @@ -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 diff --git a/kernel/branches/net/drivers/RTL8139.asm b/kernel/branches/net/drivers/RTL8139.asm index 85b408dc62..61fa41a7f5 100644 --- a/kernel/branches/net/drivers/RTL8139.asm +++ b/kernel/branches/net/drivers/RTL8139.asm @@ -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 diff --git a/kernel/branches/net/network/ethernet.inc b/kernel/branches/net/network/ethernet.inc index b2b7cb5c07..59ee22f7cd 100644 --- a/kernel/branches/net/network/ethernet.inc +++ b/kernel/branches/net/network/ethernet.inc @@ -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]