i8254x: Link detection

git-svn-id: svn://kolibrios.org@5588 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-07-20 16:04:03 +00:00
parent b4928356ab
commit b87cf02d06

View File

@ -655,7 +655,7 @@ start_i8254x:
mov eax, [esi + REG_ICR] ; Clear pending interrupts mov eax, [esi + REG_ICR] ; Clear pending interrupts
mov [ebx + device.mtu], 1514 mov [ebx + device.mtu], 1514
mov [ebx + device.state], ETH_LINK_UNKNOWN ; Set link state to unknown call link_status
xor eax, eax xor eax, eax
ret ret
@ -704,6 +704,41 @@ read_mac:
ret ret
link_status:
DEBUGF 1,"Verifying link status\n"
xor ecx, ecx ; ETH_LINK_DOWN
mov esi, [ebx + device.mmio_addr]
mov eax, [esi + REG_STATUS]
test eax, STATUS_LU
jz .ok
test eax, STATUS_FD
jz @f
or cl, ETH_LINK_FD
@@:
shr eax, STATUS_SPEED_SHIFT
and al, 3
test al, al
jnz @f
or cl, ETH_LINK_10M
jmp .ok
@@:
cmp al, 1
jne @f
or cl, ETH_LINK_100M
jmp .ok
@@:
or cl, ETH_LINK_1G
; jmp .ok
.ok:
mov [ebx + device.state], ecx
invoke NetLinkChanged
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Transmit ;; ;; Transmit ;;
@ -891,6 +926,8 @@ int_handler:
DEBUGF 2,"Link Changed\n" DEBUGF 2,"Link Changed\n"
call link_status
.no_link: .no_link:
;--------------- ;---------------