ReactOS 0.4.15-dev-7924-g5949c20
main.c File Reference
#include <ne2000.h>
Include dependency graph for main.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
static BOOLEAN NTAPI MiniportCheckForHang (IN NDIS_HANDLE MiniportAdapterContext)
 
static VOID NTAPI MiniportDisableInterrupt (IN NDIS_HANDLE MiniportAdapterContext)
 
static VOID NTAPI MiniportEnableInterrupt (IN NDIS_HANDLE MiniportAdapterContext)
 
static VOID NTAPI MiniportHalt (IN NDIS_HANDLE MiniportAdapterContext)
 
static VOID NTAPI MiQueryResources (OUT PNDIS_STATUS Status, IN PNIC_ADAPTER Adapter, IN NDIS_HANDLE WrapperConfigurationContext)
 
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 MiniportQueryInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
 
static NDIS_STATUS NTAPI MiniportReconfigure (OUT PNDIS_STATUS OpenErrorStatus, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE WrapperConfigurationContext)
 
static NDIS_STATUS NTAPI MiniportReset (OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext)
 
static NDIS_STATUS NTAPI MiniportSend (IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags)
 
static NDIS_STATUS NTAPI MiniportSetInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesRead, OUT PULONG BytesNeeded)
 
static NDIS_STATUS NTAPI MiniportTransferData (OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE MiniportReceiveContext, IN UINT ByteOffset, IN UINT BytesToTransfer)
 

Variables

static ULONG MiniportOIDList []
 
DRIVER_INFORMATION DriverInfo = { NULL, NULL, { NULL, NULL } }
 
NDIS_PHYSICAL_ADDRESS HighestAcceptableMax = NDIS_PHYSICAL_ADDRESS_CONST(-1, -1)
 

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 921 of file main.c.

932{
934 NDIS_HANDLE NdisWrapperHandle;
936
937 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
938
939 NdisZeroMemory(&Miniport, sizeof(Miniport));
940 Miniport.MajorNdisVersion = DRIVER_NDIS_MAJOR_VERSION;
941 Miniport.MinorNdisVersion = DRIVER_NDIS_MINOR_VERSION;
942 Miniport.CheckForHangHandler = MiniportCheckForHang;
943 Miniport.DisableInterruptHandler = MiniportDisableInterrupt;
944 Miniport.EnableInterruptHandler = MiniportEnableInterrupt;
945 Miniport.HaltHandler = MiniportHalt;
946 Miniport.HandleInterruptHandler = MiniportHandleInterrupt;
947 Miniport.InitializeHandler = MiniportInitialize;
948 Miniport.ISRHandler = MiniportISR;
949 Miniport.QueryInformationHandler = MiniportQueryInformation;
950 Miniport.ReconfigureHandler = MiniportReconfigure;
951 Miniport.ResetHandler = MiniportReset;
952 Miniport.SendHandler = MiniportSend;
953 Miniport.SetInformationHandler = MiniportSetInformation;
954 Miniport.TransferDataHandler = MiniportTransferData;
955
956 NdisMInitializeWrapper(&NdisWrapperHandle,
959 NULL);
960
961 if (!NdisWrapperHandle) {
962 NDIS_DbgPrint(MIN_TRACE, ("NdisMInitializeWrapper() failed\n"));
963 return STATUS_UNSUCCESSFUL;
964 }
965
966 DriverInfo.NdisWrapperHandle = NdisWrapperHandle;
969
970 Status = NdisMRegisterMiniport(NdisWrapperHandle,
971 &Miniport,
974 NDIS_DbgPrint(MIN_TRACE, ("NdisMRegisterMiniport() failed with status code (0x%X).\n", Status));
975 NdisTerminateWrapper(NdisWrapperHandle, NULL);
976 return STATUS_UNSUCCESSFUL;
977 }
978
979 return STATUS_SUCCESS;
980}
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
#define NULL
Definition: types.h:112
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
VOID NTAPI MiniportHandleInterrupt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: interrupt.c:46
static VOID NTAPI MiniportEnableInterrupt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: main.c:94
static 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: main.c:726
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: main.c:213
static VOID NTAPI MiniportISR(OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext)
Definition: main.c:450
static VOID NTAPI MiniportHalt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: main.c:109
static NDIS_STATUS NTAPI MiniportTransferData(OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE MiniportReceiveContext, IN UINT ByteOffset, IN UINT BytesToTransfer)
Definition: main.c:832
static 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: main.c:475
static VOID NTAPI MiniportDisableInterrupt(IN NDIS_HANDLE MiniportAdapterContext)
Definition: main.c:79
static BOOLEAN NTAPI MiniportCheckForHang(IN NDIS_HANDLE MiniportAdapterContext)
Definition: main.c:63
static NDIS_STATUS NTAPI MiniportReset(OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext)
Definition: main.c:656
DRIVER_INFORMATION DriverInfo
Definition: main.c:59
static NDIS_STATUS NTAPI MiniportSend(IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags)
Definition: main.c:684
static NDIS_STATUS NTAPI MiniportReconfigure(OUT PNDIS_STATUS OpenErrorStatus, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: main.c:633
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Status
Definition: gdiplustypes.h:25
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NdisMInitializeWrapper(NdisWrapperHandle, SystemSpecific1, SystemSpecific2, SystemSpecific3)
Definition: ndis.h:5592
#define DRIVER_NDIS_MAJOR_VERSION
Definition: ne2000.h:29
#define DRIVER_NDIS_MINOR_VERSION
Definition: ne2000.h:30
NDIS_STATUS EXPORT NdisMRegisterMiniport(IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, IN UINT CharacteristicsLength)
Definition: miniport.c:2637
VOID EXPORT NdisTerminateWrapper(IN NDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific)
Definition: miniport.c:3012
int NDIS_STATUS
Definition: ntddndis.h:475
#define STATUS_SUCCESS
Definition: shellext.h:65
NDIS_HANDLE NdisMacHandle
Definition: ne2000.h:188
LIST_ENTRY AdapterListHead
Definition: ne2000.h:189
NDIS_HANDLE NdisWrapperHandle
Definition: ne2000.h:187
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ MiniportCheckForHang()

static BOOLEAN NTAPI MiniportCheckForHang ( IN NDIS_HANDLE  MiniportAdapterContext)
static

Definition at line 63 of file main.c.

72{
73 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
74
75 return FALSE;
76}
#define FALSE
Definition: types.h:117

Referenced by DriverEntry().

◆ MiniportDisableInterrupt()

static VOID NTAPI MiniportDisableInterrupt ( IN NDIS_HANDLE  MiniportAdapterContext)
static

Definition at line 79 of file main.c.

86{
87 NDIS_DbgPrint(MAX_TRACE, ("Called. (MiniportDisableInterrupt).\n"));
88#ifndef NOCARD
89 NICDisableInterrupts((PNIC_ADAPTER)MiniportAdapterContext);
90#endif
91}
#define NICDisableInterrupts(Adapter)
Definition: 8390.h:159

Referenced by DriverEntry().

◆ MiniportEnableInterrupt()

static VOID NTAPI MiniportEnableInterrupt ( IN NDIS_HANDLE  MiniportAdapterContext)
static

Definition at line 94 of file main.c.

101{
102 NDIS_DbgPrint(MAX_TRACE, ("Called. (MiniportEnableInterrupt).\n"));
103#ifndef NOCARD
104 NICEnableInterrupts((PNIC_ADAPTER)MiniportAdapterContext);
105#endif
106}
#define NICEnableInterrupts(Adapter)
Definition: 8390.h:164

Referenced by DriverEntry().

◆ MiniportHalt()

static VOID NTAPI MiniportHalt ( IN NDIS_HANDLE  MiniportAdapterContext)
static

Definition at line 109 of file main.c.

116{
117 PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
118
120
121 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
122#ifndef NOCARD
123 /* Stop the NIC */
124 NICStop(Adapter);
125#endif
126 /* Wait for any DPCs to complete. FIXME: Use something else */
127 NdisStallExecution(250000);
128
129 if (Adapter->InterruptRegistered)
130 /* Deregister interrupt */
132
133 if (Adapter->IOPortRangeRegistered)
134 /* Deregister I/O port range */
136 Adapter->MiniportAdapterHandle,
137 Adapter->IoBaseAddress,
138 0x20,
139 Adapter->IOBase);
140
141 if (Adapter->ShutdownHandlerRegistered)
143
144 /* Remove adapter from global adapter list */
145 if ((&Adapter->ListEntry)->Blink != NULL) {
146 RemoveEntryList(&Adapter->ListEntry);
147 }
148
149 /* Free adapter context area */
150 NdisFreeMemory(Adapter, sizeof(NIC_ADAPTER), 0);
151}
#define ASSERT_IRQL_EQUAL(x)
Definition: debug.h:43
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 NdisFreeMemory(IN PVOID VirtualAddress, IN UINT Length, IN UINT MemoryFlags)
Definition: memory.c:110
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define NdisStallExecution
Definition: ndis.h:4453
struct _NIC_ADAPTER * PNIC_ADAPTER
NDIS_STATUS NICStop(PNIC_ADAPTER Adapter)
Definition: 8390.c:451
VOID EXPORT NdisMDeregisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle)
Definition: miniport.c:1517
BOOLEAN InterruptRegistered
Definition: ne2000.h:180
PUCHAR IOBase
Definition: ne2000.h:92
BOOLEAN IOPortRangeRegistered
Definition: ne2000.h:179
NDIS_MINIPORT_INTERRUPT Interrupt
Definition: ne2000.h:82
ULONG_PTR IoBaseAddress
Definition: ne2000.h:85
NDIS_HANDLE MiniportAdapterHandle
Definition: ne2000.h:80
LIST_ENTRY ListEntry
Definition: ne2000.h:78
BOOLEAN ShutdownHandlerRegistered
Definition: ne2000.h:181

Referenced by DriverEntry(), and MiniportInitialize().

◆ 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 213 of file main.c.

232{
233 UINT i;
235 PNIC_ADAPTER Adapter;
237 UINT *RegNetworkAddress = 0;
238 UINT RegNetworkAddressLength = 0;
239
241
242 NDIS_DbgPrint(MAX_TRACE, ("Called (Adapter %X).\n", MiniportAdapterHandle));
243
244 /* Search for 802.3 media which is the only one we support */
245 for (i = 0; i < MediumArraySize; i++) {
246 if (MediumArray[i] == NdisMedium802_3)
247 break;
248 }
249
250 if (i == MediumArraySize) {
251 NDIS_DbgPrint(MIN_TRACE, ("No supported media.\n"));
253 }
254
256
257 Status = NdisAllocateMemory((PVOID)&Adapter,
258 sizeof(NIC_ADAPTER),
259 0,
262 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
263 return Status;
264 }
265
266 NdisZeroMemory(Adapter, sizeof(NIC_ADAPTER));
267 Adapter->MiniportAdapterHandle = MiniportAdapterHandle;
268 Adapter->IoBaseAddress = DRIVER_DEFAULT_IO_BASE_ADDRESS;
269 Adapter->InterruptLevel = DRIVER_DEFAULT_INTERRUPT_NUMBER;
270 Adapter->InterruptVector = DRIVER_DEFAULT_INTERRUPT_NUMBER;
271 Adapter->InterruptShared = DRIVER_DEFAULT_INTERRUPT_SHARED;
272 Adapter->InterruptMode = DRIVER_DEFAULT_INTERRUPT_MODE;
273 Adapter->MaxMulticastListSize = DRIVER_MAX_MULTICAST_LIST_SIZE;
274 Adapter->InterruptMask = DRIVER_INTERRUPT_MASK;
275 Adapter->LookaheadSize = DRIVER_MAXIMUM_LOOKAHEAD;
276
277 /* Query the resources from PnP. */
279
280 /* Get the port, irq, and MAC address from registry if the PnP
281 failed. */
283 {
284 PNDIS_CONFIGURATION_PARAMETER ConfigurationParameter;
286
289 {
293 {
294 NDIS_DbgPrint(MID_TRACE,("NdisReadConfiguration for Irq returned successfully, irq 0x%x\n",
295 ConfigurationParameter->ParameterData.IntegerData));
296 Adapter->InterruptLevel =
297 Adapter->InterruptVector = ConfigurationParameter->ParameterData.IntegerData;
298 }
299
303 {
304 NDIS_DbgPrint(MID_TRACE,("NdisReadConfiguration for Port returned successfully, port 0x%x\n",
305 ConfigurationParameter->ParameterData.IntegerData));
306 Adapter->IoBaseAddress = ConfigurationParameter->ParameterData.IntegerData;
307 }
308
310 }
311 else
312 {
313 NDIS_DbgPrint(MIN_TRACE,("NdisOpenConfiguration returned error 0x%x\n", Status));
314 }
315 }
316
317 /* find the nic */
318 if (!NICCheck(Adapter)) {
319 NDIS_DbgPrint(MID_TRACE, ("No adapter found at (0x%X).\n", Adapter->IoBaseAddress));
320 NdisFreeMemory(Adapter, sizeof(NIC_ADAPTER), 0);
322 } else
323 NDIS_DbgPrint(MID_TRACE, ("Adapter found at (0x%X).\n", Adapter->IoBaseAddress));
324
327 (NDIS_HANDLE)Adapter,
328 FALSE,
330
332 (PVOID*)&Adapter->IOBase,
334 Adapter->IoBaseAddress,
335 0x20);
336
338 NDIS_DbgPrint(MIN_TRACE, ("Cannot register port range. Status (0x%X).\n", Status));
339 MiniportHalt((NDIS_HANDLE)Adapter);
340 return Status;
341 }
342
343 Adapter->IOPortRangeRegistered = TRUE;
344
345 /* Initialize NIC */
346#ifndef NOCARD
347 Status = NICInitialize(Adapter);
349 NDIS_DbgPrint(MIN_TRACE,("No NE2000 or compatible network adapter found at address 0x%X.\n",
350 Adapter->IOBase));
351
352 NDIS_DbgPrint(MID_TRACE, ("Status (0x%X).\n", Status));
353 MiniportHalt((NDIS_HANDLE)Adapter);
354 return Status;
355 }
356
359 {
360 NdisReadNetworkAddress(&Status, (PVOID *)&RegNetworkAddress, &RegNetworkAddressLength, ConfigurationHandle);
361 if(Status == NDIS_STATUS_SUCCESS && RegNetworkAddressLength == DRIVER_LENGTH_OF_ADDRESS)
362 {
363 int i;
364 NDIS_DbgPrint(MID_TRACE,("NdisReadNetworkAddress returned successfully, address %x:%x:%x:%x:%x:%x\n",
365 RegNetworkAddress[0], RegNetworkAddress[1], RegNetworkAddress[2], RegNetworkAddress[3],
366 RegNetworkAddress[4], RegNetworkAddress[5]));
367 for(i = 0; i < DRIVER_LENGTH_OF_ADDRESS; i++)
368 Adapter->StationAddress[i] = RegNetworkAddress[i];
369 }
370
372 }
373
374 if (Status != NDIS_STATUS_SUCCESS || RegNetworkAddressLength != DRIVER_LENGTH_OF_ADDRESS)
375 {
376 int i;
377 for (i = 0; i < DRIVER_LENGTH_OF_ADDRESS; i++)
378 Adapter->StationAddress[i] = Adapter->PermanentAddress[i];
379 }
380
381 NDIS_DbgPrint(MID_TRACE, ("BOARDDATA:\n"));
382 for (i = 0; i < 4; i++) {
383 NDIS_DbgPrint(MID_TRACE, ("%02X %02X %02X %02X\n",
384 Adapter->SAPROM[i*4+0],
385 Adapter->SAPROM[i*4+1],
386 Adapter->SAPROM[i*4+2],
387 Adapter->SAPROM[i*4+3]));
388 }
389
390 /* Setup adapter structure */
391 Adapter->TXStart = ((ULONG_PTR)Adapter->RamBase >> 8);
392 Adapter->TXCount = DRIVER_DEFAULT_TX_BUFFER_COUNT;
393 Adapter->TXFree = DRIVER_DEFAULT_TX_BUFFER_COUNT;
394 Adapter->TXCurrent = -1;
395 Adapter->PageStart = Adapter->TXStart + Adapter->TXCount;
396 Adapter->PageStop = Adapter->TXStart + (Adapter->RamSize >> 8);
397
398 /* Initialize multicast address mask to accept all */
399 for (i = 0; i < 8; i++)
400 Adapter->MulticastAddressMask[i] = 0xFF;
401
402 /* Setup the NIC */
403 NICSetup(Adapter);
404
405 NDIS_DbgPrint(MID_TRACE, ("TXStart (0x%X) TXCount (0x%X) PageStart (0x%X)\n",
406 Adapter->TXStart,
407 Adapter->TXCount,
408 Adapter->PageStart));
409
410 NDIS_DbgPrint(MID_TRACE, ("PageStop (0x%X) CurrentPage (0x%X) NextPacket (0x%X).\n",
411 Adapter->PageStop,
412 Adapter->CurrentPage,
413 Adapter->NextPacket));
414#endif
415 /* Register the interrupt */
417 &Adapter->Interrupt,
419 Adapter->InterruptVector,
420 Adapter->InterruptLevel,
421 FALSE,
422 Adapter->InterruptShared,
423 Adapter->InterruptMode);
425 NDIS_DbgPrint(MIN_TRACE, ("Cannot register interrupt. Status (0x%X).\n", Status));
426 MiniportHalt((NDIS_HANDLE)Adapter);
427 return Status;
428 }
429
430 Adapter->InterruptRegistered = TRUE;
431#ifndef NOCARD
432 /* Start the NIC */
433 NICStart(Adapter);
434#endif
435
436 /* Register the shutdown handler */
438
439 Adapter->ShutdownHandlerRegistered = TRUE;
440
441 /* Add adapter to the global adapter list */
442 InsertTailList(&DriverInfo.AdapterListHead, &Adapter->ListEntry);
443
444 NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
445
446 return NDIS_STATUS_SUCCESS;
447}
#define MID_TRACE
Definition: debug.h:15
#define TRUE
Definition: types.h:120
VOID NTAPI MiniportShutdown(PVOID Context)
Definition: main.c:206
static VOID NTAPI MiQueryResources(OUT PNDIS_STATUS Status, IN PNIC_ADAPTER Adapter, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: main.c:154
NDIS_PHYSICAL_ADDRESS HighestAcceptableMax
Definition: main.c:60
VOID EXPORT NdisCloseConfiguration(IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:136
VOID EXPORT NdisReadConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, IN NDIS_HANDLE ConfigurationHandle, IN PNDIS_STRING Keyword, IN NDIS_PARAMETER_TYPE ParameterType)
Definition: config.c:414
VOID EXPORT NdisReadNetworkAddress(OUT PNDIS_STATUS Status, OUT PVOID *NetworkAddress, OUT PUINT NetworkAddressLength, IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:740
VOID EXPORT NdisOpenConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: config.c:197
NDIS_STATUS EXPORT NdisMRegisterIoPortRange(OUT PVOID *PortOffset, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts)
Definition: io.c:1018
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 NdisAllocateMemory(OUT PVOID *VirtualAddress, IN UINT Length, IN UINT MemoryFlags, IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress)
Definition: memory.c:57
VOID EXPORT NdisInitUnicodeString(IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString)
Definition: string.c:130
#define ULONG_PTR
Definition: config.h:101
#define InsertTailList(ListHead, Entry)
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
@ NdisParameterHexInteger
Definition: ndis.h:927
unsigned int UINT
Definition: ndis.h:50
#define NdisMSetAttributes(MiniportAdapterHandle, MiniportAdapterContext, BusMaster, AdapterType)
Definition: ndis.h:5736
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:6011
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT MediumArraySize
Definition: ndis.h:6013
@ NdisInterfaceIsa
Definition: ndis.h:901
_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
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE ConfigurationHandle
Definition: ndis.h:3945
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
#define NDIS_STATUS_ADAPTER_NOT_FOUND
Definition: ndis.h:470
#define DRIVER_DEFAULT_INTERRUPT_MODE
Definition: ne2000.h:35
#define DRIVER_MAXIMUM_LOOKAHEAD
Definition: ne2000.h:47
#define DRIVER_MAX_MULTICAST_LIST_SIZE
Definition: ne2000.h:37
BOOLEAN NICCheck(PNIC_ADAPTER Adapter)
Definition: 8390.c:53
#define DRIVER_DEFAULT_INTERRUPT_SHARED
Definition: ne2000.h:34
#define DRIVER_DEFAULT_INTERRUPT_NUMBER
Definition: ne2000.h:33
#define DRIVER_DEFAULT_TX_BUFFER_COUNT
Definition: ne2000.h:54
#define DRIVER_INTERRUPT_MASK
Definition: ne2000.h:58
#define DRIVER_LENGTH_OF_ADDRESS
Definition: ne2000.h:44
NDIS_STATUS NICSetup(PNIC_ADAPTER Adapter)
Definition: 8390.c:352
NDIS_STATUS NICStart(PNIC_ADAPTER Adapter)
Definition: 8390.c:429
NDIS_STATUS NICInitialize(PNIC_ADAPTER Adapter)
Definition: 8390.c:289
#define DRIVER_DEFAULT_IO_BASE_ADDRESS
Definition: ne2000.h:32
VOID EXPORT NdisMRegisterAdapterShutdownHandler(IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler)
Definition: miniport.c:1694
@ NdisMedium802_3
Definition: ntddndis.h:188
#define L(x)
Definition: ntvdm.h:50
union _NDIS_CONFIGURATION_PARAMETER::@2097 ParameterData

Referenced by DriverEntry().

◆ MiniportISR()

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

Definition at line 450 of file main.c.

465{
466 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
467
468 NICDisableInterrupts((PNIC_ADAPTER)MiniportAdapterContext);
469
470 *InterruptRecognized = TRUE;
471 *QueueMiniportHandleInterrupt = TRUE;
472}

Referenced by DriverEntry().

◆ MiniportQueryInformation()

static NDIS_STATUS NTAPI MiniportQueryInformation ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesWritten,
OUT PULONG  BytesNeeded 
)
static

Definition at line 475 of file main.c.

495{
497 PVOID CopyFrom;
498 UINT CopySize;
499 ULONG GenericULONG;
500 USHORT GenericUSHORT;
502 PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
503
504 NDIS_DbgPrint(MAX_TRACE, ("Called. Oid (0x%X).\n", Oid));
505
507 CopyFrom = (PVOID)&GenericULONG;
508 CopySize = sizeof(ULONG);
509
510 switch (Oid) {
512 CopyFrom = (PVOID)&MiniportOIDList;
513 CopySize = sizeof(MiniportOIDList);
514 break;
516 GenericULONG = (ULONG)NdisHardwareStatusReady;
517 break;
520 CopyFrom = (PVOID)&Medium;
521 CopySize = sizeof(NDIS_MEDIUM);
522 break;
524 GenericULONG = DRIVER_MAXIMUM_LOOKAHEAD;
525 break;
527 GenericULONG = DRIVER_FRAME_SIZE - DRIVER_HEADER_SIZE;
528 break;
530 GenericULONG = 100000; /* 10Mbps */
531 break;
533 GenericULONG = Adapter->TXCount * DRIVER_BLOCK_SIZE;
534 break;
536 GenericULONG = Adapter->RamSize -
537 (ULONG_PTR)Adapter->RamBase -
538 (Adapter->TXCount * DRIVER_BLOCK_SIZE);
539 break;
541 GenericULONG = DRIVER_BLOCK_SIZE;
542 break;
544 GenericULONG = DRIVER_BLOCK_SIZE;
545 break;
547 NdisMoveMemory(&GenericULONG, &Adapter->PermanentAddress, 3);
548 GenericULONG &= 0xFFFFFF00;
549 GenericULONG |= 0x01;
550 break;
552 CopyFrom = (PVOID)&DRIVER_VENDOR_DESCRIPTION;
553 CopySize = sizeof(DRIVER_VENDOR_DESCRIPTION);
554 break;
556 GenericUSHORT = (USHORT)DRIVER_VENDOR_DRIVER_VERSION;
557 CopyFrom = (PVOID)&GenericUSHORT;
558 CopySize = sizeof(USHORT);
559 break;
561 GenericULONG = Adapter->PacketFilter;
562 break;
564 GenericULONG = Adapter->LookaheadSize;
565 break;
568 CopyFrom = (PVOID)&GenericUSHORT;
569 CopySize = sizeof(USHORT);
570 break;
572 GenericULONG = DRIVER_FRAME_SIZE;
573 break;
575 NDIS_DbgPrint(MID_TRACE, ("OID_GEN_PROTOCOL_OPTIONS.\n"));
577 break;
583 break;
585 GenericULONG = (ULONG)NdisMediaStateConnected;
586 break;
588 GenericULONG = 1;
589 break;
591 CopyFrom = (PVOID)&Adapter->PermanentAddress;
592 CopySize = DRIVER_LENGTH_OF_ADDRESS;
593 break;
595 CopyFrom = (PVOID)&Adapter->StationAddress;
596 CopySize = DRIVER_LENGTH_OF_ADDRESS;
597 break;
599 NDIS_DbgPrint(MID_TRACE, ("OID_802_3_MULTICAST_LIST.\n"));
601 break;
603 GenericULONG = Adapter->MaxMulticastListSize;
604 break;
606 NDIS_DbgPrint(MID_TRACE, ("OID_802_3_MAC_OPTIONS.\n"));
608 break;
609 default:
610 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID (0x%X).\n", Oid));
612 break;
613 }
614
616 if (CopySize > InformationBufferLength) {
617 *BytesNeeded = (CopySize - InformationBufferLength);
618 *BytesWritten = 0;
620 } else {
621 NdisMoveMemory(InformationBuffer, CopyFrom, CopySize);
622 *BytesWritten = CopySize;
623 *BytesNeeded = 0;
624 }
625 }
626
627 NDIS_DbgPrint(MAX_TRACE, ("Leaving. Status is (0x%X).\n", Status));
628
629 return Status;
630}
static ULONG MiniportOIDList[]
Definition: main.c:29
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
#define NDIS_STATUS_INVALID_OID
Definition: ndis.h:488
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
#define DRIVER_VENDOR_DESCRIPTION
Definition: ne2000.h:39
#define DRIVER_HEADER_SIZE
Definition: ne2000.h:43
#define DRIVER_FRAME_SIZE
Definition: ne2000.h:42
#define DRIVER_VENDOR_DRIVER_VERSION
Definition: ne2000.h:40
#define DRIVER_BLOCK_SIZE
Definition: ne2000.h:50
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
#define OID_GEN_PROTOCOL_OPTIONS
Definition: ntddndis.h:250
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#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_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
@ NdisMediaStateConnected
Definition: ntddndis.h:470
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_802_3_MAC_OPTIONS
Definition: ntddndis.h:306
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#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
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
unsigned short USHORT
Definition: pedump.c:61
ULONG PacketFilter
Definition: ne2000.h:126
UINT RamSize
Definition: ne2000.h:99
UINT TXCount
Definition: ne2000.h:161
PUCHAR RamBase
Definition: ne2000.h:98
DRIVER_HARDWARE_ADDRESS PermanentAddress
Definition: ne2000.h:105
UINT LookaheadSize
Definition: ne2000.h:129
ULONG MaxMulticastListSize
Definition: ne2000.h:111
DRIVER_HARDWARE_ADDRESS StationAddress
Definition: ne2000.h:108
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
_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

Referenced by DriverEntry().

◆ MiniportReconfigure()

static NDIS_STATUS NTAPI MiniportReconfigure ( OUT PNDIS_STATUS  OpenErrorStatus,
IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_HANDLE  WrapperConfigurationContext 
)
static

Definition at line 633 of file main.c.

648{
649 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
650
651 return NDIS_STATUS_FAILURE;
652}
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465

Referenced by DriverEntry().

◆ MiniportReset()

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

Definition at line 656 of file main.c.

669{
670 NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
671
672 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
673
674#ifndef NOCARD
675 NdisStatus = NICReset((PNIC_ADAPTER)MiniportAdapterContext);
676#endif
677
678 *AddressingReset = TRUE;
679
680 return NdisStatus;
681}
NDIS_STATUS NICReset(PNIC_ADAPTER Adapter)
Definition: 8390.c:500

Referenced by DriverEntry().

◆ MiniportSend()

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

Definition at line 684 of file main.c.

698{
699 PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
700
702
703#ifndef NOCARD
704 NDIS_DbgPrint(MID_TRACE, ("Queueing packet.\n"));
705
706 /* Queue the packet on the transmit queue */
707 RESERVED(Packet)->Next = NULL;
708 if (Adapter->TXQueueHead == NULL) {
709 Adapter->TXQueueHead = Packet;
710 } else {
711 RESERVED(Adapter->TXQueueTail)->Next = Packet;
712 }
713
714 Adapter->TXQueueTail = Packet;
715
716 /* Transmit the packet */
717 NICTransmit(Adapter);
718
719 return NDIS_STATUS_PENDING;
720#else
721 return NDIS_STATUS_SUCCESS;
722#endif
723}
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
#define RESERVED(Packet)
Definition: ne2000.h:70
VOID NICTransmit(PNIC_ADAPTER Adapter)
Definition: 8390.c:1124
PNDIS_PACKET TXQueueTail
Definition: ne2000.h:171
PNDIS_PACKET TXQueueHead
Definition: ne2000.h:169

Referenced by DriverEntry().

◆ MiniportSetInformation()

static NDIS_STATUS NTAPI MiniportSetInformation ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesRead,
OUT PULONG  BytesNeeded 
)
static

Definition at line 726 of file main.c.

746{
747 ULONG GenericULONG;
749 PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
750
751 NDIS_DbgPrint(MAX_TRACE, ("Called. Oid (0x%X).\n", Oid));
752
753 switch (Oid) {
755 /* Verify length */
756 if (InformationBufferLength < sizeof(ULONG)) {
757 *BytesRead = 0;
758 *BytesNeeded = sizeof(ULONG) - InformationBufferLength;
760 break;
761 }
762
763 NdisMoveMemory(&GenericULONG, InformationBuffer, sizeof(ULONG));
764 /* Check for properties the driver don't support */
765 if (GenericULONG &
772 *BytesRead = 4;
773 *BytesNeeded = 0;
775 break;
776 }
777
778 Adapter->PacketFilter = GenericULONG;
779
780 /* FIXME: Set filter on hardware */
781
782 break;
784 /* Verify length */
785 if (InformationBufferLength < sizeof(ULONG)) {
786 *BytesRead = 0;
787 *BytesNeeded = sizeof(ULONG) - InformationBufferLength;
789 break;
790 }
791
792 NdisMoveMemory(&GenericULONG, InformationBuffer, sizeof(ULONG));
793 if (GenericULONG > DRIVER_MAXIMUM_LOOKAHEAD)
795 else
796 Adapter->LookaheadSize = GenericULONG;
797 break;
799 /* Verify length. Must be multiple of hardware address length */
800 if ((InformationBufferLength % DRIVER_LENGTH_OF_ADDRESS) != 0) {
801 *BytesRead = 0;
802 *BytesNeeded = 0;
804 break;
805 }
806
807 /* Set new multicast address list */
808 NdisMoveMemory(Adapter->Addresses, InformationBuffer, InformationBufferLength);
809
810 /* FIXME: Update hardware */
811
812 break;
813 default:
814 NDIS_DbgPrint(MIN_TRACE, ("Invalid object ID (0x%X).\n", Oid));
815 *BytesRead = 0;
816 *BytesNeeded = 0;
818 break;
819 }
820
822 *BytesRead = InformationBufferLength;
823 *BytesNeeded = 0;
824 }
825
826 NDIS_DbgPrint(MAX_TRACE, ("Leaving. Status (0x%X).\n", Status));
827
828 return Status;
829}
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#define NDIS_PACKET_TYPE_SOURCE_ROUTING
Definition: ndis.h:667
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL
Definition: ndis.h:672
#define NDIS_PACKET_TYPE_FUNCTIONAL
Definition: ndis.h:673
#define NDIS_PACKET_TYPE_GROUP
Definition: ndis.h:671
#define NDIS_PACKET_TYPE_SMT
Definition: ndis.h:669
DRIVER_HARDWARE_ADDRESS Addresses[DRIVER_MAX_MULTICAST_LIST_SIZE]
Definition: ne2000.h:114
_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().

◆ MiniportShutdown()

VOID NTAPI MiniportShutdown ( PVOID  Context)

Definition at line 206 of file main.c.

207{
208 #ifndef NOCARD
210 #endif
211}

Referenced by MiniportInitialize().

◆ MiniportTransferData()

static NDIS_STATUS NTAPI MiniportTransferData ( OUT PNDIS_PACKET  Packet,
OUT PUINT  BytesTransferred,
IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_HANDLE  MiniportReceiveContext,
IN UINT  ByteOffset,
IN UINT  BytesToTransfer 
)
static

Definition at line 832 of file main.c.

851{
852 PNDIS_BUFFER DstBuffer;
853 UINT BytesCopied, BytesToCopy, DstSize;
854 ULONG SrcData;
855 PUCHAR DstData;
856 UINT RecvStart;
857 UINT RecvStop;
858 PNIC_ADAPTER Adapter = (PNIC_ADAPTER)MiniportAdapterContext;
859
860 NDIS_DbgPrint(MAX_TRACE, ("Called. Packet (0x%X) ByteOffset (0x%X) BytesToTransfer (%d).\n",
861 Packet, ByteOffset, BytesToTransfer));
862
863 if (BytesToTransfer == 0) {
864 *BytesTransferred = 0;
865 return NDIS_STATUS_SUCCESS;
866 }
867
868 RecvStart = Adapter->PageStart * DRIVER_BLOCK_SIZE;
869 RecvStop = Adapter->PageStop * DRIVER_BLOCK_SIZE;
870
871 NdisQueryPacket(Packet, NULL, NULL, &DstBuffer, NULL);
872 NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
873
874 SrcData = Adapter->PacketOffset + sizeof(DISCARD_HEADER) + ByteOffset;
875 if (ByteOffset + sizeof(DISCARD_HEADER) + BytesToTransfer >
876 Adapter->PacketHeader.PacketLength)
877 BytesToTransfer = Adapter->PacketHeader.PacketLength -
878 sizeof(DISCARD_HEADER) - ByteOffset;
879
880 /* Start copying the data */
881 BytesCopied = 0;
882 for (;;) {
883 BytesToCopy = (DstSize < BytesToTransfer) ? DstSize : BytesToTransfer;
884 if (SrcData + BytesToCopy > RecvStop)
885 BytesToCopy = (RecvStop - SrcData);
886
887 NICReadData(Adapter, DstData, SrcData, BytesToCopy);
888
890 SrcData += BytesToCopy;
891 DstData = (PUCHAR)((ULONG_PTR) DstData + BytesToCopy);
892 BytesToTransfer -= BytesToCopy;
893 if (BytesToTransfer == 0)
894 break;
895
896 DstSize -= BytesToCopy;
897 if (DstSize == 0) {
898 /* No more bytes in destination buffer. Proceed to
899 the next buffer in the destination buffer chain */
900 NdisGetNextBuffer(DstBuffer, &DstBuffer);
901 if (!DstBuffer)
902 break;
903
904 NdisQueryBuffer(DstBuffer, (PVOID)&DstData, &DstSize);
905 }
906
907 if (SrcData == RecvStop)
908 SrcData = RecvStart;
909 }
910
911 NDIS_DbgPrint(MID_TRACE, ("Transferred (%d) bytes.\n", BytesToTransfer));
912
914
915 return NDIS_STATUS_SUCCESS;
916}
struct _DISCARD_HEADER DISCARD_HEADER
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:731
#define NdisGetNextBuffer(CurrentBuffer, NextBuffer)
Definition: ndis.h:3386
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
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3171
_In_ UINT _In_ UINT BytesToCopy
Definition: ndis.h:3168
MDL * PNDIS_BUFFER
Definition: ndis.h:343
#define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length)
Definition: ndis.h:3029
VOID NICReadData(PNIC_ADAPTER Adapter, PUCHAR Target, ULONG_PTR Source, USHORT Length)
Definition: 8390.c:791
PACKET_HEADER PacketHeader
Definition: ne2000.h:151
UINT PageStart
Definition: ne2000.h:133
UINT PageStop
Definition: ne2000.h:134
ULONG PacketOffset
Definition: ne2000.h:154
USHORT PacketLength
Definition: 8390.h:142
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1342

Referenced by DriverEntry().

◆ MiQueryResources()

static VOID NTAPI MiQueryResources ( OUT PNDIS_STATUS  Status,
IN PNIC_ADAPTER  Adapter,
IN NDIS_HANDLE  WrapperConfigurationContext 
)
static

Definition at line 154 of file main.c.

158{
159 PNDIS_RESOURCE_LIST AssignedResources;
160 UINT BufferSize = 0;
162 UINT i;
163
166 NULL,
167 &BufferSize);
169 return;
170
171 *Status = NdisAllocateMemory((PVOID)&AssignedResources,
173 0,
176 return;
177
180 AssignedResources,
181 &BufferSize);
183 return;
184
185 for (i = 0; i < AssignedResources->Count; i++)
186 {
187 Descriptor = AssignedResources->PartialDescriptors + i;
188 switch (Descriptor->Type)
189 {
191 Adapter->InterruptLevel = Descriptor->u.Interrupt.Level;
192 Adapter->InterruptVector = Descriptor->u.Interrupt.Vector;
193 Adapter->InterruptShared = (Descriptor->ShareDisposition == CmResourceShareShared);
194 Adapter->InterruptMode = Descriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED ?
196 break;
198 Adapter->IoBaseAddress = Descriptor->u.Port.Start.LowPart;
199 break;
200 }
201 }
202}
VOID EXPORT NdisMQueryAdapterResources(OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, OUT PNDIS_RESOURCE_LIST ResourceList, IN OUT PUINT BufferSize)
Definition: hardware.c:103
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define NdisInterruptLatched
Definition: ndis.h:921
#define NdisInterruptLevelSensitive
Definition: ndis.h:920
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by MiniportInitialize().

Variable Documentation

◆ DriverInfo

DRIVER_INFORMATION DriverInfo = { NULL, NULL, { NULL, NULL } }

◆ HighestAcceptableMax

NDIS_PHYSICAL_ADDRESS HighestAcceptableMax = NDIS_PHYSICAL_ADDRESS_CONST(-1, -1)

Definition at line 60 of file main.c.

Referenced by MiniportInitialize(), and MiQueryResources().

◆ MiniportOIDList