From add164dcfa43953e9df5472907c3ecccf7d17b41 Mon Sep 17 00:00:00 2001 From: evb Date: Fri, 16 Jul 2010 00:39:54 +0000 Subject: [PATCH] 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 --- reactos/drivers/bus/pcix/arb/ar_busno.c | 62 ++++ reactos/drivers/bus/pcix/arb/ar_memio.c | 124 ++++++++ reactos/drivers/bus/pcix/arb/arb_comn.c | 4 +- reactos/drivers/bus/pcix/arb/tr_irq.c | 82 +++++- reactos/drivers/bus/pcix/dispatch.c | 12 +- reactos/drivers/bus/pcix/fdo.c | 70 ++++- reactos/drivers/bus/pcix/intrface/agpintrf.c | 48 +++ reactos/drivers/bus/pcix/intrface/busintrf.c | 36 +++ reactos/drivers/bus/pcix/intrface/cardbus.c | 36 +++ reactos/drivers/bus/pcix/intrface/devhere.c | 57 ++++ reactos/drivers/bus/pcix/intrface/intrface.c | 126 ++++++++ reactos/drivers/bus/pcix/intrface/lddintrf.c | 36 +++ reactos/drivers/bus/pcix/intrface/locintrf.c | 36 +++ reactos/drivers/bus/pcix/intrface/pmeintf.c | 39 +++ reactos/drivers/bus/pcix/intrface/routintf.c | 39 +++ reactos/drivers/bus/pcix/pci.h | 290 +++++++++++++++++-- reactos/drivers/bus/pcix/pcix.rbuild | 1 + 17 files changed, 1067 insertions(+), 31 deletions(-) create mode 100644 reactos/drivers/bus/pcix/intrface/devhere.c diff --git a/reactos/drivers/bus/pcix/arb/ar_busno.c b/reactos/drivers/bus/pcix/arb/ar_busno.c index 5086357c836..dba5250dd16 100644 --- a/reactos/drivers/bus/pcix/arb/ar_busno.c +++ b/reactos/drivers/bus/pcix/arb/ar_busno.c @@ -14,6 +14,68 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE ArbiterInterfaceBusNumber = +{ + &GUID_ARBITER_INTERFACE_STANDARD, + sizeof(ARBITER_INTERFACE), + 0, + 0, + PCI_INTERFACE_FDO, + 0, + PciArb_BusNumber, + arbusno_Constructor, + arbusno_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +arbusno_Initializer(IN PVOID Instance) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + //while (TRUE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +arbusno_Constructor(IN PVOID DeviceExtension, + IN PVOID PciInterface, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + PPCI_FDO_EXTENSION FdoExtension = (PPCI_FDO_EXTENSION)DeviceExtension; + NTSTATUS Status; + PAGED_CODE(); + + /* Make sure it's the expected interface */ + if ((ULONG)InterfaceData != CmResourceTypeBusNumber) + { + /* Arbiter support must have been initialized first */ + if (FdoExtension->ArbitersInitialized) + { + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + } + else + { + /* No arbiters for this FDO */ + Status = STATUS_NOT_SUPPORTED; + } + } + else + { + /* Not the right interface */ + Status = STATUS_INVALID_PARAMETER_5; + } + + /* Return the status */ + return Status; +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/arb/ar_memio.c b/reactos/drivers/bus/pcix/arb/ar_memio.c index 47d6e07b150..8b544536dff 100644 --- a/reactos/drivers/bus/pcix/arb/ar_memio.c +++ b/reactos/drivers/bus/pcix/arb/ar_memio.c @@ -14,6 +14,130 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE ArbiterInterfaceMemory = +{ + &GUID_ARBITER_INTERFACE_STANDARD, + sizeof(ARBITER_INTERFACE), + 0, + 0, + PCI_INTERFACE_FDO, + 0, + PciArb_Memory, + armem_Constructor, + armem_Initializer +}; + +PCI_INTERFACE ArbiterInterfaceIo = +{ + &GUID_ARBITER_INTERFACE_STANDARD, + sizeof(ARBITER_INTERFACE), + 0, + 0, + PCI_INTERFACE_FDO, + 0, + PciArb_Io, + ario_Constructor, + ario_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +ario_Initializer(IN PVOID Instance) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + //while (TRUE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +ario_Constructor(IN PVOID DeviceExtension, + IN PVOID PciInterface, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + PPCI_FDO_EXTENSION FdoExtension = (PPCI_FDO_EXTENSION)DeviceExtension; + NTSTATUS Status; + PAGED_CODE(); + + /* Make sure it's the expected interface */ + if ((ULONG)InterfaceData != CmResourceTypePort) + { + /* Arbiter support must have been initialized first */ + if (FdoExtension->ArbitersInitialized) + { + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + } + else + { + /* No arbiters for this FDO */ + Status = STATUS_NOT_SUPPORTED; + } + } + else + { + /* Not the right interface */ + Status = STATUS_INVALID_PARAMETER_5; + } + + /* Return the status */ + return Status; +} + +NTSTATUS +NTAPI +armem_Initializer(IN PVOID Instance) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + //while (TRUE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +armem_Constructor(IN PVOID DeviceExtension, + IN PVOID PciInterface, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + PPCI_FDO_EXTENSION FdoExtension = (PPCI_FDO_EXTENSION)DeviceExtension; + NTSTATUS Status; + PAGED_CODE(); + + /* Make sure it's the expected interface */ + if ((ULONG)InterfaceData != CmResourceTypeMemory) + { + /* Arbiter support must have been initialized first */ + if (FdoExtension->ArbitersInitialized) + { + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + } + else + { + /* No arbiters for this FDO */ + Status = STATUS_NOT_SUPPORTED; + } + } + else + { + /* Not the right interface */ + Status = STATUS_INVALID_PARAMETER_5; + } + + /* Return the status */ + return Status; +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/arb/arb_comn.c b/reactos/drivers/bus/pcix/arb/arb_comn.c index 4f89c95b684..b66fb549705 100644 --- a/reactos/drivers/bus/pcix/arb/arb_comn.c +++ b/reactos/drivers/bus/pcix/arb/arb_comn.c @@ -44,7 +44,7 @@ PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension) ASSERT_FDO(FdoExtension); /* Loop all the arbiters */ - for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++) + for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_BusNumber; ArbiterType++) { /* Check if this is the extension for the Root PCI Bus */ if (!PCI_IS_ROOT_FDO(FdoExtension)) @@ -113,7 +113,7 @@ PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension) /* This arbiter is now initialized, move to the next one */ DPRINT1("PCI - FDO ext 0x%08x %S arbiter initialized (context 0x%08x).\n", FdoExtension, - "ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name, + L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name, ArbiterInterface); Status = STATUS_SUCCESS; } diff --git a/reactos/drivers/bus/pcix/arb/tr_irq.c b/reactos/drivers/bus/pcix/arb/tr_irq.c index 7d27173b463..c19bf4d2928 100644 --- a/reactos/drivers/bus/pcix/arb/tr_irq.c +++ b/reactos/drivers/bus/pcix/arb/tr_irq.c @@ -1,8 +1,8 @@ /* * PROJECT: ReactOS PCI Bus Driver * LICENSE: BSD - See COPYING.ARM in the top level directory - * FILE: drivers/bus/pci/arb/tr_irq.c - * PURPOSE: IRQ Resource Translation + * FILE: drivers/bus/pci/intrface/tr_irq.c + * PURPOSE: IRQ Translator Interface * PROGRAMMERS: ReactOS Portable Systems Group */ @@ -14,6 +14,84 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE TranslatorInterfaceInterrupt = +{ + &GUID_TRANSLATOR_INTERFACE_STANDARD, + sizeof(TRANSLATOR_INTERFACE), + 0, + 0, + PCI_INTERFACE_FDO, + 0, + PciTrans_Interrupt, + tranirq_Constructor, + tranirq_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +tranirq_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI tranirq_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +tranirq_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + PPCI_FDO_EXTENSION FdoExtension = (PPCI_FDO_EXTENSION)DeviceExtension; + ULONG BaseBus, ParentBus; + INTERFACE_TYPE ParentInterface; + ASSERT_FDO(FdoExtension); + + /* Make sure it's the right resource type */ + if ((ULONG)InterfaceData != CmResourceTypeInterrupt) + { + /* Fail this invalid request */ + DPRINT1("PCI - IRQ trans constructor doesn't like %x in InterfaceSpecificData\n", + InterfaceData); + return STATUS_INVALID_PARAMETER_3; + } + + /* Get the bus, and use this as the interface-specific data */ + BaseBus = FdoExtension->BaseBus; + InterfaceData = (PVOID)BaseBus; + + /* Check if this is the root bus */ + if (PCI_IS_ROOT_FDO(FdoExtension)) + { + /* It is, so there is no parent, and it's connected on the system bus */ + ParentBus = 0; + ParentInterface = Internal; + DPRINT1(" Is root FDO\n"); + } + else + { + /* It's not, so we have to get the root bus' bus number instead */ + #if 0 // when have PDO commit + ParentBus = FdoExtension->PhysicalDeviceObject->DeviceExtension->ParentFdoExtension->BaseBus; + ParentInterface = PCIBus; + DPRINT1(" Is bridge FDO, parent bus %x, secondary bus %x\n", + ParentBus, BaseBus); + #endif + } + + /* Now call the legacy HAL interface to get the correct translator */ + return HalGetInterruptTranslator(ParentInterface, + ParentBus, + PCIBus, + sizeof(TRANSLATOR_INTERFACE), + 0, + (PTRANSLATOR_INTERFACE)Interface, + (PULONG)&InterfaceData); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/dispatch.c b/reactos/drivers/bus/pcix/dispatch.c index c30322d6603..0298ea2d0d7 100644 --- a/reactos/drivers/bus/pcix/dispatch.c +++ b/reactos/drivers/bus/pcix/dispatch.c @@ -102,8 +102,8 @@ PciDispatchIrp(IN PDEVICE_OBJECT DeviceObject, NTSTATUS Status; PPCI_MN_DISPATCH_TABLE TableArray = NULL, Table; USHORT MaxMinor; - PCI_DISPATCH_STYLE DispatchStyle; - PCI_DISPATCH_FUNCTION DispatchFunction; + PCI_DISPATCH_STYLE DispatchStyle = 0; + PCI_DISPATCH_FUNCTION DispatchFunction = NULL; DPRINT1("PCI: Dispatch IRP\n"); /* Get the extension and I/O stack location for this IRP */ @@ -146,7 +146,7 @@ PciDispatchIrp(IN PDEVICE_OBJECT DeviceObject, /* WMI IRPs */ DispatchFunction = IrpDispatchTable->SystemControlIrpDispatchFunction; DispatchStyle = IrpDispatchTable->SystemControlIrpDispatchStyle; - MaxMinor = -1; + MaxMinor = 0xFFFF; break; default: @@ -154,12 +154,12 @@ PciDispatchIrp(IN PDEVICE_OBJECT DeviceObject, /* Unrecognized IRPs */ DispatchFunction = IrpDispatchTable->OtherIrpDispatchFunction; DispatchStyle = IrpDispatchTable->OtherIrpDispatchStyle; - MaxMinor = -1; + MaxMinor = 0xFFFF; break; } /* Only deal with recognized IRPs */ - if (MaxMinor != -1) + if (MaxMinor != 0xFFFF) { /* Make sure the function is recognized */ if (IoStackLocation->MinorFunction > MaxMinor) @@ -260,7 +260,7 @@ PciIrpNotSupported(IN PIRP Irp, { /* Not supported */ DPRINT1("WARNING: PCI received unsupported IRP!\n"); - DbgBreakPoint(); + //DbgBreakPoint(); return STATUS_NOT_SUPPORTED; } diff --git a/reactos/drivers/bus/pcix/fdo.c b/reactos/drivers/bus/pcix/fdo.c index d7c51150830..08d61ade478 100644 --- a/reactos/drivers/bus/pcix/fdo.c +++ b/reactos/drivers/bus/pcix/fdo.c @@ -164,9 +164,73 @@ PciFdoIrpQueryInterface(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + NTSTATUS Status; + PAGED_CODE(); + ASSERT(DeviceExtension->ExtensionType == PciFdoExtensionType); + + /* Deleted extensions don't respond to IRPs */ + if (DeviceExtension->DeviceState == PciDeleted) + { + /* Hand it bacO try to deal with it */ + return PciPassIrpFromFdoToPdo(DeviceExtension, Irp); + } + + /* Query our driver for this interface */ + Status = PciQueryInterface(DeviceExtension, + IoStackLocation->Parameters.QueryInterface. + InterfaceType, + IoStackLocation->Parameters.QueryInterface. + Size, + IoStackLocation->Parameters.QueryInterface. + Version, + IoStackLocation->Parameters.QueryInterface. + InterfaceSpecificData, + IoStackLocation->Parameters.QueryInterface. + Interface, + FALSE); + if (NT_SUCCESS(Status)) + { + /* We found it, let the PDO handle it */ + Irp->IoStatus.Status = Status; + return PciPassIrpFromFdoToPdo(DeviceExtension, Irp); + } + else if (Status == STATUS_NOT_SUPPORTED) + { + /* Otherwise, we can't handle it, let someone else down the stack try */ + Status = PciCallDownIrpStack(DeviceExtension, Irp); + if (Status == STATUS_NOT_SUPPORTED) + { + /* They can't either, try a last-resort interface lookup */ + Status = PciQueryInterface(DeviceExtension, + IoStackLocation->Parameters.QueryInterface. + InterfaceType, + IoStackLocation->Parameters.QueryInterface. + Size, + IoStackLocation->Parameters.QueryInterface. + Version, + IoStackLocation->Parameters.QueryInterface. + InterfaceSpecificData, + IoStackLocation->Parameters.QueryInterface. + Interface, + TRUE); + } + } + + /* Has anyone claimed this interface yet? */ + if (Status == STATUS_NOT_SUPPORTED) + { + /* No, return the original IRP status */ + Status = Irp->IoStatus.Status; + } + else + { + /* Yes, set the new IRP status */ + Irp->IoStatus.Status = Status; + } + + /* Complete this IRP */ + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; } NTSTATUS diff --git a/reactos/drivers/bus/pcix/intrface/agpintrf.c b/reactos/drivers/bus/pcix/intrface/agpintrf.c index 351ae575b9d..41bd8245e6f 100644 --- a/reactos/drivers/bus/pcix/intrface/agpintrf.c +++ b/reactos/drivers/bus/pcix/intrface/agpintrf.c @@ -14,6 +14,54 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE AgpTargetInterface = +{ + &GUID_AGP_TARGET_BUS_INTERFACE_STANDARD, + sizeof(AGP_BUS_INTERFACE_STANDARD), + AGP_BUS_INTERFACE_V1, + AGP_BUS_INTERFACE_V1, + PCI_INTERFACE_PDO, + 0, + PciInterface_AgpTarget, + agpintrf_Constructor, + agpintrf_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +agpintrf_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI agpintrf_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +agpintrf_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ +#if 0 // when have PDO commit + PPCI_PDO_EXTENSION PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension; + + /* Only AGP bridges are supported (which are PCI-to-PCI Bridge Devices) */ + if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) || + (PdoExtension->SubClass != PCI_SUBCLASS_BR_PCI_TO_PCI)) + { + /* Fail any other PDO */ + return STATUS_NOT_SUPPORTED; + } +#endif + + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/busintrf.c b/reactos/drivers/bus/pcix/intrface/busintrf.c index 468d9edd1f0..08681cb1be7 100644 --- a/reactos/drivers/bus/pcix/intrface/busintrf.c +++ b/reactos/drivers/bus/pcix/intrface/busintrf.c @@ -14,6 +14,42 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE BusHandlerInterface = +{ + &GUID_BUS_INTERFACE_STANDARD, + sizeof(BUS_INTERFACE_STANDARD), + 1, + 1, + PCI_INTERFACE_PDO, + 0, + PciInterface_BusHandler, + busintrf_Constructor, + busintrf_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +busintrf_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI busintrf_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +busintrf_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/cardbus.c b/reactos/drivers/bus/pcix/intrface/cardbus.c index a36f2d886f4..7f1e78b763d 100644 --- a/reactos/drivers/bus/pcix/intrface/cardbus.c +++ b/reactos/drivers/bus/pcix/intrface/cardbus.c @@ -14,6 +14,42 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE PciCardbusPrivateInterface = +{ + &GUID_PCI_CARDBUS_INTERFACE_PRIVATE, + sizeof(PCI_CARDBUS_INTERFACE_PRIVATE), + PCI_CB_INTRF_VERSION, + PCI_CB_INTRF_VERSION, + PCI_INTERFACE_PDO, + 0, + PciInterface_PciCb, + pcicbintrf_Constructor, + pcicbintrf_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +pcicbintrf_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI pcicbintrf_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +pcicbintrf_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/devhere.c b/reactos/drivers/bus/pcix/intrface/devhere.c new file mode 100644 index 00000000000..919ff30dc56 --- /dev/null +++ b/reactos/drivers/bus/pcix/intrface/devhere.c @@ -0,0 +1,57 @@ +/* + * PROJECT: ReactOS PCI Bus Driver + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: drivers/bus/pci/intrface/devhere.c + * PURPOSE: Device Presence Interface + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +PCI_INTERFACE PciDevicePresentInterface = +{ + &GUID_PCI_DEVICE_PRESENT_INTERFACE, + sizeof(PCI_DEVICE_PRESENT_INTERFACE), + PCI_DEVICE_PRESENT_INTERFACE_VERSION, + PCI_DEVICE_PRESENT_INTERFACE_VERSION, + PCI_INTERFACE_PDO, + 0, + PciInterface_DevicePresent, + devpresent_Constructor, + devpresent_Initializer +}; + +/* FUNCTIONS ******************************************************************/ + +NTSTATUS +NTAPI +devpresent_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI devpresent_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +devpresent_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + PAGED_CODE(); + + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + +/* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/intrface.c b/reactos/drivers/bus/pcix/intrface/intrface.c index 2b75f8d97d9..c378937fcc3 100644 --- a/reactos/drivers/bus/pcix/intrface/intrface.c +++ b/reactos/drivers/bus/pcix/intrface/intrface.c @@ -16,9 +16,135 @@ PPCI_INTERFACE PciInterfaces[] = { + &ArbiterInterfaceBusNumber, + &ArbiterInterfaceMemory, + &ArbiterInterfaceIo, + &BusHandlerInterface, + &PciRoutingInterface, + &PciCardbusPrivateInterface, + &PciLegacyDeviceDetectionInterface, + &PciPmeInterface, + &PciDevicePresentInterface, +// &PciNativeIdeInterface, + &PciLocationInterface, + &AgpTargetInterface, + NULL +}; + +PPCI_INTERFACE PciInterfacesLastResort[] = +{ + &TranslatorInterfaceInterrupt, NULL }; /* 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) +{ + UNICODE_STRING GuidString; + NTSTATUS Status; + PPCI_INTERFACE *InterfaceList; + PPCI_INTERFACE PciInterface; + RtlStringFromGUID(InterfaceType, &GuidString); + DPRINT1("PCI - PciQueryInterface TYPE = %wZ\n", &GuidString); + RtlFreeUnicodeString(&GuidString); + DPRINT1(" Size = %d, Version = %d, InterfaceData = %x, LastChance = %s\n", + 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 */ + DPRINT1("PCI - PciQueryInterface - Contructor %08lx = %08lx\n", + 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; +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/lddintrf.c b/reactos/drivers/bus/pcix/intrface/lddintrf.c index 43224559e85..6665427f1fd 100644 --- a/reactos/drivers/bus/pcix/intrface/lddintrf.c +++ b/reactos/drivers/bus/pcix/intrface/lddintrf.c @@ -14,6 +14,42 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE PciLegacyDeviceDetectionInterface = +{ + &GUID_LEGACY_DEVICE_DETECTION_STANDARD, + sizeof(LEGACY_DEVICE_DETECTION_INTERFACE), + 0, + 0, + PCI_INTERFACE_FDO, + 0, + PciInterface_LegacyDeviceDetection, + lddintrf_Constructor, + lddintrf_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +lddintrf_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI lddintrf_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +lddintrf_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/locintrf.c b/reactos/drivers/bus/pcix/intrface/locintrf.c index a633d98654a..f2ca1797ba7 100644 --- a/reactos/drivers/bus/pcix/intrface/locintrf.c +++ b/reactos/drivers/bus/pcix/intrface/locintrf.c @@ -14,6 +14,42 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE PciLocationInterface = +{ + &GUID_PNP_LOCATION_INTERFACE, + sizeof(PNP_LOCATION_INTERFACE), + PNP_LOCATION_INTERFACE_VERSION, + PNP_LOCATION_INTERFACE_VERSION, + PCI_INTERFACE_FDO | PCI_INTERFACE_ROOT | PCI_INTERFACE_PDO, + 0, + PciInterface_Location, + locintrf_Constructor, + locintrf_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +locintrf_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI locintrf_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +locintrf_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/pmeintf.c b/reactos/drivers/bus/pcix/intrface/pmeintf.c index ecb3b6e88e9..5b59e9af68b 100644 --- a/reactos/drivers/bus/pcix/intrface/pmeintf.c +++ b/reactos/drivers/bus/pcix/intrface/pmeintf.c @@ -14,6 +14,45 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE PciPmeInterface = +{ + &GUID_PCI_PME_INTERFACE, + sizeof(PCI_PME_INTERFACE), + PCI_PME_INTRF_STANDARD_VER, + PCI_PME_INTRF_STANDARD_VER, + PCI_INTERFACE_FDO | PCI_INTERFACE_ROOT, + 0, + PciInterface_PmeHandler, + PciPmeInterfaceConstructor, + PciPmeInterfaceInitializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +PciPmeInterfaceInitializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI PciPmeInterfaceInitializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +PciPmeInterfaceConstructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + /* Only version 1 is supported */ + if (Version != PCI_PME_INTRF_STANDARD_VER) return STATUS_NOINTERFACE; + + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/intrface/routintf.c b/reactos/drivers/bus/pcix/intrface/routintf.c index 6332953d685..e910b7c47f6 100644 --- a/reactos/drivers/bus/pcix/intrface/routintf.c +++ b/reactos/drivers/bus/pcix/intrface/routintf.c @@ -14,6 +14,45 @@ /* GLOBALS ********************************************************************/ +PCI_INTERFACE PciRoutingInterface = +{ + &GUID_INT_ROUTE_INTERFACE_STANDARD, + sizeof(INT_ROUTE_INTERFACE_STANDARD), + PCI_INT_ROUTE_INTRF_STANDARD_VER, + PCI_INT_ROUTE_INTRF_STANDARD_VER, + PCI_INTERFACE_FDO, + 0, + PciInterface_IntRouteHandler, + routeintrf_Constructor, + routeintrf_Initializer +}; + /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +routeintrf_Initializer(IN PVOID Instance) +{ + /* PnP Interfaces don't get Initialized */ + ASSERTMSG(FALSE, "PCI routeintrf_Initializer, unexpected call."); + return STATUS_UNSUCCESSFUL; +} + +NTSTATUS +NTAPI +routeintrf_Constructor(IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface) +{ + /* Only version 1 is supported */ + if (Version != PCI_INT_ROUTE_INTRF_STANDARD_VER) return STATUS_NOINTERFACE; + + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/pci.h b/reactos/drivers/bus/pcix/pci.h index 5065d8156d3..3ceaadb1da2 100644 --- a/reactos/drivers/bus/pcix/pci.h +++ b/reactos/drivers/bus/pcix/pci.h @@ -49,27 +49,34 @@ #define PCI_HACK_HAS_REVISION_INFO 0x01 #define PCI_HACK_HAS_SUBSYSTEM_INFO 0x02 +// +// PCI Interface Flags +// +#define PCI_INTERFACE_PDO 0x01 +#define PCI_INTERFACE_FDO 0x02 +#define PCI_INTERFACE_ROOT 0x04 + // // Device Extension, Interface, Translator and Arbiter Signatures // typedef enum _PCI_SIGNATURE { - PciPdoExtensionType = '0Pci', - PciFdoExtensionType = '1Pci', - PciArb_Io = '2Pci', - PciArb_Memory = '3Pci', - PciArb_Interrupt = '4Pci', - PciArb_BusNumber = '5Pci', - PciTrans_Interrupt = '6Pci', - PciInterface_BusHandler = '7Pci', - PciInterface_IntRouteHandler = '8Pci', - PciInterface_PciCb = '9Pci', - PciInterface_LegacyDeviceDetection = ':Pci', - PciInterface_PmeHandler = ';Pci', - PciInterface_DevicePresent = 'agpintrf.c busintrf.c cardbus.c + devhere.c ideintrf.c intrface.c lddintrf.c