ReactOS 0.4.15-dev-8408-g466a198
media041.c File Reference
#include "dc21x4.h"
#include <debug.h>
Include dependency graph for media041.c:

Go to the source code of this file.

Functions

VOID MediaLinkStateChange21041 (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG InterruptStatus)
 
static VOID Media041SelectNextMedia (_In_ PDC21X4_ADAPTER Adapter)
 
VOID NTAPI MediaMonitor21041Dpc (_In_ PVOID SystemSpecific1, _In_ PVOID FunctionContext, _In_ PVOID SystemSpecific2, _In_ PVOID SystemSpecific3)
 

Function Documentation

◆ Media041SelectNextMedia()

static VOID Media041SelectNextMedia ( _In_ PDC21X4_ADAPTER  Adapter)
static

Definition at line 62 of file media041.c.

64{
65 if (Adapter->MediaNumber == MEDIA_AUI)
66 Adapter->ModeFlags |= DC_MODE_AUI_FAILED;
67 else if (Adapter->MediaNumber == MEDIA_BNC)
68 Adapter->ModeFlags |= DC_MODE_BNC_FAILED;
69
70 if ((Adapter->ModeFlags & (DC_MODE_AUI_FAILED | DC_MODE_BNC_FAILED)) ==
72 {
73 Adapter->MediaNumber = MEDIA_10T;
74 }
75 else
76 {
77 Adapter->MediaNumber = (MEDIA_BNC + MEDIA_AUI) - Adapter->MediaNumber;
78 }
79
80 MediaSiaSelect(Adapter);
81}
#define DC_MODE_AUI_FAILED
Definition: dc21x4.h:166
#define DC_MODE_BNC_FAILED
Definition: dc21x4.h:167
VOID MediaSiaSelect(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:268
#define MEDIA_AUI
Definition: media.h:48
#define MEDIA_10T
Definition: media.h:46
#define MEDIA_BNC
Definition: media.h:47

Referenced by MediaMonitor21041Dpc().

◆ MediaLinkStateChange21041()

VOID MediaLinkStateChange21041 ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  InterruptStatus 
)

Definition at line 17 of file media041.c.

20{
21 NdisDprAcquireSpinLock(&Adapter->ModeLock);
22
23 if (InterruptStatus & DC_IRQ_LINK_PASS)
24 {
25 INFO_VERB("Link passed, CSR12 %08lx\n", DC_READ(Adapter, DcCsr12_SiaStatus));
26
27 /* 10Base-T is the active port now */
28 if (MEDIA_IS_AUI_BNC(Adapter->MediaNumber))
29 {
30 /* Switch to TP medium */
31 if (!MEDIA_IS_FIXED(Adapter))
32 {
33 Adapter->MediaNumber = MEDIA_10T;
34 MediaSiaSelect(Adapter);
35
36 NdisMSetTimer(&Adapter->MediaMonitorTimer, 3000);
37 }
38 }
39
40 /* 10Base-T link is up */
41 if (!MEDIA_IS_AUI_BNC(Adapter->MediaNumber))
42 {
43 MediaIndicateConnect(Adapter, TRUE);
44 }
45 }
46 else // DC_IRQ_LINK_FAIL
47 {
48 INFO_VERB("Link failed, CSR12 %08lx\n", DC_READ(Adapter, DcCsr12_SiaStatus));
49
50 /* 10Base-T link is down */
51 if (!MEDIA_IS_AUI_BNC(Adapter->MediaNumber))
52 {
54 }
55 }
56
57 NdisDprReleaseSpinLock(&Adapter->ModeLock);
58}
FORCEINLINE ULONG DC_READ(_In_ PDC21X4_ADAPTER Adapter, _In_ DC_CSR Register)
Definition: dc21x4.h:262
VOID MediaIndicateConnect(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN LinkUp)
Definition: media.c:17
@ DcCsr12_SiaStatus
Definition: dc21x4hw.h:188
#define DC_IRQ_LINK_PASS
Definition: dc21x4hw.h:271
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define INFO_VERB
Definition: debug.h:90
VOID EXPORT NdisMSetTimer(IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsToDelay)
Definition: time.c:272
#define MEDIA_IS_FIXED(Adapter)
Definition: media.h:126
#define MEDIA_IS_AUI_BNC(MediaNumber)
Definition: media.h:110
#define NdisDprReleaseSpinLock(_SpinLock)
Definition: ndis.h:4133
#define NdisDprAcquireSpinLock(_SpinLock)
Definition: ndis.h:4124

◆ MediaMonitor21041Dpc()

VOID NTAPI MediaMonitor21041Dpc ( _In_ PVOID  SystemSpecific1,
_In_ PVOID  FunctionContext,
_In_ PVOID  SystemSpecific2,
_In_ PVOID  SystemSpecific3 
)

Definition at line 85 of file media041.c.

90{
92 BOOLEAN LinkUp, Report;
93 ULONG DelayMs, SiaStatus;
94
95 UNREFERENCED_PARAMETER(SystemSpecific1);
98
99 if (!(Adapter->Flags & DC_ACTIVE))
100 return;
101
102 Report = FALSE;
103 DelayMs = 5000;
104
106
107 SiaStatus = DC_READ(Adapter, DcCsr12_SiaStatus);
108
109 if (MEDIA_IS_AUI_BNC(Adapter->MediaNumber))
110 {
111 if ((Adapter->ModeFlags & DC_MODE_PORT_AUTOSENSE))
112 {
113 Adapter->ModeFlags &= ~DC_MODE_PORT_AUTOSENSE;
114
115 /* Select the other port */
116 if (!(SiaStatus & DC_SIA_STATUS_SELECTED_PORT_ACTIVITY))
117 {
118 Adapter->MediaNumber = MEDIA_BNC;
119 MediaSiaSelect(Adapter);
120 }
121
122 DelayMs = 1000;
123 }
124 else
125 {
127
128 if (!(Adapter->ModeFlags & DC_MODE_TEST_PACKET))
129 {
130 if ((Adapter->MediaNumber == MEDIA_AUI) &&
132 {
133 /* Clear the selected port activity bit */
135
136 LinkUp = TRUE;
137 Report = TRUE;
138 }
139 /* Check for any received packets */
140 else if (ReceiveActivity != Adapter->LastReceiveActivity)
141 {
142 LinkUp = TRUE;
143 Report = TRUE;
144
145 DelayMs = 3000;
146 }
147 else
148 {
149 /* Send a loopback packet */
151 DcTestPacket(Adapter);
153
154 DelayMs = 3000;
155 }
156 }
157 else
158 {
159 Adapter->ModeFlags &= ~DC_MODE_TEST_PACKET;
160
161 LinkUp = !!Adapter->MediaTestStatus;
162 Report = TRUE;
163
164 /* Select the other port */
165 if (!LinkUp && !MEDIA_IS_FIXED(Adapter))
166 {
168
169 DelayMs = 3000;
170 }
171 }
173 }
174 }
175 else // 10Base-T
176 {
177 Report = TRUE;
180
181 if (!LinkUp)
182 {
183 DelayMs = 3000;
184
185 /* Select the AUI or BNC port */
186 if (!MEDIA_IS_FIXED(Adapter) && (Adapter->MediaBitmap & MEDIA_AUI_BNC_MASK))
187 {
188 Adapter->ModeFlags &= ~(DC_MODE_AUI_FAILED |
191
193 {
194 Adapter->MediaNumber = MEDIA_AUI;
196 }
197 else
198 {
199 Adapter->MediaNumber = MEDIA_BNC;
200 }
201 MediaSiaSelect(Adapter);
202
203 Adapter->LastReceiveActivity = (ULONG)Adapter->Statistics.ReceiveOk;
204
205 /* Clear the port activity bits */
208
209 DelayMs = 1000;
210 }
211 }
212 }
213
214 if (Report)
215 {
217 }
218
220
221 NdisMSetTimer(&Adapter->MediaMonitorTimer, DelayMs);
222}
unsigned char BOOLEAN
#define DC_ACTIVE
Definition: dc21x4.h:120
#define DC_MODE_PORT_AUTOSENSE
Definition: dc21x4.h:164
#define DC_MODE_TEST_PACKET
Definition: dc21x4.h:165
#define DC_WRITE(Adapter, Register, Value)
Definition: dc21x4.h:272
VOID DcTestPacket(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:135
#define DC_SIA_STATUS_10T_LINK_FAIL
Definition: dc21x4hw.h:422
#define DC_SIA_STATUS_SELECTED_PORT_ACTIVITY
Definition: dc21x4hw.h:423
#define DC_SIA_STATUS_NETWORK_CONNECTION_ERROR
Definition: dc21x4hw.h:420
#define DC_SIA_STATUS_NONSEL_PORT_ACTIVITY
Definition: dc21x4hw.h:426
if(dx< 0)
Definition: linetemp.h:194
static VOID Media041SelectNextMedia(_In_ PDC21X4_ADAPTER Adapter)
Definition: media041.c:62
#define MEDIA_AUI_BNC_MASK
Definition: media.h:82
_In_ PVOID _In_ PVOID SystemSpecific2
Definition: ndis.h:638
_In_ PVOID FunctionContext
Definition: ndis.h:637
_In_ PVOID _In_ PVOID _In_ PVOID SystemSpecific3
Definition: ndis.h:639
static NTSTATUS ReceiveActivity(PAFD_FCB FCB, PIRP Irp)
Definition: read.c:151
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
@ LinkUp
Definition: srb.h:741
volatile LONG MediaTestStatus
Definition: dc21x4.h:180
ULONG ModeFlags
Definition: dc21x4.h:162
DECLSPEC_CACHEALIGN NDIS_SPIN_LOCK ModeLock
Definition: dc21x4.h:161
ULONG MediaBitmap
Definition: dc21x4.h:175
ULONG LastReceiveActivity
Definition: dc21x4.h:179
ULONG MediaNumber
Definition: dc21x4.h:174
NDIS_MINIPORT_TIMER MediaMonitorTimer
Definition: dc21x4.h:181
DECLSPEC_CACHEALIGN NDIS_SPIN_LOCK SendLock
Definition: dc21x4.h:129
DC_STATISTICS Statistics
Definition: dc21x4.h:156
ULONG Flags
Definition: dc21x4.h:119
ULONG64 ReceiveOk
Definition: dc21x4.h:90
uint32_t ULONG
Definition: typedefs.h:59