diff --git a/drivers/ethernet/i8254x.asm b/drivers/ethernet/i8254x.asm index f18566359b..746c00d6ba 100644 --- a/drivers/ethernet/i8254x.asm +++ b/drivers/ethernet/i8254x.asm @@ -655,7 +655,7 @@ start_i8254x: mov eax, [esi + REG_ICR] ; Clear pending interrupts mov [ebx + device.mtu], 1514 - mov [ebx + device.state], ETH_LINK_UNKNOWN ; Set link state to unknown + call link_status xor eax, eax ret @@ -704,6 +704,41 @@ read_mac: 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 ;; @@ -891,6 +926,8 @@ int_handler: DEBUGF 2,"Link Changed\n" + call link_status + .no_link: ;---------------