Changeset 70280 in vbox for trunk/src/VBox
- Timestamp:
- Dec 21, 2017 2:02:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r70279 r70280 80 80 VGDRVNTDEVSTATE_REMOVED 81 81 } VGDRVNTDEVSTATE; 82 83 84 typedef struct VBOXGUESTWINBASEADDRESS85 {86 /** Original device physical address. */87 PHYSICAL_ADDRESS RangeStart;88 /** Length of I/O or memory range. */89 ULONG RangeLength;90 /** Flag: Unmapped range is I/O or memory range. */91 BOOLEAN RangeInMemory;92 /** Mapped I/O or memory range. */93 PVOID MappedRangeStart;94 /** Flag: mapped range is I/O or memory range. */95 BOOLEAN MappedRangeInMemory;96 /** Flag: resource is mapped (i.e. MmMapIoSpace called). */97 BOOLEAN ResourceMapped;98 } VBOXGUESTWINBASEADDRESS;99 typedef VBOXGUESTWINBASEADDRESS *PVBOXGUESTWINBASEADDRESS;100 82 101 83 … … 127 109 /** LevelSensitive or Latched. */ 128 110 KINTERRUPT_MODE enmInterruptMode; 129 130 /** PCI base address information. */131 ULONG cPciAddresses;132 VBOXGUESTWINBASEADDRESS aPciBaseAddresses[PCI_TYPE0_ADDRESSES];133 111 134 112 /** Physical address and length of VMMDev memory. */ … … 536 514 static NTSTATUS vgdrvNtScanPCIResourceList(PVBOXGUESTDEVEXTWIN pDevExt, PCM_RESOURCE_LIST pResList, bool fTranslated) 537 515 { 538 /* Enumerate the resource list. */ 539 LogFlowFunc(("Found %d resources\n", 540 pResList->List->PartialResourceList.Count)); 541 542 NTSTATUS rc = STATUS_SUCCESS; 516 LogFlowFunc(("Found %d resources\n", pResList->List->PartialResourceList.Count)); 543 517 PCM_PARTIAL_RESOURCE_DESCRIPTOR pPartialData = NULL; 544 PVBOXGUESTWINBASEADDRESS pBaseAddress = pDevExt->aPciBaseAddresses; 545 uint32_t cBaseAddresses = 0; 546 bool fGotIrq = false; 547 bool fGotMmio = false; 548 bool fGotIoPorts = false; 518 bool fGotIrq = false; 519 bool fGotMmio = false; 520 bool fGotIoPorts = false; 521 NTSTATUS rc = STATUS_SUCCESS; 549 522 for (ULONG i = 0; i < pResList->List->PartialResourceList.Count; i++) 550 523 { … … 553 526 { 554 527 case CmResourceTypePort: 555 {556 528 LogFlowFunc(("I/O range: Base=%#RX64, length=%08x\n", 557 529 pPartialData->u.Port.Start.QuadPart, pPartialData->u.Port.Length)); 558 559 /* Overflow protection. */ 560 if (cBaseAddresses < PCI_TYPE0_ADDRESSES) 530 /* Save the first I/O port base. */ 531 if (!fGotIoPorts) 561 532 { 562 /* Save the first I/O port base. */ 563 if (!fGotIoPorts) 564 { 565 pDevExt->Core.IOPortBase = (RTIOPORT)pPartialData->u.Port.Start.LowPart; 566 fGotIoPorts = true; 567 } 568 else 569 LogRelFunc(("More than one I/O port range?!?\n")); 570 571 /* Save resource information. */ 572 pBaseAddress->RangeStart = pPartialData->u.Port.Start; 573 pBaseAddress->RangeLength = pPartialData->u.Port.Length; 574 pBaseAddress->RangeInMemory = FALSE; 575 pBaseAddress->ResourceMapped = FALSE; 576 533 pDevExt->Core.IOPortBase = (RTIOPORT)pPartialData->u.Port.Start.LowPart; 534 fGotIoPorts = true; 577 535 LogFunc(("I/O range for VMMDev found! Base=%#RX64, length=%08x\n", 578 536 pPartialData->u.Port.Start.QuadPart, pPartialData->u.Port.Length)); 579 580 /* Next item ... */581 pBaseAddress++;582 cBaseAddresses++;583 537 } 584 538 else 585 Log Func(("Too many PCI addresses!\n"));539 LogRelFunc(("More than one I/O port range?!?\n")); 586 540 break; 587 }588 541 589 542 case CmResourceTypeInterrupt: 590 {591 543 LogFunc(("Interrupt: Level=%x, vector=%x, mode=%x\n", 592 544 pPartialData->u.Interrupt.Level, pPartialData->u.Interrupt.Vector, pPartialData->Flags)); 593 594 545 if (!fGotIrq) 595 546 { … … 605 556 pDevExt->enmInterruptMode = LevelSensitive; 606 557 fGotIrq = true; 558 LogFunc(("Interrupt for VMMDev found! Vector=%#x Level=%#x Affinity=%zx Mode=%d\n", pDevExt->uInterruptVector, 559 pDevExt->uInterruptLevel, pDevExt->fInterruptAffinity, pDevExt->enmInterruptMode)); 607 560 } 608 561 else 609 562 LogFunc(("More than one IRQ resource!\n")); 610 563 break; 611 }612 564 613 565 case CmResourceTypeMemory: 614 {615 566 LogFlowFunc(("Memory range: Base=%#RX64, length=%08x\n", 616 567 pPartialData->u.Memory.Start.QuadPart, pPartialData->u.Memory.Length)); 617 618 /* Overflow protection. */619 if (cBaseAddresses < PCI_TYPE0_ADDRESSES)568 /* We only care about the first read/write memory range. */ 569 if ( !fGotMmio 570 && (pPartialData->Flags & CM_RESOURCE_MEMORY_WRITEABILITY_MASK) == CM_RESOURCE_MEMORY_READ_WRITE) 620 571 { 621 /* We only care about the first read/write memory range. */ 622 if ( !fGotMmio 623 && (pPartialData->Flags & CM_RESOURCE_MEMORY_WRITEABILITY_MASK) == CM_RESOURCE_MEMORY_READ_WRITE) 572 /* Save physical MMIO base + length for VMMDev. */ 573 pDevExt->uVmmDevMemoryPhysAddr = pPartialData->u.Memory.Start; 574 pDevExt->cbVmmDevMemory = (ULONG)pPartialData->u.Memory.Length; 575 576 if (!fTranslated) 624 577 { 625 /* Save physical MMIO base + length for VMMDev. */ 626 pDevExt->uVmmDevMemoryPhysAddr = pPartialData->u.Memory.Start; 627 pDevExt->cbVmmDevMemory = (ULONG)pPartialData->u.Memory.Length; 628 629 if (!fTranslated) 578 /* Technically we need to make the HAL translate the address. since we 579 didn't used to do this and it probably just returns the input address, 580 we allow ourselves to ignore failures. */ 581 ULONG uAddressSpace = 0; 582 PHYSICAL_ADDRESS PhysAddr = pPartialData->u.Memory.Start; 583 if (HalTranslateBusAddress(pResList->List->InterfaceType, pResList->List->BusNumber, PhysAddr, 584 &uAddressSpace, &PhysAddr)) 630 585 { 631 /* Technically we need to make the HAL translate the address. since we 632 didn't used to do this and it probably just returns the input address, 633 we allow ourselves to ignore failures. */ 634 ULONG uAddressSpace = 0; 635 PHYSICAL_ADDRESS PhysAddr = pPartialData->u.Memory.Start; 636 if (HalTranslateBusAddress(pResList->List->InterfaceType, pResList->List->BusNumber, PhysAddr, 637 &uAddressSpace, &PhysAddr)) 638 { 639 Log(("HalTranslateBusAddress(%#RX64) -> %RX64, type %#x\n", 640 pPartialData->u.Memory.Start.QuadPart, PhysAddr.QuadPart, uAddressSpace)); 641 if (pPartialData->u.Memory.Start.QuadPart != PhysAddr.QuadPart) 642 pDevExt->uVmmDevMemoryPhysAddr = PhysAddr; 643 } 644 else 645 Log(("HalTranslateBusAddress(%#RX64) -> failed!\n", pPartialData->u.Memory.Start.QuadPart)); 586 Log(("HalTranslateBusAddress(%#RX64) -> %RX64, type %#x\n", 587 pPartialData->u.Memory.Start.QuadPart, PhysAddr.QuadPart, uAddressSpace)); 588 if (pPartialData->u.Memory.Start.QuadPart != PhysAddr.QuadPart) 589 pDevExt->uVmmDevMemoryPhysAddr = PhysAddr; 646 590 } 647 648 /* Save resource information. */ 649 pBaseAddress->RangeStart = pPartialData->u.Memory.Start; 650 pBaseAddress->RangeLength = pPartialData->u.Memory.Length; 651 pBaseAddress->RangeInMemory = TRUE; 652 pBaseAddress->ResourceMapped = FALSE; 653 654 LogFunc(("Found memory range for VMMDev! Base = %#RX64, Length = %08x\n", 655 pPartialData->u.Memory.Start.QuadPart, pPartialData->u.Memory.Length)); 656 657 /* Next item ... */ 658 cBaseAddresses++; 659 pBaseAddress++; 660 fGotMmio = true; 591 else 592 Log(("HalTranslateBusAddress(%#RX64) -> failed!\n", pPartialData->u.Memory.Start.QuadPart)); 661 593 } 662 else 663 LogFunc(("Ignoring memory: Flags=%08x Base=%#RX64\n", 664 pPartialData->Flags, pPartialData->u.Memory.Start.QuadPart)); 594 595 fGotMmio = true; 596 LogFunc(("Found memory range for VMMDev! Base = %#RX64, Length = %08x\n", 597 pPartialData->u.Memory.Start.QuadPart, pPartialData->u.Memory.Length)); 665 598 } 666 599 else 667 LogFunc(("Too many PCI addresses!\n")); 600 LogFunc(("Ignoring memory: Flags=%08x Base=%#RX64\n", 601 pPartialData->Flags, pPartialData->u.Memory.Start.QuadPart)); 668 602 break; 669 }670 603 671 604 default: 672 {673 605 LogFunc(("Unhandled resource found, type=%d\n", pPartialData->Type)); 674 606 break; 675 }676 607 } 677 608 } 678 679 /* Memorize the number of resources found. */680 pDevExt->cPciAddresses = cBaseAddresses;681 609 return rc; 682 610 } … … 807 735 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 808 736 # ifdef LOG_ENABLED 809 vgdrvNtShowDeviceResources(pStack->Parameters.StartDevice.AllocatedResources );737 vgdrvNtShowDeviceResources(pStack->Parameters.StartDevice.AllocatedResourcesTranslated); 810 738 # endif 811 739 rcNt = vgdrvNtScanPCIResourceList(pDevExt, pStack->Parameters.StartDevice.AllocatedResourcesTranslated,
Note:
See TracChangeset
for help on using the changeset viewer.