Esempio n. 1
0
static
NTSTATUS
IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode)
{
   IO_STACK_LOCATION Stack;
   IO_STATUS_BLOCK IoStatusBlock;
   NTSTATUS Status;

   DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n");

   Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList = DeviceNode->ResourceRequirements;
   Status = IopInitiatePnpIrp(
      DeviceNode->PhysicalDeviceObject,
      &IoStatusBlock,
      IRP_MN_FILTER_RESOURCE_REQUIREMENTS,
      &Stack);
   if (!NT_SUCCESS(Status) && Status != STATUS_NOT_SUPPORTED)
   {
      DPRINT1("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n");
      return Status;
   }
   else if (NT_SUCCESS(Status) && IoStatusBlock.Information)
   {
      DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information;
   }

   return STATUS_SUCCESS;
}
Esempio n. 2
0
/*
 * @implemented
 */
PDMA_ADAPTER
NTAPI
IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject,
                IN PDEVICE_DESCRIPTION DeviceDescription,
                IN OUT PULONG NumberOfMapRegisters)
{
    NTSTATUS Status;
    ULONG ResultLength;
    BUS_INTERFACE_STANDARD BusInterface;
    IO_STATUS_BLOCK IoStatusBlock;
    IO_STACK_LOCATION Stack;
    DEVICE_DESCRIPTION PrivateDeviceDescription;
    PDMA_ADAPTER Adapter = NULL;

    DPRINT("IoGetDmaAdapter called\n");


    /* Try to create DMA adapter through bus driver */
    if (PhysicalDeviceObject)
    {
        if (DeviceDescription->InterfaceType == PNPBus ||
            DeviceDescription->InterfaceType == InterfaceTypeUndefined)
        {
            RtlCopyMemory(&PrivateDeviceDescription,
                          DeviceDescription,
                          sizeof(DEVICE_DESCRIPTION));

            Status = IoGetDeviceProperty(PhysicalDeviceObject,
                                         DevicePropertyLegacyBusType,
                                         sizeof(INTERFACE_TYPE),
                                         &PrivateDeviceDescription.InterfaceType,
                                         &ResultLength);

            if (!NT_SUCCESS(Status))
                PrivateDeviceDescription.InterfaceType = Internal;

            DeviceDescription = &PrivateDeviceDescription;
        }

        Stack.Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);
        Stack.Parameters.QueryInterface.Version = 1;
        Stack.Parameters.QueryInterface.Interface = (PINTERFACE)&BusInterface;
        Stack.Parameters.QueryInterface.InterfaceType =
            &GUID_BUS_INTERFACE_STANDARD;

        Status = IopInitiatePnpIrp(PhysicalDeviceObject,
                                   &IoStatusBlock,
                                   IRP_MN_QUERY_INTERFACE,
                                   &Stack);

        if (NT_SUCCESS(Status))
        {
            Adapter = BusInterface.GetDmaAdapter(BusInterface.Context,
                                                 DeviceDescription,
                                                 NumberOfMapRegisters);

            BusInterface.InterfaceDereference(BusInterface.Context);
            if (Adapter) return Adapter;
        }
    }

    /* Fall back to HAL */
    return HalGetDmaAdapter(PhysicalDeviceObject,
                            DeviceDescription,
                            NumberOfMapRegisters);
}