// // set token [checked] // NTSTATUS PciSetRoutingToken(__in PDEVICE_OBJECT Pdo,__in PROUTING_TOKEN RoutingToken) { PAGED_CODE(); // // try to set legacy device token // if(NT_SUCCESS(PciSetLegacyDeviceToken(Pdo,RoutingToken))) return STATUS_SUCCESS; // // is not a legacy device,build an IntRouteHandler extension // PPCI_PDO_EXTENSION PdoExt = static_cast<PPCI_PDO_EXTENSION>(Pdo->DeviceExtension); if(PciFindNextSecondaryExtension(PdoExt->SecondaryExtension.Next,PciInterface_IntRouteHandler)) { DbgPrint("PCI: *** redundant PCI routing extesion being created ***\n"); ASSERT(FALSE); } ULONG Length = sizeof(PCI_INTTERUPT_ROUTING_SECONDARY_EXTENSION); PPCI_INTTERUPT_ROUTING_SECONDARY_EXTENSION IntExt = static_cast<PPCI_INTTERUPT_ROUTING_SECONDARY_EXTENSION>(PciAllocateColdPoolWithTag(PagedPool,Length,'BicP')); if(!IntExt) return STATUS_INSUFFICIENT_RESOURCES; RtlZeroMemory(IntExt,Length); RtlCopyMemory(&IntExt->RoutingToken,RoutingToken,sizeof(ROUTING_TOKEN)); // // link it to the device // PcipLinkSecondaryExtension(&PdoExt->SecondaryExtension,&IntExt->SecondaryExtension,&PdoExt->Common.SecondaryExtLock,PciInterface_IntRouteHandler,0); return STATUS_SUCCESS; }
NTSTATUS NTAPI PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension) { PPCI_INTERFACE CurrentInterface, *Interfaces; PPCI_PDO_EXTENSION PdoExtension; PPCI_ARBITER_INSTANCE ArbiterInterface; NTSTATUS Status; PCI_SIGNATURE ArbiterType; ASSERT_FDO(FdoExtension); /* Loop all the arbiters */ 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)) { /* Get the PDO extension */ PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension; ASSERT_PDO(PdoExtension); /* Skip this bus if it does subtractive decode */ if (PdoExtension->Dependent.type1.SubtractiveDecode) { DPRINT1("PCI Not creating arbiters for subtractive bus %u\n", PdoExtension->Dependent.type1.SubtractiveDecode); continue; } } /* Query all the registered arbiter interfaces */ Interfaces = PciInterfaces; while (*Interfaces) { /* Find the one that matches the arbiter currently being setup */ CurrentInterface = *Interfaces; if (CurrentInterface->Signature == ArbiterType) break; Interfaces++; } /* Check if the required arbiter was not found in the list */ if (!*Interfaces) { /* Skip this arbiter and try the next one */ DPRINT1("PCI - FDO ext 0x%p no %s arbiter.\n", FdoExtension, PciArbiterNames[ArbiterType - PciArb_Io]); continue; } /* An arbiter was found, allocate an instance for it */ Status = STATUS_INSUFFICIENT_RESOURCES; ArbiterInterface = ExAllocatePoolWithTag(PagedPool, sizeof(PCI_ARBITER_INSTANCE), PCI_POOL_TAG); if (!ArbiterInterface) break; /* Setup the instance */ ArbiterInterface->BusFdoExtension = FdoExtension; ArbiterInterface->Interface = CurrentInterface; swprintf(ArbiterInterface->InstanceName, L"PCI %S (b=%02x)", PciArbiterNames[ArbiterType - PciArb_Io], FdoExtension->BaseBus); /* Call the interface initializer for it */ Status = CurrentInterface->Initializer(ArbiterInterface); if (!NT_SUCCESS(Status)) break; /* Link it with this FDO */ PcipLinkSecondaryExtension(&FdoExtension->SecondaryExtension, &FdoExtension->SecondaryExtLock, &ArbiterInterface->Header, ArbiterType, PciArbiterDestructor); /* This arbiter is now initialized, move to the next one */ DPRINT1("PCI - FDO ext 0x%p %S arbiter initialized (context 0x%p).\n", FdoExtension, L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name, ArbiterInterface); Status = STATUS_SUCCESS; } /* Return to caller */ return Status; }