Subversion Repositories Kolibri OS

Rev

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

Rev 1541 Rev 1564
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                  ;;
2
;;                                                                  ;;
3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved.     ;;
3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved.     ;;
4
;; Distributed under terms of the GNU General Public License        ;;
4
;; Distributed under terms of the GNU General Public License        ;;
5
;;                                                                  ;;
5
;;                                                                  ;;
6
;;  PCnet32 driver for KolibriOS                                    ;;
6
;;  PCnet driver for KolibriOS                                      ;;
-
 
7
;;                                                                  ;;
-
 
8
;;  By hidnplayr & clevermouse                                      ;;
7
;;                                                                  ;;
9
;;                                                                  ;;
8
;;  Based on the PCnet32 driver for MenuetOS, by Jarek Pelczar      ;;
10
;;  Based on the PCnet32 driver for MenuetOS, by Jarek Pelczar      ;;
9
;;                                                                  ;;
11
;;                                                                  ;;
10
;;          GNU GENERAL PUBLIC LICENSE                              ;;
12
;;          GNU GENERAL PUBLIC LICENSE                              ;;
11
;;             Version 2, June 1991                                 ;;
13
;;             Version 2, June 1991                                 ;;
12
;;                                                                  ;;
14
;;                                                                  ;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 16...
-
 
16
 
-
 
17
; $Revision: 1564 $
14
 
18
 
Line 15... Line 19...
15
format MS COFF
19
format MS COFF
16
 
-
 
17
	API_VERSION		equ 0x01000100
-
 
18
	DRIVER_VERSION		equ 5
-
 
Line 19... Line 20...
19
 
20
 
20
	MAX_DEVICES		equ 16
21
	API_VERSION		equ 0x01000100
21
 
22
 
Line 22... Line -...
22
	DEBUG			equ 1
-
 
23
	__DEBUG__		equ 1
23
	DEBUG			equ 1
24
	__DEBUG_LEVEL__ 	equ 1
24
	__DEBUG__		equ 1
25
 
-
 
Line 26... Line 25...
26
	TX_RING_SIZE		equ 4
25
	__DEBUG_LEVEL__ 	equ 1
27
	RX_RING_SIZE		equ 4
26
 
28
	PKT_BUF_SZ		equ 1544
27
	MAX_DEVICES equ 4
29
 
28
	MAX_ETH_FRAME_SIZE equ 1514
Line -... Line 29...
-
 
29
 
30
 
30
include 'proc32.inc'
31
include 'proc32.inc'
31
include 'imports.inc'
32
include 'imports.inc'
32
include 'fdo.inc'
Line 33... Line -...
33
include 'fdo.inc'
-
 
34
include 'netdrv.inc'
-
 
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 ?
-
 
Line 46... Line 33...
46
	.reserved	dd ?
33
include 'netdrv.inc'
Line 47... Line 34...
47
	.size:
34
 
Line 48... Line 35...
48
}
35
 
Line 49... Line -...
49
 
-
 
50
virtual at 0
-
 
51
 buf_head buf_head
-
 
52
end virtual
-
 
53
 
-
 
54
virtual at ebx
-
 
55
 
-
 
56
	device:
36
public START
57
 
-
 
58
	ETH_DEVICE
-
 
59
 
-
 
60
	.rx_buffer	dd ?
-
 
61
	.tx_buffer	dd ?
-
 
62
 
-
 
63
	.io_addr	dd ?
-
 
64
	.irq_line	db ?
-
 
65
	.pci_bus	db ?
-
 
66
	.pci_dev	db ?
-
 
67
			db ?	; align 4
-
 
Line 68... Line 37...
68
 
37
public service_proc
69
	.access_read_csr	dd ?
38
public version
70
	.access_write_csr	dd ?
39
 
71
	.access_read_bcr	dd ?
40
 
72
	.access_write_bcr	dd ?
41
virtual at ebx
73
	.access_read_rap	dd ?
42
 
74
	.access_write_rap	dd ?
43
	device:
75
	.access_reset		dd ?
44
 
Line 76... Line -...
76
 
-
 
77
	; The following fields up to .tx_ring_phys inclusive form
-
 
78
	; initialization block for hardware; do not modify  (must be 4-aligned)
-
 
79
 
45
	ETH_DEVICE
80
	.private:
46
 
81
	.mode_		dw ?
47
; device specific
82
	.tlen_rlen	dw ?
48
 
83
	.phys_addr	dp ?
49
      .private:
Line 101... Line 67...
101
	.ltint		db ?
67
      .ltint		db ?
102
	.dxsuflo	db ?
68
      .dxsuflo		db ?
103
	.fset		db ?
69
      .fset		db ?
104
	.fdx		db ?
70
      .fdx		db ?
Line 105... Line 71...
105
 
71
 
106
	.size = $ - device
-
 
107
 
72
      .rx_buffer	dd ?
Line -... Line 73...
-
 
73
      .tx_buffer	dd ?
-
 
74
 
-
 
75
      .io_addr		dd ?
-
 
76
      .irq_line 	db ?
Line 108... Line -...
108
end virtual
-
 
Line 109... Line 77...
109
 
77
      .pci_bus		db ?
110
 
78
      .pci_dev		db ?
111
struc rx_desc_2 { ; Swstyle 2
79
 
112
 
-
 
113
	.rbadr		dd ?
-
 
114
	.status 	dd ?
-
 
115
	.rfrtag 	dd ?
-
 
116
 
80
 
117
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
-
 
118
; |Address |  31 |  30 |  29 |  28 |  27 |  26 |  25 |  24 |  23 |  22 |  21 |  20 |19-16|15-12|11-0 |
81
      .access_read_csr		dd ?
119
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
-
 
120
; |CRDA+00h|                                       RBADR[31:0]                                       |
82
      .access_write_csr 	dd ?
121
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
-
 
122
; |CRDA+04h| OWN | ERR |FRAM |OFLO | CRC |BUFF | STP | ENP | BPE | PAM |LAFM | BAM | RES |1111 |BCNT |
83
      .access_read_bcr		dd ?
123
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
-
 
Line 124... Line -...
124
; |CRDA+08h| RES |                              RFRTAG[14:0]                             |0000 |MCNT |
-
 
-
 
84
      .access_write_bcr 	dd ?
Line 125... Line 85...
125
; +--------+-----+-----------------------------------------------------------------------+-----+-----+
85
      .access_read_rap		dd ?
Line -... Line 86...
-
 
86
      .access_write_rap 	dd ?
126
; |CRDA+0Ch|                                    USER SPACE                               |     |     |
87
      .access_reset		dd ?
-
 
88
 
127
; +--------+-----------------------------------------------------------------------------+-----+-----+
89
      device_size	= $ - device
-
 
90
 
128
 
91
end virtual
129
}
-
 
130
 
-
 
131
struc rx_desc_3 {  ; Swstyle 3
92
 
132
 
-
 
133
	.mcnt		dd ?
-
 
134
	.status 	dd ?
-
 
135
	.rbadr		dd ?
-
 
136
 
-
 
137
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
-
 
138
; |Address |  31 |  30 |  29 |  28 |  27 |  26 |  25 |  24 |  23 |22-16|15-12|11-0 |
-
 
139
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
-
 
140
; |CRDA+00h|                      RES                      | RES | RES |0000 |MCNT |
-
 
Line -... Line 93...
-
 
93
struc buf_head {
141
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
94
	.base		dd ?
Line 142... Line 95...
142
; |CRDA+04h| OWN | ERR |FRAM |OFLO | CRC |BUFF | STP | ENP | BPE | RES |1111 |BCNT |
95
	.length 	dw ?
143
; +--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
96
	.status 	dw ?
144
; |CRDA+08h|                            RBADR[31:0]                                |
97
	.msg_length	dw ?
Line 145... Line 98...
145
; +--------+-----------------------------------------------------------------------+
98
	.misc		dw ?
146
; |CRDA+0Ch|                             USER SPACE                                |
99
	.reserved	dd ?
147
; +--------+-----------------------------------------------------------------------+
100
 
148
 
101
	.size:
149
}
102
}
150
 
103
 
151
virtual at 0
104
virtual at 0
152
 rx_desc rx_desc_2
105
 buf_head buf_head
153
end virtual
106
end virtual
154
 
107
 
155
	PORT_AUI		equ 0x00
108
	PCNET_PORT_AUI		      equ 0x00
156
	PORT_10BT		equ 0x01
109
	PCNET_PORT_10BT 	      equ 0x01
157
	PORT_GPSI		equ 0x02
110
	PCNET_PORT_GPSI 	      equ 0x02
158
	PORT_MII		equ 0x03
111
	PCNET_PORT_MII		      equ 0x03
-
 
112
	PCNET_PORT_PORTSEL	      equ 0x03
159
	PORT_PORTSEL		equ 0x03
113
	PCNET_PORT_ASEL 	      equ 0x04
160
	PORT_ASEL		equ 0x04
114
	PCNET_PORT_100		      equ 0x40
161
	PORT_100		equ 0x40
115
	PCNET_PORT_FD		      equ 0x80
-
 
116
 
162
	PORT_FD 		equ 0x80
117
	PCNET_DMA_MASK		      equ 0xffffffff
163
 
118
 
-
 
119
	PCNET_LOG_TX_BUFFERS	      equ 2
-
 
120
	PCNET_LOG_RX_BUFFERS	      equ 2
-
 
121
 
164
	DMA_MASK		equ 0xffffffff
122
	PCNET_TX_RING_SIZE	      equ 4
165
 
123
	PCNET_TX_RING_MOD_MASK	      equ (PCNET_TX_RING_SIZE-1)
166
	LOG_TX_BUFFERS		equ 2
124
	PCNET_TX_RING_LEN_BITS	      equ (PCNET_LOG_TX_BUFFERS shl 12)
167
	LOG_RX_BUFFERS		equ 2
125
 
168
 
126
	PCNET_RX_RING_SIZE	      equ 4
169
	TX_RING_MOD_MASK	equ (TX_RING_SIZE-1)
127
	PCNET_RX_RING_MOD_MASK	      equ (PCNET_RX_RING_SIZE-1)
170
	TX_RING_LEN_BITS	equ (LOG_TX_BUFFERS shl 12)
128
	PCNET_RX_RING_LEN_BITS	      equ (PCNET_LOG_RX_BUFFERS shl 4)
171
 
129
 
172
	RX_RING_MOD_MASK	equ (RX_RING_SIZE-1)
130
	PCNET_PKT_BUF_SZ	      equ 1544
173
	RX_RING_LEN_BITS	equ (LOG_RX_BUFFERS shl 4)
131
	PCNET_PKT_BUF_SZ_NEG	      equ 0xf9f8
Line 174... Line 132...
174
 
132
 
Line 175... Line 133...
175
	WIO_RDP 		equ 0x10
133
	PCNET_WIO_RDP		      equ 0x10
176
	WIO_RAP 		equ 0x12
134
	PCNET_WIO_RAP		      equ 0x12
177
	WIO_RESET		equ 0x14
135
	PCNET_WIO_RESET 	      equ 0x14
178
	WIO_BDP 		equ 0x16
136
	PCNET_WIO_BDP		      equ 0x16
179
	DWIO_RDP		equ 0x10
137
	PCNET_DWIO_RDP		      equ 0x10
180
	DWIO_RAP		equ 0x14
138
	PCNET_DWIO_RAP		      equ 0x14
181
	DWIO_RESET		equ 0x18
139
	PCNET_DWIO_RESET	      equ 0x18
182
	DWIO_BDP		equ 0x1C
140
	PCNET_DWIO_BDP		      equ 0x1C
183
	TOTAL_SIZE		equ 0x20
141
	PCNET_TOTAL_SIZE	      equ 0x20
184
 
142
 
185
; CSR registers
143
; CSR registers
186
 
144
 
187
	CSR_CSR 		equ 0x00
145
	PCNET_CSR_CSR		      equ 0x00
188
	CSR_IAB0		equ 0x01
146
	PCNET_CSR_IAB0		      equ 0x01
189
	CSR_IAB1		equ 0x02
147
	PCNET_CSR_IAB1		      equ 0x02
190
	CSR_IMR 		equ 0x03
148
	PCNET_CSR_IMR		      equ 0x03
191
	CSR_TFEAT		equ 0x04
149
	PCNET_CSR_TFEAT 	      equ 0x04
192
	CSR_EXTCTL1		equ 0x05
150
	PCNET_CSR_EXTCTL1	      equ 0x05
193
	CSR_DTBLLEN		equ 0x06
151
	PCNET_CSR_DTBLLEN	      equ 0x06
194
	CSR_EXTCTL2		equ 0x07
152
	PCNET_CSR_EXTCTL2	      equ 0x07
195
	CSR_MAR0		equ 0x08
153
	PCNET_CSR_MAR0		      equ 0x08
196
	CSR_MAR1		equ 0x09
154
	PCNET_CSR_MAR1		      equ 0x09
197
	CSR_MAR2		equ 0x0A
155
	PCNET_CSR_MAR2		      equ 0x0A
198
	CSR_MAR3		equ 0x0B
156
	PCNET_CSR_MAR3		      equ 0x0B
199
	CSR_PAR0		equ 0x0C
157
	PCNET_CSR_PAR0		      equ 0x0C
200
	CSR_PAR1		equ 0x0D
158
	PCNET_CSR_PAR1		      equ 0x0D
201
	CSR_PAR2		equ 0x0E
159
	PCNET_CSR_PAR2		      equ 0x0E
202
	CSR_MODE		equ 0x0F
160
	PCNET_CSR_MODE		      equ 0x0F
203
	CSR_RXADDR0		equ 0x18
161
	PCNET_CSR_RXADDR0	      equ 0x18
204
	CSR_RXADDR1		equ 0x19
162
	PCNET_CSR_RXADDR1	      equ 0x19
205
	CSR_TXADDR0		equ 0x1E
163
	PCNET_CSR_TXADDR0	      equ 0x1E
206
	CSR_TXADDR1		equ 0x1F
164
	PCNET_CSR_TXADDR1	      equ 0x1F
Line 207... Line 165...
207
	CSR_TXPOLL		equ 0x2F
165
	PCNET_CSR_TXPOLL	      equ 0x2F
Line 208... Line 166...
208
	CSR_RXPOLL		equ 0x31
166
	PCNET_CSR_RXPOLL	      equ 0x31
209
	CSR_RXRINGLEN		equ 0x4C
167
	PCNET_CSR_RXRINGLEN	      equ 0x4C
210
	CSR_TXRINGLEN		equ 0x4E
168
	PCNET_CSR_TXRINGLEN	      equ 0x4E
211
	CSR_DMACTL		equ 0x50
169
	PCNET_CSR_DMACTL	      equ 0x50
212
	CSR_BUSTIMER		equ 0x52
170
	PCNET_CSR_BUSTIMER	      equ 0x52
213
	CSR_MEMERRTIMEO 	equ 0x64
171
	PCNET_CSR_MEMERRTIMEO	      equ 0x64
214
	CSR_ONNOWMISC		equ 0x74
172
	PCNET_CSR_ONNOWMISC	      equ 0x74
215
	CSR_ADVFEAT		equ 0x7A
173
	PCNET_CSR_ADVFEAT	      equ 0x7A
216
	CSR_MACCFG		equ 0x7D
174
	PCNET_CSR_MACCFG	      equ 0x7D
217
	CSR_CHIPID0		equ 0x58
175
	PCNET_CSR_CHIPID0	      equ 0x58
218
	CSR_CHIPID1		equ 0x59
176
	PCNET_CSR_CHIPID1	      equ 0x59
219
 
177
 
220
; Control and Status Register (CSR0)
178
; Control and Status Register (CSR0)
221
 
179
 
Line 222... Line 180...
222
	CSR_INIT		equ 1 shl 0
180
	PCNET_CSR_INIT		      equ 1 shl 0
Line 223... Line 181...
223
	CSR_START		equ 1 shl 1
181
	PCNET_CSR_START 	      equ 1 shl 1
224
	CSR_STOP		equ 1 shl 2
182
	PCNET_CSR_STOP		      equ 1 shl 2
225
	CSR_TX			equ 1 shl 3
183
	PCNET_CSR_TX		      equ 1 shl 3
226
	CSR_TXON		equ 1 shl 4
184
	PCNET_CSR_TXON		      equ 1 shl 4
227
	CSR_RXON		equ 1 shl 5
185
	PCNET_CSR_RXON		      equ 1 shl 5
228
	CSR_INTEN		equ 1 shl 6
186
	PCNET_CSR_INTEN 	      equ 1 shl 6
229
	CSR_INTR		equ 1 shl 7
187
	PCNET_CSR_INTR		      equ 1 shl 7
230
	CSR_IDONE		equ 1 shl 8
188
	PCNET_CSR_IDONE 	      equ 1 shl 8
231
	CSR_TINT		equ 1 shl 9
189
	PCNET_CSR_TINT		      equ 1 shl 9
232
	CSR_RINT		equ 1 shl 10
190
	PCNET_CSR_RINT		      equ 1 shl 10
Line 233... Line 191...
233
	CSR_MERR		equ 1 shl 11
191
	PCNET_CSR_MERR		      equ 1 shl 11
Line 234... Line 192...
234
	CSR_MISS		equ 1 shl 12
192
	PCNET_CSR_MISS		      equ 1 shl 12
Line 235... Line 193...
235
	CSR_CERR		equ 1 shl 13
193
	PCNET_CSR_CERR		      equ 1 shl 13
236
 
194
 
237
; Interrupt masks and deferral control (CSR3)
195
; Interrupt masks and deferral control (CSR3)
238
 
196
 
239
	IMR_BSWAP		equ 0x0004
197
	PCNET_IMR_BSWAP 	      equ 0x0004
240
	IMR_ENMBA		equ 0x0008  ; enable modified backoff alg
198
	PCNET_IMR_ENMBA 	      equ 0x0008  ; enable modified backoff alg
241
	IMR_DXMT2PD		equ 0x0010
199
	PCNET_IMR_DXMT2PD	      equ 0x0010
242
	IMR_LAPPEN		equ 0x0020  ; lookahead packet processing enb
200
	PCNET_IMR_LAPPEN	      equ 0x0020  ; lookahead packet processing enb
243
	IMR_DXSUFLO		equ 0x0040  ; disable TX stop on underflow
201
	PCNET_IMR_DXSUFLO	      equ 0x0040  ; disable TX stop on underflow
244
	IMR_IDONE		equ 0x0100
202
	PCNET_IMR_IDONE 	      equ 0x0100
245
	IMR_TINT		equ 0x0200
203
	PCNET_IMR_TINT		      equ 0x0200
246
	IMR_RINT		equ 0x0400
204
	PCNET_IMR_RINT		      equ 0x0400
Line 247... Line 205...
247
	IMR_MERR		equ 0x0800
205
	PCNET_IMR_MERR		      equ 0x0800
Line 248... Line 206...
248
	IMR_MISS		equ 0x1000
206
	PCNET_IMR_MISS		      equ 0x1000
249
 
207
 
250
	IMR			equ IMR_TINT+IMR_RINT+IMR_IDONE+IMR_MERR+IMR_MISS
208
	PCNET_IMR		      equ PCNET_IMR_TINT+PCNET_IMR_RINT+PCNET_IMR_IDONE+PCNET_IMR_MERR+PCNET_IMR_MISS
251
 
209
 
252
; Test and features control (CSR4)
210
; Test and features control (CSR4)
253
 
211
 
254
	TFEAT_TXSTRTMASK	equ 0x0004
212
	PCNET_TFEAT_TXSTRTMASK	      equ 0x0004
255
	TFEAT_TXSTRT		equ 0x0008
213
	PCNET_TFEAT_TXSTRT	      equ 0x0008
256
	TFEAT_RXCCOFLOWM	equ 0x0010  ; Rx collision counter oflow
214
	PCNET_TFEAT_RXCCOFLOWM	      equ 0x0010  ; Rx collision counter oflow
257
	TFEAT_RXCCOFLOW 	equ 0x0020
215
	PCNET_TFEAT_RXCCOFLOW	      equ 0x0020
258
	TFEAT_UINT		equ 0x0040
216
	PCNET_TFEAT_UINT	      equ 0x0040
259
	TFEAT_UINTREQ		equ 0x0080
217
	PCNET_TFEAT_UINTREQ	      equ 0x0080
Line 260... Line 218...
260
	TFEAT_MISSOFLOWM	equ 0x0100
218
	PCNET_TFEAT_MISSOFLOWM	      equ 0x0100
Line 261... Line 219...
261
	TFEAT_MISSOFLOW 	equ 0x0200
219
	PCNET_TFEAT_MISSOFLOW	      equ 0x0200
262
	TFEAT_STRIP_FCS 	equ 0x0400
220
	PCNET_TFEAT_STRIP_FCS	      equ 0x0400
Line 263... Line 221...
263
	TFEAT_PAD_TX		equ 0x0800
221
	PCNET_TFEAT_PAD_TX	      equ 0x0800
Line 264... Line 222...
264
	TFEAT_TXDPOLL		equ 0x1000
222
	PCNET_TFEAT_TXDPOLL	      equ 0x1000
265
	TFEAT_DMAPLUS		equ 0x4000
223
	PCNET_TFEAT_DMAPLUS	      equ 0x4000
266
 
224
 
267
; Extended control and interrupt 1 (CSR5)
225
; Extended control and interrupt 1 (CSR5)
268
 
226
 
269
	EXTCTL1_SPND		equ 0x0001  ; suspend
227
	PCNET_EXTCTL1_SPND	      equ 0x0001  ; suspend
270
	EXTCTL1_MPMODE		equ 0x0002  ; magic packet mode
228
	PCNET_EXTCTL1_MPMODE	      equ 0x0002  ; magic packet mode
271
	EXTCTL1_MPENB		equ 0x0004  ; magic packet enable
229
	PCNET_EXTCTL1_MPENB	      equ 0x0004  ; magic packet enable
272
	EXTCTL1_MPINTEN 	equ 0x0008  ; magic packet interrupt enable
230
	PCNET_EXTCTL1_MPINTEN	      equ 0x0008  ; magic packet interrupt enable
273
	EXTCTL1_MPINT		equ 0x0010  ; magic packet interrupt
231
	PCNET_EXTCTL1_MPINT	      equ 0x0010  ; magic packet interrupt
274
	EXTCTL1_MPPLBA		equ 0x0020  ; magic packet phys. logical bcast
232
	PCNET_EXTCTL1_MPPLBA	      equ 0x0020  ; magic packet phys. logical bcast
275
	EXTCTL1_EXDEFEN 	equ 0x0040  ; excessive deferral interrupt enb.
233
	PCNET_EXTCTL1_EXDEFEN	      equ 0x0040  ; excessive deferral interrupt enb.
276
	EXTCTL1_EXDEF		equ 0x0080  ; excessive deferral interrupt
234
	PCNET_EXTCTL1_EXDEF	      equ 0x0080  ; excessive deferral interrupt
277
	EXTCTL1_SINTEN		equ 0x0400  ; system interrupt enable
235
	PCNET_EXTCTL1_SINTEN	      equ 0x0400  ; system interrupt enable
278
	EXTCTL1_SINT		equ 0x0800  ; system interrupt
236
	PCNET_EXTCTL1_SINT	      equ 0x0800  ; system interrupt
279
	EXTCTL1_LTINTEN 	equ 0x4000  ; last TX interrupt enb
237
	PCNET_EXTCTL1_LTINTEN	      equ 0x4000  ; last TX interrupt enb
Line 280... Line 238...
280
	EXTCTL1_TXOKINTD	equ 0x8000  ; TX OK interrupt disable
238
	PCNET_EXTCTL1_TXOKINTD	      equ 0x8000  ; TX OK interrupt disable
Line 281... Line 239...
281
 
239
 
282
; RX/TX descriptor len (CSR6)
240
; RX/TX descriptor len (CSR6)
283
 
241
 
284
	DTBLLEN_RLEN		equ 0x0F00
242
	PCNET_DTBLLEN_RLEN	      equ 0x0F00
285
	DTBLLEN_TLEN		equ 0xF000
243
	PCNET_DTBLLEN_TLEN	      equ 0xF000
286
 
244
 
287
; Extended control and interrupt 2 (CSR7)
245
; Extended control and interrupt 2 (CSR7)
288
 
246
 
289
	EXTCTL2_MIIPDTINTE	equ 0x0001
247
	PCNET_EXTCTL2_MIIPDTINTE      equ 0x0001
290
	EXTCTL2_MIIPDTINT	equ 0x0002
248
	PCNET_EXTCTL2_MIIPDTINT       equ 0x0002
291
	EXTCTL2_MCCIINTE	equ 0x0004
249
	PCNET_EXTCTL2_MCCIINTE	      equ 0x0004
Line 292... Line 250...
292
	EXTCTL2_MCCIINT 	equ 0x0008
250
	PCNET_EXTCTL2_MCCIINT	      equ 0x0008
Line 293... Line 251...
293
	EXTCTL2_MCCINTE 	equ 0x0010
251
	PCNET_EXTCTL2_MCCINTE	      equ 0x0010
294
	EXTCTL2_MCCINT		equ 0x0020
252
	PCNET_EXTCTL2_MCCINT	      equ 0x0020
295
	EXTCTL2_MAPINTE 	equ 0x0040
253
	PCNET_EXTCTL2_MAPINTE	      equ 0x0040
296
	EXTCTL2_MAPINT		equ 0x0080
254
	PCNET_EXTCTL2_MAPINT	      equ 0x0080
297
	EXTCTL2_MREINTE 	equ 0x0100
255
	PCNET_EXTCTL2_MREINTE	      equ 0x0100
298
	EXTCTL2_MREINT		equ 0x0200
256
	PCNET_EXTCTL2_MREINT	      equ 0x0200
299
	EXTCTL2_STINTE		equ 0x0400
257
	PCNET_EXTCTL2_STINTE	      equ 0x0400
300
	EXTCTL2_STINT		equ 0x0800
258
	PCNET_EXTCTL2_STINT	      equ 0x0800
301
	EXTCTL2_RXDPOLL 	equ 0x1000
259
	PCNET_EXTCTL2_RXDPOLL	      equ 0x1000
302
	EXTCTL2_RDMD		equ 0x2000
260
	PCNET_EXTCTL2_RDMD	      equ 0x2000
303
	EXTCTL2_RXFRTG		equ 0x4000
261
	PCNET_EXTCTL2_RXFRTG	      equ 0x4000
304
	EXTCTL2_FASTSPNDE	equ 0x8000
262
	PCNET_EXTCTL2_FASTSPNDE       equ 0x8000
305
 
263
 
306
; Mode (CSR15)
264
; Mode (CSR15)
307
 
265
 
308
	MODE_RXD		equ 0x0001  ; RX disable
266
	PCNET_MODE_RXD		      equ 0x0001  ; RX disable
309
	MODE_TXD		equ 0x0002  ; TX disable
267
	PCNET_MODE_TXD		      equ 0x0002  ; TX disable
310
	MODE_LOOP		equ 0x0004  ; loopback enable
268
	PCNET_MODE_LOOP 	      equ 0x0004  ; loopback enable
311
	MODE_TXCRCD		equ 0x0008
269
	PCNET_MODE_TXCRCD	      equ 0x0008
312
	MODE_FORCECOLL		equ 0x0010
270
	PCNET_MODE_FORCECOLL	      equ 0x0010
313
	MODE_RETRYD		equ 0x0020
271
	PCNET_MODE_RETRYD	      equ 0x0020
314
	MODE_INTLOOP		equ 0x0040
272
	PCNET_MODE_INTLOOP	      equ 0x0040
315
	MODE_PORTSEL		equ 0x0180
273
	PCNET_MODE_PORTSEL	      equ 0x0180
316
	MODE_RXVPAD		equ 0x2000
274
	PCNET_MODE_RXVPAD	      equ 0x2000
317
	MODE_RXNOBROAD		equ 0x4000
275
	PCNET_MODE_RXNOBROAD	      equ 0x4000
318
	MODE_PROMISC		equ 0x8000
276
	PCNET_MODE_PROMISC	      equ 0x8000
319
 
277
 
320
; BCR (Bus Control Registers)
278
; BCR (Bus Control Registers)
321
 
279
 
322
	BCR_MMRA		equ 0x00    ; Master Mode Read Active
280
	PCNET_BCR_MMRA		      equ 0x00	  ; Master Mode Read Active
323
	BCR_MMW 		equ 0x01    ; Master Mode Write Active
281
	PCNET_BCR_MMW		      equ 0x01	  ; Master Mode Write Active
324
	BCR_MISCCFG		equ 0x02
282
	PCNET_BCR_MISCCFG	      equ 0x02
325
	BCR_LED0		equ 0x04
283
	PCNET_BCR_LED0		      equ 0x04
326
	BCR_LED1		equ 0x05
284
	PCNET_BCR_LED1		      equ 0x05
Line 327... Line 285...
327
	BCR_LED2		equ 0x06
285
	PCNET_BCR_LED2		      equ 0x06
Line 328... Line 286...
328
	BCR_LED3		equ 0x07
286
	PCNET_BCR_LED3		      equ 0x07
329
	BCR_DUPLEX		equ 0x09
287
	PCNET_BCR_DUPLEX	      equ 0x09
330
	BCR_BUSCTL		equ 0x12
288
	PCNET_BCR_BUSCTL	      equ 0x12
331
	BCR_EECTL		equ 0x13
289
	PCNET_BCR_EECTL 	      equ 0x13
332
	BCR_SSTYLE		equ 0x14
290
	PCNET_BCR_SSTYLE	      equ 0x14
333
	BCR_PCILAT		equ 0x16
291
	PCNET_BCR_PCILAT	      equ 0x16
334
	BCR_PCISUBVENID 	equ 0x17
292
	PCNET_BCR_PCISUBVENID	      equ 0x17
335
	BCR_PCISUBSYSID 	equ 0x18
293
	PCNET_BCR_PCISUBSYSID	      equ 0x18
336
	BCR_SRAMSIZE		equ 0x19
294
	PCNET_BCR_SRAMSIZE	      equ 0x19
Line 337... Line 295...
337
	BCR_SRAMBOUND		equ 0x1A
295
	PCNET_BCR_SRAMBOUND	      equ 0x1A
Line 338... Line 296...
338
	BCR_SRAMCTL		equ 0x1B
296
	PCNET_BCR_SRAMCTL	      equ 0x1B
339
	BCR_MIICTL		equ 0x20
297
	PCNET_BCR_MIICTL	      equ 0x20
340
	BCR_MIIADDR		equ 0x21
298
	PCNET_BCR_MIIADDR	      equ 0x21
341
	BCR_MIIDATA		equ 0x22
299
	PCNET_BCR_MIIDATA	      equ 0x22
342
	BCR_PCIVENID		equ 0x23
300
	PCNET_BCR_PCIVENID	      equ 0x23
343
	BCR_PCIPCAP		equ 0x24
301
	PCNET_BCR_PCIPCAP	      equ 0x24
344
	BCR_DATA0		equ 0x25
302
	PCNET_BCR_DATA0 	      equ 0x25
345
	BCR_DATA1		equ 0x26
303
	PCNET_BCR_DATA1 	      equ 0x26
346
	BCR_DATA2		equ 0x27
304
	PCNET_BCR_DATA2 	      equ 0x27
347
	BCR_DATA3		equ 0x28
305
	PCNET_BCR_DATA3 	      equ 0x28
348
	BCR_DATA4		equ 0x29
306
	PCNET_BCR_DATA4 	      equ 0x29
349
	BCR_DATA5		equ 0x2A
307
	PCNET_BCR_DATA5 	      equ 0x2A
350
	BCR_DATA6		equ 0x2B
308
	PCNET_BCR_DATA6 	      equ 0x2B
351
	BCR_DATA7		equ 0x2C
309
	PCNET_BCR_DATA7 	      equ 0x2C
352
	BCR_ONNOWPAT0		equ 0x2D
310
	PCNET_BCR_ONNOWPAT0	      equ 0x2D
353
	BCR_ONNOWPAT1		equ 0x2E
311
	PCNET_BCR_ONNOWPAT1	      equ 0x2E
354
	BCR_ONNOWPAT2		equ 0x2F
312
	PCNET_BCR_ONNOWPAT2	      equ 0x2F
355
	BCR_PHYSEL		equ 0x31
313
	PCNET_BCR_PHYSEL	      equ 0x31
356
 
314
 
-
 
315
; RX status register
Line 357... Line -...
357
; RX status register
-
 
Line 358... Line 316...
358
 
316
 
Line 359... Line 317...
359
	RXSTAT_BPE		equ 0x0080  ; bus parity error
317
	PCNET_RXSTAT_BPE	      equ 0x0080  ; bus parity error
Line 398... Line 356...
398
;; proc START             ;;
356
;; proc START             ;;
399
;;                        ;;
357
;;                        ;;
400
;; (standard driver proc) ;;
358
;; (standard driver proc) ;;
401
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
359
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 402... Line -...
402
 
-
 
403
align 4
360
 
Line 404... Line 361...
404
proc START stdcall, state:dword
361
proc START stdcall, state:dword
405
 
362
 
Line 478... Line 435...
478
 
435
 
479
  .firstdevice:
436
  .firstdevice:
480
	cmp	[devices], MAX_DEVICES			; First check if the driver can handle one more card
437
	cmp	[devices], MAX_DEVICES			; First check if the driver can handle one more card
Line 481... Line -...
481
	jge	.fail
-
 
482
 
438
	jge	.fail
483
	push	edx
-
 
484
	stdcall KernelAlloc, device.size		; Allocate the buffer for eth_device structure
-
 
485
	pop	edx
-
 
486
	test	eax, eax
-
 
Line 487... Line 439...
487
	jz	.fail
439
 
Line 488... Line 440...
488
	mov	ebx, eax				; ebx is always used as a pointer to the structure (in driver, but also in kernel code)
440
	allocate_and_clear ebx, device_size, .fail
489
 
441
 
Line 513... Line 465...
513
	find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
465
	find_irq [device.pci_bus], [device.pci_dev], [device.irq_line]
Line 514... Line 466...
514
 
466
 
515
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
467
	DEBUGF	1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
Line 516... Line 468...
516
	[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
468
	[device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4
517
 
469
 
Line 518... Line 470...
518
	allocate_and_clear [device.tx_buffer], (RX_RING_SIZE * PKT_BUF_SZ), .err
470
	allocate_and_clear [device.tx_buffer], PCNET_RX_RING_SIZE * (PCNET_PKT_BUF_SZ + buf_head.size), .err
519
	allocate_and_clear [device.rx_buffer], (TX_RING_SIZE * PKT_BUF_SZ), .err
471
	allocate_and_clear [device.rx_buffer], PCNET_TX_RING_SIZE * (PCNET_PKT_BUF_SZ + buf_head.size), .err
520
 
472
 
521
; Ok, the eth_device structure is ready, let's probe the device
473
; Ok, the eth_device structure is ready, let's probe the device
Line 528... Line 480...
528
	test	eax, eax
480
	test	eax, eax
529
	jnz	.destroy						; If an error occured, exit
481
	jnz	.destroy							; If an error occured, exit
Line 530... Line 482...
530
 
482
 
531
	mov	[device.type], NET_TYPE_ETH
483
	mov	[device.type], NET_TYPE_ETH
532
	call	NetRegDev
-
 
533
 
484
	call	NetRegDev
534
	cmp	eax, -1
485
	cmp	eax, -1
Line 535... Line 486...
535
	je	.destroy
486
	je	.destroy
Line 549... Line 500...
549
 
500
 
Line 550... Line 501...
550
; If an error occured, remove all allocated data and exit (returning -1 in eax)
501
; If an error occured, remove all allocated data and exit (returning -1 in eax)
551
 
502
 
-
 
503
  .destroy:
552
  .destroy:
504
	; todo: reset device into virgin state
553
	; todo: reset device into virgin state
505
 
554
	dec	[devices]
506
	dec	[devices]
555
  .err:
507
  .err:
556
	DEBUGF	1,"Error, removing all data !\n"
508
	DEBUGF	1,"Error, removing all data !\n"
Line 593... Line 545...
593
;;
545
;;
594
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
546
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 595... Line 547...
595
 
547
 
596
align 4
548
align 4
-
 
549
probe:
Line 597... Line -...
597
probe:
-
 
598
 
-
 
599
; make the device a bus master
-
 
600
 
-
 
601
	make_bus_master [device.pci_bus], [device.pci_dev]
-
 
602
 
-
 
603
; create the RX-ring
-
 
604
 
-
 
605
	lea	edi, [device.rx_ring]
-
 
606
	mov	ecx, RX_RING_SIZE
-
 
607
	mov	eax, [device.rx_buffer]
-
 
608
	call	GetPgAddr
-
 
609
  .rx_init:
-
 
610
	mov	[edi + buf_head.base], eax
-
 
611
	mov	[edi + buf_head.length], - PKT_BUF_SZ
-
 
612
	mov	[edi + buf_head.status], 0x8000
-
 
613
	and	dword [edi + buf_head.msg_length], 0
-
 
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]
-
 
620
	GetRealAddr
-
 
621
	mov	[device.rx_ring_phys], eax
-
 
622
 
-
 
623
; create the Tx-ring
-
 
624
 
-
 
625
	lea	edi, [device.tx_ring]
-
 
626
	mov	ecx, TX_RING_SIZE
-
 
627
	mov	eax, [device.tx_buffer]
-
 
628
	call	GetPgAddr
-
 
629
  .tx_init:
-
 
630
	mov	[edi + buf_head.base], eax
-
 
631
	and	dword [edi + buf_head.length], 0
-
 
632
	and	dword [edi + buf_head.msg_length], 0
-
 
633
	and	dword [edi + buf_head.reserved], 0
-
 
634
	add	eax, PKT_BUF_SZ
-
 
635
	add	edi, buf_head.size
-
 
636
	loop	.tx_init
-
 
637
 
-
 
638
	lea	eax, [device.tx_ring]
-
 
639
	GetRealAddr
-
 
640
	mov	[device.tx_ring_phys], eax
-
 
641
 
-
 
642
	mov	[device.tlen_rlen], (TX_RING_LEN_BITS or RX_RING_LEN_BITS)
-
 
643
 
-
 
644
; First, we must try to use Word operations
-
 
645
	call	switch_to_wio
550
	mov	edx, [device.io_addr]
Line 646... Line 551...
646
	set_io	0
551
 
647
	call	wio_reset
552
	call	wio_reset
648
 
553
 
649
	xor	ecx, ecx
554
	xor	ecx, ecx
Line 650... Line 555...
650
	call	wio_read_csr
555
	call	wio_read_csr
651
	cmp	eax, 4
556
	cmp	eax, 4
652
	jne	.try_dwio
557
	jne	.try_dwio
653
 
558
 
654
	; Try Word I/O
559
	; Try Word I/O
655
	mov	ax, 88
560
	mov	ax , 88
656
	set_io	WIO_RAP
561
	add	edx, PCNET_WIO_RAP
657
	out	dx, ax
562
	out	dx , ax
658
	nop
563
	nop
659
	nop
564
	nop
Line 660... Line -...
660
	in	ax, dx
-
 
661
	set_io	0
-
 
662
	cmp	ax, 88
565
	in	ax , dx
Line 663... Line 566...
663
	jne	.try_dwio
566
	sub	edx, PCNET_WIO_RAP
Line 664... Line -...
664
 
-
 
665
	DEBUGF	1,"Using WIO\n"
567
	cmp	ax , 88
666
 
568
	jne	.try_dwio
Line 667... Line -...
667
	call	switch_to_wio
-
 
668
 
569
 
669
	jmp	.L1
570
	call	switch_to_wio
670
 
571
 
671
; If WIO fails, try to use DWIO
572
	jmp	.L1
Line 672... Line 573...
672
  .try_dwio:
573
 
673
	call	dwio_reset
574
  .try_dwio:
674
 
575
	call	dwio_reset
675
	set_io	0
576
 
676
	xor	ecx, ecx
577
	xor	ecx, ecx
677
	call	dwio_read_csr
578
	call	dwio_read_csr
678
	cmp	eax, 4
579
	cmp	eax, 4
-
 
580
	jne	.no_dev
679
	jne	.no_dev
581
 
680
 
582
	; Try Dword I/O
681
	; Try Dword I/O
583
	add	edx, PCNET_DWIO_RAP
Line 682... Line -...
682
	set_io	DWIO_RAP
-
 
683
	mov	eax, 88
-
 
684
	out	dx, eax
584
	mov	eax, 88
Line 685... Line 585...
685
	nop
585
	out	dx , eax
Line 686... Line -...
686
	nop
-
 
687
	in	eax, dx
586
	nop
688
	set_io	0
587
	nop
689
	cmp	ax, 88
588
	in	eax, dx
690
	jne	.no_dev
589
	sub	edx, PCNET_DWIO_RAP
691
 
-
 
692
	DEBUGF	1,"Using DWIO\n"
590
	and	eax, 0xffff
-
 
591
	cmp	eax, 88
693
 
592
	jne	.no_dev
694
	call	switch_to_dwio
593
 
695
 
594
	call	switch_to_dwio
Line 696... Line 595...
696
	jmp	.L1
595
 
697
 
596
	jmp	.L1
698
; If both methods fail, something is wrong!
597
 
699
  .no_dev:
598
  .no_dev:
Line 700... Line 599...
700
	DEBUGF	1,"PCnet device not found!\n"
599
	DEBUGF 1,"PCnet device not found!\n"
Line 718... Line 617...
718
 
617
 
719
	shr	eax, 12
618
	shr	eax, 12
720
	and	eax, 0xffff
619
	and	eax, 0xffff
Line 721... Line 620...
721
	mov	[device.chip_version], eax
620
	mov	[device.chip_version], eax
722
 
-
 
723
	DEBUGF	1,"chip version: %x\n", eax
621
 
724
 
622
	DEBUGF 1,"chip version ok\n"
725
	mov	[device.fdx], 0
623
	mov	[device.fdx], 0
726
	mov	[device.mii], 0
624
	mov	[device.mii], 0
727
	mov	[device.fset], 0
625
	mov	[device.fset], 0
Line 776... Line 674...
776
	mov	[device.mii], 1
674
	mov	[device.mii], 1
777
	jmp	.L10
675
	jmp	.L10
778
  .L8:
676
  .L8:
779
	mov	[device.name], device_l8
677
	mov	[device.name], device_l8
780
;        mov     [device.fdx], 1
678
;        mov     [device.fdx], 1
781
	mov	ecx, CSR_RXPOLL
679
	mov	ecx, PCNET_CSR_RXPOLL
782
	call	[device.access_read_bcr]
680
	call	dword [device.access_read_bcr]
783
	call	[device.access_write_bcr]
681
	call	dword [device.access_write_bcr]
784
	jmp	.L10
682
	jmp	.L10
785
  .L9:
683
  .L9:
786
	mov	[device.name], device_l9
684
	mov	[device.name], device_l9
787
;        mov     [device.fdx], 1
685
;        mov     [device.fdx], 1
788
	mov	[device.mii], 1
686
	mov	[device.mii], 1
789
  .L10:
687
  .L10:
790
	DEBUGF	1,"device name: %s\n",[device.name]
688
	DEBUGF 1,"device name: %s\n",[device.name]
Line 791... Line 689...
791
 
689
 
792
	cmp	[device.fset], 1
690
	cmp	[device.fset], 1
793
	jne	.L11
691
	jne	.L11
794
	mov	ecx, BCR_BUSCTL
692
	mov	ecx, PCNET_BCR_BUSCTL
795
	call	[device.access_read_bcr]
693
	call	[device.access_read_bcr]
796
	or	ax, 0x800
694
	or	eax, 0x800
Line 797... Line 695...
797
	call	[device.access_write_bcr]
695
	call	[device.access_write_bcr]
798
 
696
 
-
 
697
	mov	ecx, PCNET_CSR_DMACTL
-
 
698
	call	[device.access_read_csr]
799
	mov	ecx, CSR_DMACTL
699
;        and     eax, 0xc00
800
	call	[device.access_read_csr]
700
;        or      eax, 0xc00
Line 801... Line 701...
801
	mov	eax, 0xc00
701
	mov	eax, 0xc00
802
	call	[device.access_write_csr]
702
	call	[device.access_write_csr]
803
 
703
 
Line -... Line 704...
-
 
704
	mov	[device.dxsuflo],1
-
 
705
	mov	[device.ltint],1
804
	mov	[device.dxsuflo],1
706
  .L11:
805
	mov	[device.ltint],1
707
 
806
  .L11:
708
	make_bus_master [device.pci_bus], [device.pci_dev]
807
 
709
 
Line 808... Line 710...
808
	mov	eax, PORT_ASEL			; Auto-select
710
	mov	eax, PCNET_PORT_ASEL
809
	mov	[device.options], eax
711
	mov	[device.options], eax
Line 810... Line 712...
810
	mov	[device.mode_], word 0x0003
712
	mov	[device.mode_], word 0x0003
811
	mov	[device.tlen_rlen], word (TX_RING_LEN_BITS or RX_RING_LEN_BITS)
713
	mov	[device.tlen_rlen], word (PCNET_TX_RING_LEN_BITS or PCNET_RX_RING_LEN_BITS)
812
 
714
 
Line 813... Line -...
813
	mov	dword [device.filter], 0
-
 
814
	mov	dword [device.filter+4], 0
715
	mov	dword [device.filter], 0
815
 
716
	mov	dword [device.filter+4], 0
Line 816... Line -...
816
	mov	eax, IMR
-
 
817
	mov	ecx, CSR_IMR			; Write interrupt mask
-
 
818
	call	[device.access_write_csr]
717
 
Line 819... Line 718...
819
 
718
	mov	eax, PCNET_IMR
820
 
719
	mov	ecx, PCNET_CSR_IMR			; Write interrupt mask
821
align 4
720
	call	[device.access_write_csr]
Line 833... Line 732...
833
	DEBUGF	1,"\nCould not attach int handler!\n"
732
	DEBUGF	1,"\nCould not attach int handler!\n"
834
;        or      eax, -1
733
;        or      eax, -1
835
;        ret
734
;        ret
836
  @@:
735
  @@:
Line 837... Line -...
837
 
-
 
838
	set_io	0
-
 
839
	call	[device.access_reset]		; after a reset, device will be in WIO mode!
-
 
840
 
-
 
841
; Switch to dword operations
-
 
842
 
-
 
843
	DEBUGF	1,"Switching to 32-bit mode\n"
-
 
844
 
736
 
845
	mov	ecx, DWIO_RDP
-
 
846
	xor	eax, eax
-
 
847
	call	wio_write_csr
-
 
848
 
-
 
849
	call	switch_to_dwio
-
 
850
 
-
 
851
; Lets find out if we are really in 32-bit mode now..
-
 
852
 
-
 
853
	set_io	0
-
 
854
	set_io	DWIO_RAP
-
 
855
	mov	eax, 88
-
 
856
	out	dx, eax
-
 
857
	nop
-
 
858
	nop
-
 
859
	in	eax, dx
-
 
860
	set_io	0
-
 
861
	cmp	ax, 88
-
 
862
	je	.yes_dwio
-
 
863
 
-
 
864
	call	switch_to_wio			; it seems to have failed, reset device again and use wio
-
 
865
	set_io	0
737
	mov	edx, [device.io_addr]
Line 866... Line 738...
866
	call	[device.access_reset]
738
	call	[device.access_reset]
867
 
-
 
868
  .yes_dwio:
739
 
869
	set_io	0
740
	; Switch pcnet32 to 32bit mode
870
	mov	ecx, BCR_SSTYLE 		; Select Software style 2      ;;;
741
	mov	ecx, PCNET_BCR_SSTYLE
Line 871... Line 742...
871
	mov	eax, 2
742
	mov	eax, 2
872
	call	[device.access_write_bcr]
743
	call	[device.access_write_bcr]
873
 
744
 
874
	; set/reset autoselect bit
-
 
875
	mov	ecx, BCR_MISCCFG
-
 
876
	call	[device.access_read_bcr]
-
 
877
 
745
	; set/reset autoselect bit
-
 
746
	mov	ecx, PCNET_BCR_MISCCFG
-
 
747
	call	[device.access_read_bcr]
-
 
748
	and	eax,not 2
878
	test	[device.options], PORT_ASEL
749
	test	[device.options], PCNET_PORT_ASEL
879
	jnz	 .L1
750
	jz	.L1
Line 880... Line 751...
880
	and	eax, not 2
751
	or	eax, 2
881
  .L1:
752
  .L1:
882
	call	[device.access_write_bcr]
753
	call	[device.access_write_bcr]
883
 
754
 
884
 
755
 
885
	; Handle full duplex setting
756
	; Handle full duplex setting
886
	cmp	byte [device.full_duplex], 0
757
	cmp	byte [device.full_duplex], 0
887
	je	.L2
758
	je	.L2
888
	mov	ecx, BCR_DUPLEX
759
	mov	ecx, PCNET_BCR_DUPLEX
889
	call	[device.access_read_bcr]
760
	call	[device.access_read_bcr]
890
	and	eax, not 3
761
	and	eax, not 3
891
	test	[device.options], PORT_FD
762
	test	[device.options], PCNET_PORT_FD
892
	jz	.L3
763
	jz	.L3
893
	or	eax, 1
764
	or	eax, 1
894
	cmp	[device.options], PORT_FD or PORT_AUI
765
	cmp	[device.options], PCNET_PORT_FD or PCNET_PORT_AUI
895
	jne	.L4
766
	jne	.L4
896
	or	eax, 2
767
	or	eax, 2
897
	jmp	.L4
768
	jmp	.L4
898
  .L3:
769
  .L3:
899
	test	[device.options], PORT_ASEL
770
	test	[device.options], PCNET_PORT_ASEL
900
	jz	.L4
771
	jz	.L4
901
	cmp	[device.chip_version], 0x2627
772
	cmp	[device.chip_version], 0x2627
902
	jne	.L4
773
	jne	.L4
Line 903... Line 774...
903
	or	eax, 3
774
	or	eax, 3
904
  .L4:
775
  .L4:
905
	mov	ecx, BCR_DUPLEX
776
	mov	ecx, PCNET_BCR_DUPLEX
906
	call	[device.access_write_bcr]
777
	call	[device.access_write_bcr]
907
  .L2:
778
  .L2:
908
 
779
 
909
 
780
 
910
	; set/reset GPSI bit in test register
781
	; set/reset GPSI bit in test register
911
	mov	ecx, 124
782
	mov	ecx, 124
912
	call	[device.access_read_csr]
783
	call	[device.access_read_csr]
913
	mov	ecx, [device.options]
784
	mov	ecx, [device.options]
914
	and	ecx, PORT_PORTSEL
785
	and	ecx, PCNET_PORT_PORTSEL
915
	cmp	ecx, PORT_GPSI
786
	cmp	ecx, PCNET_PORT_GPSI
916
	jne	.L5
787
	jne	.L5
917
	or	eax, 0x10
788
	or	eax, 0x10
918
  .L5:
789
  .L5:
919
	call	[device.access_write_csr]
790
	call	[device.access_write_csr]
920
	cmp	[device.mii], 0
791
	cmp	[device.mii], 0
921
	je	.L6
792
	je	.L6
922
	test	[device.options], PORT_ASEL
793
	test	[device.options], PCNET_PORT_ASEL
923
	jnz	.L6
794
	jnz	.L6
924
	mov	ecx, BCR_MIICTL
795
	mov	ecx, PCNET_BCR_MIICTL
925
	call	[device.access_read_bcr]
796
	call	[device.access_read_bcr]
926
	and	eax,not 0x38
797
	and	eax,not 0x38
927
	test	[device.options], PORT_FD
798
	test	[device.options], PCNET_PORT_FD
928
	jz	.L7
799
	jz	.L7
929
	or	eax, 0x10
800
	or	eax, 0x10
930
  .L7:
801
  .L7:
931
	test	[device.options], PORT_100
802
	test	[device.options], PCNET_PORT_100
932
	jz	.L8
803
	jz	.L8
933
	or	eax, 0x08
804
	or	eax, 0x08
934
  .L8:
805
  .L8:
935
	call	[device.access_write_bcr]
806
	call	[device.access_write_bcr]
936
	jmp	.L9
807
	jmp	.L9
937
.L6:
808
.L6:
938
	test	[device.options], PORT_ASEL
809
	test	[device.options], PCNET_PORT_ASEL
Line 950... Line 821...
950
	call	[device.access_read_csr]
821
	call	[device.access_read_csr]
951
	or	eax,(1 shl 14)
822
	or	eax,(1 shl 14)
952
	call	[device.access_write_csr]
823
	call	[device.access_write_csr]
953
.L10:
824
.L10:
954
	mov	eax, [device.options]
825
	mov	eax,[device.options]
955
	and	eax, PORT_PORTSEL
826
	and	eax,PCNET_PORT_PORTSEL
956
	shl	eax, 7
827
	shl	eax,7
957
	mov	[device.mode_], ax
828
	mov	[device.mode_],ax
958
	mov	dword [device.filter], -1
829
	mov	dword [device.filter], -1
959
	mov	dword [device.filter+4], -1
830
	mov	dword [device.filter+4], -1
Line 963... Line 834...
963
	lea	esi, [device.mac]
834
	lea	esi, [device.mac]
964
	lea	edi, [device.phys_addr]
835
	lea	edi, [device.phys_addr]
965
	movsd
836
	movsd
966
	movsw
837
	movsw
Line -... Line 838...
-
 
838
 
-
 
839
	call	init_ring
967
 
840
 
968
	lea	eax, [device.private]
841
	lea	eax, [device.private]
-
 
842
	GetRealAddr
969
	GetRealAddr
843
 
970
	push	eax
844
	push	eax
971
	and	eax, 0xffff
845
	and	eax, 0xffff
972
	mov	ecx, 1
846
	mov	ecx, 1
973
	call	[device.access_write_csr]
847
	call	[device.access_write_csr]
Line 978... Line 852...
978
 
852
 
979
	mov	ecx, 4
853
	mov	ecx,4
980
	mov	eax, 0x0915
854
	mov	eax,0x0915
Line 981... Line 855...
981
	call	[device.access_write_csr]
855
	call	[device.access_write_csr]
982
 
856
 
983
	xor	ecx, ecx
857
	mov	ecx,0
Line 984... Line 858...
984
	mov	eax, 1
858
	mov	eax,1
985
	call	[device.access_write_csr]
859
	call	[device.access_write_csr]
Line 994... Line 868...
994
.L11:
868
.L11:
995
	push	ecx
869
	push	ecx
996
	xor	ecx, ecx
870
	xor	ecx,ecx
997
	call	[device.access_read_csr]
871
	call	[device.access_read_csr]
998
	pop	ecx
872
	pop	ecx
999
	push	esi
-
 
1000
	mov	esi, 100
-
 
1001
	call	Sleep
-
 
1002
	pop	esi
-
 
1003
	test	ax, 0x100
873
	test	ax,0x100
1004
	jnz	.L12
874
	jnz	.L12
1005
	loop	.L11
875
	loop	.L11
1006
.L12:
876
.L12:
Line 1007... Line 877...
1007
 
877
 
1008
	DEBUGF 1,"Starting up device\n"
878
	DEBUGF 1,"hardware reset\n"
1009
	xor	ecx, ecx
879
	xor	ecx, ecx
1010
	mov	eax, 0x0002
880
	mov	eax, 0x0002
Line 1011... Line 881...
1011
	call	[device.access_write_csr]
881
	call	[device.access_write_csr]
1012
 
882
 
Line 1013... Line 883...
1013
	xor	ecx, ecx
883
	xor	ecx, ecx
1014
	call	[device.access_read_csr]
884
	call	[device.access_read_csr]
1015
 
885
 
Line -... Line 886...
-
 
886
	xor	ecx, ecx
-
 
887
	mov	eax, PCNET_CSR_INTEN or PCNET_CSR_START
-
 
888
	call	[device.access_write_csr]
1016
	xor	ecx, ecx
889
 
1017
	mov	eax, CSR_INTEN or CSR_START
890
; Set the mtu, kernel will be able to send now
1018
	call	[device.access_write_csr]
-
 
1019
 
-
 
1020
	DEBUGF 1,"PCNET reset complete\n"
-
 
1021
	xor	eax, eax
891
	mov	[device.mtu], 1514
Line -... Line 892...
-
 
892
 
-
 
893
	DEBUGF 1,"PCNET reset complete\n"
-
 
894
	xor	eax, eax
-
 
895
	ret
-
 
896
 
-
 
897
 
-
 
898
align 4
-
 
899
init_ring:
-
 
900
 
-
 
901
	mov	ecx, PCNET_RX_RING_SIZE
-
 
902
	mov	edi, [device.rx_buffer]
-
 
903
	mov	eax, edi
-
 
904
	GetRealAddr
-
 
905
	mov	[device.rx_ring_phys], eax
-
 
906
	add	eax, PCNET_RX_RING_SIZE * buf_head.size
1022
; clear packet/byte counters
907
  .rx_init:
-
 
908
	mov	[edi + buf_head.base], eax
-
 
909
	mov	[edi + buf_head.length], PCNET_PKT_BUF_SZ_NEG
-
 
910
	mov	[edi + buf_head.status], 0x8000
-
 
911
	and	dword [edi + buf_head.msg_length], 0
-
 
912
	and	dword [edi + buf_head.reserved], 0
1023
	lea	edi, [device.bytes_tx]
913
	add	eax, PCNET_PKT_BUF_SZ
-
 
914
	add	edi, buf_head.size
-
 
915
	loop	.rx_init
-
 
916
 
-
 
917
	mov	ecx, PCNET_TX_RING_SIZE
-
 
918
	mov	edi, [device.tx_buffer]
-
 
919
	mov	eax, edi
-
 
920
	GetRealAddr
-
 
921
	mov	[device.tx_ring_phys], eax
-
 
922
	add	eax, PCNET_TX_RING_SIZE * buf_head.size
-
 
923
  .tx_init:
-
 
924
	mov	[edi + buf_head.base], eax
-
 
925
	and	dword [edi + buf_head.length], 0
-
 
926
	and	dword [edi + buf_head.msg_length], 0
-
 
927
	and	dword [edi + buf_head.reserved], 0
Line 1024... Line 928...
1024
	mov	ecx, 6
928
	add	eax, PCNET_PKT_BUF_SZ
Line 1056... Line 960...
1056
	cmp	dword [esp+8], 60
960
	cmp	dword [esp+8], 60
1057
	jl	.finish 			; packet is too short
961
	jl	.finish 			; packet is too short
Line 1058... Line 962...
1058
 
962
 
1059
; check descriptor
963
; check descriptor
1060
	movzx	eax, [device.cur_tx]
964
	movzx	eax, [device.cur_tx]
1061
	imul	edi, eax, PKT_BUF_SZ
965
	imul	edi, eax, PCNET_PKT_BUF_SZ
-
 
966
	shl	eax, 4
1062
	shl	eax, 4
967
	add	eax, [device.tx_buffer]
1063
	add	edi, [device.tx_buffer]
-
 
1064
 
968
	add	edi, [device.tx_buffer]
Line 1065... Line 969...
1065
	lea	eax, [eax + device.tx_ring]
969
	add	edi, PCNET_TX_RING_SIZE * buf_head.size
1066
 
970
 
1067
	test	byte [eax + buf_head.status + 1], 80h
-
 
1068
	jnz	.nospace
971
	test	byte [eax + buf_head.status + 1], 80h
1069
 
972
	jnz	.nospace
1070
; descriptor is free, copy data
973
; descriptor is free, copy data
1071
	mov	esi, [esp+4]
974
	mov	esi, [esp+4]
1072
	mov	ecx, [esp+8]
975
	mov	ecx, [esp+8]
1073
	mov	edx, ecx
976
	mov	edx, ecx
1074
	shr	ecx, 2
977
	shr	ecx, 2
1075
	and	edx, 3
978
	and	edx, 3
1076
	rep	movsd
979
	rep	movsd
1077
	mov	ecx, edx
-
 
1078
	rep	movsb
980
	mov	ecx, edx
1079
 
981
	rep	movsb
1080
; set length
982
; set length
1081
	mov	ecx, [esp+8]
983
	mov	ecx, [esp+8]
1082
	neg	ecx
984
	neg	ecx
1083
	mov	[eax + buf_head.length], cx
985
	mov	[eax + buf_head.length], cx
Line 1084... Line 986...
1084
; put to transfer queue
986
; put to transfer queue
1085
	mov	[eax + buf_head.status], 0x8300
987
	mov	[eax + buf_head.status], 0x8300
1086
 
988
 
1087
; trigger an immediate send
989
; trigger an immediate send
1088
	xor	ecx, ecx	 ; CSR0
990
	xor	ecx, ecx	 ; CSR0
Line 1089... Line 991...
1089
	call	[device.access_read_csr]
991
	call	[device.access_read_csr]
1090
	or	eax, CSR_TX
992
	or	eax, PCNET_CSR_TX
1091
	call	[device.access_write_csr]
993
	call	[device.access_write_csr]
1092
 
994
 
Line 1093... Line 995...
1093
; get next descriptor 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ...
995
; get next descriptor 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, ...
1094
	inc	[device.cur_tx]
-
 
1095
	and	[device.cur_tx], 3
-
 
1096
	DEBUGF	2," - Packet Sent! "
-
 
1097
 
-
 
1098
.finish:
-
 
1099
; update statistics
-
 
1100
	inc	[device.packets_tx]
996
	inc	[device.cur_tx]
1101
 
-
 
1102
	mov	ecx, [esp+8]
997
	and	[device.cur_tx], 3
1103
	add	dword [device.bytes_tx], ecx
998
	DEBUGF	2," - Packet Sent! "
Line 1104... Line 999...
1104
	adc	dword [device.bytes_tx + 4], 0
999
 
1105
	DEBUGF	2," - Done!\n"
1000
.finish:
1106
 
1001
	DEBUGF	2," - Done!\n"
1107
	stdcall KernelFree, [esp+4]
-
 
1108
	ret	8
1002
	stdcall KernelFree, [esp+4]
1109
 
1003
	ret	8
Line 1123... Line 1017...
1123
;;;;;;;;;;;;;;;;;;;;;;;
1017
;;;;;;;;;;;;;;;;;;;;;;;
Line 1124... Line 1018...
1124
 
1018
 
1125
align 4
1019
align 4
Line 1126... Line 1020...
1126
int_handler:
1020
int_handler:
Line 1127... Line 1021...
1127
 
1021
 
Line 1128... Line 1022...
1128
	DEBUGF	1,"IRQ=%x ", eax:2		; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO
1022
;       DEBUGF  1,"IRQ %x ",eax:2                   ; no, you cant replace 'eax:2' with 'al', this must be a bug in FDO
1129
 
1023
 
1130
; find pointer of device wich made IRQ occur
1024
; find pointer of device wich made IRQ occur
1131
 
1025
 
1132
	mov	esi, device_list
1026
	mov	esi, device_list
1133
	mov	ecx, [devices]
1027
	mov	ecx, [devices]
1134
	test	ecx, ecx
1028
	test	ecx, ecx
Line 1135... Line 1029...
1135
	jz	.abort
1029
	jz	.abort
1136
  .nextdevice:
1030
  .nextdevice:
1137
	mov	ebx, [esi]
1031
	mov	ebx, dword [esi]
1138
	set_io	0
1032
	mov	edx, [device.io_addr]	  ; get IRQ reason
Line 1139... Line 1033...
1139
 
1033
 
1140
	push	ecx
1034
	push	ecx
Line 1141... Line 1035...
1141
	xor	ecx, ecx ; CSR0
1035
	xor	ecx, ecx ; CSR0
1142
	call	[device.access_read_csr]       ; get IRQ reason
1036
	call	[device.access_read_csr]
Line 1143... Line 1037...
1143
	pop	ecx
1037
	pop	ecx
Line 1144... Line 1038...
1144
 
1038
 
1145
	test	ax , ax
-
 
1146
	jnz	.got_it
1039
	test	al , al
1147
 
1040
	js	.got_it
1148
	add	esi, 4
1041
 
1149
	loop	.nextdevice
1042
	add	esi, 4
1150
 
1043
	loop	.nextdevice
Line 1162... Line 1055...
1162
; to two or more reasons in one IRQ.
1055
; to two or more reasons in one IRQ.
1163
	xor	ecx, ecx
1056
	xor	ecx, ecx
1164
	call	[device.access_write_csr]
1057
	call	[device.access_write_csr]
1165
; Received packet ok?
1058
; Received packet ok?
Line 1166... Line 1059...
1166
 
1059
 
1167
	test	ax, CSR_RINT
1060
	test	ax, PCNET_CSR_RINT
Line 1168... Line -...
1168
	jz	@f
-
 
1169
 
-
 
1170
	push	ax
-
 
1171
 
-
 
1172
	DEBUGF	1,"packet received!\n"
1061
	jz	@f
1173
 
1062
 
1174
 .receiver_test_loop:
1063
.receiver_test_loop:
1175
	movzx	eax, [device.cur_rx]
1064
	movzx	eax, [device.cur_rx]
Line 1176... Line 1065...
1176
;        and     eax, RX_RING_MOD_MASK
1065
;        and     eax, PCNET_RX_RING_MOD_MASK
1177
	mov	edi, eax
1066
	mov	edi, eax
-
 
1067
 
Line 1178... Line 1068...
1178
 
1068
	imul	esi, eax, PCNET_PKT_BUF_SZ	;
1179
	imul	esi, eax, PKT_BUF_SZ	  ;
1069
	add	esi, [device.rx_buffer] 	; esi now points to rx buffer
Line 1180... Line 1070...
1180
	add	esi, [device.rx_buffer] 	; esi now points to rx buffer
1070
	add	esi, PCNET_RX_RING_SIZE * buf_head.size
Line 1181... Line 1071...
1181
 
1071
 
1182
	shl	edi, 4				; desc * 16 (16 is size of one ring entry)
1072
	shl	edi, 4				; desc * 16 (16 is size of one ring entry)
Line 1183... Line 1073...
1183
	lea	edi, [edi + device.rx_ring]	; edi now points to current rx ring entry
1073
	add	edi, [device.rx_buffer]     ; edi now points to current rx ring entry
1184
 
1074
 
Line 1185... Line 1075...
1185
	mov	cx , [edi + buf_head.status]
1075
	mov	cx , [edi + buf_head.status]
1186
 
1076
 
Line 1187... Line 1077...
1187
	test	cx , RXSTAT_OWN 	  ; If this bit is set, the controller OWN's the packet, if not, we do
1077
	test	cx , PCNET_RXSTAT_OWN		; If this bit is set, the controller OWN's the packet, if not, we do
1188
	jnz	.abort
1078
	jnz	.abort
Line 1204... Line 1094...
1204
 
1094
 
1205
	push	.receiver_test_loop		;
1095
	push	.receiver_test_loop		;
1206
	push	ecx				; for eth_receiver
1096
	push	ecx				; for eth_receiver
Line 1207... Line -...
1207
	push	eax				;
-
 
1208
 
-
 
1209
; update statistics
-
 
1210
	inc	[device.packets_rx]
-
 
1211
 
-
 
1212
	add	dword [device.bytes_rx], ecx
-
 
1213
	adc	dword [device.bytes_rx + 4], 0
1097
	push	eax				;
1214
 
-
 
1215
	xchg	edi, eax
-
 
1216
 
-
 
1217
; copy packet data
1098
 
1218
	shr	cx , 1
-
 
1219
	jnc	.nb
-
 
1220
	movsb
1099
	xchg	edi, eax
1221
  .nb:
-
 
1222
	shr	cx , 1
1100
	push	ecx
1223
	jnc	.nw
-
 
1224
	movsw
1101
	shr	ecx, 2
-
 
1102
	cld
-
 
1103
	rep	movsd
-
 
1104
	pop	ecx
Line 1225... Line 1105...
1225
  .nw:
1105
	and	ecx, 3
1226
	rep	movsd
1106
	rep	movsb
Line 1227... Line 1107...
1227
 
1107
 
1228
;       mov     word [eax + buf_head.length], PKT_BUF_SZ_NEG
1108
;       mov     word [eax + buf_head.length], PCNET_PKT_BUF_SZ_NEG
Line 1229... Line -...
1229
	mov	word [eax + buf_head.status], RXSTAT_OWN      ; Set OWN bit back to 1 (controller may write to tx-buffer again now)
-
 
1230
 
1109
	mov	word [eax + buf_head.status], PCNET_RXSTAT_OWN	    ; Set OWN bit back to 1 (controller may write to tx-buffer again now)
Line 1231... Line 1110...
1231
	inc	[device.cur_rx] 	  ; update descriptor
1110
 
1232
	and	[device.cur_rx], 3	  ;
-
 
1233
 
-
 
1234
	DEBUGF	1,"Inserting packet\n"
-
 
1235
	jmp	EthReceiver			; Send the copied packet to kernel
-
 
1236
 
-
 
1237
  .abort:
-
 
1238
	pop	ax
-
 
1239
  @@:
-
 
1240
 
-
 
1241
	test	ax, IMR_TINT
-
 
1242
	jz	@f
-
 
1243
 
-
 
1244
	DEBUGF	1,"Transmit OK!\n"
-
 
1245
 
-
 
Line 1246... Line 1111...
1246
  @@:
1111
	inc	[device.cur_rx] 	  ; update descriptor
Line 1247... Line -...
1247
 
-
 
1248
	test	ax, IMR_MISS
-
 
1249
	jz	@f
1112
	and	[device.cur_rx], 3	  ;
Line 1268... Line 1131...
1268
align 4
1131
align 4
1269
write_mac:	; in: mac pushed onto stack (as 3 words)
1132
write_mac:	; in: mac pushed onto stack (as 3 words)
Line 1270... Line 1133...
1270
 
1133
 
Line 1271... Line 1134...
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
1134
	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
1272
 
1135
 
1273
	set_io	0
1136
	mov	edx, [device.io_addr]
-
 
1137
	add	dx, 2
1274
;        set_io  2
1138
	xor	eax, eax
1275
	xor	eax, eax
1139
 
1276
	mov	ecx, CSR_PAR0
1140
	mov	ecx, PCNET_CSR_PAR0
1277
       @@:
1141
       @@:
1278
	pop	ax
1142
	pop	ax
1279
	call	[device.access_write_csr]
1143
	call	[device.access_write_csr]
1280
	DEBUGF	1,"."
1144
	DEBUGF	1,"."
1281
	inc	ecx
1145
	inc	ecx
Line 1282... Line 1146...
1282
	cmp	ecx, CSR_PAR2
1146
	cmp	ecx, PCNET_CSR_PAR2
Line 1283... Line 1147...
1283
	jl	@r
1147
	jl	@r
Line 1289... Line 1153...
1289
;;;;;;;;;;;;;;;;;;;;;;
1153
;;;;;;;;;;;;;;;;;;;;;;
1290
;;                  ;;
1154
;;                  ;;
1291
;; Read MAC address ;;
1155
;; Read MAC address ;;
1292
;;                  ;;
1156
;;                  ;;
1293
;;;;;;;;;;;;;;;;;;;;;;
1157
;;;;;;;;;;;;;;;;;;;;;;
1294
 
1158
align 4
1295
read_mac:
1159
read_mac:
1296
	DEBUGF	1,"Reading MAC"
1160
	DEBUGF	1,"Reading MAC"
Line 1297... Line 1161...
1297
 
1161
 
1298
	set_io	0
1162
	mov	edx, [device.io_addr]
1299
	set_io	6
1163
	add	dx, 6
1300
       @@:
1164
       @@:
1301
	dec	dx
1165
	dec	dx
1302
	dec	dx
1166
	dec	dx
1303
	in	ax, dx
1167
	in	ax, dx
Line 1316... Line 1180...
1316
	pop	ax
1180
	pop	ax
1317
	stosw
1181
	stosw
Line 1318... Line 1182...
1318
 
1182
 
Line 1319... Line 1183...
1319
	ret
1183
	ret
1320
 
1184
 
-
 
1185
align 4
1321
 
1186
switch_to_wio:
Line 1322... Line 1187...
1322
switch_to_wio:
1187
 
1323
	DEBUGF	1,"Switch to WIO\n"
1188
	DEBUGF	1,"Switching to 16-bit mode\n"
1324
 
1189
 
1325
	mov	[device.access_read_csr], wio_read_csr
1190
	mov	[device.access_read_csr], wio_read_csr
Line 1330... Line 1195...
1330
	mov	[device.access_write_rap], wio_write_rap
1195
	mov	[device.access_write_rap], wio_write_rap
1331
	mov	[device.access_reset], wio_reset
1196
	mov	[device.access_reset], wio_reset
Line 1332... Line 1197...
1332
 
1197
 
Line -... Line 1198...
-
 
1198
	ret
1333
	ret
1199
 
-
 
1200
align 4
1334
 
1201
switch_to_dwio:
Line 1335... Line 1202...
1335
switch_to_dwio:
1202
 
1336
	DEBUGF	1,"Switch to DWIO\n"
1203
	DEBUGF	1,"Switching to 32-bit mode\n"
1337
 
1204
 
1338
	mov	[device.access_read_csr], dwio_read_csr
1205
	mov	[device.access_read_csr], dwio_read_csr
Line 1344... Line 1211...
1344
	mov	[device.access_reset], dwio_reset
1211
	mov	[device.access_reset], dwio_reset
Line 1345... Line 1212...
1345
 
1212
 
Line 1346... Line -...
1346
	ret
-
 
1347
 
-
 
1348
 
-
 
1349
 
1213
	ret
1350
 
1214
 
1351
 
1215
 
-
 
1216
; ecx - index
1352
; ecx - index
1217
; return:
Line 1353... Line 1218...
1353
; return:
1218
; eax - data
1354
; eax - data
1219
align 4
1355
wio_read_csr:
1220
wio_read_csr:
1356
 
1221
 
1357
	add	edx, WIO_RAP
1222
	add	edx, PCNET_WIO_RAP
1358
	mov	ax , cx
1223
	mov	ax , cx
1359
	out	dx , ax
1224
	out	dx , ax
Line 1360... Line 1225...
1360
	add	edx, WIO_RDP - WIO_RAP
1225
	add	edx, PCNET_WIO_RDP - PCNET_WIO_RAP
Line 1361... Line 1226...
1361
	in	ax , dx
1226
	in	ax , dx
1362
	and	eax, 0xffff
1227
	and	eax, 0xffff
-
 
1228
	sub	edx, PCNET_WIO_RDP
1363
	sub	edx, WIO_RDP
1229
 
Line 1364... Line 1230...
1364
 
1230
	ret
1365
	ret
1231
 
1366
 
1232
 
1367
 
1233
; eax - data
1368
; eax - data
1234
; ecx - index
1369
; ecx - index
1235
align 4
1370
wio_write_csr:
1236
wio_write_csr:
Line 1371... Line 1237...
1371
 
1237
 
Line 1372... Line 1238...
1372
	add	edx, WIO_RAP
1238
	add	edx, PCNET_WIO_RAP
1373
	xchg	eax, ecx
1239
	xchg	eax, ecx
1374
	out	dx , ax
1240
	out	dx , ax
-
 
1241
	xchg	eax, ecx
1375
	xchg	eax, ecx
1242
	add	edx, PCNET_WIO_RDP - PCNET_WIO_RAP
Line 1376... Line 1243...
1376
	add	edx, WIO_RDP - WIO_RAP
1243
	out	dx , ax
1377
	out	dx , ax
1244
	sub	edx, PCNET_WIO_RDP
1378
	sub	edx, WIO_RDP
1245
 
1379
 
1246
	ret
1380
	ret
1247
 
1381
 
1248
 
1382
 
1249
; ecx - index
Line 1383... Line 1250...
1383
; ecx - index
1250
; return:
Line 1384... Line 1251...
1384
; return:
1251
; eax - data
1385
; eax - data
1252
align 4
-
 
1253
wio_read_bcr:
1386
wio_read_bcr:
1254
 
Line 1387... Line 1255...
1387
 
1255
	add	edx, PCNET_WIO_RAP
1388
	add	edx, WIO_RAP
1256
	mov	ax , cx
1389
	mov	ax , cx
1257
	out	dx , ax
1390
	out	dx , ax
1258
	add	edx, PCNET_WIO_BDP - PCNET_WIO_RAP
1391
	add	edx, WIO_BDP - WIO_RAP
1259
	in	ax , dx
1392
	in	ax , dx
1260
	and	eax, 0xffff
1393
	and	eax, 0xffff
1261
	sub	edx, PCNET_WIO_BDP
Line 1394... Line 1262...
1394
	sub	edx, WIO_BDP
1262
 
Line 1395... Line 1263...
1395
 
1263
	ret
1396
	ret
1264
 
Line 1397... Line 1265...
1397
 
1265
 
1398
 
1266
; eax - data
1399
; eax - data
1267
; ecx - index
1400
; ecx - index
1268
align 4
Line 1401... Line 1269...
1401
wio_write_bcr:
1269
wio_write_bcr:
Line 1402... Line 1270...
1402
 
1270
 
-
 
1271
	add	edx, PCNET_WIO_RAP
1403
	add	edx, WIO_RAP
1272
	xchg	eax, ecx
Line 1404... Line 1273...
1404
	xchg	eax, ecx
1273
	out	dx , ax
1405
	out	dx , ax
1274
	xchg	eax, ecx
1406
	xchg	eax, ecx
1275
	add	edx, PCNET_WIO_BDP - PCNET_WIO_RAP
Line 1407... Line 1276...
1407
	add	edx, WIO_BDP - WIO_RAP
1276
	out	dx , ax
Line -... Line 1277...
-
 
1277
	sub	edx, PCNET_WIO_BDP
1408
	out	dx , ax
1278
 
Line 1409... Line 1279...
1409
	sub	edx, WIO_BDP
1279
	ret
1410
 
1280
 
1411
	ret
1281
align 4
1412
 
1282
wio_read_rap:
1413
 
1283
 
Line 1414... Line 1284...
1414
wio_read_rap:
1284
	add	edx, PCNET_WIO_RAP
Line -... Line 1285...
-
 
1285
	in	ax , dx
1415
 
1286
	and	eax, 0xffff
1416
	add	edx, WIO_RAP
1287
	sub	edx, PCNET_WIO_RAP
1417
	in	ax , dx
1288
 
-
 
1289
	ret
1418
	and	eax, 0xffff
1290
 
Line 1419... Line 1291...
1419
	sub	edx, WIO_RAP
1291
; eax - val
1420
 
1292
align 4
1421
	ret
1293
wio_write_rap:
1422
 
1294
 
1423
; eax - val
1295
	add	edx, PCNET_WIO_RAP
1424
wio_write_rap:
1296
	out	dx , ax
1425
 
1297
	sub	edx, PCNET_WIO_RAP
Line 1426... Line 1298...
1426
	add	edx, WIO_RAP
1298
 
Line 1427... Line 1299...
1427
	out	dx , ax
1299
	ret
1428
	sub	edx, WIO_RAP
1300
 
-
 
1301
align 4
1429
 
1302
wio_reset:
Line 1430... Line 1303...
1430
	ret
1303
 
1431
 
1304
	push	eax
1432
wio_reset:
1305
	add	edx, PCNET_WIO_RESET
1433
 
1306
	in	ax , dx
1434
	push	eax
1307
	pop	eax
1435
	add	edx, WIO_RESET
1308
	sub	edx, PCNET_WIO_RESET
1436
	in	ax , dx
1309
 
Line 1437... Line 1310...
1437
	pop	eax
1310
	ret
Line 1438... Line 1311...
1438
	sub	edx, WIO_RESET
1311
 
1439
 
1312
 
1440
	ret
1313
 
-
 
1314
; ecx - index
1441
 
1315
; return:
Line 1442... Line 1316...
1442
 
1316
; eax - data
1443
; ecx - index
1317
align 4
1444
; return:
1318
dwio_read_csr:
1445
; eax - data
1319
 
1446
dwio_read_csr:
1320
	add	edx, PCNET_DWIO_RAP
1447
 
1321
	mov	eax, ecx
1448
	add	edx, DWIO_RAP
1322
	out	dx , eax
Line 1449... Line 1323...
1449
	mov	eax, ecx
1323
	add	edx, PCNET_DWIO_RDP - PCNET_DWIO_RAP
Line 1450... Line 1324...
1450
	out	dx , eax
1324
	in	eax, dx
1451
	add	edx, DWIO_RDP - DWIO_RAP
1325
	and	eax, 0xffff
-
 
1326
	sub	edx, PCNET_DWIO_RDP
1452
	in	eax, dx
1327
 
Line 1453... Line 1328...
1453
	and	eax, 0xffff
1328
	ret
1454
	sub	edx, DWIO_RDP
1329
 
1455
 
1330
 
1456
	ret
1331
; ecx - index
1457
 
1332
; eax - data
1458
 
1333
align 4
1459
; ecx - index
1334
dwio_write_csr:
Line 1460... Line 1335...
1460
; eax - data
1335
 
Line 1461... Line 1336...
1461
dwio_write_csr:
1336
	add	edx, PCNET_DWIO_RAP
1462
 
1337
	xchg	eax, ecx
Line 1463... Line 1338...
1463
	add	edx, DWIO_RAP
1338
	out	dx , eax
1464
	xchg	eax, ecx
1339
	add	edx, PCNET_DWIO_RDP - PCNET_DWIO_RAP
1465
	out	dx , eax
1340
	xchg	eax, ecx
1466
	add	edx, DWIO_RDP - DWIO_RAP
1341
	out	dx , eax
Line 1467... Line 1342...
1467
	xchg	eax, ecx
1342
	sub	edx, PCNET_DWIO_RDP
Line 1468... Line 1343...
1468
	out	dx , eax
1343
 
-
 
1344
	ret
1469
	sub	edx, DWIO_RDP
1345
 
Line 1470... Line 1346...
1470
 
1346
; ecx - index
1471
	ret
1347
; return:
1472
 
1348
; eax - data
Line 1473... Line 1349...
1473
; ecx - index
1349
align 4
Line 1474... Line 1350...
1474
; return:
1350
dwio_read_bcr:
1475
; eax - data
1351
 
Line 1476... Line 1352...
1476
dwio_read_bcr:
1352
	add	edx, PCNET_DWIO_RAP
1477
 
1353
	mov	eax, ecx
1478
	add	edx, DWIO_RAP
1354
	out	dx , eax
1479
	mov	eax, ecx
1355
	add	edx, PCNET_DWIO_BDP - PCNET_DWIO_RAP
1480
	out	dx , eax
1356
	in	eax, dx
Line 1481... Line 1357...
1481
	add	edx, DWIO_BDP - DWIO_RAP
1357
	and	eax, 0xffff
Line 1482... Line 1358...
1482
	in	eax, dx
1358
	sub	edx, PCNET_DWIO_BDP
-
 
1359
 
1483
	and	eax, 0xffff
1360
	ret
Line 1484... Line 1361...
1484
	sub	edx, DWIO_BDP
1361
 
1485
 
1362
 
1486
	ret
1363
; ecx - index
Line 1487... Line 1364...
1487
 
1364
; eax - data
1488
 
1365
align 4
1489
; ecx - index
1366
dwio_write_bcr:
Line 1547... Line 1424...
1547
device_l7     db "PCnet/FAST III 79C973",0
1424
device_l7     db "PCnet/FAST III 79C973",0
1548
device_l8     db "PCnet/Home 79C978",0
1425
device_l8     db "PCnet/Home 79C978",0
1549
device_l9     db "PCnet/FAST III 79C975",0
1426
device_l9     db "PCnet/FAST III 79C975",0
Line 1550... Line 1427...
1550
 
1427
 
1551
options_mapping:
1428
options_mapping:
1552
dd PORT_ASEL					  ;  0 Auto-select
1429
dd PCNET_PORT_ASEL					;  0 Auto-select
1553
dd PORT_AUI					  ;  1 BNC/AUI
1430
dd PCNET_PORT_AUI					;  1 BNC/AUI
1554
dd PORT_AUI					  ;  2 AUI/BNC
1431
dd PCNET_PORT_AUI					;  2 AUI/BNC
1555
dd PORT_ASEL					  ;  3 not supported
1432
dd PCNET_PORT_ASEL					;  3 not supported
1556
dd PORT_10BT or PORT_FD 			  ;  4 10baseT-FD
1433
dd PCNET_PORT_10BT or PCNET_PORT_FD			;  4 10baseT-FD
1557
dd PORT_ASEL					  ;  5 not supported
1434
dd PCNET_PORT_ASEL					;  5 not supported
1558
dd PORT_ASEL					  ;  6 not supported
1435
dd PCNET_PORT_ASEL					;  6 not supported
1559
dd PORT_ASEL					  ;  7 not supported
1436
dd PCNET_PORT_ASEL					;  7 not supported
1560
dd PORT_ASEL					  ;  8 not supported
1437
dd PCNET_PORT_ASEL					;  8 not supported
1561
dd PORT_MII					  ;  9 MII 10baseT
1438
dd PCNET_PORT_MII					;  9 MII 10baseT
1562
dd PORT_MII or PORT_FD				  ; 10 MII 10baseT-FD
1439
dd PCNET_PORT_MII or PCNET_PORT_FD			; 10 MII 10baseT-FD
1563
dd PORT_MII					  ; 11 MII (autosel)
1440
dd PCNET_PORT_MII					; 11 MII (autosel)
1564
dd PORT_10BT					  ; 12 10BaseT
1441
dd PCNET_PORT_10BT					; 12 10BaseT
1565
dd PORT_MII or PORT_100 			  ; 13 MII 100BaseTx
1442
dd PCNET_PORT_MII or PCNET_PORT_100			; 13 MII 100BaseTx
1566
dd PORT_MII or PORT_100 or PORT_FD		  ; 14 MII 100BaseTx-FD
1443
dd PCNET_PORT_MII or PCNET_PORT_100 or PCNET_PORT_FD	; 14 MII 100BaseTx-FD
Line 1567... Line 1444...
1567
dd PORT_ASEL					  ; 15 not supported
1444
dd PCNET_PORT_ASEL					; 15 not supported
Line 1568... Line 1445...
1568
 
1445