ReactOS 0.4.15-dev-8222-g9164419
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;
58 DPRINT1("PCI - PciQueryInterface TYPE = %wZ\n", &GuidString);
60 DPRINT1(" Size = %u, Version = %u, InterfaceData = %p, LastChance = %s\n",
61 Size,
62 Version,
63 InterfaceData,
64 LastChance ? "TRUE" : "FALSE");
65
66 /* Loop all the available interfaces */
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,
127 InterfaceData,
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");
149}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PCI_INTERFACE_PDO
Definition: pci.h:57
#define PCI_INTERFACE_FDO
Definition: pci.h:58
#define PCI_INTERFACE_ROOT
Definition: pci.h:59
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:32
@ PciFdoExtensionType
Definition: pci.h:95
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
PPCI_INTERFACE PciInterfacesLastResort[]
Definition: intrface.c:35
static PWSTR GuidString
Definition: apphelp.c:93
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
USHORT MinSize
Definition: pci.h:378
USHORT Flags
Definition: pci.h:381
PCI_INTERFACE_CONSTRUCTOR Constructor
Definition: pci.h:384
USHORT MinVersion
Definition: pci.h:379
CONST GUID * InterfaceType
Definition: pci.h:377
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by PciFdoIrpQueryInterface().

Variable Documentation

◆ PciInterfaces

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

Definition at line 18 of file intrface.c.

Referenced by PciInitializeArbiters(), and PciQueryInterface().

◆ PciInterfacesLastResort

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

Definition at line 35 of file intrface.c.

Referenced by PciQueryInterface().