From c5df59af4b3986f527431fbc3d4b00f46ed97fd4 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Thu, 28 May 2015 10:32:10 +0000 Subject: [PATCH] i8255x: Fixed memory leak when i8255x runs out of resources. git-svn-id: svn://kolibrios.org@5560 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/ethernet/i8255x.asm | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/ethernet/i8255x.asm b/drivers/ethernet/i8255x.asm index 7566f9fc23..332d8bb53f 100644 --- a/drivers/ethernet/i8255x.asm +++ b/drivers/ethernet/i8255x.asm @@ -18,6 +18,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;TODO: use more RX buffers format PE DLL native entry START @@ -376,9 +377,8 @@ unload: ; - call unregister function in kernel ; - Remove all allocated structures and buffers the card used - or eax,-1 - -ret + or eax, -1 + ret ;------------- @@ -611,7 +611,7 @@ init_rx_ring: invoke GetPhysAddr add eax, NET_BUFF.data mov [esi + sizeof.NET_BUFF + rxfd.status], 0x0000 - mov [esi + sizeof.NET_BUFF + rxfd.command], 0x0000 + mov [esi + sizeof.NET_BUFF + rxfd.command], 0xc000 ; End of list + Suspend mov [esi + sizeof.NET_BUFF + rxfd.link], eax mov [esi + sizeof.NET_BUFF + rxfd.count], 0 mov [esi + sizeof.NET_BUFF + rxfd.size], 1528 @@ -619,7 +619,6 @@ init_rx_ring: ret .out_of_mem: - ret @@ -837,8 +836,9 @@ int_handler: set_io [ebx + device.io_addr], 0 set_io [ebx + device.io_addr], reg_scb_ptr -; lea eax, [ebx + device.rx_desc] +; mov eax, [ebx + device.rx_desc] ; invoke GetPhysAddr +; add eax, NET_BUFF.data out dx, eax set_io [ebx + device.io_addr], reg_scb_cmd @@ -890,27 +890,18 @@ int_handler: cmp ax, 00001000b jne .fail - DEBUGF 1, "out of resources!\n" -; Restart the RX + DEBUGF 2, "Out of resources!\n" -; allocate new descriptor - - invoke KernelAlloc, 2000 - mov [ebx + device.rx_desc], eax - mov esi, eax - invoke GetPhysAddr - mov [esi + rxfd.status], 0x0000 - mov [esi + rxfd.command], 0xc000 ; End of list + Suspend - mov [esi + rxfd.link], eax - mov [esi + rxfd.count], 0 - mov [esi + rxfd.size], 1528 +; call init_rx_ring +; test eax, eax +; jz .fail ; restart RX - set_io [ebx + device.io_addr], 0 set_io [ebx + device.io_addr], reg_scb_ptr -; lea eax, [ebx + device.rx_desc] -; invoke GetPhysAddr + mov eax, [ebx + device.rx_desc] + invoke GetPhysAddr + add eax, NET_BUFF.data out dx, eax set_io [ebx + device.io_addr], reg_scb_cmd