Rev 1558 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1558 | Rev 1559 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2010. 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 | ;; RTL8169 driver for KolibriOS ;; |
6 | ;; RTL8169 driver for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Copyright 2007 mike.dld, ;; |
8 | ;; Copyright 2007 mike.dld, ;; |
9 | ;; mike.dld@gmail.com ;; |
9 | ;; mike.dld@gmail.com ;; |
10 | ;; ;; |
10 | ;; ;; |
11 | ;; Version 0.1 11 February 2007 ;; |
11 | ;; Version 0.1 11 February 2007 ;; |
12 | ;; Version 0.2 3 August 2010 - port to net branch by hidnplayr ;; |
12 | ;; Version 0.2 3 August 2010 - port to net branch by hidnplayr ;; |
13 | ;; ;; |
13 | ;; ;; |
14 | ;; References: ;; |
14 | ;; References: ;; |
15 | ;; r8169.c - linux driver (etherboot project) ;; |
15 | ;; r8169.c - linux driver (etherboot project) ;; |
16 | ;; ;; |
16 | ;; ;; |
17 | ;; GNU GENERAL PUBLIC LICENSE ;; |
17 | ;; GNU GENERAL PUBLIC LICENSE ;; |
18 | ;; Version 2, June 1991 ;; |
18 | ;; Version 2, June 1991 ;; |
19 | ;; ;; |
19 | ;; ;; |
20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
21 | 21 | ||
22 | format MS COFF |
22 | format MS COFF |
23 | 23 | ||
24 | API_VERSION equ 0x01000100 |
24 | API_VERSION equ 0x01000100 |
25 | DRIVER_VERSION equ 5 |
25 | DRIVER_VERSION equ 5 |
26 | 26 | ||
27 | MAX_DEVICES equ 16 |
27 | MAX_DEVICES equ 16 |
28 | 28 | ||
29 | DEBUG equ 1 |
29 | DEBUG equ 1 |
30 | __DEBUG__ equ 1 |
30 | __DEBUG__ equ 1 |
31 | __DEBUG_LEVEL__ equ 1 |
31 | __DEBUG_LEVEL__ equ 1 |
32 | 32 | ||
33 | NUM_TX_DESC equ 4 |
33 | NUM_TX_DESC equ 4 |
34 | NUM_RX_DESC equ 4 |
34 | NUM_RX_DESC equ 4 |
35 | 35 | ||
36 | include 'proc32.inc' |
36 | include 'proc32.inc' |
37 | include 'imports.inc' |
37 | include 'imports.inc' |
38 | include 'fdo.inc' |
38 | include 'fdo.inc' |
39 | include 'netdrv.inc' |
39 | include 'netdrv.inc' |
40 | 40 | ||
41 | public START |
41 | public START |
42 | public service_proc |
42 | public service_proc |
43 | public version |
43 | public version |
44 | 44 | ||
45 | 45 | ||
46 | REG_MAC0 equ 0x0 ; Ethernet hardware address |
46 | REG_MAC0 equ 0x0 ; Ethernet hardware address |
47 | REG_MAR0 equ 0x8 ; Multicast filter |
47 | REG_MAR0 equ 0x8 ; Multicast filter |
48 | REG_TxDescStartAddr equ 0x20 |
48 | REG_TxDescStartAddr equ 0x20 |
49 | REG_TxHDescStartAddr equ 0x28 |
49 | REG_TxHDescStartAddr equ 0x28 |
50 | REG_FLASH equ 0x30 |
50 | REG_FLASH equ 0x30 |
51 | REG_ERSR equ 0x36 |
51 | REG_ERSR equ 0x36 |
52 | REG_ChipCmd equ 0x37 |
52 | REG_ChipCmd equ 0x37 |
53 | REG_TxPoll equ 0x38 |
53 | REG_TxPoll equ 0x38 |
54 | REG_IntrMask equ 0x3C |
54 | REG_IntrMask equ 0x3C |
55 | REG_IntrStatus equ 0x3E |
55 | REG_IntrStatus equ 0x3E |
56 | REG_TxConfig equ 0x40 |
56 | REG_TxConfig equ 0x40 |
57 | REG_RxConfig equ 0x44 |
57 | REG_RxConfig equ 0x44 |
58 | REG_RxMissed equ 0x4C |
58 | REG_RxMissed equ 0x4C |
59 | REG_Cfg9346 equ 0x50 |
59 | REG_Cfg9346 equ 0x50 |
60 | REG_Config0 equ 0x51 |
60 | REG_Config0 equ 0x51 |
61 | REG_Config1 equ 0x52 |
61 | REG_Config1 equ 0x52 |
62 | REG_Config2 equ 0x53 |
62 | REG_Config2 equ 0x53 |
63 | REG_Config3 equ 0x54 |
63 | REG_Config3 equ 0x54 |
64 | REG_Config4 equ 0x55 |
64 | REG_Config4 equ 0x55 |
65 | REG_Config5 equ 0x56 |
65 | REG_Config5 equ 0x56 |
66 | REG_MultiIntr equ 0x5C |
66 | REG_MultiIntr equ 0x5C |
67 | REG_PHYAR equ 0x60 |
67 | REG_PHYAR equ 0x60 |
68 | REG_TBICSR equ 0x64 |
68 | REG_TBICSR equ 0x64 |
69 | REG_TBI_ANAR equ 0x68 |
69 | REG_TBI_ANAR equ 0x68 |
70 | REG_TBI_LPAR equ 0x6A |
70 | REG_TBI_LPAR equ 0x6A |
71 | REG_PHYstatus equ 0x6C |
71 | REG_PHYstatus equ 0x6C |
72 | REG_RxMaxSize equ 0xDA |
72 | REG_RxMaxSize equ 0xDA |
73 | REG_CPlusCmd equ 0xE0 |
73 | REG_CPlusCmd equ 0xE0 |
74 | REG_RxDescStartAddr equ 0xE4 |
74 | REG_RxDescStartAddr equ 0xE4 |
75 | REG_ETThReg equ 0xEC |
75 | REG_ETThReg equ 0xEC |
76 | REG_FuncEvent equ 0xF0 |
76 | REG_FuncEvent equ 0xF0 |
77 | REG_FuncEventMask equ 0xF4 |
77 | REG_FuncEventMask equ 0xF4 |
78 | REG_FuncPresetState equ 0xF8 |
78 | REG_FuncPresetState equ 0xF8 |
79 | REG_FuncForceEvent equ 0xFC |
79 | REG_FuncForceEvent equ 0xFC |
80 | 80 | ||
81 | ; InterruptStatusBits |
81 | ; InterruptStatusBits |
82 | ISB_SYSErr equ 0x8000 |
82 | ISB_SYSErr equ 0x8000 |
83 | ISB_PCSTimeout equ 0x4000 |
83 | ISB_PCSTimeout equ 0x4000 |
84 | ISB_SWInt equ 0x0100 |
84 | ISB_SWInt equ 0x0100 |
85 | ISB_TxDescUnavail equ 0x80 |
85 | ISB_TxDescUnavail equ 0x80 |
86 | ISB_RxFIFOOver equ 0x40 |
86 | ISB_RxFIFOOver equ 0x40 |
87 | ISB_LinkChg equ 0x20 |
87 | ISB_LinkChg equ 0x20 |
88 | ISB_RxOverflow equ 0x10 |
88 | ISB_RxOverflow equ 0x10 |
89 | ISB_TxErr equ 0x08 |
89 | ISB_TxErr equ 0x08 |
90 | ISB_TxOK equ 0x04 |
90 | ISB_TxOK equ 0x04 |
91 | ISB_RxErr equ 0x02 |
91 | ISB_RxErr equ 0x02 |
92 | ISB_RxOK equ 0x01 |
92 | ISB_RxOK equ 0x01 |
93 | 93 | ||
94 | ; RxStatusDesc |
94 | ; RxStatusDesc |
95 | SD_RxRES equ 0x00200000 |
95 | SD_RxRES equ 0x00200000 |
96 | SD_RxCRC equ 0x00080000 |
96 | SD_RxCRC equ 0x00080000 |
97 | SD_RxRUNT equ 0x00100000 |
97 | SD_RxRUNT equ 0x00100000 |
98 | SD_RxRWT equ 0x00400000 |
98 | SD_RxRWT equ 0x00400000 |
99 | 99 | ||
100 | ; ChipCmdBits |
100 | ; ChipCmdBits |
101 | CMD_Reset equ 0x10 |
101 | CMD_Reset equ 0x10 |
102 | CMD_RxEnb equ 0x08 |
102 | CMD_RxEnb equ 0x08 |
103 | CMD_TxEnb equ 0x04 |
103 | CMD_TxEnb equ 0x04 |
104 | CMD_RxBufEmpty equ 0x01 |
104 | CMD_RxBufEmpty equ 0x01 |
105 | 105 | ||
106 | ; Cfg9346Bits |
106 | ; Cfg9346Bits |
107 | CFG_9346_Lock equ 0x00 |
107 | CFG_9346_Lock equ 0x00 |
108 | CFG_9346_Unlock equ 0xC0 |
108 | CFG_9346_Unlock equ 0xC0 |
109 | 109 | ||
110 | ; rx_mode_bits |
110 | ; rx_mode_bits |
111 | RXM_AcceptErr equ 0x20 |
111 | RXM_AcceptErr equ 0x20 |
112 | RXM_AcceptRunt equ 0x10 |
112 | RXM_AcceptRunt equ 0x10 |
113 | RXM_AcceptBroadcast equ 0x08 |
113 | RXM_AcceptBroadcast equ 0x08 |
114 | RXM_AcceptMulticast equ 0x04 |
114 | RXM_AcceptMulticast equ 0x04 |
115 | RXM_AcceptMyPhys equ 0x02 |
115 | RXM_AcceptMyPhys equ 0x02 |
116 | RXM_AcceptAllPhys equ 0x01 |
116 | RXM_AcceptAllPhys equ 0x01 |
117 | 117 | ||
118 | ; RxConfigBits |
118 | ; RxConfigBits |
119 | RXC_FIFOShift equ 13 |
119 | RXC_FIFOShift equ 13 |
120 | RXC_DMAShift equ 8 |
120 | RXC_DMAShift equ 8 |
121 | 121 | ||
122 | ; TxConfigBits |
122 | ; TxConfigBits |
123 | TXC_InterFrameGapShift equ 24 |
123 | TXC_InterFrameGapShift equ 24 |
124 | TXC_DMAShift equ 8 ; DMA burst value (0-7) is shift this many bits |
124 | TXC_DMAShift equ 8 ; DMA burst value (0-7) is shift this many bits |
125 | 125 | ||
126 | ; PHYstatus |
126 | ; PHYstatus |
127 | PHYS_TBI_Enable equ 0x80 |
127 | PHYS_TBI_Enable equ 0x80 |
128 | PHYS_TxFlowCtrl equ 0x40 |
128 | PHYS_TxFlowCtrl equ 0x40 |
129 | PHYS_RxFlowCtrl equ 0x20 |
129 | PHYS_RxFlowCtrl equ 0x20 |
130 | PHYS_1000bpsF equ 0x10 |
130 | PHYS_1000bpsF equ 0x10 |
131 | PHYS_100bps equ 0x08 |
131 | PHYS_100bps equ 0x08 |
132 | PHYS_10bps equ 0x04 |
132 | PHYS_10bps equ 0x04 |
133 | PHYS_LinkStatus equ 0x02 |
133 | PHYS_LinkStatus equ 0x02 |
134 | PHYS_FullDup equ 0x01 |
134 | PHYS_FullDup equ 0x01 |
135 | 135 | ||
136 | ; GIGABIT_PHY_registers |
136 | ; GIGABIT_PHY_registers |
137 | PHY_CTRL_REG equ 0 |
137 | PHY_CTRL_REG equ 0 |
138 | PHY_STAT_REG equ 1 |
138 | PHY_STAT_REG equ 1 |
139 | PHY_AUTO_NEGO_REG equ 4 |
139 | PHY_AUTO_NEGO_REG equ 4 |
140 | PHY_1000_CTRL_REG equ 9 |
140 | PHY_1000_CTRL_REG equ 9 |
141 | 141 | ||
142 | ; GIGABIT_PHY_REG_BIT |
142 | ; GIGABIT_PHY_REG_BIT |
143 | PHY_Restart_Auto_Nego equ 0x0200 |
143 | PHY_Restart_Auto_Nego equ 0x0200 |
144 | PHY_Enable_Auto_Nego equ 0x1000 |
144 | PHY_Enable_Auto_Nego equ 0x1000 |
145 | 145 | ||
146 | ; PHY_STAT_REG = 1; |
146 | ; PHY_STAT_REG = 1; |
147 | PHY_Auto_Neco_Comp equ 0x0020 |
147 | PHY_Auto_Neco_Comp equ 0x0020 |
148 | 148 | ||
149 | ; PHY_AUTO_NEGO_REG = 4; |
149 | ; PHY_AUTO_NEGO_REG = 4; |
150 | PHY_Cap_10_Half equ 0x0020 |
150 | PHY_Cap_10_Half equ 0x0020 |
151 | PHY_Cap_10_Full equ 0x0040 |
151 | PHY_Cap_10_Full equ 0x0040 |
152 | PHY_Cap_100_Half equ 0x0080 |
152 | PHY_Cap_100_Half equ 0x0080 |
153 | PHY_Cap_100_Full equ 0x0100 |
153 | PHY_Cap_100_Full equ 0x0100 |
154 | 154 | ||
155 | ; PHY_1000_CTRL_REG = 9; |
155 | ; PHY_1000_CTRL_REG = 9; |
156 | PHY_Cap_1000_Full equ 0x0200 |
156 | PHY_Cap_1000_Full equ 0x0200 |
157 | PHY_Cap_1000_Half equ 0x0100 |
157 | PHY_Cap_1000_Half equ 0x0100 |
158 | 158 | ||
159 | PHY_Cap_PAUSE equ 0x0400 |
159 | PHY_Cap_PAUSE equ 0x0400 |
160 | PHY_Cap_ASYM_PAUSE equ 0x0800 |
160 | PHY_Cap_ASYM_PAUSE equ 0x0800 |
161 | 161 | ||
162 | PHY_Cap_Null equ 0x0 |
162 | PHY_Cap_Null equ 0x0 |
163 | 163 | ||
164 | ; _MediaType |
164 | ; _MediaType |
165 | MT_10_Half equ 0x01 |
165 | MT_10_Half equ 0x01 |
166 | MT_10_Full equ 0x02 |
166 | MT_10_Full equ 0x02 |
167 | MT_100_Half equ 0x04 |
167 | MT_100_Half equ 0x04 |
168 | MT_100_Full equ 0x08 |
168 | MT_100_Full equ 0x08 |
169 | MT_1000_Full equ 0x10 |
169 | MT_1000_Full equ 0x10 |
170 | 170 | ||
171 | ; _TBICSRBit |
171 | ; _TBICSRBit |
172 | TBI_LinkOK equ 0x02000000 |
172 | TBI_LinkOK equ 0x02000000 |
173 | 173 | ||
174 | ; _DescStatusBit |
174 | ; _DescStatusBit |
175 | DSB_OWNbit equ 0x80000000 |
175 | DSB_OWNbit equ 0x80000000 |
176 | DSB_EORbit equ 0x40000000 |
176 | DSB_EORbit equ 0x40000000 |
177 | DSB_FSbit equ 0x20000000 |
177 | DSB_FSbit equ 0x20000000 |
178 | DSB_LSbit equ 0x10000000 |
178 | DSB_LSbit equ 0x10000000 |
179 | 179 | ||
180 | RX_BUF_SIZE equ 1536 ; Rx Buffer size |
180 | RX_BUF_SIZE equ 1536 ; Rx Buffer size |
181 | 181 | ||
182 | 182 | ||
183 | ETH_ALEN equ 6 |
183 | ETH_ALEN equ 6 |
184 | ETH_HLEN equ (2 * ETH_ALEN + 2) |
184 | ETH_HLEN equ (2 * ETH_ALEN + 2) |
185 | ETH_ZLEN equ 60 ; 60 + 4bytes auto payload for |
185 | ETH_ZLEN equ 60 ; 60 + 4bytes auto payload for |
186 | ; mininmum 64bytes frame length |
186 | ; mininmum 64bytes frame length |
187 | 187 | ||
188 | ; MAC address length |
188 | ; MAC address length |
189 | MAC_ADDR_LEN equ 6 |
189 | MAC_ADDR_LEN equ 6 |
190 | 190 | ||
191 | ; max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4) |
191 | ; max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4) |
192 | MAX_ETH_FRAME_SIZE equ 1536 |
192 | MAX_ETH_FRAME_SIZE equ 1536 |
193 | 193 | ||
194 | TX_FIFO_THRESH equ 256 ; In bytes |
194 | TX_FIFO_THRESH equ 256 ; In bytes |
195 | 195 | ||
196 | RX_FIFO_THRESH equ 7 ; 7 means NO threshold, Rx buffer level before first PCI xfer |
196 | RX_FIFO_THRESH equ 7 ; 7 means NO threshold, Rx buffer level before first PCI xfer |
197 | RX_DMA_BURST equ 7 ; Maximum PCI burst, '6' is 1024 |
197 | RX_DMA_BURST equ 7 ; Maximum PCI burst, '6' is 1024 |
198 | TX_DMA_BURST equ 7 ; Maximum PCI burst, '6' is 1024 |
198 | TX_DMA_BURST equ 7 ; Maximum PCI burst, '6' is 1024 |
199 | ETTh equ 0x3F ; 0x3F means NO threshold |
199 | ETTh equ 0x3F ; 0x3F means NO threshold |
200 | 200 | ||
201 | EarlyTxThld equ 0x3F ; 0x3F means NO early transmit |
201 | EarlyTxThld equ 0x3F ; 0x3F means NO early transmit |
202 | RxPacketMaxSize equ 0x0800 ; Maximum size supported is 16K-1 |
202 | RxPacketMaxSize equ 0x0800 ; Maximum size supported is 16K-1 |
203 | InterFrameGap equ 0x03 ; 3 means InterFrameGap = the shortest one |
203 | InterFrameGap equ 0x03 ; 3 means InterFrameGap = the shortest one |
204 | 204 | ||
205 | HZ equ 1000 |
205 | HZ equ 1000 |
206 | 206 | ||
207 | RTL_MIN_IO_SIZE equ 0x80 |
207 | RTL_MIN_IO_SIZE equ 0x80 |
208 | TX_TIMEOUT equ (6*HZ) |
208 | TX_TIMEOUT equ (6*HZ) |
209 | 209 | ||
210 | TIMER_EXPIRE_TIME equ 100 |
210 | TIMER_EXPIRE_TIME equ 100 |
211 | 211 | ||
212 | ETH_HDR_LEN equ 14 |
212 | ETH_HDR_LEN equ 14 |
213 | DEFAULT_MTU equ 1500 |
213 | DEFAULT_MTU equ 1500 |
214 | DEFAULT_RX_BUF_LEN equ 1536 |
214 | DEFAULT_RX_BUF_LEN equ 1536 |
215 | 215 | ||
216 | 216 | ||
217 | ;#ifdef JUMBO_FRAME_SUPPORT |
217 | ;#ifdef JUMBO_FRAME_SUPPORT |
218 | ;#define MAX_JUMBO_FRAME_MTU ( 10000 ) |
218 | ;#define MAX_JUMBO_FRAME_MTU ( 10000 ) |
219 | ;#define MAX_RX_SKBDATA_SIZE ( MAX_JUMBO_FRAME_MTU + ETH_HDR_LEN ) |
219 | ;#define MAX_RX_SKBDATA_SIZE ( MAX_JUMBO_FRAME_MTU + ETH_HDR_LEN ) |
220 | ;#else |
220 | ;#else |
221 | MAX_RX_SKBDATA_SIZE equ 1600 |
221 | MAX_RX_SKBDATA_SIZE equ 1600 |
222 | ;#endif //end #ifdef JUMBO_FRAME_SUPPORT |
222 | ;#endif //end #ifdef JUMBO_FRAME_SUPPORT |
223 | 223 | ||
224 | MCFG_METHOD_01 equ 0x01 |
224 | MCFG_METHOD_01 equ 0x01 |
225 | MCFG_METHOD_02 equ 0x02 |
225 | MCFG_METHOD_02 equ 0x02 |
226 | MCFG_METHOD_03 equ 0x03 |
226 | MCFG_METHOD_03 equ 0x03 |
227 | MCFG_METHOD_04 equ 0x04 |
227 | MCFG_METHOD_04 equ 0x04 |
228 | MCFG_METHOD_05 equ 0x05 |
228 | MCFG_METHOD_05 equ 0x05 |
229 | MCFG_METHOD_11 equ 0x0b |
229 | MCFG_METHOD_11 equ 0x0b |
230 | MCFG_METHOD_12 equ 0x0c |
230 | MCFG_METHOD_12 equ 0x0c |
231 | MCFG_METHOD_13 equ 0x0d |
231 | MCFG_METHOD_13 equ 0x0d |
232 | MCFG_METHOD_14 equ 0x0e |
232 | MCFG_METHOD_14 equ 0x0e |
233 | MCFG_METHOD_15 equ 0x0f |
233 | MCFG_METHOD_15 equ 0x0f |
234 | 234 | ||
235 | PCFG_METHOD_1 equ 0x01 ; PHY Reg 0x03 bit0-3 == 0x0000 |
235 | PCFG_METHOD_1 equ 0x01 ; PHY Reg 0x03 bit0-3 == 0x0000 |
236 | PCFG_METHOD_2 equ 0x02 ; PHY Reg 0x03 bit0-3 == 0x0001 |
236 | PCFG_METHOD_2 equ 0x02 ; PHY Reg 0x03 bit0-3 == 0x0001 |
237 | PCFG_METHOD_3 equ 0x03 ; PHY Reg 0x03 bit0-3 == 0x0002 |
237 | PCFG_METHOD_3 equ 0x03 ; PHY Reg 0x03 bit0-3 == 0x0002 |
238 | 238 | ||
239 | virtual at 0 |
239 | virtual at 0 |
240 | tx_desc: |
240 | tx_desc: |
241 | .status dd ? |
241 | .status dd ? |
242 | .vlan_tag dd ? |
242 | .vlan_tag dd ? |
243 | .buf_addr dq ? |
243 | .buf_addr dq ? |
244 | .size = $ |
244 | .size = $ |
245 | rb (NUM_TX_DESC-1)*tx_desc.size |
245 | rb (NUM_TX_DESC-1)*tx_desc.size |
246 | .buf_soft_addr dd ? |
246 | .buf_soft_addr dd ? |
247 | end virtual |
247 | end virtual |
248 | 248 | ||
249 | virtual at 0 |
249 | virtual at 0 |
250 | rx_desc: |
250 | rx_desc: |
251 | .status dd ? |
251 | .status dd ? |
252 | .vlan_tag dd ? |
252 | .vlan_tag dd ? |
253 | .buf_addr dq ? |
253 | .buf_addr dq ? |
254 | .size = $ |
254 | .size = $ |
255 | rb (NUM_RX_DESC-1)*rx_desc.size |
255 | rb (NUM_RX_DESC-1)*rx_desc.size |
256 | .buf_soft_addr dd ? |
256 | .buf_soft_addr dd ? |
257 | end virtual |
257 | end virtual |
258 | 258 | ||
259 | virtual at ebx |
259 | virtual at ebx |
260 | 260 | ||
261 | device: |
261 | device: |
262 | 262 | ||
263 | ETH_DEVICE |
263 | ETH_DEVICE |
264 | 264 | ||
265 | .io_addr dd ? |
265 | .io_addr dd ? |
266 | .pci_bus db ? |
266 | .pci_bus db ? |
267 | .pci_dev db ? |
267 | .pci_dev db ? |
268 | .irq_line db ? |
268 | .irq_line db ? |
269 | 269 | ||
270 | tpc: |
270 | tpc: |
271 | .mmio_addr dd ? ; memory map physical address |
271 | .mmio_addr dd ? ; memory map physical address |
272 | .chipset dd ? |
272 | .chipset dd ? |
273 | .pcfg dd ? |
273 | .pcfg dd ? |
274 | .mcfg dd ? |
274 | .mcfg dd ? |
275 | .cur_rx dd ? ; Index into the Rx descriptor buffer of next Rx pkt |
275 | .cur_rx dd ? ; Index into the Rx descriptor buffer of next Rx pkt |
276 | .cur_tx dd ? ; Index into the Tx descriptor buffer of next Rx pkt |
276 | .cur_tx dd ? ; Index into the Tx descriptor buffer of next Rx pkt |
277 | .TxDescArrays dd ? ; Index of Tx Descriptor buffer |
277 | .TxDescArrays dd ? ; Index of Tx Descriptor buffer |
278 | .RxDescArrays dd ? ; Index of Rx Descriptor buffer |
278 | .RxDescArrays dd ? ; Index of Rx Descriptor buffer |
279 | .TxDescArray dd ? ; Index of 256-alignment Tx Descriptor buffer |
279 | .TxDescArray dd ? ; Index of 256-alignment Tx Descriptor buffer |
280 | .RxDescArray dd ? ; Index of 256-alignment Rx Descriptor buffer |
280 | .RxDescArray dd ? ; Index of 256-alignment Rx Descriptor buffer |
281 | 281 | ||
282 | rb 256-(($ - device) and 255) ; align 256 |
282 | rb 256-(($ - device) and 255) ; align 256 |
283 | tx_ring rb NUM_TX_DESC * tx_desc.size * 2 |
283 | tx_ring rb NUM_TX_DESC * tx_desc.size * 2 |
284 | 284 | ||
285 | rb 256-(($ - device) and 255) ; align 256 |
285 | rb 256-(($ - device) and 255) ; align 256 |
286 | rx_ring rb NUM_RX_DESC * rx_desc.size * 2 |
286 | rx_ring rb NUM_RX_DESC * rx_desc.size * 2 |
287 | 287 | ||
288 | device_size = $ - device |
288 | device_size = $ - device |
289 | 289 | ||
290 | end virtual |
290 | end virtual |
291 | 291 | ||
292 | intr_mask = ISB_LinkChg or ISB_RxOverflow or ISB_RxFIFOOver or ISB_TxErr or ISB_TxOK or ISB_RxErr or ISB_RxOK |
292 | intr_mask = ISB_LinkChg or ISB_RxOverflow or ISB_RxFIFOOver or ISB_TxErr or ISB_TxOK or ISB_RxErr or ISB_RxOK |
293 | rx_config = (RX_FIFO_THRESH shl RXC_FIFOShift) or (RX_DMA_BURST shl RXC_DMAShift) or 0x0000000E |
293 | rx_config = (RX_FIFO_THRESH shl RXC_FIFOShift) or (RX_DMA_BURST shl RXC_DMAShift) or 0x0000000E |
294 | 294 | ||
295 | 295 | ||
296 | macro udelay msec { |
296 | macro udelay msec { |
297 | 297 | ||
298 | push esi |
298 | push esi |
299 | mov esi, msec |
299 | mov esi, msec |
300 | call Sleep |
300 | call Sleep |
301 | pop esi |
301 | pop esi |
302 | 302 | ||
303 | } |
303 | } |
304 | 304 | ||
305 | macro WRITE_GMII_REG RegAddr, value { |
305 | macro WRITE_GMII_REG RegAddr, value { |
306 | 306 | ||
307 | set_io REG_PHYAR |
307 | set_io REG_PHYAR |
308 | if value eq ax |
308 | if value eq ax |
309 | and eax, 0x0000ffff |
309 | and eax, 0x0000ffff |
310 | or eax, 0x80000000 + (RegAddr shl 16) |
310 | or eax, 0x80000000 + (RegAddr shl 16) |
311 | else |
311 | else |
312 | mov eax, 0x80000000 + (RegAddr shl 16) + value |
312 | mov eax, 0x80000000 + (RegAddr shl 16) + value |
313 | end if |
313 | end if |
314 | out dx, eax |
314 | out dx, eax |
315 | 315 | ||
316 | call PHY_WAIT |
316 | call PHY_WAIT |
317 | } |
317 | } |
318 | 318 | ||
319 | macro READ_GMII_REG RegAddr { |
319 | macro READ_GMII_REG RegAddr { |
320 | 320 | ||
321 | local .error, .done |
321 | local .error, .done |
322 | 322 | ||
323 | set_io REG_PHYAR |
323 | set_io REG_PHYAR |
324 | mov eax, RegAddr shl 16 |
324 | mov eax, RegAddr shl 16 |
325 | out dx, eax |
325 | out dx, eax |
326 | 326 | ||
327 | call PHY_WAIT |
327 | call PHY_WAIT |
328 | jz .error |
328 | jz .error |
329 | 329 | ||
330 | in eax, dx |
330 | in eax, dx |
331 | and eax, 0xFFFF |
331 | and eax, 0xFFFF |
332 | jmp .done |
332 | jmp .done |
333 | 333 | ||
334 | .error: |
334 | .error: |
335 | or eax, -1 |
335 | or eax, -1 |
336 | .done: |
336 | .done: |
337 | } |
337 | } |
338 | 338 | ||
339 | align 4 |
339 | align 4 |
340 | PHY_WAIT: ; io addr must already be set to REG_PHYAR |
340 | PHY_WAIT: ; io addr must already be set to REG_PHYAR |
341 | 341 | ||
342 | udelay 1 ;;;1000 |
342 | udelay 1 ;;;1000 |
343 | 343 | ||
344 | push ecx |
344 | push ecx |
345 | mov ecx, 2000 |
345 | mov ecx, 2000 |
346 | ; Check if the RTL8169 has completed writing/reading to the specified MII register |
346 | ; Check if the RTL8169 has completed writing/reading to the specified MII register |
347 | @@: |
347 | @@: |
348 | in eax, dx |
348 | in eax, dx |
349 | test eax, 0x80000000 |
349 | test eax, 0x80000000 |
350 | jz .exit |
350 | jz .exit |
351 | udelay 1 ;;;100 |
351 | udelay 1 ;;;100 |
352 | loop @b |
352 | loop @b |
353 | .exit: |
353 | .exit: |
354 | pop ecx |
354 | pop ecx |
355 | ret |
355 | ret |
356 | 356 | ||
357 | 357 | ||
358 | 358 | ||
359 | section '.flat' code readable align 16 |
359 | section '.flat' code readable align 16 |
360 | 360 | ||
361 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
361 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
362 | ;; ;; |
362 | ;; ;; |
363 | ;; proc START ;; |
363 | ;; proc START ;; |
364 | ;; ;; |
364 | ;; ;; |
365 | ;; (standard driver proc) ;; |
365 | ;; (standard driver proc) ;; |
366 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
366 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
367 | 367 | ||
368 | align 4 |
368 | align 4 |
369 | proc START stdcall, state:dword |
369 | proc START stdcall, state:dword |
370 | 370 | ||
371 | cmp [state], 1 |
371 | cmp [state], 1 |
372 | jne .exit |
372 | jne .exit |
373 | 373 | ||
374 | .entry: |
374 | .entry: |
375 | 375 | ||
376 | DEBUGF 2,"Loading rtl8169 driver\n" |
376 | DEBUGF 2,"Loading rtl8169 driver\n" |
377 | stdcall RegService, my_service, service_proc |
377 | stdcall RegService, my_service, service_proc |
378 | ret |
378 | ret |
379 | 379 | ||
380 | .fail: |
380 | .fail: |
381 | .exit: |
381 | .exit: |
382 | xor eax, eax |
382 | xor eax, eax |
383 | ret |
383 | ret |
384 | 384 | ||
385 | endp |
385 | endp |
386 | 386 | ||
387 | 387 | ||
388 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
388 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
389 | ;; ;; |
389 | ;; ;; |
390 | ;; proc SERVICE_PROC ;; |
390 | ;; proc SERVICE_PROC ;; |
391 | ;; ;; |
391 | ;; ;; |
392 | ;; (standard driver proc) ;; |
392 | ;; (standard driver proc) ;; |
393 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
393 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
394 | 394 | ||
395 | align 4 |
395 | align 4 |
396 | proc service_proc stdcall, ioctl:dword |
396 | proc service_proc stdcall, ioctl:dword |
397 | 397 | ||
398 | mov edx, [ioctl] |
398 | mov edx, [ioctl] |
399 | mov eax, [IOCTL.io_code] |
399 | mov eax, [IOCTL.io_code] |
400 | 400 | ||
401 | ;------------------------------------------------------ |
401 | ;------------------------------------------------------ |
402 | 402 | ||
403 | cmp eax, 0 ;SRV_GETVERSION |
403 | cmp eax, 0 ;SRV_GETVERSION |
404 | jne @F |
404 | jne @F |
405 | 405 | ||
406 | cmp [IOCTL.out_size], 4 |
406 | cmp [IOCTL.out_size], 4 |
407 | jl .fail |
407 | jl .fail |
408 | mov eax, [IOCTL.output] |
408 | mov eax, [IOCTL.output] |
409 | mov [eax], dword API_VERSION |
409 | mov [eax], dword API_VERSION |
410 | 410 | ||
411 | xor eax, eax |
411 | xor eax, eax |
412 | ret |
412 | ret |
413 | 413 | ||
414 | ;------------------------------------------------------ |
414 | ;------------------------------------------------------ |
415 | @@: |
415 | @@: |
416 | cmp eax, 1 ;SRV_HOOK |
416 | cmp eax, 1 ;SRV_HOOK |
417 | jne .fail |
417 | jne .fail |
418 | 418 | ||
419 | cmp [IOCTL.inp_size], 3 ; Data input must be at least 3 bytes |
419 | cmp [IOCTL.inp_size], 3 ; Data input must be at least 3 bytes |
420 | jl .fail |
420 | jl .fail |
421 | 421 | ||
422 | mov eax, [IOCTL.input] |
422 | mov eax, [IOCTL.input] |
423 | cmp byte [eax], 1 ; 1 means device number and bus number (pci) are given |
423 | cmp byte [eax], 1 ; 1 means device number and bus number (pci) are given |
424 | jne .fail ; other types arent supported for this card yet |
424 | jne .fail ; other types arent supported for this card yet |
425 | 425 | ||
426 | ; check if the device is already listed |
426 | ; check if the device is already listed |
427 | 427 | ||
428 | mov esi, device_list |
428 | mov esi, device_list |
429 | mov ecx, [devices] |
429 | mov ecx, [devices] |
430 | test ecx, ecx |
430 | test ecx, ecx |
431 | jz .firstdevice |
431 | jz .firstdevice |
432 | 432 | ||
433 | ; mov eax, [IOCTL.input] ; get the pci bus and device numbers |
433 | ; mov eax, [IOCTL.input] ; get the pci bus and device numbers |
434 | mov ax , [eax+1] ; |
434 | mov ax , [eax+1] ; |
435 | .nextdevice: |
435 | .nextdevice: |
436 | mov ebx, [esi] |
436 | mov ebx, [esi] |
437 | cmp ax , word [device.pci_bus] ; compare with pci and device num in device list (notice the usage of word instead of byte) |
437 | cmp ax , word [device.pci_bus] ; compare with pci and device num in device list (notice the usage of word instead of byte) |
438 | je .find_devicenum ; Device is already loaded, let's find it's device number |
438 | je .find_devicenum ; Device is already loaded, let's find it's device number |
439 | add esi, 4 |
439 | add esi, 4 |
440 | loop .nextdevice |
440 | loop .nextdevice |
441 | 441 | ||
442 | 442 | ||
443 | ; This device doesnt have its own eth_device structure yet, lets create one |
443 | ; This device doesnt have its own eth_device structure yet, lets create one |
444 | .firstdevice: |
444 | .firstdevice: |
445 | cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card |
445 | cmp [devices], MAX_DEVICES ; First check if the driver can handle one more card |
446 | jge .fail |
446 | jge .fail |
447 | 447 | ||
448 | allocate_and_clear ebx, device_size, .fail ; Allocate memory to put the device structure in |
448 | allocate_and_clear ebx, device_size, .fail ; Allocate memory to put the device structure in |
449 | 449 | ||
450 | ; Fill in the direct call addresses into the struct |
450 | ; Fill in the direct call addresses into the struct |
451 | 451 | ||
452 | mov [device.reset], reset |
452 | mov [device.reset], reset |
453 | mov [device.transmit], transmit |
453 | mov [device.transmit], transmit |
454 | mov [device.get_MAC], read_mac |
454 | mov [device.get_MAC], read_mac |
455 | mov [device.set_MAC], write_mac |
455 | mov [device.set_MAC], write_mac |
456 | mov [device.unload], unload |
456 | mov [device.unload], unload |
457 | mov [device.name], my_service |
457 | mov [device.name], my_service |
458 | 458 | ||
459 | ; save the pci bus and device numbers |
459 | ; save the pci bus and device numbers |
460 | 460 | ||
461 | mov eax, [IOCTL.input] |
461 | mov eax, [IOCTL.input] |
462 | mov cl , [eax+1] |
462 | mov cl , [eax+1] |
463 | mov [device.pci_bus], cl |
463 | mov [device.pci_bus], cl |
464 | mov cl , [eax+2] |
464 | mov cl , [eax+2] |
465 | mov [device.pci_dev], cl |
465 | mov [device.pci_dev], cl |
466 | 466 | ||
467 | ; Now, it's time to find the base io addres of the PCI device |
467 | ; Now, it's time to find the base io addres of the PCI device |
468 | 468 | ||
469 | find_io [device.pci_bus], [device.pci_dev], [device.io_addr] |
469 | find_io [device.pci_bus], [device.pci_dev], [device.io_addr] |
470 | mov eax, [device.io_addr] |
470 | mov eax, [device.io_addr] |
471 | mov [tpc.mmio_addr], eax |
471 | mov [tpc.mmio_addr], eax |
472 | 472 | ||
473 | ; We've found the io address, find IRQ now |
473 | ; We've found the io address, find IRQ now |
474 | 474 | ||
475 | find_irq [device.pci_bus], [device.pci_dev], [device.irq_line] |
475 | find_irq [device.pci_bus], [device.pci_dev], [device.irq_line] |
476 | 476 | ||
477 | DEBUGF 2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
477 | DEBUGF 2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
478 | [device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:8 |
478 | [device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:8 |
479 | 479 | ||
480 | ; Ok, the eth_device structure is ready, let's probe the device |
480 | ; Ok, the eth_device structure is ready, let's probe the device |
481 | ; Because initialization fires IRQ, IRQ handler must be aware of this device |
481 | ; Because initialization fires IRQ, IRQ handler must be aware of this device |
482 | mov eax, [devices] ; Add the device structure to our device list |
482 | mov eax, [devices] ; Add the device structure to our device list |
483 | mov [device_list+4*eax], ebx ; (IRQ handler uses this list to find device) |
483 | mov [device_list+4*eax], ebx ; (IRQ handler uses this list to find device) |
484 | inc [devices] ; |
484 | inc [devices] ; |
485 | 485 | ||
486 | call probe ; this function will output in eax |
486 | call probe ; this function will output in eax |
487 | test eax, eax |
487 | test eax, eax |
488 | jnz .err2 ; If an error occured, exit |
488 | jnz .err2 ; If an error occured, exit |
489 | 489 | ||
490 | 490 | ||
491 | mov [device.type], NET_TYPE_ETH |
491 | mov [device.type], NET_TYPE_ETH |
492 | call NetRegDev |
492 | call NetRegDev |
493 | 493 | ||
494 | cmp eax, -1 |
494 | cmp eax, -1 |
495 | je .destroy |
495 | je .destroy |
496 | 496 | ||
497 | ret |
497 | ret |
498 | 498 | ||
499 | ; If the device was already loaded, find the device number and return it in eax |
499 | ; If the device was already loaded, find the device number and return it in eax |
500 | 500 | ||
501 | .find_devicenum: |
501 | .find_devicenum: |
502 | DEBUGF 2,"Trying to find device number of already registered device\n" |
502 | DEBUGF 2,"Trying to find device number of already registered device\n" |
503 | mov ebx, eax |
503 | mov ebx, eax |
504 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
504 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
505 | ; into a device number in edi |
505 | ; into a device number in edi |
506 | mov eax, edi ; Application wants it in eax instead |
506 | mov eax, edi ; Application wants it in eax instead |
507 | DEBUGF 2,"Kernel says: %u\n", eax |
507 | DEBUGF 2,"Kernel says: %u\n", eax |
508 | ret |
508 | ret |
509 | 509 | ||
510 | ; If an error occured, remove all allocated data and exit (returning -1 in eax) |
510 | ; If an error occured, remove all allocated data and exit (returning -1 in eax) |
511 | 511 | ||
512 | .destroy: |
512 | .destroy: |
513 | ; todo: reset device into virgin state |
513 | ; todo: reset device into virgin state |
514 | 514 | ||
515 | .err2: |
515 | .err2: |
516 | dec [devices] |
516 | dec [devices] |
517 | .err: |
517 | .err: |
518 | DEBUGF 2,"removing device structure\n" |
518 | DEBUGF 2,"removing device structure\n" |
519 | stdcall KernelFree, ebx |
519 | stdcall KernelFree, ebx |
520 | 520 | ||
521 | 521 | ||
522 | .fail: |
522 | .fail: |
523 | or eax, -1 |
523 | or eax, -1 |
524 | ret |
524 | ret |
525 | 525 | ||
526 | ;------------------------------------------------------ |
526 | ;------------------------------------------------------ |
527 | endp |
527 | endp |
528 | 528 | ||
529 | 529 | ||
530 | align 4 |
530 | align 4 |
531 | unload: |
531 | unload: |
532 | 532 | ||
533 | ret |
533 | ret |
534 | 534 | ||
535 | 535 | ||
536 | align 4 |
536 | align 4 |
537 | init_board: |
537 | init_board: |
538 | 538 | ||
539 | DEBUGF 1,"init_board\n" |
539 | DEBUGF 1,"init_board\n" |
540 | 540 | ||
541 | make_bus_master [device.pci_bus], [device.pci_dev] |
541 | make_bus_master [device.pci_bus], [device.pci_dev] |
542 | 542 | ||
543 | ; Soft reset the chip |
543 | ; Soft reset the chip |
544 | set_io 0 |
544 | set_io 0 |
545 | set_io REG_ChipCmd |
545 | set_io REG_ChipCmd |
546 | mov al, CMD_Reset |
546 | mov al, CMD_Reset |
547 | out dx, al |
547 | out dx, al |
548 | 548 | ||
549 | ; Check that the chip has finished the reset |
549 | ; Check that the chip has finished the reset |
550 | mov ecx, 1000 |
550 | mov ecx, 1000 |
551 | set_io REG_ChipCmd |
551 | set_io REG_ChipCmd |
552 | @@: in al, dx |
552 | @@: in al, dx |
553 | test al, CMD_Reset |
553 | test al, CMD_Reset |
554 | jz @f |
554 | jz @f |
555 | udelay 10 |
555 | udelay 10 |
556 | loop @b |
556 | loop @b |
557 | @@: |
557 | @@: |
558 | ; identify config method |
558 | ; identify config method |
559 | set_io REG_TxConfig |
559 | set_io REG_TxConfig |
560 | in eax, dx |
560 | in eax, dx |
561 | and eax, 0x7c800000 |
561 | and eax, 0x7c800000 |
562 | DEBUGF 1,"init_board: TxConfig & 0x7c800000 = 0x%x\n", eax |
562 | DEBUGF 1,"init_board: TxConfig & 0x7c800000 = 0x%x\n", eax |
563 | mov esi, mac_info-8 |
563 | mov esi, mac_info-8 |
564 | @@: add esi, 8 |
564 | @@: add esi, 8 |
565 | mov ecx, eax |
565 | mov ecx, eax |
566 | and ecx, [esi] |
566 | and ecx, [esi] |
567 | cmp ecx, [esi] |
567 | cmp ecx, [esi] |
568 | jne @b |
568 | jne @b |
569 | mov eax, [esi+4] |
569 | mov eax, [esi+4] |
570 | mov [tpc.mcfg], eax |
570 | mov [tpc.mcfg], eax |
571 | 571 | ||
572 | mov [tpc.pcfg], PCFG_METHOD_3 |
572 | mov [tpc.pcfg], PCFG_METHOD_3 |
573 | READ_GMII_REG 3 |
573 | READ_GMII_REG 3 |
574 | and al, 0x0f |
574 | and al, 0x0f |
575 | or al, al |
575 | or al, al |
576 | jnz @f |
576 | jnz @f |
577 | mov [tpc.pcfg], PCFG_METHOD_1 |
577 | mov [tpc.pcfg], PCFG_METHOD_1 |
578 | jmp .pconf |
578 | jmp .pconf |
579 | @@: dec al |
579 | @@: dec al |
580 | jnz .pconf |
580 | jnz .pconf |
581 | mov [tpc.pcfg], PCFG_METHOD_2 |
581 | mov [tpc.pcfg], PCFG_METHOD_2 |
582 | .pconf: |
582 | .pconf: |
583 | 583 | ||
584 | ; identify chip attached to board |
584 | ; identify chip attached to board |
585 | mov ecx, 10 |
585 | mov ecx, 10 |
586 | mov eax, [tpc.mcfg] |
586 | mov eax, [tpc.mcfg] |
587 | @@: dec ecx |
587 | @@: dec ecx |
588 | js @f |
588 | js @f |
589 | cmp eax, [rtl_chip_info+ecx*8] |
589 | cmp eax, [rtl_chip_info+ecx*8] |
590 | jne @b |
590 | jne @b |
591 | mov [tpc.chipset], ecx |
591 | mov [tpc.chipset], ecx |
592 | jmp .match |
592 | jmp .match |
593 | @@: |
593 | @@: |
594 | ; if unknown chip, assume array element #0, original RTL-8169 in this case |
594 | ; if unknown chip, assume array element #0, original RTL-8169 in this case |
595 | DEBUGF 1,"init_board: PCI device: unknown chip version, assuming RTL-8169\n" |
595 | DEBUGF 1,"init_board: PCI device: unknown chip version, assuming RTL-8169\n" |
596 | set_io REG_TxConfig |
596 | set_io REG_TxConfig |
597 | in eax, dx |
597 | in eax, dx |
598 | DEBUGF 1,"init_board: PCI device: TxConfig = 0x%x\n", eax |
598 | DEBUGF 1,"init_board: PCI device: TxConfig = 0x%x\n", eax |
599 | 599 | ||
600 | mov [tpc.chipset], 0 |
600 | mov [tpc.chipset], 0 |
601 | 601 | ||
602 | xor eax, eax |
602 | xor eax, eax |
603 | inc eax |
603 | inc eax |
604 | ret |
604 | ret |
605 | 605 | ||
606 | .match: |
606 | .match: |
607 | xor eax,eax |
607 | xor eax,eax |
608 | ret |
608 | ret |
609 | 609 | ||
610 | 610 | ||
611 | 611 | ||
612 | ;*************************************************************************** |
612 | ;*************************************************************************** |
613 | ; Function |
613 | ; Function |
614 | ; probe |
614 | ; probe |
615 | ; Description |
615 | ; Description |
616 | ; Searches for an ethernet card, enables it and clears the rx buffer |
616 | ; Searches for an ethernet card, enables it and clears the rx buffer |
617 | ; If a card was found, it enables the ethernet -> TCPIP link |
617 | ; If a card was found, it enables the ethernet -> TCPIP link |
618 | ; Destroyed registers |
618 | ; Destroyed registers |
619 | ; eax, ebx, ecx, edx |
619 | ; eax, ebx, ecx, edx |
620 | ; |
620 | ; |
621 | ;*************************************************************************** |
621 | ;*************************************************************************** |
622 | align 4 |
622 | align 4 |
623 | probe: |
623 | probe: |
624 | 624 | ||
625 | DEBUGF 1,"probe\n" |
625 | DEBUGF 1,"probe\n" |
626 | 626 | ||
627 | call init_board |
627 | call init_board |
628 | 628 | ||
629 | call read_mac |
629 | call read_mac |
630 | 630 | ||
631 | call PHY_config |
631 | call PHY_config |
632 | 632 | ||
633 | ; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n" |
633 | ; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n" |
634 | set_io 0 |
634 | set_io 0 |
635 | set_io 0x82 |
635 | set_io 0x82 |
636 | mov al, 0x01 |
636 | mov al, 0x01 |
637 | out dx, al |
637 | out dx, al |
638 | cmp [tpc.mcfg], MCFG_METHOD_03 |
638 | cmp [tpc.mcfg], MCFG_METHOD_03 |
639 | jae @f |
639 | jae @f |
640 | ; DEBUGF 1,"K : Set PCI Latency=0x40\n" |
640 | ; DEBUGF 1,"K : Set PCI Latency=0x40\n" |
641 | ; stdcall pci_write_config_byte,PCI_LATENCY_TIMER,0x40 |
641 | ; stdcall pci_write_config_byte,PCI_LATENCY_TIMER,0x40 |
642 | @@: |
642 | @@: |
643 | cmp [tpc.mcfg], MCFG_METHOD_02 |
643 | cmp [tpc.mcfg], MCFG_METHOD_02 |
644 | jne @f |
644 | jne @f |
645 | ; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n" |
645 | ; DEBUGF 1,"K : Set MAC Reg C+CR Offset 0x82h = 0x01h\n" |
646 | set_io 0x82 |
646 | set_io 0x82 |
647 | mov al, 0x01 |
647 | mov al, 0x01 |
648 | out dx, al |
648 | out dx, al |
649 | ; DEBUGF 1,"K : Set PHY Reg 0x0bh = 0x00h\n" |
649 | ; DEBUGF 1,"K : Set PHY Reg 0x0bh = 0x00h\n" |
650 | WRITE_GMII_REG 0x0b, 0x0000 ; w 0x0b 15 0 0 |
650 | WRITE_GMII_REG 0x0b, 0x0000 ; w 0x0b 15 0 0 |
651 | @@: |
651 | @@: |
652 | ; if TBI is not enabled |
652 | ; if TBI is not enabled |
653 | set_io 0 |
653 | set_io 0 |
654 | set_io REG_PHYstatus |
654 | set_io REG_PHYstatus |
655 | in al, dx |
655 | in al, dx |
656 | test al, PHYS_TBI_Enable |
656 | test al, PHYS_TBI_Enable |
657 | jz .tbi_dis |
657 | jz .tbi_dis |
658 | READ_GMII_REG PHY_AUTO_NEGO_REG |
658 | READ_GMII_REG PHY_AUTO_NEGO_REG |
659 | 659 | ||
660 | ; enable 10/100 Full/Half Mode, leave PHY_AUTO_NEGO_REG bit4:0 unchanged |
660 | ; enable 10/100 Full/Half Mode, leave PHY_AUTO_NEGO_REG bit4:0 unchanged |
661 | and eax, 0x0C1F |
661 | and eax, 0x0C1F |
662 | or eax, PHY_Cap_10_Half or PHY_Cap_10_Full or PHY_Cap_100_Half or PHY_Cap_100_Full |
662 | or eax, PHY_Cap_10_Half or PHY_Cap_10_Full or PHY_Cap_100_Half or PHY_Cap_100_Full |
663 | WRITE_GMII_REG PHY_AUTO_NEGO_REG, ax |
663 | WRITE_GMII_REG PHY_AUTO_NEGO_REG, ax |
664 | 664 | ||
665 | ; enable 1000 Full Mode |
665 | ; enable 1000 Full Mode |
666 | WRITE_GMII_REG PHY_1000_CTRL_REG, PHY_Cap_1000_Full or PHY_Cap_1000_Half ; rtl8168 |
666 | WRITE_GMII_REG PHY_1000_CTRL_REG, PHY_Cap_1000_Full or PHY_Cap_1000_Half ; rtl8168 |
667 | 667 | ||
668 | ; Enable auto-negotiation and restart auto-nigotiation |
668 | ; Enable auto-negotiation and restart auto-nigotiation |
669 | WRITE_GMII_REG PHY_CTRL_REG, PHY_Enable_Auto_Nego or PHY_Restart_Auto_Nego |
669 | WRITE_GMII_REG PHY_CTRL_REG, PHY_Enable_Auto_Nego or PHY_Restart_Auto_Nego |
670 | 670 | ||
671 | udelay 100 |
671 | udelay 100 |
672 | mov ecx, 10000 |
672 | mov ecx, 10000 |
673 | ; wait for auto-negotiation process |
673 | ; wait for auto-negotiation process |
674 | @@: dec ecx |
674 | @@: dec ecx |
675 | jz @f |
675 | jz @f |
676 | set_io 0 |
676 | set_io 0 |
677 | READ_GMII_REG PHY_STAT_REG |
677 | READ_GMII_REG PHY_STAT_REG |
678 | udelay 100 |
678 | udelay 100 |
679 | test eax, PHY_Auto_Neco_Comp |
679 | test eax, PHY_Auto_Neco_Comp |
680 | jz @b |
680 | jz @b |
681 | set_io REG_PHYstatus |
681 | set_io REG_PHYstatus |
682 | in al, dx |
682 | in al, dx |
683 | jmp @f |
683 | jmp @f |
684 | .tbi_dis: |
684 | .tbi_dis: |
685 | udelay 100 |
685 | udelay 100 |
686 | @@: |
686 | @@: |
687 | 687 | ||
688 | 688 | ||
689 | ;*************************************************************************** |
689 | ;*************************************************************************** |
690 | ; Function |
690 | ; Function |
691 | ; rt8169_reset |
691 | ; rt8169_reset |
692 | ; Description |
692 | ; Description |
693 | ; Place the chip (ie, the ethernet card) into a virgin state |
693 | ; Place the chip (ie, the ethernet card) into a virgin state |
694 | ; Destroyed registers |
694 | ; Destroyed registers |
695 | ; eax, ebx, ecx, edx |
695 | ; eax, ebx, ecx, edx |
696 | ; |
696 | ; |
697 | ;*************************************************************************** |
697 | ;*************************************************************************** |
698 | align 4 |
698 | align 4 |
699 | reset: |
699 | reset: |
700 | 700 | ||
701 | DEBUGF 1,"reset\n" |
701 | DEBUGF 1,"reset\n" |
702 | 702 | ||
703 | lea eax, [tx_ring] |
703 | lea eax, [tx_ring] |
704 | mov [tpc.TxDescArrays], eax |
704 | mov [tpc.TxDescArrays], eax |
705 | mov [tpc.TxDescArray], eax |
705 | mov [tpc.TxDescArray], eax |
706 | 706 | ||
707 | lea eax, [rx_ring] |
707 | lea eax, [rx_ring] |
708 | mov [tpc.RxDescArrays], eax |
708 | mov [tpc.RxDescArrays], eax |
709 | mov [tpc.RxDescArray], eax |
709 | mov [tpc.RxDescArray], eax |
710 | 710 | ||
711 | call init_ring |
711 | call init_ring |
712 | call hw_start |
712 | call hw_start |
713 | 713 | ||
714 | ; clear packet/byte counters |
714 | ; clear packet/byte counters |
715 | 715 | ||
716 | xor eax, eax |
716 | xor eax, eax |
717 | lea edi, [device.bytes_tx] |
717 | lea edi, [device.bytes_tx] |
718 | mov ecx, 6 |
718 | mov ecx, 6 |
719 | rep stosd |
719 | rep stosd |
720 | 720 | ||
721 | mov [device.mtu], 1500 |
721 | mov [device.mtu], 1500 |
722 | 722 | ||
723 | xor eax, eax |
723 | xor eax, eax |
724 | ret |
724 | ret |
725 | 725 | ||
726 | 726 | ||
727 | 727 | ||
728 | 728 | ||
729 | 729 | ||
730 | align 4 |
730 | align 4 |
731 | PHY_config: |
731 | PHY_config: |
732 | 732 | ||
733 | DEBUGF 1,"hw_PHY_config: priv.mcfg=%d, priv.pcfg=%d\n",[tpc.mcfg],[tpc.pcfg] |
733 | DEBUGF 1,"hw_PHY_config: priv.mcfg=%d, priv.pcfg=%d\n",[tpc.mcfg],[tpc.pcfg] |
734 | 734 | ||
735 | cmp [tpc.mcfg], MCFG_METHOD_04 |
735 | cmp [tpc.mcfg], MCFG_METHOD_04 |
736 | jne .not_4 |
736 | jne .not_4 |
737 | set_io 0 |
737 | set_io 0 |
738 | ; WRITE_GMII_REG 0x1F, 0x0001 |
738 | ; WRITE_GMII_REG 0x1F, 0x0001 |
739 | ; WRITE_GMII_REG 0x1b, 0x841e |
739 | ; WRITE_GMII_REG 0x1b, 0x841e |
740 | ; WRITE_GMII_REG 0x0e, 0x7bfb |
740 | ; WRITE_GMII_REG 0x0e, 0x7bfb |
741 | ; WRITE_GMII_REG 0x09, 0x273a |
741 | ; WRITE_GMII_REG 0x09, 0x273a |
742 | WRITE_GMII_REG 0x1F, 0x0002 |
742 | WRITE_GMII_REG 0x1F, 0x0002 |
743 | WRITE_GMII_REG 0x01, 0x90D0 |
743 | WRITE_GMII_REG 0x01, 0x90D0 |
744 | WRITE_GMII_REG 0x1F, 0x0000 |
744 | WRITE_GMII_REG 0x1F, 0x0000 |
745 | jmp .exit |
745 | jmp .exit |
746 | .not_4: |
746 | .not_4: |
747 | cmp [tpc.mcfg], MCFG_METHOD_02 |
747 | cmp [tpc.mcfg], MCFG_METHOD_02 |
748 | je @f |
748 | je @f |
749 | cmp [tpc.mcfg], MCFG_METHOD_03 |
749 | cmp [tpc.mcfg], MCFG_METHOD_03 |
750 | jne .not_2_or_3 |
750 | jne .not_2_or_3 |
751 | @@: |
751 | @@: |
752 | set_io 0 |
752 | set_io 0 |
753 | WRITE_GMII_REG 0x1F, 0x0001 |
753 | WRITE_GMII_REG 0x1F, 0x0001 |
754 | WRITE_GMII_REG 0x15, 0x1000 |
754 | WRITE_GMII_REG 0x15, 0x1000 |
755 | WRITE_GMII_REG 0x18, 0x65C7 |
755 | WRITE_GMII_REG 0x18, 0x65C7 |
756 | WRITE_GMII_REG 0x04, 0x0000 |
756 | WRITE_GMII_REG 0x04, 0x0000 |
757 | WRITE_GMII_REG 0x03, 0x00A1 |
757 | WRITE_GMII_REG 0x03, 0x00A1 |
758 | WRITE_GMII_REG 0x02, 0x0008 |
758 | WRITE_GMII_REG 0x02, 0x0008 |
759 | WRITE_GMII_REG 0x01, 0x1020 |
759 | WRITE_GMII_REG 0x01, 0x1020 |
760 | WRITE_GMII_REG 0x00, 0x1000 |
760 | WRITE_GMII_REG 0x00, 0x1000 |
761 | WRITE_GMII_REG 0x04, 0x0800 |
761 | WRITE_GMII_REG 0x04, 0x0800 |
762 | WRITE_GMII_REG 0x04, 0x0000 |
762 | WRITE_GMII_REG 0x04, 0x0000 |
763 | WRITE_GMII_REG 0x04, 0x7000 |
763 | WRITE_GMII_REG 0x04, 0x7000 |
764 | WRITE_GMII_REG 0x03, 0xFF41 |
764 | WRITE_GMII_REG 0x03, 0xFF41 |
765 | WRITE_GMII_REG 0x02, 0xDE60 |
765 | WRITE_GMII_REG 0x02, 0xDE60 |
766 | WRITE_GMII_REG 0x01, 0x0140 |
766 | WRITE_GMII_REG 0x01, 0x0140 |
767 | WRITE_GMII_REG 0x00, 0x0077 |
767 | WRITE_GMII_REG 0x00, 0x0077 |
768 | WRITE_GMII_REG 0x04, 0x7800 |
768 | WRITE_GMII_REG 0x04, 0x7800 |
769 | WRITE_GMII_REG 0x04, 0x7000 |
769 | WRITE_GMII_REG 0x04, 0x7000 |
770 | WRITE_GMII_REG 0x04, 0xA000 |
770 | WRITE_GMII_REG 0x04, 0xA000 |
771 | WRITE_GMII_REG 0x03, 0xDF01 |
771 | WRITE_GMII_REG 0x03, 0xDF01 |
772 | WRITE_GMII_REG 0x02, 0xDF20 |
772 | WRITE_GMII_REG 0x02, 0xDF20 |
773 | WRITE_GMII_REG 0x01, 0xFF95 |
773 | WRITE_GMII_REG 0x01, 0xFF95 |
774 | WRITE_GMII_REG 0x00, 0xFA00 |
774 | WRITE_GMII_REG 0x00, 0xFA00 |
775 | WRITE_GMII_REG 0x04, 0xA800 |
775 | WRITE_GMII_REG 0x04, 0xA800 |
776 | WRITE_GMII_REG 0x04, 0xA000 |
776 | WRITE_GMII_REG 0x04, 0xA000 |
777 | WRITE_GMII_REG 0x04, 0xB000 |
777 | WRITE_GMII_REG 0x04, 0xB000 |
778 | WRITE_GMII_REG 0x03, 0xFF41 |
778 | WRITE_GMII_REG 0x03, 0xFF41 |
779 | WRITE_GMII_REG 0x02, 0xDE20 |
779 | WRITE_GMII_REG 0x02, 0xDE20 |
780 | WRITE_GMII_REG 0x01, 0x0140 |
780 | WRITE_GMII_REG 0x01, 0x0140 |
781 | WRITE_GMII_REG 0x00, 0x00BB |
781 | WRITE_GMII_REG 0x00, 0x00BB |
782 | WRITE_GMII_REG 0x04, 0xB800 |
782 | WRITE_GMII_REG 0x04, 0xB800 |
783 | WRITE_GMII_REG 0x04, 0xB000 |
783 | WRITE_GMII_REG 0x04, 0xB000 |
784 | WRITE_GMII_REG 0x04, 0xF000 |
784 | WRITE_GMII_REG 0x04, 0xF000 |
785 | WRITE_GMII_REG 0x03, 0xDF01 |
785 | WRITE_GMII_REG 0x03, 0xDF01 |
786 | WRITE_GMII_REG 0x02, 0xDF20 |
786 | WRITE_GMII_REG 0x02, 0xDF20 |
787 | WRITE_GMII_REG 0x01, 0xFF95 |
787 | WRITE_GMII_REG 0x01, 0xFF95 |
788 | WRITE_GMII_REG 0x00, 0xBF00 |
788 | WRITE_GMII_REG 0x00, 0xBF00 |
789 | WRITE_GMII_REG 0x04, 0xF800 |
789 | WRITE_GMII_REG 0x04, 0xF800 |
790 | WRITE_GMII_REG 0x04, 0xF000 |
790 | WRITE_GMII_REG 0x04, 0xF000 |
791 | WRITE_GMII_REG 0x04, 0x0000 |
791 | WRITE_GMII_REG 0x04, 0x0000 |
792 | WRITE_GMII_REG 0x1F, 0x0000 |
792 | WRITE_GMII_REG 0x1F, 0x0000 |
793 | WRITE_GMII_REG 0x0B, 0x0000 |
793 | WRITE_GMII_REG 0x0B, 0x0000 |
794 | jmp .exit |
794 | jmp .exit |
795 | .not_2_or_3: |
795 | .not_2_or_3: |
796 | DEBUGF 1,"tpc.mcfg=%d, discard hw PHY config\n", [tpc.mcfg] |
796 | DEBUGF 1,"tpc.mcfg=%d, discard hw PHY config\n", [tpc.mcfg] |
797 | .exit: |
797 | .exit: |
798 | ret |
798 | ret |
799 | 799 | ||
800 | 800 | ||
801 | 801 | ||
802 | align 4 |
802 | align 4 |
803 | set_rx_mode: |
803 | set_rx_mode: |
804 | 804 | ||
805 | DEBUGF 1,"set_rx_mode\n" |
805 | DEBUGF 1,"set_rx_mode\n" |
806 | 806 | ||
807 | ; IFF_ALLMULTI |
807 | ; IFF_ALLMULTI |
808 | ; Too many to filter perfectly -- accept all multicasts |
808 | ; Too many to filter perfectly -- accept all multicasts |
809 | set_io 0 |
809 | set_io 0 |
810 | set_io REG_RxConfig |
810 | set_io REG_RxConfig |
811 | in eax, dx |
811 | in eax, dx |
812 | mov ecx, [tpc.chipset] |
812 | mov ecx, [tpc.chipset] |
813 | and eax, [rtl_chip_info + ecx * 8 + 4] ; RxConfigMask |
813 | and eax, [rtl_chip_info + ecx * 8 + 4] ; RxConfigMask |
814 | or eax, rx_config or (RXM_AcceptBroadcast or RXM_AcceptMulticast or RXM_AcceptMyPhys) |
814 | or eax, rx_config or (RXM_AcceptBroadcast or RXM_AcceptMulticast or RXM_AcceptMyPhys) |
815 | out dx, eax |
815 | out dx, eax |
816 | 816 | ||
817 | ; Multicast hash filter |
817 | ; Multicast hash filter |
818 | set_io REG_MAR0 + 0 |
818 | set_io REG_MAR0 + 0 |
819 | or eax, -1 |
819 | or eax, -1 |
820 | out dx, eax |
820 | out dx, eax |
821 | set_io REG_MAR0 + 4 |
821 | set_io REG_MAR0 + 4 |
822 | out dx, eax |
822 | out dx, eax |
823 | 823 | ||
824 | ret |
824 | ret |
825 | 825 | ||
826 | 826 | ||
827 | align 4 |
827 | align 4 |
828 | init_ring: |
828 | init_ring: |
829 | 829 | ||
830 | DEBUGF 1,"init_ring\n" |
830 | DEBUGF 1,"init_ring\n" |
831 | 831 | ||
832 | xor eax, eax |
832 | xor eax, eax |
833 | mov [tpc.cur_rx], eax |
833 | mov [tpc.cur_rx], eax |
834 | mov [tpc.cur_tx], eax |
834 | mov [tpc.cur_tx], eax |
835 | 835 | ||
836 | lea edi, [tx_ring] |
836 | lea edi, [tx_ring] |
837 | mov ecx, (NUM_TX_DESC * tx_desc.size) / 4 |
837 | mov ecx, (NUM_TX_DESC * tx_desc.size) / 4 |
838 | rep stosd |
838 | rep stosd |
839 | 839 | ||
840 | lea edi, [rx_ring] |
840 | lea edi, [rx_ring] |
841 | mov ecx, (NUM_RX_DESC * rx_desc.size) / 4 |
841 | mov ecx, (NUM_RX_DESC * rx_desc.size) / 4 |
842 | rep stosd |
842 | rep stosd |
843 | 843 | ||
844 | mov edi, [tpc.RxDescArray] |
844 | mov edi, [tpc.RxDescArray] |
845 | mov ecx, NUM_RX_DESC |
845 | mov ecx, NUM_RX_DESC |
846 | .loop: |
846 | .loop: |
847 | push ecx |
847 | push ecx |
848 | stdcall KernelAlloc, RX_BUF_SIZE |
848 | stdcall KernelAlloc, RX_BUF_SIZE |
849 | mov [edi + rx_desc.buf_soft_addr], eax |
849 | mov [edi + rx_desc.buf_soft_addr], eax |
850 | call GetPgAddr |
850 | call GetPgAddr |
851 | mov dword [edi + rx_desc.buf_addr], eax |
851 | mov dword [edi + rx_desc.buf_addr], eax |
852 | mov [edi + rx_desc.status], DSB_OWNbit or RX_BUF_SIZE |
852 | mov [edi + rx_desc.status], DSB_OWNbit or RX_BUF_SIZE |
853 | add edi, rx_desc.size |
853 | add edi, rx_desc.size |
854 | pop ecx |
854 | pop ecx |
855 | loop .loop |
855 | loop .loop |
856 | or [edi - rx_desc.size + rx_desc.status], DSB_EORbit |
856 | or [edi - rx_desc.size + rx_desc.status], DSB_EORbit |
857 | 857 | ||
858 | ret |
858 | ret |
859 | 859 | ||
860 | 860 | ||
861 | align 4 |
861 | align 4 |
862 | hw_start: |
862 | hw_start: |
863 | 863 | ||
864 | DEBUGF 1,"hw_start\n" |
864 | DEBUGF 1,"hw_start\n" |
865 | 865 | ||
866 | ; attach int handler |
866 | ; attach int handler |
867 | movzx eax, [device.irq_line] |
867 | movzx eax, [device.irq_line] |
868 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
868 | DEBUGF 1,"Attaching int handler to irq %x\n", eax:1 |
869 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
869 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
870 | 870 | ||
871 | ; Soft reset the chip |
871 | ; Soft reset the chip |
872 | set_io 0 |
872 | set_io 0 |
873 | set_io REG_ChipCmd |
873 | set_io REG_ChipCmd |
874 | mov al, CMD_Reset |
874 | mov al, CMD_Reset |
875 | out dx, al |
875 | out dx, al |
876 | 876 | ||
877 | ; Check that the chip has finished the reset |
877 | ; Check that the chip has finished the reset |
878 | mov ecx, 1000 |
878 | mov ecx, 1000 |
879 | set_io REG_ChipCmd |
879 | set_io REG_ChipCmd |
880 | @@: in al, dx |
880 | @@: in al, dx |
881 | test al, CMD_Reset |
881 | test al, CMD_Reset |
882 | jz @f |
882 | jz @f |
883 | udelay 10 |
883 | udelay 10 |
884 | loop @b |
884 | loop @b |
885 | @@: |
885 | @@: |
886 | 886 | ||
887 | set_io REG_Cfg9346 |
887 | set_io REG_Cfg9346 |
888 | mov al, CFG_9346_Unlock |
888 | mov al, CFG_9346_Unlock |
889 | out dx, al |
889 | out dx, al |
890 | 890 | ||
891 | set_io REG_ChipCmd |
891 | set_io REG_ChipCmd |
892 | mov al, CMD_TxEnb or CMD_RxEnb |
892 | mov al, CMD_TxEnb or CMD_RxEnb |
893 | out dx, al |
893 | out dx, al |
894 | 894 | ||
895 | set_io REG_ETThReg |
895 | set_io REG_ETThReg |
896 | mov al, ETTh |
896 | mov al, ETTh |
897 | out dx, al |
897 | out dx, al |
898 | 898 | ||
899 | ; For gigabit rtl8169 |
899 | ; For gigabit rtl8169 |
900 | set_io REG_RxMaxSize |
900 | set_io REG_RxMaxSize |
901 | mov ax, RxPacketMaxSize |
901 | mov ax, RxPacketMaxSize |
902 | out dx, ax |
902 | out dx, ax |
903 | 903 | ||
904 | ; Set Rx Config register |
904 | ; Set Rx Config register |
905 | set_io REG_RxConfig |
905 | set_io REG_RxConfig |
906 | in ax, dx |
906 | in ax, dx |
907 | mov ecx, [tpc.chipset] |
907 | mov ecx, [tpc.chipset] |
908 | and eax, [rtl_chip_info + ecx * 8 + 4] ; RxConfigMask |
908 | and eax, [rtl_chip_info + ecx * 8 + 4] ; RxConfigMask |
909 | or eax, rx_config |
909 | or eax, rx_config |
910 | out dx, eax |
910 | out dx, eax |
911 | 911 | ||
912 | ; Set DMA burst size and Interframe Gap Time |
912 | ; Set DMA burst size and Interframe Gap Time |
913 | set_io REG_TxConfig |
913 | set_io REG_TxConfig |
914 | mov eax, (TX_DMA_BURST shl TXC_DMAShift) or (InterFrameGap shl TXC_InterFrameGapShift) |
914 | mov eax, (TX_DMA_BURST shl TXC_DMAShift) or (InterFrameGap shl TXC_InterFrameGapShift) |
915 | out dx, eax |
915 | out dx, eax |
916 | 916 | ||
917 | set_io REG_CPlusCmd |
917 | set_io REG_CPlusCmd |
918 | in ax, dx |
918 | in ax, dx |
919 | out dx, ax |
919 | out dx, ax |
920 | 920 | ||
921 | in ax, dx |
921 | in ax, dx |
922 | or ax, 1 shl 3 |
922 | or ax, 1 shl 3 |
923 | cmp [tpc.mcfg], MCFG_METHOD_02 |
923 | cmp [tpc.mcfg], MCFG_METHOD_02 |
924 | jne @f |
924 | jne @f |
925 | cmp [tpc.mcfg], MCFG_METHOD_03 |
925 | cmp [tpc.mcfg], MCFG_METHOD_03 |
926 | jne @f |
926 | jne @f |
927 | or ax,1 shl 14 |
927 | or ax,1 shl 14 |
928 | DEBUGF 1,"Set MAC Reg C+CR Offset 0xE0: bit-3 and bit-14\n" |
928 | DEBUGF 1,"Set MAC Reg C+CR Offset 0xE0: bit-3 and bit-14\n" |
929 | jmp .set |
929 | jmp .set |
930 | @@: |
930 | @@: |
931 | DEBUGF 1," Set MAC Reg C+CR Offset 0xE0: bit-3\n" |
931 | DEBUGF 1," Set MAC Reg C+CR Offset 0xE0: bit-3\n" |
932 | .set: |
932 | .set: |
933 | set_io REG_CPlusCmd |
933 | set_io REG_CPlusCmd |
934 | out dx, ax |
934 | out dx, ax |
935 | 935 | ||
936 | set_io 0xE2 |
936 | set_io 0xE2 |
937 | ; mov ax, 0x1517 |
937 | ; mov ax, 0x1517 |
938 | ; out dx, ax |
938 | ; out dx, ax |
939 | ; mov ax, 0x152a |
939 | ; mov ax, 0x152a |
940 | ; out dx, ax |
940 | ; out dx, ax |
941 | ; mov ax, 0x282a |
941 | ; mov ax, 0x282a |
942 | ; out dx, ax |
942 | ; out dx, ax |
943 | xor ax, ax |
943 | xor ax, ax |
944 | out dx, ax |
944 | out dx, ax |
945 | 945 | ||
946 | xor eax, eax |
946 | xor eax, eax |
947 | mov [tpc.cur_rx], eax |
947 | mov [tpc.cur_rx], eax |
948 | lea eax, [tx_ring] |
948 | lea eax, [tx_ring] |
949 | GetRealAddr |
949 | GetRealAddr |
950 | set_io REG_TxDescStartAddr |
950 | set_io REG_TxDescStartAddr |
951 | out dx, eax |
951 | out dx, eax |
952 | 952 | ||
953 | lea eax, [rx_ring] |
953 | lea eax, [rx_ring] |
954 | GetRealAddr |
954 | GetRealAddr |
955 | set_io REG_RxDescStartAddr |
955 | set_io REG_RxDescStartAddr |
956 | out dx, eax |
956 | out dx, eax |
957 | 957 | ||
958 | set_io REG_Cfg9346 |
958 | set_io REG_Cfg9346 |
959 | mov al, CFG_9346_Lock |
959 | mov al, CFG_9346_Lock |
960 | out dx, al |
960 | out dx, al |
961 | 961 | ||
962 | udelay 10 |
962 | udelay 10 |
963 | 963 | ||
964 | xor eax, eax |
964 | xor eax, eax |
965 | set_io REG_RxMissed |
965 | set_io REG_RxMissed |
966 | out dx, eax |
966 | out dx, eax |
967 | 967 | ||
968 | call set_rx_mode |
968 | call set_rx_mode |
969 | 969 | ||
970 | set_io 0 |
970 | set_io 0 |
971 | ; no early-rx interrupts |
971 | ; no early-rx interrupts |
972 | set_io REG_MultiIntr |
972 | set_io REG_MultiIntr |
973 | in ax, dx |
973 | in ax, dx |
974 | and ax, 0xF000 |
974 | and ax, 0xF000 |
975 | out dx, ax |
975 | out dx, ax |
976 | 976 | ||
977 | ; set interrupt mask |
977 | ; set interrupt mask |
978 | set_io REG_IntrMask |
978 | set_io REG_IntrMask |
979 | mov ax, intr_mask |
979 | mov ax, intr_mask |
980 | out dx, ax |
980 | out dx, ax |
981 | 981 | ||
982 | xor eax, eax |
982 | xor eax, eax |
983 | ret |
983 | ret |
984 | 984 | ||
985 | 985 | ||
986 | align 4 |
986 | align 4 |
987 | read_mac: |
987 | read_mac: |
988 | 988 | ||
989 | set_io 0 |
989 | set_io 0 |
990 | set_io REG_MAC0 |
990 | set_io REG_MAC0 |
991 | xor ecx, ecx |
991 | xor ecx, ecx |
992 | lea edi, [device.mac] |
992 | lea edi, [device.mac] |
993 | mov ecx, MAC_ADDR_LEN |
993 | mov ecx, MAC_ADDR_LEN |
994 | 994 | ||
995 | ; Get MAC address. FIXME: read EEPROM |
995 | ; Get MAC address. FIXME: read EEPROM |
996 | @@: in al, dx |
996 | @@: in al, dx |
997 | stosb |
997 | stosb |
998 | inc edx |
998 | inc edx |
999 | loop @r |
999 | loop @r |
1000 | 1000 | ||
1001 | DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",[device.mac+0]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
1001 | DEBUGF 1,"MAC = %x-%x-%x-%x-%x-%x\n",[device.mac+0]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
1002 | 1002 | ||
1003 | ret |
1003 | ret |
1004 | 1004 | ||
1005 | align 4 |
1005 | align 4 |
1006 | write_mac: |
1006 | write_mac: |
1007 | 1007 | ||
1008 | ret 6 |
1008 | ret 6 |
1009 | 1009 | ||
1010 | 1010 | ||
1011 | 1011 | ||
1012 | 1012 | ||
1013 | 1013 | ||
1014 | ;*************************************************************************** |
1014 | ;*************************************************************************** |
1015 | ; Function |
1015 | ; Function |
1016 | ; transmit |
1016 | ; transmit |
1017 | ; Description |
1017 | ; Description |
1018 | ; Transmits a packet of data via the ethernet card |
1018 | ; Transmits a packet of data via the ethernet card |
1019 | ; |
1019 | ; |
1020 | ; Destroyed registers |
1020 | ; Destroyed registers |
1021 | ; eax, edx, esi, edi |
1021 | ; eax, edx, esi, edi |
1022 | ; |
1022 | ; |
1023 | ;*************************************************************************** |
1023 | ;*************************************************************************** |
1024 | align 4 |
1024 | align 4 |
1025 | transmit: |
1025 | transmit: |
1026 | 1026 | ||
1027 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8] |
1027 | DEBUGF 1,"Transmitting packet, buffer:%x, size:%u\n", [esp+4], [esp+8] |
1028 | mov eax, [esp+4] |
1028 | mov eax, [esp+4] |
1029 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1029 | DEBUGF 1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
1030 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1030 | [eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\ |
1031 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1031 | [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\ |
1032 | [eax+13]:2,[eax+12]:2 |
1032 | [eax+13]:2,[eax+12]:2 |
1033 | 1033 | ||
1034 | cmp dword [esp+8], MAX_ETH_FRAME_SIZE |
1034 | cmp dword [esp+8], MAX_ETH_FRAME_SIZE |
1035 | ja .fail |
1035 | ja .fail |
1036 | 1036 | ||
1037 | ;---------------------------------- |
1037 | ;---------------------------------- |
1038 | ; Find currentTX descriptor address |
1038 | ; Find currentTX descriptor address |
1039 | 1039 | ||
1040 | mov eax, tx_desc.size |
1040 | mov eax, tx_desc.size |
1041 | mul [tpc.cur_tx] |
1041 | mul [tpc.cur_tx] |
1042 | lea esi, [eax + tx_ring] |
1042 | lea esi, [eax + tx_ring] |
1043 | 1043 | ||
1044 | ;--------------------------- |
1044 | ;--------------------------- |
1045 | ; Program the packet pointer |
1045 | ; Program the packet pointer |
1046 | 1046 | ||
1047 | mov eax, [esp + 4] |
1047 | mov eax, [esp + 4] |
1048 | mov [esi + tx_desc.buf_soft_addr], eax |
1048 | mov [esi + tx_desc.buf_soft_addr], eax |
1049 | GetRealAddr |
1049 | GetRealAddr |
1050 | mov dword [esi + tx_desc.buf_addr], eax |
1050 | mov dword [esi + tx_desc.buf_addr], eax |
1051 | 1051 | ||
1052 | ;------------------------ |
1052 | ;------------------------ |
1053 | ; Program the packet size |
1053 | ; Program the packet size |
1054 | 1054 | ||
1055 | mov eax, [esp + 8] |
1055 | mov eax, [esp + 8] |
1056 | @@: or eax, DSB_OWNbit or DSB_FSbit or DSB_LSbit |
1056 | @@: or eax, DSB_OWNbit or DSB_FSbit or DSB_LSbit |
1057 | cmp [tpc.cur_tx], NUM_TX_DESC - 1 |
1057 | cmp [tpc.cur_tx], NUM_TX_DESC - 1 |
1058 | jne @f |
1058 | jne @f |
1059 | or eax, DSB_EORbit |
1059 | or eax, DSB_EORbit |
1060 | @@: mov [esi + tx_desc.status], eax |
1060 | @@: mov [esi + tx_desc.status], eax |
1061 | 1061 | ||
1062 | ;----------------------------------------- |
1062 | ;----------------------------------------- |
1063 | ; Set the polling bit (start transmission) |
1063 | ; Set the polling bit (start transmission) |
1064 | 1064 | ||
1065 | set_io 0 |
1065 | set_io 0 |
1066 | set_io REG_TxPoll |
1066 | set_io REG_TxPoll |
1067 | mov al, 0x40 ; set polling bit |
1067 | mov al, 0x40 ; set polling bit |
1068 | out dx, al |
1068 | out dx, al |
1069 | 1069 | ||
1070 | ;----------------------- |
1070 | ;----------------------- |
1071 | ; Update TX descriptor |
1071 | ; Update TX descriptor |
1072 | 1072 | ||
1073 | inc [tpc.cur_tx] |
1073 | inc [tpc.cur_tx] |
1074 | and [tpc.cur_tx], NUM_TX_DESC - 1 |
1074 | and [tpc.cur_tx], NUM_TX_DESC - 1 |
1075 | 1075 | ||
1076 | ;------------- |
1076 | ;------------- |
1077 | ; Update stats |
1077 | ; Update stats |
1078 | 1078 | ||
1079 | inc [device.packets_tx] |
1079 | inc [device.packets_tx] |
1080 | mov eax, [esp+8] |
1080 | mov eax, [esp+8] |
1081 | add dword [device.bytes_tx], eax |
1081 | add dword [device.bytes_tx], eax |
1082 | adc dword [device.bytes_tx + 4], 0 |
1082 | adc dword [device.bytes_tx + 4], 0 |
1083 | 1083 | ||
1084 | ret 8 |
1084 | ret 8 |
1085 | 1085 | ||
1086 | .fail: |
1086 | .fail: |
1087 | DEBUGF 1,"transmit failed\n" |
1087 | DEBUGF 1,"transmit failed\n" |
1088 | or eax, -1 |
1088 | or eax, -1 |
1089 | stdcall KernelFree, [esp+4] |
1089 | stdcall KernelFree, [esp+4] |
1090 | ret 8 |
1090 | ret 8 |
1091 | 1091 | ||
1092 | 1092 | ||
1093 | ;;;DSB_OWNbit |
1093 | ;;;DSB_OWNbit |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | ;;;;;;;;;;;;;;;;;;;;;;; |
1096 | ;;;;;;;;;;;;;;;;;;;;;;; |
1097 | ;; ;; |
1097 | ;; ;; |
1098 | ;; Interrupt handler ;; |
1098 | ;; Interrupt handler ;; |
1099 | ;; ;; |
1099 | ;; ;; |
1100 | ;;;;;;;;;;;;;;;;;;;;;;; |
1100 | ;;;;;;;;;;;;;;;;;;;;;;; |
1101 | 1101 | ||
1102 | align 4 |
1102 | align 4 |
1103 | int_handler: |
1103 | int_handler: |
1104 | 1104 | ||
1105 | DEBUGF 1,"IRQ %x ",eax:2 |
1105 | DEBUGF 1,"IRQ %x ",eax:2 |
1106 | 1106 | ||
1107 | ; find pointer of device wich made IRQ occur |
1107 | ; find pointer of device wich made IRQ occur |
1108 | 1108 | ||
1109 | mov ecx, [devices] |
1109 | mov ecx, [devices] |
1110 | test ecx, ecx |
1110 | test ecx, ecx |
1111 | jz .fail |
1111 | jz .fail |
1112 | mov esi, device_list |
1112 | mov esi, device_list |
1113 | .nextdevice: |
1113 | .nextdevice: |
1114 | mov ebx, dword [esi] |
1114 | mov ebx, dword [esi] |
1115 | 1115 | ||
1116 | set_io 0 |
1116 | set_io 0 |
1117 | set_io REG_IntrStatus |
1117 | set_io REG_IntrStatus |
1118 | in ax, dx |
1118 | in ax, dx |
1119 | 1119 | ||
1120 | test ax, ax |
1120 | test ax, ax |
1121 | jnz .got_it |
1121 | jnz .got_it |
1122 | 1122 | ||
1123 | .continue: |
1123 | .continue: |
1124 | add esi, 4 |
1124 | add esi, 4 |
1125 | dec ecx |
1125 | dec ecx |
1126 | jnz .nextdevice |
1126 | jnz .nextdevice |
1127 | 1127 | ||
1128 | ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver) |
1128 | ret ; If no device was found, abort (The irq was probably for a device, not registered to this driver) |
1129 | 1129 | ||
1130 | .got_it: |
1130 | .got_it: |
1131 | DEBUGF 1,"IntrStatus = 0x%x\n",ax |
1131 | DEBUGF 1,"IntrStatus = 0x%x\n",ax |
1132 | 1132 | ||
1133 | cmp ax, 0xFFFF ; if so, hardware is no longer present |
1133 | cmp ax, 0xFFFF ; if so, hardware is no longer present |
1134 | je .fail |
1134 | je .fail |
1135 | 1135 | ||
1136 | ;-------- |
1136 | ;-------- |
1137 | ; Receive |
1137 | ; Receive |
1138 | 1138 | ||
1139 | test ax, ISB_RxOK |
1139 | test ax, ISB_RxOK |
1140 | jz .no_rx |
1140 | jz .no_rx |
1141 | 1141 | ||
1142 | push ax |
1142 | push ax |
- | 1143 | ||
1143 | 1144 | .check_more: |
|
1144 | mov eax, rx_desc.size |
1145 | mov eax, rx_desc.size |
1145 | mul [tpc.cur_rx] |
1146 | mul [tpc.cur_rx] |
1146 | lea esi, [eax + rx_ring] |
1147 | lea esi, [eax + rx_ring] |
1147 | 1148 | ||
1148 | DEBUGF 1,"RxDesc.status = 0x%x\n", [esi + rx_desc.status] |
1149 | DEBUGF 1,"RxDesc.status = 0x%x\n", [esi + rx_desc.status] |
1149 | 1150 | ||
1150 | mov eax, [esi + rx_desc.status] |
1151 | mov eax, [esi + rx_desc.status] |
1151 | test eax, DSB_OWNbit ;;; |
1152 | test eax, DSB_OWNbit ;;; |
1152 | jnz .rx_return |
1153 | jnz .rx_return |
1153 | 1154 | ||
1154 | DEBUGF 1,"tpc.cur_rx = %u\n", [tpc.cur_rx] |
1155 | DEBUGF 1,"tpc.cur_rx = %u\n", [tpc.cur_rx] |
1155 | 1156 | ||
1156 | test eax, SD_RxRES |
1157 | test eax, SD_RxRES |
1157 | jnz .rx_return ;;;;; RX error! |
1158 | jnz .rx_return ;;;;; RX error! |
1158 | 1159 | ||
1159 | push .rx_return |
1160 | push .check_more |
1160 | and eax, 0x00001FFF |
1161 | and eax, 0x00001FFF |
1161 | add eax, -4 ; we dont need CRC |
1162 | add eax, -4 ; we dont need CRC |
1162 | push eax |
1163 | push eax |
1163 | DEBUGF 1,"data length = %u\n", ax |
1164 | DEBUGF 1,"data length = %u\n", ax |
1164 | 1165 | ||
1165 | ;------------- |
1166 | ;------------- |
1166 | ; Update stats |
1167 | ; Update stats |
- | 1168 | ||
1167 | add dword [device.bytes_rx], eax |
1169 | add dword [device.bytes_rx], eax |
1168 | adc dword [device.bytes_rx + 4], 0 |
1170 | adc dword [device.bytes_rx + 4], 0 |
1169 | inc dword [device.packets_rx] |
1171 | inc dword [device.packets_rx] |
1170 | 1172 | ||
1171 | push [esi + rx_desc.buf_soft_addr] |
1173 | push [esi + rx_desc.buf_soft_addr] |
1172 | 1174 | ||
1173 | ;---------------------- |
1175 | ;---------------------- |
1174 | ; Allocate a new buffer |
1176 | ; Allocate a new buffer |
1175 | 1177 | ||
1176 | stdcall KernelAlloc, RX_BUF_SIZE |
1178 | stdcall KernelAlloc, RX_BUF_SIZE |
1177 | mov [esi + rx_desc.buf_soft_addr], eax |
1179 | mov [esi + rx_desc.buf_soft_addr], eax |
1178 | GetRealAddr |
1180 | GetRealAddr |
1179 | mov dword [esi + rx_desc.buf_addr], eax |
1181 | mov dword [esi + rx_desc.buf_addr], eax |
1180 | 1182 | ||
1181 | ;--------------- |
1183 | ;--------------- |
1182 | ; re set OWN bit |
1184 | ; re set OWN bit |
1183 | 1185 | ||
1184 | mov eax, DSB_OWNbit or RX_BUF_SIZE |
1186 | mov eax, DSB_OWNbit or RX_BUF_SIZE |
1185 | cmp [tpc.cur_rx], NUM_RX_DESC - 1 |
1187 | cmp [tpc.cur_rx], NUM_RX_DESC - 1 |
1186 | jne @f |
1188 | jne @f |
1187 | or eax, DSB_EORbit |
1189 | or eax, DSB_EORbit |
1188 | @@: mov [esi + rx_desc.status], eax |
1190 | @@: mov [esi + rx_desc.status], eax |
1189 | 1191 | ||
1190 | ;-------------- |
1192 | ;-------------- |
1191 | ; Update rx ptr |
1193 | ; Update rx ptr |
1192 | 1194 | ||
1193 | inc [tpc.cur_rx] |
1195 | inc [tpc.cur_rx] |
1194 | and [tpc.cur_rx], NUM_RX_DESC - 1 |
1196 | and [tpc.cur_rx], NUM_RX_DESC - 1 |
1195 | 1197 | ||
1196 | jmp EthReceiver |
1198 | jmp EthReceiver |
1197 | .rx_return: |
1199 | .rx_return: |
1198 | 1200 | ||
1199 | pop ax |
1201 | pop ax |
1200 | .no_rx: |
1202 | .no_rx: |
1201 | 1203 | ||
1202 | ;--------- |
1204 | ;--------- |
1203 | ; Transmit |
1205 | ; Transmit |
1204 | 1206 | ||
1205 | test ax, ISB_TxOK |
1207 | test ax, ISB_TxOK |
1206 | jz .no_tx |
1208 | jz .no_tx |
1207 | push ax |
1209 | push ax |
1208 | 1210 | ||
1209 | DEBUGF 1,"TX ok!\n" |
1211 | DEBUGF 1,"TX ok!\n" |
1210 | 1212 | ||
1211 | mov ecx, NUM_TX_DESC |
1213 | mov ecx, NUM_TX_DESC |
1212 | lea esi, [device.tx_ring] |
1214 | lea esi, [tx_ring] |
1213 | .txloop: |
1215 | .txloop: |
1214 | cmp [esi+tx_desc.buf_soft_addr], 0 |
1216 | cmp [esi+tx_desc.buf_soft_addr], 0 |
1215 | jz .maybenext |
1217 | jz .maybenext |
1216 | 1218 | ||
1217 | test [esi+tx_desc.status], DSB_OWNbit |
1219 | test [esi+tx_desc.status], DSB_OWNbit |
1218 | jnz .maybenext |
1220 | jnz .maybenext |
1219 | 1221 | ||
1220 | push ecx |
1222 | push ecx |
1221 | stdcall KernelFree, [esi+tx_desc.buf_soft_addr] |
1223 | stdcall KernelFree, [esi+tx_desc.buf_soft_addr] |
1222 | pop ecx |
1224 | pop ecx |
1223 | and [esi+tx_desc.buf_soft_addr], 0 |
1225 | and [esi+tx_desc.buf_soft_addr], 0 |
1224 | 1226 | ||
1225 | .maybenext: |
1227 | .maybenext: |
1226 | add esi, tx_desc.size |
1228 | add esi, tx_desc.size |
1227 | dec ecx |
1229 | dec ecx |
1228 | jnz .txloop |
1230 | jnz .txloop |
1229 | 1231 | ||
1230 | pop ax |
1232 | pop ax |
1231 | .no_tx: |
1233 | .no_tx: |
1232 | 1234 | ||
1233 | ;------- |
1235 | ;------- |
1234 | ; Finish |
1236 | ; Finish |
1235 | 1237 | ||
1236 | set_io 0 |
1238 | set_io 0 |
1237 | set_io REG_IntrStatus |
1239 | set_io REG_IntrStatus |
1238 | out dx, ax ; ACK all interrupts |
1240 | out dx, ax ; ACK all interrupts |
1239 | 1241 | ||
1240 | .fail: |
1242 | .fail: |
1241 | ret |
1243 | ret |
1242 | 1244 | ||
1243 | 1245 | ||
1244 | 1246 | ||
1245 | 1247 | ||
1246 | 1248 | ||
1247 | 1249 | ||
1248 | 1250 | ||
1249 | 1251 | ||
1250 | 1252 | ||
1251 | ; End of code |
1253 | ; End of code |
1252 | align 4 ; Place all initialised data here |
1254 | align 4 ; Place all initialised data here |
1253 | 1255 | ||
1254 | devices dd 0 |
1256 | devices dd 0 |
1255 | version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF) |
1257 | version dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF) |
1256 | my_service db 'RTL8169',0 ; max 16 chars include zero |
1258 | my_service db 'RTL8169',0 ; max 16 chars include zero |
1257 | 1259 | ||
1258 | include_debug_strings ; All data wich FDO uses will be included here |
1260 | include_debug_strings ; All data wich FDO uses will be included here |
1259 | 1261 | ||
1260 | rtl_chip_info dd \ |
1262 | rtl_chip_info dd \ |
1261 | MCFG_METHOD_01, 0xff7e1880, \ ; RTL8169 |
1263 | MCFG_METHOD_01, 0xff7e1880, \ ; RTL8169 |
1262 | MCFG_METHOD_02, 0xff7e1880, \ ; RTL8169s/8110s |
1264 | MCFG_METHOD_02, 0xff7e1880, \ ; RTL8169s/8110s |
1263 | MCFG_METHOD_03, 0xff7e1880, \ ; RTL8169s/8110s |
1265 | MCFG_METHOD_03, 0xff7e1880, \ ; RTL8169s/8110s |
1264 | MCFG_METHOD_04, 0xff7e1880, \ ; RTL8169sb/8110sb |
1266 | MCFG_METHOD_04, 0xff7e1880, \ ; RTL8169sb/8110sb |
1265 | MCFG_METHOD_05, 0xff7e1880, \ ; RTL8169sc/8110sc |
1267 | MCFG_METHOD_05, 0xff7e1880, \ ; RTL8169sc/8110sc |
1266 | MCFG_METHOD_11, 0xff7e1880, \ ; RTL8168b/8111b // PCI-E |
1268 | MCFG_METHOD_11, 0xff7e1880, \ ; RTL8168b/8111b // PCI-E |
1267 | MCFG_METHOD_12, 0xff7e1880, \ ; RTL8168b/8111b // PCI-E |
1269 | MCFG_METHOD_12, 0xff7e1880, \ ; RTL8168b/8111b // PCI-E |
1268 | MCFG_METHOD_13, 0xff7e1880, \ ; RTL8101e // PCI-E 8139 |
1270 | MCFG_METHOD_13, 0xff7e1880, \ ; RTL8101e // PCI-E 8139 |
1269 | MCFG_METHOD_14, 0xff7e1880, \ ; RTL8100e // PCI-E 8139 |
1271 | MCFG_METHOD_14, 0xff7e1880, \ ; RTL8100e // PCI-E 8139 |
1270 | MCFG_METHOD_15, 0xff7e1880 ; RTL8100e // PCI-E 8139 |
1272 | MCFG_METHOD_15, 0xff7e1880 ; RTL8100e // PCI-E 8139 |
1271 | 1273 | ||
1272 | mac_info dd \ |
1274 | mac_info dd \ |
1273 | 0x38800000, MCFG_METHOD_15, \ |
1275 | 0x38800000, MCFG_METHOD_15, \ |
1274 | 0x38000000, MCFG_METHOD_12, \ |
1276 | 0x38000000, MCFG_METHOD_12, \ |
1275 | 0x34000000, MCFG_METHOD_13, \ |
1277 | 0x34000000, MCFG_METHOD_13, \ |
1276 | 0x30800000, MCFG_METHOD_14, \ |
1278 | 0x30800000, MCFG_METHOD_14, \ |
1277 | 0x30000000, MCFG_METHOD_11, \ |
1279 | 0x30000000, MCFG_METHOD_11, \ |
1278 | 0x18000000, MCFG_METHOD_05, \ |
1280 | 0x18000000, MCFG_METHOD_05, \ |
1279 | 0x10000000, MCFG_METHOD_04, \ |
1281 | 0x10000000, MCFG_METHOD_04, \ |
1280 | 0x04000000, MCFG_METHOD_03, \ |
1282 | 0x04000000, MCFG_METHOD_03, \ |
1281 | 0x00800000, MCFG_METHOD_02, \ |
1283 | 0x00800000, MCFG_METHOD_02, \ |
1282 | 0x00000000, MCFG_METHOD_01 ; catch-all |
1284 | 0x00000000, MCFG_METHOD_01 ; catch-all |
1283 | 1285 | ||
1284 | name_01 db "RTL8169", 0 |
1286 | name_01 db "RTL8169", 0 |
1285 | name_02_03 db "RTL8169s/8110s", 0 |
1287 | name_02_03 db "RTL8169s/8110s", 0 |
1286 | name_04 db "RTL8169sb/8110sb", 0 |
1288 | name_04 db "RTL8169sb/8110sb", 0 |
1287 | name_05 db "RTL8169sc/8110sc", 0 |
1289 | name_05 db "RTL8169sc/8110sc", 0 |
1288 | name_11_12 db "RTL8168b/8111b", 0 ; PCI-E |
1290 | name_11_12 db "RTL8168b/8111b", 0 ; PCI-E |
1289 | name_13 db "RTL8101e", 0 ; PCI-E 8139 |
1291 | name_13 db "RTL8101e", 0 ; PCI-E 8139 |
1290 | name_14_15 db "RTL8100e", 0 ; PCI-E 8139 |
1292 | name_14_15 db "RTL8100e", 0 ; PCI-E 8139 |
1291 | 1293 | ||
1292 | 1294 | ||
1293 | section '.data' data readable writable align 16 ; place all uninitialized data place here |
1295 | section '.data' data readable writable align 16 ; place all uninitialized data place here |
1294 | 1296 | ||
1295 | device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling |
1297 | device_list rd MAX_DEVICES ; This list contains all pointers to device structures the driver is handling |