ReactOS  0.4.14-dev-1112-g2b067d6
pcnet.c File Reference
#include "pcnet.h"
#include <debug.h>
Include dependency graph for pcnet.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
static VOID NTAPI MiniportHandleInterrupt (IN NDIS_HANDLE MiniportAdapterContext)
 
static NDIS_STATUS MiQueryCard (IN PADAPTER Adapter)
 
static VOID MiFreeSharedMemory (PADAPTER Adapter)
 
static NDIS_STATUS MiAllocateSharedMemory (PADAPTER Adapter)
 
static VOID MiPrepareInitializationBlock (PADAPTER Adapter)
 
static BOOLEAN NTAPI MiSyncStop (IN PVOID SynchronizeContext)
 
static VOID NTAPI MiniportHalt (IN NDIS_HANDLE MiniportAdapterContext)
 
static BOOLEAN NTAPI MiSyncMediaDetection (IN PVOID SynchronizeContext)
 
static VOID NTAPI MiniportMediaDetectionTimer (IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
 
static VOID MiInitChip (PADAPTER Adapter)
 
VOID NTAPI MiniportShutdown (PVOID Context)
 
static NDIS_STATUS NTAPI MiniportInitialize (OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT MediumArraySize, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE WrapperConfigurationContext)
 
static VOID NTAPI MiniportISR (OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext)
 
static NDIS_STATUS NTAPI MiniportReset (OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext)
 
static BOOLEAN NTAPI MiSyncStartTransmit (IN PVOID SynchronizeContext)
 
static NDIS_STATUS NTAPI MiniportSend (IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags)
 
static ULONG NTAPI MiEthernetCrc (UCHAR *Address)
 
NDIS_STATUS NTAPI MiSetMulticast (PADAPTER Adapter, UCHAR *Addresses, UINT AddressCount)
 
BOOLEAN NTAPI MiGetMediaDuplex (PADAPTER Adapter)
 
UINT NTAPI MiGetMediaSpeed (PADAPTER Adapter)
 
NDIS_MEDIA_STATE NTAPI MiGetMediaState (PADAPTER Adapter)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 43 of file pcnet.c.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 1327 of file pcnet.c.

1342 {
1343  NDIS_HANDLE WrapperHandle;
1344  NDIS_MINIPORT_CHARACTERISTICS Characteristics;
1346 
1347  RtlZeroMemory(&Characteristics, sizeof(Characteristics));
1348  Characteristics.MajorNdisVersion = NDIS_MINIPORT_MAJOR_VERSION;
1349  Characteristics.MinorNdisVersion = NDIS_MINIPORT_MINOR_VERSION;
1350  Characteristics.HaltHandler = MiniportHalt;
1351  Characteristics.HandleInterruptHandler = MiniportHandleInterrupt;
1352  Characteristics.InitializeHandler = MiniportInitialize;
1353  Characteristics.ISRHandler = MiniportISR;
1354  Characteristics.QueryInformationHandler = MiniportQueryInformation;
1355  Characteristics.ResetHandler = MiniportReset;
1356  Characteristics.SetInformationHandler = MiniportSetInformation;
1357  Characteristics.SendHandler = MiniportSend;
1358 
1359  NdisMInitializeWrapper(&WrapperHandle, DriverObject, RegistryPath, 0);
1360  if (!WrapperHandle) return NDIS_STATUS_FAILURE;
1361 
1362  Status = NdisMRegisterMiniport(WrapperHandle, &Characteristics, sizeof(Characteristics));
1364  {
1365  NdisTerminateWrapper(WrapperHandle, 0);
1366  return NDIS_STATUS_FAILURE;
1367  }
1368 
1369  return NDIS_STATUS_SUCCESS;
1370 }
static VOID NTAPI MiniportISR(OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext)
Definition: pcnet.c:1050
int NDIS_STATUS
Definition: ntddndis.h:471
static NDIS_STATUS NTAPI MiniportInitialize(OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, IN UINT MediumArraySize, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: pcnet.c:853
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
VOID EXPORT NdisTerminateWrapper(IN NDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific)
Definition: miniport.c:3012
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
static VOID NTAPI MiniportHalt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: pcnet.c:570
static NDIS_STATUS NTAPI MiniportSend(IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags)
Definition: pcnet.c:1144
Status
Definition: gdiplustypes.h:24
NDIS_STATUS NTAPI MiniportSetInformation(IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesRead, OUT PULONG BytesNeeded)
Definition: info.c:232
static VOID NTAPI MiniportHandleInterrupt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: pcnet.c:54
static NDIS_STATUS NTAPI MiniportReset(OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext)
Definition: pcnet.c:1103
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:28
#define NdisMInitializeWrapper(NdisWrapperHandle, SystemSpecific1, SystemSpecific2, SystemSpecific3)
Definition: ndis.h:5592
NDIS_STATUS EXPORT NdisMRegisterMiniport(IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, IN UINT CharacteristicsLength)
Definition: miniport.c:2637
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
NDIS_STATUS NTAPI MiniportQueryInformation(IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
Definition: info.c:51

◆ MiAllocateSharedMemory()

static NDIS_STATUS MiAllocateSharedMemory ( PADAPTER  Adapter)
static

Definition at line 353 of file pcnet.c.

363 {
364  PTRANSMIT_DESCRIPTOR TransmitDescriptor;
365  PRECEIVE_DESCRIPTOR ReceiveDescriptor;
367  ULONG i;
368  ULONG BufferCount = NUMBER_OF_BUFFERS;
369  ULONG LogBufferCount = LOG_NUMBER_OF_BUFFERS;
370 
371  while (BufferCount != 0)
372  {
373  /* allocate the initialization block (we have this in the loop so we can use MiFreeSharedMemory) */
377  if(!Adapter->InitializationBlockVirt)
378  {
379  /* Buffer backoff won't help us here */
380  DPRINT1("insufficient resources\n");
381  return NDIS_STATUS_RESOURCES;
382  }
383 
384  if (((ULONG_PTR)Adapter->InitializationBlockVirt & 0x00000003) != 0)
385  {
386  DPRINT1("address 0x%x not dword-aligned\n", Adapter->InitializationBlockVirt);
387  return NDIS_STATUS_RESOURCES;
388  }
389 
391 
392  /* allocate the transport descriptor ring */
393  Adapter->TransmitDescriptorRingLength = sizeof(TRANSMIT_DESCRIPTOR) * BufferCount;
396  if (!Adapter->TransmitDescriptorRingVirt)
397  {
398  DPRINT1("Backing off buffer count by %d buffers due to allocation failure\n", (BufferCount >> 1));
399  BufferCount = BufferCount >> 1;
400  LogBufferCount--;
401  MiFreeSharedMemory(Adapter);
402  continue;
403  }
404 
405  if (((ULONG_PTR)Adapter->TransmitDescriptorRingVirt & 0x00000003) != 0)
406  {
407  DPRINT1("address 0x%x not dword-aligned\n", Adapter->TransmitDescriptorRingVirt);
408  return NDIS_STATUS_RESOURCES;
409  }
410 
412  RtlZeroMemory(Adapter->TransmitDescriptorRingVirt, sizeof(TRANSMIT_DESCRIPTOR) * BufferCount);
413 
414  /* allocate the receive descriptor ring */
415  Adapter->ReceiveDescriptorRingLength = sizeof(RECEIVE_DESCRIPTOR) * BufferCount;
418  if (!Adapter->ReceiveDescriptorRingVirt)
419  {
420  DPRINT1("Backing off buffer count by %d buffers due to allocation failure\n", (BufferCount >> 1));
421  BufferCount = BufferCount >> 1;
422  LogBufferCount--;
423  MiFreeSharedMemory(Adapter);
424  continue;
425  }
426 
427  if (((ULONG_PTR)Adapter->ReceiveDescriptorRingVirt & 0x00000003) != 0)
428  {
429  DPRINT1("address 0x%x not dword-aligned\n", Adapter->ReceiveDescriptorRingVirt);
430  return NDIS_STATUS_RESOURCES;
431  }
432 
434  RtlZeroMemory(Adapter->ReceiveDescriptorRingVirt, sizeof(RECEIVE_DESCRIPTOR) * BufferCount);
435 
436  /* allocate transmit buffers */
437  Adapter->TransmitBufferLength = BUFFER_SIZE * BufferCount;
440  if(!Adapter->TransmitBufferPtrVirt)
441  {
442  DPRINT1("Backing off buffer count by %d buffers due to allocation failure\n", (BufferCount >> 1));
443  BufferCount = BufferCount >> 1;
444  LogBufferCount--;
445  MiFreeSharedMemory(Adapter);
446  continue;
447  }
448 
449  if(((ULONG_PTR)Adapter->TransmitBufferPtrVirt & 0x00000003) != 0)
450  {
451  DPRINT1("address 0x%x not dword-aligned\n", Adapter->TransmitBufferPtrVirt);
452  return NDIS_STATUS_RESOURCES;
453  }
454 
456  RtlZeroMemory(Adapter->TransmitBufferPtrVirt, BUFFER_SIZE * BufferCount);
457 
458  /* allocate receive buffers */
459  Adapter->ReceiveBufferLength = BUFFER_SIZE * BufferCount;
462  if(!Adapter->ReceiveBufferPtrVirt)
463  {
464  DPRINT1("Backing off buffer count by %d buffers due to allocation failure\n", (BufferCount >> 1));
465  BufferCount = BufferCount >> 1;
466  LogBufferCount--;
467  MiFreeSharedMemory(Adapter);
468  continue;
469  }
470 
471  if (((ULONG_PTR)Adapter->ReceiveBufferPtrVirt & 0x00000003) != 0)
472  {
473  DPRINT1("address 0x%x not dword-aligned\n", Adapter->ReceiveBufferPtrVirt);
474  return NDIS_STATUS_RESOURCES;
475  }
476 
478  RtlZeroMemory(Adapter->ReceiveBufferPtrVirt, BUFFER_SIZE * BufferCount);
479 
480  break;
481  }
482 
483  if (!BufferCount)
484  {
485  DPRINT1("Failed to allocate adapter buffers\n");
486  return NDIS_STATUS_RESOURCES;
487  }
488 
489  Adapter->BufferCount = BufferCount;
490  Adapter->LogBufferCount = LogBufferCount;
491 
492  /* initialize tx descriptors */
493  TransmitDescriptor = Adapter->TransmitDescriptorRingVirt;
494  for(i = 0; i < BufferCount; i++)
495  {
496  (TransmitDescriptor+i)->TBADR = Adapter->TransmitBufferPtrPhys.QuadPart + i * BUFFER_SIZE;
497  (TransmitDescriptor+i)->BCNT = 0xf000 | -BUFFER_SIZE; /* 2's compliment + set top 4 bits */
498  (TransmitDescriptor+i)->FLAGS = TD1_STP | TD1_ENP;
499  }
500 
501  DPRINT("transmit ring initialized\n");
502 
503  /* initialize rx */
504  ReceiveDescriptor = Adapter->ReceiveDescriptorRingVirt;
505  for(i = 0; i < BufferCount; i++)
506  {
507  (ReceiveDescriptor+i)->RBADR = Adapter->ReceiveBufferPtrPhys.QuadPart + i * BUFFER_SIZE;
508  (ReceiveDescriptor+i)->BCNT = 0xf000 | -BUFFER_SIZE; /* 2's compliment + set top 4 bits */
509  (ReceiveDescriptor+i)->FLAGS = RD_OWN;
510  }
511 
512  DPRINT("receive ring initialized\n");
513 
514  return NDIS_STATUS_SUCCESS;
515 }
#define LOG_NUMBER_OF_BUFFERS
Definition: pcnet.h:153
struct _TRANSMIT_DESCRIPTOR TRANSMIT_DESCRIPTOR
#define TD1_ENP
Definition: pcnethw.h:398
#define TRUE
Definition: types.h:120
VOID EXPORT NdisMAllocateSharedMemory(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, IN BOOLEAN Cached, OUT PVOID *VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
Definition: memory.c:148
ULONG ReceiveDescriptorRingLength
Definition: pcnet.h:95
PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
Definition: pcnet.h:86
PHYSICAL_ADDRESS TransmitDescriptorRingPhys
Definition: pcnet.h:87
#define TD1_STP
Definition: pcnethw.h:399
ULONG TransmitBufferLength
Definition: pcnet.h:90
PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt
Definition: pcnet.h:96
PCHAR ReceiveBufferPtrVirt
Definition: pcnet.h:101
ULONG BufferCount
Definition: pcnet.h:105
uint32_t ULONG_PTR
Definition: typedefs.h:64
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
struct _RECEIVE_DESCRIPTOR RECEIVE_DESCRIPTOR
ULONG LogBufferCount
Definition: pcnet.h:106
PHYSICAL_ADDRESS ReceiveBufferPtrPhys
Definition: pcnet.h:102
PHYSICAL_ADDRESS TransmitBufferPtrPhys
Definition: pcnet.h:92
void DPRINT(...)
Definition: polytest.cpp:61
ULONG InitializationBlockLength
Definition: pcnet.h:80
#define RD_OWN
Definition: pcnethw.h:383
static VOID MiFreeSharedMemory(PADAPTER Adapter)
Definition: pcnet.c:301
NDIS_HANDLE MiniportAdapterHandle
Definition: pcnet.h:61
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
ULONG TransmitDescriptorRingLength
Definition: pcnet.h:85
#define NUMBER_OF_BUFFERS
Definition: pcnet.h:152
ULONG ReceiveBufferLength
Definition: pcnet.h:100
PHYSICAL_ADDRESS ReceiveDescriptorRingPhys
Definition: pcnet.h:97
struct _INITIALIZATION_BLOCK INITIALIZATION_BLOCK
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
#define DPRINT1
Definition: precomp.h:8
PHYSICAL_ADDRESS InitializationBlockPhys
Definition: pcnet.h:82
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG FLAGS
Definition: mapi.h:36
PCHAR TransmitBufferPtrVirt
Definition: pcnet.h:91
LONGLONG QuadPart
Definition: typedefs.h:113

Referenced by MiniportInitialize().

◆ MiEthernetCrc()

static ULONG NTAPI MiEthernetCrc ( UCHAR Address)
static

Definition at line 1235 of file pcnet.c.

1243 {
1244  UINT Counter, Length;
1245  ULONG Value = ~0;
1246 
1247  for (Length = 0; Length < 6; Length++)
1248  {
1249  Value ^= *Address++;
1250  for (Counter = 0; Counter < 8; Counter++)
1251  {
1252  Value >>= 1;
1253  Value ^= (Value & 1) * 0xedb88320;
1254  }
1255  }
1256 
1257  return Value;
1258 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2374
static WCHAR Address[46]
Definition: ping.c:68
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned int UINT
Definition: ndis.h:50
static LARGE_INTEGER Counter
Definition: clock.c:43
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiSetMulticast().

◆ MiFreeSharedMemory()

static VOID MiFreeSharedMemory ( PADAPTER  Adapter)
static

Definition at line 301 of file pcnet.c.

308 {
310 
311  if(Adapter->InitializationBlockVirt)
312  {
316  Adapter->InitializationBlockVirt = NULL;
317  }
318 
319  if(Adapter->TransmitDescriptorRingVirt)
320  {
324  Adapter->TransmitDescriptorRingVirt = NULL;
325  }
326 
327  if(Adapter->ReceiveDescriptorRingVirt)
328  {
332  Adapter->ReceiveDescriptorRingVirt = NULL;
333  }
334 
335  if(Adapter->TransmitBufferPtrVirt)
336  {
340  Adapter->TransmitBufferPtrVirt = NULL;
341  }
342 
343  if(Adapter->ReceiveBufferPtrVirt)
344  {
348  Adapter->ReceiveBufferPtrVirt = NULL;
349  }
350 }
#define TRUE
Definition: types.h:120
ULONG ReceiveDescriptorRingLength
Definition: pcnet.h:95
PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
Definition: pcnet.h:86
PHYSICAL_ADDRESS TransmitDescriptorRingPhys
Definition: pcnet.h:87
ULONG TransmitBufferLength
Definition: pcnet.h:90
PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt
Definition: pcnet.h:96
PCHAR ReceiveBufferPtrVirt
Definition: pcnet.h:101
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
PHYSICAL_ADDRESS ReceiveBufferPtrPhys
Definition: pcnet.h:102
PHYSICAL_ADDRESS TransmitBufferPtrPhys
Definition: pcnet.h:92
smooth NULL
Definition: ftsmooth.c:416
ULONG InitializationBlockLength
Definition: pcnet.h:80
NDIS_HANDLE MiniportAdapterHandle
Definition: pcnet.h:61
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1061
ULONG TransmitDescriptorRingLength
Definition: pcnet.h:85
ULONG ReceiveBufferLength
Definition: pcnet.h:100
PHYSICAL_ADDRESS ReceiveDescriptorRingPhys
Definition: pcnet.h:97
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
PHYSICAL_ADDRESS InitializationBlockPhys
Definition: pcnet.h:82
PCHAR TransmitBufferPtrVirt
Definition: pcnet.h:91

Referenced by MiAllocateSharedMemory(), MiniportHalt(), and MiniportInitialize().

◆ MiGetMediaDuplex()

BOOLEAN NTAPI MiGetMediaDuplex ( PADAPTER  Adapter)

Definition at line 1285 of file pcnet.c.

1286 {
1287  ULONG Data;
1288 
1290  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
1291 
1292  return (Data & BCR5_LEDOUT) != 0;
1293 }
#define RAP
Definition: pcnethw.h:48
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
#define BCR5
Definition: pcnethw.h:140
#define BCR5_LEDOUT
Definition: pcnethw.h:285
unsigned int ULONG
Definition: retypes.h:1
#define BDP
Definition: pcnethw.h:49

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiGetMediaSpeed()

UINT NTAPI MiGetMediaSpeed ( PADAPTER  Adapter)

Definition at line 1297 of file pcnet.c.

1298 {
1299  ULONG Data;
1300 
1302  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
1303 
1304  return Data & BCR6_LEDOUT ? 100 : 10;
1305 }
#define BCR6
Definition: pcnethw.h:141
#define RAP
Definition: pcnethw.h:48
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define BCR6_LEDOUT
Definition: pcnethw.h:301
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
unsigned int ULONG
Definition: retypes.h:1
#define BDP
Definition: pcnethw.h:49

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiGetMediaState()

NDIS_MEDIA_STATE NTAPI MiGetMediaState ( PADAPTER  Adapter)

Definition at line 1309 of file pcnet.c.

1318 {
1319  ULONG Data;
1321  NdisRawReadPortUshort(Adapter->PortOffset + BDP, &Data);
1323 }
#define RAP
Definition: pcnethw.h:48
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define BCR4
Definition: pcnethw.h:139
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
unsigned int ULONG
Definition: retypes.h:1
#define BDP
Definition: pcnethw.h:49
#define BCR4_LEDOUT
Definition: pcnethw.h:269

Referenced by MiInitChip(), and MiSyncMediaDetection().

◆ MiInitChip()

static VOID MiInitChip ( PADAPTER  Adapter)
static

Definition at line 675 of file pcnet.c.

685 {
686  USHORT Data = 0;
687 
688  DPRINT("Called\n");
689 
690  /*
691  * first reset the chip - 32-bit reset followed by 16-bit reset. if it's in 32-bit mode, it'll reset
692  * twice. if it's in 16-bit mode, the first read will be nonsense and the second will be a reset. the
693  * card is reset by reading from the reset register. on reset it's in 16-bit i/o mode.
694  */
697 
698  /* stop the chip */
701 
702  /* pause for 1ms so the chip will have time to reset */
704 
705  DPRINT("chip stopped\n");
706 
707  /* set the software style to 2 (32 bits) */
710 
711  Data |= SW_STYLE_2;
712 
714 
715  /* set up csr4: auto transmit pad, disable polling, disable transmit interrupt, dmaplus */
718 
719  Data |= CSR4_APAD_XMT | /* CSR4_DPOLL |*/ CSR4_TXSTRTM | CSR4_DMAPLUS;
721 
722  /* set up bcr18: burst read/write enable */
725 
728 
729  /* set up csr1 and csr2 with init block */
733  NdisRawWritePortUshort(Adapter->PortOffset + RDP, (USHORT)(Adapter->InitializationBlockPhys.LowPart >> 16) & 0xffff);
734 
735  DPRINT("programmed with init block\n");
736 
737  /* Set mode to 0 */
738  Data = 0;
741 
742  /* load init block and start the card */
745 
746  /* Allow LED programming */
749 
750  /* LED0 is configured for link status (on = up, off = down) */
753 
754  /* LED1 is configured for link duplex (on = full, off = half) */
757 
758  /* LED2 is configured for link speed (on = 100M, off = 10M) */
761 
762  /* LED3 is configured for trasmit/receive activity */
765 
766  Adapter->MediaState = MiGetMediaState(Adapter);
767  Adapter->FullDuplex = MiGetMediaDuplex(Adapter);
768  Adapter->MediaSpeed = MiGetMediaSpeed(Adapter);
769 
770  DPRINT("card started\n");
771 
772  Adapter->Flags &= ~RESET_IN_PROGRESS;
773 }
#define BCR7_XMTE
Definition: pcnethw.h:308
#define BCR18_BREADE
Definition: pcnethw.h:326
#define CSR4
Definition: pcnethw.h:67
#define RESET32
Definition: pcnethw.h:44
#define BCR6
Definition: pcnethw.h:141
#define CSR1
Definition: pcnethw.h:64
#define CSR4_APAD_XMT
Definition: pcnethw.h:195
#define BCR5_PSE
Definition: pcnethw.h:279
#define BCR6_E100
Definition: pcnethw.h:298
#define BCR5_FDLSE
Definition: pcnethw.h:280
#define RAP
Definition: pcnethw.h:48
#define BCR7
Definition: pcnethw.h:142
UINT MediaSpeed
Definition: pcnet.h:68
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
#define CSR0
Definition: pcnethw.h:63
#define BCR4_PSE
Definition: pcnethw.h:263
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define CSR0_IENA
Definition: pcnethw.h:159
#define BCR4
Definition: pcnethw.h:139
#define BCR2
Definition: pcnethw.h:138
#define CSR58
Definition: pcnethw.h:110
#define BCR7_RCVE
Definition: pcnethw.h:306
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
#define BCR7_PSE
Definition: pcnethw.h:311
#define CSR15
Definition: pcnethw.h:77
#define CSR2
Definition: pcnethw.h:65
void DPRINT(...)
Definition: polytest.cpp:61
#define BCR5
Definition: pcnethw.h:140
#define BCR6_PSE
Definition: pcnethw.h:295
#define CSR4_DMAPLUS
Definition: pcnethw.h:198
BOOLEAN NTAPI MiGetMediaDuplex(PADAPTER Adapter)
Definition: pcnet.c:1285
#define CSR0_STOP
Definition: pcnethw.h:155
#define BCR18
Definition: pcnethw.h:146
NDIS_MEDIA_STATE NTAPI MiGetMediaState(PADAPTER Adapter)
Definition: pcnet.c:1309
ULONG LowPart
Definition: typedefs.h:105
#define SW_STYLE_2
Definition: pcnethw.h:59
#define RESET16
Definition: pcnethw.h:40
#define RESET_IN_PROGRESS
Definition: pcnet.h:159
unsigned short USHORT
Definition: pedump.c:61
ULONG Flags
Definition: pcnet.h:62
#define RDP
Definition: pcnethw.h:37
UINT NTAPI MiGetMediaSpeed(PADAPTER Adapter)
Definition: pcnet.c:1297
PHYSICAL_ADDRESS InitializationBlockPhys
Definition: pcnet.h:82
#define BCR18_BWRITE
Definition: pcnethw.h:325
#define CSR4_TXSTRTM
Definition: pcnethw.h:186
#define BCR2_LEDPE
Definition: pcnethw.h:252
#define CSR0_STRT
Definition: pcnethw.h:154
BOOLEAN FullDuplex
Definition: pcnet.h:69
#define BCR4_LNKSTE
Definition: pcnethw.h:262
#define NdisStallExecution
Definition: ndis.h:4453
#define CSR0_INIT
Definition: pcnethw.h:153
NDIS_MEDIA_STATE MediaState
Definition: pcnet.h:67
#define BDP
Definition: pcnethw.h:49

Referenced by MiniportInitialize().

◆ MiniportHalt()

static VOID NTAPI MiniportHalt ( IN NDIS_HANDLE  MiniportAdapterContext)
static

Definition at line 570 of file pcnet.c.

579 {
580  PADAPTER Adapter = (PADAPTER)MiniportAdapterContext;
582 
583  DPRINT("Called\n");
584  ASSERT(Adapter);
585 
586  /* stop the media detection timer */
588 
589  /* stop the chip */
591 
592  /* deregister the interrupt */
594 
595  /* deregister i/o port range */
597 
598  /* deregister the shutdown routine */
600 
601  /* free shared memory */
602  MiFreeSharedMemory(Adapter);
603 
604  /* free map registers */
606 
607  /* free the lock */
608  NdisFreeSpinLock(&Adapter->Lock);
609 
610  /* free the adapter */
611  NdisFreeMemory(Adapter, 0, 0);
612 }
Definition: pcnet.h:57
VOID EXPORT NdisMDeregisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle)
Definition: miniport.c:1517
#define NUMBER_OF_PORTS
Definition: pcnethw.h:34
_Out_ _At_ TimerCancelled PBOOLEAN TimerCancelled
Definition: ndis.h:2820
struct _ADAPTER * PADAPTER
ULONG_PTR PortOffset
Definition: pcnet.h:65
NDIS_MINIPORT_TIMER MediaDetectionTimer
Definition: pcnet.h:70
unsigned char BOOLEAN
VOID EXPORT NdisFreeSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:204
VOID EXPORT NdisMFreeMapRegisters(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: io.c:721
void DPRINT(...)
Definition: polytest.cpp:61
NDIS_SPIN_LOCK Lock
Definition: pcnet.h:59
NDIS_MINIPORT_INTERRUPT InterruptObject
Definition: pcnet.h:66
static BOOLEAN NTAPI MiSyncStop(IN PVOID SynchronizeContext)
Definition: pcnet.c:554
static VOID MiFreeSharedMemory(PADAPTER Adapter)
Definition: pcnet.c:301
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NDIS_HANDLE MiniportAdapterHandle
Definition: pcnet.h:61
BOOLEAN EXPORT NdisMSynchronizeWithInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, IN PVOID SynchronizeContext)
Definition: miniport.c:2955
VOID EXPORT NdisMDeregisterIoPortRange(IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts, IN PVOID PortOffset)
Definition: io.c:1093
ULONG IoBaseAddress
Definition: pcnet.h:64
VOID EXPORT NdisMCancelTimer(IN PNDIS_MINIPORT_TIMER Timer, OUT PBOOLEAN TimerCancelled)
Definition: time.c:131
VOID EXPORT NdisMDeregisterInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt)
Definition: io.c:700
VOID EXPORT NdisFreeMemory(IN PVOID VirtualAddress, IN UINT Length, IN UINT MemoryFlags)
Definition: memory.c:110

Referenced by DriverEntry().

◆ MiniportHandleInterrupt()

static VOID NTAPI MiniportHandleInterrupt ( IN NDIS_HANDLE  MiniportAdapterContext)
static

Definition at line 54 of file pcnet.c.

63 {
64  PADAPTER Adapter = (PADAPTER)MiniportAdapterContext;
65  USHORT Data;
66  UINT i = 0;
67 
68  DPRINT("Called\n");
69 
71 
72  NdisDprAcquireSpinLock(&Adapter->Lock);
73 
76 
77  DPRINT("CSR0 is 0x%x\n", Data);
78 
79  while((Data & CSR0_INTR) && i++ < INTERRUPT_LIMIT)
80  {
81  /* Clear interrupt flags early to avoid race conditions. */
83 
84  if(Data & CSR0_ERR)
85  {
86  DPRINT("error: %x\n", Data & (CSR0_MERR|CSR0_BABL|CSR0_CERR|CSR0_MISS));
87  if (Data & CSR0_CERR)
88  Adapter->Statistics.XmtCollisions++;
89  }
90  if(Data & CSR0_IDON)
91  {
92  DPRINT("IDON\n");
93  }
94  if(Data & CSR0_RINT)
95  {
96  BOOLEAN IndicatedData = FALSE;
97 
98  DPRINT("receive interrupt\n");
99 
100  while(1)
101  {
103  PCHAR Buffer;
105 
106  if(Descriptor->FLAGS & RD_OWN)
107  {
108  DPRINT("no more receive descriptors to process\n");
109  break;
110  }
111 
112  if(Descriptor->FLAGS & RD_ERR)
113  {
114  DPRINT("receive descriptor error: 0x%x\n", Descriptor->FLAGS);
115  if (Descriptor->FLAGS & RD_BUFF)
116  Adapter->Statistics.RcvBufferErrors++;
117  if (Descriptor->FLAGS & RD_CRC)
118  Adapter->Statistics.RcvCrcErrors++;
119  if (Descriptor->FLAGS & RD_OFLO)
120  Adapter->Statistics.RcvOverflowErrors++;
121  if (Descriptor->FLAGS & RD_FRAM)
122  Adapter->Statistics.RcvFramingErrors++;
123  break;
124  }
125 
126  if(!((Descriptor->FLAGS & RD_STP) && (Descriptor->FLAGS & RD_ENP)))
127  {
128  DPRINT("receive descriptor not start&end: 0x%x\n", Descriptor->FLAGS);
129  break;
130  }
131 
133  ByteCount = Descriptor->MCNT & 0xfff;
134 
135  DPRINT("Indicating a %d-byte packet (index %d)\n", ByteCount, Adapter->CurrentReceiveDescriptorIndex);
136 
138 
139  IndicatedData = TRUE;
140 
142  Descriptor->RBADR = Adapter->ReceiveBufferPtrPhys.QuadPart +
144  Descriptor->BCNT = (-BUFFER_SIZE) | 0xf000;
145  Descriptor->FLAGS |= RD_OWN;
146 
148  Adapter->CurrentReceiveDescriptorIndex %= Adapter->BufferCount;
149 
150  Adapter->Statistics.RcvGoodFrames++;
151  }
152 
153  if (IndicatedData)
155  }
156  if(Data & CSR0_TINT)
157  {
159 
160  DPRINT("transmit interrupt\n");
161 
162  while (Adapter->CurrentTransmitStartIndex !=
163  Adapter->CurrentTransmitEndIndex)
164  {
166 
167  DPRINT("buffer %d flags %x flags2 %x\n",
168  Adapter->CurrentTransmitStartIndex,
169  Descriptor->FLAGS, Descriptor->FLAGS2);
170 
171  if (Descriptor->FLAGS & TD1_OWN)
172  {
173  DPRINT("non-TXed buffer\n");
174  break;
175  }
176 
177  if (Descriptor->FLAGS & TD1_STP)
178  {
179  if (Descriptor->FLAGS & TD1_ONE)
180  Adapter->Statistics.XmtOneRetry++;
181  else if (Descriptor->FLAGS & TD1_MORE)
182  Adapter->Statistics.XmtMoreThanOneRetry++;
183  }
184 
185  if (Descriptor->FLAGS & TD1_ERR)
186  {
187  DPRINT("major error: %x\n", Descriptor->FLAGS2);
188  if (Descriptor->FLAGS2 & TD2_RTRY)
189  Adapter->Statistics.XmtRetryErrors++;
190  if (Descriptor->FLAGS2 & TD2_LCAR)
191  Adapter->Statistics.XmtLossesOfCarrier++;
192  if (Descriptor->FLAGS2 & TD2_LCOL)
193  Adapter->Statistics.XmtLateCollisions++;
194  if (Descriptor->FLAGS2 & TD2_EXDEF)
196  if (Descriptor->FLAGS2 & TD2_UFLO)
197  Adapter->Statistics.XmtBufferUnderflows++;
198  if (Descriptor->FLAGS2 & TD2_BUFF)
199  Adapter->Statistics.XmtBufferErrors++;
200  break;
201  }
202 
203  Adapter->CurrentTransmitStartIndex++;
204  Adapter->CurrentTransmitStartIndex %= Adapter->BufferCount;
205 
206  Adapter->Statistics.XmtGoodFrames++;
207  }
209  }
210  if(Data & ~(CSR0_ERR | CSR0_IDON | CSR0_RINT | CSR0_TINT))
211  {
212  DPRINT("UNHANDLED INTERRUPT CSR0 0x%x\n", Data);
213  }
214 
216  }
217 
218  /* re-enable interrupts */
220 
222  DPRINT("CSR0 is now 0x%x\n", Data);
223 
224  NdisDprReleaseSpinLock(&Adapter->Lock);
225 }
signed char * PCHAR
Definition: retypes.h:7
#define CSR0_TINT
Definition: pcnethw.h:162
ADAPTER_STATS Statistics
Definition: pcnet.h:108
#define RD_BUFF
Definition: pcnethw.h:378
#define TRUE
Definition: types.h:120
ULONG XmtGoodFrames
Definition: pcnet.h:39
ULONG XmtLateCollisions
Definition: pcnet.h:43
Definition: pcnet.h:57
ULONG RcvFramingErrors
Definition: pcnet.h:53
PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
Definition: pcnet.h:86
VOID EXPORT NdisDprReleaseSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:187
#define TD1_STP
Definition: pcnethw.h:399
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
#define NdisMEthIndicateReceiveComplete(MiniportAdapterHandle)
Definition: ndis.h:5482
#define TD1_OWN
Definition: pcnethw.h:407
PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt
Definition: pcnet.h:96
#define TD1_ONE
Definition: pcnethw.h:401
#define TD1_ERR
Definition: pcnethw.h:406
#define RAP
Definition: pcnethw.h:48
ULONG RcvBufferErrors
Definition: pcnet.h:50
PCHAR ReceiveBufferPtrVirt
Definition: pcnet.h:101
#define RD_FRAM
Definition: pcnethw.h:381
ULONG BufferCount
Definition: pcnet.h:105
struct _ADAPTER * PADAPTER
ULONG CurrentTransmitEndIndex
Definition: pcnet.h:77
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
ULONG RcvGoodFrames
Definition: pcnet.h:49
#define CSR0
Definition: pcnethw.h:63
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define CSR0_IENA
Definition: pcnethw.h:159
ULONG XmtRetryErrors
Definition: pcnet.h:40
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
VOID EXPORT NdisDprAcquireSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:169
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
PHYSICAL_ADDRESS ReceiveBufferPtrPhys
Definition: pcnet.h:102
unsigned char BOOLEAN
#define CSR0_BABL
Definition: pcnethw.h:167
#define RD_OFLO
Definition: pcnethw.h:380
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define TD2_UFLO
Definition: pcnethw.h:414
NDIS_SPIN_LOCK Lock
Definition: pcnet.h:59
#define RD_CRC
Definition: pcnethw.h:379
#define CSR0_MERR
Definition: pcnethw.h:164
#define RD_OWN
Definition: pcnethw.h:383
#define RD_STP
Definition: pcnethw.h:377
#define NdisMEthIndicateReceive(MiniportAdapterHandle, MiniportReceiveContext, HeaderBuffer, HeaderBufferSize, LookaheadBuffer, LookaheadBufferSize, PacketSize)
Definition: ndis.h:5458
ULONG XmtCollisions
Definition: pcnet.h:42
ULONG XmtMoreThanOneRetry
Definition: pcnet.h:48
ULONG XmtLossesOfCarrier
Definition: pcnet.h:41
#define CSR0_RINT
Definition: pcnethw.h:163
ULONG RcvCrcErrors
Definition: pcnet.h:51
#define TD2_LCOL
Definition: pcnethw.h:412
ULONG CurrentTransmitStartIndex
Definition: pcnet.h:76
NDIS_HANDLE MiniportAdapterHandle
Definition: pcnet.h:61
ULONG CurrentReceiveDescriptorIndex
Definition: pcnet.h:71
#define CSR0_INTR
Definition: pcnethw.h:160
#define TD2_RTRY
Definition: pcnethw.h:410
#define TD2_EXDEF
Definition: pcnethw.h:413
#define CSR0_ERR
Definition: pcnethw.h:168
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _In_ LARGE_INTEGER ByteCount
Definition: iotypes.h:1061
#define INTERRUPT_LIMIT
Definition: ne2000.h:61
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
ULONG XmtBufferUnderflows
Definition: pcnet.h:45
ULONG XmtBufferErrors
Definition: pcnet.h:46
#define CSR0_CERR
Definition: pcnethw.h:166
ULONG RcvOverflowErrors
Definition: pcnet.h:52
unsigned short USHORT
Definition: pedump.c:61
VOID EXPORT NdisMSendResourcesAvailable(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:2831
#define TD2_BUFF
Definition: pcnethw.h:415
ULONG XmtExcessiveDeferrals
Definition: pcnet.h:44
#define CSR0_IDON
Definition: pcnethw.h:161
unsigned int UINT
Definition: ndis.h:50
#define TD1_MORE
Definition: pcnethw.h:402
#define RDP
Definition: pcnethw.h:37
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RD_ERR
Definition: pcnethw.h:382
ULONG XmtOneRetry
Definition: pcnet.h:47
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define RD_ENP
Definition: pcnethw.h:376
#define CSR0_MISS
Definition: pcnethw.h:165
LONGLONG QuadPart
Definition: typedefs.h:113
#define TD2_LCAR
Definition: pcnethw.h:411
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by DriverEntry().

◆ MiniportInitialize()

static NDIS_STATUS NTAPI MiniportInitialize ( OUT PNDIS_STATUS  OpenErrorStatus,
OUT PUINT  SelectedMediumIndex,
IN PNDIS_MEDIUM  MediumArray,
IN UINT  MediumArraySize,
IN NDIS_HANDLE  MiniportAdapterHandle,
IN NDIS_HANDLE  WrapperConfigurationContext 
)
static

Definition at line 853 of file pcnet.c.

880 {
881  UINT i = 0;
882  PADAPTER Adapter = 0;
884  BOOLEAN InterruptRegistered = FALSE, MapRegistersAllocated = FALSE;
886  UINT *RegNetworkAddress = 0;
887  UINT RegNetworkAddressLength = 0;
888 
890 
891  /* Pick a medium */
892  for(i = 0; i < MediumArraySize; i++)
893  if(MediumArray[i] == NdisMedium802_3)
894  break;
895 
896  if(i == MediumArraySize)
897  {
899  DPRINT1("unsupported media\n");
901  return Status;
902  }
903 
905 
906  /* allocate our adapter struct */
907  Status = NdisAllocateMemoryWithTag((PVOID *)&Adapter, sizeof(ADAPTER), PCNET_TAG);
909  {
911  DPRINT1("Insufficient resources\n");
913  return Status;
914  }
915 
916  RtlZeroMemory(Adapter, sizeof(ADAPTER));
917 
918  Adapter->MiniportAdapterHandle = MiniportAdapterHandle;
919 
920  /* register our adapter structwith ndis */
921  NdisMSetAttributesEx(Adapter->MiniportAdapterHandle, Adapter, 0, NDIS_ATTRIBUTE_BUS_MASTER, NdisInterfacePci);
922 
923  do
924  {
925  /* Card-specific detection and setup */
926  Status = MiQueryCard(Adapter);
928  {
929  DPRINT1("MiQueryCard failed\n");
931  break;
932  }
933 
934  /* register an IO port range */
935  Status = NdisMRegisterIoPortRange((PVOID*)&Adapter->PortOffset, Adapter->MiniportAdapterHandle,
936  (UINT)Adapter->IoBaseAddress, NUMBER_OF_PORTS);
938  {
939  DPRINT1("NdisMRegisterIoPortRange failed: 0x%x\n", Status);
940  break;
941  }
942 
943  /* Allocate map registers */
944  Status = NdisMAllocateMapRegisters(Adapter->MiniportAdapterHandle, 0,
947  {
948  DPRINT1("NdisMAllocateMapRegisters failed: 0x%x\n", Status);
949  break;
950  }
951 
952  MapRegistersAllocated = TRUE;
953 
954  /* set up the interrupt */
955  Status = NdisMRegisterInterrupt(&Adapter->InterruptObject, Adapter->MiniportAdapterHandle, Adapter->InterruptVector,
956  Adapter->InterruptVector, TRUE, TRUE, NdisInterruptLevelSensitive);
958  {
959  DPRINT1("NdisMRegisterInterrupt failed: 0x%x\n", Status);
960  break;
961  }
962 
963  InterruptRegistered = TRUE;
964 
965  /* Allocate and initialize shared data structures */
966  Status = MiAllocateSharedMemory(Adapter);
968  {
970  DPRINT1("MiAllocateSharedMemory failed\n", Status);
971  break;
972  }
973 
974  /* set up the initialization block */
976 
977  /* see if someone set a network address manually */
980  {
981  NdisReadNetworkAddress(&Status, (PVOID *)&RegNetworkAddress, &RegNetworkAddressLength, ConfigurationHandle);
982  if(Status == NDIS_STATUS_SUCCESS && RegNetworkAddressLength == 6)
983  {
984  int i;
985  DPRINT("NdisReadNetworkAddress returned successfully, address %x:%x:%x:%x:%x:%x\n",
986  RegNetworkAddress[0], RegNetworkAddress[1], RegNetworkAddress[2], RegNetworkAddress[3],
987  RegNetworkAddress[4], RegNetworkAddress[5]);
988 
989  for(i = 0; i < 6; i++)
990  Adapter->InitializationBlockVirt->PADR[i] = RegNetworkAddress[i];
991  }
992 
994  }
995 
996  DPRINT("Interrupt registered successfully\n");
997 
998  /* Initialize and start the chip */
999  MiInitChip(Adapter);
1000 
1001  NdisAllocateSpinLock(&Adapter->Lock);
1002 
1004  }
1005  while(0);
1006 
1007  if(Status != NDIS_STATUS_SUCCESS && Adapter)
1008  {
1009  DPRINT("Error; freeing stuff\n");
1010 
1011  MiFreeSharedMemory(Adapter);
1012 
1013  if(MapRegistersAllocated)
1014  NdisMFreeMapRegisters(Adapter->MiniportAdapterHandle);
1015 
1016  if(Adapter->PortOffset)
1017  NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle, Adapter->IoBaseAddress, NUMBER_OF_PORTS, (PVOID)Adapter->PortOffset);
1018 
1019  if(InterruptRegistered)
1020  NdisMDeregisterInterrupt(&Adapter->InterruptObject);
1021 
1022  NdisFreeMemory(Adapter, 0, 0);
1023  }
1024 
1026  {
1027  NdisMInitializeTimer(&Adapter->MediaDetectionTimer,
1028  Adapter->MiniportAdapterHandle,
1030  Adapter);
1031  NdisMSetPeriodicTimer(&Adapter->MediaDetectionTimer,
1033  NdisMRegisterAdapterShutdownHandler(Adapter->MiniportAdapterHandle,
1034  Adapter,
1036  }
1037 
1038 #if DBG
1039  if(!MiTestCard(Adapter))
1040  ASSERT(0);
1041 #endif
1042 
1043  DPRINT("returning 0x%x\n", Status);
1045  return Status;
1046 }
static VOID MiPrepareInitializationBlock(PADAPTER Adapter)
Definition: pcnet.c:518
#define NdisInterruptLevelSensitive
Definition: ndis.h:920
#define TRUE
Definition: types.h:120
Definition: pcnet.h:57
VOID EXPORT NdisAllocateSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:152
#define MEDIA_DETECTION_INTERVAL
Definition: pcnet.h:156
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS OpenErrorStatus
Definition: ndis.h:6008
NDIS_STATUS EXPORT NdisAllocateMemoryWithTag(OUT PVOID *VirtualAddress, IN UINT Length, IN ULONG Tag)
Definition: memory.c:21
#define NUMBER_OF_PORTS
Definition: pcnethw.h:34
VOID EXPORT NdisOpenConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: config.c:197
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
NDIS_STATUS EXPORT NdisMRegisterIoPortRange(OUT PVOID *PortOffset, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts)
Definition: io.c:1018
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:6008
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT MediumArraySize
Definition: ndis.h:6013
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
#define PCNET_TAG
Definition: pcnet.h:165
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _In_ NDIS_HANDLE WrapperConfigurationContext
Definition: ndis.h:3944
int NDIS_STATUS
Definition: ntddndis.h:471
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
VOID EXPORT NdisMInitializeTimer(IN OUT PNDIS_MINIPORT_TIMER Timer, IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_TIMER_FUNCTION TimerFunction, IN PVOID FunctionContext)
Definition: time.c:192
static NDIS_STATUS MiAllocateSharedMemory(PADAPTER Adapter)
Definition: pcnet.c:353
#define NDIS_DMA_32BITS
Definition: ndis.h:881
unsigned char BOOLEAN
VOID EXPORT NdisMFreeMapRegisters(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: io.c:721
void DPRINT(...)
Definition: polytest.cpp:61
NDIS_STATUS EXPORT NdisMAllocateMapRegisters(IN NDIS_HANDLE MiniportAdapterHandle, IN UINT DmaChannel, IN NDIS_DMA_SIZE DmaSize, IN ULONG BaseMapRegistersNeeded, IN ULONG MaximumBufferSize)
Definition: io.c:252
VOID EXPORT NdisCloseConfiguration(IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:136
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
#define NDIS_ATTRIBUTE_BUS_MASTER
Definition: ndis.h:586
static VOID MiFreeSharedMemory(PADAPTER Adapter)
Definition: pcnet.c:301
static NDIS_STATUS MiQueryCard(IN PADAPTER Adapter)
Definition: pcnet.c:228
#define NDIS_STATUS_ADAPTER_NOT_FOUND
Definition: ndis.h:470
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE ConfigurationHandle
Definition: ndis.h:3944
VOID EXPORT NdisReadNetworkAddress(OUT PNDIS_STATUS Status, OUT PVOID *NetworkAddress, OUT PUINT NetworkAddressLength, IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:740
static VOID NTAPI MiniportMediaDetectionTimer(IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
Definition: pcnet.c:645
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
static VOID MiInitChip(PADAPTER Adapter)
Definition: pcnet.c:675
unsigned int UINT
Definition: ndis.h:50
VOID EXPORT NdisMDeregisterIoPortRange(IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts, IN PVOID PortOffset)
Definition: io.c:1093
#define DPRINT1
Definition: precomp.h:8
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
VOID EXPORT NdisMRegisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
Definition: miniport.c:1694
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID EXPORT NdisMSetPeriodicTimer(IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsPeriod)
Definition: time.c:226
VOID NTAPI MiniportShutdown(PVOID Context)
Definition: pcnet.c:841
VOID EXPORT NdisMDeregisterInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt)
Definition: io.c:700
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
VOID EXPORT NdisFreeMemory(IN PVOID VirtualAddress, IN UINT Length, IN UINT MemoryFlags)
Definition: memory.c:110
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

Referenced by DriverEntry().

◆ MiniportISR()

static VOID NTAPI MiniportISR ( OUT PBOOLEAN  InterruptRecognized,
OUT PBOOLEAN  QueueMiniportHandleInterrupt,
IN NDIS_HANDLE  MiniportAdapterContext 
)
static

Definition at line 1050 of file pcnet.c.

1065 {
1066  USHORT Data;
1067  USHORT Rap;
1068  PADAPTER Adapter = (PADAPTER)MiniportAdapterContext;
1069 
1070  DPRINT("Called\n");
1071 
1072  /* save the old RAP value */
1073  NdisRawReadPortUshort(Adapter->PortOffset + RAP, &Rap);
1074 
1075  /* is this ours? */
1077  NdisRawReadPortUshort(Adapter->PortOffset + RDP, &Data);
1078 
1079  if(!(Data & CSR0_INTR))
1080  {
1081  DPRINT("not our interrupt.\n");
1082  *InterruptRecognized = FALSE;
1083  *QueueMiniportHandleInterrupt = FALSE;
1084  }
1085  else
1086  {
1087  DPRINT("detected our interrupt\n");
1088 
1089  /* disable interrupts */
1091  NdisRawWritePortUshort(Adapter->PortOffset + RDP, 0);
1092 
1093  *InterruptRecognized = TRUE;
1094  *QueueMiniportHandleInterrupt = TRUE;
1095  }
1096 
1097  /* restore the rap */
1098  NdisRawWritePortUshort(Adapter->PortOffset + RAP, Rap);
1099 }
#define TRUE
Definition: types.h:120
Definition: pcnet.h:57
#define RAP
Definition: pcnethw.h:48
struct _ADAPTER * PADAPTER
#define NdisRawReadPortUshort(Port, Data)
Definition: ndis.h:4191
#define CSR0
Definition: pcnethw.h:63
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
void DPRINT(...)
Definition: polytest.cpp:61
#define CSR0_INTR
Definition: pcnethw.h:160
unsigned short USHORT
Definition: pedump.c:61
#define RDP
Definition: pcnethw.h:37

Referenced by DriverEntry().

◆ MiniportMediaDetectionTimer()

static VOID NTAPI MiniportMediaDetectionTimer ( IN PVOID  SystemSpecific1,
IN PVOID  FunctionContext,
IN PVOID  SystemSpecific2,
IN PVOID  SystemSpecific3 
)
static

Definition at line 645 of file pcnet.c.

657 {
658  PADAPTER Adapter = (PADAPTER)FunctionContext;
659 
661 
665  {
667  Adapter->MediaState == NdisMediaStateConnected ?
669  (PVOID)0, 0);
671  }
672 }
Definition: pcnet.h:57
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
struct _ADAPTER * PADAPTER
static BOOLEAN NTAPI MiSyncMediaDetection(IN PVOID SynchronizeContext)
Definition: pcnet.c:616
_In_ PVOID FunctionContext
Definition: ndis.h:637
NDIS_MINIPORT_INTERRUPT InterruptObject
Definition: pcnet.h:66
VOID EXPORT NdisMIndicateStatusComplete(IN NDIS_HANDLE MiniportAdapterHandle)
Definition: miniport.c:1580
#define NDIS_STATUS_MEDIA_CONNECT
Definition: ndis.h:361
NDIS_HANDLE MiniportAdapterHandle
Definition: pcnet.h:61
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
BOOLEAN EXPORT NdisMSynchronizeWithInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, IN PVOID SynchronizeContext)
Definition: miniport.c:2955
NDIS_MEDIA_STATE MediaState
Definition: pcnet.h:67
VOID EXPORT NdisMIndicateStatus(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Definition: miniport.c:1565
#define NDIS_STATUS_MEDIA_DISCONNECT
Definition: ndis.h:362

Referenced by MiniportInitialize().

◆ MiniportReset()

static NDIS_STATUS NTAPI MiniportReset ( OUT PBOOLEAN  AddressingReset,
IN NDIS_HANDLE  MiniportAdapterContext 
)
static

Definition at line 1103 of file pcnet.c.

1117 {
1118  DPRINT("Called\n");
1119 
1120  /* MiniportReset doesn't do anything at the moment... perhaps this should be fixed. */
1121 
1122  *AddressingReset = FALSE;
1123  return NDIS_STATUS_SUCCESS;
1124 }
void DPRINT(...)
Definition: polytest.cpp:61
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346

Referenced by DriverEntry().

◆ MiniportSend()

static NDIS_STATUS NTAPI MiniportSend ( IN NDIS_HANDLE  MiniportAdapterContext,
IN PNDIS_PACKET  Packet,
IN UINT  Flags 
)
static

Definition at line 1144 of file pcnet.c.

1160 {
1161  PADAPTER Adapter = (PADAPTER)MiniportAdapterContext;
1162  PTRANSMIT_DESCRIPTOR Desc;
1163  PNDIS_BUFFER NdisBuffer;
1164  PVOID SourceBuffer;
1165  UINT TotalPacketLength, SourceLength, Position = 0;
1166 
1167  DPRINT("Called\n");
1168 
1170 
1171  NdisDprAcquireSpinLock(&Adapter->Lock);
1172 
1173  /* Check if we have free entry in our circular buffer. */
1174  if ((Adapter->CurrentTransmitEndIndex + 1 ==
1175  Adapter->CurrentTransmitStartIndex) ||
1176  (Adapter->CurrentTransmitEndIndex == Adapter->BufferCount - 1 &&
1177  Adapter->CurrentTransmitStartIndex == 0))
1178  {
1179  DPRINT1("No free space in circular buffer\n");
1180  NdisDprReleaseSpinLock(&Adapter->Lock);
1181  return NDIS_STATUS_RESOURCES;
1182  }
1183 
1184  Desc = Adapter->TransmitDescriptorRingVirt + Adapter->CurrentTransmitEndIndex;
1185 
1186  NdisQueryPacket(Packet, NULL, NULL, &NdisBuffer, &TotalPacketLength);
1187  ASSERT(TotalPacketLength <= BUFFER_SIZE);
1188 
1189  DPRINT("TotalPacketLength: %x\n", TotalPacketLength);
1190 
1191  while (NdisBuffer)
1192  {
1193  NdisQueryBuffer(NdisBuffer, &SourceBuffer, &SourceLength);
1194 
1195  DPRINT("Buffer: %x Length: %x\n", SourceBuffer, SourceLength);
1196 
1199  SourceBuffer, SourceLength);
1200 
1201  Position += SourceLength;
1202 
1203  NdisGetNextBuffer(NdisBuffer, &NdisBuffer);
1204  }
1205 
1206 #if DBG && 0
1207  {
1208  PUCHAR Ptr = Adapter->TransmitBufferPtrVirt +
1210  for (Position = 0; Position < TotalPacketLength; Position++)
1211  {
1212  if (Position % 16 == 0)
1213  DbgPrint("\n");
1214  DbgPrint("%x ", *Ptr++);
1215  }
1216  }
1217  DbgPrint("\n");
1218 #endif
1219 
1220  Adapter->CurrentTransmitEndIndex++;
1221  Adapter->CurrentTransmitEndIndex %= Adapter->BufferCount;
1222 
1223  Desc->FLAGS = TD1_OWN | TD1_STP | TD1_ENP;
1224  Desc->BCNT = 0xf000 | -(INT)TotalPacketLength;
1225 
1227 
1228  NdisDprReleaseSpinLock(&Adapter->Lock);
1229 
1230  return NDIS_STATUS_SUCCESS;
1231 }
#define TD1_ENP
Definition: pcnethw.h:398
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
Definition: pcnet.h:57
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define DbgPrint
Definition: loader.c:25
PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt
Definition: pcnet.h:86
VOID EXPORT NdisDprReleaseSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:187
MDL * PNDIS_BUFFER
Definition: ndis.h:343
#define TD1_STP
Definition: pcnethw.h:399
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
static COORD Position
Definition: mouse.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define INT
Definition: polytest.cpp:20
static BOOLEAN NTAPI MiSyncStartTransmit(IN PVOID SynchronizeContext)
Definition: pcnet.c:1128
#define TD1_OWN
Definition: pcnethw.h:407
ULONG BufferCount
Definition: pcnet.h:105
struct _ADAPTER * PADAPTER
ULONG CurrentTransmitEndIndex
Definition: pcnet.h:77
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
VOID EXPORT NdisDprAcquireSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:169
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NDIS_SPIN_LOCK Lock
Definition: pcnet.h:59
NDIS_MINIPORT_INTERRUPT InterruptObject
Definition: pcnet.h:66
ULONG CurrentTransmitStartIndex
Definition: pcnet.h:76
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
BOOLEAN EXPORT NdisMSynchronizeWithInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, IN PVOID SynchronizeContext)
Definition: miniport.c:2955
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
static __inline VOID NdisQueryPacket(IN PNDIS_PACKET Packet, OUT PUINT PhysicalBufferCount OPTIONAL, OUT PUINT BufferCount OPTIONAL, OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, OUT PUINT TotalPacketLength OPTIONAL)
Definition: ndis.h:3593
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:953
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
PCHAR TransmitBufferPtrVirt
Definition: pcnet.h:91

Referenced by DriverEntry().

◆ MiniportShutdown()

VOID NTAPI MiniportShutdown ( PVOID  Context)

Definition at line 841 of file pcnet.c.

842 {
843  PADAPTER Adapter = Context;
844 
845  DPRINT("Stopping the chip\n");
846 
849 }
Definition: pcnet.h:57
#define RAP
Definition: pcnethw.h:48
#define CSR0
Definition: pcnethw.h:63
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
void DPRINT(...)
Definition: polytest.cpp:61
#define CSR0_STOP
Definition: pcnethw.h:155
#define RDP
Definition: pcnethw.h:37
struct tagContext Context
Definition: acpixf.h:1034

Referenced by MiniportInitialize().

◆ MiPrepareInitializationBlock()

static VOID MiPrepareInitializationBlock ( PADAPTER  Adapter)
static

Definition at line 518 of file pcnet.c.

525 {
526  ULONG i = 0;
527 
529 
530  /* read burned-in address from card */
531  for(i = 0; i < 6; i++)
533  DPRINT("MAC address: %02x-%02x-%02x-%02x-%02x-%02x\n",
534  Adapter->InitializationBlockVirt->PADR[0],
535  Adapter->InitializationBlockVirt->PADR[1],
536  Adapter->InitializationBlockVirt->PADR[2],
537  Adapter->InitializationBlockVirt->PADR[3],
538  Adapter->InitializationBlockVirt->PADR[4],
539  Adapter->InitializationBlockVirt->PADR[5]);
540 
541  /* set up receive ring */
542  DPRINT("Receive ring physical address: 0x%x\n", Adapter->ReceiveDescriptorRingPhys);
544  Adapter->InitializationBlockVirt->RLEN = (Adapter->LogBufferCount << 4) & 0xf0;
545 
546  /* set up transmit ring */
547  DPRINT("Transmit ring physical address: 0x%x\n", Adapter->TransmitDescriptorRingPhys);
549  Adapter->InitializationBlockVirt->TLEN = (Adapter->LogBufferCount << 4) & 0xf0;
550 }
PHYSICAL_ADDRESS TransmitDescriptorRingPhys
Definition: pcnet.h:87
ULONG_PTR PortOffset
Definition: pcnet.h:65
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
ULONG LogBufferCount
Definition: pcnet.h:106
void DPRINT(...)
Definition: polytest.cpp:61
PHYSICAL_ADDRESS ReceiveDescriptorRingPhys
Definition: pcnet.h:97
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define NdisRawReadPortUchar(Port, Data)
Definition: ndis.h:4173
LONGLONG QuadPart
Definition: typedefs.h:113

Referenced by MiniportInitialize().

◆ MiQueryCard()

static NDIS_STATUS MiQueryCard ( IN PADAPTER  Adapter)
static

Definition at line 228 of file pcnet.c.

239 {
240  ULONG buf32 = 0;
241  UCHAR buf8 = 0;
243 
244  /* Detect the card in the configured slot */
245  Status = NdisReadPciSlotInformation(Adapter->MiniportAdapterHandle, 0, PCI_PCIID, &buf32, 4);
246  if(Status != 4)
247  {
249  DPRINT1("NdisReadPciSlotInformation failed\n");
250  return Status;
251  }
252 
253  if(buf32 != PCI_ID)
254  {
256  DPRINT1("card in slot isn't our: 0x%x\n", 0, buf32);
257  return Status;
258  }
259 
260  /* set busmaster and io space enable bits */
261  buf32 = PCI_BMEN | PCI_IOEN;
262  NdisWritePciSlotInformation(Adapter->MiniportAdapterHandle, 0, PCI_COMMAND, &buf32, 4);
263 
264  /* get IO base physical address */
265  buf32 = 0;
266  Status = NdisReadPciSlotInformation(Adapter->MiniportAdapterHandle, 0, PCI_IOBAR, &buf32, 4);
267  if(Status != 4)
268  {
270  DPRINT1("NdisReadPciSlotInformation failed\n");
271  return Status;
272  }
273 
274  if(!buf32)
275  {
276  DPRINT1("No base i/o address set\n");
277  return NDIS_STATUS_FAILURE;
278  }
279 
280  buf32 &= ~1; /* even up address - comes out odd for some reason */
281 
282  DPRINT("detected io address 0x%x\n", buf32);
283  Adapter->IoBaseAddress = buf32;
284 
285  /* get interrupt vector */
286  Status = NdisReadPciSlotInformation(Adapter->MiniportAdapterHandle, 0, PCI_ILR, &buf8, 1);
287  if(Status != 1)
288  {
290  DPRINT1("NdisReadPciSlotInformation failed\n");
291  return Status;
292  }
293 
294  DPRINT("interrupt: 0x%x\n", buf8);
295  Adapter->InterruptVector = buf8;
296 
297  return NDIS_STATUS_SUCCESS;
298 }
#define PCI_ID
Definition: pcnethw.h:52
#define PCI_BMEN
Definition: pci.h:51
int NDIS_STATUS
Definition: ntddndis.h:471
#define PCI_IOBAR
Definition: pci.h:40
#define PCI_ILR
Definition: pci.h:43
void DPRINT(...)
Definition: polytest.cpp:61
#define NDIS_STATUS_ADAPTER_NOT_FOUND
Definition: ndis.h:470
#define PCI_PCIID
Definition: pci.h:29
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
#define PCI_IOEN
Definition: pci.h:49
ULONG EXPORT NdisReadPciSlotInformation(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:180
#define PCI_COMMAND
Definition: pcidef.h:26
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
ULONG EXPORT NdisWritePciSlotInformation(IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, IN ULONG Offset, IN PVOID Buffer, IN ULONG Length)
Definition: hardware.c:199
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465

Referenced by MiniportInitialize().

◆ MiSetMulticast()

NDIS_STATUS NTAPI MiSetMulticast ( PADAPTER  Adapter,
UCHAR Addresses,
UINT  AddressCount 
)

Definition at line 1262 of file pcnet.c.

1266 {
1267  UINT Index;
1268  ULONG CrcIndex;
1269 
1271  for (Index = 0; Index < AddressCount; Index++)
1272  {
1273  CrcIndex = MiEthernetCrc(Addresses) >> 26;
1274  Adapter->InitializationBlockVirt->LADR[CrcIndex >> 3] |= 1 << (CrcIndex & 15);
1275  Addresses += 6;
1276  }
1277 
1278  /* FIXME: The specification mentions we need to reload the init block here. */
1279 
1280  return NDIS_STATUS_SUCCESS;
1281 }
static ULONG NTAPI MiEthernetCrc(UCHAR *Address)
Definition: pcnet.c:1235
static const UCHAR Index[8]
Definition: usbohci.c:18
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
unsigned int UINT
Definition: ndis.h:50
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
unsigned int ULONG
Definition: retypes.h:1

Referenced by MiniportSetInformation().

◆ MiSyncMediaDetection()

static BOOLEAN NTAPI MiSyncMediaDetection ( IN PVOID  SynchronizeContext)
static

Definition at line 616 of file pcnet.c.

623 {
625  NDIS_MEDIA_STATE MediaState = MiGetMediaState(Adapter);
626  UINT MediaSpeed = MiGetMediaSpeed(Adapter);
627  BOOLEAN FullDuplex = MiGetMediaDuplex(Adapter);
628 
629  DPRINT("Called\n");
630  DPRINT("MediaState: %d\n", MediaState);
631  if (MediaState != Adapter->MediaState ||
632  MediaSpeed != Adapter->MediaSpeed ||
633  FullDuplex != Adapter->FullDuplex)
634  {
635  Adapter->MediaState = MediaState;
636  Adapter->MediaSpeed = MediaSpeed;
637  Adapter->FullDuplex = FullDuplex;
638  return TRUE;
639  }
640  return FALSE;
641 }
#define TRUE
Definition: types.h:120
Definition: pcnet.h:57
enum _NDIS_MEDIA_STATE NDIS_MEDIA_STATE
struct _ADAPTER * PADAPTER
UINT MediaSpeed
Definition: pcnet.h:68
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN NTAPI MiGetMediaDuplex(PADAPTER Adapter)
Definition: pcnet.c:1285
NDIS_MEDIA_STATE NTAPI MiGetMediaState(PADAPTER Adapter)
Definition: pcnet.c:1309
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536
unsigned int UINT
Definition: ndis.h:50
UINT NTAPI MiGetMediaSpeed(PADAPTER Adapter)
Definition: pcnet.c:1297
BOOLEAN FullDuplex
Definition: pcnet.h:69
NDIS_MEDIA_STATE MediaState
Definition: pcnet.h:67

Referenced by MiniportMediaDetectionTimer().

◆ MiSyncStartTransmit()

static BOOLEAN NTAPI MiSyncStartTransmit ( IN PVOID  SynchronizeContext)
static

Definition at line 1128 of file pcnet.c.

1135 {
1139  return TRUE;
1140 }
#define TRUE
Definition: types.h:120
Definition: pcnet.h:57
#define RAP
Definition: pcnethw.h:48
struct _ADAPTER * PADAPTER
#define CSR0
Definition: pcnethw.h:63
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define CSR0_IENA
Definition: pcnethw.h:159
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
#define CSR0_TDMD
Definition: pcnethw.h:156
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536
#define RDP
Definition: pcnethw.h:37

Referenced by MiniportSend().

◆ MiSyncStop()

static BOOLEAN NTAPI MiSyncStop ( IN PVOID  SynchronizeContext)
static

Definition at line 554 of file pcnet.c.

561 {
565  return TRUE;
566 }
#define TRUE
Definition: types.h:120
Definition: pcnet.h:57
#define RAP
Definition: pcnethw.h:48
struct _ADAPTER * PADAPTER
#define CSR0
Definition: pcnethw.h:63
ULONG_PTR PortOffset
Definition: pcnet.h:65
#define NdisRawWritePortUshort(Port, Data)
Definition: ndis.h:4248
#define CSR0_STOP
Definition: pcnethw.h:155
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536
#define RDP
Definition: pcnethw.h:37

Referenced by MiniportHalt().