ReactOS  0.4.13-dev-687-g023794c
fdo.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for fdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI PciFdoIrpStartDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpCancelRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpCancelStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryDeviceRelations (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryInterface (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryCapabilities (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpDeviceUsageNotification (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpSurpriseRemoval (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryLegacyBusInformation (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
VOID NTAPI PciGetHotPlugParameters (IN PPCI_FDO_EXTENSION FdoExtension)
 
VOID NTAPI PciInitializeFdoExtensionCommonFields (PPCI_FDO_EXTENSION FdoExtension, IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI PciAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 

Variables

SINGLE_LIST_ENTRY PciFdoExtensionListHead
 
BOOLEAN PciBreakOnDefault
 
PCI_MN_DISPATCH_TABLE PciFdoDispatchPowerTable []
 
PCI_MN_DISPATCH_TABLE PciFdoDispatchPnpTable []
 
PCI_MJ_DISPATCH_TABLE PciFdoDispatchTable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file fdo.c.

Function Documentation

◆ PciAddDevice()

NTSTATUS NTAPI PciAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 458 of file fdo.c.

460 {
462  PDEVICE_OBJECT AttachedTo;
464  PPCI_FDO_EXTENSION ParentExtension;
467  UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
473  PAGED_CODE();
474  DPRINT1("PCI - AddDevice (a new bus). PDO: %p (Driver: %wZ)\n",
475  PhysicalDeviceObject, &PhysicalDeviceObject->DriverObject->DriverName);
476 
477  /* Zero out variables so failure path knows what to do */
478  AttachedTo = NULL;
479  FdoExtension = NULL;
480  PdoExtension = NULL;
481  DeviceObject = NULL;
482 
483  do
484  {
485  /* Check if there's already a device extension for this bus */
487  &PciGlobalLock);
488  if (ParentExtension)
489  {
490  /* Make sure we find a real PDO */
491  PdoExtension = PhysicalDeviceObject->DeviceExtension;
493 
494  /* Make sure it's a PCI-to-PCI bridge */
495  if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
497  {
498  /* This should never happen */
499  DPRINT1("PCI - PciAddDevice for Non-Root/Non-PCI-PCI bridge,\n"
500  " Class %02x, SubClass %02x, will not add.\n",
501  PdoExtension->BaseClass,
502  PdoExtension->SubClass);
503  ASSERT((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
505 
506  /* Enter the failure path */
508  break;
509  }
510 
511  /* Subordinate bus on the bridge */
512  DPRINT1("PCI - AddDevice (new bus is child of bus 0x%x).\n",
513  ParentExtension->BaseBus);
514 
515  /* Make sure PCI bus numbers are configured */
517  {
518  /* This is a critical failure */
519  DPRINT1("PCI - Bus numbers not configured for bridge (0x%x.0x%x.0x%x)\n",
520  ParentExtension->BaseBus,
521  PdoExtension->Slot.u.bits.DeviceNumber,
522  PdoExtension->Slot.u.bits.FunctionNumber);
523 
524  /* Enter the failure path */
526  break;
527  }
528  }
529 
530  /* Create the FDO for the bus */
532  sizeof(PCI_FDO_EXTENSION),
533  NULL,
535  0,
536  0,
537  &DeviceObject);
538  if (!NT_SUCCESS(Status)) break;
539 
540  /* Initialize the extension for the FDO */
543  DeviceObject,
545 
546  /* Attach to the root PDO */
550  ASSERT(AttachedTo != NULL);
551  if (!AttachedTo) break;
552  FdoExtension->AttachedDeviceObject = AttachedTo;
553 
554  /* Check if this is a child bus, or the root */
555  if (ParentExtension)
556  {
557  /* The child inherits root data */
558  FdoExtension->BaseBus = PdoExtension->Dependent.type1.SecondaryBus;
559  FdoExtension->BusRootFdoExtension = ParentExtension->BusRootFdoExtension;
560  PdoExtension->BridgeFdoExtension = FdoExtension;
561  FdoExtension->ParentFdoExtension = ParentExtension;
562  }
563  else
564  {
565  /* Query the boot configuration */
568  (PVOID*)&Descriptor);
569  if (!NT_SUCCESS(Status))
570  {
571  /* No configuration has been set */
572  Descriptor = NULL;
573  }
574  else
575  {
576  /* Root PDO in ReactOS does not assign boot resources */
577  UNIMPLEMENTED_DBGBREAK("Encountered during setup\n");
578  Descriptor = NULL;
579  }
580 
581  if (Descriptor)
582  {
583  /* Root PDO in ReactOS does not assign boot resources */
585  }
586  else
587  {
588  /* Default configuration isn't the normal path on Windows */
589  if (PciBreakOnDefault)
590  {
591  /* If a second bus is found and there's still no data, crash */
592  KeBugCheckEx(PCI_BUS_DRIVER_INTERNAL,
593  0xDEAD0010u,
595  0,
596  0);
597  }
598 
599  /* Warn that a default configuration will be used, and set bus 0 */
600  DPRINT1("PCI Will use default configuration.\n");
602  FdoExtension->BaseBus = 0;
603  }
604 
605  /* This is the root bus */
606  FdoExtension->BusRootFdoExtension = FdoExtension;
607  }
608 
609  /* Get the HAL or ACPI Bus Handler Callbacks for Configuration Access */
611  if (!NT_SUCCESS(Status)) break;
612 
613  /* Initialize all the supported PCI arbiters */
615  if (!NT_SUCCESS(Status)) break;
616 
617  /* This is a real FDO, insert it into the list */
618  FdoExtension->Fake = FALSE;
620  FdoExtension,
621  &PciGlobalLock);
622 
623  /* Open the device registry key so that we can query the errata flags */
627  &KeyHandle),
628 
629  /* Open the value that contains errata flags for this bus instance */
630  RtlInitUnicodeString(&ValueName, L"HackFlags");
631  Status = ZwQueryValueKey(KeyHandle,
632  &ValueName,
634  ValueInfo,
635  sizeof(Buffer),
636  &ResultLength);
638  if (NT_SUCCESS(Status))
639  {
640  /* Make sure the data is of expected type and size */
641  if ((ValueInfo->Type == REG_DWORD) &&
642  (ValueInfo->DataLength == sizeof(ULONG)))
643  {
644  /* Read the flags for this bus */
645  FdoExtension->BusHackFlags = *(PULONG)&ValueInfo->Data;
646  }
647  }
648 
649  /* Query ACPI for PCI HotPlug Support */
651 
652  /* The Bus FDO is now initialized */
654  return STATUS_SUCCESS;
655  } while (FALSE);
656 
657  /* This is the failure path */
659 
660  /* Check if the FDO extension exists */
661  if (FdoExtension) DPRINT1("Should destroy secondaries\n");
662 
663  /* Delete device objects */
664  if (AttachedTo) IoDetachDevice(AttachedTo);
666  return Status;
667 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
NTSTATUS NTAPI PciGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, OUT PVOID *OutputBuffer)
Definition: utils.c:475
VOID NTAPI PciInsertEntryAtTail(IN PSINGLE_LIST_ENTRY ListHead, IN PPCI_FDO_EXTENSION DeviceExtension, IN PKEVENT Lock)
Definition: utils.c:400
#define TRUE
Definition: types.h:120
KEVENT PciGlobalLock
Definition: init.c:20
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2738
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSTATUS NTAPI PciGetConfigHandlers(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: config.c:224
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1295
#define PAGED_CODE()
Definition: video.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
#define ASSERT_PDO(x)
Definition: pci.h:36
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
PVOID DeviceExtension
Definition: env_spec_w32.h:418
VOID NTAPI PciGetHotPlugParameters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: fdo.c:379
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI PciAreBusNumbersConfigured(IN PPCI_PDO_EXTENSION PdoExtension)
Definition: busno.c:20
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS NTAPI PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: arb_comn.c:40
BOOLEAN BaseBus
Definition: pci.h:209
Definition: bufpool.h:45
PPCI_FDO_EXTENSION NTAPI PciFindParentPciFdoExtension(IN PDEVICE_OBJECT DeviceObject, IN PKEVENT Lock)
Definition: utils.c:340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
SINGLE_LIST_ENTRY PciFdoExtensionListHead
Definition: fdo.c:18
static const WCHAR L[]
Definition: oid.c:1250
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:3808
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
struct _PCI_FDO_EXTENSION * BusRootFdoExtension
Definition: pci.h:203
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
BOOLEAN PciBreakOnDefault
Definition: fdo.c:19
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4565
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:3752
VOID NTAPI PciInitializeFdoExtensionCommonFields(PPCI_FDO_EXTENSION FdoExtension, IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: fdo.c:433
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:147
#define REG_DWORD
Definition: sdbapi.c:596
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

◆ PciFdoIrpCancelRemoveDevice()

NTSTATUS NTAPI PciFdoIrpCancelRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 152 of file fdo.c.

155 {
157  UNREFERENCED_PARAMETER(IoStackLocation);
158  UNREFERENCED_PARAMETER(DeviceExtension);
159 
161  return STATUS_NOT_SUPPORTED;
162 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpCancelStopDevice()

NTSTATUS NTAPI PciFdoIrpCancelStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 194 of file fdo.c.

197 {
199  UNREFERENCED_PARAMETER(IoStackLocation);
200  UNREFERENCED_PARAMETER(DeviceExtension);
201 
203  return STATUS_NOT_SUPPORTED;
204 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpDeviceUsageNotification()

NTSTATUS NTAPI PciFdoIrpDeviceUsageNotification ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 337 of file fdo.c.

340 {
342  UNREFERENCED_PARAMETER(IoStackLocation);
343  UNREFERENCED_PARAMETER(DeviceExtension);
344 
346  return STATUS_NOT_SUPPORTED;
347 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpQueryCapabilities()

NTSTATUS NTAPI PciFdoIrpQueryCapabilities ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 310 of file fdo.c.

313 {
315  PAGED_CODE();
316  ASSERT_FDO(DeviceExtension);
317 
319 
320  /* Get the capabilities */
321  Capabilities = IoStackLocation->Parameters.DeviceCapabilities.Capabilities;
322 
323  /* Inherit wake levels and power mappings from the higher-up capabilities */
324  DeviceExtension->PowerState.SystemWakeLevel = Capabilities->SystemWake;
325  DeviceExtension->PowerState.DeviceWakeLevel = Capabilities->DeviceWake;
326  RtlCopyMemory(DeviceExtension->PowerState.SystemStateMapping,
327  Capabilities->DeviceState,
328  sizeof(DeviceExtension->PowerState.SystemStateMapping));
329 
330  /* Dump the capabilities and return success */
332  return STATUS_SUCCESS;
333 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
VOID NTAPI PciDebugDumpQueryCapabilities(IN PDEVICE_CAPABILITIES DeviceCaps)
Definition: debug.c:221
#define PAGED_CODE()
Definition: video.h:57
#define ASSERT_FDO(x)
Definition: pci.h:35
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
* PDEVICE_CAPABILITIES
Definition: iotypes.h:927
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ PciFdoIrpQueryDeviceRelations()

NTSTATUS NTAPI PciFdoIrpQueryDeviceRelations ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 208 of file fdo.c.

211 {
213  PAGED_CODE();
214 
215  /* Are bus relations being queried? */
216  if (IoStackLocation->Parameters.QueryDeviceRelations.Type != BusRelations)
217  {
218  /* The FDO is a bus, so only bus relations can be obtained */
220  }
221  else
222  {
223  /* Scan the PCI bus and build the device relations for the caller */
224  Status = PciQueryDeviceRelations(DeviceExtension,
226  &Irp->IoStatus.Information);
227  }
228 
229  /* Return the enumeration status back */
230  return Status;
231 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
Status
Definition: gdiplustypes.h:24
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
NTSTATUS NTAPI PciQueryDeviceRelations(IN PPCI_FDO_EXTENSION DeviceExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:2034

◆ PciFdoIrpQueryInterface()

NTSTATUS NTAPI PciFdoIrpQueryInterface ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 235 of file fdo.c.

238 {
240  PAGED_CODE();
241  ASSERT(DeviceExtension->ExtensionType == PciFdoExtensionType);
242 
243  /* Deleted extensions don't respond to IRPs */
244  if (DeviceExtension->DeviceState == PciDeleted)
245  {
246  /* Hand it back to try to deal with it */
247  return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
248  }
249 
250  /* Query our driver for this interface */
251  Status = PciQueryInterface(DeviceExtension,
252  IoStackLocation->Parameters.QueryInterface.
253  InterfaceType,
254  IoStackLocation->Parameters.QueryInterface.
255  Size,
256  IoStackLocation->Parameters.QueryInterface.
257  Version,
258  IoStackLocation->Parameters.QueryInterface.
259  InterfaceSpecificData,
260  IoStackLocation->Parameters.QueryInterface.
261  Interface,
262  FALSE);
263  if (NT_SUCCESS(Status))
264  {
265  /* We found it, let the PDO handle it */
266  Irp->IoStatus.Status = Status;
267  return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
268  }
269  else if (Status == STATUS_NOT_SUPPORTED)
270  {
271  /* Otherwise, we can't handle it, let someone else down the stack try */
272  Status = PciCallDownIrpStack(DeviceExtension, Irp);
274  {
275  /* They can't either, try a last-resort interface lookup */
276  Status = PciQueryInterface(DeviceExtension,
277  IoStackLocation->Parameters.QueryInterface.
278  InterfaceType,
279  IoStackLocation->Parameters.QueryInterface.
280  Size,
281  IoStackLocation->Parameters.QueryInterface.
282  Version,
283  IoStackLocation->Parameters.QueryInterface.
284  InterfaceSpecificData,
285  IoStackLocation->Parameters.QueryInterface.
286  Interface,
287  TRUE);
288  }
289  }
290 
291  /* Has anyone claimed this interface yet? */
293  {
294  /* No, return the original IRP status */
295  Status = Irp->IoStatus.Status;
296  }
297  else
298  {
299  /* Yes, set the new IRP status */
300  Irp->IoStatus.Status = Status;
301  }
302 
303  /* Complete this IRP */
305  return Status;
306 }
#define TRUE
Definition: types.h:120
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI PciPassIrpFromFdoToPdo(IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
Definition: dispatch.c:70
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI PciCallDownIrpStack(IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
Definition: dispatch.c:39
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define IO_NO_INCREMENT
Definition: iotypes.h:565

◆ PciFdoIrpQueryLegacyBusInformation()

NTSTATUS NTAPI PciFdoIrpQueryLegacyBusInformation ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 365 of file fdo.c.

368 {
370  UNREFERENCED_PARAMETER(IoStackLocation);
371  UNREFERENCED_PARAMETER(DeviceExtension);
372 
374  return STATUS_NOT_SUPPORTED;
375 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpQueryRemoveDevice()

NTSTATUS NTAPI PciFdoIrpQueryRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 124 of file fdo.c.

127 {
129  UNREFERENCED_PARAMETER(IoStackLocation);
130  UNREFERENCED_PARAMETER(DeviceExtension);
131 
133  return STATUS_NOT_SUPPORTED;
134 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PciFdoIrpQueryStopDevice()

NTSTATUS NTAPI PciFdoIrpQueryStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 180 of file fdo.c.

183 {
185  UNREFERENCED_PARAMETER(IoStackLocation);
186  UNREFERENCED_PARAMETER(DeviceExtension);
187 
189  return STATUS_NOT_SUPPORTED;
190 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpRemoveDevice()

NTSTATUS NTAPI PciFdoIrpRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 138 of file fdo.c.

141 {
143  UNREFERENCED_PARAMETER(IoStackLocation);
144  UNREFERENCED_PARAMETER(DeviceExtension);
145 
147  return STATUS_NOT_SUPPORTED;
148 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpStartDevice()

NTSTATUS NTAPI PciFdoIrpStartDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 76 of file fdo.c.

79 {
82  PAGED_CODE();
83 
84  /* The device stack must be starting the FDO in a success path */
85  if (!NT_SUCCESS(Irp->IoStatus.Status)) return STATUS_NOT_SUPPORTED;
86 
87  /* Attempt to switch the state machine to the started state */
88  Status = PciBeginStateTransition(DeviceExtension, PciStarted);
89  if (!NT_SUCCESS(Status)) return Status;
90 
91  /* Check for any boot-provided resources */
92  Resources = IoStackLocation->Parameters.StartDevice.AllocatedResources;
93  if ((Resources) && !(PCI_IS_ROOT_FDO(DeviceExtension)))
94  {
95  /* These resources would only be for non-root FDOs, unhandled for now */
96  ASSERT(Resources->Count == 1);
98  }
99 
100  /* Initialize the arbiter for this FDO */
101  Status = PciInitializeArbiterRanges(DeviceExtension, Resources);
102  if (!NT_SUCCESS(Status))
103  {
104  /* Cancel the transition if this failed */
105  PciCancelStateTransition(DeviceExtension, PciStarted);
106  return Status;
107  }
108 
109  /* Again, check for boot-provided resources for non-root FDO */
110  if ((Resources) && !(PCI_IS_ROOT_FDO(DeviceExtension)))
111  {
112  /* Unhandled for now */
113  ASSERT(Resources->Count == 1);
115  }
116 
117  /* Commit the transition to the started state */
118  PciCommitStateTransition(DeviceExtension, PciStarted);
119  return STATUS_SUCCESS;
120 }
VOID NTAPI PciCommitStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:181
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS NTAPI PciCancelStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE StateNotEntered)
Definition: state.c:145
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI PciBeginStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:97
Status
Definition: gdiplustypes.h:24
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:30
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
return STATUS_SUCCESS
Definition: btrfs.c:2777
NTSTATUS NTAPI PciInitializeArbiterRanges(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources)
Definition: arb_comn.c:128

◆ PciFdoIrpStopDevice()

NTSTATUS NTAPI PciFdoIrpStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 166 of file fdo.c.

169 {
171  UNREFERENCED_PARAMETER(IoStackLocation);
172  UNREFERENCED_PARAMETER(DeviceExtension);
173 
175  return STATUS_NOT_SUPPORTED;
176 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciFdoIrpSurpriseRemoval()

NTSTATUS NTAPI PciFdoIrpSurpriseRemoval ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 351 of file fdo.c.

354 {
356  UNREFERENCED_PARAMETER(IoStackLocation);
357  UNREFERENCED_PARAMETER(DeviceExtension);
358 
360  return STATUS_NOT_SUPPORTED;
361 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409

◆ PciGetHotPlugParameters()

VOID NTAPI PciGetHotPlugParameters ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 379 of file fdo.c.

380 {
383  ULONG Length;
385  PAGED_CODE();
386 
387  /* We should receive 4 parameters, per the HPP specification */
388  Length = sizeof(ACPI_EVAL_OUTPUT_BUFFER) + 4 * sizeof(ACPI_METHOD_ARGUMENT);
389 
390  /* Allocate the buffer to hold the parameters */
392  if (!OutputBuffer) return;
393 
394  /* Initialize the output and input buffers. The method is _HPP */
396  *(PULONG)InputBuffer.MethodName = 'PPH_';
398  do
399  {
400  /* Send the IOCTL to the ACPI driver */
401  Status = PciSendIoctl(FdoExtension->PhysicalDeviceObject,
403  &InputBuffer,
404  sizeof(InputBuffer),
405  OutputBuffer,
406  Length);
407  if (!NT_SUCCESS(Status))
408  {
409  /* The method failed, check if we can salvage data from parent */
411  {
412  /* Copy the root bus' hot plug parameters */
413  FdoExtension->HotPlugParameters = FdoExtension->ParentFdoExtension->HotPlugParameters;
414  }
415 
416  /* Nothing more to do on this path */
417  break;
418  }
419 
420  /* ACPI sent back some data. 4 parameters are expected in the output */
421  if (OutputBuffer->Count != 4) break;
422 
423  /* HotPlug PCI Support not yet implemented */
425  } while (FALSE);
426 
427  /* Free the buffer and return */
429 }
#define PCI_POOL_TAG
Definition: pci.h:25
NTSTATUS NTAPI PciSendIoctl(IN PDEVICE_OBJECT DeviceObject, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength)
Definition: utils.c:531
ACPI_EVAL_OUTPUT_BUFFER UNALIGNED * PACPI_EVAL_OUTPUT_BUFFER
Definition: acpiioct.h:90
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
CHAR InputBuffer[80]
Definition: conmgr.c:33
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IOCTL_ACPI_EVAL_METHOD
Definition: acpiioct.h:178
Status
Definition: gdiplustypes.h:24
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:30
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:7
unsigned int * PULONG
Definition: retypes.h:1
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _ACPI_EVAL_OUTPUT_BUFFER ACPI_EVAL_OUTPUT_BUFFER
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by PciAddDevice().

◆ PciInitializeFdoExtensionCommonFields()

VOID NTAPI PciInitializeFdoExtensionCommonFields ( PPCI_FDO_EXTENSION  FdoExtension,
IN PDEVICE_OBJECT  DeviceObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 433 of file fdo.c.

436 {
437  /* Initialize the extension */
439 
440  /* Setup the common fields */
441  FdoExtension->PhysicalDeviceObject = PhysicalDeviceObject;
442  FdoExtension->FunctionalDeviceObject = DeviceObject;
443  FdoExtension->ExtensionType = PciFdoExtensionType;
444  FdoExtension->PowerState.CurrentSystemState = PowerSystemWorking;
445  FdoExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
446  FdoExtension->IrpDispatchTable = &PciFdoDispatchTable;
447 
448  /* Initialize the extension locks */
451 
452  /* Initialize the default state */
454 }
#define TRUE
Definition: types.h:120
PCI_MJ_DISPATCH_TABLE PciFdoDispatchTable
Definition: fdo.c:60
VOID NTAPI PciInitializeState(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: state.c:88
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by PciAddDevice().

Variable Documentation

◆ PciBreakOnDefault

BOOLEAN PciBreakOnDefault

Definition at line 19 of file fdo.c.

Referenced by PciAddDevice().

◆ PciFdoDispatchPnpTable

PCI_MN_DISPATCH_TABLE PciFdoDispatchPnpTable[]
Initial value:
=
{
}
NTSTATUS NTAPI PciFdoIrpStartDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:76
NTSTATUS NTAPI PciFdoIrpStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:166
NTSTATUS NTAPI PciFdoIrpQueryStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:180
NTSTATUS NTAPI PciFdoIrpQueryInterface(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:235
NTSTATUS NTAPI PciFdoIrpCancelRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:152
NTSTATUS NTAPI PciFdoIrpSurpriseRemoval(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:351
NTSTATUS NTAPI PciFdoIrpCancelStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:194
NTSTATUS NTAPI PciFdoIrpRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:138
NTSTATUS NTAPI PciFdoIrpQueryDeviceRelations(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:208
NTSTATUS NTAPI PciFdoIrpDeviceUsageNotification(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:337
NTSTATUS NTAPI PciFdoIrpQueryRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:124
NTSTATUS NTAPI PciFdoIrpQueryCapabilities(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:310
NTSTATUS NTAPI PciFdoIrpQueryLegacyBusInformation(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:365
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:323
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261

Definition at line 30 of file fdo.c.

◆ PciFdoDispatchPowerTable

PCI_MN_DISPATCH_TABLE PciFdoDispatchPowerTable[]
Initial value:
=
{
}
NTSTATUS NTAPI PciFdoIrpQueryPower(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: power.c:236
NTSTATUS NTAPI PciFdoWaitWake(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: power.c:206
NTSTATUS NTAPI PciFdoSetPowerState(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: power.c:221
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:323
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261

Definition at line 21 of file fdo.c.

◆ PciFdoDispatchTable

PCI_MJ_DISPATCH_TABLE PciFdoDispatchTable
Initial value:
=
{
}
#define IRP_MN_QUERY_POWER
PCI_MN_DISPATCH_TABLE PciFdoDispatchPnpTable[]
Definition: fdo.c:30
#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION
Definition: iotypes.h:4070
PCI_MN_DISPATCH_TABLE PciFdoDispatchPowerTable[]
Definition: fdo.c:21
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:323
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261

Definition at line 60 of file fdo.c.

Referenced by PciInitializeFdoExtensionCommonFields().

◆ PciFdoExtensionListHead

SINGLE_LIST_ENTRY PciFdoExtensionListHead

Definition at line 18 of file fdo.c.

Referenced by PciAddDevice(), PciFindParentPciFdoExtension(), and PciFindPdoByLocation().