i8254x: Improved interrupt handling.

git-svn-id: svn://kolibrios.org@9147 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2021-08-22 20:49:13 +00:00
parent 8822960988
commit b13c4c9c6d
2 changed files with 22 additions and 30 deletions

View File

@ -480,7 +480,7 @@ proc transmit stdcall bufferptr
add dword[ebx + device.bytes_tx], eax add dword[ebx + device.bytes_tx], eax
adc dword[ebx + device.bytes_tx + 4], 0 adc dword[ebx + device.bytes_tx + 4], 0
popf spin_unlock_irqrestore
xor eax, eax xor eax, eax
ret ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; i8254x driver for KolibriOS ;; ;; i8254x driver for KolibriOS ;;
@ -749,11 +749,10 @@ link_status:
;; Out: eax = 0 on success ;; ;; Out: eax = 0 on success ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 16
proc transmit stdcall bufferptr proc transmit stdcall bufferptr
pushf spin_lock_irqsave
cli
mov esi, [bufferptr] mov esi, [bufferptr]
DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length] DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [bufferptr], [esi + NET_BUFF.length]
@ -801,7 +800,7 @@ proc transmit stdcall bufferptr
call clean_tx call clean_tx
popf spin_unlock_irqrestore
xor eax, eax xor eax, eax
ret ret
@ -810,7 +809,7 @@ proc transmit stdcall bufferptr
DEBUGF 2,"Send failed\n" DEBUGF 2,"Send failed\n"
invoke NetFree, [bufferptr] invoke NetFree, [bufferptr]
popf spin_unlock_irqrestore
or eax, -1 or eax, -1
ret ret
@ -822,38 +821,24 @@ endp
;; Interrupt handler ;; ;; Interrupt handler ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
align 16
align 4
int_handler: int_handler:
push ebx esi edi push ebx esi edi
DEBUGF 1,"INT\n" mov ebx, [esp+4*4]
;------------------------------------------- DEBUGF 1,"INT for 0x%x\n", ebx
; Find pointer of device wich made IRQ occur
; TODO? if we are paranoid, we can check that the value from ebx is present in the current device_list
mov ecx, [devices]
test ecx, ecx
jz .nothing
mov esi, device_list
.nextdevice:
mov ebx, [esi]
mov edi, [ebx + device.mmio_addr] mov edi, [ebx + device.mmio_addr]
mov eax, [edi + REG_ICR] mov eax, [edi + REG_ICR]
cmp eax, 0xffffffff ; if so, hardware is no longer present
je .nothing ;
test eax, eax test eax, eax
jnz .got_it jz .nothing
.continue:
add esi, 4
dec ecx
jnz .nextdevice
.nothing:
pop edi esi ebx
xor eax, eax
ret DEBUGF 1,"Status: %x\n", eax
.got_it:
DEBUGF 1,"Device: %x Status: %x\n", ebx, eax
;--------- ;---------
; RX done? ; RX done?
@ -943,11 +928,18 @@ int_handler:
; call clean_tx ; call clean_tx
.no_tx: .no_tx:
pop edi esi ebx pop edi esi ebx
xor eax, eax xor eax, eax
inc eax inc eax
ret ret
.nothing:
pop edi esi ebx
xor eax, eax
ret
clean_tx: clean_tx: