Subversion Repositories Kolibri OS

Rev

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

Rev 1519 Rev 1541
Line 21... Line 21...
21
 
21
 
22
	DEBUG			equ 1
22
	DEBUG			equ 1
23
	__DEBUG__		equ 1
23
	__DEBUG__		equ 1
Line -... Line 24...
-
 
24
	__DEBUG_LEVEL__ 	equ 1
-
 
25
 
-
 
26
	TX_RING_SIZE		equ 4
-
 
27
	RX_RING_SIZE		equ 4
Line 24... Line 28...
24
	__DEBUG_LEVEL__ 	equ 1
28
	PKT_BUF_SZ		equ 1544
25
 
29
 
26
 
30
 
27
include 'proc32.inc'
31
include 'proc32.inc'
Line 28... Line 32...
28
include 'imports.inc'
32
include 'imports.inc'
29
include 'fdo.inc'
33
include 'fdo.inc'
30
include 'netdrv.inc'
34
include 'netdrv.inc'
Line -... Line 35...
-
 
35
 
-
 
36
public START
-
 
37
public service_proc
-
 
38
public version
-
 
39
 
-
 
40
struc buf_head {
-
 
41
	.base		dd ?
-
 
42
	.length 	dw ?
-
 
43
	.status 	dw ?
-
 
44
	.msg_length	dw ?
-
 
45
	.misc		dw ?
-
 
46
	.reserved	dd ?
-
 
47
	.size:
Line 31... Line 48...
31
 
48
}
Line 32... Line 49...
32
public START
49
 
Line 66... Line 83...
66
	.phys_addr	dp ?
83
	.phys_addr	dp ?
67
	.reserved	dw ?
84
	.reserved	dw ?
68
	.filter 	dq ?
85
	.filter 	dq ?
69
	.rx_ring_phys	dd ?
86
	.rx_ring_phys	dd ?
70
	.tx_ring_phys	dd ?
87
	.tx_ring_phys	dd ?
-
 
88
 
71
	.rx_ring	dd ?
89
	.rx_ring	rb RX_RING_SIZE * buf_head.size
72
	.tx_ring	dd ?
90
	.tx_ring	rb TX_RING_SIZE * buf_head.size
-
 
91
 
73
	.cur_rx 	db ?
92
	.cur_rx 	db ?
74
	.cur_tx 	db ?
93
	.cur_tx 	db ?
75
	.dirty_rx	dd ?
94
	.dirty_rx	dd ?
76
	.dirty_tx	dd ?
95
	.dirty_tx	dd ?
77
	.tx_full	db ?
96
	.tx_full	db ?
Line 86... Line 105...
86
 
105
 
Line 87... Line 106...
87
	.size = $ - device
106
	.size = $ - device
Line 88... Line -...
88
 
-
 
89
end virtual
-
 
90
 
-
 
91
struc buf_head {
-
 
92
	.base		dd ?
-
 
93
	.length 	dw ?
-
 
94
	.status 	dw ?
-
 
95
	.msg_length	dw ?
-
 
96
	.misc		dw ?
-
 
97
	.reserved	dd ?
-
 
98
 
-
 
99
	.size:
-
 
100
}
-
 
101
 
-
 
Line 102... Line 107...
102
virtual at 0
107
 
Line 103... Line 108...
103
 buf_head buf_head
108
end virtual
104
end virtual
109
 
Line 145... Line 150...
145
 
150
 
146
virtual at 0
151
virtual at 0
147
 rx_desc rx_desc_2
152
 rx_desc rx_desc_2
Line 148... Line -...
148
end virtual
-
 
149
 
-
 
150
 
-
 
151
; PCI Bus defines
153
end virtual
152
 
154
 
153
	PORT_AUI		equ 0x00
155
	PORT_AUI		equ 0x00
154
	PORT_10BT		equ 0x01
156
	PORT_10BT		equ 0x01
155
	PORT_GPSI		equ 0x02
157
	PORT_GPSI		equ 0x02
Line 162... Line 164...
162
	DMA_MASK		equ 0xffffffff
164
	DMA_MASK		equ 0xffffffff
Line 163... Line 165...
163
 
165
 
164
	LOG_TX_BUFFERS		equ 2
166
	LOG_TX_BUFFERS		equ 2
Line 165... Line -...
165
	LOG_RX_BUFFERS		equ 2
-
 
166
 
167
	LOG_RX_BUFFERS		equ 2
167
	TX_RING_SIZE		equ 4
168
 
Line 168... Line -...
168
	TX_RING_MOD_MASK	equ (TX_RING_SIZE-1)
-
 
169
	TX_RING_LEN_BITS	equ (LOG_TX_BUFFERS shl 12)
169
	TX_RING_MOD_MASK	equ (TX_RING_SIZE-1)
170
 
170
	TX_RING_LEN_BITS	equ (LOG_TX_BUFFERS shl 12)
Line 171... Line -...
171
	RX_RING_SIZE		equ 4
-
 
172
	RX_RING_MOD_MASK	equ (RX_RING_SIZE-1)
-
 
173
	RX_RING_LEN_BITS	equ (LOG_RX_BUFFERS shl 4)
-
 
174
 
171
 
175
	PKT_BUF_SZ		equ 1544
172
	RX_RING_MOD_MASK	equ (RX_RING_SIZE-1)
176
	PKT_BUF_SZ_NEG		equ 0xf9f8
173
	RX_RING_LEN_BITS	equ (LOG_RX_BUFFERS shl 4)
177
 
174
 
178
	WIO_RDP 		equ 0x10
175
	WIO_RDP 		equ 0x10
Line 516... Line 513...
516
	find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
513
	find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
Line 517... Line 514...
517
 
514
 
518
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
515
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
Line 519... Line 516...
519
	[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
516
	[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
520
 
517
 
521
;;;        allocate_and_clear [device.tx_buffer], (RX_RING_SIZE * PKT_BUF_SZ), .err
-
 
522
	allocate_and_clear [device.rx_buffer], (TX_RING_SIZE * PKT_BUF_SZ), .err
-
 
523
	allocate_and_clear [device.rx_ring], (RX_RING_SIZE * buf_head.size), .err
-
 
524
 
-
 
525
	mov	eax, [device.rx_ring]
-
 
526
	call	GetPgAddr
-
 
527
	mov	[device.rx_ring_phys], eax
-
 
528
 
-
 
529
	allocate_and_clear [device.tx_ring], (TX_RING_SIZE * buf_head.size), .err
-
 
530
 
-
 
531
	mov	eax, [device.tx_ring]
-
 
Line 532... Line 518...
532
	call	GetPgAddr
518
	allocate_and_clear [device.tx_buffer], (RX_RING_SIZE * PKT_BUF_SZ), .err
533
	mov	[device.tx_ring_phys], eax
519
	allocate_and_clear [device.rx_buffer], (TX_RING_SIZE * PKT_BUF_SZ), .err
534
 
520
 
535
; Ok, the eth_device structure is ready, let's probe the device
521
; Ok, the eth_device structure is ready, let's probe the device
Line 567... Line 553...
567
	; todo: reset device into virgin state
553
	; todo: reset device into virgin state
568
	dec	[devices]
554
	dec	[devices]
569
  .err:
555
  .err:
570
	DEBUGF	1,"Error, removing all data !\n"
556
	DEBUGF	1,"Error, removing all data !\n"
571
	stdcall KernelFree, [device.rx_buffer]
557
	stdcall KernelFree, [device.rx_buffer]
572
;;;        stdcall KernelFree, [device.tx_buffer]
558
	stdcall KernelFree, [device.tx_buffer]
573
	stdcall KernelFree, ebx
559
	stdcall KernelFree, ebx
Line 574... Line 560...
574
 
560
 
575
  .fail:
561
  .fail:
576
	or	eax, -1
562
	or	eax, -1
Line 608... Line 594...
608
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
594
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 609... Line 595...
609
 
595
 
610
align 4
596
align 4
Line -... Line 597...
-
 
597
probe:
-
 
598
 
611
probe:
599
; make the device a bus master
Line 612... Line 600...
612
 
600
 
Line 613... Line 601...
613
	make_bus_master [device.pci_bus], [device.pci_dev]
601
	make_bus_master [device.pci_bus], [device.pci_dev]
614
 
602
 
615
; first, fill in some of the structure variables
603
; create the RX-ring
616
 
604
 
617
	mov	edi, [device.rx_ring]
605
	lea	edi, [device.rx_ring]
618
	mov	ecx, RX_RING_SIZE
606
	mov	ecx, RX_RING_SIZE
619
	mov	eax, [device.rx_buffer]
607
	mov	eax, [device.rx_buffer]
620
	call	GetPgAddr
608
	call	GetPgAddr
621
  .rx_init:
609
  .rx_init:
622
	mov	[edi + buf_head.base], eax
610
	mov	[edi + buf_head.base], eax
623
	mov	[edi + buf_head.length], PKT_BUF_SZ_NEG
611
	mov	[edi + buf_head.length], - PKT_BUF_SZ
624
	mov	[edi + buf_head.status], 0x8000
-
 
625
	and	dword [edi + buf_head.msg_length], 0
612
	mov	[edi + buf_head.status], 0x8000
626
	and	dword [edi + buf_head.reserved], 0
613
	and	dword [edi + buf_head.msg_length], 0
Line -... Line 614...
-
 
614
	and	dword [edi + buf_head.reserved], 0
-
 
615
	add	eax, PKT_BUF_SZ
-
 
616
	add	edi, buf_head.size
-
 
617
	loop	.rx_init
-
 
618
 
-
 
619
	lea	eax, [device.rx_ring]
627
	add	eax, PKT_BUF_SZ
620
	GetRealAddr
628
;        inc     eax
621
	mov	[device.rx_ring_phys], eax
629
	add	 edi, buf_head.size
622
 
630
	loop	 .rx_init
623
; create the Tx-ring
631
 
624
 
632
	mov	edi, [device.tx_ring]
625
	lea	edi, [device.tx_ring]
Line 640... Line 633...
640
	and	dword [edi + buf_head.reserved], 0
633
	and	dword [edi + buf_head.reserved], 0
641
	add	eax, PKT_BUF_SZ
634
	add	eax, PKT_BUF_SZ
642
	add	edi, buf_head.size
635
	add	edi, buf_head.size
643
	loop	.tx_init
636
	loop	.tx_init
Line -... Line 637...
-
 
637
 
-
 
638
	lea	eax, [device.tx_ring]
-
 
639
	GetRealAddr
-
 
640
	mov	[device.tx_ring_phys], eax
644
 
641
 
Line 645... Line 642...
645
	mov	[device.tlen_rlen], (TX_RING_LEN_BITS or RX_RING_LEN_BITS)
642
	mov	[device.tlen_rlen], (TX_RING_LEN_BITS or RX_RING_LEN_BITS)
646
 
643
 
647
	; First, we must try to use Word operations
644
; First, we must try to use Word operations
Line 654... Line 651...
654
	cmp	eax, 4
651
	cmp	eax, 4
655
	jne	.try_dwio
652
	jne	.try_dwio
Line 656... Line 653...
656
 
653
 
657
	; Try Word I/O
654
	; Try Word I/O
658
	mov	ax , 88
655
	mov	ax, 88
659
	add	edx, WIO_RAP
656
	set_io	WIO_RAP
660
	out	dx , ax
657
	out	dx, ax
661
	nop
658
	nop
662
	nop
659
	nop
663
	in	ax , dx
660
	in	ax, dx
664
	sub	edx, WIO_RAP
661
	set_io	0
665
	cmp	ax , 88
662
	cmp	ax, 88
Line 666... Line 663...
666
	jne	.try_dwio
663
	jne	.try_dwio
Line 667... Line 664...
667
 
664
 
Line 668... Line 665...
668
	DEBUGF 1,"Using WIO\n"
665
	DEBUGF	1,"Using WIO\n"
Line -... Line 666...
-
 
666
 
669
 
667
	call	switch_to_wio
670
	call	switch_to_wio
668
 
Line 671... Line 669...
671
 
669
	jmp	.L1
672
	jmp	.L1
670
 
Line 686... Line 684...
686
	out	dx , eax
684
	out	dx, eax
687
	nop
685
	nop
688
	nop
686
	nop
689
	in	eax, dx
687
	in	eax, dx
690
	set_io	0
688
	set_io	0
691
	and	eax, 0xffff
-
 
692
	cmp	eax, 88
689
	cmp	ax, 88
693
	jne	.no_dev
690
	jne	.no_dev
Line 694... Line 691...
694
 
691
 
Line 695... Line 692...
695
	DEBUGF 1,"Using DWIO\n"
692
	DEBUGF	1,"Using DWIO\n"
Line 696... Line 693...
696
 
693
 
Line -... Line 694...
-
 
694
	call	switch_to_dwio
697
	call	switch_to_dwio
695
 
698
 
696
	jmp	.L1
699
	jmp	.L1
697
 
700
 
698
; If both methods fail, something is wrong!
701
  .no_dev:
-
 
Line -... Line 699...
-
 
699
  .no_dev:
702
	DEBUGF 1,"PCnet device not found!\n"
700
	DEBUGF	1,"PCnet device not found!\n"
703
	mov	eax, 1
701
	mov	eax, -1
704
	ret
702
	ret
Line 705... Line 703...
705
  .L1:
703
 
Line 720... Line 718...
720
 
718
 
721
	shr	eax, 12
719
	shr	eax, 12
722
	and	eax, 0xffff
720
	and	eax, 0xffff
Line 723... Line 721...
723
	mov	[device.chip_version], eax
721
	mov	[device.chip_version], eax
-
 
722
 
724
 
723
	DEBUGF	1,"chip version: %x\n", eax
725
	DEBUGF 1,"chip version ok\n"
724
 
726
	mov	[device.fdx], 0
725
	mov	[device.fdx], 0
727
	mov	[device.mii], 0
726
	mov	[device.mii], 0
728
	mov	[device.fset], 0
727
	mov	[device.fset], 0
Line 792... Line 791...
792
 
791
 
793
	cmp	[device.fset], 1
792
	cmp	[device.fset], 1
794
	jne	.L11
793
	jne	.L11
795
	mov	ecx, BCR_BUSCTL
794
	mov	ecx, BCR_BUSCTL
796
	call	[device.access_read_bcr]
795
	call	[device.access_read_bcr]
797
	or	eax, 0x800
796
	or	ax, 0x800
Line 798... Line 797...
798
	call	[device.access_write_bcr]
797
	call	[device.access_write_bcr]
799
 
798
 
800
	mov	ecx, CSR_DMACTL
-
 
801
	call	[device.access_read_csr]
-
 
802
;        and     eax, 0xc00
799
	mov	ecx, CSR_DMACTL
803
;        or      eax, 0xc00
800
	call	[device.access_read_csr]
Line 804... Line 801...
804
	mov	eax, 0xc00
801
	mov	eax, 0xc00
805
	call	[device.access_write_csr]
802
	call	[device.access_write_csr]
806
 
803
 
Line 807... Line -...
807
	mov	[device.dxsuflo],1
-
 
808
	mov	[device.ltint],1
804
	mov	[device.dxsuflo],1
809
  .L11:
805
	mov	[device.ltint],1
810
 
806
  .L11:
811
	DEBUGF 1,"PCI done\n"
807
 
Line 812... Line 808...
812
	mov	eax, PORT_ASEL
808
	mov	eax, PORT_ASEL			; Auto-select
Line 820... Line 816...
820
	mov	eax, IMR
816
	mov	eax, IMR
821
	mov	ecx, CSR_IMR			  ; Write interrupt mask
817
	mov	ecx, CSR_IMR			; Write interrupt mask
822
	call	[device.access_write_csr]
818
	call	[device.access_write_csr]
Line 823... Line -...
823
 
-
 
824
 
-
 
825
 
-
 
826
 
819
 
827
 
820
 
Line -... Line 821...
-
 
821
align 4
-
 
822
reset:
828
align 4
823
 
Line 829... Line 824...
829
reset:
824
	DEBUGF	1,"Resetting PCnet device: %x\n", ebx
830
 
825
 
831
; attach int handler
826
; attach int handler
Line 846... Line 841...
846
; Switch to dword operations
841
; Switch to dword operations
Line 847... Line 842...
847
 
842
 
Line 848... Line 843...
848
	DEBUGF 1,"Switching to 32-bit mode\n"
843
	DEBUGF	1,"Switching to 32-bit mode\n"
849
 
844
 
850
	mov	ecx, DWIO_RDP
845
	mov	ecx, DWIO_RDP
Line 851... Line 846...
851
	mov	eax, 0
846
	xor	eax, eax
Line 852... Line 847...
852
	call	wio_write_csr
847
	call	wio_write_csr
Line 861... Line 856...
861
	out	dx , eax
856
	out	dx, eax
862
	nop
857
	nop
863
	nop
858
	nop
864
	in	eax, dx
859
	in	eax, dx
865
	set_io	0
860
	set_io	0
866
	and	eax, 0xffff
-
 
867
	cmp	eax, 88
861
	cmp	ax, 88
868
	je	.yes_dwio
862
	je	.yes_dwio
Line 869... Line 863...
869
 
863
 
870
	call	switch_to_wio			; it seem to have failed, reset device again and use wio
864
	call	switch_to_wio			; it seems to have failed, reset device again and use wio
871
	set_io	0
865
	set_io	0
Line 872... Line 866...
872
	call	[device.access_reset]
866
	call	[device.access_reset]
-
 
867
 
-
 
868
  .yes_dwio:
-
 
869
	set_io	0
-
 
870
	mov	ecx, BCR_SSTYLE 		; Select Software style 2      ;;;
Line 873... Line 871...
873
 
871
	mov	eax, 2
874
  .yes_dwio:
872
	call	[device.access_write_bcr]
875
 
873
 
876
	; set/reset autoselect bit
874
	; set/reset autoselect bit
877
	mov	ecx, BCR_MISCCFG
875
	mov	ecx, BCR_MISCCFG
878
	call	[device.access_read_bcr]
876
	call	[device.access_read_bcr]
879
	and	eax,not 2
877
 
880
	test	[device.options], PORT_ASEL
878
	test	[device.options], PORT_ASEL
881
	jz	.L1
879
	jnz	 .L1
Line 882... Line 880...
882
	or	eax, 2
880
	and	eax, not 2
Line 966... Line 964...
966
	lea	edi, [device.phys_addr]
964
	lea	edi, [device.phys_addr]
967
	movsd
965
	movsd
968
	movsw
966
	movsw
Line 969... Line 967...
969
 
967
 
970
	lea	eax, [device.private]
-
 
971
	mov	ecx, eax
-
 
972
	and	ecx, 0xFFF ; KolibriOS PAGE SIZE
968
	lea	eax, [device.private]
973
	call	GetPgAddr
-
 
974
	add	eax, ecx
-
 
975
 
969
	GetRealAddr
976
	push	eax
970
	push	eax
977
	and	eax, 0xffff
971
	and	eax, 0xffff
978
	mov	ecx, 1
972
	mov	ecx, 1
979
	call	[device.access_write_csr]
973
	call	[device.access_write_csr]
Line 984... Line 978...
984
 
978
 
985
	mov	ecx,4
979
	mov	ecx, 4
986
	mov	eax,0x0915
980
	mov	eax, 0x0915
Line 987... Line 981...
987
	call	[device.access_write_csr]
981
	call	[device.access_write_csr]
988
 
982
 
989
	mov	ecx,0
983
	xor	ecx, ecx
Line 990... Line 984...
990
	mov	eax,1
984
	mov	eax, 1
991
	call	[device.access_write_csr]
985
	call	[device.access_write_csr]
Line 1000... Line 994...
1000
.L11:
994
.L11:
1001
	push	ecx
995
	push	ecx
1002
	xor	ecx, ecx
996
	xor	ecx, ecx
1003
	call	[device.access_read_csr]
997
	call	[device.access_read_csr]
1004
	pop	ecx
998
	pop	ecx
-
 
999
	push	esi
-
 
1000
	mov	esi, 100
-
 
1001
	call	Sleep
-
 
1002
	pop	esi
1005
	test	ax,0x100
1003
	test	ax, 0x100
1006
	jnz	.L12
1004
	jnz	.L12
1007
	loop	.L11
1005
	loop	.L11
1008
.L12:
1006
.L12:
Line 1061... Line 1059...
1061
; check descriptor
1059
; check descriptor
1062
	movzx	eax, [device.cur_tx]
1060
	movzx	eax, [device.cur_tx]
1063
	imul	edi, eax, PKT_BUF_SZ
1061
	imul	edi, eax, PKT_BUF_SZ
1064
	shl	eax, 4
1062
	shl	eax, 4
1065
	add	edi, [device.tx_buffer]
1063
	add	edi, [device.tx_buffer]
-
 
1064
 
1066
	add	eax, [device.tx_ring]
1065
	lea	eax, [eax + device.tx_ring]
-
 
1066
 
1067
	test	byte [eax + buf_head.status + 1], 80h
1067
	test	byte [eax + buf_head.status + 1], 80h
1068
	jnz	.nospace
1068
	jnz	.nospace
Line 1069... Line 1069...
1069
 
1069
 
1070
; descriptor is free, copy data
1070
; descriptor is free, copy data
Line 1102... Line 1102...
1102
	mov	ecx, [esp+8]
1102
	mov	ecx, [esp+8]
1103
	add	dword [device.bytes_tx], ecx
1103
	add	dword [device.bytes_tx], ecx
1104
	adc	dword [device.bytes_tx + 4], 0
1104
	adc	dword [device.bytes_tx + 4], 0
1105
	DEBUGF	2," - Done!\n"
1105
	DEBUGF	2," - Done!\n"
Line 1106... Line 1106...
1106
 
1106
 
1107
	call	Kernelfree
-
 
1108
	add	esp, 4
1107
	stdcall KernelFree, [esp+4]
Line 1109... Line 1108...
1109
	ret
1108
	ret	8
1110
 
1109
 
1111
.nospace:
1110
.nospace:
Line 1112... Line 1111...
1112
	DEBUGF	1, 'ERROR: no free transmit descriptors\n'
1111
	DEBUGF	1, 'ERROR: no free transmit descriptors\n'
1113
; todo: maybe somehow notify the kernel about the error?
-
 
1114
 
1112
; todo: maybe somehow notify the kernel about the error?
Line 1115... Line 1113...
1115
	call	Kernelfree
1113
 
1116
	add	esp, 4
1114
	stdcall KernelFree, [esp+4]
Line 1125... Line 1123...
1125
;;;;;;;;;;;;;;;;;;;;;;;
1123
;;;;;;;;;;;;;;;;;;;;;;;
Line 1126... Line 1124...
1126
 
1124
 
1127
align 4
1125
align 4
Line 1128... Line 1126...
1128
int_handler:
1126
int_handler:
Line 1129... Line 1127...
1129
 
1127
 
Line 1130... Line 1128...
1130
	DEBUGF	1,"IRQ %x ", eax:2		; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO
1128
	DEBUGF	1,"IRQ=%x ", eax:2		; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO
1131
 
1129
 
1132
; find pointer of device wich made IRQ occur
1130
; find pointer of device wich made IRQ occur
1133
 
1131
 
1134
	mov	esi, device_list
1132
	mov	esi, device_list
1135
	mov	ecx, [devices]
1133
	mov	ecx, [devices]
1136
	test	ecx, ecx
-
 
1137
	jz	.abort
1134
	test	ecx, ecx
Line 1138... Line 1135...
1138
  .nextdevice:
1135
	jz	.abort
1139
	mov	ebx, [esi]
1136
  .nextdevice:
1140
	DEBUGF	1,"device=%x? ", ebx
1137
	mov	ebx, [esi]
Line 1152... Line 1149...
1152
	loop	.nextdevice
1149
	loop	.nextdevice
Line 1153... Line 1150...
1153
 
1150
 
Line 1154... Line 1151...
1154
	ret					; If no device was found, abort (The irq was probably for a device, not registered to this driver
1151
	ret					; If no device was found, abort (The irq was probably for a device, not registered to this driver
1155
 
1152
 
1156
  .got_it:
1153
  .got_it:
1157
	DEBUGF	1,"yes, reason=%x ", ax
1154
	DEBUGF	1,"csr=%x\n", ax
1158
;-------------------------------------------------------
1155
;-------------------------------------------------------
1159
; Possible reasons:
1156
; Possible reasons:
1160
; initialization done - ignore
1157
; initialization done - ignore
Line 1168... Line 1165...
1168
; Received packet ok?
1165
; Received packet ok?
Line 1169... Line 1166...
1169
 
1166
 
1170
	test	ax, CSR_RINT
1167
	test	ax, CSR_RINT
Line -... Line 1168...
-
 
1168
	jz	@f
-
 
1169
 
-
 
1170
	push	ax
-
 
1171
 
1171
	jz	@f
1172
	DEBUGF	1,"packet received!\n"
1172
 
1173
 
1173
.receiver_test_loop:
1174
 .receiver_test_loop:
1174
	movzx	eax, [device.cur_rx]
1175
	movzx	eax, [device.cur_rx]
Line 1175... Line 1176...
1175
;        and     eax, RX_RING_MOD_MASK
1176
;        and     eax, RX_RING_MOD_MASK
1176
	mov	edi, eax
1177
	mov	edi, eax
Line 1177... Line 1178...
1177
 
1178
 
1178
	imul	esi, eax, PKT_BUF_SZ	  ;
1179
	imul	esi, eax, PKT_BUF_SZ	  ;
Line 1179... Line 1180...
1179
	add	esi, [device.rx_buffer] 	; esi now points to rx buffer
1180
	add	esi, [device.rx_buffer] 	; esi now points to rx buffer
Line 1180... Line 1181...
1180
 
1181
 
1181
	shl	edi, 4				; desc * 16 (16 is size of one ring entry)
1182
	shl	edi, 4				; desc * 16 (16 is size of one ring entry)
Line 1232... Line 1233...
1232
 
1233
 
1233
	DEBUGF	1,"Inserting packet\n"
1234
	DEBUGF	1,"Inserting packet\n"
Line 1234... Line 1235...
1234
	jmp	EthReceiver			; Send the copied packet to kernel
1235
	jmp	EthReceiver			; Send the copied packet to kernel
1235
 
1236
 
1236
  .abort:
1237
  .abort:
Line -... Line 1238...
-
 
1238
	pop	ax
-
 
1239
  @@:
-
 
1240
 
-
 
1241
	test	ax, IMR_TINT
-
 
1242
	jz	@f
-
 
1243
 
-
 
1244
	DEBUGF	1,"Transmit OK!\n"
-
 
1245
 
-
 
1246
  @@:
-
 
1247
 
-
 
1248
	test	ax, IMR_MISS
-
 
1249
	jz	@f
-
 
1250
 
-
 
1251
	DEBUGF	1,"We missed a frame! (RX ring full?)\n"
-
 
1252
 
-
 
1253
  @@:
1237
	DEBUGF	1,"done \n"
1254
 
Line 1251... Line 1268...
1251
align 4
1268
align 4
1252
write_mac:	; in: mac pushed onto stack (as 3 words)
1269
write_mac:	; in: mac pushed onto stack (as 3 words)
Line 1253... Line 1270...
1253
 
1270
 
Line 1254... Line 1271...
1254
	DEBUGF	1,"Writing MAC: %x-%x-%x-%x-%x-%x",[esp+0]:2,[esp+1]:2,[esp+2]:2,[esp+3]:2,[esp+4]:2,[esp+5]:2
1271
	DEBUGF	1,"Writing MAC: %x-%x-%x-%x-%x-%x",[esp+0]:2,[esp+1]:2,[esp+2]:2,[esp+3]:2,[esp+4]:2,[esp+5]:2
1255
 
1272
 
1256
	mov	edx, [device.io_addr]
1273
	set_io	0
1257
	add	edx, 2
-
 
1258
	xor	eax, eax
1274
;        set_io  2
1259
 
1275
	xor	eax, eax
1260
	mov	ecx, CSR_PAR0
1276
	mov	ecx, CSR_PAR0
1261
       @@:
1277
       @@:
1262
	pop	ax
1278
	pop	ax
Line 1277... Line 1293...
1277
;;;;;;;;;;;;;;;;;;;;;;
1293
;;;;;;;;;;;;;;;;;;;;;;
Line 1278... Line 1294...
1278
 
1294
 
1279
read_mac:
1295
read_mac:
Line 1280... Line 1296...
1280
	DEBUGF	1,"Reading MAC"
1296
	DEBUGF	1,"Reading MAC"
1281
 
1297
 
1282
	mov	edx, [device.io_addr]
1298
	set_io	0
1283
	add	edx, 6
1299
	set_io	6
1284
       @@:
1300
       @@:
1285
	dec	dx
1301
	dec	dx
1286
	dec	dx
1302
	dec	dx
Line 1520... Line 1536...
1520
; End of code
1536
; End of code
1521
align 4 					; Place all initialised data here
1537
align 4 					  ; Place all initialised data here
Line 1522... Line 1538...
1522
 
1538
 
1523
devices       dd 0
1539
devices       dd 0
1524
version       dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)
1540
version       dd (DRIVER_VERSION shl 16) or (API_VERSION and 0xFFFF)
Line 1525... Line 1541...
1525
my_service    db 'PCnet32',0			; max 16 chars include zero
1541
my_service    db 'PCnet',0			  ; max 16 chars include zero
1526
 
1542
 
1527
device_l2     db "PCnet/PCI 79C970",0
1543
device_l2     db "PCnet/PCI 79C970",0
1528
device_l4     db "PCnet/PCI II 79C970A",0
1544
device_l4     db "PCnet/PCI II 79C970A",0