ReactOS 0.4.15-dev-7931-gfd331f1
dc21x4.h File Reference
#include <ndis.h>
#include <section_attribs.h>
#include "dc21x4hw.h"
#include "eeprom.h"
#include "media.h"
#include "util.h"
#include "sendrcv.h"
Include dependency graph for dc21x4.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DC_TX_BUFFER_DATA
 
struct  _DC_STATISTICS
 
struct  _DC21X4_ADAPTER
 

Macros

#define NO_KERNEL_LIST_ENTRY_CHECKS
 
#define DC21X4_TAG   '4x12'
 
#define DC_TRANSMIT_DESCRIPTORS   64
 
#define DC_TRANSMIT_BLOCKS   48
 
#define DC_TRANSMIT_BUFFERS   4
 
#define DC_LOOPBACK_FRAMES   4
 
#define DC_RECEIVE_BUFFERS_DEFAULT   64
 
#define DC_RECEIVE_BUFFERS_MIN   8
 
#define DC_RECEIVE_BUFFERS_EXTRA   16
 
#define DC_RECEIVE_ARRAY_SIZE   16
 
#define DC_MULTICAST_LIST_SIZE   36
 
#define DC_MAXIMUM_FRAME_SIZE   1514
 
#define DC_TRANSMIT_BLOCK_SIZE   1536
 
#define DC_RECEIVE_BLOCK_SIZE   1536
 
#define DC_ETHERNET_HEADER_SIZE   14
 
#define DC_TX_UNDERRUN_LIMIT   5
 
#define DC_INTERRUPT_PROCESSING_LIMIT   8
 
#define DC_FRAGMENTATION_THRESHOLD   32
 
#define DC_PACKET_FILTERS
 
#define DC_LOOPBACK_FRAME_SIZE   64
 
#define DC_TBD_RESERVE   (2 + DC_LOOPBACK_FRAMES) /* (+2 for setup frame) */
 
#define DC_TCB_RESERVE   (1 + DC_LOOPBACK_FRAMES) /* (+1 for setup frame) */
 
#define DC_EVENT_SETUP_FRAME_COMPLETED   0x00000001
 
#define DC_NEED_RX_OVERFLOW_WORKAROUND   0x80000000
 
#define DC_SIA_GPIO   0x00000001
 
#define DC_SIA_ANALOG_CONTROL   0x00000002
 
#define DC_HAS_POWER_MANAGEMENT   0x00000004
 
#define DC_HAS_POWER_SAVING   0x00000008
 
#define DC_HAS_MII   0x00000010
 
#define DC_PERFECT_FILTERING_ONLY   0x00000020
 
#define DC_ENABLE_PCI_COMMANDS   0x00000040
 
#define DC_MII_AUTOSENSE   0x00000080
 
#define DC_HAS_TIMER   0x00000100
 
#define DC_ACTIVE   0x80000000
 
#define DC_IO_MAPPED   0x00000001
 
#define DC_IRQ_SHARED   0x00000002
 
#define DC_FIRST_SETUP   0x00000004
 
#define DC_AUTOSENSE   0x00000008
 
#define DC_MODE_AUTONEG_MASK   0x0000000F
 
#define DC_MODE_PORT_AUTOSENSE   0x00000010
 
#define DC_MODE_TEST_PACKET   0x00000020
 
#define DC_MODE_AUI_FAILED   0x00000040
 
#define DC_MODE_BNC_FAILED   0x00000080
 
#define DC_MODE_AUTONEG_NONE   0x00000000
 
#define DC_MODE_AUTONEG_WAIT_INTERRUPT   0x00000001
 
#define DC_MODE_AUTONEG_LINK_STATUS_CHECK   0x00000002
 
#define DC_WRITE(Adapter, Register, Value)    NdisRawWritePortUlong((PULONG)((Adapter)->IoBase + (Register)), (Value));
 

Typedefs

typedef struct _DC21X4_ADAPTER DC21X4_ADAPTER
 
typedef struct _DC21X4_ADAPTERPDC21X4_ADAPTER
 
typedef struct _DC_TCB DC_TCB
 
typedef struct _DC_TCBPDC_TCB
 
typedef struct _DC_RCB DC_RCB
 
typedef struct _DC_RCBPDC_RCB
 
typedef struct _DC_COALESCE_BUFFER DC_COALESCE_BUFFER
 
typedef struct _DC_COALESCE_BUFFERPDC_COALESCE_BUFFER
 
typedef VOID() MEDIA_HANDLE_LINK_STATE_CHANGE(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG InterruptStatus)
 
typedef MEDIA_HANDLE_LINK_STATE_CHANGEPMEDIA_HANDLE_LINK_STATE_CHANGE
 
typedef struct _DC_TX_BUFFER_DATA DC_TX_BUFFER_DATA
 
typedef struct _DC_TX_BUFFER_DATAPDC_TX_BUFFER_DATA
 
typedef struct _DC_STATISTICS DC_STATISTICS
 
typedef struct _DC_STATISTICSPDC_STATISTICS
 

Functions

FORCEINLINE ULONG DC_READ (_In_ PDC21X4_ADAPTER Adapter, _In_ DC_CSR Register)
 
NDIS_STATUS NTAPI DcInitialize (_Out_ PNDIS_STATUS OpenErrorStatus, _Out_ PUINT SelectedMediumIndex, _In_ PNDIS_MEDIUM MediumArray, _In_ UINT MediumArraySize, _In_ NDIS_HANDLE MiniportAdapterHandle, _In_ NDIS_HANDLE WrapperConfigurationContext)
 
VOID NTAPI DcSendPackets (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PPNDIS_PACKET PacketArray, _In_ UINT NumberOfPackets)
 
VOID NTAPI DcCancelSendPackets (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PVOID CancelId)
 
VOID DcProcessPendingPackets (_In_ PDC21X4_ADAPTER Adapter)
 
VOID NTAPI DcReturnPacket (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet)
 
NDIS_STATUS NTAPI DcQueryInformation (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ NDIS_OID Oid, _In_ PVOID InformationBuffer, _In_ ULONG InformationBufferLength, _Out_ PULONG BytesWritten, _Out_ PULONG BytesNeeded)
 
NDIS_STATUS NTAPI DcSetInformation (_In_ NDIS_HANDLE MiniportAdapterContext, _In_ NDIS_OID Oid, _In_ PVOID InformationBuffer, _In_ ULONG InformationBufferLength, _Out_ PULONG BytesRead, _Out_ PULONG BytesNeeded)
 
VOID NTAPI DcIsr (_Out_ PBOOLEAN InterruptRecognized, _Out_ PBOOLEAN QueueMiniportHandleInterrupt, _In_ NDIS_HANDLE MiniportAdapterContext)
 
VOID NTAPI DcHandleInterrupt (_In_ NDIS_HANDLE MiniportAdapterContext)
 
VOID NTAPI DcPowerWorker (_In_ PNDIS_WORK_ITEM WorkItem, _In_opt_ PVOID Context)
 
NDIS_STATUS DcSetPower (_In_ PDC21X4_ADAPTER Adapter, _In_ NDIS_DEVICE_POWER_STATE PowerState)
 
NDIS_STATUS DcAddWakeUpPattern (_In_ PDC21X4_ADAPTER Adapter, _In_ PNDIS_PM_PACKET_PATTERN PmPattern)
 
NDIS_STATUS DcRemoveWakeUpPattern (_In_ PDC21X4_ADAPTER Adapter, _In_ PNDIS_PM_PACKET_PATTERN PmPattern)
 
VOID DcFreeAdapter (_In_ __drv_freesMem(Mem) PDC21X4_ADAPTER Adapter)
 
VOID NTAPI DcResetWorker (_In_ PNDIS_WORK_ITEM WorkItem, _In_opt_ PVOID Context)
 
DECLSPEC_NOINLINE VOID DcStopAdapter (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN WaitForPackets)
 
VOID DcStartAdapter (_In_ PDC21X4_ADAPTER Adapter)
 
NDIS_STATUS DcSetupAdapter (_In_ PDC21X4_ADAPTER Adapter)
 
NDIS_STATUS DcReadEeprom (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcFreeEeprom (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcInitTxRing (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcInitRxRing (_In_ PDC21X4_ADAPTER Adapter)
 
ULONG DcEthernetCrc (_In_reads_bytes_(Size) const VOID *Buffer, _In_ ULONG Size)
 
VOID DcDisableHw (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcStopTxRxProcess (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcWriteGpio (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Value)
 
VOID DcWriteSia (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Csr13, _In_ ULONG Csr14, _In_ ULONG Csr15)
 
VOID DcTestPacket (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcSetupFrameInitialize (_In_ PDC21X4_ADAPTER Adapter)
 
BOOLEAN DcSetupFrameDownload (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN WaitForCompletion)
 
NDIS_STATUS DcApplyPacketFilter (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PacketFilter)
 
NDIS_STATUS DcUpdateMulticastList (_In_ PDC21X4_ADAPTER Adapter)
 
VOID DcPowerSave (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN Enable)
 
BOOLEAN DcFindMiiPhy (_In_ PDC21X4_ADAPTER Adapter)
 
BOOLEAN MiiWrite (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _In_ ULONG Data)
 
BOOLEAN MiiRead (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _Out_ PULONG Data)
 
VOID HpnaPhyInit (_In_ PDC21X4_ADAPTER Adapter)
 
VOID NTAPI DcTransmitTimeoutRecoveryWorker (_In_ PNDIS_WORK_ITEM WorkItem, _In_opt_ PVOID Context)
 
VOID MediaInitMediaList (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaInitDefaultMedia (_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG MediaNumber)
 
VOID MediaIndicateConnect (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN LinkUp)
 
VOID MediaSelectMiiPort (_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN ResetPhy)
 
VOID MediaMiiSelect (_In_ PDC21X4_ADAPTER Adapter)
 
BOOLEAN MediaMiiCheckLink (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaSiaSelect (_In_ PDC21X4_ADAPTER Adapter)
 
VOID MediaGprSelect (_In_ PDC21X4_ADAPTER Adapter)
 

Variables

LIST_ENTRY SRompAdapterList
 
DRIVER_INITIALIZE DriverEntry
 
NDIS_TIMER_FUNCTION MediaMonitor21040Dpc
 
NDIS_TIMER_FUNCTION MediaMonitor21041Dpc
 
NDIS_TIMER_FUNCTION MediaMonitor21140Dpc
 
NDIS_TIMER_FUNCTION MediaMonitor21143Dpc
 
MEDIA_HANDLE_LINK_STATE_CHANGE MediaLinkStateChange21040
 
MEDIA_HANDLE_LINK_STATE_CHANGE MediaLinkStateChange21041
 
MEDIA_HANDLE_LINK_STATE_CHANGE MediaLinkStateChange21143
 

Macro Definition Documentation

◆ DC21X4_TAG

#define DC21X4_TAG   '4x12'

Definition at line 21 of file dc21x4.h.

◆ DC_ACTIVE

#define DC_ACTIVE   0x80000000

Definition at line 120 of file dc21x4.h.

◆ DC_AUTOSENSE

#define DC_AUTOSENSE   0x00000008

Definition at line 124 of file dc21x4.h.

◆ DC_ENABLE_PCI_COMMANDS

#define DC_ENABLE_PCI_COMMANDS   0x00000040

Definition at line 115 of file dc21x4.h.

◆ DC_ETHERNET_HEADER_SIZE

#define DC_ETHERNET_HEADER_SIZE   14

Definition at line 39 of file dc21x4.h.

◆ DC_EVENT_SETUP_FRAME_COMPLETED

#define DC_EVENT_SETUP_FRAME_COMPLETED   0x00000001

Definition at line 59 of file dc21x4.h.

◆ DC_FIRST_SETUP

#define DC_FIRST_SETUP   0x00000004

Definition at line 123 of file dc21x4.h.

◆ DC_FRAGMENTATION_THRESHOLD

#define DC_FRAGMENTATION_THRESHOLD   32

Definition at line 44 of file dc21x4.h.

◆ DC_HAS_MII

#define DC_HAS_MII   0x00000010

Definition at line 113 of file dc21x4.h.

◆ DC_HAS_POWER_MANAGEMENT

#define DC_HAS_POWER_MANAGEMENT   0x00000004

Definition at line 111 of file dc21x4.h.

◆ DC_HAS_POWER_SAVING

#define DC_HAS_POWER_SAVING   0x00000008

Definition at line 112 of file dc21x4.h.

◆ DC_HAS_TIMER

#define DC_HAS_TIMER   0x00000100

Definition at line 117 of file dc21x4.h.

◆ DC_INTERRUPT_PROCESSING_LIMIT

#define DC_INTERRUPT_PROCESSING_LIMIT   8

Definition at line 42 of file dc21x4.h.

◆ DC_IO_MAPPED

#define DC_IO_MAPPED   0x00000001

Definition at line 121 of file dc21x4.h.

◆ DC_IRQ_SHARED

#define DC_IRQ_SHARED   0x00000002

Definition at line 122 of file dc21x4.h.

◆ DC_LOOPBACK_FRAME_SIZE

#define DC_LOOPBACK_FRAME_SIZE   64

Definition at line 53 of file dc21x4.h.

◆ DC_LOOPBACK_FRAMES

#define DC_LOOPBACK_FRAMES   4

Definition at line 26 of file dc21x4.h.

◆ DC_MAXIMUM_FRAME_SIZE

#define DC_MAXIMUM_FRAME_SIZE   1514

Definition at line 36 of file dc21x4.h.

◆ DC_MII_AUTOSENSE

#define DC_MII_AUTOSENSE   0x00000080

Definition at line 116 of file dc21x4.h.

◆ DC_MODE_AUI_FAILED

#define DC_MODE_AUI_FAILED   0x00000040

Definition at line 166 of file dc21x4.h.

◆ DC_MODE_AUTONEG_LINK_STATUS_CHECK

#define DC_MODE_AUTONEG_LINK_STATUS_CHECK   0x00000002

Definition at line 171 of file dc21x4.h.

◆ DC_MODE_AUTONEG_MASK

#define DC_MODE_AUTONEG_MASK   0x0000000F

Definition at line 163 of file dc21x4.h.

◆ DC_MODE_AUTONEG_NONE

#define DC_MODE_AUTONEG_NONE   0x00000000

Definition at line 169 of file dc21x4.h.

◆ DC_MODE_AUTONEG_WAIT_INTERRUPT

#define DC_MODE_AUTONEG_WAIT_INTERRUPT   0x00000001

Definition at line 170 of file dc21x4.h.

◆ DC_MODE_BNC_FAILED

#define DC_MODE_BNC_FAILED   0x00000080

Definition at line 167 of file dc21x4.h.

◆ DC_MODE_PORT_AUTOSENSE

#define DC_MODE_PORT_AUTOSENSE   0x00000010

Definition at line 164 of file dc21x4.h.

◆ DC_MODE_TEST_PACKET

#define DC_MODE_TEST_PACKET   0x00000020

Definition at line 165 of file dc21x4.h.

◆ DC_MULTICAST_LIST_SIZE

#define DC_MULTICAST_LIST_SIZE   36

Definition at line 34 of file dc21x4.h.

◆ DC_NEED_RX_OVERFLOW_WORKAROUND

#define DC_NEED_RX_OVERFLOW_WORKAROUND   0x80000000

Definition at line 108 of file dc21x4.h.

◆ DC_PACKET_FILTERS

#define DC_PACKET_FILTERS
Value:
( \
#define NDIS_PACKET_TYPE_PROMISCUOUS
Definition: ndis.h:668
#define NDIS_PACKET_TYPE_BROADCAST
Definition: ndis.h:666
#define NDIS_PACKET_TYPE_MULTICAST
Definition: ndis.h:664
#define NDIS_PACKET_TYPE_DIRECTED
Definition: ndis.h:663
#define NDIS_PACKET_TYPE_ALL_MULTICAST
Definition: ndis.h:665

Definition at line 46 of file dc21x4.h.

◆ DC_PERFECT_FILTERING_ONLY

#define DC_PERFECT_FILTERING_ONLY   0x00000020

Definition at line 114 of file dc21x4.h.

◆ DC_RECEIVE_ARRAY_SIZE

#define DC_RECEIVE_ARRAY_SIZE   16

Definition at line 32 of file dc21x4.h.

◆ DC_RECEIVE_BLOCK_SIZE

#define DC_RECEIVE_BLOCK_SIZE   1536

Definition at line 38 of file dc21x4.h.

◆ DC_RECEIVE_BUFFERS_DEFAULT

#define DC_RECEIVE_BUFFERS_DEFAULT   64

Definition at line 28 of file dc21x4.h.

◆ DC_RECEIVE_BUFFERS_EXTRA

#define DC_RECEIVE_BUFFERS_EXTRA   16

Definition at line 30 of file dc21x4.h.

◆ DC_RECEIVE_BUFFERS_MIN

#define DC_RECEIVE_BUFFERS_MIN   8

Definition at line 29 of file dc21x4.h.

◆ DC_SIA_ANALOG_CONTROL

#define DC_SIA_ANALOG_CONTROL   0x00000002

Definition at line 110 of file dc21x4.h.

◆ DC_SIA_GPIO

#define DC_SIA_GPIO   0x00000001

Definition at line 109 of file dc21x4.h.

◆ DC_TBD_RESERVE

#define DC_TBD_RESERVE   (2 + DC_LOOPBACK_FRAMES) /* (+2 for setup frame) */

Definition at line 56 of file dc21x4.h.

◆ DC_TCB_RESERVE

#define DC_TCB_RESERVE   (1 + DC_LOOPBACK_FRAMES) /* (+1 for setup frame) */

Definition at line 57 of file dc21x4.h.

◆ DC_TRANSMIT_BLOCK_SIZE

#define DC_TRANSMIT_BLOCK_SIZE   1536

Definition at line 37 of file dc21x4.h.

◆ DC_TRANSMIT_BLOCKS

#define DC_TRANSMIT_BLOCKS   48

Definition at line 24 of file dc21x4.h.

◆ DC_TRANSMIT_BUFFERS

#define DC_TRANSMIT_BUFFERS   4

Definition at line 25 of file dc21x4.h.

◆ DC_TRANSMIT_DESCRIPTORS

#define DC_TRANSMIT_DESCRIPTORS   64

Definition at line 23 of file dc21x4.h.

◆ DC_TX_UNDERRUN_LIMIT

#define DC_TX_UNDERRUN_LIMIT   5

Definition at line 41 of file dc21x4.h.

◆ DC_WRITE

#define DC_WRITE (   Adapter,
  Register,
  Value 
)     NdisRawWritePortUlong((PULONG)((Adapter)->IoBase + (Register)), (Value));

Definition at line 272 of file dc21x4.h.

◆ NO_KERNEL_LIST_ENTRY_CHECKS

#define NO_KERNEL_LIST_ENTRY_CHECKS

Definition at line 11 of file dc21x4.h.

Typedef Documentation

◆ DC21X4_ADAPTER

Definition at line 61 of file dc21x4.h.

◆ DC_COALESCE_BUFFER

Definition at line 64 of file dc21x4.h.

◆ DC_RCB

Definition at line 63 of file dc21x4.h.

◆ DC_STATISTICS

◆ DC_TCB

Definition at line 62 of file dc21x4.h.

◆ DC_TX_BUFFER_DATA

◆ MEDIA_HANDLE_LINK_STATE_CHANGE

typedef VOID() MEDIA_HANDLE_LINK_STATE_CHANGE(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG InterruptStatus)

Definition at line 66 of file dc21x4.h.

◆ PDC21X4_ADAPTER

Definition at line 61 of file dc21x4.h.

◆ PDC_COALESCE_BUFFER

Definition at line 64 of file dc21x4.h.

◆ PDC_RCB

typedef struct _DC_RCB * PDC_RCB

Definition at line 63 of file dc21x4.h.

◆ PDC_STATISTICS

◆ PDC_TCB

typedef struct _DC_TCB * PDC_TCB

Definition at line 62 of file dc21x4.h.

◆ PDC_TX_BUFFER_DATA

◆ PMEDIA_HANDLE_LINK_STATE_CHANGE

Function Documentation

◆ DC_READ()

◆ DcAddWakeUpPattern()

NDIS_STATUS DcAddWakeUpPattern ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ PNDIS_PM_PACKET_PATTERN  PmPattern 
)

Definition at line 215 of file power.c.

218{
219 // TODO: Not implemented
220 ERR("FIXME: Not implemented\n");
222}
#define ERR(fmt,...)
Definition: debug.h:110
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479

Referenced by DcSetInformation().

◆ DcApplyPacketFilter()

NDIS_STATUS DcApplyPacketFilter ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  PacketFilter 
)

Definition at line 401 of file hardware.c.

404{
405 ULONG OpMode, OldPacketFilter;
406
407 INFO("Packet filter value 0x%lx\n", PacketFilter);
408
409 NdisAcquireSpinLock(&Adapter->ModeLock);
410
411 /* Update the filtering mode */
412 OpMode = Adapter->OpMode;
414 if (PacketFilter & NDIS_PACKET_TYPE_PROMISCUOUS)
415 {
416 OpMode |= DC_OPMODE_RX_PROMISCUOUS;
417 }
418 else if (PacketFilter & NDIS_PACKET_TYPE_ALL_MULTICAST)
419 {
421 }
422 Adapter->OpMode = OpMode;
423 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
424
425 NdisReleaseSpinLock(&Adapter->ModeLock);
426
427 OldPacketFilter = Adapter->PacketFilter;
428 Adapter->PacketFilter = PacketFilter;
429
430 /* Program the NIC to receive or reject broadcast frames */
431 if ((OldPacketFilter ^ PacketFilter) & NDIS_PACKET_TYPE_BROADCAST)
432 {
433 return DcUpdateMulticastList(Adapter);
434 }
435
436 return NDIS_STATUS_SUCCESS;
437}
#define DC_WRITE(Adapter, Register, Value)
Definition: dc21x4.h:272
#define DC_OPMODE_RX_PROMISCUOUS
Definition: dc21x4hw.h:324
@ DcCsr6_OpMode
Definition: dc21x4hw.h:180
#define DC_OPMODE_RX_ALL_MULTICAST
Definition: dc21x4hw.h:325
#define INFO
Definition: debug.h:89
NDIS_STATUS DcUpdateMulticastList(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:375
#define NdisReleaseSpinLock(_SpinLock)
Definition: ndis.h:4115
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NdisAcquireSpinLock(_SpinLock)
Definition: ndis.h:4106

Referenced by DcSetInformation().

◆ DcCancelSendPackets()

VOID NTAPI DcCancelSendPackets ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ PVOID  CancelId 
)

Definition at line 271 of file send.c.

274{
275 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
276 LIST_ENTRY DoneList;
277 PLIST_ENTRY Entry, NextEntry;
278
279 TRACE("Called\n");
280
281 InitializeListHead(&DoneList);
282
283 NdisAcquireSpinLock(&Adapter->SendLock);
284
285 NextEntry = Adapter->SendQueueList.Flink;
286 while (NextEntry != &Adapter->SendQueueList)
287 {
289
290 Entry = NextEntry;
291 NextEntry = NextEntry->Flink;
292
294
296 {
298
300 }
301 }
302
303 NdisReleaseSpinLock(&Adapter->SendLock);
304
305 while (!IsListEmpty(&DoneList))
306 {
307 Entry = RemoveHeadList(&DoneList);
308
312 }
313}
struct _DC21X4_ADAPTER * PDC21X4_ADAPTER
Definition: dc21x4.h:61
LONG CancelId
Definition: main.c:23
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
#define NDIS_STATUS_REQUEST_ABORTED
Definition: ndis.h:476
#define NDIS_GET_PACKET_CANCEL_ID(Packet)
Definition: ndis.h:1333
#define NdisMSendComplete(MiniportAdapterHandle, Packet, Status)
Definition: ndis.h:5689
#define DC_PACKET_FROM_LIST_ENTRY(ListEntry)
Definition: sendrcv.h:13
#define DC_LIST_ENTRY_FROM_PACKET(Packet)
Definition: sendrcv.h:10
#define TRACE(s)
Definition: solgame.cpp:4
base of all file and directory entries
Definition: entries.h:83
NDIS_HANDLE AdapterHandle
Definition: dc21x4.h:158
LIST_ENTRY SendQueueList
Definition: dc21x4.h:136
DECLSPEC_CACHEALIGN NDIS_SPIN_LOCK SendLock
Definition: dc21x4.h:129
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121

Referenced by DriverEntry().

◆ DcDisableHw()

VOID DcDisableHw ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 17 of file hardware.c.

19{
20 ULONG OpMode;
21
22 /* Disable interrupts */
23 DC_WRITE(Adapter, DcCsr7_IrqMask, 0);
24
25 /* Stop DMA */
26 OpMode = Adapter->OpMode;
28 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
29
30 /* Put the adapter to snooze mode */
31 DcPowerSave(Adapter, TRUE);
32
33 /* Perform a software reset */
35}
VOID DcPowerSave(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN Enable)
Definition: power.c:225
#define DC_OPMODE_TX_ENABLE
Definition: dc21x4hw.h:330
@ DcCsr0_BusMode
Definition: dc21x4hw.h:172
@ DcCsr7_IrqMask
Definition: dc21x4hw.h:181
#define DC_BUS_MODE_SOFT_RESET
Definition: dc21x4hw.h:197
#define DC_OPMODE_RX_ENABLE
Definition: dc21x4hw.h:319
#define TRUE
Definition: types.h:120

Referenced by DcHalt(), DcInitialize(), and DcShutdown().

◆ DcEthernetCrc()

ULONG DcEthernetCrc ( _In_reads_bytes_(Size) const VOID Buffer,
_In_ ULONG  Size 
)

Definition at line 17 of file dc21x4.c.

20{
21 ULONG i, j, Crc;
22 const UCHAR* Data = Buffer;
23
24 Crc = 0xFFFFFFFF;
25 for (i = 0; i < Size; ++i)
26 {
27 Crc ^= Data[i];
28 for (j = 8; j > 0; j--)
29 {
30 /* CRC-32 polynomial little-endian */
31 Crc = (Crc >> 1) ^ (-(LONG)(Crc & 1) & 0xEDB88320);
32 }
33 }
34
35 return Crc;
36}
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
long LONG
Definition: pedump.c:60
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DcSetupFrameImperfectFiltering().

◆ DcFindMiiPhy()

BOOLEAN DcFindMiiPhy ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 217 of file phy.c.

219{
220 ULONG Phy;
221
222 PAGED_CODE();
223
224 /* Look for the first connected PHY */
225 for (Phy = 1; Phy <= MII_MAX_PHY_ADDRESSES; ++Phy)
226 {
227 ULONG PhyAddress = Phy % MII_MAX_PHY_ADDRESSES; /* Check the PHY 0 last */
228 ULONG MiiStatus;
229#if DBG
230 ULONG PhyIdLow, PhyIdHigh, MiiControl, MiiAdvertise;
231#endif
232
233 /*
234 * Read the status register. Some PHYs, such as the ML6692,
235 * don't implement the IEEE ID registers.
236 */
237 if (!MiiRead(Adapter, PhyAddress, MII_STATUS, &MiiStatus))
238 continue;
239 if (MiiStatus == 0xFFFF || MiiStatus == 0)
240 continue;
241
242#if DBG
243 MiiRead(Adapter, PhyAddress, MII_PHY_ID1, &PhyIdLow);
244 MiiRead(Adapter, PhyAddress, MII_PHY_ID2, &PhyIdHigh);
245 MiiRead(Adapter, PhyAddress, MII_CONTROL, &MiiControl);
246 MiiRead(Adapter, PhyAddress, MII_AUTONEG_ADVERTISE, &MiiAdvertise);
247
248 INFO_VERB("Found PHY at address %u: ID %04lx:%04lx, Ctrl %04lx, Status %04lx, Adv %04lx\n",
249 PhyAddress,
250 PhyIdLow,
251 PhyIdHigh,
252 MiiControl,
253 MiiStatus,
254 MiiAdvertise);
255#endif
256
257 Adapter->PhyAddress = PhyAddress;
258
259 return TRUE;
260 }
261
262 return FALSE;
263}
#define PAGED_CODE()
BOOLEAN MiiRead(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _Out_ PULONG Data)
Definition: phy.c:101
#define MII_STATUS
Definition: dc21x4hw.h:566
#define MII_PHY_ID2
Definition: dc21x4hw.h:570
#define MII_MAX_PHY_ADDRESSES
Definition: dc21x4hw.h:551
#define MII_AUTONEG_ADVERTISE
Definition: dc21x4hw.h:571
#define MII_PHY_ID1
Definition: dc21x4hw.h:569
#define MII_CONTROL
Definition: dc21x4hw.h:556
#define FALSE
Definition: types.h:117
#define INFO_VERB
Definition: debug.h:90

Referenced by DcInitialize().

◆ DcFreeAdapter()

VOID DcFreeAdapter ( _In_ __drv_freesMem(Mem) PDC21X4_ADAPTER  Adapter)

Definition at line 1022 of file init.c.

1024{
1025 ULONG i;
1026
1027 PAGED_CODE();
1028
1029 DcFreeEeprom(Adapter);
1030
1031 if (Adapter->Interrupt.InterruptObject)
1032 {
1033 NdisMDeregisterInterrupt(&Adapter->Interrupt);
1034 }
1035
1036 if (Adapter->IoBase)
1037 {
1038 if (Adapter->Flags & DC_IO_MAPPED)
1039 {
1040 NdisMUnmapIoSpace(Adapter->AdapterHandle,
1041 Adapter->IoBase,
1042 DC_IO_LENGTH);
1043 }
1044 else
1045 {
1046 NdisMDeregisterIoPortRange(Adapter->AdapterHandle,
1047 Adapter->IoBaseAddress.LowPart,
1049 Adapter->IoBase);
1050 }
1051 }
1052
1053 if (Adapter->HeadTcb)
1054 {
1055 NdisFreeMemory(Adapter->HeadTcb, sizeof(DC_TCB) * DC_TRANSMIT_BLOCKS, 0);
1056 }
1057 if (Adapter->RcbArray)
1058 {
1059 NdisFreeMemory(Adapter->RcbArray, sizeof(PVOID) * Adapter->RcbCount, 0);
1060 }
1061 if (Adapter->SetupFrameSaved)
1062 {
1063 NdisFreeMemory(Adapter->SetupFrameSaved, DC_SETUP_FRAME_SIZE, 0);
1064 }
1065
1066 while (Adapter->AllocRcbList.Next)
1067 {
1068 PSINGLE_LIST_ENTRY Entry = PopEntryList(&Adapter->AllocRcbList);
1069 PDC_RCB Rcb = CONTAINING_RECORD(Entry, DC_RCB, AllocListEntry);
1070
1071 DcFreeRcb(Adapter, Rcb);
1072 }
1073
1074 if (Adapter->RbdOriginal)
1075 {
1076 NdisMFreeSharedMemory(Adapter->AdapterHandle,
1078 FALSE, /* Non-cached */
1079 Adapter->RbdOriginal,
1080 Adapter->RbdPhysOriginal);
1081 }
1082 if (Adapter->TbdOriginal)
1083 {
1084 NdisMFreeSharedMemory(Adapter->AdapterHandle,
1086 FALSE, /* Non-cached */
1087 Adapter->TbdOriginal,
1088 Adapter->TbdPhysOriginal);
1089 }
1090 if (Adapter->CoalesceBuffer)
1091 {
1092 for (i = 0; i < DC_TRANSMIT_BUFFERS; ++i)
1093 {
1094 PDC_TX_BUFFER_DATA SendBufferData = &Adapter->SendBufferData[i];
1095
1096 if (!SendBufferData->VirtualAddress)
1097 continue;
1098
1099 NdisMFreeSharedMemory(Adapter->AdapterHandle,
1101 FALSE, /* Non-cached */
1102 SendBufferData->VirtualAddress,
1103 SendBufferData->PhysicalAddress);
1104 }
1105 }
1106
1107 if (Adapter->PacketPool)
1108 NdisFreePacketPool(Adapter->PacketPool);
1109 if (Adapter->BufferPool)
1110 NdisFreeBufferPool(Adapter->BufferPool);
1111
1112 if (Adapter->SendLock.SpinLock)
1113 NdisFreeSpinLock(&Adapter->SendLock);
1114 if (Adapter->ReceiveLock.SpinLock)
1115 NdisFreeSpinLock(&Adapter->ReceiveLock);
1116 if (Adapter->ModeLock.SpinLock)
1117 NdisFreeSpinLock(&Adapter->ModeLock);
1118
1119 NdisFreeMemory(Adapter->AdapterOriginal, sizeof(*Adapter), 0);
1120}
#define DC_IO_MAPPED
Definition: dc21x4.h:121
#define DC_TRANSMIT_BUFFERS
Definition: dc21x4.h:25
#define DC_TRANSMIT_BLOCKS
Definition: dc21x4.h:24
VOID DcFreeEeprom(_In_ PDC21X4_ADAPTER Adapter)
Definition: eeprom.c:1444
#define DC_IO_LENGTH
Definition: dc21x4hw.h:33
#define DC_SETUP_FRAME_SIZE
Definition: dc21x4hw.h:35
#define DC_MEM_BLOCK_SIZE_TX_BUFFER
Definition: init.c:39
static VOID DcFreeRcb(_In_ PDC21X4_ADAPTER Adapter, _In_ __drv_freesMem(Mem) PDC_RCB Rcb)
Definition: init.c:154
#define DC_MEM_BLOCK_SIZE_RBD
Definition: init.c:31
#define DC_MEM_BLOCK_SIZE_TBD_AUX
Definition: init.c:34
VOID EXPORT NdisFreeBufferPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:777
VOID EXPORT NdisFreePacketPool(IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:793
VOID EXPORT NdisMDeregisterInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt)
Definition: io.c:700
VOID EXPORT NdisMDeregisterIoPortRange(IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts, IN PVOID PortOffset)
Definition: io.c:1093
VOID EXPORT NdisMUnmapIoSpace(IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID VirtualAddress, IN UINT Length)
Definition: io.c:1139
VOID EXPORT NdisFreeMemory(IN PVOID VirtualAddress, IN UINT Length, IN UINT MemoryFlags)
Definition: memory.c:110
VOID EXPORT NdisMFreeSharedMemory(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, IN BOOLEAN Cached, IN PVOID VirtualAddress, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress)
Definition: memory.c:215
#define NdisFreeSpinLock(_SpinLock)
Definition: ndis.h:4097
PVOID VirtualAddress
Definition: dc21x4.h:74
NDIS_PHYSICAL_ADDRESS PhysicalAddress
Definition: dc21x4.h:75
Definition: ntbasedef.h:628
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240

Referenced by DcHalt(), and DcInitialize().

◆ DcFreeEeprom()

VOID DcFreeEeprom ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 1444 of file eeprom.c.

1446{
1447 PDC_SROM_ENTRY SRomEntry;
1448
1449 PAGED_CODE();
1450
1451 SRomEntry = Adapter->SRomEntry;
1452 if (!SRomEntry)
1453 return;
1454
1456
1457 /* Unregister the port */
1458 SRomEntry->DeviceBitmap &= ~(1 << Adapter->DeviceNumber);
1459
1460 /*
1461 * Free the SROM as soon as the last registered port has removed.
1462 * We can't free it in an unload handler
1463 * as the bus numbers can be changed by a resource rebalance.
1464 */
1465 if (SRomEntry->DeviceBitmap == 0)
1466 {
1467 INFO("Freeing SROM %p at %u:%u\n",
1468 SRomEntry,
1469 SRomEntry->BusNumber,
1470 SRomEntry->DeviceNumber);
1471
1472 RemoveEntryList(&SRomEntry->ListEntry);
1473
1474 NdisFreeMemory(SRomEntry, 0, 0);
1475 }
1476
1478}
static VOID SRomAcquireListMutex(VOID)
Definition: eeprom.c:40
static VOID SRomReleaseListMutex(VOID)
Definition: eeprom.c:53
Definition: eeprom.h:29
UCHAR DeviceNumber
Definition: eeprom.h:33
LIST_ENTRY ListEntry
Definition: eeprom.h:30
ULONG BusNumber
Definition: eeprom.h:31
ULONG DeviceBitmap
Definition: eeprom.h:36

Referenced by DcFreeAdapter().

◆ DcHandleInterrupt()

VOID NTAPI DcHandleInterrupt ( _In_ NDIS_HANDLE  MiniportAdapterContext)

Definition at line 514 of file interrupt.c.

516{
517 ULONG InterruptStatus, IoLimit;
518 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
519
520 TRACE("Events %08lx\n", Adapter->InterruptStatus);
521
522 if (!(Adapter->Flags & DC_ACTIVE))
523 return;
524
526 InterruptStatus = Adapter->InterruptStatus;
527
528 /* Loop until the condition to stop is encountered */
529 while (TRUE)
530 {
531 /* Uncommon interrupts */
532 if (InterruptStatus & DC_IRQ_ABNORMAL_SUMMARY)
533 {
534 /* PCI bus error detected */
535 if (InterruptStatus & DC_IRQ_SYSTEM_ERROR)
536 {
537 DcHandleSystemError(Adapter, InterruptStatus);
538 return;
539 }
540
541 /* Transmit jabber timeout */
542 if (InterruptStatus & DC_IRQ_TX_JABBER_TIMEOUT)
543 {
545 }
546
547 /* Link state changed */
548 if (InterruptStatus & Adapter->LinkStateChangeMask)
549 {
550 Adapter->HandleLinkStateChange(Adapter, InterruptStatus);
551 }
552 }
553
554 /* Handling receive interrupts */
555 if (InterruptStatus & (DC_IRQ_RX_OK | DC_IRQ_RX_STOPPED))
556 {
557 DcHandleRx(Adapter);
558 }
559
560 /* Handling transmit interrupts */
561 if (InterruptStatus & (DC_IRQ_TX_OK | DC_IRQ_TX_STOPPED))
562 {
563 DcHandleTx(Adapter);
564 }
565
566 /* Transmit underflow error detected */
567 if (InterruptStatus & DC_IRQ_TX_UNDERFLOW)
568 {
570 }
571
572 /* Limit in order to avoid doing too much work at DPC level */
573 if (!--IoLimit)
574 break;
575
576 /* Check if new events have occurred */
577 InterruptStatus = DC_READ(Adapter, DcCsr5_Status);
578 if (InterruptStatus == 0xFFFFFFFF || !(InterruptStatus & Adapter->InterruptMask))
579 break;
580
581 /* Acknowledge the events */
582 DC_WRITE(Adapter, DcCsr5_Status, InterruptStatus);
583 }
584
585 /* TODO: Add interrupt mitigation (CSR11) */
586
587 /* Reenable interrupts */
589 DC_WRITE(Adapter, DcCsr7_IrqMask, Adapter->InterruptMask);
590}
#define DC_INTERRUPT_PROCESSING_LIMIT
Definition: dc21x4.h:42
#define DC_ACTIVE
Definition: dc21x4.h:120
FORCEINLINE ULONG DC_READ(_In_ PDC21X4_ADAPTER Adapter, _In_ DC_CSR Register)
Definition: dc21x4.h:262
#define DC_IRQ_RX_OK
Definition: dc21x4hw.h:273
@ DcCsr5_Status
Definition: dc21x4hw.h:179
#define DC_IRQ_TX_OK
Definition: dc21x4hw.h:267
#define DC_IRQ_ABNORMAL_SUMMARY
Definition: dc21x4hw.h:284
#define DC_IRQ_TX_STOPPED
Definition: dc21x4hw.h:268
#define DC_IRQ_RX_STOPPED
Definition: dc21x4hw.h:275
#define DC_IRQ_TX_JABBER_TIMEOUT
Definition: dc21x4hw.h:270
#define DC_IRQ_TX_UNDERFLOW
Definition: dc21x4hw.h:272
#define DC_IRQ_SYSTEM_ERROR
Definition: dc21x4hw.h:282
static VOID DcHandleRx(_In_ PDC21X4_ADAPTER Adapter)
Definition: interrupt.c:481
static VOID DcHandleTxJabberTimeout(_In_ PDC21X4_ADAPTER Adapter)
Definition: interrupt.c:69
static VOID DcHandleSystemError(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG InterruptStatus)
Definition: interrupt.c:497
static VOID DcAdjustTxFifoThreshold(_In_ PDC21X4_ADAPTER Adapter)
Definition: interrupt.c:18
static VOID DcHandleTx(_In_ PDC21X4_ADAPTER Adapter)
Definition: interrupt.c:174
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
ULONG InterruptStatus
Definition: dc21x4.h:126
ULONG CurrentInterruptMask
Definition: dc21x4.h:105
PMEDIA_HANDLE_LINK_STATE_CHANGE HandleLinkStateChange
Definition: dc21x4.h:127
ULONG InterruptMask
Definition: dc21x4.h:104
ULONG LinkStateChangeMask
Definition: dc21x4.h:190
ULONG Flags
Definition: dc21x4.h:119
int32_t * PLONG
Definition: typedefs.h:58

Referenced by DriverEntry().

◆ DcInitialize()

NDIS_STATUS NTAPI DcInitialize ( _Out_ PNDIS_STATUS  OpenErrorStatus,
_Out_ PUINT  SelectedMediumIndex,
_In_ PNDIS_MEDIUM  MediumArray,
_In_ UINT  MediumArraySize,
_In_ NDIS_HANDLE  MiniportAdapterHandle,
_In_ NDIS_HANDLE  WrapperConfigurationContext 
)

Definition at line 1125 of file init.c.

1132{
1133 PDC21X4_ADAPTER Adapter;
1134 PVOID UnalignedAdapter;
1136 ULONG Alignment, AdapterSize, OpMode;
1138 UINT i;
1139
1140 INFO("Called\n");
1141
1142 PAGED_CODE();
1143
1144 for (i = 0; i < MediumArraySize; ++i)
1145 {
1146 if (MediumArray[i] == NdisMedium802_3)
1147 {
1149 break;
1150 }
1151 }
1152 if (i == MediumArraySize)
1153 {
1154 ERR("No supported media\n");
1156 }
1157
1159 AdapterSize = sizeof(*Adapter) + Alignment;
1160
1161 Status = NdisAllocateMemoryWithTag((PVOID*)&UnalignedAdapter, AdapterSize, DC21X4_TAG);
1163 {
1164 ERR("Failed to allocate adapter context\n");
1165 return NDIS_STATUS_RESOURCES;
1166 }
1167 NdisZeroMemory(UnalignedAdapter, AdapterSize);
1168
1169 Adapter = ALIGN_UP_POINTER_BY(UnalignedAdapter, Alignment);
1170 Adapter->AdapterOriginal = UnalignedAdapter;
1171 Adapter->AdapterSize = AdapterSize;
1174
1178
1180 Adapter,
1181 2, /* CheckForHangTimeInSeconds */
1186
1187 Status = DcRecognizeHardware(Adapter);
1189 {
1190 return Status;
1191 }
1192
1195 {
1196 goto Failure;
1197 }
1198
1201 {
1202 goto Failure;
1203 }
1204
1205 /* Bring the chip out of sleep mode */
1206 DcPowerSave(Adapter, FALSE);
1207
1208 OpMode = DC_READ(Adapter, DcCsr6_OpMode);
1210 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
1211
1212 MediaInitMediaList(Adapter);
1213
1214 Status = DcReadEeprom(Adapter);
1216 {
1217 goto Failure;
1218 }
1219
1221
1222 Status = DcReadConfiguration(Adapter);
1224 {
1225 goto Failure;
1226 }
1227
1228 Status = DcAllocateMemory(Adapter);
1230 {
1231 goto Failure;
1232 }
1233
1234 DcInitTestPacket(Adapter);
1235
1236 DcCreateRxRing(Adapter);
1237
1238 /* Execute the reset sequence */
1239 if (Adapter->ResetStreamLength)
1240 {
1241 for (i = 0; i < Adapter->ResetStreamLength; ++i)
1242 {
1243 DcWriteGpio(Adapter, Adapter->ResetStream[i]);
1244 NdisMSleep(100);
1245 }
1246
1247 /* Give the PHY some time to reset */
1248 NdisMSleep(5000);
1249 }
1250
1251 /* Perform a software reset */
1253 NdisMSleep(100);
1254 DC_WRITE(Adapter, DcCsr0_BusMode, Adapter->BusMode);
1255
1256 /* Try to detect a MII PHY */
1257 if (Adapter->Features & DC_HAS_MII)
1258 {
1259 MediaSelectMiiPort(Adapter, TRUE);
1260
1261 Success = DcFindMiiPhy(Adapter);
1262 if (Success)
1263 {
1264 /* Disable all link interrupts when the MII PHY media is found */
1266 Adapter->LinkStateChangeMask = 0;
1267 }
1268 else
1269 {
1270 /* Incorrect EEPROM table or PHY is not connected, switch to a serial transceiver */
1271 WARN("No PHY devices found\n");
1272 Adapter->Features &= ~DC_HAS_MII;
1273 }
1274 }
1275
1276 MediaInitDefaultMedia(Adapter, Adapter->DefaultMedia);
1277
1278 /* Set the MAC address */
1279 DcSetupFrameInitialize(Adapter);
1280
1281 /* Clear statistics */
1282 DC_READ(Adapter, DcCsr8_RxCounters);
1283
1284 Adapter->Flags |= DC_FIRST_SETUP;
1285
1286 Status = DcSetupAdapter(Adapter);
1288 {
1289 ERR("Failed to initialize the NIC\n");
1290 goto Disable;
1291 }
1292
1293 Adapter->Flags &= ~DC_FIRST_SETUP;
1294
1296 Adapter->AdapterHandle,
1297 Adapter->InterruptVector,
1298 Adapter->InterruptLevel,
1299 TRUE, /* Request ISR calls */
1300 !!(Adapter->Flags & DC_IRQ_SHARED),
1304 {
1305 ERR("Unable to register interrupt\n");
1306 goto Disable;
1307 }
1308
1309 DcStartAdapter(Adapter);
1310
1311 return NDIS_STATUS_SUCCESS;
1312
1313Disable:
1314 DcDisableHw(Adapter);
1315Failure:
1316 ERR("Initialization failed with status %08lx\n", Status);
1317
1318 DcFreeAdapter(Adapter);
1319
1320 return Status;
1321}
unsigned char BOOLEAN
#define WARN(fmt,...)
Definition: debug.h:112
VOID DcStartAdapter(_In_ PDC21X4_ADAPTER Adapter)
Definition: dc21x4.c:168
VOID NTAPI DcTransmitTimeoutRecoveryWorker(_In_ PNDIS_WORK_ITEM WorkItem, _In_opt_ PVOID Context)
Definition: dc21x4.c:247
VOID NTAPI DcResetWorker(_In_ PNDIS_WORK_ITEM WorkItem, _In_opt_ PVOID Context)
Definition: dc21x4.c:190
VOID DcWriteGpio(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Value)
Definition: hardware.c:64
NDIS_STATUS DcSetupAdapter(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:462
VOID MediaSelectMiiPort(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN ResetPhy)
Definition: media.c:215
VOID DcDisableHw(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:17
#define DC21X4_TAG
Definition: dc21x4.h:21
VOID NTAPI DcPowerWorker(_In_ PNDIS_WORK_ITEM WorkItem, _In_opt_ PVOID Context)
Definition: power.c:167
VOID DcSetupFrameInitialize(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:260
#define DC_FIRST_SETUP
Definition: dc21x4.h:123
VOID MediaInitMediaList(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:545
#define DC_IRQ_SHARED
Definition: dc21x4.h:122
#define DC_HAS_MII
Definition: dc21x4.h:113
VOID MediaInitDefaultMedia(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG MediaNumber)
Definition: media.c:325
NDIS_STATUS DcReadEeprom(_In_ PDC21X4_ADAPTER Adapter)
Definition: eeprom.c:1482
BOOLEAN DcFindMiiPhy(_In_ PDC21X4_ADAPTER Adapter)
Definition: phy.c:217
#define DC_IRQ_LINK_CHANGED
Definition: dc21x4hw.h:290
@ DcCsr8_RxCounters
Definition: dc21x4hw.h:182
#define DC_IRQ_LINK_PASS
Definition: dc21x4hw.h:271
#define DC_IRQ_LINK_FAIL
Definition: dc21x4hw.h:281
static VOID DcInitTestPacket(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:644
static NDIS_STATUS DcRecognizeHardware(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:874
static NDIS_STATUS DcReadConfiguration(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:93
static NDIS_STATUS DcInitializeAdapterResources(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:674
VOID DcFreeAdapter(_In_ __drv_freesMem(Mem) PDC21X4_ADAPTER Adapter)
Definition: init.c:1022
static NDIS_STATUS DcInitializeAdapterLocation(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:783
static VOID DcCreateRxRing(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:530
static NDIS_STATUS DcAllocateMemory(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:601
NDIS_STATUS EXPORT NdisMRegisterInterrupt(OUT PNDIS_MINIPORT_INTERRUPT Interrupt, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InterruptVector, IN UINT InterruptLevel, IN BOOLEAN RequestIsr, IN BOOLEAN SharedInterrupt, IN NDIS_INTERRUPT_MODE InterruptMode)
Definition: io.c:941
NDIS_STATUS EXPORT NdisAllocateMemoryWithTag(OUT PVOID *VirtualAddress, IN UINT Length, IN ULONG Tag)
Definition: memory.c:21
ULONG EXPORT NdisGetSharedDataAlignment(VOID)
Definition: misc.c:502
#define ETH_LENGTH_OF_ADDRESS
Definition: efilter.h:16
@ Success
Definition: eventcreate.c:712
union Alignment_ Alignment
Status
Definition: gdiplustypes.h:25
#define NdisInterruptLatched
Definition: ndis.h:921
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
#define NdisInitializeWorkItem(_WI_, _R_, _C_)
Definition: ndis.h:3197
unsigned int UINT
Definition: ndis.h:50
#define NDIS_ATTRIBUTE_BUS_MASTER
Definition: ndis.h:586
#define NdisInterruptLevelSensitive
Definition: ndis.h:920
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:6011
#define NDIS_ATTRIBUTE_DESERIALIZE
Definition: ndis.h:588
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT MediumArraySize
Definition: ndis.h:6013
@ NdisInterfacePci
Definition: ndis.h:905
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _In_ NDIS_HANDLE WrapperConfigurationContext
Definition: ndis.h:3946
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
#define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS
Definition: ndis.h:592
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
VOID EXPORT NdisMSetAttributesEx(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN UINT CheckForHangTimeInSeconds OPTIONAL, IN ULONG AttributeFlags, IN NDIS_INTERFACE_TYPE AdapterType)
Definition: miniport.c:2883
VOID EXPORT NdisMSleep(IN ULONG MicrosecondsToSleep)
Definition: miniport.c:2928
@ NdisMedium802_3
Definition: ntddndis.h:188
int NDIS_STATUS
Definition: ntddndis.h:475
UCHAR CurrentMacAddress[ETH_LENGTH_OF_ADDRESS]
Definition: dc21x4.h:200
NDIS_HANDLE WrapperConfigurationHandle
Definition: dc21x4.h:159
ULONG AdapterSize
Definition: dc21x4.h:235
UCHAR ResetStreamLength
Definition: dc21x4.h:226
PVOID AdapterOriginal
Definition: dc21x4.h:242
UCHAR PermanentMacAddress[ETH_LENGTH_OF_ADDRESS]
Definition: dc21x4.h:199
ULONG InterruptLevel
Definition: dc21x4.h:233
ULONG InterruptFlags
Definition: dc21x4.h:234
USHORT ResetStream[SROM_MAX_STREAM_REGS]
Definition: dc21x4.h:227
NDIS_WORK_ITEM ResetWorkItem
Definition: dc21x4.h:237
ULONG Features
Definition: dc21x4.h:107
ULONG DefaultMedia
Definition: dc21x4.h:212
NDIS_MINIPORT_INTERRUPT Interrupt
Definition: dc21x4.h:231
ULONG InterruptVector
Definition: dc21x4.h:232
ULONG BusMode
Definition: dc21x4.h:211
NDIS_WORK_ITEM PowerWorkItem
Definition: dc21x4.h:236
NDIS_WORK_ITEM TxRecoveryWorkItem
Definition: dc21x4.h:238
#define ALIGN_UP_POINTER_BY(ptr, align)
Definition: umtypes.h:85

Referenced by DriverEntry().

◆ DcInitRxRing()

VOID DcInitRxRing ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 574 of file init.c.

576{
577 PDC_RBD Rbd;
578 ULONG i;
579
580 PAGED_CODE();
581
582 Rbd = Adapter->HeadRbd;
583 Adapter->CurrentRbd = Rbd;
584
585 for (i = 0; i < Adapter->RcbCount; ++i)
586 {
589
590 ++Rbd;
591 }
592 Rbd = Rbd - 1;
594
595 ASSERT(Rbd == Adapter->TailRbd);
596}
#define DC_RBD_CONTROL_CHAINED
Definition: dc21x4hw.h:131
#define DC_RBD_STATUS_OWNED
Definition: dc21x4hw.h:124
#define DC_RECEIVE_BUFFER_SIZE
Definition: init.c:25
#define ASSERT(a)
Definition: mode.c:44
ULONG Control
Definition: dc21x4hw.h:128
ULONG Status
Definition: dc21x4hw.h:106

Referenced by DcSetupAdapter().

◆ DcInitTxRing()

VOID DcInitTxRing ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 499 of file init.c.

501{
502 PDC_TCB Tcb;
503 PDC_TBD Tbd;
504
505 PAGED_CODE();
506
507 InitializeListHead(&Adapter->SendQueueList);
508
509 Tcb = Adapter->HeadTcb;
510
511 Adapter->CurrentTcb = Tcb;
512 Adapter->LastTcb = Tcb;
513
514 Adapter->TcbSlots = DC_TRANSMIT_BLOCKS - DC_TCB_RESERVE;
515 Adapter->TbdSlots = DC_TRANSMIT_DESCRIPTORS - DC_TBD_RESERVE;
516 Adapter->LoopbackFrameSlots = DC_LOOPBACK_FRAMES;
517 Adapter->TcbCompleted = 0;
518
519 Tbd = Adapter->HeadTbd;
520 Adapter->CurrentTbd = Tbd;
521
522 NdisZeroMemory(Tbd, sizeof(*Tbd) * DC_TRANSMIT_DESCRIPTORS);
523
524 Adapter->TailTbd->Control |= DC_TBD_CONTROL_END_OF_RING;
525}
#define DC_LOOPBACK_FRAMES
Definition: dc21x4.h:26
#define DC_TCB_RESERVE
Definition: dc21x4.h:57
#define DC_TRANSMIT_DESCRIPTORS
Definition: dc21x4.h:23
#define DC_TBD_RESERVE
Definition: dc21x4.h:56
#define DC_TBD_CONTROL_END_OF_RING
Definition: dc21x4hw.h:82

Referenced by DcSetupAdapter().

◆ DcIsr()

VOID NTAPI DcIsr ( _Out_ PBOOLEAN  InterruptRecognized,
_Out_ PBOOLEAN  QueueMiniportHandleInterrupt,
_In_ NDIS_HANDLE  MiniportAdapterContext 
)

Definition at line 594 of file interrupt.c.

598{
599 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
600 ULONG InterruptStatus;
601
602 if (Adapter->CurrentInterruptMask == 0)
603 goto NotOurs;
604
605 InterruptStatus = DC_READ(Adapter, DcCsr5_Status);
606 if (InterruptStatus == 0xFFFFFFFF || !(InterruptStatus & Adapter->CurrentInterruptMask))
607 goto NotOurs;
608
609 /* Disable further interrupts */
610 DC_WRITE(Adapter, DcCsr7_IrqMask, 0);
611
612 /* Clear all pending events */
613 DC_WRITE(Adapter, DcCsr5_Status, InterruptStatus);
614
615 Adapter->InterruptStatus = InterruptStatus;
616 Adapter->CurrentInterruptMask = 0;
617
618 *InterruptRecognized = TRUE;
619 *QueueMiniportHandleInterrupt = TRUE;
620 return;
621
622NotOurs:
623 *InterruptRecognized = FALSE;
624 *QueueMiniportHandleInterrupt = FALSE;
625}

Referenced by DriverEntry().

◆ DcPowerSave()

VOID DcPowerSave ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  Enable 
)

Definition at line 225 of file power.c.

228{
229 ULONG ConfigValue;
230
231 if (!(Adapter->Features & DC_HAS_POWER_SAVING))
232 return;
233
234 NdisReadPciSlotInformation(Adapter->AdapterHandle,
235 0,
237 &ConfigValue,
238 sizeof(ConfigValue));
239
240 ConfigValue &= ~DC_PCI_DEVICE_CONFIG_SLEEP;
241
242 if (Enable)
243 ConfigValue |= DC_PCI_DEVICE_CONFIG_SNOOZE;
244 else
245 ConfigValue &= ~DC_PCI_DEVICE_CONFIG_SNOOZE;
246
247 NdisWritePciSlotInformation(Adapter->AdapterHandle,
248 0,
250 &ConfigValue,
251 sizeof(ConfigValue));
252}
#define DC_HAS_POWER_SAVING
Definition: dc21x4.h:112
#define DC_PCI_DEVICE_CONFIG
Definition: dc21x4hw.h:520
#define DC_PCI_DEVICE_CONFIG_SNOOZE
Definition: dc21x4hw.h:521
ULONG EXPORT NdisReadPciSlotInformation(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:180
ULONG EXPORT NdisWritePciSlotInformation(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:199
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142

Referenced by DcDisableHw(), and DcInitialize().

◆ DcPowerWorker()

VOID NTAPI DcPowerWorker ( _In_ PNDIS_WORK_ITEM  WorkItem,
_In_opt_ PVOID  Context 
)

Definition at line 167 of file power.c.

170{
171 PDC21X4_ADAPTER Adapter = Context;
172
174
175 PAGED_CODE();
176
177 if (Adapter->PowerState == NdisDeviceStateD0)
178 {
179 DcPowerUp(Adapter);
180 }
181 else
182 {
183 DcPowerDown(Adapter);
184 }
185 Adapter->PrevPowerState = Adapter->PowerState;
186
188}
static VOID DcPowerDown(_In_ PDC21X4_ADAPTER Adapter)
Definition: power.c:84
static VOID DcPowerUp(_In_ PDC21X4_ADAPTER Adapter)
Definition: power.c:138
#define NdisMSetInformationComplete(MiniportAdapterHandle, Status)
Definition: ndis.h:5762
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
@ NdisDeviceStateD0
Definition: ntddndis.h:38
NDIS_DEVICE_POWER_STATE PowerState
Definition: dc21x4.h:193
NDIS_DEVICE_POWER_STATE PrevPowerState
Definition: dc21x4.h:194
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115

Referenced by DcInitialize().

◆ DcProcessPendingPackets()

VOID DcProcessPendingPackets ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 201 of file send.c.

203{
207
208 ASSERT(!IsListEmpty(&Adapter->SendQueueList));
209
210 do
211 {
212 Entry = RemoveHeadList(&Adapter->SendQueueList);
213
215
216 Status = DcSendPacket(Adapter, Packet);
218 {
219 InsertHeadList(&Adapter->SendQueueList, DC_LIST_ENTRY_FROM_PACKET(Packet));
220 break;
221 }
222 }
223 while (!IsListEmpty(&Adapter->SendQueueList));
224}
static NDIS_STATUS DcSendPacket(_In_ NDIS_HANDLE MiniportAdapterContext, _In_ PNDIS_PACKET Packet)
Definition: send.c:127
#define InsertHeadList(ListHead, Entry)

Referenced by DcHandleTx().

◆ DcQueryInformation()

NDIS_STATUS NTAPI DcQueryInformation ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ NDIS_OID  Oid,
_In_ PVOID  InformationBuffer,
_In_ ULONG  InformationBufferLength,
_Out_ PULONG  BytesWritten,
_Out_ PULONG  BytesNeeded 
)

Definition at line 208 of file requests.c.

215{
216 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
218 ULONG InfoLength;
219 PVOID InfoPtr;
220 union _GENERIC_INFORMATION
221 {
223 ULONG Ulong;
224 ULONG64 Ulong64;
225 NDIS_MEDIUM Medium;
228 } GenericInfo;
229
230 InfoLength = sizeof(ULONG);
231 InfoPtr = &GenericInfo;
232
233 switch (Oid)
234 {
236 InfoPtr = (PVOID)&DcpSupportedOidList;
237 InfoLength = sizeof(DcpSupportedOidList);
238 break;
239
241 GenericInfo.Ulong = Adapter->PacketFilter;
242 break;
243
245 InfoPtr = Adapter->MulticastList;
246 InfoLength = Adapter->MulticastCount * ETH_LENGTH_OF_ADDRESS;
247 break;
248
250 GenericInfo.Ulong = Adapter->MulticastMaxEntries;
251 break;
252
255 {
256 GenericInfo.Medium = NdisMedium802_3;
257 InfoLength = sizeof(NDIS_MEDIUM);
258 break;
259 }
260
262 {
263 ULONG InterruptStatus;
264
265 /* NOTE: Reading the status register has no effect on the events */
266 InterruptStatus = DC_READ(Adapter, DcCsr5_Status);
267
268 /* Inserted into the motherboard */
269 if (InterruptStatus != 0xFFFFFFFF)
270 GenericInfo.Status = NdisHardwareStatusReady;
271 else
272 GenericInfo.Status = NdisHardwareStatusNotReady;
273
274 InfoLength = sizeof(NDIS_HARDWARE_STATUS);
275 break;
276 }
277
282 break;
283
285 GenericInfo.Ulong = DC_MAXIMUM_FRAME_SIZE;
286 break;
287
289 GenericInfo.Ulong = DC_TRANSMIT_BLOCK_SIZE;
290 break;
291
293 GenericInfo.Ulong = DC_TRANSMIT_BLOCK_SIZE * DC_TRANSMIT_BLOCKS;
294 break;
295
297 GenericInfo.Ulong = DC_RECEIVE_BLOCK_SIZE;
298 break;
299
301 GenericInfo.Ulong = DC_RECEIVE_BLOCK_SIZE * Adapter->RcbCount;
302 break;
303
305 GenericInfo.Ulong = DcGetLinkSpeed(Adapter) * 10000;
306 break;
307
309 GenericInfo.Ulong = 0;
310 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[0] << 16);
311 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[1] << 8);
312 GenericInfo.Ulong |= (Adapter->PermanentMacAddress[2] & 0xFF);
313 break;
314
316 {
317 static const CHAR VendorDesc[] = "DC21x4 compatible Ethernet Adapter";
318 InfoPtr = (PVOID)&VendorDesc;
319 InfoLength = sizeof(VendorDesc);
320 break;
321 }
322
324 /* 1.0.0 */
325 GenericInfo.Ulong = 0x100;
326 break;
327
329 {
330 InfoLength = sizeof(USHORT);
331 GenericInfo.Ushort = (NDIS_MINIPORT_MAJOR_VERSION << 8) | NDIS_MINIPORT_MINOR_VERSION;
332 break;
333 }
334
336 GenericInfo.Ulong = DC_TRANSMIT_BLOCKS - DC_TCB_RESERVE;
337 break;
338
340 GenericInfo.Ulong = NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA |
343 break;
344
346 GenericInfo.Ulong = Adapter->LinkUp ? NdisMediaStateConnected
348 break;
349
351 InfoPtr = Adapter->PermanentMacAddress;
352 InfoLength = ETH_LENGTH_OF_ADDRESS;
353 break;
354
356 InfoPtr = Adapter->CurrentMacAddress;
357 InfoLength = ETH_LENGTH_OF_ADDRESS;
358 break;
359
360 case OID_GEN_XMIT_OK:
361 case OID_GEN_RCV_OK:
379 {
380 DcQueryStatisticCounter(Adapter, Oid, &GenericInfo.Ulong64);
381
382 *BytesNeeded = sizeof(ULONG64);
383 if (InformationBufferLength < sizeof(ULONG))
384 {
385 *BytesWritten = 0;
387 }
388 if (InformationBufferLength >= sizeof(ULONG64))
389 {
390 *BytesWritten = sizeof(ULONG64);
391 NdisMoveMemory(InformationBuffer, InfoPtr, sizeof(ULONG64));
392 }
393 else
394 {
395 *BytesWritten = sizeof(ULONG);
396 NdisMoveMemory(InformationBuffer, InfoPtr, sizeof(ULONG));
397 }
398
399 return NDIS_STATUS_SUCCESS;
400 }
401
403 GenericInfo.Ulong = (DC_TRANSMIT_BLOCKS - DC_TCB_RESERVE) - Adapter->TcbSlots;
404 break;
405
407 {
409
410 InfoLength = sizeof(NDIS_PNP_CAPABILITIES);
411
412 if (InformationBufferLength < InfoLength)
413 {
414 *BytesWritten = 0;
415 *BytesNeeded = InfoLength;
417 }
418
419 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
421
422 *BytesWritten = InfoLength;
423 *BytesNeeded = 0;
424
425 Capabilities = InformationBuffer;
426 Capabilities->WakeUpCapabilities.MinMagicPacketWakeUp = NdisDeviceStateD3;
427 Capabilities->WakeUpCapabilities.MinPatternWakeUp = NdisDeviceStateD3;
428 Capabilities->WakeUpCapabilities.MinLinkChangeWakeUp = NdisDeviceStateD3;
429
430 return NDIS_STATUS_SUCCESS;
431 }
432
434 {
435 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
437
438 return NDIS_STATUS_SUCCESS;
439 }
440
442 {
443 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
445
446 GenericInfo.Ulong = Adapter->WakeUpFlags & (NDIS_PNP_WAKE_UP_MAGIC_PACKET |
449 break;
450 }
451
452 default:
454 break;
455 }
456
458 {
459 if (InfoLength > InformationBufferLength)
460 {
461 *BytesWritten = 0;
462 *BytesNeeded = InfoLength;
464 }
465 else
466 {
467 NdisMoveMemory(InformationBuffer, InfoPtr, InfoLength);
468 *BytesWritten = InfoLength;
469 *BytesNeeded = 0;
470 }
471 }
472 else
473 {
474 *BytesWritten = 0;
475 *BytesNeeded = 0;
476 }
477
478 return Status;
479}
static const NDIS_OID DcpSupportedOidList[]
Definition: requests.c:16
static ULONG DcGetLinkSpeed(_In_ PDC21X4_ADAPTER Adapter)
Definition: requests.c:167
static VOID DcQueryStatisticCounter(_In_ PDC21X4_ADAPTER Adapter, _In_ NDIS_OID Oid, _Out_ PULONG64 Counter)
Definition: requests.c:79
#define DC_MAXIMUM_FRAME_SIZE
Definition: dc21x4.h:36
#define DC_HAS_POWER_MANAGEMENT
Definition: dc21x4.h:111
#define DC_TRANSMIT_BLOCK_SIZE
Definition: dc21x4.h:37
#define DC_RECEIVE_BLOCK_SIZE
Definition: dc21x4.h:38
#define DC_ETHERNET_HEADER_SIZE
Definition: dc21x4.h:39
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
unsigned __int64 ULONG64
Definition: imports.h:198
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_STATUS_INVALID_OID
Definition: ndis.h:488
#define NDIS_STATUS_BUFFER_TOO_SHORT
Definition: ndis.h:487
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define NDIS_PNP_WAKE_UP_MAGIC_PACKET
Definition: ntddndis.h:372
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:267
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:244
#define OID_802_3_RCV_OVERRUN
Definition: ntddndis.h:312
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
@ NdisMediaStateConnected
Definition: ntddndis.h:470
@ NdisMediaStateDisconnected
Definition: ntddndis.h:471
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
#define OID_802_3_XMIT_HEARTBEAT_FAILURE
Definition: ntddndis.h:314
enum _NDIS_DEVICE_POWER_STATE NDIS_DEVICE_POWER_STATE
#define OID_802_3_XMIT_ONE_COLLISION
Definition: ntddndis.h:308
#define OID_802_3_XMIT_MORE_COLLISIONS
Definition: ntddndis.h:309
#define OID_802_3_XMIT_MAX_COLLISIONS
Definition: ntddndis.h:311
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
#define OID_802_3_XMIT_TIMES_CRS_LOST
Definition: ntddndis.h:315
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_802_3_XMIT_UNDERRUN
Definition: ntddndis.h:313
#define OID_802_3_XMIT_LATE_COLLISIONS
Definition: ntddndis.h:316
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
#define OID_GEN_DIRECTED_FRAMES_RCV
Definition: ntddndis.h:281
#define OID_PNP_ENABLE_WAKE_UP
Definition: ntddndis.h:366
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
#define OID_GEN_BROADCAST_FRAMES_RCV
Definition: ntddndis.h:285
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
#define OID_GEN_RCV_CRC_ERROR
Definition: ntddndis.h:286
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_RCV_OK
Definition: ntddndis.h:268
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
#define OID_802_3_RCV_ERROR_ALIGNMENT
Definition: ntddndis.h:307
#define OID_PNP_QUERY_POWER
Definition: ntddndis.h:362
#define NDIS_PNP_WAKE_UP_LINK_CHANGE
Definition: ntddndis.h:374
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
@ NdisHardwareStatusNotReady
Definition: ntddndis.h:454
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#define OID_PNP_CAPABILITIES
Definition: ntddndis.h:360
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:245
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:233
@ NdisDeviceStateD3
Definition: ntddndis.h:41
#define OID_802_3_XMIT_DEFERRED
Definition: ntddndis.h:310
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define OID_GEN_TRANSMIT_QUEUE_LENGTH
Definition: ntddndis.h:287
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
#define OID_GEN_MULTICAST_FRAMES_RCV
Definition: ntddndis.h:283
#define NDIS_PNP_WAKE_UP_PATTERN_MATCH
Definition: ntddndis.h:373
enum _NDIS_HARDWARE_STATUS NDIS_HARDWARE_STATUS
unsigned short USHORT
Definition: pedump.c:61
ULONG MulticastMaxEntries
Definition: dc21x4.h:202
ULONG TcbSlots
Definition: dc21x4.h:137
ULONG RcbCount
Definition: dc21x4.h:213
ULONG PacketFilter
Definition: dc21x4.h:154
BOOLEAN LinkUp
Definition: dc21x4.h:176
struct _DC21X4_ADAPTER::@983 MulticastList[DC_MULTICAST_LIST_SIZE]
ULONG WakeUpFlags
Definition: dc21x4.h:192
void * PVOID
Definition: typedefs.h:50
unsigned short Ushort
Definition: utypes.h:44
unsigned long Ulong
Definition: utypes.h:42
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3034
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
char CHAR
Definition: xmlstorage.h:175

Referenced by DriverEntry().

◆ DcReadEeprom()

NDIS_STATUS DcReadEeprom ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 1482 of file eeprom.c.

1484{
1486
1487 PAGED_CODE();
1488
1489 if (Adapter->ChipType == DC21040)
1490 {
1491 /* Ethernet Address ROM */
1492 Status = AddressRomRead(Adapter);
1493 }
1494 else
1495 {
1496 /* MicroWire Compatible Serial EEPROM */
1497 Status = SRomRead(Adapter);
1498 }
1499
1501 return Status;
1502
1503 INFO("MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
1504 Adapter->PermanentMacAddress[0],
1505 Adapter->PermanentMacAddress[1],
1506 Adapter->PermanentMacAddress[2],
1507 Adapter->PermanentMacAddress[3],
1508 Adapter->PermanentMacAddress[4],
1509 Adapter->PermanentMacAddress[5]);
1510
1511 if (ETH_IS_BROADCAST(Adapter->PermanentMacAddress) ||
1512 ETH_IS_EMPTY(Adapter->PermanentMacAddress) ||
1513 ETH_IS_MULTICAST(Adapter->PermanentMacAddress))
1514 {
1515 ERR("Invalid permanent MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
1516 Adapter->PermanentMacAddress[0],
1517 Adapter->PermanentMacAddress[1],
1518 Adapter->PermanentMacAddress[2],
1519 Adapter->PermanentMacAddress[3],
1520 Adapter->PermanentMacAddress[4],
1521 Adapter->PermanentMacAddress[5]);
1522
1523 NdisWriteErrorLogEntry(Adapter->AdapterHandle, NDIS_ERROR_CODE_NETWORK_ADDRESS, 0);
1524
1526 }
1527
1528 return NDIS_STATUS_SUCCESS;
1529}
@ DC21040
Definition: dc21x4hw.h:12
#define ETH_IS_EMPTY(Address)
Definition: util.h:22
VOID _cdecl NdisWriteErrorLogEntry(IN NDIS_HANDLE NdisAdapterHandle, IN NDIS_ERROR_CODE ErrorCode, IN ULONG NumberOfErrorValues,...)
Definition: main.c:76
static NDIS_STATUS SRomRead(_In_ PDC21X4_ADAPTER Adapter)
Definition: eeprom.c:1299
static NDIS_STATUS AddressRomRead(_In_ PDC21X4_ADAPTER Adapter)
Definition: eeprom.c:1386
#define NDIS_ERROR_CODE_NETWORK_ADDRESS
Definition: ndis.h:570
#define NDIS_STATUS_INVALID_ADDRESS
Definition: ndis.h:500
#define ETH_IS_BROADCAST(Address)
Definition: xfilter.h:32
#define ETH_IS_MULTICAST(Address)
Definition: xfilter.h:37

Referenced by DcInitialize().

◆ DcRemoveWakeUpPattern()

NDIS_STATUS DcRemoveWakeUpPattern ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ PNDIS_PM_PACKET_PATTERN  PmPattern 
)

Definition at line 205 of file power.c.

208{
209 // TODO: Not implemented
210 ERR("FIXME: Not implemented\n");
212}

Referenced by DcSetInformation().

◆ DcResetWorker()

VOID NTAPI DcResetWorker ( _In_ PNDIS_WORK_ITEM  WorkItem,
_In_opt_ PVOID  Context 
)

Definition at line 190 of file dc21x4.c.

193{
194 PDC21X4_ADAPTER Adapter = Context;
196 ULONG InterruptStatus;
197 LONG ResetReason;
198
200
201 PAGED_CODE();
202
204
205 /* Check if the device is present */
206 InterruptStatus = DC_READ(Adapter, DcCsr5_Status);
207 if (InterruptStatus == 0xFFFFFFFF)
208 {
209 ERR("Hardware is gone...\n");
210
211 /* Remove this adapter */
213
215 goto Done;
216 }
217
218 DcStopAdapter(Adapter, FALSE);
219
220 if (Adapter->LinkUp)
221 {
222 Adapter->LinkUp = FALSE;
223
226 NULL,
227 0);
229 }
230
231 DcSetupAdapter(Adapter);
232
233 DcStartAdapter(Adapter);
234
235Done:
236 ResetReason = _InterlockedExchange(&Adapter->ResetLock, 0);
237
238 /* Complete the pending reset request */
239 if (ResetReason == 1)
240 {
242 }
243}
NDIS_STATUS EXPORT NdisMRemoveMiniport(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: 50stubs.c:376
DECLSPEC_NOINLINE VOID DcStopAdapter(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN WaitForPackets)
Definition: dc21x4.c:123
#define NULL
Definition: types.h:112
#define NdisMIndicateStatusComplete(MiniportAdapterHandle)
Definition: ndis.h:5580
#define NdisMResetComplete(MiniportAdapterHandle, Status, AddressingReset)
Definition: ndis.h:5674
#define NDIS_STATUS_MEDIA_DISCONNECT
Definition: ndis.h:362
#define NDIS_STATUS_HARD_ERRORS
Definition: ndis.h:463
#define NdisMIndicateStatus(MiniportAdapterHandle, GeneralStatus, StatusBuffer, StatusBufferSize)
Definition: ndis.h:5570
_Interlocked_ volatile LONG ResetLock
Definition: dc21x4.h:239

Referenced by DcInitialize().

◆ DcReturnPacket()

VOID NTAPI DcReturnPacket ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ PNDIS_PACKET  Packet 
)

Definition at line 244 of file interrupt.c.

247{
248 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
249 PDC_RCB Rcb;
250
252
254
255 PushEntryList(&Adapter->FreeRcbList, &Rcb->ListEntry);
256
257 ++Adapter->RcbFree;
258
260}
#define DC_RCB_FROM_PACKET(Packet)
Definition: sendrcv.h:16
ULONG RcbFree
Definition: dc21x4.h:151
DECLSPEC_CACHEALIGN NDIS_SPIN_LOCK ReceiveLock
Definition: dc21x4.h:145
SINGLE_LIST_ENTRY FreeRcbList
Definition: dc21x4.h:150
SINGLE_LIST_ENTRY ListEntry
Definition: sendrcv.h:42
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:253

Referenced by DriverEntry().

◆ DcSendPackets()

VOID NTAPI DcSendPackets ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ PPNDIS_PACKET  PacketArray,
_In_ UINT  NumberOfPackets 
)

Definition at line 228 of file send.c.

232{
233 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
235 ULONG i;
236
237 NdisAcquireSpinLock(&Adapter->SendLock);
238
239 if (!(Adapter->Flags & DC_ACTIVE))
240 {
241 NdisReleaseSpinLock(&Adapter->SendLock);
242
243 for (i = 0; i < NumberOfPackets; ++i)
244 {
246 PacketArray[i],
248 }
249
250 return;
251 }
252
253 TRACE("Send packets %u\n", NumberOfPackets);
254
255 for (i = 0; i < NumberOfPackets; ++i)
256 {
258
259 Status = DcSendPacket(Adapter, Packet);
261 {
263 }
264 }
265
266 NdisReleaseSpinLock(&Adapter->SendLock);
267}
_In_ PPNDIS_PACKET _In_ UINT NumberOfPackets
Definition: ndis.h:5121
_In_ PPNDIS_PACKET PacketArray
Definition: ndis.h:5120
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350

Referenced by DriverEntry().

◆ DcSetInformation()

NDIS_STATUS NTAPI DcSetInformation ( _In_ NDIS_HANDLE  MiniportAdapterContext,
_In_ NDIS_OID  Oid,
_In_ PVOID  InformationBuffer,
_In_ ULONG  InformationBufferLength,
_Out_ PULONG  BytesRead,
_Out_ PULONG  BytesNeeded 
)

Definition at line 483 of file requests.c.

490{
491 PDC21X4_ADAPTER Adapter = (PDC21X4_ADAPTER)MiniportAdapterContext;
493 ULONG GenericUlong;
494
495 *BytesRead = 0;
496 *BytesNeeded = 0;
497
498 switch (Oid)
499 {
501 {
502 if (InformationBufferLength < sizeof(ULONG))
503 {
504 *BytesNeeded = sizeof(ULONG);
506 break;
507 }
508
509 *BytesRead = sizeof(ULONG);
510 NdisMoveMemory(&GenericUlong, InformationBuffer, sizeof(ULONG));
511
512 if (GenericUlong & ~DC_PACKET_FILTERS)
513 {
515 break;
516 }
517
518 Status = DcApplyPacketFilter(Adapter, GenericUlong);
519 break;
520 }
521
523 {
524 ULONG Size;
525
526 if (InformationBufferLength % ETH_LENGTH_OF_ADDRESS)
527 {
528 *BytesNeeded = (InformationBufferLength / ETH_LENGTH_OF_ADDRESS) *
531 break;
532 }
533
535 if (InformationBufferLength > Size)
536 {
537 *BytesNeeded = Size;
539 break;
540 }
541
542 *BytesRead = InformationBufferLength;
543 NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
544
545 Adapter->MulticastCount = InformationBufferLength / ETH_LENGTH_OF_ADDRESS;
546
547 Status = DcUpdateMulticastList(Adapter);
548 break;
549 }
550
552 {
553 if (InformationBufferLength < sizeof(ULONG))
554 {
555 *BytesNeeded = sizeof(ULONG);
557 break;
558 }
559
560 /* Nothing to do */
561 *BytesRead = sizeof(ULONG);
562 break;
563 }
564
566 {
567 if (InformationBufferLength < sizeof(ULONG))
568 {
569 *BytesNeeded = sizeof(ULONG);
571 break;
572 }
573
574 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
575 {
577 }
578
579 *BytesRead = sizeof(ULONG);
580 NdisMoveMemory(&GenericUlong, InformationBuffer, sizeof(ULONG));
581
582 Adapter->WakeUpFlags = GenericUlong;
583 break;
584 }
585
587 {
588 if (InformationBufferLength < sizeof(NDIS_PM_PACKET_PATTERN))
589 {
590 *BytesNeeded = sizeof(NDIS_PM_PACKET_PATTERN);
592 break;
593 }
594
595 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
596 {
598 }
599
601
602 Status = DcAddWakeUpPattern(Adapter, InformationBuffer);
603 break;
604 }
605
607 {
608 if (InformationBufferLength < sizeof(NDIS_PM_PACKET_PATTERN))
609 {
610 *BytesNeeded = sizeof(NDIS_PM_PACKET_PATTERN);
612 break;
613 }
614
615 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
616 {
618 }
619
621
622 Status = DcRemoveWakeUpPattern(Adapter, InformationBuffer);
623 break;
624 }
625
627 {
628 if (InformationBufferLength < sizeof(NDIS_DEVICE_POWER_STATE))
629 {
630 *BytesNeeded = sizeof(NDIS_DEVICE_POWER_STATE);
632 break;
633 }
634
635 if (!(Adapter->Features & DC_HAS_POWER_MANAGEMENT))
636 {
638 }
639
640 *BytesRead = sizeof(ULONG);
641 NdisMoveMemory(&GenericUlong, InformationBuffer, sizeof(ULONG));
642
643 if (GenericUlong < NdisDeviceStateD0 || GenericUlong > NdisDeviceStateD3)
644 {
645 ASSERT(FALSE);
647 break;
648 }
649
650 DcSetPower(Adapter, GenericUlong);
651 break;
652 }
653
654 default:
656 break;
657 }
658
659 return Status;
660}
NDIS_STATUS DcUpdateMulticastList(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:375
NDIS_STATUS DcSetPower(_In_ PDC21X4_ADAPTER Adapter, _In_ NDIS_DEVICE_POWER_STATE PowerState)
Definition: power.c:191
#define DC_PACKET_FILTERS
Definition: dc21x4.h:46
NDIS_STATUS DcApplyPacketFilter(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PacketFilter)
Definition: hardware.c:401
NDIS_STATUS DcRemoveWakeUpPattern(_In_ PDC21X4_ADAPTER Adapter, _In_ PNDIS_PM_PACKET_PATTERN PmPattern)
Definition: power.c:205
NDIS_STATUS DcAddWakeUpPattern(_In_ PDC21X4_ADAPTER Adapter, _In_ PNDIS_PM_PACKET_PATTERN PmPattern)
Definition: power.c:215
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_STATUS_MULTICAST_FULL
Definition: ndis.h:473
struct _NDIS_PM_PACKET_PATTERN NDIS_PM_PACKET_PATTERN
#define OID_PNP_SET_POWER
Definition: ntddndis.h:361
#define OID_PNP_ADD_WAKE_UP_PATTERN
Definition: ntddndis.h:363
#define OID_PNP_REMOVE_WAKE_UP_PATTERN
Definition: ntddndis.h:364
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by DriverEntry().

◆ DcSetPower()

NDIS_STATUS DcSetPower ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ NDIS_DEVICE_POWER_STATE  PowerState 
)

Definition at line 191 of file power.c.

194{
195 INFO("Power state %u\n", PowerState);
196
197 Adapter->PowerState = PowerState;
198
199 NdisScheduleWorkItem(&Adapter->PowerWorkItem);
200
201 return NDIS_STATUS_PENDING;
202}
NDIS_STATUS EXPORT NdisScheduleWorkItem(IN PNDIS_WORK_ITEM pWorkItem)
Definition: misc.c:467
#define NDIS_STATUS_PENDING
Definition: ndis.h:347

Referenced by DcSetInformation().

◆ DcSetupAdapter()

NDIS_STATUS DcSetupAdapter ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 462 of file hardware.c.

464{
465 PAGED_CODE();
466
467 DcInitTxRing(Adapter);
468 DcInitRxRing(Adapter);
469
470 /* Initial values */
471 if (!MEDIA_IS_FIXED(Adapter))
472 {
473 Adapter->LinkSpeedMbps = 10;
474 }
475 Adapter->MediaNumber = Adapter->DefaultMedia;
478
479 DcSoftReset(Adapter);
480
481 /* Receive descriptor ring buffer */
482 DC_WRITE(Adapter, DcCsr3_RxRingAddress, Adapter->RbdPhys);
483
484 /* Transmit descriptor ring buffer */
485 DC_WRITE(Adapter, DcCsr4_TxRingAddress, Adapter->TbdPhys);
486
487 switch (Adapter->ChipType)
488 {
489 case DC21040:
490 {
491 DcWriteSia(Adapter,
492 Adapter->Media[Adapter->MediaNumber].Csr13,
493 Adapter->Media[Adapter->MediaNumber].Csr14,
494 Adapter->Media[Adapter->MediaNumber].Csr15);
495
496 /* Explicitly specifed by user */
497 if (Adapter->MediaNumber == MEDIA_10T_FD)
498 {
499 Adapter->OpMode |= DC_OPMODE_FULL_DUPLEX;
500 }
501 break;
502 }
503
504 case DC21041:
505 {
506 MediaSiaSelect(Adapter);
507 break;
508 }
509
510 case DC21140:
511 {
512 if (Adapter->MediaNumber == MEDIA_MII)
513 {
514 MediaSelectMiiPort(Adapter, !(Adapter->Flags & DC_FIRST_SETUP));
515 MediaMiiSelect(Adapter);
516 }
517 else
518 {
519 /* All media use the same GPIO directon */
520 DC_WRITE(Adapter, DcCsr12_Gpio, Adapter->Media[Adapter->MediaNumber].GpioCtrl);
522
523 MediaGprSelect(Adapter);
524 }
525 break;
526 }
527
528 case DC21143:
529 case DC21145:
530 {
531 /* Init the HPNA PHY */
532 if ((Adapter->MediaBitmap & (1 << MEDIA_HMR)) && Adapter->HpnaInitBitmap)
533 {
534 HpnaPhyInit(Adapter);
535 }
536
537 if (Adapter->MediaNumber == MEDIA_MII)
538 {
539 MediaSelectMiiPort(Adapter, !(Adapter->Flags & DC_FIRST_SETUP));
540 MediaMiiSelect(Adapter);
541 break;
542 }
543
544 /* If the current media is FX, assume we have a link */
545 if (MEDIA_IS_FX(Adapter->MediaNumber))
546 {
547 Adapter->LinkUp = TRUE;
548
549 NdisMIndicateStatus(Adapter->AdapterHandle,
551 NULL,
552 0);
553 NdisMIndicateStatusComplete(Adapter->AdapterHandle);
554 }
555
556 MediaSiaSelect(Adapter);
557 break;
558 }
559
560 default:
561 ASSERT(FALSE);
563 break;
564 }
565
566 /* Start the TX process */
567 Adapter->OpMode |= DC_OPMODE_TX_ENABLE;
568 DC_WRITE(Adapter, DcCsr6_OpMode, Adapter->OpMode);
569
570 /* Load the address recognition RAM */
571 if (!DcSetupFrameDownload(Adapter, TRUE))
572 {
573 /* This normally should not happen */
574 ASSERT(FALSE);
575
576 NdisWriteErrorLogEntry(Adapter->AdapterHandle,
578 1,
579 __LINE__);
580
582 }
583
584 return NDIS_STATUS_SUCCESS;
585}
VOID MediaMiiSelect(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:197
VOID DcInitRxRing(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:574
#define DC_MODE_AUI_FAILED
Definition: dc21x4.h:166
VOID HpnaPhyInit(_In_ PDC21X4_ADAPTER Adapter)
Definition: phy.c:194
#define DC_MODE_BNC_FAILED
Definition: dc21x4.h:167
VOID MediaGprSelect(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:303
#define DC_MODE_PORT_AUTOSENSE
Definition: dc21x4.h:164
#define DC_MODE_TEST_PACKET
Definition: dc21x4.h:165
VOID DcInitTxRing(_In_ PDC21X4_ADAPTER Adapter)
Definition: init.c:499
VOID MediaSiaSelect(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:268
#define DC_MODE_AUTONEG_MASK
Definition: dc21x4.h:163
#define DC_OPMODE_FULL_DUPLEX
Definition: dc21x4hw.h:327
@ DC21145
Definition: dc21x4hw.h:16
@ DC21140
Definition: dc21x4hw.h:14
@ DC21041
Definition: dc21x4hw.h:13
@ DC21143
Definition: dc21x4hw.h:15
@ DcCsr4_TxRingAddress
Definition: dc21x4hw.h:178
@ DcCsr12_Gpio
Definition: dc21x4hw.h:187
@ DcCsr3_RxRingAddress
Definition: dc21x4hw.h:177
static VOID DcSoftReset(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:442
VOID DcWriteSia(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Csr13, _In_ ULONG Csr14, _In_ ULONG Csr15)
Definition: hardware.c:89
BOOLEAN DcSetupFrameDownload(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN WaitForCompletion)
Definition: hardware.c:187
#define MEDIA_MII
Definition: media.h:67
#define MEDIA_IS_FIXED(Adapter)
Definition: media.h:126
#define MEDIA_10T_FD
Definition: media.h:51
#define MEDIA_IS_FX(MediaNumber)
Definition: media.h:122
#define MEDIA_HMR
Definition: media.h:56
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
#define NDIS_ERROR_CODE_HARDWARE_FAILURE
Definition: ndis.h:564
#define NdisStallExecution
Definition: ndis.h:4453
#define UNREACHABLE

Referenced by DcInitialize(), DcPowerUp(), and DcResetWorker().

◆ DcSetupFrameDownload()

BOOLEAN DcSetupFrameDownload ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  WaitForCompletion 
)

Definition at line 187 of file hardware.c.

190{
191 PDC_TCB Tcb;
192 PDC_TBD Tbd;
193 ULONG i, Control;
194
195 Tbd = Adapter->CurrentTbd;
196
197 /* Ensure correct setup frame processing */
198 if (Tbd != Adapter->HeadTbd)
199 {
201
202 /* Put the null frame on the transmit ring */
204 Tbd->Address1 = 0;
205 Tbd->Address2 = 0;
208
209 Tbd = DC_NEXT_TBD(Adapter, Tbd);
210 }
211
212 Adapter->CurrentTbd = DC_NEXT_TBD(Adapter, Tbd);
213
214 Tcb = Adapter->CurrentTcb;
215 Adapter->CurrentTcb = DC_NEXT_TCB(Adapter, Tcb);
216
217 Tcb->Tbd = Tbd;
218 Tcb->Packet = NULL;
219
221
222 /* Prepare the setup frame */
223 Tbd->Address1 = Adapter->SetupFramePhys;
224 Tbd->Address2 = 0;
227 if (!WaitForCompletion)
229 if (Adapter->ProgramHashPerfectFilter)
231 Tbd->Control |= Control;
234
236
237 if (!WaitForCompletion)
238 return TRUE;
239
240 /* Wait up to 500 ms for the chip to process the setup frame */
241 for (i = 50000; i > 0; --i)
242 {
244
246 if (!(Tbd->Status & DC_TBD_STATUS_OWNED))
247 break;
248 }
249 if (i == 0)
250 {
251 ERR("Failed to complete setup frame %08lx\n", Tbd->Status);
252 return FALSE;
253 }
254
255 return TRUE;
256}
@ DcCsr1_TxPoll
Definition: dc21x4hw.h:173
#define DC_TBD_STATUS_OWNED
Definition: dc21x4hw.h:71
#define DC_TBD_CONTROL_REQUEST_INTERRUPT
Definition: dc21x4hw.h:87
#define DC_TBD_CONTROL_SETUP_FRAME
Definition: dc21x4hw.h:84
#define DC_TX_POLL_DOORBELL
Definition: dc21x4hw.h:244
#define DC_TBD_CONTROL_HASH_PERFECT_FILTER
Definition: dc21x4hw.h:89
#define DC_WRITE_BARRIER()
Definition: util.h:30
#define KeMemoryBarrierWithoutFence()
Definition: ke.h:66
FORCEINLINE PDC_TBD DC_NEXT_TBD(_In_ PDC21X4_ADAPTER Adapter, _In_ PDC_TBD Tbd)
Definition: sendrcv.h:86
FORCEINLINE PDC_TCB DC_NEXT_TCB(_In_ PDC21X4_ADAPTER Adapter, _In_ PDC_TCB Tcb)
Definition: sendrcv.h:74
ULONG Status
Definition: dc21x4hw.h:59
ULONG Address1
Definition: dc21x4hw.h:95
ULONG Control
Definition: dc21x4hw.h:77
ULONG Address2
Definition: dc21x4hw.h:96
PDC_TBD Tbd
Definition: sendrcv.h:33
PNDIS_PACKET Packet
Definition: sendrcv.h:34
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166

Referenced by DcPowerUp(), DcSetupAdapter(), and DcUpdateMulticastList().

◆ DcSetupFrameInitialize()

VOID DcSetupFrameInitialize ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 260 of file hardware.c.

262{
263 PULONG SetupFrame, SetupFrameStart;
264 PUSHORT MacAddress;
265 ULONG i;
266
267 PAGED_CODE();
268
269 SetupFrame = Adapter->SetupFrame;
270
271 /* Add the physical address entry */
272 MacAddress = (PUSHORT)Adapter->CurrentMacAddress;
273 *SetupFrame++ = DC_SETUP_FRAME_ENTRY(MacAddress[0]);
274 *SetupFrame++ = DC_SETUP_FRAME_ENTRY(MacAddress[1]);
275 *SetupFrame++ = DC_SETUP_FRAME_ENTRY(MacAddress[2]);
276
277 /* Pad to 16 addresses */
278 SetupFrameStart = Adapter->SetupFrame;
280 {
281 *SetupFrame++ = SetupFrameStart[0];
282 *SetupFrame++ = SetupFrameStart[1];
283 *SetupFrame++ = SetupFrameStart[2];
284 }
285}
#define DC_SETUP_FRAME_PERFECT_FILTER_ADDRESSES
Definition: dc21x4hw.h:38
#define DC_SETUP_FRAME_ENTRY(Value)
Definition: dc21x4hw.h:47
uint16_t * PUSHORT
Definition: typedefs.h:56

Referenced by DcInitialize().

◆ DcStartAdapter()

VOID DcStartAdapter ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 168 of file dc21x4.c.

170{
171 PAGED_CODE();
172
173 /* Enable interrupts */
174 _InterlockedExchange((PLONG)&Adapter->CurrentInterruptMask, Adapter->InterruptMask);
175 DC_WRITE(Adapter, DcCsr7_IrqMask, Adapter->InterruptMask);
176
177 Adapter->Flags |= DC_ACTIVE;
178
179 /* Start the RX process */
180 Adapter->OpMode |= DC_OPMODE_RX_ENABLE;
181 DC_WRITE(Adapter, DcCsr6_OpMode, Adapter->OpMode);
182
183 /* Start the media monitor, wait the selected media to become ready */
184 NdisMSetTimer(&Adapter->MediaMonitorTimer, 2400);
185}
VOID EXPORT NdisMSetTimer(IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsToDelay)
Definition: time.c:272

Referenced by DcInitialize(), DcPowerUp(), and DcResetWorker().

◆ DcStopAdapter()

DECLSPEC_NOINLINE VOID DcStopAdapter ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  WaitForPackets 
)

Definition at line 123 of file dc21x4.c.

126{
128
129 /* Attempt to disable interrupts to complete more quickly */
130 DC_WRITE(Adapter, DcCsr7_IrqMask, 0);
131
132 /* Prevent DPCs from executing and stop accepting incoming packets */
133 NdisAcquireSpinLock(&Adapter->SendLock);
134 Adapter->Flags &= ~DC_ACTIVE;
135 NdisReleaseSpinLock(&Adapter->SendLock);
136
137 NdisMCancelTimer(&Adapter->MediaMonitorTimer, &TimerCancelled);
138
139 /* Wait for any DPCs to complete */
141
142 /* Disable interrupts */
143 DC_WRITE(Adapter, DcCsr7_IrqMask, 0);
144
145 /* Wait for completion of TX/RX and stop the DMA engine inside the NIC */
146 DcStopTxRxProcess(Adapter);
147 Adapter->OpMode &= ~(DC_OPMODE_RX_ENABLE | DC_OPMODE_TX_ENABLE);
148
149 DcFlushTransmitQueue(Adapter);
150
151 /* Wait for the packets to be returned to the driver */
152 if (WaitForPackets)
153 {
154 DcStopReceivePath(Adapter);
155 }
156
157 /* Make sure there is no pending OID request */
158 if (Adapter->OidPending)
159 {
160 NdisMSetInformationComplete(Adapter->AdapterHandle, NDIS_STATUS_SUCCESS);
161
162 Adapter->OidPending = FALSE;
163 }
164}
static VOID DcFlushTransmitQueue(_In_ PDC21X4_ADAPTER Adapter)
Definition: dc21x4.c:40
static VOID DcStopReceivePath(_In_ PDC21X4_ADAPTER Adapter)
Definition: dc21x4.c:90
VOID DcStopTxRxProcess(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:38
VOID NTAPI KeFlushQueuedDpcs(VOID)
Definition: dpc.c:919
VOID EXPORT NdisMCancelTimer(IN PNDIS_MINIPORT_TIMER Timer, OUT PBOOLEAN TimerCancelled)
Definition: time.c:131
_Out_ _At_ TimerCancelled PBOOLEAN TimerCancelled
Definition: ndis.h:2820

Referenced by DcHalt(), DcPowerDown(), and DcResetWorker().

◆ DcStopTxRxProcess()

VOID DcStopTxRxProcess ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 38 of file hardware.c.

40{
41 ULONG i, OpMode, Status;
42
43 OpMode = Adapter->OpMode;
45 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
46
47 for (i = 0; i < 5000; ++i)
48 {
49 Status = DC_READ(Adapter, DcCsr5_Status);
50
53 {
54 return;
55 }
56
58 }
59
60 WARN("Failed to stop the TX/RX process 0x%08lx\n", Status);
61}
#define DC_STATUS_RX_STATE_MASK
Definition: dc21x4hw.h:286
#define DC_STATUS_TX_STATE_STOPPED
Definition: dc21x4hw.h:293
#define DC_STATUS_RX_STATE_STOPPED
Definition: dc21x4hw.h:302
#define DC_STATUS_TX_STATE_MASK
Definition: dc21x4hw.h:287

Referenced by DcAdjustTxFifoThreshold(), DcStopAdapter(), DcTransmitTimeoutRecoveryWorker(), Media143SelectNextSerialMedia(), MediaMiiSetSpeedAndDuplex(), and MediaSiaSelect().

◆ DcTestPacket()

VOID DcTestPacket ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 135 of file hardware.c.

137{
138 PDC_TCB Tcb;
139 PDC_TBD Tbd;
140 ULONG FrameNumber;
141
142 Adapter->MediaTestStatus = FALSE;
143 Adapter->ModeFlags |= DC_MODE_TEST_PACKET;
144
145 if (!Adapter->LoopbackFrameSlots)
146 {
147 ERR("Failed to complete test packets, CSR12 %08lx, CSR5 %08lx\n",
148 DC_READ(Adapter, DcCsr12_SiaStatus),
149 DC_READ(Adapter, DcCsr5_Status));
150
151 /* Try to recover the lost TX buffers */
152 NdisScheduleWorkItem(&Adapter->TxRecoveryWorkItem);
153 return;
154 }
155
156 --Adapter->LoopbackFrameSlots;
157
158 FrameNumber = (Adapter->LoopbackFrameNumber++) % DC_LOOPBACK_FRAMES;
159
160 Tbd = Adapter->CurrentTbd;
161 Adapter->CurrentTbd = DC_NEXT_TBD(Adapter, Tbd);
162
163 Tcb = Adapter->CurrentTcb;
164 Adapter->CurrentTcb = DC_NEXT_TCB(Adapter, Tcb);
165
166 Tcb->Tbd = Tbd;
167 Tcb->Packet = NULL;
168
170
171 /* Put the loopback frame on the transmit ring */
172 Tbd->Address1 = Adapter->LoopbackFramePhys[FrameNumber];
173 Tbd->Address2 = 0;
181
182 /* Send the loopback packet to verify connectivity of a media */
184}
#define DC_LOOPBACK_FRAME_SIZE
Definition: dc21x4.h:53
@ DcCsr12_SiaStatus
Definition: dc21x4hw.h:188
#define DC_TBD_CONTROL_FIRST_FRAGMENT
Definition: dc21x4hw.h:85
#define DC_TBD_CONTROL_LAST_FRAGMENT
Definition: dc21x4hw.h:86

Referenced by MediaMonitor21040Dpc(), MediaMonitor21041Dpc(), and MediaMonitor21143Dpc().

◆ DcTransmitTimeoutRecoveryWorker()

VOID NTAPI DcTransmitTimeoutRecoveryWorker ( _In_ PNDIS_WORK_ITEM  WorkItem,
_In_opt_ PVOID  Context 
)

Definition at line 247 of file dc21x4.c.

250{
251 PDC21X4_ADAPTER Adapter = Context;
252
254
255 NdisAcquireSpinLock(&Adapter->ModeLock);
256
257 DcStopTxRxProcess(Adapter);
258 DC_WRITE(Adapter, DcCsr6_OpMode, Adapter->OpMode);
259
261
263
265
266 NdisReleaseSpinLock(&Adapter->ModeLock);
267}
#define NdisDprReleaseSpinLock(_SpinLock)
Definition: ndis.h:4133
#define NdisDprAcquireSpinLock(_SpinLock)
Definition: ndis.h:4124
DECLSPEC_CACHEALIGN NDIS_SPIN_LOCK ModeLock
Definition: dc21x4.h:161
ULONG OpMode
Definition: dc21x4.h:173

Referenced by DcInitialize().

◆ DcUpdateMulticastList()

NDIS_STATUS DcUpdateMulticastList ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 375 of file hardware.c.

377{
378 BOOLEAN UsePerfectFiltering;
379
380 /* If more than 14 addresses are requested, switch to hash filtering mode */
381 UsePerfectFiltering = (Adapter->MulticastCount <= DC_SETUP_FRAME_ADDRESSES);
382
383 Adapter->ProgramHashPerfectFilter = UsePerfectFiltering;
384 Adapter->OidPending = TRUE;
385
386 if (UsePerfectFiltering)
388 else
390
391 NdisAcquireSpinLock(&Adapter->SendLock);
392
393 DcSetupFrameDownload(Adapter, FALSE);
394
395 NdisReleaseSpinLock(&Adapter->SendLock);
396
397 return NDIS_STATUS_PENDING;
398}
#define DC_SETUP_FRAME_ADDRESSES
Definition: dc21x4hw.h:41
static VOID DcSetupFrameImperfectFiltering(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:340
static VOID DcSetupFramePerfectFiltering(_In_ PDC21X4_ADAPTER Adapter)
Definition: hardware.c:289

Referenced by DcApplyPacketFilter(), and DcSetInformation().

◆ DcWriteGpio()

VOID DcWriteGpio ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  Value 
)

Definition at line 64 of file hardware.c.

67{
69
70 /* Some chips don't have a separate GPIO register */
71 if (Adapter->Features & DC_SIA_GPIO)
72 {
73 Data = Adapter->SiaSetting;
74 Data &= 0x0000FFFF; /* SIA */
75 Data |= Value << 16; /* GPIO */
76 Adapter->SiaSetting = Data;
77
79 }
80 else
81 {
82 Data = Value;
84 }
85 DC_WRITE(Adapter, Register, Data);
86}
#define DC_SIA_GPIO
Definition: dc21x4.h:109
@ DcCsr15_SiaGeneral
Definition: dc21x4hw.h:191

Referenced by DcInitialize(), MediaSelectMiiPort(), and MediaSiaSelect().

◆ DcWriteSia()

VOID DcWriteSia ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  Csr13,
_In_ ULONG  Csr14,
_In_ ULONG  Csr15 
)

Definition at line 89 of file hardware.c.

94{
95 ULONG SiaConn, SiaGen;
96
97 TRACE("CSR13 %08lx, CSR14 %08lx, CSR15 %08lx\n", Csr13, Csr14, Csr15);
98
99 SiaConn = 0;
100
101 /* The 21145 comes with 16 new bits in CSR13 */
102 if (Adapter->Features & DC_SIA_ANALOG_CONTROL)
103 {
104 SiaConn = Adapter->AnalogControl;
105 }
106
107 /* Reset the transceiver */
110
111 /* Some chips don't have a separate GPIO register */
112 if (Adapter->Features & DC_SIA_GPIO)
113 {
114 SiaGen = Adapter->SiaSetting;
115 SiaGen &= 0xFFFF0000; /* GPIO */
116 SiaGen |= Csr15; /* SIA */
117 Adapter->SiaSetting = SiaGen;
118 }
119 else
120 {
121 SiaGen = Csr15;
122 }
123
124 DC_WRITE(Adapter, DcCsr14_SiaTxRx, Csr14);
125 DC_WRITE(Adapter, DcCsr15_SiaGeneral, SiaGen);
126
127 /* Don't reset the transceiver twice */
128 if (Csr13 == DC_SIA_CONN_RESET)
129 return;
130
131 DC_WRITE(Adapter, DcCsr13_SiaConnectivity, SiaConn | Csr13);
132}
#define DC_SIA_ANALOG_CONTROL
Definition: dc21x4.h:110
#define DC_SIA_CONN_RESET
Definition: dc21x4hw.h:449
@ DcCsr14_SiaTxRx
Definition: dc21x4hw.h:190
@ DcCsr13_SiaConnectivity
Definition: dc21x4hw.h:189

Referenced by DcSetupAdapter(), MediaMonitor21040Dpc(), MediaSelectMiiPort(), and MediaSiaSelect().

◆ HpnaPhyInit()

VOID HpnaPhyInit ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 194 of file phy.c.

196{
197 ULONG SiaConn, i;
198
199 PAGED_CODE();
200
201 /* Select the HPNA interface */
202 SiaConn = DC_READ(Adapter, DcCsr13_SiaConnectivity);
203 SiaConn |= DC_SIA_CONN_HPNA;
204 DC_WRITE(Adapter, DcCsr13_SiaConnectivity, SiaConn);
205
206 for (i = 0; i < RTL_NUMBER_OF(Adapter->HpnaRegister); ++i)
207 {
208 if (Adapter->HpnaInitBitmap & (1 << i))
209 {
210 HpnaWrite(Adapter, i, Adapter->HpnaRegister[i]);
211 }
212 }
213}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static VOID HpnaWrite(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG RegAddress, _In_ ULONG Data)
Definition: phy.c:174
#define DC_SIA_CONN_HPNA
Definition: dc21x4hw.h:450

Referenced by DcSetupAdapter().

◆ MediaGprSelect()

VOID MediaGprSelect ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 303 of file media.c.

305{
306 ULONG OpMode;
307 PDC_MEDIA Media;
308
309 INFO("Selected media %s\n", MediaNumber2Str(Adapter, Adapter->MediaNumber));
310
311 Media = &Adapter->Media[Adapter->MediaNumber];
312
313 DC_WRITE(Adapter, DcCsr12_Gpio, Media->GpioData);
314
315 OpMode = Adapter->OpMode;
316 OpMode &= ~DC_OPMODE_MEDIA_MASK;
317 OpMode |= Media->OpMode;
318 Adapter->OpMode = OpMode;
319
320 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
321}
#define MediaNumber2Str
Definition: debug.h:93
ULONG OpMode
Definition: media.h:12
USHORT GpioData
Definition: media.h:15

Referenced by DcSetupAdapter(), and MediaMonitor21140Dpc().

◆ MediaIndicateConnect()

VOID MediaIndicateConnect ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  LinkUp 
)

Definition at line 17 of file media.c.

20{
21 /* Nothing to do */
22 if (Adapter->LinkUp == LinkUp)
23 return;
24
25 Adapter->LinkUp = LinkUp;
26
27 INFO_VERB("Link %sconnected, media is %s\n",
28 LinkUp ? "" : "dis",
29 MediaNumber2Str(Adapter, Adapter->MediaNumber));
30
31 NdisDprReleaseSpinLock(&Adapter->ModeLock);
32
33 NdisMIndicateStatus(Adapter->AdapterHandle,
35 NULL,
36 0);
37 NdisMIndicateStatusComplete(Adapter->AdapterHandle);
38
39 NdisDprAcquireSpinLock(&Adapter->ModeLock);
40}
@ LinkUp
Definition: srb.h:741

Referenced by Media143Handle100LinkChange(), Media143Handle10LinkFail(), Media143Handle10LinkPass(), Media143SelectNextMedia(), MediaLinkStateChange21040(), MediaLinkStateChange21041(), MediaMonitor143(), MediaMonitor21040Dpc(), MediaMonitor21041Dpc(), MediaMonitor21140Dpc(), and MediaMonitor21143Dpc().

◆ MediaInitDefaultMedia()

VOID MediaInitDefaultMedia ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  MediaNumber 
)

Definition at line 325 of file media.c.

328{
329 ULONG Csr14, MiiAdvertising, MiiControl, i;
330 BOOLEAN UseMii;
331
332 PAGED_CODE();
333
334 /* Media auto-detection */
335 if (MediaNumber == MEDIA_AUTO)
336 {
337 Adapter->Flags |= DC_AUTOSENSE;
338
339 /* Initial value for all boards */
340 Adapter->DefaultMedia = MEDIA_10T;
341
342 Adapter->MiiAdvertising = Adapter->MiiMedia.Advertising;
343 Adapter->MiiControl = MII_CR_AUTONEG | MII_CR_AUTONEG_RESTART;
344
345 switch (Adapter->ChipType)
346 {
347 case DC21041:
348 {
349 /* Errata: don't enable auto-negotiation */
350 if (Adapter->RevisionId < 0x20)
351 break;
352
353 /* Advertise 10T HD and 10T FD. The chip chooses the 10T FD mode automatically */
354 Adapter->Media[MEDIA_10T].Csr14 |= DC_SIA_TXRX_AUTONEG | DC_SIA_TXRX_ADV_10T_HD;
355 Adapter->Media[MEDIA_10T].OpMode |= DC_OPMODE_FULL_DUPLEX;
356 break;
357 }
358
359 case DC21140:
360 {
361 /* Pick the default media */
362 if (Adapter->Features & DC_HAS_MII)
363 {
364 Adapter->DefaultMedia = MEDIA_MII;
365 break;
366 }
367
368 /* The final entry in the media list should be checked first */
369 _BitScanReverse(&Adapter->DefaultMedia, Adapter->MediaBitmap);
370
371 /*
372 * Select the first half-duplex media.
373 * If you want to be able to use 21140 boards without MII in full-duplex mode,
374 * you have to manually select the media.
375 */
376 for (i = Adapter->DefaultMedia; i > 0; --i)
377 {
378 if ((Adapter->MediaBitmap & (1 << i)) && !MEDIA_IS_FD(i))
379 break;
380 }
381 Adapter->DefaultMedia = i;
382 break;
383 }
384
385 case DC21143:
386 case DC21145:
387 {
388 /* Pick the default media */
389 if (Adapter->Features & DC_HAS_MII)
390 {
391 Adapter->DefaultMedia = MEDIA_MII;
392 }
393 else if (Adapter->MediaBitmap & (1 << MEDIA_10T))
394 {
395 /* Start at 10mbps to do internal auto-negotiation */
396 Adapter->DefaultMedia = MEDIA_10T;
397 }
398 else
399 {
400 /* The final entry in the media list should be checked first */
401 _BitScanReverse(&Adapter->DefaultMedia, Adapter->MediaBitmap);
402 }
403
404 /* Enable the PCS function to do 100mbps parallel detection */
405 if (Adapter->SymAdvertising & MII_ADV_100)
406 {
407 Adapter->Media[MEDIA_10T].OpMode |= DC_OPMODE_PORT_PCS;
408 Adapter->Media[MEDIA_10T_FD].OpMode |= DC_OPMODE_PORT_PCS;
409 Adapter->Media[MEDIA_AUI].OpMode |= DC_OPMODE_PORT_PCS;
410 Adapter->Media[MEDIA_BNC].OpMode |= DC_OPMODE_PORT_PCS;
411 Adapter->Media[MEDIA_HMR].OpMode |= DC_OPMODE_PORT_PCS;
412 }
413
414 Csr14 = DC_SIA_TXRX_AUTONEG;
415
416 if (Adapter->SymAdvertising & MII_ADV_10T_HD)
417 Csr14 |= DC_SIA_TXRX_ADV_10T_HD;
418
419 /* When NWay is turned on, the FDX bit advertises 10T FD */
420 if (Adapter->SymAdvertising & MII_ADV_10T_FD)
421 Adapter->Media[MEDIA_10T].OpMode |= DC_OPMODE_FULL_DUPLEX;
422
423 if (Adapter->SymAdvertising & MII_ADV_100T_HD)
425
426 if (Adapter->SymAdvertising & MII_ADV_100T_FD)
428
429 if (Adapter->SymAdvertising & MII_ADV_100T4)
430 Csr14 |= DC_SIA_TXRX_ADV_100T4;
431
432 /* Advertise the PHY capability */
433 Adapter->Media[MEDIA_10T].Csr14 |= Csr14;
434
435 /* This media may use GPIO data different from the 10T HD */
436 Adapter->Media[MEDIA_10T_FD].Csr14 |= Csr14;
437 break;
438 }
439
440 default:
441 break;
442 }
443 }
444 else /* Forced speed and duplex */
445 {
446 UseMii = FALSE;
447
448 if (Adapter->Features & DC_HAS_MII)
449 {
450 if (!MEDIA_MII_OVERRIDE(MediaNumber))
451 {
452 UseMii = TRUE;
453 }
454 }
455
456 if (!UseMii)
457 {
458 Adapter->DefaultMedia = MediaNumber;
459
460 if (MEDIA_IS_10T(MediaNumber))
461 {
462 Adapter->InterruptMask &= ~DC_IRQ_LINK_CHANGED;
463 Adapter->LinkStateChangeMask &= ~DC_IRQ_LINK_CHANGED;
464 }
465
466 if (MEDIA_IS_100(MediaNumber))
467 {
468 Adapter->InterruptMask &= ~(DC_IRQ_LINK_FAIL | DC_IRQ_LINK_PASS);
469 Adapter->LinkStateChangeMask &= ~(DC_IRQ_LINK_FAIL | DC_IRQ_LINK_PASS);
470 }
471 }
472 else
473 {
474 Adapter->DefaultMedia = MEDIA_MII;
475
476 switch (MediaNumber)
477 {
478 case MEDIA_10T:
479 MiiAdvertising = MII_ADV_10T_HD;
480 break;
481 case MEDIA_10T_FD:
482 MiiAdvertising = MII_ADV_10T_FD;
483 MiiControl = MII_CR_FULL_DUPLEX;
484 break;
485 case MEDIA_100TX_HD:
486 MiiAdvertising = MII_ADV_100T_HD;
487 MiiControl = MII_CR_SPEED_SELECTION;
488 break;
489 case MEDIA_100TX_FD:
490 MiiAdvertising = MII_ADV_100T_FD;
492 break;
493 case MEDIA_100T4:
494 MiiAdvertising = MII_ADV_100T4 | MII_CR_SPEED_SELECTION;
495 break;
496
497 default:
498 MiiAdvertising = 0;
499 MiiControl = 0;
500 break;
501 }
502
503 if (MiiControl & MII_CR_SPEED_SELECTION)
504 Adapter->LinkSpeedMbps = 100;
505 else
506 Adapter->LinkSpeedMbps = 10;
507
508 Adapter->MiiAdvertising = MiiAdvertising;
509 Adapter->MiiControl = MiiControl;
510 }
511 }
512
513 INFO("Default media is %s\n", MediaNumber2Str(Adapter, Adapter->DefaultMedia));
514}
#define DC_AUTOSENSE
Definition: dc21x4.h:124
#define MII_ADV_10T_FD
Definition: dc21x4hw.h:574
#define DC_SIA_TXRX_ADV_100TX_FD
Definition: dc21x4hw.h:471
#define DC_SIA_TXRX_ADV_10T_HD
Definition: dc21x4hw.h:460
#define MII_ADV_100T4
Definition: dc21x4hw.h:577
#define DC_SIA_TXRX_ADV_100TX_HD
Definition: dc21x4hw.h:470
#define MII_CR_FULL_DUPLEX
Definition: dc21x4hw.h:558
#define MII_CR_AUTONEG
Definition: dc21x4hw.h:562
#define MII_ADV_100
Definition: dc21x4hw.h:596
#define MII_CR_AUTONEG_RESTART
Definition: dc21x4hw.h:559
#define DC_OPMODE_PORT_PCS
Definition: dc21x4hw.h:338
#define DC_SIA_TXRX_AUTONEG
Definition: dc21x4hw.h:461
#define DC_SIA_TXRX_ADV_100T4
Definition: dc21x4hw.h:472
#define MII_ADV_100T_HD
Definition: dc21x4hw.h:575
#define MII_ADV_100T_FD
Definition: dc21x4hw.h:576
#define MII_ADV_10T_HD
Definition: dc21x4hw.h:573
#define MII_CR_SPEED_SELECTION
Definition: dc21x4hw.h:563
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:180
#define MEDIA_AUI
Definition: media.h:48
#define MEDIA_100TX_FD
Definition: media.h:52
#define MEDIA_IS_10T(MediaNumber)
Definition: media.h:114
#define MEDIA_IS_100(MediaNumber)
Definition: media.h:118
#define MEDIA_AUTO
Definition: media.h:62
#define MEDIA_IS_FD(MediaNumber)
Definition: media.h:106
#define MEDIA_MII_OVERRIDE(MediaNumber)
Definition: media.h:102
#define MEDIA_10T
Definition: media.h:46
#define MEDIA_100T4
Definition: media.h:53
#define MEDIA_BNC
Definition: media.h:47
#define MEDIA_100TX_HD
Definition: media.h:49

Referenced by DcInitialize().

◆ MediaInitMediaList()

VOID MediaInitMediaList ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 545 of file media.c.

547{
548 PAGED_CODE();
549
550 /*
551 * Set the default internal values for the SIA/SYM operating modes.
552 * The SROM parsing code may later overwrite them.
553 */
554 switch (Adapter->ChipType)
555 {
556 case DC21040:
557 {
558 Adapter->Media[MEDIA_10T].Csr13 = 0x8F01;
559 Adapter->Media[MEDIA_10T].Csr14 = 0xFFFF;
560 Adapter->Media[MEDIA_10T].Csr15 = 0x0000;
561
562 Adapter->Media[MEDIA_BNC].Csr13 = 0x8F09;
563 Adapter->Media[MEDIA_BNC].Csr14 = 0x0705;
564 Adapter->Media[MEDIA_BNC].Csr15 = 0x0006;
565
566 Adapter->Media[MEDIA_10T_FD].Csr13 = 0x8F01;
567 Adapter->Media[MEDIA_10T_FD].Csr14 = 0xFFFD;
568 Adapter->Media[MEDIA_10T_FD].Csr15 = 0x0000;
569 Adapter->Media[MEDIA_10T_FD].OpMode = DC_OPMODE_FULL_DUPLEX;
570 break;
571 }
572
573 case DC21041:
574 {
575 Adapter->Media[MEDIA_10T].Csr13 = 0xEF01;
576 Adapter->Media[MEDIA_10T].Csr14 = 0xFF3F;
577 Adapter->Media[MEDIA_10T].Csr15 = 0x0008;
578
579 Adapter->Media[MEDIA_BNC].Csr13 = 0xEF09;
580 Adapter->Media[MEDIA_BNC].Csr14 = 0xF7FD;
581 Adapter->Media[MEDIA_BNC].Csr15 = 0x0006;
582
583 Adapter->Media[MEDIA_AUI].Csr13 = 0xEF09;
584 Adapter->Media[MEDIA_AUI].Csr14 = 0xF7FD;
585 Adapter->Media[MEDIA_AUI].Csr15 = 0x000E;
586
587 Adapter->Media[MEDIA_10T_HD].Csr13 = 0xEF01;
588 Adapter->Media[MEDIA_10T_HD].Csr14 = 0x7F3F;
589 Adapter->Media[MEDIA_10T_HD].Csr15 = 0x0008;
590
591 Adapter->Media[MEDIA_10T_FD].Csr13 = 0xEF01;
592 Adapter->Media[MEDIA_10T_FD].Csr14 = 0x7F3D;
593 Adapter->Media[MEDIA_10T_FD].Csr15 = 0x0008;
594 Adapter->Media[MEDIA_10T_FD].OpMode = DC_OPMODE_FULL_DUPLEX;
595 break;
596 }
597
598 case DC21140:
599 {
600 MediaInitOpMode2114x(Adapter);
601 break;
602 }
603
604 case DC21143:
605 case DC21145:
606 {
607 Adapter->Media[MEDIA_10T].Csr13 = 0x0001;
608 Adapter->Media[MEDIA_10T].Csr14 = 0x7F3F;
609 Adapter->Media[MEDIA_10T].Csr15 = 0x0008;
610
611 Adapter->Media[MEDIA_BNC].Csr13 = 0x0009;
612 Adapter->Media[MEDIA_BNC].Csr14 = 0x0705;
613 Adapter->Media[MEDIA_BNC].Csr15 = 0x0006;
614
615 Adapter->Media[MEDIA_AUI].Csr13 = 0x0009;
616 Adapter->Media[MEDIA_AUI].Csr14 = 0x0705;
617 Adapter->Media[MEDIA_AUI].Csr15 = 0x000E;
618
619 Adapter->Media[MEDIA_10T_FD].Csr13 = 0x0001;
620 Adapter->Media[MEDIA_10T_FD].Csr14 = 0x7F3D;
621 Adapter->Media[MEDIA_10T_FD].Csr15 = 0x0008;
622
623 Adapter->Media[MEDIA_HMR].Csr13 = 0x0009;
624 Adapter->Media[MEDIA_HMR].Csr14 = 0x0505;
625 Adapter->Media[MEDIA_HMR].Csr15 = 0x0010;
626
627 MediaInitOpMode2114x(Adapter);
628 break;
629 }
630
631 default:
632 break;
633 }
634}
static VOID MediaInitOpMode2114x(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:519
#define MEDIA_10T_HD
Definition: media.h:50

Referenced by DcInitialize().

◆ MediaMiiCheckLink()

BOOLEAN MediaMiiCheckLink ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 141 of file media.c.

143{
144 ULONG MiiStatus;
145 BOOLEAN FullDuplex, Speed100;
146
147 /* The link status is a latched-low bit, read it twice */
148 if (!MiiRead(Adapter, Adapter->PhyAddress, MII_STATUS, &MiiStatus))
149 {
150 goto NoLink;
151 }
152 if (!(MiiStatus & MII_SR_LINK_STATUS))
153 {
154 MiiRead(Adapter, Adapter->PhyAddress, MII_STATUS, &MiiStatus);
155 }
156 TRACE("MII Status %04lx\n", MiiStatus);
157
158 /* Check the link status */
159 if (!(MiiStatus & MII_SR_LINK_STATUS))
160 {
161NoLink:
162 /* No link detected, check the other port */
163 if (Adapter->MediaBitmap & ((1 << MEDIA_HMR) | (1 << MEDIA_AUI) | (1 << MEDIA_BNC)))
164 {
165 if ((Adapter->Features & DC_MII_AUTOSENSE) && !MEDIA_IS_FIXED(Adapter))
166 {
167 Adapter->MediaNumber = MediaMiiNextMedia(Adapter);
168 MediaSiaSelect(Adapter);
169 }
170 }
171
172 return FALSE;
173 }
174
175 /* If we are forcing speed and duplex */
176 if (MEDIA_IS_FIXED(Adapter))
177 {
178 FullDuplex = !!(Adapter->MiiControl & MII_CR_FULL_DUPLEX);
179 Speed100 = !!(Adapter->MiiControl & MII_CR_SPEED_SELECTION);
180 }
181 else
182 {
183 /* Check auto-negotiation is complete */
184 if (!(MiiStatus & MII_SR_AUTONEG_COMPLETE))
185 return FALSE;
186
187 MediaMiiGetSpeedAndDuplex(Adapter, &FullDuplex, &Speed100);
188 }
189
190 /* Set the link speed and duplex */
191 MediaMiiSetSpeedAndDuplex(Adapter, FullDuplex, Speed100);
192
193 return TRUE;
194}
#define DC_MII_AUTOSENSE
Definition: dc21x4.h:116
BOOLEAN MiiRead(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _Out_ PULONG Data)
Definition: phy.c:101
#define MII_SR_AUTONEG_COMPLETE
Definition: dc21x4hw.h:568
#define MII_SR_LINK_STATUS
Definition: dc21x4hw.h:567
static VOID MediaMiiGetSpeedAndDuplex(_In_ PDC21X4_ADAPTER Adapter, _Out_ PBOOLEAN FullDuplex, _Out_ PBOOLEAN Speed100)
Definition: media.c:101
static VOID MediaMiiSetSpeedAndDuplex(_In_ PDC21X4_ADAPTER Adapter, _In_ BOOLEAN FullDuplex, _In_ BOOLEAN Speed100)
Definition: media.c:64
VOID MediaSiaSelect(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:268
static ULONG MediaMiiNextMedia(_In_ PDC21X4_ADAPTER Adapter)
Definition: media.c:44

Referenced by MediaMonitor21140Dpc(), and MediaMonitor21143Dpc().

◆ MediaMiiSelect()

VOID MediaMiiSelect ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 197 of file media.c.

199{
200 ULONG MiiControl, MiiAdvertise;
201
202 MiiRead(Adapter, Adapter->PhyAddress, MII_CONTROL, &MiiControl);
205 MiiWrite(Adapter, Adapter->PhyAddress, MII_CONTROL, MiiControl);
206
207 MiiControl |= Adapter->MiiControl;
208 MiiAdvertise = Adapter->MiiAdvertising;
209
210 MiiWrite(Adapter, Adapter->PhyAddress, MII_AUTONEG_ADVERTISE, MiiAdvertise | MII_ADV_CSMA);
211 MiiWrite(Adapter, Adapter->PhyAddress, MII_CONTROL, MiiControl);
212}
BOOLEAN MiiWrite(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG PhyAddress, _In_ ULONG RegAddress, _In_ ULONG Data)
Definition: phy.c:78
#define MII_ADV_CSMA
Definition: dc21x4hw.h:572
#define MII_CR_POWER_DOWN
Definition: dc21x4hw.h:561
#define MII_CR_RESET
Definition: dc21x4hw.h:565
#define MII_CR_ISOLATE
Definition: dc21x4hw.h:560

Referenced by DcSetupAdapter(), and Media143SelectNextSerialMedia().

◆ MediaSelectMiiPort()

VOID MediaSelectMiiPort ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ BOOLEAN  ResetPhy 
)

Definition at line 215 of file media.c.

218{
219 ULONG OpMode, i;
220
221 if (Adapter->ChipType != DC21140)
222 {
223 DcWriteSia(Adapter, 0, 0, 0);
224 }
225
226 OpMode = Adapter->OpMode;
227 OpMode &= ~DC_OPMODE_MEDIA_MASK;
229 Adapter->OpMode = OpMode;
230
231 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
232
234
235 if (ResetPhy)
236 {
238
239 /* Execute the GPIO reset sequence */
240 if (Adapter->MiiMedia.ResetStreamLength)
241 {
242 /* Set the GPIO direction */
243 DcWriteGpio(Adapter, Adapter->MiiMedia.SetupStream[0]);
244
245 for (i = 0; i < Adapter->MiiMedia.ResetStreamLength; ++i)
246 {
247 NdisMSleep(100);
248 DcWriteGpio(Adapter, Adapter->MiiMedia.ResetStream[i]);
249 }
250
251 /* Give the PHY some time to reset */
252 NdisMSleep(5000);
253 }
254 }
255
256 /* Set the GPIO direction */
257 DcWriteGpio(Adapter, Adapter->MiiMedia.SetupStream[0]);
258
259 /* Execute the GPIO setup sequence */
260 for (i = 1; i < Adapter->MiiMedia.SetupStreamLength; ++i)
261 {
263 DcWriteGpio(Adapter, Adapter->MiiMedia.SetupStream[i]);
264 }
265}
VOID DcWriteSia(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Csr13, _In_ ULONG Csr14, _In_ ULONG Csr15)
Definition: hardware.c:89
#define DC_OPMODE_PORT_HEARTBEAT_DISABLE
Definition: dc21x4hw.h:335
#define DC_OPMODE_PORT_SELECT
Definition: dc21x4hw.h:334
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

Referenced by DcInitialize(), DcSetupAdapter(), and Media143SelectNextSerialMedia().

◆ MediaSiaSelect()

VOID MediaSiaSelect ( _In_ PDC21X4_ADAPTER  Adapter)

Definition at line 268 of file media.c.

270{
271 ULONG OpMode;
272 PDC_MEDIA Media;
273
274 INFO_VERB("Selected media %s\n",
275 MediaNumber2Str(Adapter, Adapter->MediaNumber));
276
277 Media = &Adapter->Media[Adapter->MediaNumber];
278
279 DcStopTxRxProcess(Adapter);
280
281 if (Adapter->ChipType != DC21041)
282 {
283 /* Make sure the reset pulse is wide enough */
285 DcWriteGpio(Adapter, Media->GpioCtrl);
287 DcWriteGpio(Adapter, Media->GpioData);
288 }
289
290 DcWriteSia(Adapter, Media->Csr13, Media->Csr14, Media->Csr15);
291
293
294 OpMode = Adapter->OpMode;
295 OpMode &= ~DC_OPMODE_MEDIA_MASK;
296 OpMode |= Media->OpMode;
297 Adapter->OpMode = OpMode;
298
299 DC_WRITE(Adapter, DcCsr6_OpMode, OpMode);
300}
ULONG Csr14
Definition: media.h:22
USHORT GpioCtrl
Definition: media.h:14
ULONG Csr13
Definition: media.h:21
ULONG Csr15
Definition: media.h:23

Referenced by DcSetupAdapter(), Media041SelectNextMedia(), Media143Handle10LinkPass(), Media143HandleNWayComplete(), Media143SelectNextMedia(), Media143SelectNextSerialMedia(), MediaLinkStateChange21041(), MediaMiiCheckLink(), and MediaMonitor21041Dpc().

◆ MiiRead()

BOOLEAN MiiRead ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  PhyAddress,
_In_ ULONG  RegAddress,
_Out_ PULONG  Data 
)

Definition at line 101 of file phy.c.

106{
107 ULONG Csr;
109
110 MiiMdioPacket(Adapter, MDIO_PREAMBLE, 32);
111 MiiMdioPacket(Adapter,
112 (MDIO_START << 12) |
113 (MDIO_READ << 10) |
114 (PhyAddress << 5) |
115 RegAddress,
116 14);
117
118 /* Turnaround */
119 MiiMdioClearExtraBits(Adapter);
120
121 Csr = DC_READ(Adapter, DcCsr9_SerialInterface);
122 Success = !(Csr & DC_SERIAL_MII_MDI);
123
124 *Data = MiiMdioShiftIn(Adapter);
125
126 /* Idle state */
127 MiiMdioClearExtraBits(Adapter);
128
129 return Success;
130}
static VOID MiiMdioClearExtraBits(_In_ PDC21X4_ADAPTER Adapter)
Definition: phy.c:70
static ULONG MiiMdioShiftIn(_In_ PDC21X4_ADAPTER Adapter)
Definition: phy.c:50
static VOID MiiMdioPacket(_In_ PDC21X4_ADAPTER Adapter, _In_ ULONG Sequence, _In_ ULONG BitCount)
Definition: phy.c:32
#define MDIO_PREAMBLE
Definition: dc21x4hw.h:549
#define MDIO_START
Definition: dc21x4hw.h:545
@ DcCsr9_SerialInterface
Definition: dc21x4hw.h:183
#define DC_SERIAL_MII_MDI
Definition: dc21x4hw.h:385
#define MDIO_READ
Definition: dc21x4hw.h:547

Referenced by DcFindMiiPhy(), FindPhyDevice(), MediaMiiCheckLink(), MediaMiiGetSpeedAndDuplex(), MediaMiiSelect(), MiiGetSpeedAndDuplex(), NvNetInitNIC(), NvNetPhyInit(), NvNetSetSpeedAndDuplex(), PhyInit(), PhyInitCicadaSemiconductor(), PhyInitRealtek8201(), PhyInitRealtek8211c(), PhyInitVitesseSemiconductor(), and PhyReset().

◆ MiiWrite()

BOOLEAN MiiWrite ( _In_ PDC21X4_ADAPTER  Adapter,
_In_ ULONG  PhyAddress,
_In_ ULONG  RegAddress,
_In_ ULONG  Data 
)

Definition at line 78 of file phy.c.

83{
84 MiiMdioPacket(Adapter, MDIO_PREAMBLE, 32);
85 MiiMdioPacket(Adapter,
86 (MDIO_START << 30) |
87 (MDIO_WRITE << 28) |
88 (PhyAddress << 23) |
89 (RegAddress << 18) |
90 (MDIO_TA << 16) |
91 Data,
92 32);
93
94 /* Idle state */
95 MiiMdioClearExtraBits(Adapter);
96
97 return TRUE;
98}
#define MDIO_TA
Definition: dc21x4hw.h:548
#define MDIO_WRITE
Definition: dc21x4hw.h:546

Referenced by MediaMiiSelect(), NvNetInitNIC(), PhyInit(), PhyInitCicadaSemiconductor(), PhyInitRealtek8201(), PhyInitRealtek8211b(), PhyInitRealtek8211c(), PhyInitVitesseSemiconductor(), and PhyReset().

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 276 of file dc21x4.h.

◆ MediaLinkStateChange21040

MEDIA_HANDLE_LINK_STATE_CHANGE MediaLinkStateChange21040

Definition at line 502 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ MediaLinkStateChange21041

MEDIA_HANDLE_LINK_STATE_CHANGE MediaLinkStateChange21041

Definition at line 503 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ MediaLinkStateChange21143

MEDIA_HANDLE_LINK_STATE_CHANGE MediaLinkStateChange21143

Definition at line 504 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ MediaMonitor21040Dpc

NDIS_TIMER_FUNCTION MediaMonitor21040Dpc

Definition at line 497 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ MediaMonitor21041Dpc

NDIS_TIMER_FUNCTION MediaMonitor21041Dpc

Definition at line 498 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ MediaMonitor21140Dpc

NDIS_TIMER_FUNCTION MediaMonitor21140Dpc

Definition at line 499 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ MediaMonitor21143Dpc

NDIS_TIMER_FUNCTION MediaMonitor21143Dpc

Definition at line 500 of file dc21x4.h.

Referenced by DcRecognizeHardware().

◆ SRompAdapterList

LIST_ENTRY SRompAdapterList
extern

Definition at line 30 of file eeprom.c.

Referenced by DriverEntry(), SRomIsAdapterInList(), and SRomRegisterMasterAdapter().