Author: evb Date: Fri Jul 16 00:39:54 2010 New Revision: 48074
URL: http://svn.reactos.org/svn/reactos?rev=48074&view=rev Log: 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!
Added: trunk/reactos/drivers/bus/pcix/intrface/devhere.c (with props) Modified: trunk/reactos/drivers/bus/pcix/arb/ar_busno.c trunk/reactos/drivers/bus/pcix/arb/ar_memio.c trunk/reactos/drivers/bus/pcix/arb/arb_comn.c trunk/reactos/drivers/bus/pcix/arb/tr_irq.c trunk/reactos/drivers/bus/pcix/dispatch.c trunk/reactos/drivers/bus/pcix/fdo.c trunk/reactos/drivers/bus/pcix/intrface/agpintrf.c trunk/reactos/drivers/bus/pcix/intrface/busintrf.c trunk/reactos/drivers/bus/pcix/intrface/cardbus.c trunk/reactos/drivers/bus/pcix/intrface/intrface.c trunk/reactos/drivers/bus/pcix/intrface/lddintrf.c trunk/reactos/drivers/bus/pcix/intrface/locintrf.c trunk/reactos/drivers/bus/pcix/intrface/pmeintf.c trunk/reactos/drivers/bus/pcix/intrface/routintf.c trunk/reactos/drivers/bus/pcix/pci.h trunk/reactos/drivers/bus/pcix/pcix.rbuild
Modified: trunk/reactos/drivers/bus/pcix/arb/ar_busno.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/arb/ar_bus... ============================================================================== --- trunk/reactos/drivers/bus/pcix/arb/ar_busno.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/arb/ar_busno.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/arb/ar_memio.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/arb/ar_mem... ============================================================================== --- trunk/reactos/drivers/bus/pcix/arb/ar_memio.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/arb/ar_memio.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/arb/arb_comn.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/arb/arb_co... ============================================================================== --- trunk/reactos/drivers/bus/pcix/arb/arb_comn.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/arb/arb_comn.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -44,7 +44,7 @@ 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 @@ /* 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; }
Modified: trunk/reactos/drivers/bus/pcix/arb/tr_irq.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/arb/tr_irq... ============================================================================== --- trunk/reactos/drivers/bus/pcix/arb/tr_irq.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/arb/tr_irq.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/dispatch.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/dispatch.c... ============================================================================== --- trunk/reactos/drivers/bus/pcix/dispatch.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/dispatch.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -102,8 +102,8 @@ 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 @@ /* WMI IRPs */ DispatchFunction = IrpDispatchTable->SystemControlIrpDispatchFunction; DispatchStyle = IrpDispatchTable->SystemControlIrpDispatchStyle; - MaxMinor = -1; + MaxMinor = 0xFFFF; break;
default: @@ -154,12 +154,12 @@ /* 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 @@ { /* Not supported */ DPRINT1("WARNING: PCI received unsupported IRP!\n"); - DbgBreakPoint(); + //DbgBreakPoint(); return STATUS_NOT_SUPPORTED; }
Modified: trunk/reactos/drivers/bus/pcix/fdo.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/fdo.c?rev=... ============================================================================== --- trunk/reactos/drivers/bus/pcix/fdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/fdo.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -164,9 +164,73 @@ 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
Modified: trunk/reactos/drivers/bus/pcix/intrface/agpintrf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/a... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/agpintrf.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/agpintrf.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/intrface/busintrf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/b... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/busintrf.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/busintrf.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/intrface/cardbus.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/c... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/cardbus.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/cardbus.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Added: trunk/reactos/drivers/bus/pcix/intrface/devhere.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/d... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/devhere.c (added) +++ trunk/reactos/drivers/bus/pcix/intrface/devhere.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -1,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 <pci.h> +#define NDEBUG +#include <debug.h> + +/* 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 */
Propchange: trunk/reactos/drivers/bus/pcix/intrface/devhere.c ------------------------------------------------------------------------------ svn:eol-style = native
Propchange: trunk/reactos/drivers/bus/pcix/intrface/devhere.c ------------------------------------------------------------------------------ svn:mime-type = text/plain
Modified: trunk/reactos/drivers/bus/pcix/intrface/intrface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/i... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/intrface.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/intrface.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/intrface/lddintrf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/l... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/lddintrf.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/lddintrf.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/intrface/locintrf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/l... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/locintrf.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/locintrf.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/intrface/pmeintf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/p... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/pmeintf.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/pmeintf.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/intrface/routintf.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/intrface/r... ============================================================================== --- trunk/reactos/drivers/bus/pcix/intrface/routintf.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/intrface/routintf.c [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -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 */
Modified: trunk/reactos/drivers/bus/pcix/pci.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/pci.h?rev=... ============================================================================== --- trunk/reactos/drivers/bus/pcix/pci.h [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/pci.h [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -50,26 +50,33 @@ #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 = '<Pci', - PciInterface_NativeIde = '=Pci', - PciInterface_AgpTarget = '>Pci', - PciInterface_Location = '?Pci' + PciPdoExtensionType = 'icP0', + PciFdoExtensionType = 'icP1', + PciArb_Io = 'icP2', + PciArb_Memory = 'icP3', + PciArb_Interrupt = 'icP4', + PciArb_BusNumber = 'icP5', + PciTrans_Interrupt = 'icP6', + PciInterface_BusHandler = 'icP7', + PciInterface_IntRouteHandler = 'icP8', + PciInterface_PciCb = 'icP9', + PciInterface_LegacyDeviceDetection = 'icP:', + PciInterface_PmeHandler = 'icP;', + PciInterface_DevicePresent = 'icP<', + PciInterface_NativeIde = 'icP=', + PciInterface_AgpTarget = 'icP>', + PciInterface_Location = 'icP?' } PCI_SIGNATURE, *PPCI_SIGNATURE;
// @@ -220,7 +227,7 @@ // struct _PCI_INTERFACE; typedef NTSTATUS (NTAPI *PCI_INTERFACE_CONSTRUCTOR)( - IN PPCI_FDO_EXTENSION DeviceExtension, + IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, @@ -237,7 +244,7 @@ // typedef struct _PCI_INTERFACE { - LPGUID InterfaceType; + CONST GUID *InterfaceType; USHORT MinSize; USHORT MinVersion; USHORT MaxVersion; @@ -288,6 +295,21 @@ IN PPCI_FDO_EXTENSION DeviceExtension );
+NTSTATUS +NTAPI +PciPassIrpFromFdoToPdo( + IN PPCI_FDO_EXTENSION DeviceExtension, + IN PIRP Irp +); + +NTSTATUS +NTAPI +PciCallDownIrpStack( + IN PPCI_FDO_EXTENSION DeviceExtension, + IN PIRP Irp +); + + // // Power Routines // @@ -581,10 +603,242 @@ );
// +// Interface Support +// +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 +); + +NTSTATUS +NTAPI +PciPmeInterfaceInitializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +routeintrf_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +arbusno_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +agpintrf_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +tranirq_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +busintrf_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +armem_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +ario_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +locintrf_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +pcicbintrf_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +lddintrf_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +devpresent_Initializer( + IN PVOID Instance +); + +NTSTATUS +NTAPI +agpintrf_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +arbusno_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +tranirq_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +armem_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +busintrf_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +ario_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +pcicbintrf_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +lddintrf_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +locintrf_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +PciPmeInterfaceConstructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +routeintrf_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +NTSTATUS +NTAPI +devpresent_Constructor( + IN PVOID DeviceExtension, + IN PVOID Instance, + IN PVOID InterfaceData, + IN USHORT Version, + IN USHORT Size, + IN PINTERFACE Interface +); + +// // External Resources // extern SINGLE_LIST_ENTRY PciFdoExtensionListHead; extern KEVENT PciGlobalLock; extern PPCI_INTERFACE PciInterfaces[]; +extern PCI_INTERFACE ArbiterInterfaceBusNumber; +extern PCI_INTERFACE ArbiterInterfaceMemory; +extern PCI_INTERFACE ArbiterInterfaceIo; +extern PCI_INTERFACE BusHandlerInterface; +extern PCI_INTERFACE PciRoutingInterface; +extern PCI_INTERFACE PciCardbusPrivateInterface; +extern PCI_INTERFACE PciLegacyDeviceDetectionInterface; +extern PCI_INTERFACE PciPmeInterface; +extern PCI_INTERFACE PciDevicePresentInterface; +//extern PCI_INTERFACE PciNativeIdeInterface; +extern PCI_INTERFACE PciLocationInterface; +extern PCI_INTERFACE AgpTargetInterface; +extern PCI_INTERFACE TranslatorInterfaceInterrupt;
/* EOF */
Modified: trunk/reactos/drivers/bus/pcix/pcix.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/pcix.rbuil... ============================================================================== --- trunk/reactos/drivers/bus/pcix/pcix.rbuild [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/pcix.rbuild [iso-8859-1] Fri Jul 16 00:39:54 2010 @@ -16,6 +16,7 @@ <file>agpintrf.c</file> <file>busintrf.c</file> <file>cardbus.c</file> + <file>devhere.c</file> <file>ideintrf.c</file> <file>intrface.c</file> <file>lddintrf.c</file>