From b87cf02d06b4398afbe3328b73205199bb2a1933 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Mon, 20 Jul 2015 16:04:03 +0000 Subject: [PATCH] i8254x: Link detection git-svn-id: svn://kolibrios.org@5588 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/ethernet/i8254x.asm | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) 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: ;---------------