2010-04-01 19:07:40 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS PCI Bus Driver
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: drivers/bus/pci/intrface/intrface.c
|
|
|
|
* PURPOSE: Common Interface Support Routines
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
|
|
|
#include <pci.h>
|
2014-01-04 12:05:02 +00:00
|
|
|
|
2010-04-01 19:07:40 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* GLOBALS ********************************************************************/
|
|
|
|
|
Implement Root Bus FDO AddDevice codes, get boot config, connect to HAL or ACPI config handlers (PciQueryForPciBusInterface, PciGetConfigHandlers), read BUS FDO hack flag, get _HPP HotPlug PCI ACPI data and initialize arbiter support.
PciGetHotPlugParameters work but no PCI HotPlug support on my machines, so cannot test ACPI data, that part stub now
Add PciFdoDispatchTable, PciFdoDispatchPnpTable, PciFdoDispatchPowerTable but all stub to PciIrpNotSupported however set correct IRP Dispatch Style for the IRPS
Arbiter support in PciInitializeARbiters done, but PciInterfaces array is NULL (stub) at moment
Add PCI_SIGNATURE, PCI_STATE, PCI_DISAPTCH_STYLE type, add PciInitializeState to begin the state support
Add structure for PCI_FDO_EXTENSION, PCI_SECONDARY_EXTENSION, PCI_INTERFACE, PCI_ARBITER_INSTANCE, PCI_DISPATCH_TABLE
PCI utility functions added: PciFindParentPciFdoExtension, PciInsertEntryAtTail, PciInsertEntryAtHead, PcipLinkSecondaryExtension, PciGetDeviceProperty, PciSendIoctl
Need sir_richard to add arbiter.h header to define ARBITER_INSTANCE for finish support
This 1000 more codes done now~
svn path=/trunk/; revision=47898
2010-06-28 17:30:35 +00:00
|
|
|
PPCI_INTERFACE PciInterfaces[] =
|
|
|
|
{
|
Fix for code to handle IRP dispatching when unrecognized IRP (Thanks you sir_richard)
Add FDO IRP_MN_QUERY_INTERFACE support (it calls PciQueryInterface)
Add all PCI interface descriptor: PciLocationInterface (GUID_PNP_LOCATION_INTERFACE), PciPmeInterface (GUID_PCI_PME_INTERFACE), PciCardbusPrivateInterface (GUID_PCI_CARDBUS_INTERFACE_PRIVATE), PciLegacyDeviceDetectionInterface (GUID_LEGACY_DEVICE_DETECTION_STANDARD), AgpTargetInterface (GUID_AGP_TARGET_BUS_INTERFACE_STANDARD), PciRoutingInterface (GUID_INT_ROUTE_INTERFACE_STANDARD), BusHandlerInterface (GUID_BUS_INTERFACE_STANDARD) and stub initializer and constructor.
Add missing devhere.c interface file
Add all PCI arbiter descritptor: ArbiterInterfaceBusNumber, ArbiterInterfaceMemory, ArbiterInterfaceIo. Write constructor stub but not handled ArbitersInitialized == TRUE
Also add last-resort PCI interface: TranslatorInterfaceInterrupt (GUID_TRANSLATOR_INTERFACE_STANDARD) and part implement tranirq_Constructor
Add PciQueryInterface to find correct FDO/PDO/ROOT interface for a request and call interface constructor
Fix interface signatures, fix interface constructor type and PCI_INTERFACE, add interface flags (Thanks sir_richard)
Fix Aribtriter code (Thanks sir_richard)
Now another 1200 codes added, soon time for enumeration code!
svn path=/trunk/; revision=48074
2010-07-16 00:39:54 +00:00
|
|
|
&ArbiterInterfaceBusNumber,
|
|
|
|
&ArbiterInterfaceMemory,
|
|
|
|
&ArbiterInterfaceIo,
|
|
|
|
&BusHandlerInterface,
|
|
|
|
&PciRoutingInterface,
|
|
|
|
&PciCardbusPrivateInterface,
|
|
|
|
&PciLegacyDeviceDetectionInterface,
|
|
|
|
&PciPmeInterface,
|
|
|
|
&PciDevicePresentInterface,
|
|
|
|
// &PciNativeIdeInterface,
|
|
|
|
&PciLocationInterface,
|
|
|
|
&AgpTargetInterface,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
PPCI_INTERFACE PciInterfacesLastResort[] =
|
|
|
|
{
|
|
|
|
&TranslatorInterfaceInterrupt,
|
Implement Root Bus FDO AddDevice codes, get boot config, connect to HAL or ACPI config handlers (PciQueryForPciBusInterface, PciGetConfigHandlers), read BUS FDO hack flag, get _HPP HotPlug PCI ACPI data and initialize arbiter support.
PciGetHotPlugParameters work but no PCI HotPlug support on my machines, so cannot test ACPI data, that part stub now
Add PciFdoDispatchTable, PciFdoDispatchPnpTable, PciFdoDispatchPowerTable but all stub to PciIrpNotSupported however set correct IRP Dispatch Style for the IRPS
Arbiter support in PciInitializeARbiters done, but PciInterfaces array is NULL (stub) at moment
Add PCI_SIGNATURE, PCI_STATE, PCI_DISAPTCH_STYLE type, add PciInitializeState to begin the state support
Add structure for PCI_FDO_EXTENSION, PCI_SECONDARY_EXTENSION, PCI_INTERFACE, PCI_ARBITER_INSTANCE, PCI_DISPATCH_TABLE
PCI utility functions added: PciFindParentPciFdoExtension, PciInsertEntryAtTail, PciInsertEntryAtHead, PcipLinkSecondaryExtension, PciGetDeviceProperty, PciSendIoctl
Need sir_richard to add arbiter.h header to define ARBITER_INSTANCE for finish support
This 1000 more codes done now~
svn path=/trunk/; revision=47898
2010-06-28 17:30:35 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2010-04-01 19:07:40 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
Fix for code to handle IRP dispatching when unrecognized IRP (Thanks you sir_richard)
Add FDO IRP_MN_QUERY_INTERFACE support (it calls PciQueryInterface)
Add all PCI interface descriptor: PciLocationInterface (GUID_PNP_LOCATION_INTERFACE), PciPmeInterface (GUID_PCI_PME_INTERFACE), PciCardbusPrivateInterface (GUID_PCI_CARDBUS_INTERFACE_PRIVATE), PciLegacyDeviceDetectionInterface (GUID_LEGACY_DEVICE_DETECTION_STANDARD), AgpTargetInterface (GUID_AGP_TARGET_BUS_INTERFACE_STANDARD), PciRoutingInterface (GUID_INT_ROUTE_INTERFACE_STANDARD), BusHandlerInterface (GUID_BUS_INTERFACE_STANDARD) and stub initializer and constructor.
Add missing devhere.c interface file
Add all PCI arbiter descritptor: ArbiterInterfaceBusNumber, ArbiterInterfaceMemory, ArbiterInterfaceIo. Write constructor stub but not handled ArbitersInitialized == TRUE
Also add last-resort PCI interface: TranslatorInterfaceInterrupt (GUID_TRANSLATOR_INTERFACE_STANDARD) and part implement tranirq_Constructor
Add PciQueryInterface to find correct FDO/PDO/ROOT interface for a request and call interface constructor
Fix interface signatures, fix interface constructor type and PCI_INTERFACE, add interface flags (Thanks sir_richard)
Fix Aribtriter code (Thanks sir_richard)
Now another 1200 codes added, soon time for enumeration code!
svn path=/trunk/; revision=48074
2010-07-16 00:39:54 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
UNICODE_STRING GuidString;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PPCI_INTERFACE *InterfaceList;
|
|
|
|
PPCI_INTERFACE PciInterface;
|
|
|
|
RtlStringFromGUID(InterfaceType, &GuidString);
|
|
|
|
DPRINT1("PCI - PciQueryInterface TYPE = %wZ\n", &GuidString);
|
|
|
|
RtlFreeUnicodeString(&GuidString);
|
2013-05-10 10:22:01 +00:00
|
|
|
DPRINT1(" Size = %u, Version = %u, InterfaceData = %p, LastChance = %s\n",
|
Fix for code to handle IRP dispatching when unrecognized IRP (Thanks you sir_richard)
Add FDO IRP_MN_QUERY_INTERFACE support (it calls PciQueryInterface)
Add all PCI interface descriptor: PciLocationInterface (GUID_PNP_LOCATION_INTERFACE), PciPmeInterface (GUID_PCI_PME_INTERFACE), PciCardbusPrivateInterface (GUID_PCI_CARDBUS_INTERFACE_PRIVATE), PciLegacyDeviceDetectionInterface (GUID_LEGACY_DEVICE_DETECTION_STANDARD), AgpTargetInterface (GUID_AGP_TARGET_BUS_INTERFACE_STANDARD), PciRoutingInterface (GUID_INT_ROUTE_INTERFACE_STANDARD), BusHandlerInterface (GUID_BUS_INTERFACE_STANDARD) and stub initializer and constructor.
Add missing devhere.c interface file
Add all PCI arbiter descritptor: ArbiterInterfaceBusNumber, ArbiterInterfaceMemory, ArbiterInterfaceIo. Write constructor stub but not handled ArbitersInitialized == TRUE
Also add last-resort PCI interface: TranslatorInterfaceInterrupt (GUID_TRANSLATOR_INTERFACE_STANDARD) and part implement tranirq_Constructor
Add PciQueryInterface to find correct FDO/PDO/ROOT interface for a request and call interface constructor
Fix interface signatures, fix interface constructor type and PCI_INTERFACE, add interface flags (Thanks sir_richard)
Fix Aribtriter code (Thanks sir_richard)
Now another 1200 codes added, soon time for enumeration code!
svn path=/trunk/; revision=48074
2010-07-16 00:39:54 +00:00
|
|
|
Size,
|
|
|
|
Version,
|
|
|
|
InterfaceData,
|
|
|
|
LastChance ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
/* Loop all the available interfaces */
|
|
|
|
for (InterfaceList = LastChance ? PciInterfacesLastResort : PciInterfaces;
|
|
|
|
*InterfaceList;
|
|
|
|
InterfaceList++)
|
|
|
|
{
|
|
|
|
/* Get the current interface */
|
|
|
|
PciInterface = *InterfaceList;
|
|
|
|
|
|
|
|
/* For debugging, construct the GUID string */
|
|
|
|
RtlStringFromGUID(PciInterface->InterfaceType, &GuidString);
|
|
|
|
|
|
|
|
/* Check if this is an FDO or PDO */
|
|
|
|
if (DeviceExtension->ExtensionType == PciFdoExtensionType)
|
|
|
|
{
|
|
|
|
/* Check if the interface is for FDOs */
|
|
|
|
if (!(PciInterface->Flags & PCI_INTERFACE_FDO))
|
|
|
|
{
|
|
|
|
/* This interface is not for FDOs, skip it */
|
|
|
|
DPRINT1("PCI - PciQueryInterface: guid = %wZ only for FDOs\n",
|
|
|
|
&GuidString);
|
|
|
|
RtlFreeUnicodeString(&GuidString);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the interface is for root FDO only */
|
|
|
|
if ((PciInterface->Flags & PCI_INTERFACE_ROOT) &&
|
|
|
|
(!PCI_IS_ROOT_FDO(DeviceExtension)))
|
|
|
|
{
|
|
|
|
/* This FDO isn't the root, skip the interface */
|
|
|
|
DPRINT1("PCI - PciQueryInterface: guid = %wZ only for ROOT\n",
|
|
|
|
&GuidString);
|
|
|
|
RtlFreeUnicodeString(&GuidString);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This is a PDO, check if the interface is for PDOs too */
|
|
|
|
if (!(PciInterface->Flags & PCI_INTERFACE_PDO))
|
|
|
|
{
|
|
|
|
/* It isn't, skip it */
|
|
|
|
DPRINT1("PCI - PciQueryInterface: guid = %wZ only for PDOs\n",
|
|
|
|
&GuidString);
|
|
|
|
RtlFreeUnicodeString(&GuidString);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print the GUID for debugging, and then free the string */
|
|
|
|
DPRINT1("PCI - PciQueryInterface looking at guid = %wZ\n", &GuidString);
|
|
|
|
RtlFreeUnicodeString(&GuidString);
|
|
|
|
|
|
|
|
/* Check if the GUID, version, and size all match */
|
|
|
|
if ((IsEqualGUIDAligned(PciInterface->InterfaceType, InterfaceType)) &&
|
|
|
|
(Version >= PciInterface->MinVersion) &&
|
|
|
|
(Version <= PciInterface->MaxVersion) &&
|
|
|
|
(Size >= PciInterface->MinSize))
|
|
|
|
{
|
|
|
|
/* Call the interface's constructor */
|
|
|
|
Status = PciInterface->Constructor(DeviceExtension,
|
|
|
|
PciInterface,
|
|
|
|
InterfaceData,
|
|
|
|
Version,
|
|
|
|
Size,
|
|
|
|
Interface);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* This interface was not initialized correctly, skip it */
|
2016-11-13 15:31:39 +00:00
|
|
|
DPRINT1("PCI - PciQueryInterface - Constructor %p = %08lx\n",
|
Fix for code to handle IRP dispatching when unrecognized IRP (Thanks you sir_richard)
Add FDO IRP_MN_QUERY_INTERFACE support (it calls PciQueryInterface)
Add all PCI interface descriptor: PciLocationInterface (GUID_PNP_LOCATION_INTERFACE), PciPmeInterface (GUID_PCI_PME_INTERFACE), PciCardbusPrivateInterface (GUID_PCI_CARDBUS_INTERFACE_PRIVATE), PciLegacyDeviceDetectionInterface (GUID_LEGACY_DEVICE_DETECTION_STANDARD), AgpTargetInterface (GUID_AGP_TARGET_BUS_INTERFACE_STANDARD), PciRoutingInterface (GUID_INT_ROUTE_INTERFACE_STANDARD), BusHandlerInterface (GUID_BUS_INTERFACE_STANDARD) and stub initializer and constructor.
Add missing devhere.c interface file
Add all PCI arbiter descritptor: ArbiterInterfaceBusNumber, ArbiterInterfaceMemory, ArbiterInterfaceIo. Write constructor stub but not handled ArbitersInitialized == TRUE
Also add last-resort PCI interface: TranslatorInterfaceInterrupt (GUID_TRANSLATOR_INTERFACE_STANDARD) and part implement tranirq_Constructor
Add PciQueryInterface to find correct FDO/PDO/ROOT interface for a request and call interface constructor
Fix interface signatures, fix interface constructor type and PCI_INTERFACE, add interface flags (Thanks sir_richard)
Fix Aribtriter code (Thanks sir_richard)
Now another 1200 codes added, soon time for enumeration code!
svn path=/trunk/; revision=48074
2010-07-16 00:39:54 +00:00
|
|
|
PciInterface->Constructor, Status);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reference the interface and return success, all is good */
|
|
|
|
Interface->InterfaceReference(Interface->Context);
|
|
|
|
DPRINT1("PCI - PciQueryInterface returning SUCCESS\n");
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* An interface of this type, and for this device, could not be found */
|
|
|
|
DPRINT1("PCI - PciQueryInterface FAILED TO FIND INTERFACE\n");
|
|
|
|
return STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2010-04-01 19:07:40 +00:00
|
|
|
/* EOF */
|