Subversion Repositories Kolibri OS

Rev

Rev 1514 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1514 Rev 1519
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2009. 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
;;  3Com network driver for KolibriOS                           ;;
-
 
7
;;                                                              ;;
-
 
8
;;  Ported to KolibriOS net-branch by hidnplayr (28/05/10)      ;;
-
 
9
;;                                                              ;;
-
 
10
;;  Thanks to: scrap metal recyclers, whom provide me with      ;;
-
 
11
;;                         loads of hardware                    ;;
-
 
12
;;             diamond: who makes me understand KolibriOS       ;;
-
 
13
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 15...
7
 
15
 
8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
9
;;
-
 
10
;;  Ethernet Driver for KolibriOS
-
 
11
;;
-
 
12
;;  3c59x.asm
-
 
13
;;  Ported to KolibriOS net-branch by hidnplayr (28/05/10)
-
 
14
;;
-
 
15
;;  Thanks to: scrap metal recyclers, whom provide me with loads of hardware
-
 
16
;;             diamond: who makes me understand KolibriOS
-
 
17
;;
-
 
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 
19
 
-
 
20
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21
;;                                                                         ;;
17
;;                                                                         ;;
22
;;  3C59X.INC                                                              ;;
18
;;  3C59X.INC                                                              ;;
23
;;                                                                         ;;
19
;;                                                                         ;;
24
;;  Ethernet driver for Menuet OS                                          ;;
20
;;  Ethernet driver for Menuet OS                                          ;;
Line 82... Line 78...
82
;;  Revision 1.1  2004/06/12 18:27:15  kozma
78
;;  Revision 1.1  2004/06/12 18:27:15  kozma
83
;;  Initial revision
79
;;  Initial revision
84
;;
80
;;
85
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
81
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 86... Line -...
86
 
-
 
87
 
-
 
88
PROMISCIOUS equ 1
-
 
89
 
-
 
90
 
82
 
Line 91... Line 83...
91
format MS COFF
83
format MS COFF
-
 
84
 
-
 
85
	API_VERSION		equ 0x01000100
-
 
86
	DRIVER_VERSION		equ 5
-
 
87
 
-
 
88
	MAX_DEVICES		equ 16
Line 92... Line 89...
92
 
89
	FORCE_FD		equ 0  ; forcing full duplex mode makes sense at some cards and link types
93
	API_VERSION		equ 0x01000100
90
	PROMISCIOUS		equ 0  ; enables promiscous mode
94
 
91
 
Line 95... Line 92...
95
	DEBUG			equ 1
92
	DEBUG			equ 1
96
	__DEBUG__		equ 1
93
	__DEBUG__		equ 1
97
	__DEBUG_LEVEL__ 	equ 1
94
	__DEBUG_LEVEL__ 	equ 1
98
 
95
 
Line 99... Line -...
99
include 'proc32.inc'
-
 
100
include 'imports.inc'
-
 
101
include 'fdo.inc'
-
 
102
include 'netdrv.inc'
-
 
103
 
-
 
104
 
96
include 'proc32.inc'
105
OS_BASE 	equ 0
97
include 'imports.inc'
106
new_app_base	equ 0x60400000
98
include 'fdo.inc'
Line 107... Line -...
107
PROC_BASE	equ OS_BASE+0x0080000
-
 
108
 
-
 
109
public START
-
 
110
public service_proc
-
 
111
public version
-
 
112
 
-
 
113
 
-
 
114
virtual at ebx
-
 
115
 
-
 
116
	device:
-
 
117
 
-
 
118
	ETH_DEVICE
-
 
119
 
-
 
120
      .rx_buffer	dd ?
-
 
121
      .tx_buffer	dd ?
-
 
122
      .dpd_buffer	dd ?
-
 
123
      .upd_buffer	dd ?
-
 
124
      .curr_upd 	dd ?
-
 
125
      .prev_dpd 	dd ?
-
 
126
 
-
 
127
      .io_addr		dd ?
-
 
128
      .pci_bus		db ?
-
 
129
      .pci_dev		db ?
-
 
130
      .irq_line 	db ?
-
 
131
 
-
 
132
      .prev_tx_frame		dd ?
-
 
133
      .ver_id			db ?
-
 
134
      .full_bus_master		db ?
-
 
135
      .has_hwcksm		db ?
-
 
136
      .preamble 		db ?
-
 
137
      .dn_list_ptr_cleared	db ?
-
 
138
      .self_directed_packet	rb 20
-
 
139
 
99
include 'netdrv.inc'
Line 140... Line 100...
140
      .size = $ - device
100
 
141
 
101
public START
142
end virtual
102
public service_proc
Line 170... Line 130...
170
 
130
 
171
virtual at 0
131
virtual at 0
172
  upd UPD
132
  upd UPD
Line 173... Line -...
173
end virtual
-
 
174
 
-
 
175
 
-
 
176
	MAX_DEVICES		equ 16
-
 
177
	FORCE_FD		equ 0  ; forcing full duplex mode makes sense at some cards and link types
-
 
178
 
133
end virtual
179
 
134
 
180
; Ethernet frame symbols
135
; Ethernet frame symbols
181
	ETH_ALEN		equ 6
136
	ETH_ALEN		equ 6
182
	ETH_HLEN		equ (2*ETH_ALEN+2)
137
	ETH_HLEN		equ (2*ETH_ALEN+2)
183
	ETH_ZLEN		equ 60 ; 60 + 4bytes auto payload for
-
 
184
					      ; mininmum 64bytes frame length
138
	ETH_ZLEN		equ 60 ; 60 + 4bytes auto payload for
185
 
139
					      ; mininmum 64bytes frame length
186
; Registers
140
; Registers
187
	REG_POWER_MGMT_CTRL	equ 0x7c
141
	REG_POWER_MGMT_CTRL	equ 0x7c
188
	REG_UP_LIST_PTR 	equ 0x38
142
	REG_UP_LIST_PTR 	equ 0x38
189
	REG_UP_PKT_STATUS	equ 0x30
143
	REG_UP_PKT_STATUS	equ 0x30
190
	REG_TX_FREE_THRESH	equ 0x2f
144
	REG_TX_FREE_THRESH	equ 0x2f
191
	REG_DN_LIST_PTR 	equ 0x24
145
	REG_DN_LIST_PTR 	equ 0x24
192
	REG_DMA_CTRL		equ 0x20
146
	REG_DMA_CTRL		equ 0x20
193
	REG_TX_STATUS		equ 0x1b
147
	REG_TX_STATUS		equ 0x1b
-
 
148
	REG_RX_STATUS		equ 0x18
194
	REG_RX_STATUS		equ 0x18
149
	REG_TX_DATA		equ 0x10
195
	REG_TX_DATA		equ 0x10
150
 
196
; Common window registers
151
; Common window registers
-
 
152
	REG_INT_STATUS		equ 0xe
197
	REG_INT_STATUS		equ 0xe
153
	REG_COMMAND		equ 0xe
198
	REG_COMMAND		equ 0xe
154
 
199
; Register window 7
155
; Register window 7
200
	REG_MASTER_STATUS	equ 0xc
156
	REG_MASTER_STATUS	equ 0xc
201
	REG_POWER_MGMT_EVENT	equ 0xc
157
	REG_POWER_MGMT_EVENT	equ 0xc
202
	REG_MASTER_LEN		equ 0x6
158
	REG_MASTER_LEN		equ 0x6
203
	REG_VLAN_ETHER_TYPE	equ 0x4
159
	REG_VLAN_ETHER_TYPE	equ 0x4
-
 
160
	REG_VLAN_MASK		equ 0x0
204
	REG_VLAN_MASK		equ 0x0
161
	REG_MASTER_ADDRESS	equ 0x0
205
	REG_MASTER_ADDRESS	equ 0x0
162
 
206
; Register window 6
163
; Register window 6
207
	REG_BYTES_XMITTED_OK	equ 0xc
164
	REG_BYTES_XMITTED_OK	equ 0xc
208
	REG_BYTES_RCVD_OK	equ 0xa
165
	REG_BYTES_RCVD_OK	equ 0xa
Line 214... Line 171...
214
	REG_LATE_COLLISIONS	equ 0x4
171
	REG_LATE_COLLISIONS	equ 0x4
215
	REG_SINGLE_COLLISIONS	equ 0x3
172
	REG_SINGLE_COLLISIONS	equ 0x3
216
	REG_MULTIPLE_COLLISIONS equ 0x2
173
	REG_MULTIPLE_COLLISIONS equ 0x2
217
	REG_SQE_ERRORS		equ 0x1
174
	REG_SQE_ERRORS		equ 0x1
218
	REG_CARRIER_LOST	equ 0x0
175
	REG_CARRIER_LOST	equ 0x0
-
 
176
 
219
; Register window 5
177
; Register window 5
220
	REG_INDICATION_ENABLE	equ 0xc
178
	REG_INDICATION_ENABLE	equ 0xc
221
	REG_INTERRUPT_ENABLE	equ 0xa
179
	REG_INTERRUPT_ENABLE	equ 0xa
222
	REG_TX_RECLAIM_THRESH	equ 0x9
180
	REG_TX_RECLAIM_THRESH	equ 0x9
223
	REG_RX_FILTER		equ 0x8
181
	REG_RX_FILTER		equ 0x8
224
	REG_RX_EARLY_THRESH	equ 0x6
182
	REG_RX_EARLY_THRESH	equ 0x6
225
	REG_TX_START_THRESH	equ 0x0
183
	REG_TX_START_THRESH	equ 0x0
-
 
184
 
226
; Register window 4
185
; Register window 4
227
	REG_UPPER_BYTES_OK	equ 0xe
186
	REG_UPPER_BYTES_OK	equ 0xe
228
	REG_BAD_SSD		equ 0xc
187
	REG_BAD_SSD		equ 0xc
229
	REG_MEDIA_STATUS	equ 0xa
188
	REG_MEDIA_STATUS	equ 0xa
230
	REG_PHYSICAL_MGMT	equ 0x8
189
	REG_PHYSICAL_MGMT	equ 0x8
231
	REG_NETWORK_DIAGNOSTIC	equ 0x6
190
	REG_NETWORK_DIAGNOSTIC	equ 0x6
232
	REG_FIFO_DIAGNOSTIC	equ 0x4
191
	REG_FIFO_DIAGNOSTIC	equ 0x4
233
	REG_VCO_DIAGNOSTIC	equ 0x2 ; may not supported
192
	REG_VCO_DIAGNOSTIC	equ 0x2 ; may not supported
-
 
193
 
234
; Bits in register window 4
194
; Bits in register window 4
235
	BIT_AUTOSELECT		equ 24
195
	BIT_AUTOSELECT		equ 24
-
 
196
 
236
; Register window 3
197
; Register window 3
237
	REG_TX_FREE		equ 0xc
198
	REG_TX_FREE		equ 0xc
238
	REG_RX_FREE		equ 0xa
199
	REG_RX_FREE		equ 0xa
239
	REG_MEDIA_OPTIONS	equ 0x8
200
	REG_MEDIA_OPTIONS	equ 0x8
240
	REG_MAC_CONTROL 	equ 0x6
201
	REG_MAC_CONTROL 	equ 0x6
241
	REG_MAX_PKT_SIZE	equ 0x4
202
	REG_MAX_PKT_SIZE	equ 0x4
242
	REG_INTERNAL_CONFIG	equ 0x0
203
	REG_INTERNAL_CONFIG	equ 0x0
-
 
204
 
243
; Register window 2
205
; Register window 2
244
	REG_RESET_OPTIONS	equ 0xc
206
	REG_RESET_OPTIONS	equ 0xc
245
	REG_STATION_MASK_HI	equ 0xa
207
	REG_STATION_MASK_HI	equ 0xa
246
	REG_STATION_MASK_MID	equ 0x8
208
	REG_STATION_MASK_MID	equ 0x8
247
	REG_STATION_MASK_LO	equ 0x6
209
	REG_STATION_MASK_LO	equ 0x6
248
	REG_STATION_ADDRESS_HI	equ 0x4
210
	REG_STATION_ADDRESS_HI	equ 0x4
249
	REG_STATION_ADDRESS_MID equ 0x2
211
	REG_STATION_ADDRESS_MID equ 0x2
250
	REG_STATION_ADDRESS_LO	equ 0x0
212
	REG_STATION_ADDRESS_LO	equ 0x0
-
 
213
 
251
; Register window 1
214
; Register window 1
252
	REG_TRIGGER_BITS	equ 0xc
215
	REG_TRIGGER_BITS	equ 0xc
253
	REG_SOS_BITS		equ 0xa
216
	REG_SOS_BITS		equ 0xa
254
	REG_WAKE_ON_TIMER	equ 0x8
217
	REG_WAKE_ON_TIMER	equ 0x8
255
	REG_SMB_RXBYTES 	equ 0x7
218
	REG_SMB_RXBYTES 	equ 0x7
256
	REG_SMB_DIAG		equ 0x5
219
	REG_SMB_DIAG		equ 0x5
257
	REG_SMB_ARB		equ 0x4
220
	REG_SMB_ARB		equ 0x4
258
	REG_SMB_STATUS		equ 0x2
221
	REG_SMB_STATUS		equ 0x2
259
	REG_SMB_ADDRESS 	equ 0x1
222
	REG_SMB_ADDRESS 	equ 0x1
260
	REG_SMB_FIFO_DATA	equ 0x0
223
	REG_SMB_FIFO_DATA	equ 0x0
-
 
224
 
261
; Register window 0
225
; Register window 0
262
	REG_EEPROM_DATA 	equ 0xc
226
	REG_EEPROM_DATA 	equ 0xc
263
	REG_EEPROM_COMMAND	equ 0xa
227
	REG_EEPROM_COMMAND	equ 0xa
264
	REG_BIOS_ROM_DATA	equ 0x8
228
	REG_BIOS_ROM_DATA	equ 0x8
265
	REG_BIOS_ROM_ADDR	equ 0x4
229
	REG_BIOS_ROM_ADDR	equ 0x4
-
 
230
 
266
; Physical management bits
231
; Physical management bits
267
	BIT_MGMT_DIR		equ 2 ; drive with the data written in mgmtData
232
	BIT_MGMT_DIR		equ 2 ; drive with the data written in mgmtData
268
	BIT_MGMT_DATA		equ 1 ; MII management data bit
233
	BIT_MGMT_DATA		equ 1 ; MII management data bit
269
	BIT_MGMT_CLK		equ 0 ; MII management clock
234
	BIT_MGMT_CLK		equ 0 ; MII management clock
-
 
235
 
270
; MII commands
236
; MII commands
271
	MII_CMD_MASK		equ (1111b shl 10)
237
	MII_CMD_MASK		equ (1111b shl 10)
272
	MII_CMD_READ		equ (0110b shl 10)
238
	MII_CMD_READ		equ (0110b shl 10)
273
	MII_CMD_WRITE		equ (0101b shl 10)
239
	MII_CMD_WRITE		equ (0101b shl 10)
-
 
240
 
274
; MII registers
241
; MII registers
275
	REG_MII_BMCR		equ 0 ; basic mode control register
242
	REG_MII_BMCR		equ 0 ; basic mode control register
276
	REG_MII_BMSR		equ 1 ; basic mode status register
243
	REG_MII_BMSR		equ 1 ; basic mode status register
277
	REG_MII_ANAR		equ 4 ; auto negotiation advertisement register
244
	REG_MII_ANAR		equ 4 ; auto negotiation advertisement register
278
	REG_MII_ANLPAR		equ 5 ; auto negotiation link partner ability register
245
	REG_MII_ANLPAR		equ 5 ; auto negotiation link partner ability register
279
	REG_MII_ANER		equ 6 ; auto negotiation expansion register
246
	REG_MII_ANER		equ 6 ; auto negotiation expansion register
-
 
247
 
280
; MII bits
248
; MII bits
281
	BIT_MII_AUTONEG_COMPLETE     equ 5 ; auto-negotiation complete
249
	BIT_MII_AUTONEG_COMPLETE     equ 5 ; auto-negotiation complete
282
	BIT_MII_PREAMBLE_SUPPRESSION equ 6
250
	BIT_MII_PREAMBLE_SUPPRESSION equ 6
-
 
251
 
283
; eeprom bits and commands
252
; eeprom bits and commands
284
	EEPROM_CMD_READ 	equ 0x80
253
	EEPROM_CMD_READ 	equ 0x80
285
	EEPROM_BIT_BUSY 	equ 15
254
	EEPROM_BIT_BUSY 	equ 15
-
 
255
 
286
; eeprom registers
256
; eeprom registers
287
	EEPROM_REG_OEM_NODE_ADDR equ 0xa
257
	EEPROM_REG_OEM_NODE_ADDR equ 0xa
288
	EEPROM_REG_CAPABILITIES  equ 0x10
258
	EEPROM_REG_CAPABILITIES  equ 0x10
-
 
259
 
289
; Commands for command register
260
; Commands for command register
290
	SELECT_REGISTER_WINDOW	equ (1 shl 11)
261
	SELECT_REGISTER_WINDOW	equ (1 shl 11)
Line 291... Line 262...
291
 
262
 
292
	IS_VORTEX		equ 0x1
263
	IS_VORTEX		equ 0x1
Line 304... Line 275...
304
	EEPROM_OFFSET		equ 0x1000
275
	EEPROM_OFFSET		equ 0x1000
305
	HAS_HWCKSM		equ 0x2000
276
	HAS_HWCKSM		equ 0x2000
306
	EXTRA_PREAMBLE		equ 0x4000
277
	EXTRA_PREAMBLE		equ 0x4000
Line 307... Line 278...
307
 
278
 
308
; Status
-
 
309
 
279
; Status
310
	IntLatch		equ 0x0001
280
	IntLatch		equ 0x0001
311
	HostError		equ 0x0002
281
	HostError		equ 0x0002
312
	TxComplete		equ 0x0004
282
	TxComplete		equ 0x0004
313
	TxAvailable		equ 0x0008
283
	TxAvailable		equ 0x0008
314
	RxComplete		equ 0x0010
284
	RxComplete		equ 0x0010
315
	RxEarly 		equ 0x0020
285
	RxEarly 		equ 0x0020
316
	IntReq			equ 0x0040
286
	IntReq			equ 0x0040
317
	StatsFull		equ 0x0080
287
	StatsFull		equ 0x0080
318
	DMADone 		equ 0x0100 ; 1 shl 8
288
	DMADone 		equ 0x0100
319
	DownComplete		equ 0x0200 ; 1 shl 9
289
	DownComplete		equ 0x0200
320
	UpComplete		equ 0x0400 ; 1 shl 10
290
	UpComplete		equ 0x0400
321
	DMAInProgress		equ 0x0800 ; 1 shl 11  (DMA controller is still busy)
291
	DMAInProgress		equ 0x0800 ; 1 shl 11  (DMA controller is still busy)
Line 322... Line 292...
322
	CmdInProgress		equ 0x1000 ; 1 shl 12  (EL3_CMD is still busy)
292
	CmdInProgress		equ 0x1000 ; 1 shl 12  (EL3_CMD is still busy)
323
 
-
 
324
	S_5_INTS		equ HostError + RxEarly + UpComplete + DownComplete ; + RxComplete + TxComplete + TxAvailable
-
 
Line 325... Line 293...
325
 
293
 
326
 
-
 
327
 
294
	S_5_INTS		equ HostError + RxEarly + UpComplete + DownComplete ;+ TxComplete + RxComplete  + TxAvailable
328
; Commands
295
 
329
 
296
; Commands
330
	TotalReset		equ 0 shl 11
297
	TotalReset		equ 0 shl 11
331
	SelectWindow		equ 1 shl 11
298
	SelectWindow		equ 1 shl 11
Line 352... Line 319...
352
	StartDMAUp		equ 20 shl 11
319
	StartDMAUp		equ 20 shl 11
353
	StartDMADown		equ (20 shl 11)+1
320
	StartDMADown		equ (20 shl 11)+1
354
	StatsEnable		equ 21 shl 11
321
	StatsEnable		equ 21 shl 11
355
	StatsDisable		equ 22 shl 11
322
	StatsDisable		equ 22 shl 11
356
	StopCoax		equ 23 shl 11
323
	StopCoax		equ 23 shl 11
357
	SetFilterBit		equ 25 shl 11}
324
	SetFilterBit		equ 25 shl 11
358
 
-
 
Line 359... Line 325...
359
 
325
 
360
; Rx mode bits
-
 
361
 
326
; Rx mode bits
362
	RxStation		equ 1
327
	RxStation		equ 1
363
	RxMulticast		equ 2
328
	RxMulticast		equ 2
364
	RxBroadcast		equ 4
329
	RxBroadcast		equ 4
Line 365... Line -...
365
	RxProm			equ 8
-
 
366
 
330
	RxProm			equ 8
367
 
-
 
368
; RX/TX buffers sizes
331
 
369
 
332
; RX/TX buffers sizes
370
	MAX_ETH_PKT_SIZE	equ 1536   ; max packet size
333
	MAX_ETH_PKT_SIZE	equ 1536   ; max packet size
371
	NUM_RX_DESC		equ 4	   ; a power of 2 number
-
 
372
	NUM_TX_DESC		equ 4	   ; a power of 2 number
-
 
373
	RX_BUFFER_SIZE		equ (MAX_ETH_FRAME_SIZE*NUM_RX_DESC)
334
	NUM_RX_DESC		equ 4	   ; a power of 2 number
Line -... Line 335...
-
 
335
	NUM_TX_DESC		equ 4	   ; a power of 2 number
Line -... Line 336...
-
 
336
	MAX_ETH_FRAME_SIZE	equ 1520	; size of ethernet frame + bytes alignment
Line -... Line 337...
-
 
337
 
Line -... Line 338...
-
 
338
virtual at ebx
-
 
339
 
-
 
340
	device:
-
 
341
 
-
 
342
	ETH_DEVICE
-
 
343
 
-
 
344
	.dpd_buffer	  rd (dpd.size*NUM_TX_DESC)/4
-
 
345
	.upd_buffer	  rd (upd.size*NUM_RX_DESC)/4
-
 
346
	.curr_upd	  dd ?
-
 
347
	.prev_dpd	  dd ?
-
 
348
 
-
 
349
	.io_addr	  dd ?
-
 
350
	.pci_bus	  db ?
-
 
351
	.pci_dev	  db ?
-
 
352
	.irq_line	  db ?
-
 
353
 
-
 
354
	.prev_tx_frame		  dd ?
-
 
355
	.ver_id 		  db ?
-
 
356
	.full_bus_master	  db ?
-
 
357
	.has_hwcksm		  db ?
-
 
358
	.preamble		  db ?
Line 374... Line 359...
374
	TX_BUFFER_SIZE		equ (MAX_ETH_FRAME_SIZE*NUM_TX_DESC)
359
	.dn_list_ptr_cleared	  db ?
Line 375... Line 360...
375
	MAX_ETH_FRAME_SIZE	equ 1520	; size of ethernet frame + bytes alignment
360
	.self_directed_packet	  rb 20
376
 
361
 
Line 511... Line 496...
511
	mov	[device.pci_bus], cl
496
	mov	[device.pci_bus], cl
512
	mov	cl , [eax+2]
497
	mov	cl , [eax+2]
513
	mov	[device.pci_dev], cl
498
	mov	[device.pci_dev], cl
Line 514... Line 499...
514
 
499
 
515
; Now, it's time to find the base io addres of the PCI device
-
 
516
 
500
; Now, it's time to find the base io addres of the PCI device
Line 517... Line 501...
517
	find_io [device.pci_bus], [device.pci_dev], [device.io_addr]
501
	find_io [device.pci_bus], [device.pci_dev], [device.io_addr]
518
 
-
 
519
; We've found the io address, find IRQ now
502
 
Line 520... Line 503...
520
 
503
; We've found the io address, find IRQ now
521
	find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
504
	find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
Line 522... Line -...
522
 
-
 
523
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
-
 
524
	[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
-
 
525
 
-
 
526
	allocate_and_clear [device.tx_buffer], (MAX_ETH_FRAME_SIZE*NUM_TX_DESC), .err
-
 
527
	allocate_and_clear [device.rx_buffer], (MAX_ETH_FRAME_SIZE*NUM_RX_DESC), .err
505
 
528
	allocate_and_clear [device.dpd_buffer], (dpd.size*NUM_TX_DESC), .err
506
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
529
	allocate_and_clear [device.upd_buffer], (dpd.size*NUM_RX_DESC), .err
507
	[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
530
 
508
 
Line 577... Line 555...
577
 
555
 
578
  .destroy:
556
  .destroy:
Line 579... Line 557...
579
	; todo: reset device into virgin state
557
	; todo: reset device into virgin state
580
 
-
 
581
  .err:
-
 
582
	stdcall KernelFree, [device.rx_buffer]
558
 
Line 583... Line 559...
583
	stdcall KernelFree, [device.tx_buffer]
559
  .err:
584
	stdcall KernelFree, ebx
560
	stdcall KernelFree, ebx
Line 611... Line 587...
611
;      eax, ebx, ecx, edx, edi, esi
587
;      eax, ebx, ecx, edx, edi, esi
612
;
588
;
613
;***************************************************************************
589
;***************************************************************************
Line 614... Line 590...
614
 
590
 
615
align 4
591
align 4
Line 616... Line 592...
616
probe:			; Tested - ok
592
probe:
Line 617... Line 593...
617
 
593
 
Line 669... Line 645...
669
	test	al, 100000b ; full bus master?
645
	test	al, 100000b ; full bus master?
670
	setnz	[device.full_bus_master]
646
	setnz	[device.full_bus_master]
671
	jnz	.boomerang_func
647
	jnz	.boomerang_func
672
	mov	[device.transmit], vortex_transmit
648
	mov	[device.transmit], vortex_transmit
673
	DEBUGF	1,"Device is a vortex type\n"
649
	DEBUGF	1,"Device is a vortex type\n"
-
 
650
	DEBUGF	1,"I'm sorry but vortex code hasnt been tested yet\n"
-
 
651
	DEBUGF	1,"Please contact me on hidnplayr@kolibrios.org\n"
-
 
652
	DEBUGF	1,"If you can help me finish it!\n"
-
 
653
	or	eax, -1
-
 
654
	ret
674
	jmp	@f
655
	jmp	@f
675
.boomerang_func: ; full bus master, so use boomerang functions
656
.boomerang_func: ; full bus master, so use boomerang functions
676
	mov	[device.transmit], boomerang_transmit
657
	mov	[device.transmit], boomerang_transmit
677
	DEBUGF	1,"Device is a boomerang type\n"
658
	DEBUGF	1,"Device is a boomerang type\n"
678
@@:
659
@@:
Line 810... Line 791...
810
 
791
 
811
	lea	edi, [device.bytes_tx]
792
	lea	edi, [device.bytes_tx]
812
	mov	ecx, 6
793
	mov	ecx, 6
Line -... Line 794...
-
 
794
	rep	stosd
-
 
795
 
-
 
796
; Set the mtu, kernel will be able to send now
813
	rep	stosd
797
	mov	[device.mtu], 1514
Line 973... Line 957...
973
	jz	.tx_set_prev
957
	jz	.tx_set_prev
974
	dec	ecx
958
	dec	ecx
975
	jnz	.tx_reset_loop
959
	jnz	.tx_reset_loop
976
.tx_set_prev:
960
.tx_set_prev:
977
; init last_dpd
961
; init last_dpd
978
	mov	eax, [device.dpd_buffer]
-
 
979
	add	eax, (NUM_TX_DESC-1)*dpd.size
962
	lea	eax, [device.dpd_buffer + (NUM_TX_DESC-1)*dpd.size]
980
	mov	[device.prev_dpd], eax
963
	mov	[device.prev_dpd], eax
Line 981... Line -...
981
 
-
 
982
	mov	eax, [device.tx_buffer]
-
 
983
	add	eax, (NUM_TX_DESC-1)*MAX_ETH_FRAME_SIZE
-
 
984
	mov	[device.prev_tx_frame], eax
964
 
985
.tx_enable:
965
.tx_enable:
Line 1002... Line 982...
1002
 
982
 
1003
	set_io	0
983
	set_io	0
1004
	set_io	REG_COMMAND
984
	set_io	REG_COMMAND
1005
	mov	ax, RxReset or 0x4
985
	mov	ax, RxReset or 0x4
-
 
986
	out	dx, ax
1006
	out	dx, ax
987
 
1007
; wait for RxReset to complete
988
; wait for RxReset to complete
1008
	mov	ecx, 200000
989
	mov	ecx, 200000
1009
.rx_reset_loop:
990
  .loop:
1010
	in	ax, dx
991
	in	ax, dx
1011
	test	ah, 10000b ; check CmdInProgress
992
	test	ah, 10000b ; check CmdInProgress
1012
	dec	ecx
993
	dec	ecx
1013
	jnz	.rx_reset_loop
-
 
1014
; create upd ring
-
 
1015
 
-
 
1016
	mov	eax, [device.upd_buffer]
-
 
1017
	mov	[device.curr_upd], eax
-
 
1018
	call	GetPgAddr
-
 
Line 1019... Line -...
1019
	mov	esi, eax
-
 
1020
 
994
	jnz	.loop
1021
	mov	eax, [device.rx_buffer]
-
 
1022
	call	GetPgAddr
-
 
1023
	mov	edi, eax
995
 
1024
 
996
; create upd ring
1025
	mov	edx, [device.upd_buffer]
-
 
1026
	add	edx, (NUM_RX_DESC-1)*upd.size
997
	lea	eax, [device.upd_buffer]
Line 1027... Line -...
1027
 
-
 
1028
	mov	eax, [device.upd_buffer]
998
	GetRealAddr
-
 
999
	mov	edi, eax						; real addr of first descr
Line 1029... Line 1000...
1029
 
1000
 
-
 
1001
	lea	esi, [device.upd_buffer]				; ptr to first descr
1030
	push	ebx
1002
	lea	edx, [device.upd_buffer + (NUM_RX_DESC-1)*upd.size]	; ptr to last descr
1031
	mov	ebx, [device.rx_buffer]
1003
 
-
 
1004
	mov	ecx, NUM_RX_DESC
-
 
1005
 
-
 
1006
  .upd_loop:
-
 
1007
	mov	[edx + upd.next_ptr], edi
-
 
1008
 
-
 
1009
	push	ecx edx
-
 
1010
	stdcall KernelAlloc, MAX_ETH_FRAME_SIZE
-
 
1011
	pop	edx ecx
-
 
1012
	mov	[esi + upd.realaddr], eax
Line 1032... Line -...
1032
 
-
 
1033
	mov	ecx, NUM_RX_DESC
-
 
1034
.upd_loop:
1013
	call	GetPgAddr
1035
	mov	[edx + upd.next_ptr], esi				; edx = upd buff
1014
	mov	[esi + upd.frag_addr], eax
Line 1036... Line -...
1036
 
-
 
1037
	and	[eax + upd.pkt_status], 0				; eax = next upd buff
1015
	and	[esi + upd.pkt_status], 0
1038
	mov	[eax + upd.frag_addr], edi
1016
	mov	[esi + upd.frag_len], MAX_ETH_FRAME_SIZE or (1 shl 31)
1039
	mov	[eax + upd.frag_len], MAX_ETH_FRAME_SIZE or (1 shl 31)
-
 
1040
	mov	[eax + upd.realaddr], ebx
1017
 
1041
 
-
 
1042
	add	edi, MAX_ETH_FRAME_SIZE
1018
	DEBUGF	1,"UPD: lin=%x phys=%x len=%x next ptr=%x\n", [esi+upd.realaddr]:8, [esi+upd.frag_addr]:8, [esi+upd.frag_len]:8, edi
1043
	add	ebx, MAX_ETH_FRAME_SIZE
1019
	DEBUGF	1,"UPD: cur=%x prev=%x\n", esi, edx
Line 1044... Line -...
1044
	add	esi, upd.size
-
 
1045
	mov	edx, eax
-
 
1046
	add	eax, upd.size
1020
 
-
 
1021
	mov	edx, esi
1047
 
1022
	add	esi, upd.size
1048
	dec	ecx
1023
	add	edi, upd.size
1049
	jnz	.upd_loop
1024
	dec	ecx
1050
 
1025
	jnz	.upd_loop
Line 1051... Line 1026...
1051
	pop	ebx
1026
 
Line 2226... Line 2201...
2226
; start DMA Down
2201
; start DMA Down
2227
	set_io	REG_COMMAND
2202
	set_io	REG_COMMAND
2228
	mov	ax, (10100b shl 11) + 1 ; StartDMADown
2203
	mov	ax, (10100b shl 11) + 1 ; StartDMADown
2229
	out	dx, ax
2204
	out	dx, ax
2230
.finish:
2205
.finish:
-
 
2206
	call	KernelFree
-
 
2207
	add	esp, 4
2231
	ret
2208
	ret
Line 2232... Line 2209...
2232
 
2209
 
Line 2243... Line 2220...
2243
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2220
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 2244... Line 2221...
2244
 
2221
 
2245
align 4
2222
align 4
Line 2246... Line 2223...
2246
boomerang_transmit:
2223
boomerang_transmit:
-
 
2224
 
-
 
2225
	DEBUGF	1,"Transmitting packet, buffer:%x, size:%u\n",[esp+4],[esp+8]
-
 
2226
	mov	eax, [esp+4]
-
 
2227
	DEBUGF	1,"To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\
-
 
2228
	[eax+00]:2,[eax+01]:2,[eax+02]:2,[eax+03]:2,[eax+04]:2,[eax+05]:2,\
Line 2247... Line 2229...
2247
 
2229
	[eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
2248
	DEBUGF	1,"Sending packet (boomerang)\n"
2230
	[eax+13]:2,[eax+12]:2
Line 2249... Line 2231...
2249
 
2231
 
-
 
2232
	cmp	dword [esp+8], MAX_ETH_FRAME_SIZE
2250
	cmp	dword [esp+8], MAX_ETH_FRAME_SIZE
2233
	jg	.fail
2251
	ja	.finish ; packet is too long
2234
 
Line 2252... Line 2235...
2252
 
2235
	call	check_tx_status
2253
	call	check_tx_status
2236
 
2254
	test	al, al
2237
	test	al, al
2255
	jnz	tx_reset
2238
	jnz	tx_reset
2256
 
-
 
2257
; calculate descriptor address
2239
 
2258
	mov	eax, [device.prev_dpd]
2240
; calculate descriptor address
-
 
2241
	mov	esi, [device.prev_dpd]
2259
	DEBUGF	1,"Previous DPD: %x\n", eax
2242
	DEBUGF	1,"Previous DPD: %x\n", esi
-
 
2243
	add	esi, dpd.size
-
 
2244
	lea	ecx, [device.dpd_buffer + (NUM_TX_DESC)*dpd.size]
Line 2260... Line -...
2260
	add	eax, dpd.size
-
 
2261
	mov	ecx, [device.dpd_buffer]
-
 
2262
	add	ecx, NUM_TX_DESC*dpd.size
2245
	cmp	esi, ecx
2263
	cmp	eax, ecx
2246
	jl	@f
2264
	cmovae	eax, [device.dpd_buffer]	; Wrap if needed
2247
	lea	esi, [device.dpd_buffer]	; Wrap if needed
2265
 
2248
       @@:
2266
	DEBUGF	1,"Found a free DPD: %x\n", eax
2249
	DEBUGF	1,"Found a free DPD: %x\n", esi
2267
	push	eax
2250
 
2268
; check DnListPtr
2251
; check DnListPtr
2269
	set_io	0
-
 
2270
	set_io	REG_DN_LIST_PTR
-
 
2271
	in	eax, dx
-
 
2272
; mark if Dn_List_Ptr is cleared
-
 
2273
	test	eax, eax
-
 
2274
	setz	[device.dn_list_ptr_cleared]
-
 
2275
; finish if no more free descriptor is available - FIXME!
-
 
2276
	cmp	eax, [esp]
-
 
2277
	pop	eax
-
 
2278
	jz	.finish
-
 
2279
 
-
 
2280
 
-
 
2281
	push	eax		;<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
 
2282
; calculate tx_buffer address
-
 
2283
	mov	edi, [device.prev_tx_frame]
-
 
2284
	DEBUGF	1,"Previous TX frame:: %x\n", edi
-
 
Line 2285... Line 2252...
2285
	add	edi, MAX_ETH_FRAME_SIZE
2252
	set_io	0
2286
 
2253
	set_io	REG_DN_LIST_PTR
-
 
2254
	in	eax, dx
Line 2287... Line 2255...
2287
	mov	ecx, [device.tx_buffer]
2255
; mark if Dn_List_Ptr is cleared
2288
	add	ecx, NUM_TX_DESC*MAX_ETH_FRAME_SIZE
2256
	test	eax, eax
2289
	cmp	edi, ecx
-
 
2290
	cmovae	edi, [device.tx_buffer] 	; Wrap if needed
2257
	setz	[device.dn_list_ptr_cleared]
2291
 
2258
 
2292
	DEBUGF	1,"Found place in TX buffer: %x\n", edi
2259
; finish if no more free descriptor is available - FIXME!
Line 2293... Line -...
2293
	push	edi		;<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
 
2294
 
-
 
2295
; update statistics
-
 
2296
	inc	[device.packets_tx]
-
 
2297
 
-
 
2298
	mov	ecx, [esp+8+8]
-
 
2299
	add	dword [device.bytes_tx], ecx
-
 
2300
	adc	dword [device.bytes_tx + 4], 0
-
 
2301
 
-
 
2302
; copy packet data
-
 
2303
	mov	esi, [esp+4+8]
-
 
2304
	DEBUGF	1,"Copying %u bytes from %x to %x\n", ecx, esi, edi
-
 
2305
	shr	cx , 1
-
 
2306
	jnc	.nb
2260
;        cmp     eax, esi
-
 
2261
;        jz      .finish
2307
	movsb
2262
 
-
 
2263
; update statistics
2308
  .nb:
2264
	inc	[device.packets_tx]
2309
	shr	cx , 1
-
 
2310
	jnc	.nw
-
 
2311
	movsw
-
 
2312
  .nw:
-
 
2313
	rep	movsd
-
 
2314
 
-
 
2315
; program DPD
-
 
2316
	mov	eax, [esp]		; Tx buffer address
2265
	mov	ecx, [esp+8]		; buffer size
2317
	call	GetPgAddr
-
 
2318
	mov	edi, [esp]
2266
	add	dword [device.bytes_tx], ecx
2319
	and	edi, 4096 - 1
2267
	adc	dword [device.bytes_tx + 4], 0
2320
	or	edi, eax
2268
 
-
 
2269
; program DPD
2321
 
2270
	and	[esi+dpd.next_ptr], 0
-
 
2271
	mov	eax, [esp+4]		; Tx buffer address
-
 
2272
	mov	[esi+dpd.realaddr], eax
-
 
2273
	call	GetPgAddr
Line 2322... Line -...
2322
	mov	eax, [esp+4]		; descriptor
-
 
2323
	DEBUGF	1,"Frag addr is: %x\n", edi
-
 
2324
	and	[eax+dpd.next_ptr], 0
2274
	mov	[esi+dpd.frag_addr], eax
2325
	mov	[eax+dpd.frag_addr], edi
2275
	mov	ecx, [esp+8]		; packet size
2326
 
2276
	or	ecx, 0x80000000 	; last fragment
2327
	mov	ecx, [esp+8+8]		; packet size
2277
	mov	[esi+dpd.frag_len], ecx
2328
	or	ecx, 0x80000000 	; last fragment
-
 
2329
	DEBUGF	1,"Frag size + flag is: %x\n", ecx
2278
 
Line -... Line 2279...
-
 
2279
	mov	ecx, [esp+8]		; packet size
Line 2330... Line 2280...
2330
	mov	[eax+dpd.frag_len], ecx
2280
;        or      ecx, 0x8000             ; transmission complete notification
2331
 
2281
 
2332
	mov	ecx, [esp+8+8]		; packet size
2282
	or	ecx, 1 shl 31
2333
	or	ecx, 0x8000		; transmission complete notification
-
 
2334
;        test    byte [device.has_hwcksm], 0xff
-
 
2335
;        jz      @f
2283
 
2336
;        or      ecx, (1 shl 26) ; set AddTcpChecksum
2284
;        test    byte [device.has_hwcksm], 0xff
Line 2337... Line -...
2337
;@@:
-
 
2338
	DEBUGF	1,"Frag start_hdr + flag is: %x\n", ecx
2285
;        jz      @f
-
 
2286
;        or      ecx, (1 shl 26)         ; set AddTcpChecksum
2339
	mov	[eax+dpd.frame_start_hdr], ecx
2287
;@@:
2340
 
2288
	mov	[esi+dpd.frame_start_hdr], ecx
2341
 
2289
 
2342
; calculate physical address
2290
	DEBUGF	1,"DPD: lin=%x phys=%x len=%x start hdr=%x\n", [esi+dpd.realaddr]:8, [esi+dpd.frag_addr]:8, [esi+dpd.frag_len]:8, [esi+dpd.frame_start_hdr]:8
2343
	mov	edi, eax
-
 
Line -... Line 2291...
-
 
2291
 
2344
	call	GetPgAddr
2292
; calculate physical address of dpd
2345
	and	edi, 4096 - 1
2293
	mov	eax, esi
2346
	or	eax, edi
2294
	GetRealAddr
2347
	cmp	[device.dn_list_ptr_cleared], 0
2295
	cmp	[device.dn_list_ptr_cleared], 0
2348
	jz	.add_to_list
2296
	jz	.add_to_list
2349
 
2297
 
2350
	DEBUGF	1,"DN list ptr: %x\n", eax
2298
; write Dn_List_Ptr
Line 2351... Line 2299...
2351
; write Dn_List_Ptr
2299
	DEBUGF	1,"DPD phys addr=%x\n", eax
2352
	set_io	0
-
 
2353
	set_io	REG_DN_LIST_PTR
2300
	set_io	0
2354
	out	dx, eax
2301
	set_io	REG_DN_LIST_PTR
2355
	jmp	.finish_pop
2302
	out	dx, eax
2356
.add_to_list:
2303
	jmp	.finish
2357
 
2304
 
Line 2374... Line 2321...
2374
	dec	ecx
2321
	dec	ecx
2375
	jnz	.wait_for_stall
2322
	jnz	.wait_for_stall
Line 2376... Line 2323...
2376
 
2323
 
2377
.dnstall_ok:
2324
  .dnstall_ok:
2378
	DEBUGF	1,"DnStall ok!\n"
-
 
2379
	mov	eax, [esp]		; prev_tx_frame
2325
	DEBUGF	1,"DnStall ok!\n"
2380
	mov	ecx, [device.prev_dpd]
2326
	mov	ecx, [device.prev_dpd]
Line 2381... Line 2327...
2381
	mov	[ecx+dpd.next_ptr], eax
2327
	mov	[ecx+dpd.next_ptr], eax
2382
 
2328
 
2383
	set_io	0
2329
	set_io	0
2384
	set_io	REG_DN_LIST_PTR
-
 
2385
	in	eax, dx
2330
	set_io	REG_DN_LIST_PTR
-
 
2331
	in	eax, dx
2386
 
2332
	test	eax, eax
-
 
2333
	pop	eax
2387
	test	eax, eax
2334
	jnz	.dnunstall
2388
	jnz	.dnunstall
2335
 
2389
; if Dn_List_Ptr has been cleared fill it up
-
 
2390
	DEBUGF	1,"DnList Ptr has been cleared\n"
2336
; if Dn_List_Ptr has been cleared fill it up
Line 2391... Line 2337...
2391
	mov	eax, [esp]
2337
	DEBUGF	1,"DnList Ptr has been cleared\n"
2392
	out	dx, eax
2338
	out	dx, eax
2393
 
2339
 
2394
.dnunstall:
2340
  .dnunstall:
2395
; DnUnStall
2341
; DnUnStall
2396
	set_io	0
2342
	set_io	0
Line 2397... Line -...
2397
	set_io	REG_COMMAND
-
 
2398
	mov	ax, ((110b shl 11)+3)
-
 
2399
	out	dx, ax
-
 
2400
 
-
 
2401
.finish_pop:
2343
	set_io	REG_COMMAND
-
 
2344
	mov	ax, ((110b shl 11)+3)
2402
	pop	[device.prev_tx_frame]
2345
	out	dx, ax
2403
	pop	[device.prev_dpd]
2346
 
-
 
2347
  .finish:
-
 
2348
	mov	[device.prev_dpd], esi
-
 
2349
	xor	eax, eax
-
 
2350
	ret	8
Line 2404... Line 2351...
2404
 
2351
 
2405
.finish:
2352
  .fail:
Line 2579... Line 2526...
2579
	test	ah, 0x80
2526
	test	ah, 0x80
2580
	jnz	.finish
2527
	jnz	.finish
Line 2581... Line 2528...
2581
 
2528
 
2582
  .read_frame:
2529
  .read_frame:
-
 
2530
; program buffer address to read in
2583
; program buffer address to read in
2531
	push	ecx
-
 
2532
	stdcall KernelAlloc, MAX_ETH_FRAME_SIZE
2584
	stdcall KernelAlloc, ecx ; Allocate a buffer to put packet into
2533
	pop	ecx
2585
	test	eax, eax
2534
	test	eax, eax
Line 2586... Line 2535...
2586
	jz	.finish
2535
	jz	.finish
2587
 
2536
 
Line 2670... Line 2619...
2670
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2619
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 2671... Line 2620...
2671
 
2620
 
2672
align 4
2621
align 4
Line 2673... Line 2622...
2673
int_boomerang:
2622
int_boomerang:
Line 2674... Line 2623...
2674
 
2623
 
Line 2675... Line 2624...
2675
;        DEBUGF  1,"\nIRQ %x Boomerang\n",eax:2
2624
	DEBUGF	1,"\nIRQ %x Boomerang\n",eax:2
2676
 
2625
 
Line 2677... Line -...
2677
; find pointer of device wich made IRQ occur
-
 
2678
 
2626
; find pointer of device wich made IRQ occur
2679
	mov	esi, BOOMERANG_LIST
2627
 
2680
	mov	ecx, [BOOMERANG_DEVICES]
2628
	mov	esi, BOOMERANG_LIST
2681
 
2629
	mov	ecx, [BOOMERANG_DEVICES]
Line 2703... Line 2651...
2703
	ret
2651
	ret
Line 2704... Line 2652...
2704
 
2652
 
Line 2705... Line 2653...
2705
.got_it:
2653
.got_it:
2706
 
-
 
2707
	DEBUGF	1,"Device: %x Status: %x ", ebx, eax
2654
 
2708
 
2655
	DEBUGF	1,"Device: %x Status: %x ", ebx, eax
Line 2709... Line 2656...
2709
	push	ax
2656
	push	ax
2710
; disable all INTS
2657
; disable all INTS
2711
 
2658
 
Line 2712... Line -...
2712
	set_io	REG_COMMAND
-
 
2713
	mov	ax, SetIntrEnb
-
 
2714
	out	dx, ax
-
 
2715
 
-
 
2716
;; acknowledge all int sources
-
 
2717
;
-
 
2718
;        mov     ax, word [esp]
-
 
2719
;        and     ax, 0xff
2659
	set_io	REG_COMMAND
2720
;        or      ax, AckIntr
2660
	mov	ax, SetIntrEnb
2721
;        out     dx, ax
2661
	out	dx, ax
Line 2722... Line 2662...
2722
 
2662
 
Line 2723... Line 2663...
2723
;--------------------------------------------------------------------------
2663
;--------------------------------------------------------------------------
2724
	test	word[esp], UpComplete
2664
	test	word[esp], UpComplete
Line 2725... Line 2665...
2725
	jz	.noRX
2665
	jz	.noRX
2726
 
2666
 
2727
	push	ebx
2667
	push	ebx
2728
 
2668
 
-
 
2669
  .receive:
2729
  .receive:
2670
	DEBUGF	1,"UpComplete\n"
2730
	DEBUGF	1,"UpComplete\n"
2671
 
2731
 
2672
; check if packet is uploaded
2732
; check if packet is uploaded
2673
	mov	esi, [device.curr_upd]
2733
	mov	eax, [device.curr_upd]
2674
	test	byte [esi+upd.pkt_status+1], 0x80 ; upPktComplete
2734
	test	byte [eax+upd.pkt_status+1], 0x80 ; upPktComplete
2675
	jz	.finish
2735
	jz	.finish
2676
	DEBUGF	1, "Current upd: %x\n", esi
2736
; packet is uploaded check for any error
2677
; packet is uploaded check for any error
2737
  .check_error:
2678
  .check_error:
2738
	test	byte [eax+upd.pkt_status+1], 0x40 ; upError
2679
	test	byte [esi+upd.pkt_status+1], 0x40 ; upError
2739
	jz	.copy_packet_length
-
 
2740
	DEBUGF	1,"Error in packet\n"
-
 
2741
	and	[eax+upd.pkt_status], 0 	  ; mark packet as read
-
 
2742
	jmp	.finish
-
 
Line -... Line 2680...
-
 
2680
	jz	.copy_packet_length
2743
  .copy_packet_length:
2681
	DEBUGF	1,"Error in packet\n"
2744
	mov	ecx, [eax+upd.pkt_status]
2682
	and	[esi+upd.pkt_status], 0 	  ; mark packet as read
-
 
2683
	jmp	.finish
-
 
2684
  .copy_packet_length:
Line 2745... Line -...
2745
	and	ecx, 0x1fff
-
 
2746
	cmp	ecx, MAX_ETH_PKT_SIZE
-
 
2747
	jbe	.copy_packet
-
 
2748
	and	[eax+upd.pkt_status], 0
2685
	mov	ecx, [esi+upd.pkt_status]
2749
	jmp	.finish
-
 
2750
 
-
 
2751
  .copy_packet:
-
 
Line 2752... Line 2686...
2752
	DEBUGF	1, " data hw addr:%x\n", [eax+upd.frag_addr]
2686
	and	ecx, 0x1fff
2753
 
2687
 
2754
	mov	esi, [eax+upd.realaddr]
2688
;        cmp     ecx, MAX_ETH_PKT_SIZE
2755
 
-
 
2756
	push	esi ecx
-
 
Line 2757... Line 2689...
2757
	stdcall KernelAlloc, ecx ; Allocate a buffer to put packet into
2689
;        jbe     .copy_packet
2758
	pop	ecx esi
2690
;        and     [esi+upd.pkt_status], 0
2759
	test	eax, eax
-
 
2760
	jz	.finish
2691
;        jmp     .finish
2761
 
2692
;  .copy_packet:
Line 2762... Line 2693...
2762
	push	dword .loop ;.finish
2693
 
2763
	push	ecx eax
2694
	DEBUGF	1, "Received %u bytes in buffer %x\n", ecx, [esi+upd.realaddr]:8
2764
	mov	edi, eax
-
 
2765
 
-
 
2766
	DEBUGF	1, " copying %u bytes from %x to %x\n", ecx, esi, edi
-
 
2767
 
2695
 
2768
; update statistics
-
 
2769
	inc	[device.packets_rx]
-
 
2770
 
-
 
2771
	add	dword [device.bytes_rx], ecx
2696
	push	dword .loop ;.finish
2772
	adc	dword [device.bytes_rx + 4], 0
-
 
2773
 
2697
	push	ecx
2774
; copy packet data
-
 
2775
	shr	cx , 1
2698
	push	[esi+upd.realaddr]
2776
	jnc	.nb
2699
 
2777
	movsb
-
 
2778
  .nb:
-
 
2779
	shr	cx , 1
-
 
2780
	jnc	.nw
-
 
Line -... Line 2700...
-
 
2700
; update statistics
-
 
2701
	inc	[device.packets_rx]
-
 
2702
	add	dword [device.bytes_rx], ecx
2781
	movsw
2703
	adc	dword [device.bytes_rx + 4], 0
-
 
2704
 
2782
  .nw:
2705
; update UPD (Alloc new buffer for next packet)
-
 
2706
	stdcall KernelAlloc, MAX_ETH_FRAME_SIZE
2783
	rep	movsd
2707
	mov	[esi + upd.realaddr], eax
2784
 
2708
	GetRealAddr
Line 2785... Line 2709...
2785
	mov	eax, [device.curr_upd]
2709
	mov	[esi + upd.frag_addr], eax
2786
	DEBUGF	1, "current upd: %x\n", eax
-
 
2787
	and	[eax + upd.pkt_status], 0	; clear the ring buffer entry for reuse
2710
	and	[esi + upd.pkt_status], 0
-
 
2711
	mov	[esi + upd.frag_len], MAX_ETH_FRAME_SIZE or (1 shl 31)
2788
	mov	[eax + upd.frag_len], MAX_ETH_FRAME_SIZE or (1 shl 31) ;;;
2712
 
2789
	add	eax, upd.size
2713
; Update UPD pointer
Line 2790... Line 2714...
2790
 
2714
	add	esi, upd.size
2791
	mov	ecx, [device.upd_buffer]
2715
	lea	ecx, [device.upd_buffer+(NUM_RX_DESC)*upd.size]
Line 2809... Line 2733...
2809
	set_io	0
2733
	set_io	0
2810
	set_io	REG_UP_PKT_STATUS
2734
	set_io	REG_UP_PKT_STATUS
2811
	in	eax, dx
2735
	in	eax, dx
2812
	test	ah, 0x20	     ; UpStalled
2736
	test	ah, 0x20	     ; UpStalled
2813
	jz	.noUpUnStall
2737
	jz	.noUpUnStall
-
 
2738
 
-
 
2739
	DEBUGF	1, "upUnStalling\n"
2814
; issue upUnStall command
2740
; issue upUnStall command
2815
	set_io	REG_COMMAND
2741
	set_io	REG_COMMAND
2816
	mov	ax, ((11b shl 12)+1) ; upUnStall
2742
	mov	ax, ((11b shl 12)+1) ; upUnStall
2817
	out	dx, ax
2743
	out	dx, ax
2818
	DEBUGF	1, "upUnStalling\n"
-
 
2819
  .noUpUnStall:
-
 
Line -... Line 2744...
-
 
2744
 
-
 
2745
	;;;; FIXME: make upunstall work
-
 
2746
 
2820
 
2747
  .noUpUnStall:
-
 
2748
.noRX:
-
 
2749
	test	word[esp], DownComplete
-
 
2750
	jz	.noTX
-
 
2751
	DEBUGF	1, "Downcomplete!\n"
-
 
2752
 
-
 
2753
	mov	ecx, NUM_TX_DESC
-
 
2754
	lea	esi, [device.dpd_buffer]
-
 
2755
  .txloop:
-
 
2756
	test	[esi+dpd.frame_start_hdr], 1 shl 31
-
 
2757
	jz	.maybenext
-
 
2758
 
-
 
2759
	and	[esi+dpd.frame_start_hdr], 0
-
 
2760
	push	ecx
-
 
2761
	stdcall KernelFree, [esi+dpd.realaddr]
-
 
2762
	pop	ecx
-
 
2763
 
-
 
2764
  .maybenext:
-
 
2765
	add	esi, dpd.size
-
 
2766
	dec	ecx
-
 
2767
	jnz	.txloop
-
 
2768
 
2821
.noRX:
2769
.noTX:
Line 2822... Line 2770...
2822
	pop	ax
2770
	pop	ax
2823
 
2771
 
2824
	set_io	0
2772
	set_io	0
2825
	set_io	REG_COMMAND
2773
	set_io	REG_COMMAND
Line 2826... Line -...
2826
	or	ax, AckIntr
-
 
2827
	out	dx, ax
-
 
2828
 
-
 
2829
    ;    set_io  REG_COMMAND
-
 
2830
    ;    mov     ax, AckIntr + IntLatch
-
 
2831
    ;    out     dx, ax
2774
	or	ax, AckIntr
2832
 
2775
	out	dx, ax
2833
 
2776
 
2834
	set_io	REG_INT_STATUS
2777
	set_io	REG_INT_STATUS
Line 2835... Line 2778...
2835
	in	ax, dx
2778
	in	ax, dx
2836
	test	ax, S_5_INTS
2779
	test	ax, S_5_INTS
2837
	jnz	.got_it
2780
	jnz	.got_it
2838
 
2781
 
Line 2839... Line -...
2839
;re-enable ints
-
 
2840
	set_io	REG_COMMAND
2782
;re-enable ints
Line 2841... Line 2783...
2841
	mov	ax, SetIntrEnb + S_5_INTS
2783
	set_io	REG_COMMAND
2842
	out	dx, ax
-
 
2843
 
2784
	mov	ax, SetIntrEnb + S_5_INTS
Line 2844... Line -...
2844
 
-
 
2845
	ret
-
 
2846
 
2785
	out	dx, ax
2847
 
2786
 
2848
 
2787
	ret
2849
 
2788
 
2850
; End of code
2789
 
Line 2864... Line 2803...
2864
	label db string, 0
2803
	label db string, 0
2865
}
2804
}
Line 2866... Line 2805...
2866
 
2805
 
2867
VORTEX_DEVICES	     dd 0
2806
VORTEX_DEVICES	     dd 0
2868
BOOMERANG_DEVICES    dd 0
2807
BOOMERANG_DEVICES    dd 0
2869
version 	     dd (5 shl 16) or (API_VERSION and 0xFFFF)
2808
version 	     dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)
Line 2870... Line 2809...
2870
my_service	     db '3C59X',0		     ; max 16 chars include zero
2809
my_service	     db '3C59X',0		     ; max 16 chars include zero
2871
 
2810
 
Line 2999... Line 2938...
2999
; 3c905B-T4
2938
; 3c905B-T4
3000
dw 0x9210, IS_TORNADO or HAS_NWAY or HAS_HWCKSM
2939
dw 0x9210, IS_TORNADO or HAS_NWAY or HAS_HWCKSM
3001
; 3c920B-EMB-WNM Tornado
2940
; 3c920B-EMB-WNM Tornado
3002
HW_VERSIONS_SIZE = $ - hw_versions
2941
HW_VERSIONS_SIZE = $ - hw_versions
Line 3003... Line -...
3003
 
-
 
3004
 
2942
 
Line 3005... Line 2943...
3005
include_debug_strings				; All data wich FDO uses will be included here
2943
include_debug_strings				; All data wich FDO uses will be included here
Line 3006... Line 2944...
3006
 
2944