ReactOS 0.4.15-dev-7711-g5627da4
intrface.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/intrface/intrface.c
5 * PURPOSE: Common Interface Support Routines
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
19{
29// &PciNativeIdeInterface,
32 NULL
33};
34
36{
38 NULL
39};
40
41/* FUNCTIONS ******************************************************************/
42
49 IN PVOID InterfaceData,
51 IN BOOLEAN LastChance)
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}
150
151/* EOF */
unsigned char BOOLEAN
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
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
PCI_INTERFACE BusHandlerInterface
Definition: busintrf.c:18
PCI_INTERFACE PciCardbusPrivateInterface
Definition: cardbus.c:18
#define NULL
Definition: types.h:112
#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)
PCI_INTERFACE PciDevicePresentInterface
Definition: devhere.c:18
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: intrface.c:45
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
PPCI_INTERFACE PciInterfacesLastResort[]
Definition: intrface.c:35
PCI_INTERFACE PciLegacyDeviceDetectionInterface
Definition: lddintrf.c:18
PCI_INTERFACE PciLocationInterface
Definition: locintrf.c:18
static PWSTR GuidString
Definition: apphelp.c:93
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define CONST
Definition: pedump.c:81
PCI_INTERFACE PciPmeInterface
Definition: pmeintf.c:18
PCI_INTERFACE PciRoutingInterface
Definition: routintf.c:20
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
PCI_INTERFACE TranslatorInterfaceInterrupt
Definition: tr_irq.c:18
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_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