ReactOS 0.4.17-dev-1190-g4c812f4
fdo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/fdo.c
5 * PURPOSE: FDO Device Management
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
20
22{
28};
29
31{
58};
59
61{
70};
71
72/* FUNCTIONS ******************************************************************/
73
79static
83 _In_ PCM_RESOURCE_LIST BootConfig,
84 _Out_ PUCHAR FirstBus,
85 _Out_ PUCHAR LastBus)
86{
87 PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
89 ULONG FullIndex, PartialIndex;
90 ULONG EndBus;
91 PAGED_CODE();
92
93 FullDescriptor = BootConfig->List;
94 for (FullIndex = 0; FullIndex < BootConfig->Count; FullIndex++)
95 {
96 Partial = FullDescriptor->PartialResourceList.PartialDescriptors;
97 for (PartialIndex = 0;
98 PartialIndex < FullDescriptor->PartialResourceList.Count;
99 PartialIndex++)
100 {
101 if (Partial->Type != CmResourceTypeBusNumber)
102 {
103 Partial = CmiGetNextPartialDescriptor(Partial);
104 continue;
105 }
106
107 /* Bus numbers on a single segment never go past 0xFF */
108 EndBus = Partial->u.BusNumber.Start + Partial->u.BusNumber.Length - 1;
109 ASSERT(Partial->u.BusNumber.Start <= EndBus);
110 ASSERT(EndBus <= 0xFF);
111
112 *FirstBus = (UCHAR)Partial->u.BusNumber.Start;
113 *LastBus = (UCHAR)EndBus;
114 return TRUE;
115 }
116
117 /* The next full descriptor follows the last partial one */
118 FullDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)Partial;
119 }
120
121 return FALSE;
122}
123
127static
128VOID
129NTAPI
132{
133 PPCI_PDO_EXTENSION PdoExtension, NextExtension;
134 PAGED_CODE();
135
138
139 PdoExtension = FdoExtension->ChildPdoList;
140 FdoExtension->ChildPdoList = NULL;
141 FdoExtension->ChildBridgePdoList = NULL;
142
143 KeSetEvent(&FdoExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
145
146 while (PdoExtension)
147 {
149 ASSERT(PdoExtension->DeviceState != PciStarted);
150
151 /* The extension goes away with the device object */
152 NextExtension = PdoExtension->Next;
153
154 if (PdoExtension->Resources)
156
157 IoDeleteDevice(PdoExtension->PhysicalDeviceObject);
158 PdoExtension = NextExtension;
159 }
160}
161
165static
166VOID
167NTAPI
170{
171 VOID (NTAPI *Destructor)(_In_ PVOID Extension);
174 PAGED_CODE();
175
178
179 Entry = FdoExtension->SecondaryExtension.Next;
180 FdoExtension->SecondaryExtension.Next = NULL;
181 FdoExtension->ArbitersInitialized = FALSE;
182
183 KeSetEvent(&FdoExtension->SecondaryExtLock, IO_NO_INCREMENT, FALSE);
185
186 while (Entry)
187 {
189 Entry = Entry->Next;
190
191 /* The destructor frees the range lists, the instance itself is freed here */
192 Destructor = Extension->Destructor;
193 if (Destructor)
194 Destructor(Extension);
195
197 }
198}
199
201NTAPI
204 IN PPCI_FDO_EXTENSION DeviceExtension)
205{
208 PAGED_CODE();
209
210 /* The device stack must be starting the FDO in a success path */
211 if (!NT_SUCCESS(Irp->IoStatus.Status)) return STATUS_NOT_SUPPORTED;
212
213 /* Attempt to switch the state machine to the started state */
214 Status = PciBeginStateTransition(DeviceExtension, PciStarted);
215 if (!NT_SUCCESS(Status)) return Status;
216
217 /* Only a root bus seeds its arbiters from these, a bus behind a bridge uses its windows */
218 Resources = IoStackLocation->Parameters.StartDevice.AllocatedResources;
219
220 /* Initialize the arbiter for this FDO */
221 Status = PciInitializeArbiterRanges(DeviceExtension, Resources);
222 if (!NT_SUCCESS(Status))
223 {
224 /* Cancel the transition if this failed */
225 PciCancelStateTransition(DeviceExtension, PciStarted);
226 return Status;
227 }
228
229 /* Commit the transition to the started state */
230 PciCommitStateTransition(DeviceExtension, PciStarted);
231 return STATUS_SUCCESS;
232}
233
235NTAPI
238 IN PPCI_FDO_EXTENSION DeviceExtension)
239{
240 PAGED_CODE();
241
244
245 /* Paging, hibernation and dump files behind this bus cannot lose their path */
246 if (DeviceExtension->PowerState.Paging ||
247 DeviceExtension->PowerState.Hibernate ||
248 DeviceExtension->PowerState.CrashDump)
249 {
250 return STATUS_DEVICE_BUSY;
251 }
252
253 /* The remove that follows commits this */
254 return PciBeginStateTransition(DeviceExtension, PciDeleted);
255}
256
258NTAPI
261 IN PPCI_FDO_EXTENSION DeviceExtension)
262{
264 PPCI_PDO_EXTENSION BridgeExtension;
267 PAGED_CODE();
268
270
271 /* A remove with no query before it, such as after a failed start, begins the deletion here */
272 if (DeviceExtension->TentativeNextState != PciDeleted)
273 PciBeginStateTransition(DeviceExtension, PciDeleted);
274
275 PciCommitStateTransition(DeviceExtension, PciDeleted);
276
277 /* Unlink the bus first so no lookup can reach it while it comes apart */
280
281 for (Entry = &PciFdoExtensionListHead; Entry->Next; Entry = Entry->Next)
282 {
283 if (Entry->Next == &DeviceExtension->List)
284 {
285 Entry->Next = DeviceExtension->List.Next;
286 break;
287 }
288 }
289
290 if (!PCI_IS_ROOT_FDO(DeviceExtension))
291 {
292 BridgeExtension = DeviceExtension->PhysicalDeviceObject->DeviceExtension;
293 ASSERT_PDO(BridgeExtension);
294
295 if (BridgeExtension->BridgeFdoExtension == DeviceExtension)
296 BridgeExtension->BridgeFdoExtension = NULL;
297 }
298
301
302 PciDeleteBusChildren(DeviceExtension);
303 PciFreeBusSecondaryExtensions(DeviceExtension);
304
305 if (DeviceExtension->PreservedConfig)
306 ExFreePoolWithTag(DeviceExtension->PreservedConfig, TAG_PCI_PRESERVED);
307
308 /* The lower drivers see the remove before this device leaves the stack */
309 DeviceObject = DeviceExtension->FunctionalDeviceObject;
310 AttachedDeviceObject = DeviceExtension->AttachedDeviceObject;
311
312 Irp->IoStatus.Status = STATUS_SUCCESS;
313 Status = PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
314
317 return Status;
318}
319
321NTAPI
324 IN PPCI_FDO_EXTENSION DeviceExtension)
325{
326 PAGED_CODE();
327
330
331 /* The remove is off, so the bus stays where it was */
332 PciCancelStateTransition(DeviceExtension, PciDeleted);
333 return STATUS_SUCCESS;
334}
335
337NTAPI
340 IN PPCI_FDO_EXTENSION DeviceExtension)
341{
342 PAGED_CODE();
343
346
347 PciCommitStateTransition(DeviceExtension, PciStopped);
348
349 /* The next start seeds the arbiters again from the windows it is given */
350 DeviceExtension->ArbitersInitialized = FALSE;
351 return STATUS_SUCCESS;
352}
353
355NTAPI
358 IN PPCI_FDO_EXTENSION DeviceExtension)
359{
360 PAGED_CODE();
361
364
365 /* Paging, hibernation and dump files behind this bus cannot lose their path */
366 if (DeviceExtension->PowerState.Paging ||
367 DeviceExtension->PowerState.Hibernate ||
368 DeviceExtension->PowerState.CrashDump)
369 {
370 return STATUS_DEVICE_BUSY;
371 }
372
373 /* Root bus ranges are fixed, and children would sit outside new bridge windows */
374 if (PCI_IS_ROOT_FDO(DeviceExtension) || DeviceExtension->ChildPdoList)
375 return STATUS_UNSUCCESSFUL;
376
377 return PciBeginStateTransition(DeviceExtension, PciStopped);
378}
379
381NTAPI
384 IN PPCI_FDO_EXTENSION DeviceExtension)
385{
386 PAGED_CODE();
387
390
391 /* The stop is off, so the bus keeps its windows */
392 PciCancelStateTransition(DeviceExtension, PciStopped);
393 return STATUS_SUCCESS;
394}
395
397NTAPI
400 IN PPCI_FDO_EXTENSION DeviceExtension)
401{
403 PAGED_CODE();
404
405 /* Are bus relations being queried? */
407 {
408 /* The FDO is a bus, so only bus relations can be obtained */
410 }
411 else
412 {
413 /* Scan the PCI bus and build the device relations for the caller */
414 Status = PciQueryDeviceRelations(DeviceExtension,
416 &Irp->IoStatus.Information);
417 }
418
419 /* Return the enumeration status back */
420 return Status;
421}
422
424NTAPI
427 IN PPCI_FDO_EXTENSION DeviceExtension)
428{
430 PAGED_CODE();
431 ASSERT(DeviceExtension->ExtensionType == PciFdoExtensionType);
432
433 /* Deleted extensions don't respond to IRPs */
434 if (DeviceExtension->DeviceState == PciDeleted)
435 {
436 /* Hand it back to try to deal with it */
437 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
438 }
439
440 /* Query our driver for this interface */
441 Status = PciQueryInterface(DeviceExtension,
445 Size,
447 Version,
451 Interface,
452 FALSE);
453 if (NT_SUCCESS(Status))
454 {
455 /* We found it, let the PDO handle it */
456 Irp->IoStatus.Status = Status;
457 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
458 }
459 else if (Status == STATUS_NOT_SUPPORTED)
460 {
461 /* Otherwise, we can't handle it, let someone else down the stack try */
462 Status = PciCallDownIrpStack(DeviceExtension, Irp);
464 {
465 /* They can't either, try a last-resort interface lookup */
466 Status = PciQueryInterface(DeviceExtension,
470 Size,
472 Version,
476 Interface,
477 TRUE);
478 }
479 }
480
481 /* Has anyone claimed this interface yet? */
483 {
484 /* No, return the original IRP status */
485 Status = Irp->IoStatus.Status;
486 }
487 else
488 {
489 /* Yes, set the new IRP status */
490 Irp->IoStatus.Status = Status;
491 }
492
493 /* Complete this IRP */
495 return Status;
496}
497
499NTAPI
502 IN PPCI_FDO_EXTENSION DeviceExtension)
503{
505 PAGED_CODE();
506 ASSERT_FDO(DeviceExtension);
507
509
510 /* Get the capabilities */
512
513 /* Inherit wake levels and power mappings from the higher-up capabilities */
514 DeviceExtension->PowerState.SystemWakeLevel = Capabilities->SystemWake;
515 DeviceExtension->PowerState.DeviceWakeLevel = Capabilities->DeviceWake;
516 RtlCopyMemory(DeviceExtension->PowerState.SystemStateMapping,
517 Capabilities->DeviceState,
518 sizeof(DeviceExtension->PowerState.SystemStateMapping));
519
520 /* Dump the capabilities and return success */
522 return STATUS_SUCCESS;
523}
524
526NTAPI
529 IN PPCI_FDO_EXTENSION DeviceExtension)
530{
531 PAGED_CODE();
532
533 /* A failure from below stands, but a lower driver that ignored it does not count */
534 if (!NT_SUCCESS(Irp->IoStatus.Status) &&
535 (Irp->IoStatus.Status != STATUS_NOT_SUPPORTED))
536 {
537 return Irp->IoStatus.Status;
538 }
539
540 return PciUpdateDeviceUsage(&DeviceExtension->PowerState, IoStackLocation);
541}
542
544NTAPI
547 IN PPCI_FDO_EXTENSION DeviceExtension)
548{
549 PAGED_CODE();
550
553
554 /* Only the remove that follows is left, and it commits the deletion */
556 {
558 PciBeginStateTransition(DeviceExtension, PciDeleted);
559 }
560
561 /* Failing this would keep it from reaching the PDO below */
562 return STATUS_SUCCESS;
563}
564
566NTAPI
569 IN PPCI_FDO_EXTENSION DeviceExtension)
570{
572 PAGED_CODE();
573
575
576 /* The PnP manager frees this once it has recorded the bus */
578 sizeof(*BusInformation),
580 if (!BusInformation)
582
583 BusInformation->BusTypeGuid = GUID_BUS_TYPE_PCI;
584 BusInformation->LegacyBusType = PCIBus;
585 BusInformation->BusNumber = DeviceExtension->BaseBus;
586
587 Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
588 return STATUS_SUCCESS;
589}
590
591VOID
592NTAPI
594{
598 ULONG Length, i;
600 PAGED_CODE();
601
602 /* We should receive 4 parameters, per the HPP specification */
604
605 /* Allocate the buffer to hold the parameters */
607 if (!OutputBuffer) return;
608
609 /* Initialize the output and input buffers. The method is _HPP */
611 *(PULONG)InputBuffer.MethodName = 'PPH_';
613 do
614 {
615 /* Send the IOCTL to the ACPI driver */
616 Status = PciSendIoctl(FdoExtension->PhysicalDeviceObject,
619 sizeof(InputBuffer),
621 Length);
622 if (!NT_SUCCESS(Status))
623 {
624 /* The method failed, check if we can salvage data from parent */
626 {
627 /* Copy the root bus' hot plug parameters */
628 FdoExtension->HotPlugParameters = FdoExtension->ParentFdoExtension->HotPlugParameters;
629 }
630
631 /* Nothing more to do on this path */
632 break;
633 }
634
635 /* ACPI sent back some data. 4 parameters are expected in the output */
636 if (OutputBuffer->Count != 4) break;
637
638 /* Every one of them has to be an integer for the set to mean anything */
639 Argument = OutputBuffer->Argument;
640 for (i = 0; i < 4; i++)
641 {
643 break;
644 }
645 if (i != 4)
646 {
647 DPRINT1("PCIX - _HPP returned something other than four integers\n");
648 break;
649 }
650
651 /* Cache line size and latency timer are byte registers, SERR and PERR are flags */
652 if ((Argument[0].Argument > MAXUCHAR) ||
653 (Argument[1].Argument > MAXUCHAR) ||
654 (Argument[2].Argument > 1) ||
655 (Argument[3].Argument > 1))
656 {
657 DPRINT1("PCIX - _HPP returned values out of range, ignoring them\n");
658 break;
659 }
660
661 /* Settings for devices that later appear in a hot plug slot on this bus */
662 FdoExtension->HotPlugParameters.CacheLineSize = (UCHAR)Argument[0].Argument;
663 FdoExtension->HotPlugParameters.LatencyTimer = (UCHAR)Argument[1].Argument;
664 FdoExtension->HotPlugParameters.EnableSERR = (BOOLEAN)Argument[2].Argument;
665 FdoExtension->HotPlugParameters.EnablePERR = (BOOLEAN)Argument[3].Argument;
666 FdoExtension->HotPlugParameters.Acquired = TRUE;
667
668 DPRINT1("PCIX - _HPP for FDO ext 0x%p: cache line %u, latency %u, SERR %u, PERR %u\n",
670 FdoExtension->HotPlugParameters.CacheLineSize,
671 FdoExtension->HotPlugParameters.LatencyTimer,
672 FdoExtension->HotPlugParameters.EnableSERR,
673 FdoExtension->HotPlugParameters.EnablePERR);
674 } while (FALSE);
675
676 /* Free the buffer and return */
678}
679
680VOID
681NTAPI
685{
686 /* Initialize the extension */
688
689 /* Setup the common fields */
690 FdoExtension->PhysicalDeviceObject = PhysicalDeviceObject;
691 FdoExtension->FunctionalDeviceObject = DeviceObject;
692 FdoExtension->ExtensionType = PciFdoExtensionType;
693 FdoExtension->PowerState.CurrentSystemState = PowerSystemWorking;
694 FdoExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
695 FdoExtension->IrpDispatchTable = &PciFdoDispatchTable;
696
697 /* Initialize the extension locks */
700
701 /* Initialize the default state */
703}
704
706NTAPI
709{
711 PDEVICE_OBJECT AttachedTo;
713 PPCI_FDO_EXTENSION ParentExtension;
722 PAGED_CODE();
723 DPRINT1("PCIX - AddDevice (a new bus). PDO: %p (Driver: %wZ)\n",
724 PhysicalDeviceObject, &PhysicalDeviceObject->DriverObject->DriverName);
725
726 /* Zero out variables so failure path knows what to do */
727 AttachedTo = NULL;
731
732 do
733 {
734 /* Check if there's already a device extension for this bus */
737 if (ParentExtension)
738 {
739 /* Make sure we find a real PDO */
742
743 /* Make sure it's a PCI-to-PCI bridge */
744 if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
746 {
747 /* This should never happen */
748 DPRINT1("PCIX - PciAddDevice for Non-Root/Non-PCI-PCI bridge,\n"
749 " Class %02x, SubClass %02x, will not add.\n",
750 PdoExtension->BaseClass,
751 PdoExtension->SubClass);
752 ASSERT((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
754
755 /* Enter the failure path */
757 break;
758 }
759
760 /* Subordinate bus on the bridge */
761 DPRINT1("PCIX - AddDevice (new bus is child of bus 0x%x).\n",
762 ParentExtension->BaseBus);
763
764 /* Make sure PCI bus numbers are configured */
766 {
767 /* This is a critical failure */
768 DPRINT1("PCIX - Bus numbers not configured for bridge (0x%x.0x%x.0x%x)\n",
769 ParentExtension->BaseBus,
770 PdoExtension->Slot.u.bits.DeviceNumber,
771 PdoExtension->Slot.u.bits.FunctionNumber);
772
773 /* Enter the failure path */
775 break;
776 }
777 }
778
779 /* Create the FDO for the bus */
781 sizeof(PCI_FDO_EXTENSION),
782 NULL,
784 0,
785 0,
786 &DeviceObject);
787 if (!NT_SUCCESS(Status)) break;
788
789 /* Initialize the extension for the FDO */
790 FdoExtension = DeviceObject->DeviceExtension;
794
795 /* Attach to the root PDO */
799 ASSERT(AttachedTo != NULL);
800 if (!AttachedTo) break;
801 FdoExtension->AttachedDeviceObject = AttachedTo;
802
803 /* Check if this is a child bus, or the root */
804 if (ParentExtension)
805 {
806 /* The child inherits root data */
807 FdoExtension->BaseBus = PdoExtension->Dependent.type1.SecondaryBus;
808 FdoExtension->BusRootFdoExtension = ParentExtension->BusRootFdoExtension;
809 PdoExtension->BridgeFdoExtension = FdoExtension;
810 FdoExtension->ParentFdoExtension = ParentExtension;
811 }
812 else
813 {
814 /* Query the boot configuration */
817 (PVOID*)&Descriptor);
818 if (!NT_SUCCESS(Status))
819 {
820 /* No configuration has been set */
822 }
823
824 /* The firmware reports the bus numbers this root decodes in its boot config */
825 if (Descriptor &&
827 &FdoExtension->BaseBus,
828 &FdoExtension->MaxSubordinateBus))
829 {
830 DPRINT1("PCIX - Root bus range 0x%x to 0x%x.\n",
831 FdoExtension->BaseBus,
832 FdoExtension->MaxSubordinateBus);
833 }
834 else
835 {
836 /* Default configuration isn't the normal path on Windows */
838 {
839 /* If a second bus is found and there's still no data, crash */
840 KeBugCheckEx(PCI_BUS_DRIVER_INTERNAL,
841 0xDEAD0010u,
843 0,
844 0);
845 }
846
847 /* Warn that a default configuration will be used, and set bus 0 */
848 DPRINT1("PCIX - Will use default configuration.\n");
850 FdoExtension->BaseBus = 0;
851 FdoExtension->MaxSubordinateBus = 0xFF;
852 }
853
854 if (Descriptor)
856
857 /* This is the root bus */
858 FdoExtension->BusRootFdoExtension = FdoExtension;
859 }
860
861 /* Get the HAL or ACPI Bus Handler Callbacks for Configuration Access */
863 if (!NT_SUCCESS(Status)) break;
864
865 /* Map this bus for extended configuration space access */
867
868 /* Initialize all the supported PCI arbiters */
870 if (!NT_SUCCESS(Status)) break;
871
872 /* This is a real FDO, insert it into the list */
873 FdoExtension->Fake = FALSE;
877
878 /* Open the device registry key so that we can query the errata flags */
882 &KeyHandle),
883
884 /* Open the value that contains errata flags for this bus instance */
885 RtlInitUnicodeString(&ValueName, L"HackFlags");
886 Status = ZwQueryValueKey(KeyHandle,
887 &ValueName,
889 ValueInfo,
890 sizeof(Buffer),
891 &ResultLength);
893 if (NT_SUCCESS(Status))
894 {
895 /* Make sure the data is of expected type and size */
896 if ((ValueInfo->Type == REG_DWORD) &&
897 (ValueInfo->DataLength == sizeof(ULONG)))
898 {
899 /* Read the flags for this bus */
900 FdoExtension->BusHackFlags = *(PULONG)&ValueInfo->Data;
901 }
902 }
903
904 /* Query ACPI for PCI HotPlug Support */
906
907 /* The Bus FDO is now initialized */
908 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
909 return STATUS_SUCCESS;
910 } while (FALSE);
911
912 /* This is the failure path */
914
915 /* Check if the FDO extension exists */
916 if (FdoExtension) DPRINT1("PCIX - Should destroy secondaries\n");
917
918 /* Delete device objects */
919 if (AttachedTo) IoDetachDevice(AttachedTo);
921 return Status;
922}
923
924/* EOF */
#define PAGED_CODE()
Type
Definition: Type.h:7
#define VOID
Definition: acefi.h:82
ACPI_METHOD_ARGUMENT UNALIGNED * PACPI_METHOD_ARGUMENT
Definition: acpiioct.h:80
struct _ACPI_EVAL_OUTPUT_BUFFER ACPI_EVAL_OUTPUT_BUFFER
#define ACPI_METHOD_ARGUMENT_INTEGER
Definition: acpiioct.h:30
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:12
#define IOCTL_ACPI_EVAL_METHOD
Definition: acpiioct.h:194
ACPI_EVAL_OUTPUT_BUFFER UNALIGNED * PACPI_EVAL_OUTPUT_BUFFER
Definition: acpiioct.h:99
unsigned char BOOLEAN
Definition: actypes.h:127
NTSTATUS NTAPI PciInitializeArbiterRanges(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources)
Definition: arb_comn.c:447
NTSTATUS NTAPI PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: arb_comn.c:242
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: debug.c:485
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
static VOID NTAPI PciFreeBusSecondaryExtensions(_Inout_ PPCI_FDO_EXTENSION FdoExtension)
Destroys the arbiter instances a bus being removed still holds.
Definition: fdo.c:168
PCI_MN_DISPATCH_TABLE PciFdoDispatchPnpTable[]
Definition: fdo.c:30
NTSTATUS NTAPI PciFdoIrpQueryLegacyBusInformation(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:567
NTSTATUS NTAPI PciFdoIrpStartDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:202
NTSTATUS NTAPI PciFdoIrpStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:338
static BOOLEAN NTAPI PciGetRootBusRange(_In_ PCM_RESOURCE_LIST BootConfig, _Out_ PUCHAR FirstBus, _Out_ PUCHAR LastBus)
Finds the bus number range a root bus decodes in its boot configuration.
Definition: fdo.c:82
static VOID NTAPI PciDeleteBusChildren(_Inout_ PPCI_FDO_EXTENSION FdoExtension)
Deletes the PDOs of a bus being removed. Each one already had its own remove.
Definition: fdo.c:130
NTSTATUS NTAPI PciFdoIrpSurpriseRemoval(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:545
PCI_MJ_DISPATCH_TABLE PciFdoDispatchTable
Definition: fdo.c:60
VOID NTAPI PciInitializeFdoExtensionCommonFields(PPCI_FDO_EXTENSION FdoExtension, IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: fdo.c:682
NTSTATUS NTAPI PciFdoIrpQueryDeviceRelations(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:398
NTSTATUS NTAPI PciFdoIrpQueryRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:236
PCI_MN_DISPATCH_TABLE PciFdoDispatchPowerTable[]
Definition: fdo.c:21
NTSTATUS NTAPI PciFdoIrpCancelRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:322
NTSTATUS NTAPI PciFdoIrpQueryInterface(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:425
NTSTATUS NTAPI PciFdoIrpQueryCapabilities(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:500
BOOLEAN PciBreakOnDefault
Definition: fdo.c:19
SINGLE_LIST_ENTRY PciFdoExtensionListHead
Definition: fdo.c:18
NTSTATUS NTAPI PciFdoIrpDeviceUsageNotification(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:527
NTSTATUS NTAPI PciFdoIrpQueryStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:356
VOID NTAPI PciGetHotPlugParameters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: fdo.c:593
NTSTATUS NTAPI PciFdoIrpCancelStopDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:382
NTSTATUS NTAPI PciFdoIrpRemoveDevice(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: fdo.c:259
Definition: bufpool.h:45
FORCEINLINE PCM_PARTIAL_RESOURCE_DESCRIPTOR CmiGetNextPartialDescriptor(_In_ const CM_PARTIAL_RESOURCE_DESCRIPTOR *PartialDescriptor)
Definition: cmreslist.h:31
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG _In_ PVOID Argument
Definition: dispmprt.h:1288
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
VOID NTAPI PciDebugDumpQueryCapabilities(IN PDEVICE_CAPABILITIES DeviceCaps)
Definition: debug.c:221
NTSTATUS NTAPI PciIrpNotSupported(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: dispatch.c:261
NTSTATUS NTAPI PciCallDownIrpStack(IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
Definition: dispatch.c:39
NTSTATUS NTAPI PciPassIrpFromFdoToPdo(IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
Definition: dispatch.c:70
NTSTATUS NTAPI PciQueryDeviceRelations(IN PPCI_FDO_EXTENSION DeviceExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:2366
KEVENT PciGlobalLock
Definition: init.c:20
VOID NTAPI PciInsertEntryAtTail(IN PSINGLE_LIST_ENTRY ListHead, IN PPCI_FDO_EXTENSION DeviceExtension, IN PKEVENT Lock)
Definition: utils.c:400
NTSTATUS NTAPI PciFdoWaitWake(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: power.c:305
@ PciSurpriseRemoved
Definition: pci.h:172
@ PciDeleted
Definition: pci.h:170
@ PciStarted
Definition: pci.h:169
@ PciStopped
Definition: pci.h:171
NTSTATUS NTAPI PciFdoSetPowerState(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: power.c:318
NTSTATUS NTAPI PciCancelStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:145
NTSTATUS NTAPI PciBeginStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:97
BOOLEAN NTAPI PciAreBusNumbersConfigured(IN PPCI_PDO_EXTENSION PdoExtension)
Definition: busno.c:20
@ IRP_UPWARD
Definition: pci.h:184
@ IRP_DISPATCH
Definition: pci.h:185
@ IRP_DOWNWARD
Definition: pci.h:183
VOID NTAPI PciInitializeEcam(_In_ PPCI_FDO_EXTENSION FdoExtension)
Maps the bus an FDO decodes into the ECAM window and verifies the window the first time a bus with de...
Definition: ecam.c:336
#define TAG_PCI_PRESERVED
Definition: pci.h:37
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:390
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:42
PPCI_FDO_EXTENSION NTAPI PciFindParentPciFdoExtension(IN PDEVICE_OBJECT DeviceObject, IN PKEVENT Lock)
Definition: utils.c:340
NTSTATUS NTAPI PciUpdateDeviceUsage(_Inout_ PPCI_POWER_STATE PowerState, _In_ PIO_STACK_LOCATION IoStackLocation)
Counts a paging, hibernation or dump file arriving on or leaving a device.
Definition: usage.c:35
NTSTATUS NTAPI PciGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, OUT PVOID *OutputBuffer)
Definition: utils.c:475
#define PCI_POOL_TAG
Definition: pci.h:27
VOID NTAPI PciCommitStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:181
#define ASSERT_FDO(x)
Definition: pci.h:47
#define ASSERT_PDO(x)
Definition: pci.h:48
NTSTATUS NTAPI PciFdoIrpQueryPower(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: power.c:351
VOID NTAPI PciInitializeState(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: state.c:88
NTSTATUS NTAPI PciGetConfigHandlers(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: config.c:266
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
@ PciFdoExtensionType
Definition: pci.h:134
#define ULONG_PTR
Definition: config.h:101
@ PdoExtension
Definition: precomp.h:61
@ FdoExtension
Definition: precomp.h:60
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define PagedPool
Definition: env_spec_w32.h:308
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
Status
Definition: gdiplustypes.h:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
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
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
_In_ PIRP Irp
Definition: kse.h:79
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define _Inout_
Definition: no_sal2.h:162
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
@ KeyValuePartialInformation
Definition: nt_native.h:1185
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ SynchronizationEvent
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:973
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:1038
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1306
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261
#define IoCompleteRequest
Definition: irp.c:1272
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerDeviceD0
Definition: ntpoapi.h:49
static DRIVER_ADD_DEVICE PciAddDevice
Definition: pci.c:20
#define BOOLEAN
Definition: pedump.c:73
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:1621
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:87
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
@ PCIBus
Definition: restypes.h:127
#define CmResourceTypeBusNumber
Definition: restypes.h:109
#define REG_DWORD
Definition: sdbapi.c:615
Entry
Definition: section.c:5216
#define STATUS_SUCCESS
Definition: shellext.h:65
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:145
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@502 BusNumber
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
PVOID DeviceExtension
Definition: env_spec_w32.h:418
struct _IO_STACK_LOCATION::@5020::@5045 QueryDeviceRelations
struct _IO_STACK_LOCATION::@5020::@5057 StartDevice
struct _IO_STACK_LOCATION::@5020::@5047 DeviceCapabilities
union _IO_STACK_LOCATION::@1814 Parameters
struct _IO_STACK_LOCATION::@5020::@5046 QueryInterface
BOOLEAN BaseBus
Definition: pci.h:260
struct _PCI_FDO_EXTENSION * BusRootFdoExtension
Definition: pci.h:254
PCI_FDO_EXTENSION * BridgeFdoExtension
Definition: pci.h:372
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:333
Definition: ntbasedef.h:640
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ PGUID _In_ ULONG _Out_ PULONG ResultLength
Definition: ucxcontroller.h:83
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define MAXUCHAR
Definition: umtypes.h:117
_In_ PIO_STACK_LOCATION IoStackLocation
Definition: usbdlib.h:292
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3921
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:472
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT AttachedDeviceObject
Definition: wdfminiport.h:70
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2793
@ BusRelations
Definition: iotypes.h:2154
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:4181
@ DevicePropertyBootConfiguration
Definition: iotypes.h:1198
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4124
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
#define IRP_MN_QUERY_POWER
#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION
Definition: iotypes.h:4443
@ Executive
Definition: ketypes.h:467