ReactOS 0.4.15-dev-8236-g99f0937
io.c File Reference
#include "ndissys.h"
Include dependency graph for io.c:

Go to the source code of this file.

Functions

VOID NTAPI HandleDeferredProcessing (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
BOOLEAN NTAPI ServiceRoutine (IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
 
VOID EXPORT NdisImmediateReadPortUchar (IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG Port, OUT PUCHAR Data)
 
VOID EXPORT NdisImmediateReadPortUlong (IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG Port, OUT PULONG Data)
 
VOID EXPORT NdisImmediateReadPortUshort (IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG Port, OUT PUSHORT Data)
 
VOID EXPORT NdisImmediateWritePortUchar (IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG Port, IN UCHAR Data)
 
VOID EXPORT NdisImmediateWritePortUlong (IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG Port, IN ULONG Data)
 
VOID EXPORT NdisImmediateWritePortUshort (IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG Port, IN USHORT Data)
 
IO_ALLOCATION_ACTION NTAPI NdisSubordinateMapRegisterCallback (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID MapRegisterBase, IN PVOID Context)
 
IO_ALLOCATION_ACTION NTAPI NdisBusMasterMapRegisterCallback (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID MapRegisterBase, IN PVOID Context)
 
NDIS_STATUS EXPORT NdisMAllocateMapRegisters (IN NDIS_HANDLE MiniportAdapterHandle, IN UINT DmaChannel, IN NDIS_DMA_SIZE DmaSize, IN ULONG BaseMapRegistersNeeded, IN ULONG MaximumBufferSize)
 
VOID EXPORT NdisMSetupDmaTransfer (OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportDmaHandle, IN PNDIS_BUFFER Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN WriteToDevice)
 
VOID EXPORT NdisSetupDmaTransfer (OUT PNDIS_STATUS Status, IN PNDIS_HANDLE NdisDmaHandle, IN PNDIS_BUFFER Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN WriteToDevice)
 
VOID EXPORT NdisMCompleteDmaTransfer (OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportDmaHandle, IN PNDIS_BUFFER Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN WriteToDevice)
 
VOID EXPORT NdisCompleteDmaTransfer (OUT PNDIS_STATUS Status, IN PNDIS_HANDLE NdisDmaHandle, IN PNDIS_BUFFER Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN WriteToDevice)
 
VOID EXPORT NdisMStartBufferPhysicalMapping (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_BUFFER Buffer, IN ULONG PhysicalMapRegister, IN BOOLEAN WriteToDevice, OUT PNDIS_PHYSICAL_ADDRESS_UNIT PhysicalAddressArray, OUT PUINT ArraySize)
 
VOID EXPORT NdisMCompleteBufferPhysicalMapping (IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_BUFFER Buffer, IN ULONG PhysicalMapRegister)
 
VOID EXPORT NdisMDeregisterDmaChannel (IN NDIS_HANDLE MiniportDmaHandle)
 
VOID EXPORT NdisMDeregisterInterrupt (IN PNDIS_MINIPORT_INTERRUPT Interrupt)
 
VOID EXPORT NdisMFreeMapRegisters (IN NDIS_HANDLE MiniportAdapterHandle)
 
NDIS_STATUS EXPORT NdisMMapIoSpace (OUT PVOID *VirtualAddress, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, IN UINT Length)
 
ULONG EXPORT NdisMReadDmaCounter (IN NDIS_HANDLE MiniportDmaHandle)
 
ULONG EXPORT NdisMGetDmaAlignment (IN NDIS_HANDLE MiniportAdapterHandle)
 
NDIS_STATUS EXPORT NdisMRegisterDmaChannel (OUT PNDIS_HANDLE MiniportDmaHandle, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT DmaChannel, IN BOOLEAN Dma32BitAddresses, IN PNDIS_DMA_DESCRIPTION DmaDescription, IN ULONG MaximumLength)
 
VOID EXPORT NdisAllocateDmaChannel (OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisDmaHandle, IN NDIS_HANDLE NdisAdapterHandle, IN PNDIS_DMA_DESCRIPTION DmaDescription, IN ULONG MaximumLength)
 
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)
 
NDIS_STATUS EXPORT NdisMRegisterIoPortRange (OUT PVOID *PortOffset, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts)
 
VOID EXPORT NdisMDeregisterIoPortRange (IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, IN UINT NumberOfPorts, IN PVOID PortOffset)
 
VOID EXPORT NdisMUnmapIoSpace (IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID VirtualAddress, IN UINT Length)
 
NDIS_STATUS EXPORT NdisMInitializeScatterGatherDma (IN NDIS_HANDLE MiniportAdapterHandle, IN BOOLEAN Dma64BitAddresses, IN ULONG MaximumPhysicalMapping)
 
VOID EXPORT NdisMapIoSpace (OUT PNDIS_STATUS Status, OUT PVOID *VirtualAddress, IN NDIS_HANDLE NdisAdapterHandle, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, IN UINT Length)
 
VOID EXPORT NdisFreeDmaChannel (IN PNDIS_HANDLE NdisDmaHandle)
 

Function Documentation

◆ HandleDeferredProcessing()

VOID NTAPI HandleDeferredProcessing ( IN PKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 16 of file io.c.

29{
31
32 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
33
35
36 /* Call the deferred interrupt service handler for this adapter */
37 (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.HandleInterruptHandler)(
39
40 /* re-enable the interrupt */
41 NDIS_DbgPrint(MAX_TRACE, ("re-enabling the interrupt\n"));
42 if(Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.EnableInterruptHandler)
43 (*Adapter->NdisMiniportBlock.DriverHandle->MiniportCharacteristics.EnableInterruptHandler)(
45
46 NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
47}
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define GET_LOGICAL_ADAPTER(Handle)
Definition: miniport.h:101
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define ASSERT(a)
Definition: mode.c:44
NDIS_MINIPORT_BLOCK NdisMiniportBlock
Definition: miniport.h:89
NDIS_HANDLE MiniportAdapterContext
Definition: ndis.h:2510
PNDIS_M_DRIVER_BLOCK DriverHandle
Definition: ndis.h:2509
NDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics
Definition: miniport.h:22
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:687

Referenced by NdisMRegisterInterrupt().

◆ NdisAllocateDmaChannel()

VOID EXPORT NdisAllocateDmaChannel ( OUT PNDIS_STATUS  Status,
OUT PNDIS_HANDLE  NdisDmaHandle,
IN NDIS_HANDLE  NdisAdapterHandle,
IN PNDIS_DMA_DESCRIPTION  DmaDescription,
IN ULONG  MaximumLength 
)

Definition at line 922 of file io.c.

927{
928 *Status = NdisMRegisterDmaChannel(NdisDmaHandle,
929 NdisAdapterHandle,
930 0,
931 FALSE,
932 DmaDescription,
934}
#define FALSE
Definition: types.h:117
NDIS_STATUS EXPORT NdisMRegisterDmaChannel(OUT PNDIS_HANDLE MiniportDmaHandle, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT DmaChannel, IN BOOLEAN Dma32BitAddresses, IN PNDIS_DMA_DESCRIPTION DmaDescription, IN ULONG MaximumLength)
Definition: io.c:860
Status
Definition: gdiplustypes.h:25
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength

◆ NdisBusMasterMapRegisterCallback()

IO_ALLOCATION_ACTION NTAPI NdisBusMasterMapRegisterCallback ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  MapRegisterBase,
IN PVOID  Context 
)

Definition at line 216 of file io.c.

232{
233 PLOGICAL_ADAPTER Adapter = Context;
234
235 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
236
237 Adapter->NdisMiniportBlock.MapRegisters[Adapter->NdisMiniportBlock.CurrentMapRegister].MapRegister = MapRegisterBase;
238
239 NDIS_DbgPrint(MAX_TRACE, ("setting event and leaving.\n"));
240
241 KeSetEvent(Adapter->NdisMiniportBlock.AllocationEvent, 0, FALSE);
242
243 /* We're a bus master so we can go ahead and deallocate the object now */
245}
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
PVOID MapRegister
Definition: haltypes.h:186
PMAP_REGISTER_ENTRY MapRegisters
Definition: ndis.h:2555
_Inout_ struct _IRP _In_ PVOID MapRegisterBase
Definition: iotypes.h:213
@ DeallocateObjectKeepRegisters
Definition: iotypes.h:204

Referenced by NdisMAllocateMapRegisters().

◆ NdisCompleteDmaTransfer()

VOID EXPORT NdisCompleteDmaTransfer ( OUT PNDIS_STATUS  Status,
IN PNDIS_HANDLE  NdisDmaHandle,
IN PNDIS_BUFFER  Buffer,
IN ULONG  Offset,
IN ULONG  Length,
IN BOOLEAN  WriteToDevice 
)

Definition at line 559 of file io.c.

565{
567 NdisDmaHandle,
568 Buffer,
569 Offset,
570 Length,
572}
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN WriteToDevice
Definition: cdrom.h:992
Definition: bufpool.h:45
VOID EXPORT NdisMCompleteDmaTransfer(OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportDmaHandle, IN PNDIS_BUFFER Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN WriteToDevice)
Definition: io.c:523
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

◆ NdisFreeDmaChannel()

VOID EXPORT NdisFreeDmaChannel ( IN PNDIS_HANDLE  NdisDmaHandle)

Definition at line 1245 of file io.c.

1253{
1254 NdisMDeregisterDmaChannel(NdisDmaHandle);
1255}
VOID EXPORT NdisMDeregisterDmaChannel(IN NDIS_HANDLE MiniportDmaHandle)
Definition: io.c:681

◆ NdisImmediateReadPortUchar()

VOID EXPORT NdisImmediateReadPortUchar ( IN NDIS_HANDLE  WrapperConfigurationContext,
IN ULONG  Port,
OUT PUCHAR  Data 
)

Definition at line 107 of file io.c.

111{
112 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
113 *Data = READ_PORT_UCHAR(UlongToPtr(Port)); // FIXME: What to do with WrapperConfigurationContext?
114}
#define UlongToPtr(u)
Definition: config.h:106
CPPORT Port[4]
Definition: headless.c:35
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22

◆ NdisImmediateReadPortUlong()

VOID EXPORT NdisImmediateReadPortUlong ( IN NDIS_HANDLE  WrapperConfigurationContext,
IN ULONG  Port,
OUT PULONG  Data 
)

Definition at line 121 of file io.c.

125{
126 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
127 *Data = READ_PORT_ULONG(UlongToPtr(Port)); // FIXME: What to do with WrapperConfigurationContext?
128}
ULONG NTAPI READ_PORT_ULONG(IN PULONG Port)
Definition: portio.c:70

◆ NdisImmediateReadPortUshort()

VOID EXPORT NdisImmediateReadPortUshort ( IN NDIS_HANDLE  WrapperConfigurationContext,
IN ULONG  Port,
OUT PUSHORT  Data 
)

Definition at line 135 of file io.c.

139{
140 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
141 *Data = READ_PORT_USHORT(UlongToPtr(Port)); // FIXME: What to do with WrapperConfigurationContext?
142}
USHORT NTAPI READ_PORT_USHORT(IN PUSHORT Port)
Definition: portio.c:63

◆ NdisImmediateWritePortUchar()

VOID EXPORT NdisImmediateWritePortUchar ( IN NDIS_HANDLE  WrapperConfigurationContext,
IN ULONG  Port,
IN UCHAR  Data 
)

Definition at line 149 of file io.c.

153{
154 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
155 WRITE_PORT_UCHAR(UlongToPtr(Port), Data); // FIXME: What to do with WrapperConfigurationContext?
156}
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21

◆ NdisImmediateWritePortUlong()

VOID EXPORT NdisImmediateWritePortUlong ( IN NDIS_HANDLE  WrapperConfigurationContext,
IN ULONG  Port,
IN ULONG  Data 
)

Definition at line 163 of file io.c.

167{
168 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
169 WRITE_PORT_ULONG(UlongToPtr(Port), Data); // FIXME: What to do with WrapperConfigurationContext?
170}
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123

◆ NdisImmediateWritePortUshort()

VOID EXPORT NdisImmediateWritePortUshort ( IN NDIS_HANDLE  WrapperConfigurationContext,
IN ULONG  Port,
IN USHORT  Data 
)

Definition at line 177 of file io.c.

181{
182 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
183 WRITE_PORT_USHORT(UlongToPtr(Port), Data); // FIXME: What to do with WrapperConfigurationContext?
184}
VOID NTAPI WRITE_PORT_USHORT(IN PUSHORT Port, IN USHORT Value)
Definition: portio.c:115

◆ NdisMAllocateMapRegisters()

NDIS_STATUS EXPORT NdisMAllocateMapRegisters ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN UINT  DmaChannel,
IN NDIS_DMA_SIZE  DmaSize,
IN ULONG  BaseMapRegistersNeeded,
IN ULONG  MaximumBufferSize 
)

Definition at line 252 of file io.c.

287{
289 PDMA_ADAPTER AdapterObject = 0;
290 UINT MapRegistersPerBaseRegister = 0;
291 ULONG AvailableMapRegisters;
292 NTSTATUS NtStatus;
293 PLOGICAL_ADAPTER Adapter;
295 KEVENT AllocationEvent;
297
298 NDIS_DbgPrint(MAX_TRACE, ("called: Handle 0x%x, DmaChannel 0x%x, DmaSize 0x%x, BaseMapRegsNeeded: 0x%x, MaxBuffer: 0x%x.\n",
299 MiniportAdapterHandle, DmaChannel, DmaSize, BaseMapRegistersNeeded, MaximumBufferSize));
300
301 memset(&Description,0,sizeof(Description));
302
304
305 ASSERT(Adapter);
306
307 /* only bus masters may call this routine */
309 NDIS_DbgPrint(MIN_TRACE, ("Not a bus master\n"));
311 }
312
314
315 KeInitializeEvent(&AllocationEvent, NotificationEvent, FALSE);
316 Adapter->NdisMiniportBlock.AllocationEvent = &AllocationEvent;
317
318 /*
319 * map registers correlate to physical pages. ndis documents a
320 * maximum of 64 map registers that it will return.
321 * at 4k pages, a 1514-byte buffer can span not more than 2 pages.
322 *
323 * the number of registers required for a given physical mapping
324 * is (first register + last register + one per page size),
325 * given that physical mapping is > 2.
326 */
327
328 /* unhandled corner case: {1,2}-byte max buffer size */
329 ASSERT(MaximumBufferSize > 2);
330 MapRegistersPerBaseRegister = ((MaximumBufferSize-2) / (2*PAGE_SIZE)) + 2;
331
333 Description.Master = TRUE; /* implied by calling this function */
334 Description.ScatterGather = TRUE; /* XXX UNTRUE: All BM DMA are S/G (ms seems to do this) */
335 Description.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
336 Description.InterfaceType = Adapter->NdisMiniportBlock.BusType;
337 Description.DmaChannel = DmaChannel;
338 Description.MaximumLength = MaximumBufferSize;
339
340 if(DmaSize == NDIS_DMA_64BITS)
341 Description.Dma64BitAddresses = TRUE;
342 else if(DmaSize == NDIS_DMA_32BITS)
343 Description.Dma32BitAddresses = TRUE;
344
345 AdapterObject = IoGetDmaAdapter(
346 Adapter->NdisMiniportBlock.PhysicalDeviceObject, &Description, &AvailableMapRegisters);
347
348 if(!AdapterObject)
349 {
350 NDIS_DbgPrint(MIN_TRACE, ("Unable to allocate an adapter object; bailing out\n"));
352 }
353
354 Adapter->NdisMiniportBlock.SystemAdapterObject = AdapterObject;
355
356 if(AvailableMapRegisters < MapRegistersPerBaseRegister)
357 {
358 NDIS_DbgPrint(MIN_TRACE, ("Didn't get enough map registers from hal - requested 0x%x, got 0x%x\n",
359 MapRegistersPerBaseRegister, AvailableMapRegisters));
360
361 AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
362 Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
364 }
365
366 /* allocate & zero space in the miniport block for the registers */
367 Adapter->NdisMiniportBlock.MapRegisters = ExAllocatePool(NonPagedPool, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
368 if(!Adapter->NdisMiniportBlock.MapRegisters)
369 {
370 NDIS_DbgPrint(MIN_TRACE, ("insufficient resources.\n"));
371 AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
372 Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
374 }
375
376 memset(Adapter->NdisMiniportBlock.MapRegisters, 0, BaseMapRegistersNeeded * sizeof(MAP_REGISTER_ENTRY));
377 Adapter->NdisMiniportBlock.BaseMapRegistersNeeded = (USHORT)BaseMapRegistersNeeded;
378
379 while(BaseMapRegistersNeeded)
380 {
381 NDIS_DbgPrint(MAX_TRACE, ("iterating, basemapregistersneeded = %d\n", BaseMapRegistersNeeded));
382
383 BaseMapRegistersNeeded--;
384 Adapter->NdisMiniportBlock.CurrentMapRegister = (USHORT)BaseMapRegistersNeeded;
386 {
387 NtStatus = AdapterObject->DmaOperations->AllocateAdapterChannel(
388 AdapterObject, DeviceObject, MapRegistersPerBaseRegister,
390 }
392
393 if(!NT_SUCCESS(NtStatus))
394 {
395 NDIS_DbgPrint(MIN_TRACE, ("IoAllocateAdapterChannel failed: 0x%x\n", NtStatus));
397 AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
398 Adapter->NdisMiniportBlock.CurrentMapRegister = Adapter->NdisMiniportBlock.BaseMapRegistersNeeded = 0;
399 Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
401 }
402
403 NDIS_DbgPrint(MAX_TRACE, ("waiting on event\n"));
404
405 NtStatus = KeWaitForSingleObject(&AllocationEvent, Executive, KernelMode, FALSE, 0);
406
407 if(!NT_SUCCESS(NtStatus))
408 {
409 NDIS_DbgPrint(MIN_TRACE, ("KeWaitForSingleObject failed: 0x%x\n", NtStatus));
411 AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
412 Adapter->NdisMiniportBlock.CurrentMapRegister = Adapter->NdisMiniportBlock.BaseMapRegistersNeeded = 0;
413 Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
415 }
416
417 NDIS_DbgPrint(MAX_TRACE, ("resetting event\n"));
418
419 KeClearEvent(&AllocationEvent);
420 }
421
422 NDIS_DbgPrint(MAX_TRACE, ("returning success\n"));
423 return NDIS_STATUS_SUCCESS;
424}
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR Description[]
Definition: oid.c:1266
struct _LOGICAL_ADAPTER * PLOGICAL_ADAPTER
IO_ALLOCATION_ACTION NTAPI NdisBusMasterMapRegisterCallback(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID MapRegisterBase, IN PVOID Context)
Definition: io.c:216
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define NDIS_DMA_32BITS
Definition: ndis.h:881
unsigned int UINT
Definition: ndis.h:50
#define NDIS_ATTRIBUTE_BUS_MASTER
Definition: ndis.h:586
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_DMA_64BITS
Definition: ndis.h:882
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
unsigned short USHORT
Definition: pedump.c:61
PDMA_ADAPTER NTAPI IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_DESCRIPTION DeviceDescription, IN OUT PULONG NumberOfMapRegisters)
Definition: pnpdma.c:23
#define memset(x, y, z)
Definition: compat.h:39
struct _DMA_OPERATIONS * DmaOperations
Definition: iotypes.h:2295
Definition: haltypes.h:185
PDEVICE_OBJECT DeviceObject
Definition: ndis.h:2552
PDEVICE_OBJECT PhysicalDeviceObject
Definition: ndis.h:2553
NDIS_INTERFACE_TYPE BusType
Definition: ndis.h:2550
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define DEVICE_DESCRIPTION_VERSION
Definition: iotypes.h:2063
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:415

Referenced by MiniportInitialize(), and ParaNdis_FinishSpecificInitialization().

◆ NdisMapIoSpace()

VOID EXPORT NdisMapIoSpace ( OUT PNDIS_STATUS  Status,
OUT PVOID VirtualAddress,
IN NDIS_HANDLE  NdisAdapterHandle,
IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress,
IN UINT  Length 
)

Definition at line 1220 of file io.c.

1232{
1234 NdisAdapterHandle,
1236 Length);
1237}
NDIS_STATUS EXPORT NdisMMapIoSpace(OUT PVOID *VirtualAddress, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, IN UINT Length)
Definition: io.c:774
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

◆ NdisMCompleteBufferPhysicalMapping()

VOID EXPORT NdisMCompleteBufferPhysicalMapping ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN PNDIS_BUFFER  Buffer,
IN ULONG  PhysicalMapRegister 
)

Definition at line 644 of file io.c.

657{
658 PLOGICAL_ADAPTER Adapter;
659 VOID *CurrentVa;
661
664
666 CurrentVa = MmGetMdlVirtualAddress(Buffer);
668
669 Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->FlushAdapterBuffers(
670 Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer,
671 Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
672 CurrentVa, Length,
673 Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice);
674}
BOOLEAN WriteToDevice
Definition: haltypes.h:187
#define MmGetMdlByteCount(_Mdl)
#define MmGetMdlVirtualAddress(_Mdl)

◆ NdisMCompleteDmaTransfer()

VOID EXPORT NdisMCompleteDmaTransfer ( OUT PNDIS_STATUS  Status,
IN NDIS_HANDLE  MiniportDmaHandle,
IN PNDIS_BUFFER  Buffer,
IN ULONG  Offset,
IN ULONG  Length,
IN BOOLEAN  WriteToDevice 
)

Definition at line 523 of file io.c.

529{
530 PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
531 PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
532
533 NDIS_DbgPrint(MAX_TRACE, ("called: Handle 0x%x, Buffer 0x%x, Offset 0x%x, Length 0x%x, WriteToDevice 0x%x\n",
534 MiniportDmaHandle, Buffer, Offset, Length, WriteToDevice));
535
536 if (!AdapterObject->DmaOperations->FlushAdapterBuffers(AdapterObject,
537 Buffer,
538 DmaBlock->MapRegisterBase,
540 Length,
542 {
543 NDIS_DbgPrint(MIN_TRACE, ("FlushAdapterBuffers failed\n"));
545 return;
546 }
547
548 AdapterObject->DmaOperations->FreeAdapterChannel(AdapterObject);
549
550 NDIS_DbgPrint(MAX_TRACE, ("returning success\n"));
552}
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
PVOID MapRegisterBase
Definition: ndis.h:871
PADAPTER_OBJECT SystemAdapterObject
Definition: ndis.h:873
unsigned char * PUCHAR
Definition: typedefs.h:53
struct _DMA_ADAPTER * PDMA_ADAPTER

Referenced by NdisCompleteDmaTransfer().

◆ NdisMDeregisterDmaChannel()

VOID EXPORT NdisMDeregisterDmaChannel ( IN NDIS_HANDLE  MiniportDmaHandle)

Definition at line 681 of file io.c.

683{
684 PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
685 PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
686
687 if (AdapterObject == ((PLOGICAL_ADAPTER)DmaBlock->Miniport)->NdisMiniportBlock.SystemAdapterObject)
688 ((PLOGICAL_ADAPTER)DmaBlock->Miniport)->NdisMiniportBlock.SystemAdapterObject = NULL;
689
690 AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
691
692 ExFreePool(DmaBlock);
693}
if(dx< 0)
Definition: linetemp.h:194
PVOID Miniport
Definition: ndis.h:874

Referenced by NdisFreeDmaChannel().

◆ NdisMDeregisterInterrupt()

VOID EXPORT NdisMDeregisterInterrupt ( IN PNDIS_MINIPORT_INTERRUPT  Interrupt)

Definition at line 700 of file io.c.

707{
708 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
709 IoDisconnectInterrupt(Interrupt->InterruptObject);
710 Interrupt->Miniport->RegisteredInterrupts--;
711
712 if (Interrupt->Miniport->Interrupt == Interrupt)
713 Interrupt->Miniport->Interrupt = NULL;
714}
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:142
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379

Referenced by DcFreeAdapter(), MiniportHalt(), MiniportInitialize(), NICUnregisterInterrupts(), NvNetFreeAdapter(), and ParaNdis_FinalizeCleanup().

◆ NdisMDeregisterIoPortRange()

VOID EXPORT NdisMDeregisterIoPortRange ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN UINT  InitialPort,
IN UINT  NumberOfPorts,
IN PVOID  PortOffset 
)

Definition at line 1093 of file io.c.

1105{
1109 ULONG AddressSpace = 1;
1110
1111 NDIS_DbgPrint(MAX_TRACE, ("Called - InitialPort 0x%x, NumberOfPorts 0x%x, Port Offset 0x%x\n", InitialPort, NumberOfPorts, PortOffset));
1112
1113 /* Translate the initial port again to find the address space of the translated address */
1115 PortAddress, &AddressSpace, &TranslatedAddress))
1116 {
1117 NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));
1118 return;
1119 }
1120
1121 /* Make sure we got the same translation as last time */
1123
1124 /* Check if we're in memory space */
1125 if (!AddressSpace)
1126 {
1127 NDIS_DbgPrint(MAX_TRACE, ("Calling MmUnmapIoSpace\n"));
1128
1129 /* Unmap the memory */
1131 }
1132}
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
NTSYSAPI ULONGLONG WINAPI RtlConvertUlongToLargeInteger(ULONG)
Definition: largeint.c:47
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
_In_ UINT _In_ UINT _In_ PVOID PortOffset
Definition: ndis.h:5445
_In_ UINT InitialPort
Definition: ndis.h:5443
#define NumberOfPorts()
Definition: portcls.h:444
uint32_t ULONG_PTR
Definition: typedefs.h:65
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274

Referenced by DcFreeAdapter(), MiniportHalt(), MiniportInitialize(), NICReleaseIoResources(), and ParaNdis_CleanupContext().

◆ NdisMFreeMapRegisters()

VOID EXPORT NdisMFreeMapRegisters ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 721 of file io.c.

729{
732 PDMA_ADAPTER AdapterObject;
733 UINT MapRegistersPerBaseRegister;
734 UINT i;
735
736 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
737
738 ASSERT(Adapter);
739
740 /* only bus masters may call this routine */
742 Adapter->NdisMiniportBlock.SystemAdapterObject == NULL) {
743 NDIS_DbgPrint(MIN_TRACE, ("Not bus master or bad adapter object\n"));
744 return;
745 }
746
747 MapRegistersPerBaseRegister = ((Adapter->NdisMiniportBlock.MaximumPhysicalMapping - 2) / PAGE_SIZE) + 2;
748
749 AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
750
752 {
753 for(i = 0; i < Adapter->NdisMiniportBlock.BaseMapRegistersNeeded; i++)
754 {
755 AdapterObject->DmaOperations->FreeMapRegisters(
756 Adapter->NdisMiniportBlock.SystemAdapterObject,
758 MapRegistersPerBaseRegister);
759 }
760 }
762
763 AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
764 Adapter->NdisMiniportBlock.SystemAdapterObject = NULL;
765
767}
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

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

◆ NdisMGetDmaAlignment()

ULONG EXPORT NdisMGetDmaAlignment ( IN NDIS_HANDLE  MiniportAdapterHandle)

Definition at line 843 of file io.c.

845{
846 /* NOTE: Unlike NdisMReadDmaCounter() above, this is a handle to the NDIS miniport block */
848 PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)Adapter->NdisMiniportBlock.SystemAdapterObject;
849
850 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
851
852 return AdapterObject->DmaOperations->GetDmaAlignment(AdapterObject);
853}

◆ NdisMInitializeScatterGatherDma()

NDIS_STATUS EXPORT NdisMInitializeScatterGatherDma ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN BOOLEAN  Dma64BitAddresses,
IN ULONG  MaximumPhysicalMapping 
)

Definition at line 1169 of file io.c.

1179{
1181 ULONG MapRegisters;
1182 DEVICE_DESCRIPTION DeviceDesc;
1183
1184 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
1185
1187 NDIS_DbgPrint(MIN_TRACE, ("Not a bus master\n"));
1189 }
1190
1191 RtlZeroMemory(&DeviceDesc, sizeof(DEVICE_DESCRIPTION));
1192
1194 DeviceDesc.Master = TRUE;
1195 DeviceDesc.ScatterGather = TRUE;
1196 DeviceDesc.Dma32BitAddresses = TRUE; // All callers support 32-bit addresses
1198 DeviceDesc.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
1199 DeviceDesc.InterfaceType = Adapter->NdisMiniportBlock.BusType;
1201
1202 Adapter->NdisMiniportBlock.SystemAdapterObject =
1203 IoGetDmaAdapter(Adapter->NdisMiniportBlock.PhysicalDeviceObject, &DeviceDesc, &MapRegisters);
1204
1205 if (!Adapter->NdisMiniportBlock.SystemAdapterObject)
1206 return NDIS_STATUS_RESOURCES;
1207
1208 /* FIXME: Right now we just use this as a place holder */
1209 Adapter->NdisMiniportBlock.ScatterGatherListSize = 1;
1210
1211 return NDIS_STATUS_SUCCESS;
1212}
_In_ BOOLEAN Dma64BitAddresses
Definition: ndis.h:4652
_In_ BOOLEAN _In_ ULONG MaximumPhysicalMapping
Definition: ndis.h:4653
BOOLEAN Dma64BitAddresses
Definition: iotypes.h:2077
BOOLEAN ScatterGather
Definition: iotypes.h:2071
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2080
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2074
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by DcAllocateMemory(), MiniportInitialize(), and ParaNdis_FinishSpecificInitialization().

◆ NdisMMapIoSpace()

NDIS_STATUS EXPORT NdisMMapIoSpace ( OUT PVOID VirtualAddress,
IN NDIS_HANDLE  MiniportAdapterHandle,
IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress,
IN UINT  Length 
)

Definition at line 774 of file io.c.

794{
796 ULONG AddressSpace = 0; /* Memory Space */
798
799 PAGED_CODE();
801
802 NDIS_DbgPrint(MAX_TRACE, ("Called\n"));
803
806 {
807 NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));
809 }
810
812
813 if(!*VirtualAddress) {
814 NDIS_DbgPrint(MIN_TRACE, ("MmMapIoSpace failed\n"));
816 }
817
818 return NDIS_STATUS_SUCCESS;
819}
#define PAGED_CODE()
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
@ MmNonCached
Definition: mmtypes.h:129

Referenced by DcInitializeAdapterResources(), NdisMapIoSpace(), NICAllocateIoResources(), NvNetInitializeAdapterResources(), and pci_map_address_range().

◆ NdisMReadDmaCounter()

ULONG EXPORT NdisMReadDmaCounter ( IN NDIS_HANDLE  MiniportDmaHandle)

Definition at line 826 of file io.c.

828{
829 /* NOTE: Unlike NdisMGetDmaAlignment() below, this is a handle to the DMA block */
830 PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
831 PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
832
833 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
834
835 return AdapterObject->DmaOperations->ReadDmaCounter(AdapterObject);
836}

◆ NdisMRegisterDmaChannel()

NDIS_STATUS EXPORT NdisMRegisterDmaChannel ( OUT PNDIS_HANDLE  MiniportDmaHandle,
IN NDIS_HANDLE  MiniportAdapterHandle,
IN UINT  DmaChannel,
IN BOOLEAN  Dma32BitAddresses,
IN PNDIS_DMA_DESCRIPTION  DmaDescription,
IN ULONG  MaximumLength 
)

Definition at line 860 of file io.c.

867{
869 DEVICE_DESCRIPTION DeviceDesc;
870 ULONG MapRegisters;
871 PNDIS_DMA_BLOCK DmaBlock;
872
873 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
874
875 RtlZeroMemory(&DeviceDesc, sizeof(DEVICE_DESCRIPTION));
876
879 DeviceDesc.ScatterGather = FALSE;
880 DeviceDesc.DemandMode = DmaDescription->DemandMode;
881 DeviceDesc.AutoInitialize = DmaDescription->AutoInitialize;
882 DeviceDesc.Dma32BitAddresses = Dma32BitAddresses;
883 DeviceDesc.Dma64BitAddresses = FALSE;
884 DeviceDesc.BusNumber = Adapter->NdisMiniportBlock.BusNumber;
885 DeviceDesc.DmaChannel = DmaDescription->DmaChannel;
886 DeviceDesc.InterfaceType = Adapter->NdisMiniportBlock.BusType;
887 DeviceDesc.DmaWidth = DmaDescription->DmaWidth;
888 DeviceDesc.DmaSpeed = DmaDescription->DmaSpeed;
889 DeviceDesc.MaximumLength = MaximumLength;
890
891
892 DmaBlock = ExAllocatePool(NonPagedPool, sizeof(NDIS_DMA_BLOCK));
893 if (!DmaBlock) {
894 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
896 }
897
898 DmaBlock->SystemAdapterObject = (PVOID)IoGetDmaAdapter(Adapter->NdisMiniportBlock.PhysicalDeviceObject, &DeviceDesc, &MapRegisters);
899
900 if (!DmaBlock->SystemAdapterObject) {
901 NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
902 ExFreePool(DmaBlock);
904 }
905
906 Adapter->NdisMiniportBlock.SystemAdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
907
909
910 DmaBlock->Miniport = Adapter;
911
912 *MiniportDmaHandle = DmaBlock;
913
914 return NDIS_STATUS_SUCCESS;
915}
DMA_SPEED DmaSpeed
Definition: iotypes.h:2082
BOOLEAN AutoInitialize
Definition: iotypes.h:2073
DMA_WIDTH DmaWidth
Definition: iotypes.h:2081
BOOLEAN DemandMode
Definition: iotypes.h:2072
KEVENT AllocationEvent
Definition: ndis.h:872
void * PVOID
Definition: typedefs.h:50

Referenced by NdisAllocateDmaChannel().

◆ NdisMRegisterInterrupt()

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 at line 941 of file io.c.

962{
964 ULONG MappedIRQ;
965 KIRQL DIrql;
968
969 NDIS_DbgPrint(MAX_TRACE, ("Called. InterruptVector (0x%X) InterruptLevel (0x%X) "
970 "SharedInterrupt (%d) InterruptMode (0x%X)\n",
971 InterruptVector, InterruptLevel, SharedInterrupt, InterruptMode));
972
974
975 KeInitializeSpinLock(&Interrupt->DpcCountLock);
976
977 KeInitializeDpc(&Interrupt->InterruptDpc, HandleDeferredProcessing, Adapter);
978
979 KeInitializeEvent(&Interrupt->DpcsCompletedEvent, NotificationEvent, FALSE);
980
981 Interrupt->SharedInterrupt = SharedInterrupt;
982 Interrupt->IsrRequested = RequestIsr;
983 Interrupt->Miniport = &Adapter->NdisMiniportBlock;
984
986 InterruptLevel, InterruptVector, &DIrql,
987 &Affinity);
988
989 NDIS_DbgPrint(MAX_TRACE, ("Connecting to interrupt vector (0x%X) Affinity (0x%X).\n", MappedIRQ, Affinity));
990
991 Status = IoConnectInterrupt(&Interrupt->InterruptObject, ServiceRoutine, Interrupt, &Interrupt->DpcCountLock, MappedIRQ,
992 DIrql, DIrql, InterruptMode, SharedInterrupt, Affinity, FALSE);
993
994 NDIS_DbgPrint(MAX_TRACE, ("Leaving. Status (0x%X).\n", Status));
995
996 if (NT_SUCCESS(Status)) {
998 Adapter->NdisMiniportBlock.RegisteredInterrupts++;
999 return NDIS_STATUS_SUCCESS;
1000 }
1001
1003 {
1004 /* FIXME: Log error */
1005 NDIS_DbgPrint(MIN_TRACE, ("Resource conflict!\n"));
1007 }
1008
1009 NDIS_DbgPrint(MIN_TRACE, ("Function failed. Status (0x%X).\n", Status));
1010 return NDIS_STATUS_FAILURE;
1011}
ULONG_PTR KAFFINITY
Definition: compat.h:85
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
VOID NTAPI HandleDeferredProcessing(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: io.c:16
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define NDIS_STATUS_RESOURCE_CONFLICT
Definition: ndis.h:495
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:23
PNDIS_MINIPORT_INTERRUPT Interrupt
Definition: ndis.h:2522
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
_In_ PKSERVICE_ROUTINE ServiceRoutine
Definition: iofuncs.h:800
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
Definition: iofuncs.h:806

Referenced by DcInitialize(), MiniportInitialize(), NICRegisterInterrupts(), and ParaNdis_FinishSpecificInitialization().

◆ NdisMRegisterIoPortRange()

NDIS_STATUS EXPORT NdisMRegisterIoPortRange ( OUT PVOID PortOffset,
IN NDIS_HANDLE  MiniportAdapterHandle,
IN UINT  InitialPort,
IN UINT  NumberOfPorts 
)

Definition at line 1018 of file io.c.

1033{
1036 ULONG AddressSpace = 1; /* FIXME The HAL handles this wrong atm */
1037
1038 *PortOffset = 0;
1039
1040 NDIS_DbgPrint(MAX_TRACE, ("Called - InitialPort 0x%x, NumberOfPorts 0x%x\n", InitialPort, NumberOfPorts));
1041
1042 memset(&PortAddress, 0, sizeof(PortAddress));
1043
1044 /*
1045 * FIXME: NDIS 5+ completely ignores the InitialPort parameter, but
1046 * we don't have a way to get the I/O base address yet (see
1047 * NDIS_MINIPORT_BLOCK->AllocatedResources and
1048 * NDIS_MINIPORT_BLOCK->AllocatedResourcesTranslated).
1049 */
1050 if(InitialPort)
1052 else
1053 ASSERT(FALSE);
1054
1055 NDIS_DbgPrint(MAX_TRACE, ("Translating address 0x%x 0x%x\n", PortAddress.u.HighPart, PortAddress.u.LowPart));
1056
1058 PortAddress, &AddressSpace, &TranslatedAddress))
1059 {
1060 NDIS_DbgPrint(MIN_TRACE, ("Unable to translate address\n"));
1061 return NDIS_STATUS_RESOURCES;
1062 }
1063
1064 NDIS_DbgPrint(MAX_TRACE, ("Hal returned AddressSpace=0x%x TranslatedAddress=0x%x 0x%x\n",
1065 AddressSpace, TranslatedAddress.u.HighPart, TranslatedAddress.u.LowPart));
1066
1067 if(AddressSpace)
1068 {
1069 ASSERT(TranslatedAddress.u.HighPart == 0);
1071 NDIS_DbgPrint(MAX_TRACE, ("Returning 0x%x\n", *PortOffset));
1072 return NDIS_STATUS_SUCCESS;
1073 }
1074
1075 NDIS_DbgPrint(MAX_TRACE, ("calling MmMapIoSpace\n"));
1076
1078 NDIS_DbgPrint(MAX_TRACE, ("Returning 0x%x for port range\n", *PortOffset));
1079
1080 if(!*PortOffset) {
1081 NDIS_DbgPrint(MIN_TRACE, ("MmMapIoSpace failed\n"));
1082 return NDIS_STATUS_RESOURCES;
1083 }
1084
1085 return NDIS_STATUS_SUCCESS;
1086}
struct _LARGE_INTEGER::@2306 u

Referenced by DcInitializeAdapterResources(), MiniportInitialize(), NICAllocateIoResources(), and pci_map_address_range().

◆ NdisMSetupDmaTransfer()

VOID EXPORT NdisMSetupDmaTransfer ( OUT PNDIS_STATUS  Status,
IN NDIS_HANDLE  MiniportDmaHandle,
IN PNDIS_BUFFER  Buffer,
IN ULONG  Offset,
IN ULONG  Length,
IN BOOLEAN  WriteToDevice 
)

Definition at line 432 of file io.c.

438{
439 PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
440 NTSTATUS NtStatus;
441 PLOGICAL_ADAPTER Adapter;
443 PDMA_ADAPTER AdapterObject;
444 ULONG MapRegistersNeeded;
445
446 NDIS_DbgPrint(MAX_TRACE, ("called: Handle 0x%x, Buffer 0x%x, Offset 0x%x, Length 0x%x, WriteToDevice 0x%x\n",
447 MiniportDmaHandle, Buffer, Offset, Length, WriteToDevice));
448
449 Adapter = (PLOGICAL_ADAPTER)DmaBlock->Miniport;
450 AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
451
452 MapRegistersNeeded = (Length + (PAGE_SIZE - 1)) / PAGE_SIZE;
453
455
457 {
458 NtStatus = AdapterObject->DmaOperations->AllocateAdapterChannel(AdapterObject,
460 MapRegistersNeeded,
462 }
464
465 if(!NT_SUCCESS(NtStatus))
466 {
467 NDIS_DbgPrint(MIN_TRACE, ("AllocateAdapterChannel failed: 0x%x\n", NtStatus));
468 AdapterObject->DmaOperations->FreeAdapterChannel(AdapterObject);
470 return;
471 }
472
474
475 if(!NT_SUCCESS(NtStatus))
476 {
477 NDIS_DbgPrint(MIN_TRACE, ("KeWaitForSingleObject failed: 0x%x\n", NtStatus));
478 AdapterObject->DmaOperations->FreeAdapterChannel(AdapterObject);
480 return;
481 }
482
483 /* We must throw away the return value of MapTransfer for a system DMA device */
484 AdapterObject->DmaOperations->MapTransfer(AdapterObject, Buffer,
485 DmaBlock->MapRegisterBase,
487
488 NDIS_DbgPrint(MAX_TRACE, ("returning success\n"));
490}
IO_ALLOCATION_ACTION NTAPI NdisSubordinateMapRegisterCallback(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID MapRegisterBase, IN PVOID Context)
Definition: io.c:186
#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
Definition: ke.h:174

Referenced by NdisSetupDmaTransfer().

◆ NdisMStartBufferPhysicalMapping()

VOID EXPORT NdisMStartBufferPhysicalMapping ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN PNDIS_BUFFER  Buffer,
IN ULONG  PhysicalMapRegister,
IN BOOLEAN  WriteToDevice,
OUT PNDIS_PHYSICAL_ADDRESS_UNIT  PhysicalAddressArray,
OUT PUINT  ArraySize 
)

Definition at line 579 of file io.c.

602{
603 PLOGICAL_ADAPTER Adapter;
604 PVOID CurrentVa;
606 PHYSICAL_ADDRESS ReturnedAddress;
607 UINT LoopCount = 0;
608
610 ASSERT(MiniportAdapterHandle && Buffer && PhysicalAddressArray && ArraySize);
611
613 CurrentVa = MmGetMdlVirtualAddress(Buffer);
615
616 while(TotalLength)
617 {
619
620 ReturnedAddress = Adapter->NdisMiniportBlock.SystemAdapterObject->DmaOperations->MapTransfer(
621 Adapter->NdisMiniportBlock.SystemAdapterObject, Buffer,
622 Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].MapRegister,
623 CurrentVa, &Length, WriteToDevice);
624
625 Adapter->NdisMiniportBlock.MapRegisters[PhysicalMapRegister].WriteToDevice = WriteToDevice;
626
627 PhysicalAddressArray[LoopCount].PhysicalAddress = ReturnedAddress;
628 PhysicalAddressArray[LoopCount].Length = Length;
629
631 CurrentVa = (PVOID)((ULONG_PTR)CurrentVa + Length);
632
633 LoopCount++;
634 }
635
636 *ArraySize = LoopCount;
637}
_In_ ULONG TotalLength
Definition: usbdlib.h:158

◆ NdisMUnmapIoSpace()

VOID EXPORT NdisMUnmapIoSpace ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN PVOID  VirtualAddress,
IN UINT  Length 
)

Definition at line 1139 of file io.c.

1156{
1157 PAGED_CODE();
1158
1160
1162}

Referenced by DcFreeAdapter(), NICReleaseIoResources(), NvNetFreeAdapter(), and ParaNdis_CleanupContext().

◆ NdisSetupDmaTransfer()

VOID EXPORT NdisSetupDmaTransfer ( OUT PNDIS_STATUS  Status,
IN PNDIS_HANDLE  NdisDmaHandle,
IN PNDIS_BUFFER  Buffer,
IN ULONG  Offset,
IN ULONG  Length,
IN BOOLEAN  WriteToDevice 
)

Definition at line 497 of file io.c.

509{
511 NdisDmaHandle,
512 Buffer,
513 Offset,
514 Length,
516}
VOID EXPORT NdisMSetupDmaTransfer(OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportDmaHandle, IN PNDIS_BUFFER Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN WriteToDevice)
Definition: io.c:432

◆ NdisSubordinateMapRegisterCallback()

IO_ALLOCATION_ACTION NTAPI NdisSubordinateMapRegisterCallback ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  MapRegisterBase,
IN PVOID  Context 
)

Definition at line 186 of file io.c.

201{
202 PNDIS_DMA_BLOCK DmaBlock = Context;
203
204 NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
205
207
208 NDIS_DbgPrint(MAX_TRACE, ("setting event and leaving.\n"));
209
210 KeSetEvent(&DmaBlock->AllocationEvent, 0, FALSE);
211
212 /* We have to hold the object open to keep our lock on the system DMA controller */
213 return KeepObject;
214}
@ KeepObject
Definition: iotypes.h:202

Referenced by NdisMSetupDmaTransfer().

◆ ServiceRoutine()

BOOLEAN NTAPI ServiceRoutine ( IN PKINTERRUPT  Interrupt,
IN PVOID  ServiceContext 
)

Definition at line 49 of file io.c.

60{
61 BOOLEAN InterruptRecognized = FALSE;
62 BOOLEAN QueueMiniportHandleInterrupt = FALSE;
64 PNDIS_MINIPORT_BLOCK NdisMiniportBlock = NdisInterrupt->Miniport;
65 BOOLEAN Initializing;
66
67 NDIS_DbgPrint(MAX_TRACE, ("Called. Interrupt (0x%X)\n", NdisInterrupt));
68
69 /* Certain behavior differs if MiniportInitialize is executing when the interrupt is generated */
70 Initializing = (NdisMiniportBlock->PnPDeviceState != NdisPnPDeviceStarted);
71 NDIS_DbgPrint(MAX_TRACE, ("MiniportInitialize executing: %s\n", (Initializing ? "yes" : "no")));
72
73 /* MiniportISR is always called for interrupts during MiniportInitialize */
74 if ((Initializing) || (NdisInterrupt->IsrRequested) || (NdisInterrupt->SharedInterrupt)) {
75 NDIS_DbgPrint(MAX_TRACE, ("Calling MiniportISR\n"));
76 (*NdisMiniportBlock->DriverHandle->MiniportCharacteristics.ISRHandler)(
77 &InterruptRecognized,
78 &QueueMiniportHandleInterrupt,
79 NdisMiniportBlock->MiniportAdapterContext);
80
81 } else if (NdisMiniportBlock->DriverHandle->MiniportCharacteristics.DisableInterruptHandler) {
82 NDIS_DbgPrint(MAX_TRACE, ("Calling MiniportDisableInterrupt\n"));
83 (*NdisMiniportBlock->DriverHandle->MiniportCharacteristics.DisableInterruptHandler)(
84 NdisMiniportBlock->MiniportAdapterContext);
85 QueueMiniportHandleInterrupt = TRUE;
86 InterruptRecognized = TRUE;
87 }
88
89 /* TODO: Figure out if we should call this or not if Initializing is true. It appears
90 * that calling it fixes some NICs, but documentation is contradictory on it. */
91 if (QueueMiniportHandleInterrupt)
92 {
93 NDIS_DbgPrint(MAX_TRACE, ("Queuing DPC.\n"));
94 KeInsertQueueDpc(&NdisInterrupt->InterruptDpc, NULL, NULL);
95 }
96
97 NDIS_DbgPrint(MAX_TRACE, ("Leaving.\n"));
98
99 return InterruptRecognized;
100}
unsigned char BOOLEAN
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:725
@ NdisPnPDeviceStarted
Definition: ndis.h:991
BOOLEAN SharedInterrupt
Definition: ndis.h:2243
PNDIS_MINIPORT_BLOCK Miniport
Definition: ndis.h:2239
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:801