// // get routing info [checked] // NTSTATUS PciGetInterruptRoutingInfo(__in PDEVICE_OBJECT Pdo,__out PULONG Bus,__out PULONG PciSlot,__out PUCHAR InterruptLine,__out PUCHAR InterruptPin, __out PUCHAR ClassCode,__out PUCHAR SubClassCode,__out PDEVICE_OBJECT* ParentPdo,__out PROUTING_TOKEN RoutingToken) { PAGED_CODE(); ASSERT(Bus); ASSERT(PciSlot); ASSERT(InterruptLine); ASSERT(InterruptPin); ASSERT(ClassCode); ASSERT(SubClassCode); ASSERT(ParentPdo); ASSERT(RoutingToken); // // search legacy devices with this pdo // NTSTATUS Status = PciFindLegacyDevice(Pdo,Bus,PciSlot,InterruptLine,InterruptPin,ClassCode,SubClassCode,ParentPdo,RoutingToken); if(NT_SUCCESS(Status)) return Status; // // not found in legacy device list,get those info from pdo ext // PPCI_PDO_EXTENSION PdoExt = static_cast<PPCI_PDO_EXTENSION>(Pdo->DeviceExtension); if(!PdoExt || PdoExt->Common.ExtensionType != PciPdoExtensionType) return STATUS_NOT_FOUND; *Bus = PdoExt->ParentFdoExtension->BaseBus; *PciSlot = PdoExt->Slot.u.AsULONG; *InterruptLine = PdoExt->RawInterruptLine; *InterruptPin = PdoExt->InterruptPin; *ClassCode = PdoExt->BaseClass; *SubClassCode = PdoExt->SubClass; *ParentPdo = PdoExt->ParentFdoExtension->PhysicalDeviceObject; PPCI_SECONDARY_EXTENSION SecondaryExt = PciFindNextSecondaryExtension(PdoExt->SecondaryExtension.Next,PciInterface_IntRouteHandler); if(SecondaryExt) RtlCopyMemory(RoutingToken,SecondaryExt + 1,sizeof(ROUTING_TOKEN)); else RtlZeroMemory(RoutingToken,sizeof(ROUTING_TOKEN)); return STATUS_SUCCESS; }
VOID NTAPI ario_ApplyBrokenVideoHack(IN PPCI_FDO_EXTENSION FdoExtension) { PPCI_ARBITER_INSTANCE PciArbiter; //PARBITER_INSTANCE CommonInstance; //NTSTATUS Status; /* Only valid for root FDOs who are being applied the hack for the first time */ ASSERT(!FdoExtension->BrokenVideoHackApplied); ASSERT(PCI_IS_ROOT_FDO(FdoExtension)); /* Find the I/O arbiter */ PciArbiter = (PVOID)PciFindNextSecondaryExtension(FdoExtension-> SecondaryExtension.Next, PciArb_Io); ASSERT(PciArbiter); #if 0 // when arb exist /* Get the Arb instance */ CommonInstance = &PciArbiter->CommonInstance; /* Free the two lists, enabling full VGA access */ ArbFreeOrderingList(&CommonInstance->OrderingList); ArbFreeOrderingList(&CommonInstance->ReservedList); /* Build the ordering for broken video PCI access */ Status = ArbBuildAssignmentOrdering(CommonInstance, L"Pci", L"BrokenVideo", NULL); ASSERT(NT_SUCCESS(Status)); #else //Status = STATUS_SUCCESS; UNIMPLEMENTED; while (TRUE); #endif /* Now the hack has been applied */ FdoExtension->BrokenVideoHackApplied = TRUE; }
// // 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 PciInitializeArbiterRanges(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources) { PPCI_PDO_EXTENSION PdoExtension; //CM_RESOURCE_TYPE DesiredType; PVOID Instance; PCI_SIGNATURE ArbiterType; UNREFERENCED_PARAMETER(Resources); /* Arbiters should not already be initialized */ if (DeviceExtension->ArbitersInitialized) { /* Duplicated start request, fail initialization */ DPRINT1("PCI Warning hot start FDOx %p, resource ranges not checked.\n", DeviceExtension); return STATUS_INVALID_DEVICE_REQUEST; } /* Check for non-root FDO */ if (!PCI_IS_ROOT_FDO(DeviceExtension)) { /* Grab the PDO */ PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension->PhysicalDeviceObject->DeviceExtension; ASSERT_PDO(PdoExtension); /* Check if this is a subtractive bus */ if (PdoExtension->Dependent.type1.SubtractiveDecode) { /* There is nothing to do regarding arbitration of resources */ DPRINT1("PCI Skipping arbiter initialization for subtractive bridge FDOX %p\n", DeviceExtension); return STATUS_SUCCESS; } } /* Loop all arbiters */ for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++) { /* Pick correct resource type for each arbiter */ if (ArbiterType == PciArb_Io) { /* I/O Port */ //DesiredType = CmResourceTypePort; } else if (ArbiterType == PciArb_Memory) { /* Device RAM */ //DesiredType = CmResourceTypeMemory; } else { /* Ignore anything else */ continue; } /* Find an arbiter of this type */ Instance = PciFindNextSecondaryExtension(&DeviceExtension->SecondaryExtension, ArbiterType); if (Instance) { /* * Now we should initialize it, not yet implemented because Arb * library isn't yet implemented, not even the headers. */ UNIMPLEMENTED; //while (TRUE); } else { /* The arbiter was not found, this is an error! */ DPRINT1("PCI - FDO ext 0x%p %s arbiter (REQUIRED) is missing.\n", DeviceExtension, PciArbiterNames[ArbiterType - PciArb_Io]); } } /* Arbiters are now initialized */ DeviceExtension->ArbitersInitialized = TRUE; return STATUS_SUCCESS; }