Subversion Repositories Kolibri OS

Rev

Rev 1635 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1635 Rev 2434
Line 22... Line 22...
22
;;  See file COPYING for details                                   ;;
22
;;  See file COPYING for details                                   ;;
23
;;                                                                 ;;
23
;;                                                                 ;;
24
;;                                                                 ;;
24
;;                                                                 ;;
25
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 26... Line 26...
26
 
26
 
Line 27... Line 27...
27
$Revision: 782 $
27
$Revision: 2434 $
28
 
28
 
29
 
29
 
Line 37... Line 37...
37
;      These functions are referenced in ethernet.inc
37
;      These functions are referenced in ethernet.inc
38
;
38
;
39
;********************************************************************
39
;********************************************************************
Line 40... Line 40...
40
 
40
 
41
 
41
 
42
rxfd_status		equ  eth_data_start
42
rxfd_status             equ  eth_data_start
43
rxfd_command		equ  eth_data_start + 2
43
rxfd_command            equ  eth_data_start + 2
44
rxfd_link		equ  eth_data_start + 4
44
rxfd_link               equ  eth_data_start + 4
45
rxfd_rx_buf_addr	equ  eth_data_start + 8
45
rxfd_rx_buf_addr        equ  eth_data_start + 8
46
rxfd_count		equ  eth_data_start + 12
46
rxfd_count              equ  eth_data_start + 12
Line 47... Line 47...
47
rxfd_size		equ  eth_data_start + 14
47
rxfd_size               equ  eth_data_start + 14
-
 
48
rxfd_packet             equ  eth_data_start + 16
48
rxfd_packet		equ  eth_data_start + 16
49
 
Line 49... Line 50...
49
 
50
 
Line 50... Line 51...
50
 
51
 
51
 
52
uglobal
-
 
53
eeprom_data:
52
uglobal
54
              times 16  dd 0
-
 
55
 
53
eeprom_data:  times 16	dd 0
56
align 4
-
 
57
 
54
 
58
lstats:
-
 
59
tx_good_frames:
55
align 4
60
                dd 0
-
 
61
tx_coll16_errs:
56
 
62
                 dd 0
-
 
63
tx_late_colls:
57
lstats:
64
               dd 0
-
 
65
tx_underruns:
58
tx_good_frames: dd 0
66
              dd 0
-
 
67
tx_lost_carrier:
59
tx_coll16_errs:  dd 0
68
                 dd 0
-
 
69
tx_deferred:
60
tx_late_colls: dd 0
70
             dd 0
-
 
71
tx_one_colls:
61
tx_underruns: dd 0
72
              dd 0
-
 
73
tx_multi_colls:
62
tx_lost_carrier: dd 0
74
                dd 0
-
 
75
tx_total_colls:
63
tx_deferred: dd 0
76
                dd 0
-
 
77
rx_good_frames:
64
tx_one_colls: dd 0
78
                dd 0
-
 
79
rx_crc_errs:
65
tx_multi_colls: dd 0
80
             dd 0
-
 
81
rx_align_errs:
66
tx_total_colls: dd 0
82
               dd 0
-
 
83
rx_resource_errs:
67
rx_good_frames: dd 0
84
                  dd 0
-
 
85
rx_overrun_errs:
Line 68... Line 86...
68
rx_crc_errs: dd 0
86
                 dd 0
Line 69... Line 87...
69
rx_align_errs: dd 0
87
rx_colls_errs:
70
rx_resource_errs: dd 0
88
               dd 0
-
 
89
rx_runt_errs:
71
rx_overrun_errs: dd 0
90
              dd 0
-
 
91
done_marker:
72
rx_colls_errs: dd 0
92
             dd 0
-
 
93
 
73
rx_runt_errs: dd 0
94
align 4
Line 74... Line 95...
74
done_marker: dd 0
95
 
-
 
96
confcmd:
75
 
97
confcmd_status:
76
align 4
98
                        dw    0
77
 
99
confcmd_command:
78
confcmd:
100
                        dw    0
Line 79... Line 101...
79
confcmd_status: 	dw    0
101
confcmd_link:
80
confcmd_command:	dw    0
102
                        dd    0
Line 81... Line 103...
81
confcmd_link:		dd    0
103
endg
82
endg
104
 
-
 
105
iglobal
83
 
106
confcmd_data:
-
 
107
                        db    22, 0x08, 0, 0, 0, 0x80, 0x32, 0x03, 1
84
iglobal
108
                        db    0, 0x2e, 0, 0x60, 0, 0xf2, 0x48, 0, 0x40, 0xf2
-
 
109
                        db    0x80, 0x3f, 0x05
85
confcmd_data:		db    22, 0x08, 0, 0, 0, 0x80, 0x32, 0x03, 1
110
endg
-
 
111
 
86
			db    0, 0x2e, 0, 0x60, 0, 0xf2, 0x48, 0, 0x40, 0xf2
112
uglobal
-
 
113
align 4
87
			db    0x80, 0x3f, 0x05
114
 
-
 
115
txfd:
88
endg
116
txfd_status:
-
 
117
                        dw   0
89
 
118
txfd_command:
-
 
119
                        dw   0
90
uglobal
120
txfd_link:
-
 
121
                        dd   0
Line 91... Line 122...
91
align 4
122
txfd_tx_desc_addr:
Line 92... Line 123...
92
 
123
                        dd   0
93
txfd:
124
txfd_count:
-
 
125
                        dd   0
94
txfd_status:		dw   0
126
txfd_tx_buf_addr0:
-
 
127
                        dd   0
95
txfd_command:		dw   0
128
txfd_tx_buf_size0:
-
 
129
                        dd   0
96
txfd_link:		dd   0
130
txfd_tx_buf_addr1:
Line 97... Line 131...
97
txfd_tx_desc_addr:	dd   0
131
                        dd   0
98
txfd_count:		dd   0
132
txfd_tx_buf_size1:
Line 119... Line 153...
119
;       port address in edx
153
;       port address in edx
120
;
154
;
121
;       al destroyed
155
;       al destroyed
122
;***************************************************************************
156
;***************************************************************************
123
wait_for_cmd_done:
157
wait_for_cmd_done:
124
   in	    al, dx
158
        in      al, dx
125
   cmp	    al, 0
159
        cmp     al, 0
126
   jne	    wait_for_cmd_done
160
        jne     wait_for_cmd_done
127
   ret
161
        ret
Line 128... Line 162...
128
 
162
 
129
 
163
 
Line 139... Line 173...
139
;
173
;
140
;       Data returned in eax
174
;       Data returned in eax
141
;
175
;
142
;***************************************************************************
176
;***************************************************************************
143
mdio_read:
177
mdio_read:
144
   mov	    edx, [io_addr]
178
        mov     edx, [io_addr]
145
   add	    edx, 16	    ; SCBCtrlMDI
179
        add     edx, 16     ; SCBCtrlMDI
Line 146... Line 180...
146
 
180
 
147
   mov	    eax, 0x08000000
181
        mov     eax, 0x08000000
148
   shl	    ecx, 16
182
        shl     ecx, 16
149
   or	    eax, ecx
183
        or      eax, ecx
150
   shl	    ebx, 21
184
        shl     ebx, 21
Line 151... Line 185...
151
   or	    eax, ebx
185
        or      eax, ebx
Line 152... Line 186...
152
 
186
 
153
   out	    dx, eax
187
        out     dx, eax
154
 
188
 
155
mrlp:
189
mrlp:
156
   call     delay_us
190
        call    delay_us
157
   in	    eax, dx
191
        in      eax, dx
Line 158... Line 192...
158
   mov	    ecx, eax
192
        mov     ecx, eax
159
   and	    ecx, 0x10000000
193
        and     ecx, 0x10000000
Line 160... Line 194...
160
   jz	    mrlp
194
        jz      mrlp
161
 
195
 
Line 175... Line 209...
175
;         data in edx
209
;         data in edx
176
;       Data returned in eax
210
;       Data returned in eax
177
;
211
;
178
;***************************************************************************
212
;***************************************************************************
179
mdio_write:
213
mdio_write:
180
   mov	    eax, 0x04000000
214
        mov     eax, 0x04000000
181
   shl	    ecx, 16
215
        shl     ecx, 16
182
   or	    eax, ecx
216
        or      eax, ecx
183
   shl	    ebx, 21
217
        shl     ebx, 21
184
   or	    eax, ebx
218
        or      eax, ebx
185
   or	    eax, edx
219
        or      eax, edx
186
 
220
 
187
   mov	    edx, [io_addr]
221
        mov     edx, [io_addr]
188
   add	    edx, 16	    ; SCBCtrlMDI
222
        add     edx, 16     ; SCBCtrlMDI
189
   out	    dx, eax
223
        out     dx, eax
Line 190... Line 224...
190
 
224
 
191
mwlp:
225
mwlp:
192
   call     delay_us
226
        call    delay_us
193
   in	    eax, dx
227
        in      eax, dx
194
   mov	    ecx, eax
228
        mov     ecx, eax
195
   and	    ecx, 0x10000000
229
        and     ecx, 0x10000000
Line 196... Line 230...
196
   jz	    mwlp
230
        jz      mwlp
197
 
231
 
Line 198... Line 232...
198
   and	    eax, 0xffff
232
        and     eax, 0xffff
199
   ret
233
        ret
200
 
234
 
Line 201... Line 235...
201
 
235
 
202
 
236
 
203
;/***********************************************************************/
237
;/***********************************************************************/
204
;/*                       I82557 related defines                        */
238
;/*                       I82557 related defines                        */
205
;/***********************************************************************/
239
;/***********************************************************************/
206
 
240
 
207
; Serial EEPROM section.
241
; Serial EEPROM section.
208
;   A "bit" grungy, but we work our way through bit-by-bit :->.
242
;   A "bit" grungy, but we work our way through bit-by-bit :->.
209
;  EEPROM_Ctrl bits.
243
;  EEPROM_Ctrl bits.
210
EE_SHIFT_CLK	equ   0x01    ; EEPROM shift clock.
244
EE_SHIFT_CLK    equ   0x01    ; EEPROM shift clock.
Line 211... Line 245...
211
EE_CS		equ   0x02    ; EEPROM chip select.
245
EE_CS           equ   0x02    ; EEPROM chip select.
212
EE_DATA_WRITE	equ   0x04    ; EEPROM chip data in.
246
EE_DATA_WRITE   equ   0x04    ; EEPROM chip data in.
Line 213... Line 247...
213
EE_DATA_READ	equ   0x08    ; EEPROM chip data out.
247
EE_DATA_READ    equ   0x08    ; EEPROM chip data out.
214
EE_WRITE_0	equ   0x4802
248
EE_WRITE_0      equ   0x4802
215
EE_WRITE_1	equ   0x4806
249
EE_WRITE_1      equ   0x4806
216
EE_ENB		equ   0x4802
250
EE_ENB          equ   0x4802
Line 245... Line 279...
245
;       cmd in ebx
279
;       cmd in ebx
246
;       cmd length in ecx
280
;       cmd length in ecx
247
;       return in eax
281
;       return in eax
248
;***************************************************************************
282
;***************************************************************************
249
do_eeprom_cmd:
283
do_eeprom_cmd:
250
   mov	    edx, [io_addr]    ; We only require the value in dx
284
        mov     edx, [io_addr]; We only require the value in dx
251
   add	    dx, 14	      ; the value SCBeeprom
285
        add     dx, 14        ; the value SCBeeprom
Line 252... Line 286...
252
 
286
 
253
   mov	    ax, EE_ENB
287
        mov     ax, EE_ENB
254
   out	    dx, ax
288
        out     dx, ax
255
   call     delay_us
289
        call    delay_us
256
 
290
 
257
   mov	    ax, 0x4803	      ; EE_ENB | EE_SHIFT_CLK
291
        mov     ax, 0x4803    ; EE_ENB | EE_SHIFT_CLK
258
   out	    dx, ax
292
        out     dx, ax
Line 259... Line 293...
259
   call     delay_us
293
        call    delay_us
260
 
294
 
261
    ; dx holds ee_addr
295
    ; dx holds ee_addr
262
    ; ecx holds count
296
    ; ecx holds count
Line 263... Line 297...
263
    ; eax holds cmd
297
    ; eax holds cmd
264
   xor	    edi, edi	      ; this will be the receive data
298
        xor     edi, edi      ; this will be the receive data
Line 265... Line 299...
265
 
299
 
266
dec_001:
300
dec_001:
267
   mov	    esi, 1
301
        mov     esi, 1
268
 
302
 
269
   dec	    ecx
303
        dec     ecx
270
   shl	    esi, cl
304
        shl     esi, cl
271
   inc	    ecx
305
        inc     ecx
272
   and	    esi, ebx
306
        and     esi, ebx
Line 273... Line 307...
273
   mov	    eax, EE_WRITE_0   ; I am assuming this doesnt affect the flags..
307
        mov     eax, EE_WRITE_0; I am assuming this doesnt affect the flags..
274
   cmp	    esi,0
308
        cmp     esi, 0
275
   jz	    dec_002
309
        jz      dec_002
Line 276... Line 310...
276
   mov	    eax, EE_WRITE_1
310
        mov     eax, EE_WRITE_1
277
 
311
 
278
dec_002:
312
dec_002:
279
   out	    dx, ax
313
        out     dx, ax
280
   call     delay_us
314
        call    delay_us
281
 
315
 
282
   or	    ax, EE_SHIFT_CLK
316
        or      ax, EE_SHIFT_CLK
283
   out	    dx, ax
317
        out     dx, ax
284
   call     delay_us
318
        call    delay_us
285
 
319
 
286
   shl	    edi,1
320
        shl     edi, 1
Line 287... Line 321...
287
 
321
 
288
   in	    ax, dx
322
        in      ax, dx
Line 289... Line 323...
289
   and	    ax, EE_DATA_READ
323
        and     ax, EE_DATA_READ
290
   cmp	    ax,0
324
        cmp     ax, 0
291
   jz	    dec_003
325
        jz      dec_003
Line 292... Line 326...
292
   inc	    edi
326
        inc     edi
293
 
327
 
294
dec_003:
328
dec_003:
Line 295... Line 329...
295
   loop     dec_001
329
        loop    dec_001
Line 296... Line 330...
296
 
330
 
Line 297... Line 331...
297
   mov	    ax, EE_ENB
331
        mov     ax, EE_ENB
298
   out	    dx, ax
332
        out     dx, ax
299
   call     delay_us
333
        call    delay_us
Line 315... Line 349...
315
;      If a card was found, it enables the ethernet -> TCPIP link
349
;      If a card was found, it enables the ethernet -> TCPIP link
316
;
350
;
317
;***************************************************************************
351
;***************************************************************************
318
I8255x_probe:
352
I8255x_probe:
319
   DEBUGF 1," K : Probing i8255x device \n"
353
   DEBUGF 1," K : Probing i8255x device \n"
320
   mov	    eax, [io_addr]
354
        mov     eax, [io_addr]
Line 321... Line 355...
321
 
355
 
322
   mov	    ebx, [pci_bus]
356
        mov     ebx, [pci_bus]
323
   mov	    ecx, [pci_dev]
357
        mov     ecx, [pci_dev]
324
   mov	    edx, 0x04	   ; PCI_COMMAND
358
        mov     edx, 0x04  ; PCI_COMMAND
325
   call     pcibios_read_config_word
359
        call    pcibios_read_config_word
326
 
360
 
327
   or	    ax, 0x05
361
        or      ax, 0x05
328
   mov	    ebx, [pci_bus]
362
        mov     ebx, [pci_bus]
329
   mov	    ecx, [pci_dev]
363
        mov     ecx, [pci_dev]
330
   mov	    edx, 0x04	   ; PCI_COMMAND
364
        mov     edx, 0x04  ; PCI_COMMAND
331
   call     pcibios_write_config_word
365
        call    pcibios_write_config_word
332
 
366
 
333
   mov	    ebx, 0x6000000
367
        mov     ebx, 0x6000000
334
   mov	    ecx, 27
368
        mov     ecx, 27
335
   call     do_eeprom_cmd
369
        call    do_eeprom_cmd
336
   and	    eax, 0xffe0000
370
        and     eax, 0xffe0000
337
   cmp	    eax, 0xffe0000
371
        cmp     eax, 0xffe0000
338
   je	    bige
372
        je      bige
339
 
373
 
340
   mov	    ebx, 0x1800000
374
        mov     ebx, 0x1800000
341
   mov	    ecx, 0x40
375
        mov     ecx, 0x40
Line 342... Line 376...
342
   jmp	    doread
376
        jmp     doread
343
 
377
 
344
bige:
378
bige:
Line 345... Line 379...
345
   mov	    ebx, 0x6000000
379
        mov     ebx, 0x6000000
346
   mov	    ecx, 0x100
380
        mov     ecx, 0x100
347
 
381
 
348
doread:
382
doread:
Line 349... Line 383...
349
   ; do-eeprom-cmd will destroy all registers
383
   ; do-eeprom-cmd will destroy all registers
350
   ; we have eesize in ecx
384
   ; we have eesize in ecx
Line 351... Line 385...
351
   ; read_cmd in ebx
385
   ; read_cmd in ebx
352
 
386
 
353
   ; Ignore full eeprom - just load the mac address
387
   ; Ignore full eeprom - just load the mac address
354
   mov	    ecx, 0
388
        mov     ecx, 0
355
 
389
 
356
drlp:
390
drlp:
357
   push     ecx      ; save count
391
        push    ecx  ; save count
358
   push     ebx
392
        push    ebx
359
   mov	    eax, ecx
393
        mov     eax, ecx
360
   shl	    eax, 16
394
        shl     eax, 16
361
   or	    ebx, eax
395
        or      ebx, eax
362
   mov	    ecx, 27
396
        mov     ecx, 27
363
   call     do_eeprom_cmd
397
        call    do_eeprom_cmd
364
 
398
 
365
   pop	    ebx
399
        pop     ebx
366
   pop	    ecx
400
        pop     ecx
367
 
401
 
368
   mov	    edx, ecx
402
        mov     edx, ecx
369
   shl	    edx, 2
403
        shl     edx, 2
370
   mov	    esi, eeprom_data
404
        mov     esi, eeprom_data
371
   add	    esi, edx
405
        add     esi, edx
Line 372... Line 406...
372
   mov	    [esi], eax
406
        mov     [esi], eax
373
 
407
 
Line 374... Line 408...
374
   inc	    ecx
408
        inc     ecx
375
   cmp	    ecx, 16
409
        cmp     ecx, 16
376
   jne	    drlp
410
        jne     drlp
377
 
411
 
378
   ; OK, we have the MAC address.
412
   ; OK, we have the MAC address.
379
   ; Now reset the card
413
   ; Now reset the card
380
 
414
 
381
   mov	    edx, [io_addr]
415
        mov     edx, [io_addr]
382
   add	    dx, 8	  ; SCBPort
416
        add     dx, 8     ; SCBPort
383
   xor	    eax, eax	  ; The reset cmd == 0
417
        xor     eax, eax  ; The reset cmd == 0
384
   out	    dx, eax
418
        out     dx, eax
385
 
419
 
386
   mov	    esi, 10
420
        mov     esi, 10
387
   call     delay_ms	  ; Give the card time to warm up.
421
        call    delay_ms  ; Give the card time to warm up.
388
 
422
 
389
   mov	    eax, lstats
423
        mov     eax, lstats
390
   mov	    edx, [io_addr]
424
        mov     edx, [io_addr]
391
   add	    edx, 4	      ; SCBPointer
425
        add     edx, 4        ; SCBPointer
392
   out	    dx, eax
426
        out     dx, eax
393
 
427
 
394
   mov	    eax, 0x0140 	; INT_MASK | CU_STATSADDR
428
        mov     eax, 0x0140     ; INT_MASK | CU_STATSADDR
395
   mov	    edx, [io_addr]
429
        mov     edx, [io_addr]
396
   add	    edx, 2	      ; SCBCmd
430
        add     edx, 2        ; SCBCmd
397
   out	    dx, ax
431
        out     dx, ax
398
 
432
 
399
   call     wait_for_cmd_done
433
        call    wait_for_cmd_done
400
 
434
 
401
   mov	    eax, 0
435
        mov     eax, 0
402
   mov	    edx, [io_addr]
436
        mov     edx, [io_addr]
Line 403... Line 437...
403
   add	    edx, 4	      ; SCBPointer
437
        add     edx, 4        ; SCBPointer
Line 404... Line 438...
404
   out	    dx, eax
438
        out     dx, eax
405
 
439
 
406
   mov	    eax, 0x0106 	; INT_MASK | RX_ADDR_LOAD
440
        mov     eax, 0x0106     ; INT_MASK | RX_ADDR_LOAD
407
   mov	    edx, [io_addr]
441
        mov     edx, [io_addr]
408
   add	    edx, 2	      ; SCBCmd
442
        add     edx, 2        ; SCBCmd
Line 409... Line 443...
409
   out	    dx, ax
443
        out     dx, ax
410
 
444
 
411
   call     wait_for_cmd_done
445
        call    wait_for_cmd_done
Line 412... Line 446...
412
 
446
 
413
   ; build rxrd structure
447
   ; build rxrd structure
414
   mov	    ax, 0x0001
448
        mov     ax, 0x0001
Line 415... Line 449...
415
   mov	    [rxfd_status], ax
449
        mov     [rxfd_status], ax
416
   mov	    ax, 0x0000
450
        mov     ax, 0x0000
Line 417... Line 451...
417
   mov	    [rxfd_command], ax
451
        mov     [rxfd_command], ax
418
 
452
 
Line 419... Line 453...
419
   mov	    eax, rxfd_status
453
        mov     eax, rxfd_status
420
   sub	    eax, OS_BASE
454
        sub     eax, OS_BASE
Line 421... Line 455...
421
   mov	    [rxfd_link], eax
455
        mov     [rxfd_link], eax
422
 
456
 
423
   mov	    eax, Ether_buffer
457
        mov     eax, Ether_buffer
Line 424... Line 458...
424
   sub	    eax, OS_BASE
458
        sub     eax, OS_BASE
425
   mov	    [rxfd_rx_buf_addr], eax
459
        mov     [rxfd_rx_buf_addr], eax
Line 426... Line 460...
426
 
460
 
427
   mov	    ax, 0
461
        mov     ax, 0
Line 428... Line 462...
428
   mov	    [rxfd_count], ax
462
        mov     [rxfd_count], ax
Line 429... Line 463...
429
 
463
 
Line 430... Line 464...
430
   mov	    ax, 1528
464
        mov     ax, 1528
431
   mov	    [rxfd_size], ax
465
        mov     [rxfd_size], ax
Line 432... Line 466...
432
 
466
 
433
   mov	    edx, [io_addr]
467
        mov     edx, [io_addr]
Line 434... Line 468...
434
   add	    edx, 4	     ; SCBPointer
468
        add     edx, 4       ; SCBPointer
435
 
469
 
Line 436... Line 470...
436
   mov	    eax, rxfd_status
470
        mov     eax, rxfd_status
437
   sub	    eax, OS_BASE
471
        sub     eax, OS_BASE
438
   out	    dx, eax
472
        out     dx, eax
Line 439... Line 473...
439
 
473
 
440
   mov	    edx, [io_addr]
474
        mov     edx, [io_addr]
Line 441... Line 475...
441
   add	    edx, 2	     ; SCBCmd
475
        add     edx, 2       ; SCBCmd
442
 
476
 
Line 443... Line 477...
443
   mov	    ax, 0x0101	       ; INT_MASK | RX_START
477
        mov     ax, 0x0101     ; INT_MASK | RX_START
Line 444... Line 478...
444
   out	    dx, ax
478
        out     dx, ax
445
 
479
 
Line 446... Line 480...
446
   call     wait_for_cmd_done
480
        call    wait_for_cmd_done
447
 
481
 
Line 448... Line 482...
448
   ; start the reciver
482
   ; start the reciver
449
 
483
 
Line 450... Line 484...
450
   mov	    ax, 0
484
        mov     ax, 0
451
   mov	    [rxfd_status], ax
485
        mov     [rxfd_status], ax
Line 452... Line 486...
452
 
486
 
Line 453... Line 487...
453
   mov	    ax, 0xc000
487
        mov     ax, 0xc000
Line 454... Line 488...
454
   mov	    [rxfd_command], ax
488
        mov     [rxfd_command], ax
Line 455... Line 489...
455
 
489
 
456
   mov	    edx, [io_addr]
490
        mov     edx, [io_addr]
457
   add	    edx, 4	     ; SCBPointer
491
        add     edx, 4       ; SCBPointer
458
 
492
 
459
   mov	    eax, rxfd_status
493
        mov     eax, rxfd_status
460
   sub	    eax, OS_BASE
494
        sub     eax, OS_BASE
461
   out	    dx, eax
495
        out     dx, eax
462
 
496
 
463
   mov	    edx, [io_addr]
497
        mov     edx, [io_addr]
464
   add	    edx, 2	     ; SCBCmd
498
        add     edx, 2       ; SCBCmd
465
 
499
 
466
   mov	    ax, 0x0101	       ; INT_MASK | RX_START
500
        mov     ax, 0x0101     ; INT_MASK | RX_START
467
   out	    dx, ax
501
        out     dx, ax
468
 
502
 
469
   ; Init TX Stuff
503
   ; Init TX Stuff
Line 470... Line 504...
470
 
504
 
Line 471... Line 505...
471
   mov	    edx, [io_addr]
505
        mov     edx, [io_addr]
472
   add	    edx, 4	     ; SCBPointer
506
        add     edx, 4       ; SCBPointer
473
 
507
 
474
   mov	    eax, 0
508
        mov     eax, 0
475
   out	    dx, eax
509
        out     dx, eax
476
 
510
 
477
   mov	    edx, [io_addr]
511
        mov     edx, [io_addr]
478
   add	    edx, 2	     ; SCBCmd
512
        add     edx, 2       ; SCBCmd
479
 
513
 
480
   mov	    ax, 0x0160	       ; INT_MASK | CU_CMD_BASE
514
        mov     ax, 0x0160     ; INT_MASK | CU_CMD_BASE
481
   out	    dx, ax
515
        out     dx, ax
482
 
516
 
Line 483... Line 517...
483
   call     wait_for_cmd_done
517
        call    wait_for_cmd_done
484
 
518
 
485
   ; Set TX Base address
519
   ; Set TX Base address
486
 
520
 
Line 487... Line 521...
487
   ; First, set up confcmd values
521
   ; First, set up confcmd values
488
 
522
 
489
   mov	    ax, 2
523
        mov     ax, 2
490
   mov	    [confcmd_command], ax
524
        mov     [confcmd_command], ax
491
   mov	    eax, txfd
525
        mov     eax, txfd
492
   sub	    eax, OS_BASE
526
        sub     eax, OS_BASE
493
   mov	    [confcmd_link], eax
527
        mov     [confcmd_link], eax
494
 
528
 
495
   mov	    ax, 1
529
        mov     ax, 1
496
   mov	    [txfd_command], ax	       ; CmdIASetup
530
        mov     [txfd_command], ax     ; CmdIASetup
497
 
531
 
498
   mov	    ax, 0
532
        mov     ax, 0
499
   mov	    [txfd_status], ax
533
        mov     [txfd_status], ax
500
 
534
 
501
   mov	    eax, confcmd
535
        mov     eax, confcmd
502
   sub	    eax, OS_BASE
536
        sub     eax, OS_BASE
503
   mov	    [txfd_link], eax
537
        mov     [txfd_link], eax
504
 
538
 
505
 
539
 
506
 
540
 
507
   ; ETH_ALEN is 6 bytes
541
   ; ETH_ALEN is 6 bytes
508
 
542
 
509
   mov	    esi, eeprom_data
543
        mov     esi, eeprom_data
Line 510... Line 544...
510
   mov	    edi, node_addr
544
        mov     edi, node_addr
511
   mov	    ecx, 3
545
        mov     ecx, 3
512
drp000:
546
drp000:
513
   mov	    eax, [esi]
547
        mov     eax, [esi]
514
   mov	    [edi], al
548
        mov     [edi], al
515
   shr	    eax, 8
549
        shr     eax, 8
516
   inc	    edi
550
        inc     edi
517
   mov	    [edi], al
551
        mov     [edi], al
518
   inc	    edi
552
        inc     edi
519
   add	    esi, 4
553
        add     esi, 4
520
   loop     drp000
554
        loop    drp000
Line 521... Line 555...
521
 
555
 
522
   ; Hard code your MAC address into node_addr at this point,
556
   ; Hard code your MAC address into node_addr at this point,
523
   ; If you cannot read the MAC address from the eeprom in the previous step.
557
   ; If you cannot read the MAC address from the eeprom in the previous step.
524
   ; You also have to write the mac address into txfd_tx_desc_addr, rather
558
   ; You also have to write the mac address into txfd_tx_desc_addr, rather
525
   ; than taking data from eeprom_data
559
   ; than taking data from eeprom_data
526
 
560
 
527
   mov	    esi, eeprom_data
561
        mov     esi, eeprom_data
528
   mov	    edi, txfd_tx_desc_addr
562
        mov     edi, txfd_tx_desc_addr
529
   mov	    ecx, 3
563
        mov     ecx, 3
530
drp001:
564
drp001:
531
   mov	    eax, [esi]
565
        mov     eax, [esi]
532
   mov	    [edi], al
566
        mov     [edi], al
533
   shr	    eax, 8
567
        shr     eax, 8
534
   inc	    edi
568
        inc     edi
535
   mov	    [edi], al
569
        mov     [edi], al
536
   inc	    edi
570
        inc     edi
537
   add	    esi, 4
571
        add     esi, 4
538
   loop     drp001
572
        loop    drp001
539
 
573
 
540
 
574
 
541
   mov	    esi, eeprom_data + (6 * 4)
575
        mov     esi, eeprom_data + (6 * 4)
542
   mov	    eax, [esi]
576
        mov     eax, [esi]
543
   shr	    eax, 8
577
        shr     eax, 8
544
   and	    eax, 0x3f
578
        and     eax, 0x3f
545
   cmp	    eax, 4	      ; DP83840
579
        cmp     eax, 4        ; DP83840
546
   je	    drp002
580
        je      drp002
547
   cmp	    eax, 10	       ; DP83840A
581
        cmp     eax, 10        ; DP83840A
548
   je	    drp002
582
        je      drp002
549
   jmp	    drp003
583
        jmp     drp003
550
 
584
 
551
drp002:
585
drp002:
Line 552... Line 586...
552
   mov	    ebx, [esi]
586
        mov     ebx, [esi]
553
   and	    ebx, 0x1f
587
        and     ebx, 0x1f
Line 554... Line 588...
554
   push     ebx
588
        push    ebx
555
   mov	    ecx, 23
589
        mov     ecx, 23
556
   call     mdio_read
590
        call    mdio_read
557
   pop	    ebx
591
        pop     ebx
558
   or	    eax, 0x0422
592
        or      eax, 0x0422
Line 559... Line 593...
559
   mov	    ecx, 23
593
        mov     ecx, 23
560
   mov	    edx, eax
594
        mov     edx, eax
561
   call     mdio_write
595
        call    mdio_write
562
 
596
 
Line 563... Line 597...
563
drp003:
597
drp003:
564
   mov	    ax, 0x4002	       ; Cmdsuspend | CmdConfigure
598
        mov     ax, 0x4002     ; Cmdsuspend | CmdConfigure
Line 565... Line 599...
565
   mov	    [confcmd_command], ax
599
        mov     [confcmd_command], ax
566
   mov	    ax, 0
600
        mov     ax, 0
Line 619... Line 653...
619
;      No inputs
653
;      No inputs
620
;      All registers destroyed
654
;      All registers destroyed
621
;
655
;
622
;***************************************************************************
656
;***************************************************************************
623
I8255x_reset:
657
I8255x_reset:
624
   ret
658
        ret
Line 625... Line 659...
625
 
659
 
626
 
660
 
Line 633... Line 667...
633
;    Polls the ethernet card for a received packet
667
;    Polls the ethernet card for a received packet
634
;    Received data, if any, ends up in Ether_buffer
668
;    Received data, if any, ends up in Ether_buffer
635
;
669
;
636
;***************************************************************************
670
;***************************************************************************
637
I8255x_poll:
671
I8255x_poll:
638
   mov	    ax, 0      ; assume no data
672
        mov     ax, 0  ; assume no data
639
   mov	    [eth_rx_data_len], ax
673
        mov     [eth_rx_data_len], ax
Line 640... Line 674...
640
 
674
 
641
   mov	    ax, [rxfd_status]
675
        mov     ax, [rxfd_status]
642
   cmp	    ax, 0
676
        cmp     ax, 0
Line 643... Line 677...
643
   je	    i8p_exit
677
        je      i8p_exit
644
 
678
 
Line 645... Line 679...
645
   mov	    ax, 0
679
        mov     ax, 0
646
   mov	    [rxfd_status], ax
680
        mov     [rxfd_status], ax
Line 647... Line 681...
647
 
681
 
648
   mov	    ax, 0xc000
682
        mov     ax, 0xc000
Line 649... Line 683...
649
   mov	    [rxfd_command], ax
683
        mov     [rxfd_command], ax
650
 
684
 
651
   mov	    edx, [io_addr]
685
        mov     edx, [io_addr]
Line 652... Line 686...
652
   add	    edx, 4	     ; SCBPointer
686
        add     edx, 4       ; SCBPointer
653
 
687
 
Line 654... Line 688...
654
   mov	    eax, rxfd_status
688
        mov     eax, rxfd_status
655
   sub	    eax, OS_BASE
689
        sub     eax, OS_BASE
Line 656... Line 690...
656
   out	    dx, eax
690
        out     dx, eax
Line 657... Line 691...
657
 
691
 
658
   mov	    edx, [io_addr]
692
        mov     edx, [io_addr]
659
   add	    edx, 2	     ; SCBCmd
693
        add     edx, 2       ; SCBCmd
660
 
694
 
661
   mov	    ax, 0x0101	       ; INT_MASK | RX_START
695
        mov     ax, 0x0101     ; INT_MASK | RX_START
Line 662... Line 696...
662
   out	    dx, ax
696
        out     dx, ax
663
 
697
 
664
   call     wait_for_cmd_done
698
        call    wait_for_cmd_done
Line 665... Line 699...
665
 
699
 
666
   mov	    esi, rxfd_packet
700
        mov     esi, rxfd_packet
Line 667... Line 701...
667
   mov	    edi, Ether_buffer
701
        mov     edi, Ether_buffer
668
   mov	    ecx, 1518
702
        mov     ecx, 1518
Line 690... Line 724...
690
;         pointer to packet data in esi
724
;         pointer to packet data in esi
691
;
725
;
692
;***************************************************************************
726
;***************************************************************************
693
I8255x_transmit:
727
I8255x_transmit:
Line 694... Line 728...
694
 
728
 
Line 695... Line 729...
695
   mov	    [hdr_type], bx
729
        mov     [hdr_type], bx
696
 
730
 
697
   mov	    eax, [edi]
731
        mov     eax, [edi]
698
   mov	    [hdr_dst_addr], eax
732
        mov     [hdr_dst_addr], eax
699
   mov	    ax, [edi+4]
733
        mov     ax, [edi+4]
700
   mov	    [hdr_dst_addr+4], ax
734
        mov     [hdr_dst_addr+4], ax
701
 
735
 
702
   mov	    eax, [node_addr]
736
        mov     eax, [node_addr]
703
   mov	    [hdr_src_addr], eax
737
        mov     [hdr_src_addr], eax
704
   mov	    ax, [node_addr+4]
738
        mov     ax, [node_addr+4]
705
   mov	    [hdr_src_addr+4], ax
739
        mov     [hdr_src_addr+4], ax
706
 
740
 
707
   mov	    edx, [io_addr]
741
        mov     edx, [io_addr]
708
   in	    ax, dx
742
        in      ax, dx
709
   and	    ax, 0xfc00
743
        and     ax, 0xfc00
710
   out	    dx, ax
744
        out     dx, ax
711
 
745
 
712
   xor	    ax, ax
746
        xor     ax, ax
713
   mov	    [txfd_status], ax
747
        mov     [txfd_status], ax
714
   mov	    ax, 0x400C		  ; Cmdsuspend | CmdTx | CmdTxFlex
748
        mov     ax, 0x400C        ; Cmdsuspend | CmdTx | CmdTxFlex
715
   mov	    [txfd_command], ax
749
        mov     [txfd_command], ax
716
   mov	    eax, txfd
750
        mov     eax, txfd
717
   mov	    [txfd_link], eax
751
        mov     [txfd_link], eax
718
   mov	    eax, 0x02208000
752
        mov     eax, 0x02208000
719
   mov	    [txfd_count], eax
753
        mov     [txfd_count], eax
720
   mov	    eax, txfd_tx_buf_addr0
754
        mov     eax, txfd_tx_buf_addr0
721
   sub	    eax, OS_BASE
755
        sub     eax, OS_BASE
722
   mov	    [txfd_tx_desc_addr], eax
756
        mov     [txfd_tx_desc_addr], eax
723
   mov	    eax, hdr
757
        mov     eax, hdr
724
   sub	    eax, OS_BASE
758
        sub     eax, OS_BASE
725
   mov	    [txfd_tx_buf_addr0], eax
759
        mov     [txfd_tx_buf_addr0], eax
Line 726... Line 760...
726
   mov	    eax, 14   ; sizeof hdr
760
        mov     eax, 14; sizeof hdr
727
   mov	    [txfd_tx_buf_size0], eax
761
        mov     [txfd_tx_buf_size0], eax
728
 
762
 
729
   ; Copy the buffer address and size in
763
   ; Copy the buffer address and size in
730
   mov	    eax, esi
764
        mov     eax, esi
731
   sub	    eax, OS_BASE
765
        sub     eax, OS_BASE
732
   mov	    [txfd_tx_buf_addr1], eax
766
        mov     [txfd_tx_buf_addr1], eax
733
   mov	    eax, ecx
767
        mov     eax, ecx
734
   mov	    [txfd_tx_buf_size1], eax
768
        mov     [txfd_tx_buf_size1], eax
735
 
769
 
736
   mov	    eax, txfd
770
        mov     eax, txfd
737
   sub	    eax, OS_BASE
771
        sub     eax, OS_BASE
738
   mov	    edx, [io_addr]
772
        mov     edx, [io_addr]
739
   add	    edx, 4	      ; SCBPointer
773
        add     edx, 4        ; SCBPointer
740
   out	    dx, eax
774
        out     dx, eax
741
 
775
 
742
   mov	    ax, 0x0110	       ; INT_MASK | CU_START
776
        mov     ax, 0x0110     ; INT_MASK | CU_START
Line 743... Line 777...
743
   mov	    edx, [io_addr]
777
        mov     edx, [io_addr]
Line 744... Line 778...
744
   add	    edx, 2	      ; SCBCmd
778
        add     edx, 2        ; SCBCmd
745
   out	    dx, ax
779
        out     dx, ax
Line 746... Line 780...
746
 
780
 
747
   call     wait_for_cmd_done
781
        call    wait_for_cmd_done
748
 
782
 
749
   mov	    edx, [io_addr]
783
        mov     edx, [io_addr]
Line 750... Line 784...
750
   in	    ax, dx
784
        in      ax, dx
751
 
785
 
Line 752... Line -...
752
I8t_001:
-
 
753
   mov	    ax, [txfd_status]
786
I8t_001:
-
 
787
        mov     ax, [txfd_status]