Subversion Repositories Kolibri OS

Rev

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

Rev 1377 Rev 1472
Line 19... Line 19...
19
 
19
 
Line 20... Line 20...
20
	API_VERSION		equ 0x01000100
20
	API_VERSION		equ 0x01000100
21
 
21
 
22
	DEBUG			equ 1
22
	DEBUG			equ 1
Line 23... Line 23...
23
	__DEBUG__		equ 1
23
	__DEBUG__		equ 1
24
	__DEBUG_LEVEL__ 	equ 1
24
	__DEBUG_LEVEL__ 	equ 2
25
 
25
 
-
 
26
include 'proc32.inc'
Line 26... Line 27...
26
include 'proc32.inc'
27
include 'imports.inc'
27
include 'imports.inc'
28
include 'fdo.inc'
28
include 'fdo.inc'
29
include 'netdrv.inc'
Line 29... Line 30...
29
 
30
 
30
OS_BASE 	equ 0;
31
OS_BASE 	equ 0;
31
new_app_base	equ 0x60400000
32
new_app_base	equ 0x60400000
Line 32... Line -...
32
PROC_BASE	equ OS_BASE+0x0080000
-
 
33
 
-
 
34
public START
-
 
35
public service_proc
-
 
36
public version
-
 
37
 
-
 
38
struc IOCTL {
-
 
39
      .handle		dd ?
-
 
40
      .io_code		dd ?
-
 
41
      .input		dd ?
-
 
42
      .inp_size 	dd ?
-
 
43
      .output		dd ?
-
 
Line 44... Line 33...
44
      .out_size 	dd ?
33
PROC_BASE	equ OS_BASE+0x0080000
45
}
34
 
46
 
35
public START
47
virtual at 0
36
public service_proc
Line 73... Line 62...
73
      .curr_tx_desc	db ?
62
      .curr_tx_desc	db ?
74
      .pci_bus		db ?
63
      .pci_bus		db ?
75
      .pci_dev		db ?
64
      .pci_dev		db ?
76
      .irq_line 	db ?
65
      .irq_line 	db ?
77
      .hw_ver_id	db ?
66
      .hw_ver_id	db ?
-
 
67
 
78
      .size:
68
      .size = $ - device
Line 79... Line 69...
79
 
69
 
Line 80... Line 70...
80
}
70
}
81
 
71
 
82
virtual at 0
72
virtual at ebx
Line 83... Line -...
83
  device ETH_DEVICE
-
 
84
end virtual
-
 
85
 
-
 
86
; PCI Bus defines
-
 
87
 
-
 
88
	PCI_HEADER_TYPE 		equ	0x0e  ;8 bit
-
 
89
	PCI_BASE_ADDRESS_0		equ	0x10  ;32 bit
-
 
90
	PCI_BASE_ADDRESS_5		equ	0x24  ;32 bits
-
 
91
	PCI_BASE_ADDRESS_SPACE_IO	equ	0x01
-
 
92
	PCI_VENDOR_ID			equ	0x00  ;16 bit
73
  device ETH_DEVICE
Line 93... Line 74...
93
	PCI_BASE_ADDRESS_IO_MASK	equ	0xFFFFFFFC
74
end virtual
94
 
75
 
Line 192... Line 173...
192
 
173
 
193
	RX_CONFIG		equ (RBLEN shl BIT_RBLEN) or \
174
	RX_CONFIG		equ (RBLEN shl BIT_RBLEN) or \
194
				    (RX_MXDMA shl BIT_RX_MXDMA) or \
175
				    (RX_MXDMA shl BIT_RX_MXDMA) or \
195
				    (1 shl BIT_NOWRAP) or \
176
				    (1 shl BIT_NOWRAP) or \
196
				    (RXFTH shl BIT_RXFTH) or\
177
				    (RXFTH shl BIT_RXFTH) or\
197
				    (1 shl BIT_AB) or \
178
				    (1 shl BIT_AB) or \ 		; Accept broadcast packets
198
				    (1 shl BIT_APM) or \
179
				    (1 shl BIT_APM) or \		; Accept physical match packets
199
				    (1 shl BIT_AER) or \
180
				    (1 shl BIT_AER) or \		; Accept error packets
200
				    (1 shl BIT_AR) or \
181
				    (1 shl BIT_AR) or \ 		; Accept Runt packets (smaller then 64 bytes)
Line 201... Line 182...
201
				    (1 shl BIT_AM)
182
				    (1 shl BIT_AM)			; Accept multicast packets
202
 
183
 
203
	RX_BUFFER_SIZE		equ (8192 shl RBLEN)
184
	RX_BUFFER_SIZE		equ (8192 shl RBLEN);+16
204
	MAX_ETH_FRAME_SIZE	equ 1516 ; exactly 1514 wthout CRC
185
	MAX_ETH_FRAME_SIZE	equ 1516 ; exactly 1514 wthout CRC
Line 205... Line 186...
205
	NUM_TX_DESC		equ 4
186
	NUM_TX_DESC		equ 4
Line 277... Line 258...
277
	cmp [state], 1
258
	cmp [state], 1
278
	jne .exit
259
	jne .exit
Line 279... Line 260...
279
 
260
 
Line 280... Line 261...
280
  .entry:
261
  .entry:
281
 
262
 
282
	DEBUGF 1,"Loading rtl8139 driver\n"
263
	DEBUGF	2,"Loading rtl8139 driver\n"
Line 283... Line 264...
283
	stdcall RegService, my_service, service_proc
264
	stdcall RegService, my_service, service_proc
284
	ret
265
	ret
Line 300... Line 281...
300
 
281
 
301
align 4
282
align 4
Line 302... Line 283...
302
proc service_proc stdcall, ioctl:dword
283
proc service_proc stdcall, ioctl:dword
-
 
284
 
-
 
285
	mov	edx, [ioctl]
-
 
286
 
303
 
287
	mov	eax, [IOCTL.io_code]
-
 
288
=======
Line 304... Line 289...
304
	mov	edx, [ioctl]
289
	mov	eax, [edx+IOCTL.io_code]
Line 305... Line 290...
305
	mov	eax, [edx+IOCTL.io_code]
290
>>>>>>> .r1471
306
 
291
 
Line 307... Line 292...
307
;------------------------------------------------------
292
;------------------------------------------------------
308
 
293
 
309
	cmp	eax, 0 ;SRV_GETVERSION
294
	cmp	eax, 0 ;SRV_GETVERSION
310
	jne	@F
295
	jne	@F
Line 311... Line 296...
311
 
296
 
312
	cmp	[edx+IOCTL.out_size], 4
297
	cmp	[IOCTL.out_size], 4
Line 313... Line 298...
313
	jl	.fail
298
	jl	.fail
314
	mov	eax, [edx+IOCTL.output]
299
	mov	eax, [IOCTL.output]
315
	mov	[eax], dword API_VERSION
300
	mov	[eax], dword API_VERSION
316
 
301
 
Line 317... Line 302...
317
	xor	eax, eax
302
	xor	eax, eax
318
	ret
303
	ret
Line 319... Line 304...
319
 
304
 
320
;------------------------------------------------------
305
;------------------------------------------------------
321
  @@:
306
  @@:
Line 322... Line 307...
322
	cmp	eax, 1 ;SRV_HOOK
307
	cmp	eax, 1 ;SRV_HOOK
Line 323... Line 308...
323
	jne	.fail
308
	jne	.fail
324
 
309
 
325
	cmp	[edx + IOCTL.inp_size], 3		; Data input must be at least 3 bytes
310
	cmp	[IOCTL.inp_size], 3		  ; Data input must be at least 3 bytes
326
	jl	.fail
311
	jl	.fail
-
 
312
 
327
 
313
	mov	eax, [IOCTL.input]
328
	mov	eax, [edx + IOCTL.input]
314
	cmp	byte [eax], 1				; 1 means device number and bus number (pci) are given
329
	cmp	byte [eax], 1				; 1 means device number and bus number (pci) are given
315
	jne	.fail					; other types arent supported for this card yet
330
	jne	.fail					; other types arent supported for this card yet
316
 
331
 
317
; check if the device is already listed
332
; check if the device is already listed
318
 
333
 
319
	mov	esi, RTL8139_LIST
334
	mov	esi, RTL8139_LIST
320
	mov	ecx, [RTL8139_DEV]
Line -... Line 321...
-
 
321
	test	ecx, ecx
335
	mov	ecx, [RTL8139_DEV]
322
	jz	.firstdevice
336
	test	ecx, ecx
323
 
337
	jz	.firstdevice
324
;        mov     eax, [IOCTL.input]                      ; get the pci bus and device numbers
338
;        mov     eax, [edx+IOCTL.input]                  ; get the pci bus and device numbers
325
	mov	ax , [eax+1]				;
Line 356... Line 343...
356
	jz	.fail
343
	jz	.fail
357
	mov	ebx, eax				; ebx is always used as a pointer to the structure (in driver, but also in kernel code)
344
	mov	ebx, eax				; ebx is always used as a pointer to the structure (in driver, but also in kernel code)
Line 358... Line 345...
358
 
345
 
Line 359... Line 346...
359
; Fill in the direct call addresses into the struct
346
; Fill in the direct call addresses into the struct
360
 
347
 
361
	mov	dword [ebx+device.reset], reset
348
	mov	dword [device.reset], reset
362
	mov	dword [ebx+device.transmit], transmit
349
	mov	dword [device.transmit], transmit
363
	mov	dword [ebx+device.get_MAC], read_mac
350
	mov	dword [device.get_MAC], read_mac
364
	mov	dword [ebx+device.set_MAC], write_mac
351
	mov	dword [device.set_MAC], write_mac
Line 365... Line 352...
365
	mov	dword [ebx+device.unload], unload
352
	mov	dword [device.unload], unload
Line 366... Line 353...
366
	mov	dword [ebx+device.name], my_service
353
	mov	dword [device.name], my_service
367
 
354
 
368
; save the pci bus and device numbers
355
; save the pci bus and device numbers
369
 
356
 
370
	mov	eax, [edx+IOCTL.input]
357
	mov	eax, [IOCTL.input]
Line 371... Line 358...
371
	mov	cl , [eax+1]
358
	mov	cl , [eax+1]
372
	mov	[ebx+device.pci_bus], cl
359
	mov	[device.pci_bus], cl
Line 373... Line -...
373
	mov	cl , [eax+2]
-
 
374
	mov	[ebx+device.pci_dev], cl
-
 
375
 
-
 
376
; Now, it's time to find the base io addres of the PCI device
-
 
377
; TODO: implement check if bus and dev exist on this machine
-
 
378
 
-
 
379
	mov	edx, PCI_BASE_ADDRESS_0
-
 
380
  .reg_check:
-
 
381
	movzx	eax, byte [ebx+device.pci_bus]
-
 
382
	movzx	ecx, byte [ebx+device.pci_dev]
-
 
383
 
-
 
384
	push	edx ecx
-
 
385
	stdcall PciRead16, eax ,ecx ,edx
-
 
386
	pop	ecx edx
360
	mov	cl , [eax+2]
387
 
-
 
388
	mov	[ebx+device.io_addr], eax
-
 
389
	and	eax, PCI_BASE_ADDRESS_IO_MASK
-
 
390
	test	eax, eax
-
 
391
	jz	.inc_reg
-
 
392
	mov	eax, [ebx+device.io_addr]
-
 
393
	and	eax, PCI_BASE_ADDRESS_SPACE_IO
-
 
394
	test	eax, eax
-
 
395
	jz	.inc_reg
-
 
396
 
-
 
397
	mov	eax, [ebx+device.io_addr]
-
 
398
	and	eax, PCI_BASE_ADDRESS_IO_MASK
-
 
399
	mov	[ebx+device.io_addr], eax
-
 
400
	jmp	.got_io
-
 
401
 
-
 
Line 402... Line 361...
402
  .inc_reg:
361
	mov	[device.pci_dev], cl
Line 403... Line 362...
403
	add	edx, 4
362
 
404
	cmp	edx, PCI_BASE_ADDRESS_5
363
; Now, it's time to find the base io addres of the PCI device
405
	jbe	.reg_check
364
; TODO: implement check if bus and dev exist on this machine
406
 
365
 
407
  .got_io:
366
	find_io [device.pci_bus], [device.pci_dev], [device.io_addr]
408
 
367
 
409
; We've found the io address, find IRQ now
-
 
410
 
-
 
411
	movzx	eax, byte [ebx+device.pci_bus]
-
 
Line 412... Line 368...
412
	movzx	ecx, byte [ebx+device.pci_dev]
368
; We've found the io address, find IRQ now
-
 
369
 
Line 413... Line -...
413
	push	ebx
-
 
414
	stdcall PciRead8, eax ,ecx ,0x3c				; 0x3c is the offset where irq can be found
-
 
415
	pop	ebx
-
 
416
	mov	byte [ebx+device.irq_line], al
-
 
417
 
-
 
418
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
-
 
419
	[ebx+device.pci_dev]:1,[ebx+device.pci_bus]:1,[ebx+device.irq_line]:1,[ebx+device.io_addr]:4
-
 
420
 
-
 
421
; Allocate the Receive buffer
-
 
422
 
-
 
423
	stdcall KernelAlloc, dword (RX_BUFFER_SIZE+MAX_ETH_FRAME_SIZE)
-
 
424
	test	eax, eax
-
 
Line 425... Line -...
425
	jz	.err
-
 
426
	mov	[ebx+device.rx_buffer], eax				; Save the address to it into the device struct
-
 
427
 
370
	movzx	eax, byte [device.pci_bus]
428
; Now, Clear the allocated buffer
-
 
429
 
-
 
430
	cld
-
 
431
	mov	edi, eax
-
 
432
	mov	ecx, (RX_BUFFER_SIZE)/4 				; divide by 4 because we are going to use DWORD
-
 
433
	xor	eax, eax
-
 
434
	rep	stosd
-
 
435
 
371
	movzx	ecx, byte [device.pci_dev]
436
; Allocate the Transmit Buffer
-
 
437
 
-
 
Line 438... Line 372...
438
	stdcall KernelAlloc, dword (TX_BUF_SIZE*NUM_TX_DESC)
372
	push	ebx
Line 439... Line 373...
439
	test	eax, eax
373
	stdcall PciRead8, eax ,ecx ,0x3c				; 0x3c is the offset where irq can be found
440
	jz	.err
374
	pop	ebx
Line 465... Line 399...
465
	ret
399
	ret
Line 466... Line 400...
466
 
400
 
Line 467... Line 401...
467
; If the device was already loaded, find the device number and return it in eax
401
; If the device was already loaded, find the device number and return it in eax
468
 
402
 
469
  .find_devicenum:
403
  .find_devicenum:
470
	DEBUGF	1,"Trying to find device number of already registered device\n"
404
	DEBUGF	2,"Trying to find device number of already registered device\n"
471
	mov	ebx, eax
405
	mov	ebx, eax
472
	call	EthStruc2Dev						; This kernel procedure converts a pointer to device struct in ebx
406
	call	EthStruc2Dev						; This kernel procedure converts a pointer to device struct in ebx
473
									; into a device number in edi
407
									; into a device number in edi
474
	mov	eax, edi						; Application wants it in eax instead
408
	mov	eax, edi						; Application wants it in eax instead
Line 475... Line 409...
475
	DEBUGF	1,"Kernel says: %u\n", eax
409
	DEBUGF	2,"Kernel says: %u\n", eax
Line 476... Line 410...
476
	ret
410
	ret
477
 
411
 
Line 478... Line 412...
478
; If an error occured, remove all allocated data and exit (returning -1 in eax)
412
; If an error occured, remove all allocated data and exit (returning -1 in eax)
479
 
413
 
480
  .destroy:
414
  .destroy:
481
	; todo: reset device into virgin state
415
	; todo: reset device into virgin state
Line 482... Line 416...
482
 
416
 
483
  .err:
417
  .err:
Line 523... Line 457...
523
 
457
 
524
align 4
458
align 4
525
probe:
459
probe:
Line 526... Line -...
526
	DEBUGF	2,"Probing rtl8139 device: "
-
 
527
 
-
 
528
; enable the device
-
 
529
 
460
	DEBUGF	2,"Probing rtl8139 device: "
530
	movzx	eax, byte [ebx+device.pci_bus]
-
 
531
	movzx	ecx, byte [ebx+device.pci_dev]
-
 
532
	stdcall PciRead32, eax ,ecx ,PCI_REG_CMD
-
 
533
 
-
 
534
	mov	cx , ax
-
 
535
	or	cl , (1 shl PCI_BIT_MASTER) or (1 shl PCI_BIT_PIO)
-
 
536
	and	cl , not (1 shl PCI_BIT_MMIO)
-
 
537
	movzx	eax, byte [ebx+device.pci_bus]
-
 
Line 538... Line 461...
538
	movzx	edx, byte [ebx+device.pci_dev]
461
 
Line 539... Line 462...
539
	stdcall PciWrite32, eax ,edx ,PCI_REG_CMD, ecx
462
	make_bus_master [device.pci_bus], [device.pci_dev]
540
 
463
 
541
; get chip version
464
; get chip version
542
 
465
 
543
	mov	edx, [ebx+device.io_addr]
466
	set_io	0
544
	add	edx, REG_TXCONFIG + 2
467
	set_io	REG_TXCONFIG + 2
545
	in	ax , dx
468
	in	ax , dx
Line 552... Line 475...
552
	je	.chip_ver_found
475
	je	.chip_ver_found
553
	dec	ecx
476
	dec	ecx
554
	jns	.chip_ver_loop
477
	jns	.chip_ver_loop
555
	xor	cl , cl ; default RTL8139
478
	xor	cl , cl ; default RTL8139
556
  .chip_ver_found:
479
  .chip_ver_found:
557
	mov	[ebx+device.hw_ver_id], cl
480
	mov	[device.hw_ver_id], cl
Line 558... Line 481...
558
 
481
 
559
	shl	ecx, 2
482
	shl	ecx, 2
560
	add	ecx, name_crosslist
483
	add	ecx, crosslist
561
	mov	ecx, [ecx]
484
	mov	ecx, [ecx]
Line 562... Line 485...
562
	mov	dword [ebx+device.name], ecx
485
	mov	[device.name], ecx
Line 563... Line 486...
563
 
486
 
Line 564... Line 487...
564
	DEBUGF	1,"Chip version: %s\n",ecx
487
	DEBUGF	2,"Chip version: %s\n",ecx
565
 
488
 
566
; wake up the chip
489
; wake up the chip
567
 
490
 
Line 568... Line 491...
568
	mov	edx, [ebx+device.io_addr]
491
	set_io	0
Line 569... Line 492...
569
	add	edx, REG_HLTCLK
492
	set_io	REG_HLTCLK
570
	mov	al , 'R' ; run the clock
493
	mov	al , 'R' ; run the clock
571
	out	dx , al
494
	out	dx , al
Line 572... Line 495...
572
 
495
 
Line 573... Line 496...
573
; unlock config and BMCR registers
496
; unlock config and BMCR registers
574
 
497
 
575
	add	edx, REG_9346CR - REG_HLTCLK
498
	set_io	REG_9346CR
576
	mov	al , (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
499
	mov	al , (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
Line 577... Line 500...
577
	out	dx , al
500
	out	dx , al
578
 
501
 
579
; enable power management
502
; enable power management
580
 
503
 
Line 581... Line 504...
581
	add	edx, REG_CONFIG1 - REG_9346CR
504
	set_io	REG_CONFIG1
582
	in	al , dx
505
	in	al , dx
583
	cmp	byte [ebx+device.hw_ver_id], IDX_RTL8139B
506
	cmp	[device.hw_ver_id], IDX_RTL8139B
-
 
507
	jl	.old_chip
584
	jl	.old_chip
508
 
585
 
509
; set LWAKE pin to active high (default value).
586
; set LWAKE pin to active high (default value).
510
; it is for Wake-On-LAN functionality of some motherboards.
587
; it is for Wake-On-LAN functionality of some motherboards.
511
; this signal is used to inform the motherboard to execute a wake-up process.
-
 
512
; only at newer chips.
588
; this signal is used to inform the motherboard to execute a wake-up process.
513
 
589
; only at newer chips.
514
	or	al , (1 shl BIT_PMEn)
Line 590... Line 515...
590
 
515
	and	al , not (1 shl BIT_LWACT)
Line 605... Line 530...
605
  .finish_wake_up:
530
  .finish_wake_up:
Line 606... Line 531...
606
 
531
 
Line 607... Line 532...
607
; lock config and BMCR registers
532
; lock config and BMCR registers
608
 
533
 
609
	xor	al , al
534
	xor	al , al
610
	mov	edx, [ebx+device.io_addr]
535
	set_io	0
611
	add	edx, REG_9346CR
536
	set_io	REG_9346CR
Line 612... Line 537...
612
	out	dx , al
537
	out	dx , al
Line 622... Line 547...
622
reset:
547
reset:
623
	DEBUGF	2,"Resetting rtl8139: "
548
	DEBUGF	2,"Resetting rtl8139: "
Line 624... Line 549...
624
 
549
 
Line 625... Line 550...
625
; attach int handler
550
; attach int handler
626
 
551
 
627
	movzx	eax, [ebx+device.irq_line]
552
	movzx	eax, [device.irq_line]
628
	DEBUGF	1,"Attaching int handler to irq %x, ",eax:1
553
	DEBUGF	1,"Attaching int handler to irq %x, ",eax:1
629
	stdcall AttachIntHandler, eax, int_handler, dword 0
554
	stdcall AttachIntHandler, eax, int_handler, dword 0
630
	test	eax, eax
555
	test	eax, eax
Line 635... Line 560...
635
  @@:
560
  @@:
Line 636... Line 561...
636
 
561
 
Line 637... Line 562...
637
; reset chip
562
; reset chip
638
 
563
 
639
	DEBUGF	1,"Resetting chip\n"
564
	DEBUGF	1,"Resetting chip\n"
640
	mov	edx, [ebx+device.io_addr]
565
	set_io	0
641
	add	edx, REG_COMMAND
566
	set_io	REG_COMMAND
642
	mov	al , 1 shl BIT_RST
567
	mov	al , 1 shl BIT_RST
643
	out	dx , al
568
	out	dx , al
644
	mov	cx , 1000		; wait no longer for the reset
569
	mov	cx , 1000		; wait no longer for the reset
Line 650... Line 575...
650
	jns	.wait_for_reset
575
	jns	.wait_for_reset
651
  .reset_completed:
576
  .reset_completed:
Line 652... Line 577...
652
 
577
 
Line 653... Line -...
653
; unlock config and BMCR registers
-
 
654
 
578
; unlock config and BMCR registers
655
	mov	edx, [ebx+device.io_addr]
579
 
656
	add	edx, REG_9346CR
580
	set_io	REG_9346CR
Line 657... Line 581...
657
	mov	al , (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
581
	mov	al , (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EEM0)
Line 658... Line 582...
658
	out	dx , al
582
	out	dx , al
659
 
583
 
660
; initialize multicast registers (no filtering)
584
; initialize multicast registers (no filtering)
661
 
585
 
662
	mov	eax, 0xffffffff
586
	mov	eax, 0xffffffff
Line 663... Line 587...
663
	add	edx, REG_MAR0 - REG_9346CR
587
	set_io	REG_MAR0
Line 664... Line 588...
664
	out	dx , eax
588
	out	dx , eax
665
	add	edx, REG_MAR4 - REG_MAR0
589
	set_io	REG_MAR4
666
	out	dx , eax
590
	out	dx , eax
Line 667... Line 591...
667
 
591
 
668
; enable Rx/Tx
592
; enable Rx/Tx
Line 669... Line 593...
669
 
593
 
670
	mov	al , (1 shl BIT_RE) or (1 shl BIT_TE)
594
	mov	al , (1 shl BIT_RE) or (1 shl BIT_TE)
671
	add	edx, REG_COMMAND - REG_MAR4
595
	set_io	REG_COMMAND
Line -... Line 596...
-
 
596
	out	dx , al
672
	out	dx , al
597
 
Line 673... Line 598...
673
 
598
; 32k Rxbuffer, unlimited dma burst, no wrapping, no rx threshold
674
; 32k Rxbuffer, unlimited dma burst, no wrapping, no rx threshold
599
; accept broadcast packets, accept physical match packets
675
; accept broadcast packets, accept physical match packets
600
 
Line 676... Line 601...
676
 
601
	mov	ax , RX_CONFIG
Line 677... Line 602...
677
	mov	ax , RX_CONFIG
602
	set_io	REG_RXCONFIG
678
	add	edx, REG_RXCONFIG - REG_COMMAND
603
	out	dx , ax
679
	out	dx , ax
604
 
680
 
605
 
Line 681... Line 606...
681
; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144
606
; 1024 bytes DMA burst, total retries = 16 + 8 * 16 = 144
Line 682... Line 607...
682
 
607
 
683
	mov	eax , (TX_MXDMA shl BIT_TX_MXDMA) or (TXRR shl BIT_TXRR) or BIT_IFG1 or BIT_IFG0
608
	mov	eax , (TX_MXDMA shl BIT_TX_MXDMA) or (TXRR shl BIT_TXRR) or BIT_IFG1 or BIT_IFG0
684
	add	edx, REG_TXCONFIG - REG_RXCONFIG
609
	set_io	REG_TXCONFIG
685
	out	dx , eax
610
	out	dx , eax
Line 686... Line 611...
686
 
611
 
Line 687... Line 612...
687
; enable auto negotiation
612
; enable auto negotiation
688
 
613
 
689
	add	edx, REG_BMCR - REG_TXCONFIG
614
	set_io	REG_BMCR
Line 690... Line 615...
690
	in	ax , dx
615
	in	ax , dx
Line 691... Line 616...
691
	or	ax , (1 shl BIT_ANE)
616
	or	ax , (1 shl BIT_ANE)
692
	out	dx , ax
617
	out	dx , ax
Line 693... Line 618...
693
 
618
 
Line 694... Line 619...
694
; set auto negotiation advertisement
619
; set auto negotiation advertisement
695
 
620
 
696
	add	edx, REG_ANAR - REG_BMCR
621
	set_io	REG_ANAR
Line 697... Line 622...
697
	in	ax , dx
622
	in	ax , dx
Line 698... Line 623...
698
	or	ax , (1 shl BIT_SELECTOR) or (1 shl BIT_10) or (1 shl BIT_10FD) or (1 shl BIT_TX) or (1 shl BIT_TXFD)
623
	or	ax , (1 shl BIT_SELECTOR) or (1 shl BIT_10) or (1 shl BIT_10FD) or (1 shl BIT_TX) or (1 shl BIT_TXFD)
699
	out	dx , ax
624
	out	dx , ax
Line 700... Line 625...
700
 
625
 
Line 701... Line 626...
701
; lock config and BMCR registers
626
; lock config and BMCR registers
702
 
627
 
703
	xor	eax, eax
628
	xor	eax, eax
704
	add	edx, REG_9346CR - REG_ANAR
629
	set_io	REG_9346CR
705
	out	dx , al
630
	out	dx , al
706
 
631
 
707
; init RX/TX pointers
632
; init RX/TX pointers
708
 
633
 
709
	mov	[ebx+device.rx_data_offset], eax
634
	mov	[device.rx_data_offset], eax
710
	mov	[ebx+device.curr_tx_desc], al
635
	mov	[device.curr_tx_desc], al
711
 
636
 
712
; clear packet/byte counters
637
; clear packet/byte counters
Line 713... Line 638...
713
 
638
 
Line 714... Line 639...
714
	lea	edi, [ebx+device.bytes_tx] ; TODO: check if destroying edi, ecx doesnt harm anything
639
	lea	edi, [device.bytes_tx]
715
	mov	ecx, 6
640
	mov	ecx, 6
716
	rep	stosd
641
	rep	stosd
717
 
642
 
718
; clear missing packet counter
643
; clear missing packet counter
Line 719... Line 644...
719
 
644
 
Line 720... Line 645...
720
	add	edx, REG_MPC - REG_9346CR
645
	set_io	REG_MPC
721
	out	dx , eax
646
	out	dx , eax
722
 
647
 
Line 723... Line 648...
723
; Set up the 4 Txbuffer descriptors
648
; Set up the 4 Txbuffer descriptors
Line 724... Line 649...
724
 
649
 
Line 784... Line 709...
784
	jg	.finish 			; packet is too long
709
	jg	.finish 			; packet is too long
785
	cmp	dword [esp+8], 60
710
	cmp	dword [esp+8], 60
786
	jl	.finish 			; packet is too short
711
	jl	.finish 			; packet is too short
Line 787... Line 712...
787
 
712
 
788
; check descriptor
713
; check descriptor
789
;        DEBUGF  1,"Checking descriptor, "
714
	DEBUGF	1,"Checking descriptor, "
790
	movzx	ecx, [ebx+device.curr_tx_desc]
715
	movzx	ecx, [device.curr_tx_desc]
791
	mov	edx, [ebx+device.io_addr]
716
	mov	edx, [device.io_addr]
792
	lea	edx, [edx+ecx*4+REG_TSD0]
717
	lea	edx, [edx+ecx*4+REG_TSD0]
793
	in	ax, dx
718
	in	ax, dx
794
	test	ax, 0x1fff ; or no size given
719
	test	ax, 0x1fff ; or no size given
795
	jz	.send_packet
720
	jz	.send_packet
796
	and	ax, (1 shl BIT_TOK) or (1 shl BIT_OWN)
721
	and	ax, (1 shl BIT_TOK) or (1 shl BIT_OWN)
797
	cmp	ax, (1 shl BIT_TOK) or (1 shl BIT_OWN)
722
	cmp	ax, (1 shl BIT_TOK) or (1 shl BIT_OWN)
798
	jz	.send_packet
723
	jz	.send_packet
799
; wait for timeout
724
; wait for timeout
Line 800... Line 725...
800
;        DEBUGF  1,"Waiting for timeout, "
725
	DEBUGF	1,"Waiting for timeout, "
801
 
726
 
802
	push	edx ebx 			 ; TODO : rtl8139 internal timer should be used instead
727
	push	edx ebx 			 ; TODO : rtl8139 internal timer should be used instead
Line 809... Line 734...
809
	jz	.send_packet			 ; if chip hung, reset it
734
	jz	.send_packet			 ; if chip hung, reset it
810
	push	dx
735
	push	dx
811
	call	reset				 ; reset the card
736
	call	reset				 ; reset the card
812
	pop	dx
737
	pop	dx
813
.send_packet:
738
.send_packet:
814
;        DEBUGF  1,"Sending packet, "
739
	DEBUGF	1,"Sending packet, "
Line 815... Line 740...
815
 
740
 
816
	push	edx
741
	push	edx
817
	movzx	eax, [ebx+device.curr_tx_desc]	 ; calculate the current tx_buffer address
742
	movzx	eax, [device.curr_tx_desc]   ; calculate the current tx_buffer address
818
	mov	edx, TX_BUF_SIZE ;MAX_ETH_FRAME_SIZE          ;
743
	mov	edx, TX_BUF_SIZE ;MAX_ETH_FRAME_SIZE          ;
819
	mul	edx				 ;
744
	mul	edx				 ;
820
	mov	edi, [ebx+device.tx_buffer]	 ;
745
	mov	edi, [device.tx_buffer]      ;
821
	add	edi, eax			 ; Store it in edi
746
	add	edi, eax			 ; Store it in edi
Line 822... Line 747...
822
	pop	edx
747
	pop	edx
823
 
748
 
Line 827... Line 752...
827
	rep	movsd				 ;
752
	rep	movsd				 ;
828
	mov	ecx, [esp+8]			 ;
753
	mov	ecx, [esp+8]			 ;
829
	and	ecx, 3				 ;
754
	and	ecx, 3				 ;
830
	rep	movsb				 ;
755
	rep	movsb				 ;
Line 831... Line 756...
831
 
756
 
832
	inc	[ebx+device.packets_tx] 	 ;
757
	inc	[device.packets_tx]	     ;
Line 833... Line 758...
833
	mov	eax, [esp+8]			 ; Get packet size in eax
758
	mov	eax, [esp+8]			 ; Get packet size in eax
834
 
759
 
Line 835... Line 760...
835
	add	dword [ebx + device.bytes_tx], eax
760
	add	dword [device.bytes_tx], eax
836
	adc	dword [ebx + device.bytes_tx + 4], 0
761
	adc	dword [device.bytes_tx + 4], 0
Line 837... Line 762...
837
 
762
 
838
;        or      eax, (ERTXTH shl BIT_ERTXTH)     ; Set descriptor size and the early tx treshold into the correct Transmission status register (TSD0, TSD1, TSD2 or TSD3)
763
;        or      eax, (ERTXTH shl BIT_ERTXTH)     ; Set descriptor size and the early tx treshold into the correct Transmission status register (TSD0, TSD1, TSD2 or TSD3)
839
	out	dx , eax			 ;
764
	out	dx , eax			 ;
Line 840... Line 765...
840
 
765
 
841
; get next descriptor 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ...
766
; get next descriptor 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ...
842
	inc	[ebx+device.curr_tx_desc]
767
	inc	[device.curr_tx_desc]
843
	and	[ebx+device.curr_tx_desc], 3
768
	and	[device.curr_tx_desc], 3
Line 867... Line 792...
867
	mov	esi, RTL8139_LIST
792
	mov	esi, RTL8139_LIST
868
	mov	ecx, [RTL8139_DEV]
793
	mov	ecx, [RTL8139_DEV]
869
.nextdevice:
794
.nextdevice:
870
	mov	ebx, dword [esi]
795
	mov	ebx, dword [esi]
Line 871... Line 796...
871
 
796
 
872
	mov	edx, dword [ebx+device.io_addr]     ; get IRQ reason
797
	set_io	0
873
	add	edx, REG_ISR
798
	set_io	REG_ISR
874
	in	ax , dx
799
	in	ax , dx
Line 875... Line 800...
875
	out	dx , ax 			    ; send it back to ACK
800
	out	dx , ax 			    ; send it back to ACK
Line 895... Line 820...
895
	test	ax, ISR_ROK
820
	test	ax, ISR_ROK
896
	jz	@f
821
	jz	@f
897
	push	ax
822
	push	ax
Line 898... Line 823...
898
 
823
 
899
  .receive:
824
  .receive:
900
	mov	edx, dword [ebx+device.io_addr]     ; get IRQ reason
825
	set_io	0
901
	add	edx, REG_COMMAND		    ;
826
	set_io	REG_COMMAND
902
	in	al , dx 			    ;
827
	in	al , dx
903
	test	al , BUFE			    ; test if RX buffer is empty
828
	test	al , BUFE			    ; test if RX buffer is empty
Line 904... Line 829...
904
	jnz	.finish 			    ;
829
	jnz	.finish 			    ;
Line 905... Line 830...
905
 
830
 
906
	DEBUGF	2,"RX: "
831
	DEBUGF	1,"RX: "
907
 
832
 
908
	mov	eax, dword [ebx+device.rx_buffer]
833
	mov	eax, [device.rx_buffer]
-
 
834
	add	eax, [device.rx_data_offset]
909
	add	eax, dword [ebx+device.rx_data_offset]
835
	test	byte [eax], (1 shl BIT_ROK)	    ; check if packet is ok
910
	test	byte [eax], (1 shl BIT_ROK)	    ; check if packet is ok
836
	jz	.reset_rx
-
 
837
 
-
 
838
; packet is ok, copy it
911
	jz	.reset_rx
839
	movzx	ecx, word [eax+2]		    ; packet length
912
						    ; packet is ok, copy it
840
 
913
	movzx	ecx, word [eax+2]		    ; packet length
841
; Update stats
-
 
842
	add	dword [device.bytes_rx], ecx
914
	add	dword [ebx + device.bytes_rx], ecx  ; Update stats
843
	adc	dword [device.bytes_rx + 4], 0
-
 
844
	inc	dword [device.packets_rx]
915
	adc	dword [ebx + device.bytes_rx + 4], 0
845
 
Line 916... Line 846...
916
	inc	dword [ebx + device.packets_rx]     ;
846
	sub	ecx, 4				    ; don't copy CRC
917
	sub	ecx, 4				    ; don't copy CRC
847
 
918
	DEBUGF	1,"Received %u bytes\n", ecx
848
	DEBUGF	1,"Received %u bytes\n", ecx
919
 
849
 
920
	push	ebx eax ecx
850
	push	ebx eax ecx
-
 
851
	stdcall KernelAlloc, ecx		    ; Allocate a buffer to put packet into
Line 921... Line 852...
921
	stdcall KernelAlloc, ecx		    ; Allocate a buffer to put packet into
852
	pop	ecx
-
 
853
	test	eax, eax			    ; Test if we allocated succesfully
922
	pop	ecx
854
	jz	.abort
923
	test	eax, eax			    ; Test if we allocated succesfully
855
 
Line 924... Line 856...
924
	jz	.abort				    ;
856
 
925
 
857
	mov	edi, eax			    ; Where we will copy too
Line -... Line 858...
-
 
858
 
926
	mov	edi, eax			    ; Set up registers to copy the packet
859
	mov	esi, [esp]			    ; The buffer we will copy from
927
	mov	esi, [esp]			    ;
860
	add	esi, 4				    ; Dont copy CRC
928
	add	esi, 4				    ; Dont copy CRC
861
 
-
 
862
	push	dword .abort			    ; Kernel will return to this address after EthReceiver
929
 
863
	push	ecx edi 			    ; Save buffer pointer and size, to pass to kernel
930
	push	dword .abort			    ; Kernel will return to this address after EthReceiver
864
 
-
 
865
  .copy:
-
 
866
	shr	ecx, 1
-
 
867
	jnc	.nb
931
	push	ecx edi 			    ; Save buffer pointer and size, to pass to kernel
868
	movsb
-
 
869
  .nb:
Line 932... Line 870...
932
 
870
	shr	ecx, 1
Line -... Line 871...
-
 
871
	jnc	.nw
933
	shr	ecx, 2
872
	movsw
934
	cld
873
  .nw:
935
	rep	movsd				    ; copy the dwords
874
	jz	.nd
936
	mov	ecx, [esp+4]
875
	rep	movsd
937
	and	ecx, 3
876
  .nd:
938
	rep	movsb				    ; copy the rest bytes
877
 
939
 
878
	jmp	EthReceiver			    ; Send it to kernel
-
 
879
 
940
	jmp	EthReceiver			    ; Send it to kernel
880
 
941
 
881
  .abort:
-
 
882
	pop	eax ebx
942
  .abort:
883
						    ; update eth_data_start_offset
943
	pop	eax ebx
884
	movzx	eax, word [eax+2]		    ; packet length
944
						    ; update eth_data_start_offset
885
	add	eax, [device.rx_data_offset]
945
	movzx	eax, word [eax+2]		    ; packet length
886
	add	eax, 4+3			    ; packet header is 4 bytes long + dword alignment
Line 946... Line 887...
946
	add	eax, [ebx+device.rx_data_offset]
887
	and	eax, not 3			    ; dword alignment
947
	add	eax, 4+3			    ; packet header is 4 bytes long + dword alignment
888
 
948
	and	eax, not 3			    ; dword alignment
889
	cmp	eax, RX_BUFFER_SIZE
949
	cmp	eax, RX_BUFFER_SIZE
890
	jl	.no_wrap
Line 950... Line 891...
950
	jl	.no_wrap
891
	DEBUGF	2,"Wrapping"
Line 994... Line 935...
994
  @@:
935
  @@:
995
	test	ax, ISR_TER
936
	test	ax, ISR_TER
996
	jz	@f
937
	jz	@f
Line 997... Line 938...
997
 
938
 
998
	push	ax
939
	push	ax
999
	cmp	[ebx+device.curr_tx_desc], 4
940
	cmp	[device.curr_tx_desc], 4
Line 1000... Line 941...
1000
	jz	.notxd
941
	jz	.notxd
1001
 
942
 
1002
	mov	edx, [ebx+device.io_addr]
943
	set_io	0
1003
	movzx	ecx, [ebx+device.curr_tx_desc]
944
	movzx	ecx, [device.curr_tx_desc]
Line 1004... Line 945...
1004
	lea	edx, [edx+ecx*4+REG_TSD0]
945
	lea	edx, [edx+ecx*4+REG_TSD0]
1005
	in	eax, dx
946
	in	eax, dx
1006
 
947
 
1007
  .notxd:
948
  .notxd:
Line 1008... Line 949...
1008
	test	eax, TSR_TUN
949
	test	eax, TSR_TUN
1009
	jz	.nobun
950
	jz	.nobun
1010
	DEBUGF	1, "TX: FIFO Buffer underrun!\n"
951
	DEBUGF	2, "TX: FIFO Buffer underrun!\n"
1011
 
952
 
Line 1012... Line 953...
1012
  .nobun:
953
  .nobun:
1013
	test	eax, TSR_OWC
954
	test	eax, TSR_OWC
1014
	jz	.noowc
955
	jz	.noowc
1015
	DEBUGF	1, "TX: OWC!\n"
956
	DEBUGF	2, "TX: OWC!\n"
Line 1016... Line 957...
1016
 
957
 
1017
  .noowc:
958
  .noowc:
1018
	test	eax, TSR_TABT
959
	test	eax, TSR_TABT
1019
	jz	.notabt
960
	jz	.notabt
Line 1020... Line 961...
1020
	DEBUGF	1, "TX: TABT!\n"
961
	DEBUGF	2, "TX: TABT!\n"
1021
 
962
 
1022
  .notabt:
963
  .notabt:
1023
	test	eax, TSR_CRS
964
	test	eax, TSR_CRS
Line 1037... Line 978...
1037
 
978
 
1038
  @@:
979
  @@:
1039
	test	ax, ISR_TOK
980
	test	ax, ISR_TOK
Line 1040... Line 981...
1040
	jz	@f
981
	jz	@f
Line 1041... Line 982...
1041
 
982
 
1042
	DEBUGF	1, "TX: Transmit OK (desc: %u)\n", [ebx+device.curr_tx_desc]:1
983
	DEBUGF	1, "TX: Transmit OK (desc: %u)\n", [device.curr_tx_desc]:1
Line 1043... Line 984...
1043
 
984
 
1044
;----------------------------------------------------
985
;----------------------------------------------------
1045
; Rx buffer overflow ?
986
; Rx buffer overflow ?
Line 1046... Line 987...
1046
 
987
 
1047
  @@:
988
  @@:
Line 1048... Line 989...
1048
	test	ax, ISR_RXOVW
989
	test	ax, ISR_RXOVW
1049
	jz	@f
990
	jz	@f
1050
 
991
 
1051
	push	ax
992
	push	ax
1052
	DEBUGF	1,"RX-buffer overflow!\n"
993
	DEBUGF	2,"RX-buffer overflow!\n"
Line 1063... Line 1004...
1063
 
1004
 
1064
  @@:
1005
  @@:
1065
	test	ax, ISR_PUN
1006
	test	ax, ISR_PUN
Line 1066... Line 1007...
1066
	jz	@f
1007
	jz	@f
Line 1067... Line 1008...
1067
 
1008
 
1068
	DEBUGF	1,"Packet underrun!\n"
1009
	DEBUGF	2,"Packet underrun!\n"
Line 1069... Line 1010...
1069
 
1010
 
Line 1075... Line 1016...
1075
	jz	@f
1016
	jz	@f
Line 1076... Line 1017...
1076
 
1017
 
1077
	push	ax
1018
	push	ax
Line 1078... Line 1019...
1078
	DEBUGF	2,"RX fifo overflox!\n"
1019
	DEBUGF	2,"RX fifo overflox!\n"
1079
 
1020
 
1080
	mov	edx, [ebx+device.io_addr]
1021
	mov	edx, [device.io_addr]
1081
	add	edx, REG_ISR
1022
	add	edx, REG_ISR
1082
	mov	ax , ISR_FIFOOVW or ISR_RXOVW
1023
	mov	ax , ISR_FIFOOVW or ISR_RXOVW
Line 1095... Line 1036...
1095
 
1036
 
Line 1096... Line 1037...
1096
; If none of the above events happened, just exit clearing int
1037
; If none of the above events happened, just exit clearing int
Line 1097... Line 1038...
1097
 
1038
 
1098
  .fail:
1039
  .fail:
Line 1111... Line 1052...
1111
 
1052
 
1112
align 4
1053
align 4
1113
cable:
1054
cable:
Line 1114... Line 1055...
1114
	DEBUGF	1,"Checking Cable status: "
1055
	DEBUGF	1,"Checking Cable status: "
1115
 
1056
 
1116
	mov	edx, dword [ebx+device.io_addr]
1057
	mov	edx, dword [device.io_addr]
Line 1117... Line 1058...
1117
	add	edx, REG_MSR
1058
	add	edx, REG_MSR
1118
	in	al , dx
1059
	in	al , dx
Line 1124... Line 1065...
1124
;        jnz     .10mbps
1065
;        jnz     .10mbps
Line 1125... Line 1066...
1125
 
1066
 
1126
	shr	al, 2
1067
	shr	al, 2
Line 1127... Line 1068...
1127
	and	al, 3
1068
	and	al, 3
1128
 
1069
 
1129
	mov	byte [ebx+device.mode+3], al
1070
	mov	byte [device.mode+3], al
Line 1139... Line 1080...
1139
;;;;;;;;;;;;;;;;;;;;;;;
1080
;;;;;;;;;;;;;;;;;;;;;;;
Line 1140... Line 1081...
1140
 
1081
 
1141
align 4
1082
align 4
Line 1142... Line 1083...
1142
write_mac:	; in: mac pushed onto stack (as 3 words)
1083
write_mac:	; in: mac pushed onto stack (as 3 words)
Line 1143... Line 1084...
1143
 
1084
 
Line 1144... Line 1085...
1144
	DEBUGF	1,"Writing MAC: "
1085
	DEBUGF	2,"Writing MAC: "
1145
 
1086
 
1146
; disable all in command registers
1087
; disable all in command registers
1147
 
1088
 
Line 1148... Line 1089...
1148
	mov	edx, [ebx+device.io_addr]
1089
	set_io	0
1149
	add	edx, REG_9346CR
1090
	set_io	REG_9346CR
1150
	xor	eax, eax
1091
	xor	eax, eax
Line 1151... Line 1092...
1151
	out	dx , al
1092
	out	dx , al
1152
 
1093
 
1153
	add	edx, REG_IMR - REG_9346CR
1094
	set_io	REG_IMR
Line 1154... Line 1095...
1154
	xor	eax, eax
1095
	xor	eax, eax
Line 1155... Line -...
1155
	out	dx , ax
-
 
1156
 
1096
	out	dx , ax
1157
	add	edx, REG_ISR - REG_IMR
1097
 
1158
	mov	eax, -1
1098
	set_io	REG_ISR
Line 1159... Line 1099...
1159
	out	dx , ax
1099
	mov	eax, -1
Line 1160... Line 1100...
1160
 
1100
	out	dx , ax
1161
; enable writing
1101
 
1162
 
1102
; enable writing
Line 1163... Line 1103...
1163
 
1103
 
1164
	add	edx, REG_9346CR - REG_ISR
1104
	set_io	REG_9346CR
1165
	mov	eax, REG_9346CR_WE
1105
	mov	eax, REG_9346CR_WE
1166
	out	dx , al
1106
	out	dx , al
Line 1167... Line 1107...
1167
 
1107
 
Line 1168... Line 1108...
1168
 ; write the mac ...
1108
 ; write the mac ...
1169
 
1109
 
1170
	add	edx, REG_IDR0 - REG_9346CR
1110
	set_io	REG_IDR0
Line 1171... Line 1111...
1171
	pop	eax
1111
	pop	eax
Line 1172... Line 1112...
1172
	out	dx , eax
1112
	out	dx , eax
Line 1173... Line 1113...
1173
 
1113
 
Line 1192... Line 1132...
1192
;; Read MAC address ;;
1132
;; Read MAC address ;;
1193
;;                  ;;
1133
;;                  ;;
1194
;;;;;;;;;;;;;;;;;;;;;;
1134
;;;;;;;;;;;;;;;;;;;;;;
Line 1195... Line 1135...
1195
 
1135
 
1196
read_mac:
1136
read_mac:
Line 1197... Line 1137...
1197
	DEBUGF	1,"Reading MAC: "
1137
	DEBUGF	2,"Reading MAC: "
1198
 
1138
 
1199
	mov	edx, [ebx + device.io_addr]
1139
	set_io	0
1200
	lea	edi, [ebx + device.mac]
1140
	lea	edi, [device.mac]
1201
	in	eax, dx
1141
	in	eax, dx
1202
	stosd
1142
	stosd
1203
	add	edx, 4
1143
	add	edx, 4
Line 1204... Line 1144...
1204
	in	ax, dx
1144
	in	ax, dx
Line 1205... Line 1145...
1205
	stosw
1145
	stosw
Line 1223... Line 1163...
1223
 
1163
 
1224
align 4
1164
align 4
1225
read_eeprom:
1165
read_eeprom:
Line 1226... Line 1166...
1226
	DEBUGF	2,"Reading eeprom, "
1166
	DEBUGF	2,"Reading eeprom, "
1227
 
1167
 
1228
	mov	edx, [ebx+device.io_addr]
1168
	set_io	0
1229
	push	ebx
1169
	push	ebx
1230
	movzx	ebx, al
1170
	movzx	ebx, al
1231
	add	edx, REG_RXCONFIG
1171
	set_io	REG_RXCONFIG
1232
	in	al, dx
1172
	in	al, dx
1233
	test	al, (1 shl BIT_9356SEL)
1173
	test	al, (1 shl BIT_9356SEL)
1234
	jz	.type_93c46
1174
	jz	.type_93c46
Line 1239... Line 1179...
1239
.type_93c46:
1179
.type_93c46:
1240
	and	bl, 00111111b
1180
	and	bl, 00111111b
1241
	or	bx, EE_93C46_READ_CMD		; it contains start bit
1181
	or	bx, EE_93C46_READ_CMD		; it contains start bit
1242
	mov	cx, EE_93C46_CMD_LENGTH-1	; cmd_loop counter
1182
	mov	cx, EE_93C46_CMD_LENGTH-1	; cmd_loop counter
1243
.read_eeprom:
1183
.read_eeprom:
1244
	add	edx, REG_9346CR - REG_RXCONFIG
1184
	set_io	REG_9346CR
1245
;       mov     al, (1 shl BIT_93C46_EEM1)
1185
;       mov     al, (1 shl BIT_93C46_EEM1)
1246
;       out     dx, al
1186
;       out     dx, al
1247
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS) ; wake up the eeprom
1187
	mov	al, (1 shl BIT_93C46_EEM1) or (1 shl BIT_93C46_EECS) ; wake up the eeprom
1248
	out	dx, al
1188
	out	dx, al
1249
.cmd_loop:
1189
.cmd_loop:
Line 1303... Line 1243...
1303
device_5      db 'Realtek 8100',0
1243
device_5      db 'Realtek 8100',0
1304
device_6      db 'Realtek 8139D',0
1244
device_6      db 'Realtek 8139D',0
1305
device_7      db 'Realtek 8139CP',0
1245
device_7      db 'Realtek 8139CP',0
1306
device_8      db 'Realtek 8101',0
1246
device_8      db 'Realtek 8101',0
Line 1307... Line 1247...
1307
 
1247
 
1308
name_crosslist dd device_1
1248
crosslist     dd device_1
1309
	       dd device_2
1249
	      dd device_2
1310
	       dd device_3
1250
	      dd device_3
1311
	       dd device_4
1251
	      dd device_4
1312
	       dd device_5
1252
	      dd device_5