Rev 8898 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8898 | Rev 8910 | ||
---|---|---|---|
Line 330... | Line 330... | ||
330 | pci_bus dd ? |
330 | pci_bus dd ? |
331 | pci_dev dd ? |
331 | pci_dev dd ? |
Line 332... | Line 332... | ||
332 | 332 | ||
Line -... | Line 333... | ||
- | 333 | phy dw ? |
|
- | 334 | ||
333 | phy dw ? |
335 | link_timer dd ? |
Line 334... | Line 336... | ||
334 | 336 | ||
335 | rb 0x100-($ and 0xff) ; align 256 |
337 | rb 0x100-($ and 0xff) ; align 256 |
336 | 338 | ||
Line 523... | Line 525... | ||
523 | ;; ;; |
525 | ;; ;; |
524 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
526 | ;;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\;; |
Line 525... | Line 527... | ||
525 | 527 | ||
526 | align 4 |
528 | align 4 |
- | 529 | unload: |
|
- | 530 | ||
- | 531 | cmp [ebx + device.link_timer], 0 |
|
- | 532 | je @f |
|
- | 533 | invoke CancelTimerHS, [ebx + device.link_timer] |
|
- | 534 | @@: |
|
527 | unload: |
535 | |
528 | ; TODO: (in this particular order) |
536 | ; TODO: (in this particular order) |
529 | ; |
537 | ; |
530 | ; - Stop the device |
538 | ; - Stop the device |
531 | ; - Detach int handler |
539 | ; - Detach int handler |
Line 712... | Line 720... | ||
712 | mov dword[ebx + device.init_block.filter+4], 0 |
720 | mov dword[ebx + device.init_block.filter+4], 0 |
Line 713... | Line 721... | ||
713 | 721 | ||
714 | align 4 |
722 | align 4 |
Line -... | Line 723... | ||
- | 723 | reset: |
|
- | 724 | ||
- | 725 | ; Stop link check timer if it was already running |
|
- | 726 | cmp [ebx + device.link_timer], 0 |
|
- | 727 | je @f |
|
- | 728 | invoke CancelTimerHS, [ebx + device.link_timer] |
|
715 | reset: |
729 | @@: |
Line 716... | Line 730... | ||
716 | 730 | ||
717 | ; attach int handler |
731 | ; attach int handler |
718 | 732 | ||
Line 832... | Line 846... | ||
832 | mov ecx, MII_PHYSID1 |
846 | mov ecx, MII_PHYSID1 |
833 | call mdio_read |
847 | call mdio_read |
834 | cmp ax, 0xffff |
848 | cmp ax, 0xffff |
835 | je .next |
849 | je .next |
Line 836... | Line 850... | ||
836 | 850 | ||
Line 837... | Line 851... | ||
837 | DEBUGF 1, "0x%x\n", ax |
851 | DEBUGF 1, "PHY ID1: 0x%x\n", ax |
838 | 852 | ||
839 | mov ecx, MII_PHYSID2 |
853 | mov ecx, MII_PHYSID2 |
840 | call mdio_read |
854 | call mdio_read |
Line 841... | Line 855... | ||
841 | cmp ax, 0xffff |
855 | cmp ax, 0xffff |
Line 842... | Line 856... | ||
842 | je .next |
856 | je .next |
Line 843... | Line 857... | ||
843 | 857 | ||
844 | DEBUGF 1, "0x%x\n", ax |
858 | DEBUGF 1, "PHY ID2: 0x%x\n", ax |
Line 922... | Line 936... | ||
922 | ; Start the device and enable interrupts |
936 | ; Start the device and enable interrupts |
923 | xor ecx, ecx |
937 | xor ecx, ecx |
924 | mov eax, CSR_START + CSR_INTEN |
938 | mov eax, CSR_START + CSR_INTEN |
925 | call [ebx + device.write_csr] |
939 | call [ebx + device.write_csr] |
Line 926... | Line 940... | ||
926 | 940 | ||
927 | ; Set the mtu, kernel will be able to send now |
941 | ; Set the MTU |
Line 928... | Line -... | ||
928 | mov [ebx + device.mtu], 1514 |
- | |
929 | 942 | mov [ebx + device.mtu], 1514 |
|
930 | ; get link status |
- | |
- | 943 | ||
- | 944 | mov [ebx + device.state], ETH_LINK_UNKNOWN |
|
931 | mov [ebx + device.state], ETH_LINK_UNKNOWN |
945 | ; Start media check timer |
- | 946 | cmp [ebx + device.mii], 0 |
|
- | 947 | je @f |
|
- | 948 | mov [ebx + device.state], ETH_LINK_DOWN |
|
- | 949 | invoke TimerHS, 0, 50, check_media_mii, ebx |
|
Line 932... | Line 950... | ||
932 | 950 | mov [ebx + device.link_timer], eax |
|
933 | call check_media |
951 | @@: |
934 | 952 | ||
935 | DEBUGF 1,"reset complete\n" |
953 | DEBUGF 1,"reset complete\n" |
Line 1002... | Line 1020... | ||
1002 | ;; ;; |
1020 | ;; ;; |
1003 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1021 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 1004... | Line 1022... | ||
1004 | 1022 | ||
Line 1005... | Line 1023... | ||
1005 | proc transmit stdcall bufferptr |
1023 | proc transmit stdcall bufferptr |
1006 | - | ||
Line 1007... | Line 1024... | ||
1007 | pushf |
1024 | |
1008 | cli |
1025 | spin_lock_irqsave |
1009 | 1026 | ||
1010 | mov esi, [bufferptr] |
1027 | mov esi, [bufferptr] |
Line 1056... | Line 1073... | ||
1056 | inc [ebx + device.packets_tx] |
1073 | inc [ebx + device.packets_tx] |
1057 | mov eax, [esi + NET_BUFF.length] |
1074 | mov eax, [esi + NET_BUFF.length] |
1058 | add dword[ebx + device.bytes_tx], eax |
1075 | add dword[ebx + device.bytes_tx], eax |
1059 | adc dword[ebx + device.bytes_tx + 4], 0 |
1076 | adc dword[ebx + device.bytes_tx + 4], 0 |
Line 1060... | Line 1077... | ||
1060 | 1077 | ||
1061 | popf |
1078 | spin_unlock_irqrestore |
1062 | xor eax, eax |
1079 | xor eax, eax |
Line 1063... | Line 1080... | ||
1063 | ret |
1080 | ret |
1064 | 1081 | ||
1065 | .error: |
1082 | .error: |
1066 | DEBUGF 2, "TX packet error\n" |
1083 | DEBUGF 2, "TX packet error\n" |
Line 1067... | Line 1084... | ||
1067 | inc [ebx + device.packets_tx_err] |
1084 | inc [ebx + device.packets_tx_err] |
1068 | invoke NetFree, [bufferptr] |
1085 | invoke NetFree, [bufferptr] |
1069 | 1086 | ||
Line 1070... | Line 1087... | ||
1070 | popf |
1087 | spin_unlock_irqrestore |
1071 | or eax, -1 |
1088 | or eax, -1 |
1072 | ret |
1089 | ret |
1073 | 1090 | ||
Line 1074... | Line 1091... | ||
1074 | .overrun: |
1091 | .overrun: |
1075 | DEBUGF 2, "TX overrun\n" |
1092 | DEBUGF 2, "TX overrun\n" |
1076 | inc [ebx + device.packets_tx_ovr] |
1093 | inc [ebx + device.packets_tx_ovr] |
Line 1077... | Line 1094... | ||
1077 | invoke NetFree, [bufferptr] |
1094 | invoke NetFree, [bufferptr] |
Line 1558... | Line 1575... | ||
1558 | call [ebx + device.write_bcr] |
1575 | call [ebx + device.write_bcr] |
Line 1559... | Line 1576... | ||
1559 | 1576 | ||
Line 1560... | Line -... | ||
1560 | ret |
- | |
1561 | - | ||
Line 1562... | Line -... | ||
1562 | - | ||
Line 1563... | Line 1577... | ||
1563 | align 4 |
1577 | ret |
1564 | check_media: |
- | |
Line -... | Line 1578... | ||
- | 1578 | ||
- | 1579 | ||
1565 | 1580 | ||
1566 | DEBUGF 1, "check_media\n" |
1581 | |
- | 1582 | proc check_media_mii stdcall dev:dword |
|
- | 1583 | ||
- | 1584 | spin_lock_irqsave |
|
- | 1585 | ||
- | 1586 | mov ebx, [dev] |
|
- | 1587 | mov edx, [ebx + device.io_addr] |
|
- | 1588 | ||
- | 1589 | mov ecx, MII_BMSR |
|
- | 1590 | call mdio_read |
|
1567 | 1591 | ||
- | 1592 | mov ecx, MII_BMSR |
|
- | 1593 | call mdio_read |
|
- | 1594 | ||
- | 1595 | mov ecx, eax |
|
- | 1596 | and eax, BMSR_LSTATUS |
|
Line -... | Line 1597... | ||
- | 1597 | shr eax, 2 |
|
- | 1598 | cmp eax, [ebx + device.state] |
|
- | 1599 | jne .changed |
|
- | 1600 | ||
- | 1601 | spin_unlock_irqrestore |
|
- | 1602 | ret |
|
- | 1603 | ||
- | 1604 | .changed: |
|
- | 1605 | test eax, eax |
|
- | 1606 | jz .update |
|
- | 1607 | ||
- | 1608 | test ecx, BMSR_ANEGCOMPLETE |
|
- | 1609 | jz .update |
|
- | 1610 | ||
- | 1611 | mov ecx, MII_ADVERTISE |
|
- | 1612 | call mdio_read |
|
- | 1613 | mov esi, eax |
|
- | 1614 | ||
- | 1615 | mov ecx, MII_LPA |
|
- | 1616 | call mdio_read |
|
- | 1617 | and eax, esi |
|
- | 1618 | ||
- | 1619 | test eax, LPA_100FULL |
|
- | 1620 | jz @f |
|
- | 1621 | mov eax, ETH_LINK_100M or ETH_LINK_FD |
|
- | 1622 | jmp .update |
|
- | 1623 | @@: |
|
- | 1624 | ||
- | 1625 | test eax, LPA_100HALF |
|
- | 1626 | jz @f |
|
- | 1627 | mov eax, ETH_LINK_100M |
|
- | 1628 | jmp .update |
|
- | 1629 | @@: |
|
- | 1630 | ||
- | 1631 | test eax, LPA_10FULL |
|
- | 1632 | jz @f |
|
- | 1633 | mov eax, ETH_LINK_10M or ETH_LINK_FD |
|
- | 1634 | jmp .update |
|
- | 1635 | @@: |
|
- | 1636 | ||
- | 1637 | test eax, LPA_10HALF |
|
- | 1638 | jz @f |
|
1568 | test [ebx + device.mii], 1 |
1639 | mov eax, ETH_LINK_10M |
- | 1640 | jmp .update |
|
Line -... | Line 1641... | ||
- | 1641 | @@: |
|
- | 1642 | ||
1569 | jnz mii_link_ok |
1643 | mov eax, ETH_LINK_UNKNOWN |
Line -... | Line 1644... | ||
- | 1644 | ||
- | 1645 | .update: |
|
Line 1570... | Line 1646... | ||
1570 | 1646 | mov [ebx + device.state], eax |
|
Line 1571... | Line 1647... | ||
1571 | mov ecx, BCR_LED0 |
1647 | invoke NetLinkChanged |