Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenintrface.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS PCI Bus Driver 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: drivers/bus/pci/intrface/intrface.c 00005 * PURPOSE: Common Interface Support Routines 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <pci.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 /* GLOBALS ********************************************************************/ 00016 00017 PPCI_INTERFACE PciInterfaces[] = 00018 { 00019 &ArbiterInterfaceBusNumber, 00020 &ArbiterInterfaceMemory, 00021 &ArbiterInterfaceIo, 00022 &BusHandlerInterface, 00023 &PciRoutingInterface, 00024 &PciCardbusPrivateInterface, 00025 &PciLegacyDeviceDetectionInterface, 00026 &PciPmeInterface, 00027 &PciDevicePresentInterface, 00028 // &PciNativeIdeInterface, 00029 &PciLocationInterface, 00030 &AgpTargetInterface, 00031 NULL 00032 }; 00033 00034 PPCI_INTERFACE PciInterfacesLastResort[] = 00035 { 00036 &TranslatorInterfaceInterrupt, 00037 NULL 00038 }; 00039 00040 /* FUNCTIONS ******************************************************************/ 00041 00042 NTSTATUS 00043 NTAPI 00044 PciQueryInterface(IN PPCI_FDO_EXTENSION DeviceExtension, 00045 IN CONST GUID* InterfaceType, 00046 IN ULONG Size, 00047 IN ULONG Version, 00048 IN PVOID InterfaceData, 00049 IN PINTERFACE Interface, 00050 IN BOOLEAN LastChance) 00051 { 00052 UNICODE_STRING GuidString; 00053 NTSTATUS Status; 00054 PPCI_INTERFACE *InterfaceList; 00055 PPCI_INTERFACE PciInterface; 00056 RtlStringFromGUID(InterfaceType, &GuidString); 00057 DPRINT1("PCI - PciQueryInterface TYPE = %wZ\n", &GuidString); 00058 RtlFreeUnicodeString(&GuidString); 00059 DPRINT1(" Size = %d, Version = %d, InterfaceData = %x, LastChance = %s\n", 00060 Size, 00061 Version, 00062 InterfaceData, 00063 LastChance ? "TRUE" : "FALSE"); 00064 00065 /* Loop all the available interfaces */ 00066 for (InterfaceList = LastChance ? PciInterfacesLastResort : PciInterfaces; 00067 *InterfaceList; 00068 InterfaceList++) 00069 { 00070 /* Get the current interface */ 00071 PciInterface = *InterfaceList; 00072 00073 /* For debugging, construct the GUID string */ 00074 RtlStringFromGUID(PciInterface->InterfaceType, &GuidString); 00075 00076 /* Check if this is an FDO or PDO */ 00077 if (DeviceExtension->ExtensionType == PciFdoExtensionType) 00078 { 00079 /* Check if the interface is for FDOs */ 00080 if (!(PciInterface->Flags & PCI_INTERFACE_FDO)) 00081 { 00082 /* This interface is not for FDOs, skip it */ 00083 DPRINT1("PCI - PciQueryInterface: guid = %wZ only for FDOs\n", 00084 &GuidString); 00085 RtlFreeUnicodeString(&GuidString); 00086 continue; 00087 } 00088 00089 /* Check if the interface is for root FDO only */ 00090 if ((PciInterface->Flags & PCI_INTERFACE_ROOT) && 00091 (!PCI_IS_ROOT_FDO(DeviceExtension))) 00092 { 00093 /* This FDO isn't the root, skip the interface */ 00094 DPRINT1("PCI - PciQueryInterface: guid = %wZ only for ROOT\n", 00095 &GuidString); 00096 RtlFreeUnicodeString(&GuidString); 00097 continue; 00098 } 00099 } 00100 else 00101 { 00102 /* This is a PDO, check if the interface is for PDOs too */ 00103 if (!(PciInterface->Flags & PCI_INTERFACE_PDO)) 00104 { 00105 /* It isn't, skip it */ 00106 DPRINT1("PCI - PciQueryInterface: guid = %wZ only for PDOs\n", 00107 &GuidString); 00108 RtlFreeUnicodeString(&GuidString); 00109 continue; 00110 } 00111 } 00112 00113 /* Print the GUID for debugging, and then free the string */ 00114 DPRINT1("PCI - PciQueryInterface looking at guid = %wZ\n", &GuidString); 00115 RtlFreeUnicodeString(&GuidString); 00116 00117 /* Check if the GUID, version, and size all match */ 00118 if ((IsEqualGUIDAligned(PciInterface->InterfaceType, InterfaceType)) && 00119 (Version >= PciInterface->MinVersion) && 00120 (Version <= PciInterface->MaxVersion) && 00121 (Size >= PciInterface->MinSize)) 00122 { 00123 /* Call the interface's constructor */ 00124 Status = PciInterface->Constructor(DeviceExtension, 00125 PciInterface, 00126 InterfaceData, 00127 Version, 00128 Size, 00129 Interface); 00130 if (!NT_SUCCESS(Status)) 00131 { 00132 /* This interface was not initialized correctly, skip it */ 00133 DPRINT1("PCI - PciQueryInterface - Contructor %08lx = %08lx\n", 00134 PciInterface->Constructor, Status); 00135 continue; 00136 } 00137 00138 /* Reference the interface and return success, all is good */ 00139 Interface->InterfaceReference(Interface->Context); 00140 DPRINT1("PCI - PciQueryInterface returning SUCCESS\n"); 00141 return Status; 00142 } 00143 } 00144 00145 /* An interface of this type, and for this device, could not be found */ 00146 DPRINT1("PCI - PciQueryInterface FAILED TO FIND INTERFACE\n"); 00147 return STATUS_NOT_SUPPORTED; 00148 } 00149 00150 /* EOF */ Generated on Fri May 25 2012 04:25:47 for ReactOS by
1.7.6.1
|