ReactOS  0.4.13-dev-687-g023794c
intrface.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for intrface.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI PciQueryInterface (IN PPCI_FDO_EXTENSION DeviceExtension, IN CONST GUID *InterfaceType, IN ULONG Size, IN ULONG Version, IN PVOID InterfaceData, IN PINTERFACE Interface, IN BOOLEAN LastChance)
 

Variables

PPCI_INTERFACE PciInterfaces []
 
PPCI_INTERFACE PciInterfacesLastResort []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file intrface.c.

Function Documentation

◆ PciQueryInterface()

NTSTATUS NTAPI PciQueryInterface ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN CONST GUID InterfaceType,
IN ULONG  Size,
IN ULONG  Version,
IN PVOID  InterfaceData,
IN PINTERFACE  Interface,
IN BOOLEAN  LastChance 
)

Definition at line 45 of file intrface.c.

52 {
56  PPCI_INTERFACE PciInterface;
57  RtlStringFromGUID(InterfaceType, &GuidString);
58  DPRINT1("PCI - PciQueryInterface TYPE = %wZ\n", &GuidString);
60  DPRINT1(" Size = %u, Version = %u, InterfaceData = %p, LastChance = %s\n",
61  Size,
62  Version,
64  LastChance ? "TRUE" : "FALSE");
65 
66  /* Loop all the available interfaces */
69  InterfaceList++)
70  {
71  /* Get the current interface */
72  PciInterface = *InterfaceList;
73 
74  /* For debugging, construct the GUID string */
76 
77  /* Check if this is an FDO or PDO */
78  if (DeviceExtension->ExtensionType == PciFdoExtensionType)
79  {
80  /* Check if the interface is for FDOs */
81  if (!(PciInterface->Flags & PCI_INTERFACE_FDO))
82  {
83  /* This interface is not for FDOs, skip it */
84  DPRINT1("PCI - PciQueryInterface: guid = %wZ only for FDOs\n",
85  &GuidString);
87  continue;
88  }
89 
90  /* Check if the interface is for root FDO only */
91  if ((PciInterface->Flags & PCI_INTERFACE_ROOT) &&
92  (!PCI_IS_ROOT_FDO(DeviceExtension)))
93  {
94  /* This FDO isn't the root, skip the interface */
95  DPRINT1("PCI - PciQueryInterface: guid = %wZ only for ROOT\n",
96  &GuidString);
98  continue;
99  }
100  }
101  else
102  {
103  /* This is a PDO, check if the interface is for PDOs too */
104  if (!(PciInterface->Flags & PCI_INTERFACE_PDO))
105  {
106  /* It isn't, skip it */
107  DPRINT1("PCI - PciQueryInterface: guid = %wZ only for PDOs\n",
108  &GuidString);
110  continue;
111  }
112  }
113 
114  /* Print the GUID for debugging, and then free the string */
115  DPRINT1("PCI - PciQueryInterface looking at guid = %wZ\n", &GuidString);
117 
118  /* Check if the GUID, version, and size all match */
119  if ((IsEqualGUIDAligned(PciInterface->InterfaceType, InterfaceType)) &&
120  (Version >= PciInterface->MinVersion) &&
121  (Version <= PciInterface->MaxVersion) &&
122  (Size >= PciInterface->MinSize))
123  {
124  /* Call the interface's constructor */
125  Status = PciInterface->Constructor(DeviceExtension,
126  PciInterface,
128  Version,
129  Size,
130  Interface);
131  if (!NT_SUCCESS(Status))
132  {
133  /* This interface was not initialized correctly, skip it */
134  DPRINT1("PCI - PciQueryInterface - Constructor %p = %08lx\n",
135  PciInterface->Constructor, Status);
136  continue;
137  }
138 
139  /* Reference the interface and return success, all is good */
140  Interface->InterfaceReference(Interface->Context);
141  DPRINT1("PCI - PciQueryInterface returning SUCCESS\n");
142  return Status;
143  }
144  }
145 
146  /* An interface of this type, and for this device, could not be found */
147  DPRINT1("PCI - PciQueryInterface FAILED TO FIND INTERFACE\n");
148  return STATUS_NOT_SUPPORTED;
149 }
static PWSTR GuidString
Definition: apphelp.c:91
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:168
LONG NTSTATUS
Definition: precomp.h:26
CONST GUID * InterfaceType
Definition: pci.h:375
USHORT Flags
Definition: pci.h:379
#define PCI_INTERFACE_ROOT
Definition: pci.h:57
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
#define PCI_INTERFACE_FDO
Definition: pci.h:56
PPCI_INTERFACE PciInterfacesLastResort[]
Definition: intrface.c:35
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
USHORT MinVersion
Definition: pci.h:377
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define PCI_INTERFACE_PDO
Definition: pci.h:55
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:30
PCI_INTERFACE_CONSTRUCTOR Constructor
Definition: pci.h:382
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
IN PVOID IN PVOID InterfaceData
Definition: pci.h:359
USHORT MinSize
Definition: pci.h:376

Referenced by PciFdoIrpQueryInterface().

Variable Documentation

◆ PciInterfaces

PPCI_INTERFACE PciInterfaces[]
Initial value:
=
{
}
PCI_INTERFACE ArbiterInterfaceBusNumber
Definition: ar_busno.c:18
PCI_INTERFACE ArbiterInterfaceIo
Definition: ar_memio.c:31
PCI_INTERFACE ArbiterInterfaceMemory
Definition: ar_memio.c:18
smooth NULL
Definition: ftsmooth.c:416
PCI_INTERFACE BusHandlerInterface
Definition: busintrf.c:18
PCI_INTERFACE PciLegacyDeviceDetectionInterface
Definition: lddintrf.c:18
PCI_INTERFACE PciLocationInterface
Definition: locintrf.c:18
PCI_INTERFACE PciCardbusPrivateInterface
Definition: cardbus.c:18
PCI_INTERFACE AgpTargetInterface
Definition: agpintrf.c:20
PCI_INTERFACE PciRoutingInterface
Definition: routintf.c:20
PCI_INTERFACE PciDevicePresentInterface
Definition: devhere.c:18
PCI_INTERFACE PciPmeInterface
Definition: pmeintf.c:18

Definition at line 18 of file intrface.c.

Referenced by PciInitializeArbiters(), and PciQueryInterface().

◆ PciInterfacesLastResort

PPCI_INTERFACE PciInterfacesLastResort[]
Initial value:
=
{
}
smooth NULL
Definition: ftsmooth.c:416
PCI_INTERFACE TranslatorInterfaceInterrupt
Definition: tr_irq.c:18

Definition at line 35 of file intrface.c.

Referenced by PciQueryInterface().