Subversion Repositories Kolibri OS

Rev

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

Rev 5561 Rev 5562
Line 71... Line 71...
71
RX_ADDR_LOAD    = 0x0006
71
RX_ADDR_LOAD    = 0x0006
72
RX_RESUMENR     = 0x0007
72
RX_RESUMENR     = 0x0007
73
INT_MASK        = 0x0100
73
INT_MASK        = 0x0100
74
DRVR_INT        = 0x0200        ; Driver generated interrupt
74
DRVR_INT        = 0x0200        ; Driver generated interrupt
Line 75... Line -...
75
 
-
 
76
CmdIASetup      = 0x0001
-
 
77
CmdConfigure    = 0x0002
-
 
78
CmdTx           = 0x0004
-
 
79
CmdTxFlex       = 0x0008
-
 
80
Cmdsuspend      = 0x4000
-
 
81
 
-
 
82
CmdRxFlex       = 0x0008
-
 
83
 
75
 
84
reg_scb_status  = 0
76
REG_SCB_STATUS  = 0
85
reg_scb_cmd     = 2
77
REG_SCB_CMD     = 2
86
reg_scb_ptr     = 4
78
REG_SCB_PTR     = 4
87
reg_port        = 8
79
REG_PORT        = 8
88
reg_eeprom      = 14
80
REG_EEPROM      = 14
89
reg_mdi_ctrl    = 16
81
REG_MDI_CTRL    = 16
90
 
82
 
91
phy_100a        = 0x000003E0
83
PHY_100a        = 0x000003E0
92
phy_100c        = 0x035002A8
84
PHY_100c        = 0x035002A8
93
phy_82555_tx    = 0x015002A8
85
PHY_82555_tx    = 0x015002A8
94
phy_nsc_tx      = 0x5C002000
86
PHY_nsc_tx      = 0x5C002000
95
phy_82562_et    = 0x033002A8
87
PHY_82562_et    = 0x033002A8
96
phy_82562_em    = 0x032002A8
88
PHY_82562_em    = 0x032002A8
97
phy_82562_ek    = 0x031002A8
89
PHY_82562_ek    = 0x031002A8
98
phy_82562_eh    = 0x017002A8
90
PHY_82562_eh    = 0x017002A8
99
phy_82552_v     = 0xd061004d
91
PHY_82552_v     = 0xd061004d
100
phy_unknown     = 0xFFFFFFFF
92
PHY_unknown     = 0xFFFFFFFF
101
 
93
 
102
mac_82557_D100_A        = 0
94
MAC_82557_D100_A        = 0
103
mac_82557_D100_B        = 1     
95
MAC_82557_D100_B        = 1
104
mac_82557_D100_C        = 2     
96
MAC_82557_D100_C        = 2
105
mac_82558_D101_A4       = 4     
97
MAC_82558_D101_A4       = 4
106
mac_82558_D101_B0       = 5     
98
MAC_82558_D101_B0       = 5
107
mac_82559_D101M         = 8     
99
MAC_82559_D101M         = 8
108
mac_82559_D101S         = 9     
100
MAC_82559_D101S         = 9
109
mac_82550_D102          = 12    
101
MAC_82550_D102          = 12
110
mac_82550_D102_C        = 13    
102
MAC_82550_D102_C        = 13
111
mac_82551_E             = 14    
103
MAC_82551_E             = 14
112
mac_82551_F             = 15    
104
MAC_82551_F             = 15
113
mac_82551_10            = 16    
105
MAC_82551_10            = 16
-
 
106
MAC_unknown             = 0xFF
-
 
107
 
-
 
108
SCB_STATUS_RUS          = 111100b       ; RU Status
-
 
109
RU_STATUS_IDLE          = 0000b shl 2
-
 
110
RU_STATUS_SUSPENDED     = 0001b shl 2
-
 
111
RU_STATUS_NO_RESOURCES  = 0010b shl 2
-
 
112
RU_STATUS_READY         = 0100b shl 2
-
 
113
SCB_STATUS_FCP          = 1 shl 8       ; Flow Control Pause
-
 
114
SCB_STATUS_SWI          = 1 shl 10      ; Software Interrupt
-
 
115
SCB_STATUS_MDI          = 1 shl 11      ; MDI read/write complete
-
 
116
SCB_STATUS_RNR          = 1 shl 12      ; Receiver Not Ready
-
 
117
SCB_STATUS_CNA          = 1 shl 13      ; Command unit Not Active
-
 
118
SCB_STATUS_FR           = 1 shl 14      ; Frame received
Line 114... Line 119...
114
mac_unknown             = 0xFF
119
SCB_STATUS_CX_TNO       = 1 shl 15      ; Command finished / Transmit Not Okay
Line 115... Line 120...
115
 
120
 
116
struct  rxfd
121
struct  rxfd
Line 123... Line 128...
123
        size            dw ?
128
        size            dw ?
124
        packet          rb 1500
129
        packet          rb 1500
Line 125... Line 130...
125
 
130
 
Line -... Line 131...
-
 
131
ends
-
 
132
 
-
 
133
RXFD_STATUS_RC          = 1 shl 0       ; Receive collision
-
 
134
RXFD_STATUS_IA          = 1 shl 1       ; IA mismatch
-
 
135
RXFD_STATUS_NA          = 1 shl 2       ; No address match
-
 
136
RXFD_STATUS_RE          = 1 shl 4       ; Receive Error
-
 
137
RXFD_STATUS_TL          = 1 shl 5       ; Type/length
-
 
138
RXFD_STATUS_FS          = 1 shl 7       ; Frame too short
-
 
139
RXFD_STATUS_DMA_FAIL    = 1 shl 8       ; DMA overrun failure
-
 
140
RXFD_STATUS_NR          = 1 shl 9       ; Out of buffer space; no resources
-
 
141
RXFD_STATUS_MISA        = 1 shl 10      ; Alignment error
-
 
142
RXFD_STATUS_CRC_ERR     = 1 shl 11      ; CRC error in aligned frame
-
 
143
RXFD_STATUS_OK          = 1 shl 13      ; Frame received and stored
-
 
144
RXFD_STATUS_C           = 1 shl 15      ; Completion of frame reception
-
 
145
 
-
 
146
RXFD_CMD_SF             = 1 shl 3
-
 
147
RXFD_CMD_H              = 1 shl 4       ; Header RFD
-
 
148
RXFD_CMD_SUSPEND        = 1 shl 14      ; Suspends RU after receiving the frame
126
ends
149
RXFD_CMD_EL             = 1 shl 15      ; Last RFD in RFA
Line 127... Line 150...
127
 
150
 
128
struct  txfd
151
struct  txfd
129
 
152
 
Line 138... Line 161...
138
        virt_addr       dd ?
161
        virt_addr       dd ?
139
                        dd ?            ; alignment
162
                        dd ?            ; alignment
Line 140... Line 163...
140
 
163
 
Line -... Line 164...
-
 
164
ends
-
 
165
 
-
 
166
TXFD_CMD_IA             = 1 shl 0
-
 
167
TXFD_CMD_CFG            = 1 shl 1
-
 
168
TXFD_CMD_TX             = 1 shl 2
-
 
169
TXFD_CMD_TX_FLEX        = 1 shl 3
141
ends
170
TXFD_CMD_SUSPEND        = 1 shl 14
Line 142... Line 171...
142
 
171
 
143
struc   confcmd {
172
struc   confcmd {
144
 
173
 
Line 453... Line 482...
453
 
482
 
454
;---------------
483
;---------------
Line 455... Line 484...
455
; reset the card
484
; reset the card
456
 
485
 
457
        set_io  [ebx + device.io_addr], 0
486
        set_io  [ebx + device.io_addr], 0
458
        set_io  [ebx + device.io_addr], reg_port
487
        set_io  [ebx + device.io_addr], REG_PORT
Line 459... Line 488...
459
        xor     eax, eax        ; Software Reset
488
        xor     eax, eax        ; Software Reset
460
        out     dx, eax
489
        out     dx, eax
Line 466... Line 495...
466
; Tell device where to store stats
495
; Tell device where to store stats
Line 467... Line 496...
467
 
496
 
468
        lea     eax, [ebx + device.lstats.tx_good_frames]      ; lstats
497
        lea     eax, [ebx + device.lstats.tx_good_frames]      ; lstats
469
        invoke  GetPhysAddr
498
        invoke  GetPhysAddr
470
        set_io  [ebx + device.io_addr], 0
499
        set_io  [ebx + device.io_addr], 0
471
        set_io  [ebx + device.io_addr], reg_scb_ptr
500
        set_io  [ebx + device.io_addr], REG_SCB_PTR
Line 472... Line 501...
472
        out     dx, eax
501
        out     dx, eax
473
 
502
 
474
        set_io  [ebx + device.io_addr], reg_scb_cmd
503
        set_io  [ebx + device.io_addr], REG_SCB_CMD
475
        mov     ax, CU_STATSADDR or INT_MASK
504
        mov     ax, CU_STATSADDR or INT_MASK
Line 476... Line 505...
476
        out     dx, ax
505
        out     dx, ax
477
        call    cmd_wait
506
        call    cmd_wait
Line 478... Line 507...
478
 
507
 
479
;------------------------
508
;------------------------
480
; setup RX base addr to 0
509
; setup RX base addr to 0
Line 481... Line 510...
481
 
510
 
482
        set_io  [ebx + device.io_addr], reg_scb_ptr
511
        set_io  [ebx + device.io_addr], REG_SCB_PTR
483
        xor     eax, eax
512
        xor     eax, eax
484
        out     dx, eax
513
        out     dx, eax
Line 485... Line 514...
485
 
514
 
Line 502... Line 531...
502
; Start RX
531
; Start RX
Line 503... Line 532...
503
 
532
 
Line 504... Line 533...
504
        DEBUGF  1, "Starting RX"
533
        DEBUGF  1, "Starting RX"
505
 
534
 
506
        set_io  [ebx + device.io_addr], 0
535
        set_io  [ebx + device.io_addr], 0
507
        set_io  [ebx + device.io_addr], reg_scb_ptr
536
        set_io  [ebx + device.io_addr], REG_SCB_PTR
508
        mov     eax, [ebx + device.rx_desc]
537
        mov     eax, [ebx + device.rx_desc]
509
        invoke  GetPhysAddr
538
        invoke  GetPhysAddr
Line 510... Line 539...
510
        add     eax, NET_BUFF.data
539
        add     eax, NET_BUFF.data
511
        out     dx, eax
540
        out     dx, eax
512
 
541
 
513
        set_io  [ebx + device.io_addr], reg_scb_cmd
542
        set_io  [ebx + device.io_addr], REG_SCB_CMD
Line 514... Line 543...
514
        mov     ax, RX_START or INT_MASK
543
        mov     ax, RX_START or INT_MASK
515
        out     dx, ax
544
        out     dx, ax
Line 516... Line 545...
516
        call    cmd_wait
545
        call    cmd_wait
517
 
546
 
518
;----------
547
;----------
Line 519... Line 548...
519
; Set-up TX
548
; Set-up TX
520
 
549
 
521
        set_io  [ebx + device.io_addr], reg_scb_ptr
550
        set_io  [ebx + device.io_addr], REG_SCB_PTR
522
        xor     eax, eax
551
        xor     eax, eax
Line 523... Line 552...
523
        out     dx, eax
552
        out     dx, eax
524
 
553
 
Line 525... Line 554...
525
        set_io  [ebx + device.io_addr], reg_scb_cmd
554
        set_io  [ebx + device.io_addr], REG_SCB_CMD
526
        mov     ax, CU_CMD_BASE or INT_MASK
555
        mov     ax, CU_CMD_BASE or INT_MASK
527
        out     dx, ax
556
        out     dx, ax
528
        call    cmd_wait
557
        call    cmd_wait
529
 
558
 
530
;-------------------------
559
;-------------------------
531
; Individual address setup
560
; Individual address setup
532
 
561
 
533
        mov     [ebx + device.confcmd.command], CmdIASetup + Cmdsuspend
562
        mov     [ebx + device.confcmd.command], TXFD_CMD_IA + TXFD_CMD_SUSPEND
Line 534... Line 563...
534
        mov     [ebx + device.confcmd.status], 0
563
        mov     [ebx + device.confcmd.status], 0
535
        lea     eax, [ebx + device.tx_ring]
564
        lea     eax, [ebx + device.tx_ring]
536
        invoke  GetPhysAddr
565
        invoke  GetPhysAddr
537
        mov     [ebx + device.confcmd.link], eax
566
        mov     [ebx + device.confcmd.link], eax
Line 538... Line 567...
538
        lea     edi, [ebx + device.confcmd.data]
567
        lea     edi, [ebx + device.confcmd.data]
539
        lea     esi, [ebx + device.mac]
568
        lea     esi, [ebx + device.mac]
540
        movsd
569
        movsd
541
        movsw
570
        movsw
Line 542... Line 571...
542
 
571
 
543
        set_io  [ebx + device.io_addr], reg_scb_ptr
572
        set_io  [ebx + device.io_addr], REG_SCB_PTR
Line 544... Line 573...
544
        lea     eax, [ebx + device.confcmd.status]
573
        lea     eax, [ebx + device.confcmd.status]
545
        invoke  GetPhysAddr
574
        invoke  GetPhysAddr
546
        out     dx, eax
575
        out     dx, eax
547
 
576
 
548
        set_io  [ebx + device.io_addr], reg_scb_cmd
577
        set_io  [ebx + device.io_addr], REG_SCB_CMD
Line 569... Line 598...
569
        mov     byte[ebx + device.confcmd.data + 5], 0x80
598
        mov     byte[ebx + device.confcmd.data + 5], 0x80
570
        mov     byte[ebx + device.confcmd.data + 15], 0x48
599
        mov     byte[ebx + device.confcmd.data + 15], 0x48
571
        mov     byte[ebx + device.confcmd.data + 19], 0x80
600
        mov     byte[ebx + device.confcmd.data + 19], 0x80
572
        mov     byte[ebx + device.confcmd.data + 21], 0x05
601
        mov     byte[ebx + device.confcmd.data + 21], 0x05
Line 573... Line 602...
573
 
602
 
574
        set_io  [ebx + device.io_addr], reg_scb_ptr
603
        set_io  [ebx + device.io_addr], REG_SCB_PTR
575
        lea     eax, [ebx + device.confcmd.status]
604
        lea     eax, [ebx + device.confcmd.status]
576
        invoke  GetPhysAddr
605
        invoke  GetPhysAddr
Line 577... Line 606...
577
        out     dx, eax
606
        out     dx, eax
578
 
607
 
579
        set_io  [ebx + device.io_addr], reg_scb_cmd
608
        set_io  [ebx + device.io_addr], REG_SCB_CMD
580
        mov     ax, CU_START                            ; expect Interrupts from now on
609
        mov     ax, CU_START                            ; expect Interrupts from now on
Line 581... Line 610...
581
        out     dx, ax
610
        out     dx, ax
Line 608... Line 637...
608
        jz      .out_of_mem
637
        jz      .out_of_mem
609
        mov     [ebx + device.rx_desc], eax
638