Rev 5522 | Rev 6229 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5522 | Rev 6227 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; Realtek 8139 driver for KolibriOS ;; |
6 | ;; Realtek 8139 driver for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; based on RTL8139.asm driver for menuetos ;; |
8 | ;; based on RTL8139.asm driver for menuetos ;; |
Line 56... | Line 56... | ||
56 | REG_TXCONFIG = 0x40 ; transmit configuration register |
56 | REG_TXCONFIG = 0x40 ; transmit configuration register |
57 | REG_RXCONFIG = 0x44 ; receive configuration register 0 |
57 | REG_RXCONFIG = 0x44 ; receive configuration register 0 |
58 | REG_MPC = 0x4c ; missed packet counter |
58 | REG_MPC = 0x4c ; missed packet counter |
59 | REG_9346CR = 0x50 ; serial eeprom 93C46 command register |
59 | REG_9346CR = 0x50 ; serial eeprom 93C46 command register |
60 | REG_CONFIG1 = 0x52 ; configuration register 1 |
60 | REG_CONFIG1 = 0x52 ; configuration register 1 |
61 | REG_MSR = 0x58 |
61 | REG_MSR = 0x58 ; Media Status register |
62 | REG_CONFIG4 = 0x5a ; configuration register 4 |
62 | REG_CONFIG4 = 0x5a ; configuration register 4 |
63 | REG_HLTCLK = 0x5b ; undocumented halt clock register |
63 | REG_HLTCLK = 0x5b ; undocumented halt clock register |
64 | REG_BMCR = 0x62 ; basic mode control register |
64 | REG_BMCR = 0x62 ; basic mode control register |
65 | REG_ANAR = 0x66 ; auto negotiation advertisement register |
65 | REG_ANAR = 0x66 ; auto negotiation advertisement register |
66 | REG_9346CR_WE = 11b shl 6 |
66 | REG_9346CR_WE = 11b shl 6 |
Line 141... | Line 141... | ||
141 | EE_93C46_READ_CMD = (6 shl 6) ; 110b + 6bit address |
141 | EE_93C46_READ_CMD = (6 shl 6) ; 110b + 6bit address |
142 | EE_93C56_READ_CMD = (6 shl 8) ; 110b + 8bit address |
142 | EE_93C56_READ_CMD = (6 shl 8) ; 110b + 8bit address |
143 | EE_93C46_CMD_LENGTH = 9 ; start bit + cmd + 6bit address |
143 | EE_93C46_CMD_LENGTH = 9 ; start bit + cmd + 6bit address |
144 | EE_93C56_CMD_LENGTH = 11 ; start bit + cmd + 8bit ddress |
144 | EE_93C56_CMD_LENGTH = 11 ; start bit + cmd + 8bit ddress |
Line -... | Line 145... | ||
- | 145 | ||
145 | 146 | ; See chapter "5.7 Transmit Configuration Register" of RTL8139D(L).pdf |
|
146 | VER_RTL8139 = 1100000b |
147 | VER_RTL8139 = 1100000b |
147 | VER_RTL8139A = 1110000b |
148 | VER_RTL8139A = 1110000b |
148 | VER_RTL8139AG = 1110100b |
149 | VER_RTL8139AG = 1110100b |
149 | VER_RTL8139B = 1111000b |
150 | VER_RTL8139B = 1111000b |
Line 614... | Line 615... | ||
614 | out dx, ax |
615 | out dx, ax |
Line 615... | Line 616... | ||
615 | 616 | ||
616 | ; Set the mtu, kernel will be able to send now |
617 | ; Set the mtu, kernel will be able to send now |
Line 617... | Line 618... | ||
617 | mov [ebx + device.mtu], 1514 |
618 | mov [ebx + device.mtu], 1514 |
Line 618... | Line 619... | ||
618 | 619 | ||
619 | call cable |
620 | call link |
620 | 621 | ||
Line 943... | Line 944... | ||
943 | push ax |
944 | push ax |
944 | DEBUGF 2, "RX:buffer overflow!\n" |
945 | DEBUGF 2, "RX:buffer overflow!\n" |
Line 945... | Line 946... | ||
945 | 946 | ||
946 | set_io [ebx + device.io_addr], 0 |
947 | set_io [ebx + device.io_addr], 0 |
947 | set_io [ebx + device.io_addr], REG_ISR |
948 | set_io [ebx + device.io_addr], REG_ISR |
948 | mov ax, ISR_FIFOOVW or ISR_RXOVW |
949 | mov ax, ISR_FIFOOVW or ISR_RXOVW or ISR_ROK |
949 | out dx, ax |
950 | out dx, ax |
Line 950... | Line 951... | ||
950 | pop ax |
951 | pop ax |
951 | 952 | ||
Line 955... | Line 956... | ||
955 | test ax, ISR_PUN |
956 | test ax, ISR_PUN |
956 | jz @f |
957 | jz @f |
Line 957... | Line 958... | ||
957 | 958 | ||
Line 958... | Line 959... | ||
958 | DEBUGF 1, "Packet underrun or link changed!\n" |
959 | DEBUGF 1, "Packet underrun or link changed!\n" |
Line 959... | Line 960... | ||
959 | 960 | ||
960 | call cable |
961 | call link |
961 | 962 | ||
962 | ;---------------------------------------------------- |
963 | ;---------------------------------------------------- |
Line 968... | Line 969... | ||
968 | push ax |
969 | push ax |
969 | DEBUGF 2, "RX fifo overflow!\n" |
970 | DEBUGF 2, "RX fifo overflow!\n" |
Line 970... | Line 971... | ||
970 | 971 | ||
971 | set_io [ebx + device.io_addr], 0 |
972 | set_io [ebx + device.io_addr], 0 |
972 | set_io [ebx + device.io_addr], REG_ISR |
973 | set_io [ebx + device.io_addr], REG_ISR |
973 | mov ax, ISR_FIFOOVW or ISR_RXOVW |
974 | mov ax, ISR_FIFOOVW or ISR_RXOVW or ISR_ROK |
974 | out dx, ax |
975 | out dx, ax |
Line 975... | Line 976... | ||
975 | pop ax |
976 | pop ax |
976 | 977 | ||
Line 980... | Line 981... | ||
980 | test ax, ISR_LENCHG |
981 | test ax, ISR_LENCHG |
981 | jz .fail |
982 | jz .fail |
Line 982... | Line 983... | ||
982 | 983 | ||
Line 983... | Line 984... | ||
983 | DEBUGF 2, "Cable length changed!\n" |
984 | DEBUGF 2, "Cable length changed!\n" |
Line 984... | Line 985... | ||
984 | 985 | ||
985 | call cable |
986 | call link |
986 | 987 | ||
987 | .fail: |
988 | .fail: |
Line 992... | Line 993... | ||
992 | ret |
993 | ret |
Line 993... | Line 994... | ||
993 | 994 | ||
994 | 995 | ||
995 | 996 | ||
996 | 997 | ||
997 | ;;;;;;;;;;;;;;;;;;;;;;;;; |
998 | ;;;;;;;;;;;;;;;;;;;;;;; |
Line 998... | Line 999... | ||
998 | ;; ;; |
999 | ;; ;; |
999 | ;; Update Cable status ;; |
1000 | ;; Check link status ;; |
1000 | ;; ;; |
1001 | ;; ;; |
Line 1001... | Line 1002... | ||
1001 | ;;;;;;;;;;;;;;;;;;;;;;;;; |
1002 | ;;;;;;;;;;;;;;;;;;;;;;; |
1002 | 1003 | ||
1003 | align 4 |
1004 | align 4 |
Line 1004... | Line 1005... | ||
1004 | cable: |
1005 | link: |
1005 | DEBUGF 1, "Checking link status:\n" |
1006 | DEBUGF 1, "Checking link status:\n" |
Line -... | Line 1007... | ||
- | 1007 | ||
1006 | 1008 | set_io [ebx + device.io_addr], 0 |
|
1007 | set_io [ebx + device.io_addr], 0 |
1009 | set_io [ebx + device.io_addr], REG_MSR |
1008 | set_io [ebx + device.io_addr], REG_MSR |
- | |
1009 | in al, dx |
- | |
1010 | 1010 | in ax, dx |
|
1011 | test al, 1 shl 2 ; 0 = link ok 1 = link fail |
1011 | |
1012 | jnz .notconnected |
- | |
Line -... | Line 1012... | ||
- | 1012 | test al, 1 shl 2 ; 0 = link ok 1 = link fail |
|
- | 1013 | jnz .notconnected |
|
- | 1014 | ||
1013 | 1015 | mov ecx, ETH_LINK_10M |
|
- | 1016 | test al, 1 shl 3 ; 0 = 100 Mbps 1 = 10 Mbps |
|
- | 1017 | jnz @f |
|
Line 1014... | Line -... | ||
1014 | test al, 1 shl 3 ; 0 = 100 Mbps 1 = 10 Mbps |
- | |
1015 | jnz .10mbps |
1018 | mov ecx, ETH_LINK_100M |
1016 | 1019 | @@: |
|
1017 | .100mbps: |
1020 | |
1018 | mov [ebx + device.state], ETH_LINK_100M |
- | |
1019 | invoke NetLinkChanged |
1021 | set_io [ebx + device.io_addr], REG_BMCR |
Line 1020... | Line 1022... | ||
1020 | DEBUGF 2, "link changed to 100 mbit\n" |
1022 | in ax, dx |
1021 | 1023 | test ax, 1 shl 8 ; Duplex mode |
|
1022 | ret |
1024 | jz @f |
1023 | 1025 | or ecx, ETH_LINK_FD |
|
1024 | .10mbps: |
- | |
1025 | mov [ebx + device.state], ETH_LINK_10M |
1026 | @@: |
Line 1026... | Line 1027... | ||
1026 | invoke NetLinkChanged |
1027 |