Subversion Repositories Kolibri OS

Rev

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

Rev 5074 Rev 5180
Line 23... Line 23...
23
        COMPATIBLE_API          = 0x0100
23
        COMPATIBLE_API          = 0x0100
24
        API_VERSION             = (COMPATIBLE_API shl 16) + CURRENT_API
24
        API_VERSION             = (COMPATIBLE_API shl 16) + CURRENT_API
Line 25... Line 25...
25
 
25
 
Line 26... Line 26...
26
        MAX_DEVICES             = 16
26
        MAX_DEVICES             = 16
27
 
-
 
28
        RX_DES_COUNT            = 4     ; no of RX descriptors, must be power of 2
-
 
29
        RX_BUFF_SIZE            = 2048  ; size of buffer for each descriptor, must be multiple of 4 and <= 2048 TDES1_TBS1_MASK
27
 
30
 
-
 
Line 31... Line 28...
31
        TX_DES_COUNT            = 4     ; no of TX descriptors, must be power of 2
28
        TX_RING_SIZE            = 4
32
        TX_BUFF_SIZE            = 2048  ; size of buffer for each descriptor, used for memory allocation only
29
        RX_RING_SIZE            = 4
Line 33... Line 30...
33
 
30
 
Line 40... Line 37...
40
include '../struct.inc'
37
include '../struct.inc'
41
include '../macros.inc'
38
include '../macros.inc'
42
include '../fdo.inc'
39
include '../fdo.inc'
43
include '../netdrv.inc'
40
include '../netdrv.inc'
Line -... Line 41...
-
 
41
 
-
 
42
; Capability flags used in chiplist
-
 
43
        FLAG_HAS_MII            = 1 shl 0
-
 
44
        FLAG_HAS_MEDIA_TABLE    = 1 shl 1
-
 
45
        FLAG_CSR12_IN_SROM      = 1 shl 2
-
 
46
        FLAG_ALWAYS_CHECK_MII   = 1 shl 3
-
 
47
        FLAG_HAS_ACPI           = 1 shl 4
-
 
48
 
-
 
49
; Chip id's
-
 
50
        DC21040                 = 0
-
 
51
        DC21041                 = 1
-
 
52
        DC21140                 = 2
-
 
53
        DC21142                 = 3
-
 
54
        DC21143                 = 3
-
 
55
        LC82C168                = 4
-
 
56
        MX98713                 = 5
-
 
57
        MX98715                 = 6
-
 
58
        MX98725                 = 7
44
 
59
 
45
;-------------------------------------------
60
;-------------------------------------------
46
; configuration registers
61
; configuration registers
47
;-------------------------------------------
62
;-------------------------------------------
Line 78... Line 93...
78
 
93
 
79
; using values from linux driver..
94
; using values from linux driver..
Line 80... Line 95...
80
CSR0_DEFAULT            = CSR0_WIE + CSR0_RLE + CSR0_RML + CSR0_CACHEALIGN_NONE
95
CSR0_DEFAULT            = CSR0_WIE + CSR0_RLE + CSR0_RML + CSR0_CACHEALIGN_NONE
81
 
96
 
82
;------- CSR5 -STATUS- bits --------------------------------
97
;------- CSR5 -STATUS- bits --------------------------------
83
CSR5_TI                 = 1 shl 0       ; Transmit interupt - frame transmition completed
98
CSR5_TI                 = 0x00000001    ;1 shl 0        ; Transmit interupt - frame transmition completed
84
CSR5_TPS                = 1 shl 1       ; Transmit process stopped
99
CSR5_TPS                = 0x00000002    ;1 shl 1        ; Transmit process stopped
-
 
100
CSR5_TU                 = 0x00000004    ;1 shl 2        ; Transmit Buffer unavailable
85
CSR5_TU                 = 1 shl 2       ; Transmit Buffer unavailable
101
CSR5_TJT                = 0x00000008    ;1 shl 3        ; Transmit Jabber Timeout (transmitter had been excessively active)
86
CSR5_TJT                = 1 shl 3       ; Transmit Jabber Timeout (transmitter had been excessively active)
102
CSR5_LP                 = 0x00000010    ;1 shl 4        ; Link pass
87
CSR5_UNF                = 1 shl 5       ; Transmit underflow - FIFO underflow
103
CSR5_UNF                = 0x00000020    ;1 shl 5        ; Transmit underflow - FIFO underflow
88
CSR5_RI                 = 1 shl 6       ; Receive Interrupt
104
CSR5_RI                 = 0x00000040    ;1 shl 6        ; Receive Interrupt
89
CSR5_RU                 = 1 shl 7       ; Receive Buffer unavailable
105
CSR5_RU                 = 0x00000080    ;1 shl 7        ; Receive Buffer unavailable
90
CSR5_RPS                = 1 shl 8       ; Receive Process stopped
106
CSR5_RPS                = 0x00000100    ;1 shl 8        ; Receive Process stopped
91
CSR5_RWT                = 1 shl 9       ; Receive Watchdow Timeout
107
CSR5_RWT                = 0x00000200    ;1 shl 9        ; Receive Watchdow Timeout
-
 
108
CSR5_ETI                = 0x00000400    ;1 shl 10       ; Early transmit Interrupt
92
CSR5_ETI                = 1 shl 10      ; Early transmit Interrupt
109
CSR5_GTE                = 0x00000800    ;1 shl 11       ; General Purpose Timer Expired
93
CSR5_GTE                = 1 shl 11      ; General Purpose Timer Expired
110
CSR5_LF                 = 0x00001000    ;1 shl 12       ; Link Fail
94
CSR5_FBE                = 1 shl 13      ; Fatal bus error
111
CSR5_FBE                = 0x00002000    ;1 shl 13       ; Fatal bus error
95
CSR5_ERI                = 1 shl 14      ; Early receive Interrupt
112
CSR5_ERI                = 0x00004000    ;1 shl 14       ; Early receive Interrupt
96
CSR5_AIS                = 1 shl 15      ; Abnormal interrupt summary
113
CSR5_AIS                = 0x00008000    ;1 shl 15       ; Abnormal interrupt summary
97
CSR5_NIS                = 1 shl 16      ; normal interrupt summary
114
CSR5_NIS                = 0x00010000    ;1 shl 16       ; normal interrupt summary
98
CSR5_RS_SH              = 17            ; Receive process state  -shift
115
CSR5_RS_SH              = 17            ; Receive process state  -shift
99
CSR5_RS_MASK            = 111b          ;                        -mask
116
CSR5_RS_MASK            = 111b          ;                        -mask
100
CSR5_TS_SH              = 20            ; Transmit process state -shift
117
CSR5_TS_SH              = 20            ; Transmit process state -shift
Line 116... Line 133...
116
CSR6_SR                 = 1 shl 1       ; Start/Stop receive
133
CSR6_SR                 = 1 shl 1       ; Start/Stop receive
117
CSR6_HO                 = 1 shl 2       ; Hash only Filtering mode
134
CSR6_HO                 = 1 shl 2       ; Hash only Filtering mode
118
CSR6_PB                 = 1 shl 3       ; Pass bad frames
135
CSR6_PB                 = 1 shl 3       ; Pass bad frames
119
CSR6_IF                 = 1 shl 4       ; Inverse filtering
136
CSR6_IF                 = 1 shl 4       ; Inverse filtering
120
CSR6_SB                 = 1 shl 5       ; Start/Stop backoff counter
137
CSR6_SB                 = 1 shl 5       ; Start/Stop backoff counter
121
CSR6_PR                 = 1 shl 6       ; Promiscuos mode -default after reset
138
CSR6_PR                 = 1 shl 6       ; Promiscuous mode -default after reset
122
CSR6_PM                 = 1 shl 7       ; Pass all multicast
139
CSR6_PM                 = 1 shl 7       ; Pass all multicast
123
CSR6_F                  = 1 shl 9       ; Full Duplex mode
140
CSR6_F                  = 1 shl 9       ; Full Duplex mode
124
CSR6_OM_SH              = 10            ; Operating Mode -shift
141
CSR6_OM_SH              = 10            ; Operating Mode -shift
125
CSR6_OM_MASK            = 11b           ;                -mask
142
CSR6_OM_MASK            = 11b           ;                -mask
126
CSR6_FC                 = 1 shl 12      ; Force Collision Mode
143
CSR6_FC                 = 1 shl 12      ; Force Collision Mode
Line 215... Line 232...
215
TDES1_FT1               = 1 shl 28              ; Filtering type 1
232
TDES1_FT1               = 1 shl 28              ; Filtering type 1
216
TDES1_FS                = 1 shl 29              ; First segment - buffer is first segment of frame
233
TDES1_FS                = 1 shl 29              ; First segment - buffer is first segment of frame
217
TDES1_LS                = 1 shl 30              ; Last segment
234
TDES1_LS                = 1 shl 30              ; Last segment
218
TDES1_IC                = 1 shl 31              ; Interupt on completion (CSR5<0>=1) valid when TDES1<30>=1
235
TDES1_IC                = 1 shl 31              ; Interupt on completion (CSR5<0>=1) valid when TDES1<30>=1
Line 219... Line 236...
219
 
236
 
220
RX_MEM_TOTAL_SIZE       = RX_DES_COUNT*(sizeof.DES+RX_BUFF_SIZE)
237
FULL_DUPLEX_MAGIC       = 0x6969
221
TX_MEM_TOTAL_SIZE       = TX_DES_COUNT*(sizeof.DES+TX_BUFF_SIZE)
-
 
Line 222... Line 238...
222
 
238
;MAX_ETH_FRAME_SIZE      = 1514
Line 223... Line -...
223
 
-
 
224
struct  device          ETH_DEVICE
-
 
225
 
-
 
226
        rx_p_des        dd ?    ; descriptors ring with received packets
-
 
227
        tx_p_des        dd ?    ; descriptors ring with 'to transmit' packets
-
 
228
        tx_free_des     dd ?    ; Tx descriptors available
-
 
229
        tx_wr_des       dd ?    ; Tx current descriptor to write data to
-
 
230
        tx_rd_des       dd ?    ; Tx current descriptor to read TX completion
239
 
231
        rx_crt_des      dd ?    ; Rx current descriptor
240
struct  device          ETH_DEVICE
232
 
241
 
233
        io_addr         dd ?
242
        io_addr         dd ?
-
 
243
        pci_bus         dd ?
-
 
244
        pci_dev         dd ?
-
 
245
        irq_line        db ?
-
 
246
                        rb 3    ; alignment
-
 
247
 
-
 
248
        id              dd ?    ; identification number
-
 
249
        io_size         dd ?
-
 
250
        flags           dd ?
-
 
251
        csr6            dd ?
-
 
252
        csr7            dd ?
-
 
253
        if_port         dd ?
-
 
254
        saved_if_port   dd ?
-
 
255
        default_port    dd ?
-
 
256
        mtable          dd ?
-
 
257
        mii_cnt         dd ?
-
 
258
 
-
 
259
        cur_rx          dd ?
-
 
260
        cur_tx          dd ?    ; Tx current descriptor to write data to
-
 
261
        last_tx         dd ?    ; Tx current descriptor to read TX completion
-
 
262
 
-
 
263
        rb 0x100-($ and 0xff)   ; align 256
-
 
264
        rx_ring         rb RX_RING_SIZE*2*sizeof.desc
Line 234... Line 265...
234
        pci_bus         dd ?
265
 
Line 235... Line 266...
235
        pci_dev         dd ?
266
        rb 0x100-($ and 0xff)   ; align 256
236
        irq_line        db ?
267
        tx_ring         rb TX_RING_SIZE*2*sizeof.desc
237
 
268
 
238
ends
269
ends
239
 
270
 
240
;----------- descriptor structure ---------------------
-
 
241
struct  DES
-
 
242
        status          dd ?    ; bit 31 is 'own' and rest is 'status'
-
 
243
        length          dd ?    ; control bits + bytes-count buffer 1 + bytes-count buffer 2
271
;----------- descriptor structure ---------------------
244
        buffer1         dd ?    ; pointer to buffer1
272
struct  desc
Line 245... Line 273...
245
        buffer2         dd ?    ; pointer to buffer2 or in this case to next descriptor, as we use a chained structure
273
        status          dd ?    ; bit 31 is 'own' and rest is 'status'
246
        virtaddr        dd ?
274
        length          dd ?    ; control bits + bytes-count buffer 1 + bytes-count buffer 2
247
 
275
        buffer1         dd ?    ; pointer to buffer1
Line 378... Line 406...
378
; This device doesnt have its own eth_device structure yet, lets create one
406
; This device doesnt have its own eth_device structure yet, lets create one
379
  .firstdevice:
407
  .firstdevice:
380
        cmp     [devices], MAX_DEVICES                  ; First check if the driver can handle one more card
408
        cmp     [devices], MAX_DEVICES                                  ; First check if the driver can handle one more card
381
        jae     .fail
409
        jae     .fail
Line 382... Line -...
382
 
-
 
383
        push    edx
-
 
384
        invoke  KernelAlloc, sizeof.device              ; Allocate the buffer for eth_device structure
-
 
385
        pop     edx
410
 
386
        test    eax, eax
-
 
387
        jz      .fail
-
 
Line 388... Line 411...
388
        mov     ebx, eax                                ; ebx is always used as a pointer to the structure (in driver, but also in kernel code)
411
        allocate_and_clear ebx, sizeof.device, .fail
389
 
-
 
390
; Fill in the direct call addresses into the struct
412
 
391
 
413
; Fill in the direct call addresses into the struct
392
        mov     [ebx + device.reset], reset
414
        mov     [ebx + device.reset], reset
393
        mov     [ebx + device.transmit], transmit
415
        mov     [ebx + device.transmit], transmit
Line 394... Line 416...
394
        mov     [ebx + device.unload], unload
416
        mov     [ebx + device.unload], unload
395
        mov     [ebx + device.name], my_service
-
 
396
 
417
        mov     [ebx + device.name], my_service
397
; save the pci bus and device numbers
418
 
398
 
419
; save the pci bus and device numbers
399
        mov     eax, [edx + IOCTL.input]
420
        mov     eax, [edx + IOCTL.input]
400
        movzx   ecx, byte[eax+1]
421
        movzx   ecx, byte[eax+1]
Line 401... Line 422...
401
        mov     [ebx + device.pci_bus], ecx
422
        mov     [ebx + device.pci_bus], ecx
402
        movzx   ecx, byte[eax+2]
-
 
403
        mov     [ebx + device.pci_dev], ecx
423
        movzx   ecx, byte[eax+2]
404
 
424
        mov     [ebx + device.pci_dev], ecx
Line 405... Line 425...
405
; Now, it's time to find the base io addres of the PCI device
425
 
406
 
-
 
407
        stdcall PCI_find_io, [ebx + device.pci_bus], [ebx + device.pci_dev]
426
; Now, it's time to find the base io addres of the PCI device
408
        mov     [ebx + device.io_addr], eax
427
        stdcall PCI_find_io, [ebx + device.pci_bus], [ebx + device.pci_dev]
Line 409... Line 428...
409
 
428
        mov     [ebx + device.io_addr], eax
410
; We've found the io address, find IRQ now
429
 
Line 411... Line -...
411
 
-
 
412
        invoke  PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line
-
 
413
        mov     [ebx + device.irq_line], al
-
 
414
 
430
; We've found the io address, find IRQ now
415
        DEBUGF  2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
431
        invoke  PciRead8, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.interrupt_line
416
        [ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.io_addr]:8
432
        mov     [ebx + device.irq_line], al
417
 
433
 
418
        allocate_and_clear [ebx + device.rx_p_des], RX_DES_COUNT*(sizeof.DES+RX_BUFF_SIZE), .err
434
        DEBUGF  2,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\
Line 419... Line 435...
419
        allocate_and_clear [ebx + device.tx_p_des], TX_DES_COUNT*(sizeof.DES+TX_BUFF_SIZE), .err
435
        [ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.io_addr]:8
420
 
436
 
421
; Ok, the eth_device structure is ready, let's probe the device
437
; Ok, the eth_device structure is ready, let's probe the device
Line 422... Line -...
422
; Because initialization fires IRQ, IRQ handler must be aware of this device
-
 
423
        mov     eax, [devices]                                          ; Add the device structure to our device list
438
; Because initialization fires IRQ, IRQ handler must be aware of this device
424
        mov     [device_list+4*eax], ebx                                ; (IRQ handler uses this list to find device)
439
        mov     eax, [devices]                                          ; Add the device structure to our device list
Line 425... Line 440...
425
        inc     [devices]                                               ;
440
        mov     [device_list+4*eax], ebx                                ; (IRQ handler uses this list to find device)
426
 
441
        inc     [devices]                                               ;
Line 454... Line 469...
454
 
469
 
455
  .err2:
470
  .err2:
456
        dec     [devices]
471
        dec     [devices]
457
  .err:
472
  .err:
458
        DEBUGF  2,"removing device structure\n"
-
 
459
        invoke  KernelFree, [ebx + device.rx_p_des]
-
 
460
        invoke  KernelFree, [ebx + device.tx_p_des]
473
        DEBUGF  2,"removing device structure\n"
Line 461... Line -...
461
        invoke  KernelFree, ebx
-
 
462
 
474
        invoke  KernelFree, ebx
463
 
475
 
464
  .fail:
476
  .fail:
Line 465... Line 477...
465
        or      eax, -1
477
        or      eax, -1
Line 481... Line 493...
481
unload:
493
unload:
482
        ; TODO: (in this particular order)
494
        ; TODO: (in this particular order)
483
        ;
495
        ;
484
        ; - Stop the device
496
        ; - Stop the device
485
        ; - Detach int handler
497
        ; - Detach int handler
486
        ; - Remove device from local list (RTL8139_LIST)
498
        ; - Remove device from local list
487
        ; - call unregister function in kernel
499
        ; - call unregister function in kernel
488
        ; - Remove all allocated structures and buffers the card used
500
        ; - Remove all allocated structures and buffers the card used
Line 489... Line 501...
489
 
501
 
490
        or      eax,-1
-
 
491
 
502
        or      eax, -1
Line 492... Line -...
492
ret
-
 
493
 
-
 
494
 
-
 
495
macro status {
-
 
496
        set_io  [ebx + device.io_addr], CSR5
-
 
497
        in      eax, dx
-
 
498
        DEBUGF  1,"CSR5: %x\n", eax
-
 
499
}
-
 
500
 
503
        ret
501
 
504
 
502
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
505
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
503
;;                                         ;;
506
;;                                         ;;
504
;; Probe                                   ;;
507
;; Probe                                   ;;
Line 505... Line 508...
505
;;                                         ;;
508
;;                                         ;;
506
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 507... Line 510...
507
 
510
 
508
align 4
-
 
509
probe:
-
 
510
 
-
 
511
        DEBUGF  2,"Probing dec21x4x device: "
-
 
512
 
-
 
Line 513... Line -...
513
; Make the device a bus master
-
 
514
        invoke  PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
511
align 4
515
        or      al, PCI_CMD_MASTER
-
 
516
        invoke  PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
-
 
517
 
-
 
518
; Check the vendor/device ID
-
 
519
        invoke  PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], 0                                ; get device/vendor id
512
probe:
520
        DEBUGF  1,"Vendor id: 0x%x\n", ax
-
 
521
 
-
 
522
        cmp     ax, 0x1011
-
 
523
        je      .dec
513
 
524
        cmp     ax, 0x1317
-
 
525
        je      .admtek
-
 
526
        jmp     .notfound
-
 
527
 
514
        DEBUGF  2,"Probing\n"
528
  .dec:
515
 
529
        shr     eax, 16
-
 
530
        DEBUGF  1,"Vendor ok!, device id: 0x%x\n", ax                 ; TODO: use another method to detect chip!
516
        invoke  PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], 0        ; get device/vendor id
531
 
517
        mov     esi, chiplist
532
        cmp     ax, 0x0009
-
 
533
        je      .supported_device
-
 
534
 
518
  .loop:
535
        cmp     ax, 0x0019
519
        cmp     dword[esi], eax
536
        je      .supported_device2
-
 
537
 
-
 
538
  .admtek:
-
 
Line 539... Line -...
539
        shr     eax, 16
-
 
540
        DEBUGF  1,"Vendor ok!, device id: 0x%x\n", ax
-
 
541
 
520
        je      .got_it
542
        cmp     ax, 0x0985
521
        add     esi, 6*4
Line 543... Line 522...
543
        je      .supported_device
522
        cmp     dword[esi], 0
-
 
523
        jne     .loop
-
 
524
        DEBUGF  2, "Unknown chip: 0x%x aborting\n", eax
-
 
525
 
-
 
526
        or      eax, -1
-
 
527
        ret
-
 
528
 
-
 
529
  .got_it:
-
 
530
        lodsd
-
 
531
        lodsd
-
 
532
        mov     [ebx + device.id], eax
-
 
533
        lodsd
-
 
534
        mov     [ebx + device.io_size], eax
544
 
535
        lodsd
545
  .notfound:
536
        mov     [ebx + device.csr7], eax
546
        DEBUGF  1,"Device not supported!\n"
537
        lodsd
-
 
538
        mov     [ebx + device.name], eax
-
 
539
        DEBUGF  1, "Detected chip = %s\n", eax
-
 
540
        lodsd
547
        or      eax, -1
541
        mov     [ebx + device.flags], eax
548
        ret
542
 
549
 
543
; PROBE1
Line 550... Line -...
550
  .supported_device2:
-
 
551
 
544
 
552
        ; wake up the 21143
-
 
Line 553... Line 545...
553
 
545
        test    [ebx + device.flags], FLAG_HAS_ACPI
554
        xor     eax, eax
546
        jz      .no_acpi
555
        invoke  PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], 0x40, eax
547
        DEBUGF  1, "Device has ACPI capabilities, time to wake it up\n"
556
 
548
        xor     eax, eax
557
 
549
        invoke  PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], 0x40, eax       ; wake up the 21143
Line 558... Line 550...
558
  .supported_device:
550
  .no_acpi:
559
        call    SROM_GetWidth           ; TODO: use this value returned in ecx
551
 
Line 560... Line 552...
560
                                        ; in the read_word routine!
552
        call    SROM_GetWidth           ; TODO: use this value returned in ecx in the read_word routine!
Line -... Line 553...
-
 
553
 
561
 
554
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
562
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
555
;;                                         ;;
-
 
556
;; Reset                                   ;;
Line -... Line 557...
-
 
557
;;                                         ;;
563
;;                                         ;;
558
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
564
;; Reset                                   ;;
-
 
565
;;                                         ;;
559
 
566
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
560
align 4
-
 
561
reset:
567
 
562
 
Line 568... Line 563...
568
align 4
563
        DEBUGF  2,"Reset\n"
569
reset:
564
 
570
 
565
; Make the device a bus master
Line -... Line 566...
-
 
566
        invoke  PciRead32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command
571
        DEBUGF  2,"Resetting dec21x4x\n"
567
        or      al, PCI_CMD_MASTER
572
 
568
        invoke  PciWrite32, [ebx + device.pci_bus], [ebx + device.pci_dev], PCI_header00.command, eax
Line -... Line 569...
-
 
569
 
-
 
570
; Stop TX and RX
-
 
571
        set_io  [ebx + device.io_addr], 0
-
 
572
        set_io  [ebx + device.io_addr], CSR6
-
 
573
        in      eax, dx
-
 
574
        and     eax, not (CSR6_ST or CSR6_SR)
-
 
575
        out     dx, eax
-
 
576
 
-
 
577
; Clear missed packet counter
-
 
578
        set_io  [ebx + device.io_addr], CSR8
-
 
579
        in      eax, dx
-
 
580
 
-
 
581
;; wait at least 50 PCI cycles
-
 
582
;        mov     esi, 1000
-
 
583
;        invoke  Sleep
-
 
584
 
-
 
585
        cmp     [ebx + device.id], DC21041
573
;-----------------------------------------------------------
586
        jne     @f
-
 
587
;        set_io  [ebx + device.io_addr], 0
-
 
588
        set_io  [ebx + device.io_addr], CSR9
-
 
589
        in      eax, dx
-
 
590
        test    eax, 0x8000
574
; board software reset - if fails, dont do nothing else
591
        jz      @f
-
 
592
        DEBUGF  1, "21040 compatibility mode\n"
575
 
593
        mov     [ebx + device.id], DC21040
-
 
594
  @@:
576
        set_io  [ebx + device.io_addr], 0
595
 
577
        status
596
 
-
 
597
;;; Find connected mii xceivers? 993-1043
-
 
598
 
-
 
599
; Reset the xcvr interface and turn on heartbeat.
-
 
600
        cmp     [ebx + device.id], DC21041
-
 
601
        jne     @f
-
 
602
        set_io  [ebx + device.io_addr], 0
-
 
603
        set_io  [ebx + device.io_addr], CSR13
-
 
604
        xor     eax, eax
-
 
605
        out     dx, eax
-
 
606
        set_io  [ebx + device.io_addr], CSR14
-
 
607
        dec     eax
-
 
608
        out     dx, eax
-
 
609
        set_io  [ebx + device.io_addr], CSR15
-
 
610
        inc     eax
-
 
611
        mov     al, 8
-
 
612
        out     dx, eax
-
 
613
        set_io  [ebx + device.io_addr], CSR6
-
 
614
        in      eax, dx
-
 
615
        or      ax, CSR6_ST
-
 
616
        out     dx, eax
-
 
617
        set_io  [ebx + device.io_addr], CSR13
-
 
618
        xor     eax, eax
-
 
619
        mov     ax, 0xEF05
-
 
620
        out     dx, eax
-
 
621
        jmp     .reset_done
-
 
622
  @@:
-
 
623
        cmp     [ebx + device.id], DC21040
-
 
624
        jne     @f
-
 
625
        set_io  [ebx + device.io_addr], 0
-
 
626
        set_io  [ebx + device.io_addr], CSR13
-
 
627
        xor     eax, eax
-
 
628
        out     dx, eax
-
 
629
        mov     al, 4
-
 
630
        out     dx, eax
-
 
631
        jmp     .reset_done
-
 
632
  @@:
-
 
633
        cmp     [ebx + device.id], DC21140
-
 
634
        jne     @f
-
 
635
        set_io  [ebx + device.io_addr], 0
-
 
636
        set_io  [ebx + device.io_addr], CSR12
-
 
637
        mov     eax, 0x100
-
 
638
        out     dx, eax
-
 
639
        jmp     .reset_done
-
 
640
  @@:
-
 
641
        cmp     [ebx + device.id], DC21142
-
 
642
        jne     @f
-
 
643
        ; if tp->mii_cnt
-
 
644
        set_io  [ebx + device.io_addr], 0
-
 
645
        set_io  [ebx + device.io_addr], CSR6
-
 
646
        mov     eax, 0x82020000
-
 
647
        out     dx, eax
-
 
648
        set_io  [ebx + device.io_addr], CSR13
-
 
649
        xor     eax, eax
-
 
650
        out     dx, eax
-
 
651
        set_io  [ebx + device.io_addr], CSR14
-
 
652
        out     dx, eax
-
 
653
        set_io  [ebx + device.io_addr], CSR6
-
 
654
        mov     eax, 0x820E0000
-
 
655
        out     dx, eax
Line -... Line 656...
-
 
656
        jmp     .reset_done
-
 
657
        ;;;; TODO
-
 
658
  @@:
-
 
659
        cmp     [ebx + device.id], LC82C168
-
 
660
        jne     @f
Line 578... Line 661...
578
        set_io  [ebx + device.io_addr], CSR0
661
        ; TODO
579
        mov     eax, CSR0_RESET
662
  @@:
580
        out     dx, eax
663
        cmp     [ebx + device.id], MX98713
Line 581... Line 664...
581
 
664
        jne     @f
582
; wait at least 50 PCI cycles
665
        ; TODO
Line 613... Line 696...
613
        DEBUGF  2,"Could not attach int handler!\n"
696
        DEBUGF  2,"Could not attach int handler!\n"
614
        or      eax, -1
697
        or      eax, -1
615
        ret
698
        ret
616
  @@:
699
  @@:
Line -... Line 700...
-
 
700
 
-
 
701
;----------------
-
 
702
; Set cache modes
617
 
703
 
-
 
704
        set_io  [ebx + device.io_addr], 0
-
 
705
        set_io  [ebx + device.io_addr], CSR0
-
 
706
        mov     eax, 0x01A00000 or 0x4800 ; CSR0_DEFAULT
-
 
707
        out     dx, eax
-
 
708
 
-
 
709
        ; wait at least 50 PCI cycles
618
        set_io  [ebx + device.io_addr], 0
710
        mov     esi, 100
-
 
711
        invoke  Sleep
-
 
712
 
-
 
713
;---------------------------
Line 619... Line 714...
619
        status
714
; Initialize RX and TX rings
-
 
715
 
-
 
716
        call    init_ring
-
 
717
        test    eax, eax
-
 
718
        jnz     .err
-
 
719
 
-
 
720
;-------------------
-
 
721
; Set receive filter
Line 620... Line 722...
620
 
722
 
621
        call    init_ring
723
        call    create_setup_frame
Line 622... Line -...
622
 
-
 
623
;--------------------------------------------
-
 
624
; setup CSR3 & CSR4 (pointers to descriptors)
-
 
625
 
724
 
626
        set_io  [ebx + device.io_addr], 0
725
;--------------------------------------------
627
        status
726
; setup CSR3 & CSR4 (pointers to descriptors)
-
 
727
 
-
 
728
        lea     eax, [ebx + device.rx_ring]
628
        set_io  [ebx + device.io_addr], CSR3
729
        invoke  GetPhysAddr
Line 629... Line -...
629
        mov     eax, [ebx + device.rx_p_des]
-
 
630
        invoke  GetPhysAddr
730
        DEBUGF  1,"RX descriptor base address: %x\n", eax
631
        DEBUGF  1,"RX descriptor base address: %x\n", eax
731
        set_io  [ebx + device.io_addr], 0
632
        out     dx, eax
732
        set_io  [ebx + device.io_addr], CSR3
-
 
733
        out     dx, eax
633
 
734
 
Line -... Line 735...
-
 
735
        lea     eax, [ebx + device.tx_ring]
-
 
736
        invoke  GetPhysAddr
634
        set_io  [ebx + device.io_addr], CSR4
737
        DEBUGF  1,"TX descriptor base address: %x\n", eax
-
 
738
        set_io  [ebx + device.io_addr], CSR4
-
 
739
        out     dx, eax
-
 
740
 
-
 
741
; Select media
-
 
742
        push    [ebx + device.if_port]
-
 
743
        pop     [ebx + device.saved_if_port]
-
 
744
        cmp     [ebx + device.if_port], 0
-
 
745
        jne     @f
-
 
746
        push    [ebx + device.default_port]
635
        mov     eax, [ebx + device.tx_p_des]
747
        pop     [ebx + device.if_port]
-
 
748
  @@:
-
 
749
        cmp     [ebx + device.id], DC21041
Line 636... Line 750...
636
        invoke  GetPhysAddr
750
        jne     @f
637
        DEBUGF  1,"TX descriptor base address: %x\n", eax
751
        cmp     [ebx + device.if_port], 4
638
        out     dx, eax
752
        jbe     @f
-
 
753
        ; invalid port, select inital TP, autosense, autonegotiate
639
 
754
        mov     [ebx + device.if_port], 4                               ; CHECKME
640
;-------------------------------------------------------
755
  @@:
641
; setup interrupt mask register -expect IRQs from now on
756
 
-
 
757
; Allow selecting a default media
-
 
758
        cmp     [ebx + device.mtable], 0
Line 642... Line 759...
642
 
759
        je      .media_picked
643
        status
760
 
Line -... Line 761...
-
 
761
        cmp     [ebx + device.if_port], 0
-
 
762
        je      @f
-
 
763
        ;; TODO
-
 
764
        jmp     .media_picked
-
 
765
  @@:
-
 
766
 
-
 
767
  .media_picked:
644
        DEBUGF  1,"Enabling interrupts\n"
768
        mov     [ebx + device.csr6], 0
-
 
769
 
-
 
770
        cmp     [ebx + device.id], DC21142
-
 
771
        jne     @f
-
 
772
        cmp     [ebx + device.if_port], 0
-
 
773
        jne     @f
645
        set_io  [ebx + device.io_addr], CSR7
774
        ;; TODO
-
 
775
        mov     [ebx + device.csr6], 0x82420200
-
 
776
        mov     [ebx + device.if_port], 11
646
        mov     eax, CSR7_DEFAULT
777
        set_io  [ebx + device.io_addr], 0
-
 
778
        set_io  [ebx + device.io_addr], CSR14
-
 
779
        mov     eax, 0x0003FFF
-
 
780
        out     dx, eax
-
 
781
        set_io  [ebx + device.io_addr], CSR15
Line -... Line 782...
-
 
782
        xor     eax, eax
647
        out     dx, eax
783
        mov     al, 8
-
 
784
        out     dx, eax
-
 
785
        set_io  [ebx + device.io_addr], CSR13
-
 
786
        mov     al, 1
648
        status
787
        out     dx, eax
649
 
788
        set_io  [ebx + device.io_addr], CSR12
Line -... Line 789...
-
 
789
        mov     ax, 0x1301
-
 
790
        out     dx, eax
-
 
791
 
650
;----------
792
  @@:
Line -... Line 793...
-
 
793
        cmp     [ebx + device.id], LC82C168
-
 
794
        jne     @f
-
 
795
        ;; TODO
651
; enable RX
796
  @@:
Line -... Line 797...
-
 
797
        cmp     [ebx + device.id], MX98713
-
 
798
        jne     @f
-
 
799
 
-
 
800
  @@:
652
 
801
;; wait a bit
653
        set_io  [ebx + device.io_addr], 0
802
;        mov     esi, 500
654
        status
803
;        invoke  Sleep
Line 655... Line 804...
655
        DEBUGF  1,"Enable RX\n"
804
 
656
 
805
; else:
-
 
806
        xor     eax, eax
-
 
807
        inc     eax
-
 
808
        call    select_media
-
 
809
 
-
 
810
; Start the chip's tx to process setup frame
Line -... Line 811...
-
 
811
        set_io  [ebx + device.io_addr], 0
-
 
812
        set_io  [ebx + device.io_addr], CSR6
-
 
813
        mov     eax, [ebx + device.csr6]
-
 
814
        out     dx, eax
657
        set_io  [ebx + device.io_addr], CSR6
815
        or      ax, CSR6_ST
Line -... Line 816...
-
 
816
        out     dx, eax
-
 
817
 
658
        Bit_Set CSR6_SR; or CSR6_PR or CSR6_ST
818
; Enable interrupts by setting the interrupt mask.
659
        DEBUGF  1,"CSR6: %x\n", eax
-
 
660
 
-
 
661
        status
-
 
662
 
819
        set_io  [ebx + device.io_addr], CSR5
663
        call    start_link
-
 
Line 664... Line 820...
664
 
820
        mov     eax, [ebx + device.csr7]
665
; wait a bit
821
        DEBUGF  1, "Setting CSR7 to 0x%x\n", eax
Line 666... Line 822...
666
        mov     esi, 500
822
        out     dx, eax
667
        invoke  Sleep
823
        set_io  [ebx + device.io_addr], CSR7
Line 668... Line 824...
668
 
824
        out     dx, eax
-
 
825
 
-
 
826
; Enable receiver
Line -... Line 827...
-
 
827
        set_io  [ebx + device.io_addr], CSR6
-
 
828
        mov     eax, [ebx + device.csr6]
-
 
829
        or      eax, 0x2002 + CSR6_RA
669
;----------------------------------------------------
830
        out     dx, eax
Line 670... Line 831...
670
; send setup packet to notify the board about the MAC
831
 
671
 
832
; RX poll demand
Line 672... Line -...
672
        call    Send_Setup_Packet
-
 
673
 
833
        set_io  [ebx + device.io_addr], CSR2
Line -... Line 834...
-
 
834
        xor     eax, eax
-
 
835
        out     dx, eax
-
 
836
 
674
        xor     eax, eax
837
; Set the mtu, kernel will be able to send now
675
; clear packet/byte counters
838
        mov     [ebx + device.mtu], 1514
676
 
839
 
677
        lea     edi, [ebx + device.bytes_tx]
840
; Set link state to unknown
678
        mov     ecx, 6
-
 
679
        rep     stosd
-
 
680
 
-
 
681
; Set the mtu, kernel will be able to send now
841
        mov     [ebx + device.state], ETH_LINK_UNKNOWN
682
        mov     [ebx + device.mtu], 1514
842
 
683
 
843
        DEBUGF  1,"Reset completed\n"
-
 
844
;        xor     eax, eax
684
; Set link state to unknown
845
        ret
685
        mov     [ebx + device.state], ETH_LINK_UNKNOWN
846
 
686
 
847
  .err:
687
        DEBUGF  1,"Reset done\n"
848
        DEBUGF  2,"Reset failed\n"
688
 
849
        or      eax, -1
689
        ret
850
        ret
-
 
851
 
-
 
852
 
690
 
853
 
691
 
-
 
-
 
854
align 4
692
 
855
init_ring:
693
align 4
856
 
694
init_ring:
857
        DEBUGF  1,"Init ring\n"
695
 
858
 
696
;------------------------------------------
859
;---------------------
697
; Setup RX descriptors (use chained method)
-
 
698
 
860
; Setup RX descriptors
699
        mov     eax, [ebx + device.rx_p_des]
861
 
700
        invoke  GetPhysAddr
862
        lea     eax, [ebx + device.rx_ring]
Line 701... Line 863...
701
        mov     edx, eax
863
        invoke  GetPhysAddr
702
        push    eax
864
        mov     edx, eax
Line 703... Line 865...
703
        lea     esi, [eax + RX_DES_COUNT*(sizeof.DES)]  ; jump over RX descriptors
865
        push    eax
704
        mov     eax, [ebx + device.rx_p_des]
866
        lea     edi, [ebx + device.rx_ring]
705
        add     eax, RX_DES_COUNT*(sizeof.DES)          ; jump over RX descriptors
867
        mov     ecx, RX_RING_SIZE
706
        mov     edi, [ebx + device.rx_p_des]
868
  .loop_rx_des:
707
        mov     ecx, RX_DES_COUNT
-
 
708
  .loop_rx_des:
-
 
709
        add     edx, sizeof.DES
-
 
710
        mov     [edi + DES.status], DES0_OWN            ; hardware owns buffer
869
        DEBUGF  1,"RX descriptor 0x%x\n", edi
711
        mov     [edi + DES.length], 1984 + RDES1_RCH    ; only size of first buffer, chained buffers
870
        add     edx, sizeof.desc
712
        mov     [edi + DES.buffer1], esi                ; hw buffer address
871
        mov     [edi + desc.status], DES0_OWN
-
 
872
        mov     [edi + desc.length], 1536
713
        mov     [edi + DES.buffer2], edx                ; pointer to next descriptor
873
        push    edx edi ecx
714
        mov     [edi + DES.virtaddr], eax               ; virtual buffer address
874
        invoke  KernelAlloc, 1536
715
        DEBUGF  1,"RX desc: buff addr: %x, next desc: %x, real buff addr: %x, real descr addr: %x \n", esi, edx, eax, edi
875
        pop     ecx edi edx
716
 
876
        test    eax, eax
717
        add     esi, RX_BUFF_SIZE
877
        jz      .out_of_mem
718
        add     eax, RX_BUFF_SIZE
-
 
719
        add     edi, sizeof.DES
-
 
720
        dec     ecx
-
 
721
        jnz     .loop_rx_des
-
 
722
 
-
 
723
; set last descriptor as LAST
878
        mov     [edi + RX_RING_SIZE*sizeof.desc], eax
724
        or      [edi - sizeof.DES + DES.length], RDES1_RER      ; EndOfRing
879
        invoke  GetPhysAddr
725
        pop     [edi - sizeof.DES + DES.buffer2]                ; point it to the first descriptor
880
        mov     [edi + desc.buffer1], eax
726
 
-
 
727
;---------------------
881
        mov     [edi + desc.buffer2], edx
728
; Setup TX descriptors
882
        add     edi, sizeof.desc
729
 
883
        dec     ecx
Line 730... Line 884...
730
        mov     eax, [ebx + device.tx_p_des]
884
        jnz     .loop_rx_des
731
        invoke  GetPhysAddr
885
; set last descriptor as LAST
Line -... Line 886...
-
 
886
        or      [edi - sizeof.desc + desc.length], RDES1_RER           ; EndOfRing
732
        mov     edx, eax
887
        pop     [edi - sizeof.desc + desc.buffer2]                     ; point it to the first descriptor
-
 
888
 
733
        push    eax
889
;---------------------
-
 
890
; Setup TX descriptors
-
 
891
 
-
 
892
        lea     eax, [ebx + device.tx_ring]
-
 
893
        invoke  GetPhysAddr
-
 
894
        mov     edx, eax
-
 
895
        push    eax
-
 
896
        lea     edi, [ebx + device.tx_ring]
-
 
897
        mov     ecx, TX_RING_SIZE
-
 
898
  .loop_tx_des:
-
 
899
        DEBUGF  1,"TX descriptor 0x%x\n", edi
-
 
900
        add     edx, sizeof.desc
-
 
901
        mov     [edi + desc.status], 0                                  ; owned by driver
-
 
902
        mov     [edi + desc.length], 0
-
 
903
        mov     [edi + desc.buffer1], 0
-
 
904
        mov     [edi + desc.buffer2], edx                               ; pointer to next descr
-
 
905
        add     edi, sizeof.desc
-
 
906
        dec     ecx
-
 
907
        jnz     .loop_tx_des
-
 
908
; set last descriptor as LAST
-
 
909
        or      [edi - sizeof.desc + desc.length], TDES1_TER            ; EndOfRing
-
 
910
        pop     [edi - sizeof.desc + desc.buffer2]                      ; point it to the first descriptor
-
 
911
 
-
 
912
;------------------
-
 
913
; Reset descriptors
-
 
914
 
-
 
915
        xor     eax, eax
-
 
916
        mov     [ebx + device.cur_tx], eax
-
 
917
        mov     [ebx + device.last_tx], eax
-
 
918
        mov     [ebx + device.cur_rx], eax
-
 
919
 
-
 
920
        ret
-
 
921
 
-
 
922
  .out_of_mem:
-
 
923
        DEBUGF  2, "Out of memory!\n"
-
 
924
        pop     eax
-
 
925
        or      eax, -1
-
 
926
        ret
-
 
927
 
-
 
928
 
-
 
929
; IN: eax = startup
-
 
930
align 4
-
 
931
select_media:
-
 
932
 
-
 
933
        DEBUGF  1, "Selecting media\n"
-
 
934
 
-
 
935
        cmp     [ebx + device.mtable], 0
-
 
936
        je      .no_mtable
-
 
937
        DEBUGF  1, "Device has a media table\n"
-
 
938
 
-
 
939
 
-
 
940
; default:
-
 
941
        mov     eax, 0x020E0000
-
 
942
        jmp     .update_csr6
-
 
943
 
-
 
944
  .no_mtable:
-
 
945
        DEBUGF  1, "Device has no media table\n"
-
 
946
 
-
 
947
        cmp     [ebx + device.id], DC21041
-
 
948
        jne     .not_41
-
 
949
        DEBUGF  1, "DC21041\n"
-
 
950
 
-
 
951
        set_io  [ebx + device.io_addr], 0
-
 
952
        set_io  [ebx + device.io_addr], CSR13
-
 
953
        xor     eax, eax
-
 
954
        out     dx, eax         ; reset serial interface
-
 
955
        set_io  [ebx + device.io_addr], CSR14
-
 
956
        mov     eax, 0x7F3F     ;0x7F3F     ;0x7F3D     ; 10T-FD
-
 
957
        out     dx, eax
-
 
958
        set_io  [ebx + device.io_addr], CSR15
-
 
959
        mov     eax, 0x0008     ;0x0008     ;0x0008     ; 10T-FD
-
 
960
        out     dx, eax
-
 
961
        set_io  [ebx + device.io_addr], CSR13
-
 
962
        mov     eax, 0xEF05     ;0xEF01     ;0xEF09     ; 10T-FD
-
 
963
        out     dx, eax
-
 
964
        mov     eax, 0x80020000
-
 
965
        jmp     .update_csr6
-
 
966
  .not_41:
-
 
967
        cmp     [ebx + device.id], LC82C168
-
 
968
        jne     .not_LC
-
 
969
        DEBUGF  1, "LC82C168\n"
-
 
970
 
-
 
971
        ;; TODO
-
 
972
 
-
 
973
        mov     eax, 0x812C0000
-
 
974
        jmp     .update_csr6
-
 
975
  .not_LC:
-
 
976
        cmp     [ebx + device.id], DC21040
-
 
977
        jne     .not_40
-
 
978
        DEBUGF  1, "DC21040\n"
-
 
979
 
-
 
980
        set_io  [ebx + device.io_addr], 0
734
        lea     esi, [eax + TX_DES_COUNT*(sizeof.DES)]  ; jump over TX descriptors
981
        set_io  [ebx + device.io_addr], CSR11
-
 
982
        mov     eax, FULL_DUPLEX_MAGIC
-
 
983
        out     dx, eax
735
        mov     eax, [ebx + device.tx_p_des]
984
        ; reset serial interface
-
 
985
        set_io  [ebx + device.io_addr], CSR13
-
 
986
        xor     eax, eax
-
 
987
        out     dx, eax
-
 
988
 
-
 
989
        set_io  [ebx + device.io_addr], CSR13
-
 
990
        xor     eax, eax
-
 
991
        cmp     [ebx + device.if_port], 0
-
 
992
        je      @f
Line 736... Line 993...
736
        add     eax, TX_DES_COUNT*(sizeof.DES)          ; jump over TX descriptors
993
        mov     al, 0xc
Line 737... Line 994...
737
        mov     edi, [ebx + device.tx_p_des]
994
        out     dx, eax
Line 780... Line 1037...
780
;; Send setup packet                       ;;
1037
;; Send setup packet                       ;;
781
;;                                         ;;
1038
;;                                         ;;
782
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1039
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 783... Line 1040...
783
 
1040
 
784
align 4
1041
align 4
785
Send_Setup_Packet:
-
 
786
 
-
 
Line 787... Line -...
787
        DEBUGF  1,"Sending setup packet\n"
-
 
788
 
-
 
789
; if no descriptors available, out
-
 
790
        mov     ecx, 1000
1042
create_setup_frame:
791
@@loop_wait_desc:
-
 
792
        cmp     [ebx + device.tx_free_des], 0
-
 
793
        jne     @f
-
 
794
 
-
 
Line 795... Line 1043...
795
        dec     ecx
1043
 
796
        jnz     @@loop_wait_desc
1044
        DEBUGF  1,"Creating setup packet\n"
797
 
1045
 
Line 798... Line -...
798
        mov     eax, -1
-
 
799
        ret
-
 
800
      @@:
-
 
801
 
-
 
802
; go to current send descriptor
-
 
803
        mov     edi, [ebx + device.tx_p_des]
1046
        invoke  KernelAlloc, 192
804
        mov     eax, [ebx + device.tx_wr_des]
-
 
805
        DEBUGF  1,"Got free descriptor: %u (%x)", eax, edi
-
 
Line 806... Line 1047...
806
        mov     edx, sizeof.DES
1047
        test    eax, eax
807
        mul     edx
1048
        jz      .err
-
 
1049
 
-
 
1050
        push    eax
-
 
1051
 
-
 
1052
        mov     edi, eax
Line 808... Line -...
808
        add     edi, eax
-
 
809
        DEBUGF  1,"=>%x\n",  edi
-
 
810
 
-
 
811
; if NOT sending FIRST setup packet, must set current descriptor to 0 size for both buffers,
-
 
812
;  and go to next descriptor for real setup packet...            ;; TODO: check if 2 descriptors are available
-
 
813
 
-
 
814
;       cmp     [ebx + device.tx_packets], 0
-
 
815
;       je      .first
-
 
816
;               
-
 
817
;       and     [edi+DES.des1], 0
-
 
818
;       mov     [edi+DES.des0], DES0_OWN
-
 
819
;               
-
 
820
; go to next descriptor
-
 
821
;        inc     [ebx + device.tx_wr_des]
-
 
822
;        and     [ebx + device.tx_wr_des], TX_DES_COUNT-1
-
 
823
;
-
 
824
; dec free descriptors count
-
 
825
;        cmp     [ebx + device.tx_free_des], 0
-
 
826
;        jz      @f
-
 
827
;        dec     [ebx + device.tx_free_des]
-
 
828
;       @@:
1053
        xor     eax, eax
829
;
-
 
830
;       ; recompute pointer to current descriptor
-
 
831
;       mov     edi, [ebx + device.tx_p_des]
-
 
832
;       mov     eax, [ebx + device.tx_wr_des]
-
 
833
;       mov     edx, DES.size
-
 
834
;       mul     edx
-
 
835
;       add     edi, eax
-
 
836
 
-
 
837
  .first:
-
 
838
 
-
 
839
        push    edi
-
 
840
; copy setup packet to current descriptor
1054
        dec     ax
841
        mov     edi, [edi + DES.virtaddr]
1055
        stosd
842
; copy the address once
1056
        stosd
843
        lea     esi, [ebx + device.mac]
-
 
844
        DEBUGF  1,"copying packet to %x from %x\n", edi, esi
1057
        stosd
845
        mov     ecx, 3  ; mac is 6 bytes thus 3 words
1058
 
846
  .loop:
1059
        mov     ecx, 15
Line 847... Line -...
847
        DEBUGF  1,"%x ", [esi]:4
-
 
848
        movsw
-
 
849
        inc     edi
-
 
850
        inc     edi
-
 
851
        dec     ecx
-
 
852
        jnz     .loop
-
 
853
 
-
 
854
        DEBUGF  1,"\n"
1060
  .loop:
Line 855... Line 1061...
855
 
1061
        lea     esi, [ebx + device.mac]
856
; copy 15 times the broadcast address
1062
        lodsw
857
        mov     ecx, 3*15
1063
        stosd
858
        mov     eax, 0xffffffff
1064
        dec     ecx
859
        rep     stosd
-
 
860
 
1065
        jnz     .loop
861
        pop     edi
1066
 
-
 
1067
        pop     eax
862
 
1068
 
863
; setup descriptor
1069
; setup descriptor
Line 864... Line 1070...
864
        DEBUGF  1,"setting up descriptor\n"
1070
        lea     edi, [ebx + device.tx_ring]
865
        mov     [edi + DES.length], TDES1_IC + TDES1_SET + TDES1_TCH + 192        ; size must be EXACTLY 192 bytes
1071
        DEBUGF  1, "attaching setup packet 0x%x to descriptor 0x%x\n", eax, edi
866
        mov     [edi + DES.status], DES0_OWN
-
 
867
 
-
 
868
        DEBUGF  1,"status: %x\n", [edi + DES.status]:8
-
 
869
        DEBUGF  1,"length: %x\n", [edi + DES.length]:8
-
 
870
        DEBUGF  1,"buffer1: %x\n", [edi + DES.buffer1]:8
-
 
871
        DEBUGF  1,"buffer2: %x\n", [edi + DES.buffer2]:8
-
 
872
 
-
 
Line 873... Line -...
873
; go to next descriptor
-
 
874
        inc     [ebx + device.tx_wr_des]
-
 
875
        and     [ebx + device.tx_wr_des], TX_DES_COUNT-1
1072
        mov     [edi + TX_RING_SIZE*sizeof.desc], eax
876
 
-
 
877
; dec free descriptors count
-
 
878
        cmp     [ebx + device.tx_free_des], 0
-
 
879
        jz      @f
-
 
880
        dec     [ebx + device.tx_free_des]
-
 
881
       @@:
-
 
882
 
-
 
883
; start tx
-
 
884
        set_io  [ebx + device.io_addr], 0
-
 
885
        status
-
 
886
        set_io  [ebx + device.io_addr], CSR6
-
 
887
        in      eax, dx
-
 
888
        test    eax, CSR6_ST            ; if NOT started, start now
-
 
889
        jnz     .already_started
-
 
890
        or      eax, CSR6_ST
-
 
891
        DEBUGF  1,"Starting TX\n"
-
 
892
        jmp     .do_it
-
 
Line -... Line 1073...
-
 
1073
        invoke  GetPhysAddr
-
 
1074
        mov     [edi + desc.buffer1], eax
893
  .already_started:
1075
        mov     [edi + desc.length], TDES1_SET + 192        ; size must be EXACTLY 192 bytes + TDES1_IC
Line 894... Line 1076...
894
                                        ; if already started, issue a Transmit Poll command
1076
        mov     [edi + desc.status], DES0_OWN
Line 927... Line 1109...
927
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
1109
        [eax+06]:2,[eax+07]:2,[eax+08]:2,[eax+09]:2,[eax+10]:2,[eax+11]:2,\
928
        [eax+13]:2,[eax+12]:2
1110
        [eax+13]:2,[eax+12]:2
Line 929... Line 1111...
929
 
1111
 
930
        cmp     [buffersize], 1514
1112
        cmp     [buffersize], 1514
931
        ja      .fail
-
 
932
        cmp     [buffersize], 60
-
 
933
        jb      .fail
-
 
934
 
-
 
935
;--------------------------
-
 
Line 936... Line 1113...
936
; copy packet to crt buffer
1113
        ja      .fail
937
        
1114
 
938
        mov     eax, [ebx + device.tx_wr_des]
1115
        mov     eax, [ebx + device.cur_tx]
939
        mov     edx, sizeof.DES
1116
        mov     edx, sizeof.desc
940
        mul     edx
1117
        mul     edx
941
        add     eax, [ebx + device.tx_p_des]
1118
        lea     esi, [ebx + device.tx_ring + eax]
-
 
1119
        test    [esi + desc.status], DES0_OWN
-
 
1120
        jnz     .fail
-
 
1121
 
942
        mov     edi, [eax + DES.virtaddr]               ; pointer to buffer
1122
        DEBUGF  1, "Descriptor is free\n"
943
        mov     esi, [bufferptr]
1123
 
944
        mov     ecx, [buffersize]
1124
        mov     eax, [bufferptr]
-
 
1125
        mov     [esi + TX_RING_SIZE*sizeof.desc], eax
Line 945... Line 1126...
945
        DEBUGF  1,"copying %u bytes from %x to %x\n", ecx, esi, edi
1126
        invoke  GetPhysAddr
946
        rep     movsb
1127
        mov     [esi + desc.buffer1], eax
947
 
1128
 
948
; set packet size
1129
; set packet size
949
        mov     ecx, [eax+DES.length]
1130
        mov     eax, [esi + desc.length]
950
        and     ecx, TDES1_TER                          ; preserve 'End of Ring' bit
1131
        and     eax, TDES1_TER                          ; preserve 'End of Ring' bit
Line 951... Line 1132...
951
        or      ecx, [buffersize]                       ; set size
1132
        or      eax, [buffersize]                       ; set size
952
        or      ecx, TDES1_FS or TDES1_LS or TDES1_IC or TDES1_TCH    ; first descr, last descr, interrupt on complete, chained modus
1133
        or      eax, TDES1_FS or TDES1_LS or TDES1_IC   ; first descr, last descr, interrupt on complete
Line 953... Line 1134...
953
        mov     [eax + DES.length], ecx
1134
        mov     [esi + desc.length], eax
954
 
1135
 
955
; set descriptor info
-
 
956
        mov     [eax + DES.status], DES0_OWN            ; say it is now owned by the 21x4x
1136
; set descriptor status
957
 
1137
        mov     [esi + desc.status], DES0_OWN            ; say it is now owned by the 21x4x
958
; start tx
1138
 
959
        set_io  [ebx + device.io_addr], 0
1139
; Check if transmitter is running
960
        status
1140
        set_io  [ebx + device.io_addr], 0
961
        set_io  [ebx + device.io_addr], CSR6
1141
        set_io  [ebx + device.io_addr], CSR6
962
        in      eax, dx
1142
        in      eax, dx
963
        test    eax, CSR6_ST            ; if NOT started, start now
1143
        test    eax, CSR6_ST                            ; if NOT started, start now
-
 
1144
        jnz     .already_started
964
        jnz     .already_started
1145
        or      eax, CSR6_ST
965
        or      eax, CSR6_ST
1146
        DEBUGF  1,"(Re) starting TX\n"
966
        DEBUGF  1,"Starting TX\n"
1147
        jmp     .do_it
967
        jmp     .do_it
1148
  .already_started:
968
  .already_started:
1149
 
Line 969... Line 1150...
969
                                        ; if already started, issues a Transmit Poll command
1150
; Trigger immediate transmit demand
970
        set_io  [ebx + device.io_addr], CSR1
1151
        set_io  [ebx + device.io_addr], CSR1
971
        mov     eax, -1
1152
        xor     eax, eax
972
  .do_it:
1153
  .do_it:
973
        out     dx , eax
1154
        out     dx, eax
Line 974... Line 1155...
974
 
1155
 
975
; Update stats
1156
; Update stats
976
        inc     [ebx + device.packets_tx]
1157
        inc     [ebx + device.packets_tx]
977
        mov     eax, [buffersize]
-
 
978
        add     dword [ebx + device.bytes_tx], eax
-
 
979
        adc     dword [ebx + device.bytes_tx + 4], 0
-
 
980
 
-
 
981
; go to next descriptor
-
 
982
        inc     [ebx + device.tx_wr_des]
-
 
983
        and     [ebx + device.tx_wr_des], TX_DES_COUNT-1
-
 
Line 984... Line 1158...
984
 
1158
        mov     eax, [buffersize]
985
; dec free descriptors count
-
 
986
        test    [ebx + device.tx_free_des], -1
1159
        add     dword [ebx + device.bytes_tx], eax
987
        jz      .end
1160
        adc     dword [ebx + device.bytes_tx + 4], 0
988
        dec     [ebx + device.tx_free_des]
1161
 
Line 989... Line 1162...
989
  .end:
1162
; go to next descriptor
990
        status
1163
        inc     [ebx + device.cur_tx]
991
 
1164
        and     [ebx + device.cur_tx], TX_RING_SIZE-1
992
        DEBUGF  1,"transmit ok\n"
1165
 
993
        invoke  KernelFree, [bufferptr]
1166
        DEBUGF  1,"Transmit ok\n"
994
        popf
1167
        popf
Line 1013... Line 1186...
1013
align 4
1186
align 4
1014
int_handler:
1187
int_handler:
Line 1015... Line 1188...
1015
 
1188
 
Line 1016... Line 1189...
1016
        push    ebx esi edi
1189
        push    ebx esi edi
Line 1017... Line 1190...
1017
 
1190
 
Line 1018... Line 1191...
1018
        DEBUGF  1,"\n%s int\n", my_service
1191
        DEBUGF  1,"INT\n"
1019
 
1192
 
Line 1026... Line 1199...
1026
  .nextdevice:
1199
  .nextdevice:
1027
        mov     ebx, [esi]
1200
        mov     ebx, [esi]
Line 1028... Line 1201...
1028
 
1201
 
1029
        set_io  [ebx + device.io_addr], 0
1202
        set_io  [ebx + device.io_addr], 0
1030
        set_io  [ebx + device.io_addr], CSR5
1203
        set_io  [ebx + device.io_addr], CSR5
1031
        in      ax, dx
1204
        in      eax, dx
1032
        test    ax, ax
1205
        and     eax, 0x0001ffff
1033
        out     dx, ax                                  ; send it back to ACK
1206
        out     dx, eax                                 ; send it back to ACK
1034
        jnz     .got_it
1207
        jnz     .got_it
1035
  .continue:
1208
  .continue:
1036
        add     esi, 4
1209
        add     esi, 4
1037
        dec     ecx
1210
        dec     ecx
Line 1041... Line 1214...
1041
        xor     eax, eax
1214
        xor     eax, eax
Line 1042... Line 1215...
1042
 
1215
 
Line 1043... Line 1216...
1043
        ret                                             ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
1216
        ret                                             ; If no device was found, abort (The irq was probably for a device, not registered to this driver)
1044
 
-
 
1045
  .got_it:
1217
 
Line 1046... Line 1218...
1046
 
1218
  .got_it:
1047
        DEBUGF  1,"Device: %x CSR5: %x ", ebx, ax
1219
        DEBUGF  1,"Device: %x CSR5: %x\n", ebx, eax
Line 1048... Line 1220...
1048
 
1220
 
1049
;----------------------------------
1221
;----------------------------------
1050
; TX ok?
-
 
Line -... Line 1222...
-
 
1222
; TX ok?
1051
 
1223
 
1052
        test    ax, CSR5_TI
-
 
1053
        jz      .not_tx
-
 
1054
        push    ax esi ecx
-
 
1055
 
-
 
1056
        DEBUGF 1,"TX ok!\n"
-
 
1057
                
-
 
1058
        ; go to current descriptor
-
 
1059
        mov     edi, [ebx + device.tx_p_des]
-
 
1060
 
-
 
1061
        mov     eax, [ebx + device.tx_rd_des]
1224
        test    eax, CSR5_TI
-
 
1225
        jz      .not_tx
-
 
1226
 
-
 
1227
        push    eax esi ecx
-
 
1228
        DEBUGF  1,"TX ok!\n"
-
 
1229
      .loop_tx:
Line 1062... Line -...
1062
        mov     edx, sizeof.DES
-
 
1063
        mul     edx
-
 
1064
        add     edi, eax
-
 
1065
                
-
 
1066
      .loop_tx:
1230
        ; go to last descriptor
1067
                
-
 
1068
        ; done if all desc are free
1231
        mov     eax, [ebx + device.last_tx]
1069
        cmp     [ebx + device.tx_free_des], TX_DES_COUNT
-
 
1070
        jz      .end_tx
1232
        mov     edx, sizeof.desc
-
 
1233
        mul     edx
-
 
1234
        lea     eax, [ebx + device.tx_ring + eax]
Line 1071... Line -...
1071
 
-
 
1072
        mov     eax, [edi + DES.status]
-
 
1073
 
1235
 
1074
        ; we stop at first desc that is owned be NIC
1236
        DEBUGF  1,"descriptor 0x%x\n", eax
1075
        test    eax, DES0_OWN
-
 
1076
        jnz     .end_tx
-
 
1077
 
1237
        test    [eax + desc.status], DES0_OWN           ; owned by the card?
Line 1078... Line 1238...
1078
        ; detect is setup packet
1238
        jnz     .end_tx
1079
        cmp     eax, (0ffffffffh - DES0_OWN)            ; all other bits are 1
-
 
1080
        jne     .not_setup_packet
1239
        cmp     [eax + desc.buffer1], 0                 ; empty descriptor?
1081
        DEBUGF  1,"Setup Packet detected\n"
1240
        je      .end_tx
1082
      .not_setup_packet:
-
 
1083
 
-
 
1084
        DEBUGF  1,"packet status: %x\n", eax
-
 
1085
 
-
 
1086
        ; next descriptor
-
 
1087
        add     edi, sizeof.DES
-
 
1088
        inc     [ebx + device.tx_rd_des]
-
 
Line 1089... Line 1241...
1089
        and     [ebx + device.tx_rd_des], TX_DES_COUNT-1
1241
 
1090
 
1242
        mov     [eax + desc.buffer1], 0
1091
        ; inc free desc
-
 
1092
        inc     [ebx + device.tx_free_des]
-
 
1093
        cmp     [ebx + device.tx_free_des], TX_DES_COUNT
-
 
1094
        jbe     @f
-
 
1095
        mov     [ebx + device.tx_free_des], TX_DES_COUNT
-
 
1096
       @@:
1243
        DEBUGF  1, "Free buffer 0x%x\n", [eax + TX_RING_SIZE*sizeof.desc]
-
 
1244
        invoke  KernelFree, [eax + TX_RING_SIZE*sizeof.desc]
Line 1097... Line 1245...
1097
 
1245
 
1098
        jmp     .loop_tx
1246
        ; next descriptor
1099
      .end_tx:
-
 
1100
                
1247
        inc     [ebx + device.last_tx]
1101
        ;------------------------------------------------------
1248
        and     [ebx + device.last_tx], TX_RING_SIZE-1
1102
        ; here must be called standard Ethernet Tx Irq Handler
1249
 
Line 1103... Line 1250...
1103
        ;------------------------------------------------------
1250
        jmp     .loop_tx
Line 1104... Line 1251...
1104
 
1251
  .end_tx:
1105
        pop     ecx esi ax
1252
        pop     ecx esi eax
1106
 
1253
  .not_tx:
Line 1107... Line 1254...
1107
;----------------------------------
1254
 
1108
; RX irq
-
 
1109
  .not_tx:
1255
;----------------------------------
1110
        test    ax, CSR5_RI
1256
; RX irq
1111
        jz      .not_rx
1257
        test    eax, CSR5_RI
1112
        push    ax esi ecx
1258
        jz      .not_rx
Line 1113... Line 1259...
1113
 
1259
        push    eax esi ecx
1114
        DEBUGF 1,"RX ok!\n"
1260
 
Line 1115... Line 1261...
1115
 
1261
        DEBUGF 1,"RX ok!\n"
1116
        push    ebx
1262
 
1117
  .rx_loop:
-
 
1118
        pop     ebx
1263
        push    ebx
1119
 
1264
  .rx_loop:
1120
        ; get current descriptor
-
 
1121
        mov     edi, [ebx + device.rx_p_des]
1265
        pop     ebx
1122
        mov     eax, [ebx + device.rx_crt_des]
1266
 
1123
        mov     edx, sizeof.DES
-
 
1124
        mul     edx
1267
        ; get current descriptor
1125
        add     edi, eax
1268
        mov     eax, [ebx + device.cur_rx]
Line 1126... Line 1269...
1126
 
1269
        mov     edx, sizeof.desc
1127
        ; now check status
1270
        mul     edx
1128
        mov     eax, [edi + DES.status]
1271
        lea     edi, [ebx + device.rx_ring + eax]
1129
 
1272
 
1130
        test    eax, DES0_OWN
1273
        ; now check status
Line 1131... Line 1274...
1131
        jnz     .end_rx                                 ; current desc is busy, nothing to do
1274
        mov     eax, [edi + desc.status]
Line 1132... Line 1275...
1132
 
1275
 
1133
        test    eax, RDES0_FS
1276
        test    eax, DES0_OWN
1134
        jz      .end_rx                                 ; current desc is NOT first packet, ERROR!
1277
        jnz     .end_rx                                 ; current desc is busy, nothing to do
1135
 
1278
        test    eax, RDES0_FS
1136
        test    eax, RDES0_LS                           ; if not last desc of packet, error for now
1279
        jz      .end_rx                                 ; current desc is NOT first packet, ERROR!
Line 1137... Line 1280...
1137
        jz      .end_rx
1280
        test    eax, RDES0_LS                           ; if not last desc of packet, error for now
1138
 
1281
        jz      .end_rx
1139
        test    eax, RDES0_ES
1282
        test    eax, RDES0_ES
1140
        jnz     .end_rx
1283
        jnz     .end_rx
Line 1141... Line 1284...
1141
 
1284
 
1142
        mov     esi, [edi + DES.virtaddr]
1285
        mov     esi, [edi + RX_RING_SIZE*sizeof.desc]
1143
        mov     ecx, [edi + DES.status]
1286
        mov     ecx, [edi + desc.status]
1144
        shr     ecx, RDES0_FL_SH
1287
        shr     ecx, RDES0_FL_SH
Line 1172... Line 1315...
1172
        jnc     .nw
1315
        jnc     .nw
1173
        movsw
1316
        movsw
1174
  .nw:
1317
  .nw:
1175
        rep     movsd
1318
        rep     movsd
Line 1176... Line 1319...
1176
 
1319
 
Line 1177... Line 1320...
1177
        mov     [edi + DES.status], DES0_OWN            ; free descriptor
1320
        mov     [eax + desc.status], DES0_OWN           ; free descriptor
1178
                
1321
                
Line 1179... Line 1322...
1179
        inc     [ebx + device.rx_crt_des]                     ; next descriptor
1322
        inc     [ebx + device.cur_rx]                   ; next descriptor
Line 1180... Line 1323...
1180
        and     [ebx + device.rx_crt_des], RX_DES_COUNT-1
1323
        and     [ebx + device.cur_rx], RX_RING_SIZE-1
1181
 
1324
 
1182
        jmp     [Eth_input]
1325
        jmp     [Eth_input]
1183
 
1326
 
Line 1184... Line 1327...
1184
  .end_rx:
1327
  .end_rx:
1185
  .fail:
1328
  .fail:
Line 1186... Line 1329...
1186
        pop     ecx esi ax
1329
        pop     ecx esi eax
1187
  .not_rx:
1330
  .not_rx:
Line 1188... Line 1331...
1188
 
1331
 
Line 1189... Line 1332...
1189
        pop     edi esi ebx
1332
        pop     edi esi ebx
1190
        ret
1333
        ret
1191
 
1334
 
1192
 
1335
 
1193
 
1336
 
1194
align 4
1337
align 4
Line 1195... Line 1338...
1195
write_mac:      ; in: mac pushed onto stack (as 3 words)
1338
write_mac:      ; in: mac pushed onto stack (as 3 words)
1196
 
1339
 
1197
        DEBUGF  2,"Writing MAC: "
-
 
1198
 
-
 
1199
; write data into driver cache
-
 
1200
        mov     esi, esp
-
 
1201
        lea     edi, [ebx + device.mac]
-
 
1202
        movsd
-
 
1203
        movsw
-
 
1204
        add     esp, 6
-
 
1205
        
-
 
Line 1206... Line 1340...
1206
; send setup packet (only if driver is started)
1340
        DEBUGF  1,"Writing MAC\n"
1207
        call    Send_Setup_Packet
1341
 
Line 1208... Line 1342...
1208
 
1342
; write data into driver cache
Line 1209... Line 1343...
1209
align 4
1343
        mov     esi, esp
1210
read_mac:
1344
        lea     edi, [ebx + device.mac]
1211
 
1345
        movsd
1212
        DEBUGF 1,"Read_mac\n"
1346
        movsw
Line 1229... Line 1363...
1229
        stosw
1363
        stosw
1230
        inc     esi
1364
        inc     esi
1231
        cmp     esi, 26/2
1365
        cmp     esi, 26/2
1232
        jb      .loop
1366
        jb      .loop
Line 1233... Line 1367...
1233
 
1367
 
1234
        DEBUGF  2,"%x-%x-%x-%x-%x-%x\n",[edi-6]:2,[edi-5]:2,[edi-4]:2,[edi-3]:2,[edi-2]:2,[edi-1]:2
-
 
1235
 
-
 
1236
        ret
-
 
1237
 
-
 
1238
align 4
-
 
1239
write_mac_eeprom:
-
 
1240
 
-
 
Line 1241... Line 1368...
1241
        DEBUGF 1,"Write_mac_eeprom\n"
1368
        DEBUGF  1,"%x-%x-%x-%x-%x-%x\n",[edi-6]:2,[edi-5]:2,[edi-4]:2,[edi-3]:2,[edi-2]:2,[edi-1]:2
Line 1242... Line 1369...
1242
 
1369
 
1243
        ret
1370
        ret
Line 1244... Line 1371...
1244
 
1371
 
Line 1245... Line 1372...
1245
 
1372
 
1246
align 4
1373
align 4
Line 1247... Line 1374...
1247
SROM_GetWidth:  ; should be 6 or 8 according to some manuals (returns in ecx)
1374
SROM_GetWidth:  ; should be 6 or 8 according to some manuals (returns in ecx)
Line 1288... Line 1415...
1288
        inc     ecx
1415
        inc     ecx
1289
        cmp     ecx, 12
1416
        cmp     ecx, 12
1290
        jbe     .loop2
1417
        jbe     .loop2
1291
  .end_loop2:
1418
  .end_loop2:
Line 1292... Line 1419...
1292
        
1419
        
Line 1293... Line 1420...
1293
        DEBUGF 1,"Srom width=%u\n", ecx
1420
        DEBUGF  1,"SROM width=%u\n", ecx
1294
        
1421
        
1295
        call    SROM_Idle
1422
        call    SROM_Idle
Line 1314... Line 1441...
1314
 
1441
 
1315
 
1442
 
Line 1316... Line 1443...
1316
align 4
1443
align 4
Line 1317... Line 1444...
1317
SROM_EnterAccessMode:
1444
SROM_EnterAccessMode:
1318
 
1445
 
1319
        DEBUGF 1,"SROM_EnterAccessMode\n"
1446
;        DEBUGF 1,"SROM_EnterAccessMode\n"
1320
 
1447
 
Line 1338... Line 1465...
1338
 
1465
 
1339
 
1466
 
Line 1340... Line 1467...
1340
align 4
1467
align 4
Line 1341... Line 1468...
1341
SROM_Idle:
1468
SROM_Idle:
Line 1342... Line 1469...
1342
 
1469
 
1343
        DEBUGF 1,"SROM_Idle\n"
1470
;        DEBUGF 1,"SROM_Idle\n"
Line 1379... Line 1506...
1379
;;                                                                      ;;
1506
;;                                                                      ;;
1380
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1507
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1381
align 4
1508
align 4
1382
SROM_Read_Word:
1509
SROM_Read_Word:
Line 1383... Line 1510...
1383
 
1510
 
Line 1384... Line 1511...
1384
        DEBUGF 1,"SROM_Read_word at: %x result: ", esi
1511
;        DEBUGF 1,"SROM_Read_word at: %x\n", esi
1385
 
1512
 
Line 1386... Line 1513...
1386
        set_io  [ebx + device.io_addr], 0
1513
        set_io  [ebx + device.io_addr], 0
Line 1437... Line 1564...
1437
        dec     ecx
1564
        dec     ecx
1438
        jnz     .loop_read
1565
        jnz     .loop_read
Line 1439... Line 1566...
1439
        
1566
        
Line 1440... Line 1567...
1440
        mov     eax, esi
1567
        mov     eax, esi
Line 1441... Line 1568...
1441
 
1568
 
Line 1442... Line -...
1442
        DEBUGF 1,"%x\n", ax
-
 
1443
 
-
 
1444
        ret
-
 
1445
 
-
 
1446
 
-
 
1447
 
-
 
1448
 
-
 
1449
 
-
 
1450
 
1569
;        DEBUGF 1,"%x\n", ax
1451
 
1570
 
1452
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1571
        ret
Line 1453... Line 1572...
1453
 
1572
 
Line 1483... Line 1602...
1483
; for details.
1602
; for details.
Line 1484... Line 1603...
1484
 
1603
 
1485
align 4
1604
align 4
Line 1486... Line 1605...
1486
mdio_read:      ; phy_id:edx, location:esi
1605
mdio_read:      ; phy_id:edx, location:esi
Line 1487... Line 1606...
1487
 
1606
 
1488
        DEBUGF  1,"mdio read, phy=%x, location=%x", edx, esi
1607
        DEBUGF  1,"mdio read, phy=%x, location=%x\n", edx, esi
1489
 
1608
 
Line 1577... Line 1696...
1577
        jnz     .loop3
1696
        jnz     .loop3
Line 1578... Line 1697...
1578
 
1697
 
1579
        shr     esi, 1
1698
        shr     esi, 1
Line 1580... Line 1699...
1580
        movzx   eax, si
1699
        movzx   eax, si
Line 1581... Line 1700...
1581
 
1700
 
Line 1675... Line 1794...
1675
        jnz     .loop3
1794
        jnz     .loop3
Line 1676... Line 1795...
1676
 
1795
 
Line -... Line 1796...
-
 
1796
        ret
-
 
1797
 
-
 
1798
 
-
 
1799
 
1677
        ret
1800
 
Line 1678... Line 1801...
1678
 
1801
 
1679
 
1802
 
Line 1680... Line 1803...
1680
; End of code
1803
; End of code
Line 1681... Line 1804...
1681
 
1804
 
Line -... Line 1805...
-
 
1805
data fixups
-
 
1806
end data
-
 
1807
 
-
 
1808
include '../peimport.inc'
-
 
1809
 
-
 
1810
my_service    db 'DEC21X4X',0                    ; max 16 chars include zero
-
 
1811
 
-
 
1812
chiplist:
-
 
1813
;   PCI id's , chip ,IO size, CSR7      , name  ,  flags
-
 
1814
dd 0x00021011, DC21040,  128, 0x0001ebef, sz_040,  0
-
 
1815
dd 0x00141011, DC21041,  128, 0x0001ebef, sz_041,  FLAG_HAS_MEDIA_TABLE
-
 
1816
dd 0x00091011, DC21140,  128, 0x0001ebef, sz_140,  FLAG_HAS_MII or FLAG_HAS_MEDIA_TABLE or FLAG_CSR12_IN_SROM
-
 
1817
dd 0x00191011, DC21143,  128, 0x0001ebef, sz_143,  FLAG_HAS_MII or FLAG_HAS_MEDIA_TABLE or FLAG_ALWAYS_CHECK_MII or FLAG_HAS_ACPI
-
 
1818
dd 0x000211AD, LC82C168, 256, 0x0801fbff, sz_lite, FLAG_HAS_MII
-
 
1819
dd 0x051210D9, MX98713,  128, 0x0001ebef, sz_m512, FLAG_HAS_MII or FLAG_HAS_MEDIA_TABLE
-
 
1820
dd 0x053110D9, MX98715,  256, 0x0001ebef, sz_m513, FLAG_HAS_MEDIA_TABLE
-
 
1821
dd 0x1400125B, MX98725,  128, 0x0001fbff, sz_asix, FLAG_HAS_MII or FLAG_HAS_MEDIA_TABLE or FLAG_CSR12_IN_SROM
-
 
1822
dd 0
-
 
1823
 
-
 
1824
sz_040  db "Digital DC21040 Tulip", 0
-
 
1825
sz_041  db "Digital DC21041 Tulip", 0
1682
data fixups
1826
sz_140  db "Digital DS21140 Tulip", 0
Line 1683... Line 1827...
1683
end data
1827
sz_143  db "Digital DS21143 Tulip", 0
1684
 
1828
sz_lite db "Lite-On 82c168 PNIC", 0
1685
include '../peimport.inc'
1829
sz_m512 db "Macronix 98713 PMAC", 0
1686
 
-