i8255x: Fixed memory leak when i8255x runs out of resources.

git-svn-id: svn://kolibrios.org@5560 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-05-28 10:32:10 +00:00
parent a0f73145c4
commit c5df59af4b

View File

@ -18,6 +18,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;TODO: use more RX buffers
format PE DLL native format PE DLL native
entry START entry START
@ -376,9 +377,8 @@ unload:
; - call unregister function in kernel ; - call unregister function in kernel
; - Remove all allocated structures and buffers the card used ; - Remove all allocated structures and buffers the card used
or eax,-1 or eax, -1
ret
ret
;------------- ;-------------
@ -611,7 +611,7 @@ init_rx_ring:
invoke GetPhysAddr invoke GetPhysAddr
add eax, NET_BUFF.data add eax, NET_BUFF.data
mov [esi + sizeof.NET_BUFF + rxfd.status], 0x0000 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.link], eax
mov [esi + sizeof.NET_BUFF + rxfd.count], 0 mov [esi + sizeof.NET_BUFF + rxfd.count], 0
mov [esi + sizeof.NET_BUFF + rxfd.size], 1528 mov [esi + sizeof.NET_BUFF + rxfd.size], 1528
@ -619,7 +619,6 @@ init_rx_ring:
ret ret
.out_of_mem: .out_of_mem:
ret ret
@ -837,8 +836,9 @@ int_handler:
set_io [ebx + device.io_addr], 0 set_io [ebx + device.io_addr], 0
set_io [ebx + device.io_addr], reg_scb_ptr set_io [ebx + device.io_addr], reg_scb_ptr
; lea eax, [ebx + device.rx_desc] ; mov eax, [ebx + device.rx_desc]
; invoke GetPhysAddr ; invoke GetPhysAddr
; add eax, NET_BUFF.data
out dx, eax out dx, eax
set_io [ebx + device.io_addr], reg_scb_cmd set_io [ebx + device.io_addr], reg_scb_cmd
@ -890,27 +890,18 @@ int_handler:
cmp ax, 00001000b cmp ax, 00001000b
jne .fail jne .fail
DEBUGF 1, "out of resources!\n" DEBUGF 2, "Out of resources!\n"
; Restart the RX
; allocate new descriptor ; call init_rx_ring
; test eax, eax
invoke KernelAlloc, 2000 ; jz .fail
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
; restart RX ; restart RX
set_io [ebx + device.io_addr], 0 set_io [ebx + device.io_addr], 0
set_io [ebx + device.io_addr], reg_scb_ptr set_io [ebx + device.io_addr], reg_scb_ptr
; lea eax, [ebx + device.rx_desc] mov eax, [ebx + device.rx_desc]
; invoke GetPhysAddr invoke GetPhysAddr
add eax, NET_BUFF.data
out dx, eax out dx, eax
set_io [ebx + device.io_addr], reg_scb_cmd set_io [ebx + device.io_addr], reg_scb_cmd