ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

VOID EXPORT NdisMFreeSharedMemory ( IN NDIS_HANDLE  MiniportAdapterHandle,
IN ULONG  Length,
IN BOOLEAN  Cached,
IN PVOID  VirtualAddress,
IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 221 of file memory.c.

Referenced by MiFreeSharedMemory(), and NdisFreeSharedMemory().

{
  PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
  PMINIPORT_SHARED_MEMORY Memory;
  PDMA_ADAPTER DmaAdapter = Adapter->NdisMiniportBlock.SystemAdapterObject;

  NDIS_DbgPrint(MAX_TRACE,("Called.\n"));

  ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
    
  /* Call FreeCommonBuffer synchronously if we are at PASSIVE_LEVEL */
  if (KeGetCurrentIrql() == PASSIVE_LEVEL)
  {
      /* We need this case because we free shared memory asynchronously
       * and the miniport (and DMA adapter object) could be freed before
       * our work item executes. Lucky for us, the scenarios where the
       * freeing needs to be synchronous (failed init, MiniportHalt,
       * and driver unload) are all at PASSIVE_LEVEL so we can just
       * call FreeCommonBuffer synchronously and not have to worry
       * about the miniport falling out from under us */

      NDIS_DbgPrint(MID_TRACE,("Freeing shared memory synchronously\n"));

      DmaAdapter->DmaOperations->FreeCommonBuffer(DmaAdapter,
                                                  Length,
                                                  PhysicalAddress,
                                                  VirtualAddress,
                                                  Cached);
      return;
  }

  /* Must be NonpagedPool because by definition we're at DISPATCH_LEVEL */
  Memory = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_SHARED_MEMORY));

  if(!Memory)
    {
      NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
      return;
    }

  Memory->AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
  Memory->Length = Length;
  Memory->PhysicalAddress = PhysicalAddress;
  Memory->VirtualAddress = VirtualAddress;
  Memory->Cached = Cached;
  Memory->Adapter = &Adapter->NdisMiniportBlock;

  Memory->WorkItem = IoAllocateWorkItem(Adapter->NdisMiniportBlock.DeviceObject);
  if (!Memory->WorkItem)
  {
      NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
      ExFreePool(Memory);
      return;
  }

  IoQueueWorkItem(Memory->WorkItem,
                  NdisMFreeSharedMemoryPassive,
                  CriticalWorkQueue,
                  Memory);
}

Generated on Fri May 25 2012 04:44:30 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.