Changeset 70104 in vbox for trunk/src/VBox
- Timestamp:
- Dec 13, 2017 10:22:57 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119652
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r70103 r70104 65 65 * Structures and Typedefs * 66 66 *********************************************************************************************************************************/ 67 /** Possible device states for our state machine. */ 67 /** 68 * Possible device states for our state machine. 69 */ 68 70 typedef enum VGDRVNTDEVSTATE 69 71 { … … 75 77 VGDRVNTDEVSTATE_REMOVED 76 78 } VGDRVNTDEVSTATE; 79 77 80 78 81 typedef struct VBOXGUESTWINBASEADDRESS … … 90 93 /** Flag: resource is mapped (i.e. MmMapIoSpace called). */ 91 94 BOOLEAN ResourceMapped; 92 } VBOXGUESTWINBASEADDRESS, *PVBOXGUESTWINBASEADDRESS; 93 94 95 /** Windows-specific device extension bits. */ 95 } VBOXGUESTWINBASEADDRESS; 96 typedef VBOXGUESTWINBASEADDRESS *PVBOXGUESTWINBASEADDRESS; 97 98 99 /** 100 * Subclassing the device extension for adding windows-specific bits. 101 */ 96 102 typedef struct VBOXGUESTDEVEXTWIN 97 103 { 98 VBOXGUESTDEVEXT Core; 104 /** The common device extension core. */ 105 VBOXGUESTDEVEXT Core; 99 106 100 107 /** Our functional driver object. */ 101 PDEVICE_OBJECT pDeviceObject;108 PDEVICE_OBJECT pDeviceObject; 102 109 /** Top of the stack. */ 103 PDEVICE_OBJECT pNextLowerDriver;110 PDEVICE_OBJECT pNextLowerDriver; 104 111 /** Currently active Irp. */ 105 IRP *pCurrentIrp;112 IRP *pCurrentIrp; 106 113 /** Interrupt object pointer. */ 107 PKINTERRUPT pInterruptObject;114 PKINTERRUPT pInterruptObject; 108 115 109 116 /** Bus number where the device is located. */ 110 ULONG busNumber;117 ULONG uBus; 111 118 /** Slot number where the device is located. */ 112 ULONG slotNumber;119 ULONG uSlot; 113 120 /** Device interrupt level. */ 114 ULONG interruptLevel;121 ULONG uInterruptLevel; 115 122 /** Device interrupt vector. */ 116 ULONG interruptVector;123 ULONG uInterruptVector; 117 124 /** Affinity mask. */ 118 KAFFINITY interruptAffinity;125 KAFFINITY fInterruptAffinity; 119 126 /** LevelSensitive or Latched. */ 120 KINTERRUPT_MODE interruptMode;127 KINTERRUPT_MODE enmInterruptMode; 121 128 122 129 /** PCI base address information. */ 123 ULONG pciAddressCount;124 VBOXGUESTWINBASEADDRESS pciBaseAddress[PCI_TYPE0_ADDRESSES];130 ULONG cPciAddresses; 131 VBOXGUESTWINBASEADDRESS aPciBaseAddresses[PCI_TYPE0_ADDRESSES]; 125 132 126 133 /** Physical address and length of VMMDev memory. */ 127 PHYSICAL_ADDRESS vmmDevPhysMemoryAddress; 128 ULONG vmmDevPhysMemoryLength; 134 PHYSICAL_ADDRESS uVmmDevMemoryPhysAddr; 135 /** Length of VMMDev memory. */ 136 ULONG cbVmmDevMemory; 129 137 130 138 /** Device state. */ 131 VGDRVNTDEVSTATE enmDevState;132 /** The previous device state. 133 VGDRVNTDEVSTATE enmPrevDevState;139 VGDRVNTDEVSTATE enmDevState; 140 /** The previous device state. */ 141 VGDRVNTDEVSTATE enmPrevDevState; 134 142 135 143 /** Last system power action set (see VBoxGuestPower). */ 136 POWER_ACTION LastSystemPowerAction;144 POWER_ACTION enmLastSystemPowerAction; 137 145 /** Preallocated generic request for shutdown. */ 138 146 VMMDevPowerStateRequest *pPowerStateRequest; 139 147 /** Preallocated VMMDevEvents for IRQ handler. */ 140 VMMDevEvents *pIrqAckEvents; 141 142 /** Pre-allocated kernel session data. This is needed 143 * for handling kernel IOCtls. */ 144 struct VBOXGUESTSESSION *pKernelSession; 148 VMMDevEvents *pIrqAckEvents; 145 149 146 150 /** Spinlock protecting MouseNotifyCallback. Required since the consumer is 147 151 * in a DPC callback and not the ISR. */ 148 KSPIN_LOCK MouseEventAccessLock; 149 } VBOXGUESTDEVEXTWIN, *PVBOXGUESTDEVEXTWIN; 152 KSPIN_LOCK MouseEventAccessSpinLock; 153 } VBOXGUESTDEVEXTWIN; 154 typedef VBOXGUESTDEVEXTWIN *PVBOXGUESTDEVEXTWIN; 150 155 151 156 … … 172 177 RT_C_DECLS_BEGIN 173 178 #ifdef TARGET_NT4 174 static NTSTATUS vgdrvNt4FindPciDevice(PULONG pul BusNumber, PPCI_SLOT_NUMBER pSlotNumber);179 static NTSTATUS vgdrvNt4FindPciDevice(PULONG puluBusNumber, PPCI_SLOT_NUMBER puSlotNumber); 175 180 static NTSTATUS vgdrvNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath); 176 181 #else … … 462 467 "CmResourceTypeDma", 463 468 "CmResourceTypeDeviceSpecific", 464 "CmResourceType BusNumber",469 "CmResourceTypeuBusNumber", 465 470 "CmResourceTypeDevicePrivate", 466 471 "CmResourceTypeAssignedResource", … … 528 533 RtlInitUnicodeString(&classNameString, L"VBoxGuestAdapter"); 529 534 rcNt = HalAssignSlotResources(pRegPath, &classNameString, pDrvObj, pDevObj, 530 PCIBus, pDevExt-> busNumber, pDevExt->slotNumber, &pResourceList);535 PCIBus, pDevExt->uBus, pDevExt->uSlot, &pResourceList); 531 536 # ifdef LOG_ENABLED 532 537 if (pResourceList && pResourceList->Count > 0) … … 551 556 uint32_t cbMMIO = 0; 552 557 rcNt = vgdrvNtMapVMMDevMemory(pDevExt, 553 pDevExt-> vmmDevPhysMemoryAddress,554 pDevExt-> vmmDevPhysMemoryLength,558 pDevExt->uVmmDevMemoryPhysAddr, 559 pDevExt->cbVmmDevMemory, 555 560 &pvMMIOBase, 556 561 &cbMMIO); … … 601 606 /* Get an interrupt vector. */ 602 607 /* Only proceed if the device provides an interrupt. */ 603 if ( pDevExt-> interruptLevel604 || pDevExt-> interruptVector)608 if ( pDevExt->uInterruptLevel 609 || pDevExt->uInterruptVector) 605 610 { 606 611 LogFlowFunc(("Getting interrupt vector (HAL): Bus=%u, IRQL=%u, Vector=%u\n", 607 pDevExt-> busNumber, pDevExt->interruptLevel, pDevExt->interruptVector));612 pDevExt->uBus, pDevExt->uInterruptLevel, pDevExt->uInterruptVector)); 608 613 609 614 uInterruptVector = HalGetInterruptVector(PCIBus, 610 pDevExt-> busNumber,611 pDevExt-> interruptLevel,612 pDevExt-> interruptVector,615 pDevExt->uBus, 616 pDevExt->uInterruptLevel, 617 pDevExt->uInterruptVector, 613 618 &irqLevel, 614 &pDevExt-> interruptAffinity);619 &pDevExt->fInterruptAffinity); 615 620 LogFlowFunc(("HalGetInterruptVector returns vector=%u\n", uInterruptVector)); 616 621 if (uInterruptVector == 0) … … 620 625 LogFunc(("Device does not provide an interrupt!\n")); 621 626 #endif 622 if (pDevExt-> interruptVector)627 if (pDevExt->uInterruptVector) 623 628 { 624 629 #ifdef TARGET_NT4 625 630 LogFlowFunc(("Connecting interrupt (IntVector=%#u), IrqLevel=%u) ...\n", uInterruptVector, irqLevel)); 626 631 #else 627 LogFlowFunc(("Connecting interrupt (IntVector=%#u), IrqLevel=%u) ...\n", pDevExt-> interruptVector, pDevExt->interruptLevel));632 LogFlowFunc(("Connecting interrupt (IntVector=%#u), IrqLevel=%u) ...\n", pDevExt->uInterruptVector, pDevExt->uInterruptLevel)); 628 633 #endif 629 634 … … 637 642 irqLevel, /* Interrupt level. */ 638 643 #else 639 pDevExt-> interruptVector, /* Interrupt vector. */640 (KIRQL)pDevExt-> interruptLevel, /* Interrupt level. */641 (KIRQL)pDevExt-> interruptLevel, /* Interrupt level. */644 pDevExt->uInterruptVector, /* Interrupt vector. */ 645 (KIRQL)pDevExt->uInterruptLevel, /* Interrupt level. */ 646 (KIRQL)pDevExt->uInterruptLevel, /* Interrupt level. */ 642 647 #endif 643 pDevExt-> interruptMode, /* LevelSensitive or Latched. */648 pDevExt->enmInterruptMode, /* LevelSensitive or Latched. */ 644 649 TRUE, /* Shareable interrupt. */ 645 pDevExt-> interruptAffinity, /* CPU affinity. */650 pDevExt->fInterruptAffinity, /* CPU affinity. */ 646 651 FALSE); /* Don't save FPU stack. */ 647 652 if (NT_ERROR(rcNt)) … … 694 699 * Find our virtual PCI device 695 700 */ 696 ULONG u BusNumber;697 PCI_SLOT_NUMBER SlotNumber;698 NTSTATUS rc = vgdrvNt4FindPciDevice(&u BusNumber, &SlotNumber);701 ULONG uuBusNumber; 702 PCI_SLOT_NUMBER uSlot; 703 NTSTATUS rc = vgdrvNt4FindPciDevice(&uuBusNumber, &uSlot); 699 704 if (NT_ERROR(rc)) 700 705 { … … 735 740 736 741 /* Store bus and slot number we've queried before. */ 737 pDevExt-> busNumber =uBusNumber;738 pDevExt-> slotNumber = SlotNumber.u.AsULONG;742 pDevExt->uBus = uuBusNumber; 743 pDevExt->uSlot = uSlot.u.AsULONG; 739 744 740 745 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION … … 772 777 * @returns NT status code. 773 778 * 774 * @param pul BusNumber Where to return the bus number on success.775 * @param p SlotNumber Where to return the slot number on success.776 */ 777 static NTSTATUS vgdrvNt4FindPciDevice(PULONG pul BusNumber, PPCI_SLOT_NUMBER pSlotNumber)779 * @param puluBusNumber Where to return the bus number on success. 780 * @param puSlotNumber Where to return the slot number on success. 781 */ 782 static NTSTATUS vgdrvNt4FindPciDevice(PULONG puluBusNumber, PPCI_SLOT_NUMBER puSlotNumber) 778 783 { 779 784 Log(("vgdrvNt4FindPciDevice\n")); 780 785 781 PCI_SLOT_NUMBER SlotNumber;782 SlotNumber.u.AsULONG = 0;786 PCI_SLOT_NUMBER uSlot; 787 uSlot.u.AsULONG = 0; 783 788 784 789 /* Scan each bus. */ 785 for (ULONG ul BusNumber = 0; ulBusNumber < PCI_MAX_BUSES; ulBusNumber++)790 for (ULONG uluBusNumber = 0; uluBusNumber < PCI_MAX_BUSES; uluBusNumber++) 786 791 { 787 792 /* Scan each device. */ 788 793 for (ULONG deviceNumber = 0; deviceNumber < PCI_MAX_DEVICES; deviceNumber++) 789 794 { 790 SlotNumber.u.bits.DeviceNumber = deviceNumber;795 uSlot.u.bits.DeviceNumber = deviceNumber; 791 796 792 797 /* Scan each function (not really required...). */ 793 798 for (ULONG functionNumber = 0; functionNumber < PCI_MAX_FUNCTION; functionNumber++) 794 799 { 795 SlotNumber.u.bits.FunctionNumber = functionNumber;800 uSlot.u.bits.FunctionNumber = functionNumber; 796 801 797 802 /* Have a look at what's in this slot. */ 798 803 PCI_COMMON_CONFIG PciData; 799 if (!HalGetBusData(PCIConfiguration, ul BusNumber, SlotNumber.u.AsULONG, &PciData, sizeof(ULONG)))804 if (!HalGetBusData(PCIConfiguration, uluBusNumber, uSlot.u.AsULONG, &PciData, sizeof(ULONG))) 800 805 { 801 806 /* No such bus, we're done with it. */ … … 816 821 Log(("vgdrvNt4FindPciDevice: Device found!\n")); 817 822 818 *pul BusNumber = ulBusNumber;819 *p SlotNumber = SlotNumber;823 *puluBusNumber = uluBusNumber; 824 *puSlotNumber = uSlot; 820 825 return STATUS_SUCCESS; 821 826 } … … 865 870 RT_ZERO(*pDevExt); 866 871 867 KeInitializeSpinLock(&pDevExt->MouseEventAccess Lock);872 KeInitializeSpinLock(&pDevExt->MouseEventAccessSpinLock); 868 873 869 874 pDevExt->pDeviceObject = pDeviceObject; … … 1337 1342 { 1338 1343 if ( pDevExt 1339 && pDevExt-> LastSystemPowerAction == PowerActionHibernate)1344 && pDevExt->enmLastSystemPowerAction == PowerActionHibernate) 1340 1345 { 1341 1346 Log(("vgdrvNtNt5PlusPower: Returning from hibernation!\n")); … … 1421 1426 */ 1422 1427 if (pDevExt) 1423 pDevExt-> LastSystemPowerAction = enmPowerAction;1428 pDevExt->enmLastSystemPowerAction = enmPowerAction; 1424 1429 1425 1430 break; … … 1487 1492 if (pDevExt->Core.pVMMDevMemory) 1488 1493 { 1489 MmUnmapIoSpace((void*)pDevExt->Core.pVMMDevMemory, pDevExt-> vmmDevPhysMemoryLength);1494 MmUnmapIoSpace((void*)pDevExt->Core.pVMMDevMemory, pDevExt->cbVmmDevMemory); 1490 1495 pDevExt->Core.pVMMDevMemory = NULL; 1491 1496 } 1492 1497 1493 pDevExt-> vmmDevPhysMemoryAddress.QuadPart = 0;1494 pDevExt-> vmmDevPhysMemoryLength= 0;1498 pDevExt->uVmmDevMemoryPhysAddr.QuadPart = 0; 1499 pDevExt->cbVmmDevMemory = 0; 1495 1500 } 1496 1501 … … 1516 1521 if (pDevExt) 1517 1522 { 1518 1519 #if 0 /** @todo test & enable cleaning global session data */1520 #ifdef VBOX_WITH_HGCM1521 if (pDevExt->pKernelSession)1522 {1523 VGDrvCommonCloseSession(pDevExt, pDevExt->pKernelSession);1524 pDevExt->pKernelSession = NULL;1525 }1526 #endif1527 #endif1528 1529 1523 if (pDevExt->pInterruptObject) 1530 1524 { … … 1914 1908 /* we need a lock here to avoid concurrency with the set event functionality */ 1915 1909 KIRQL OldIrql; 1916 KeAcquireSpinLock(&pDevExtWin->MouseEventAccess Lock, &OldIrql);1910 KeAcquireSpinLock(&pDevExtWin->MouseEventAccessSpinLock, &OldIrql); 1917 1911 pDevExtWin->Core.pfnMouseNotifyCallback = pNotify->u.In.pfnNotify; 1918 1912 pDevExtWin->Core.pvMouseNotifyCallbackArg = pNotify->u.In.pvUser; 1919 KeReleaseSpinLock(&pDevExtWin->MouseEventAccess Lock, OldIrql);1913 KeReleaseSpinLock(&pDevExtWin->MouseEventAccessSpinLock, OldIrql); 1920 1914 return VINF_SUCCESS; 1921 1915 } … … 1942 1936 * i.e. to prevent the event from destroyed while we're using it */ 1943 1937 Assert(KeGetCurrentIrql() == DISPATCH_LEVEL); 1944 KeAcquireSpinLockAtDpcLevel(&pDevExt->MouseEventAccess Lock);1938 KeAcquireSpinLockAtDpcLevel(&pDevExt->MouseEventAccessSpinLock); 1945 1939 1946 1940 if (pDevExt->Core.pfnMouseNotifyCallback) 1947 1941 pDevExt->Core.pfnMouseNotifyCallback(pDevExt->Core.pvMouseNotifyCallbackArg); 1948 1942 1949 KeReleaseSpinLockFromDpcLevel(&pDevExt->MouseEventAccess Lock);1943 KeReleaseSpinLockFromDpcLevel(&pDevExt->MouseEventAccessSpinLock); 1950 1944 } 1951 1945 … … 2219 2213 ULONG rangeCount = 0; 2220 2214 ULONG cMMIORange = 0; 2221 PVBOXGUESTWINBASEADDRESS pBaseAddress = pDevExt-> pciBaseAddress;2215 PVBOXGUESTWINBASEADDRESS pBaseAddress = pDevExt->aPciBaseAddresses; 2222 2216 for (ULONG i = 0; i < pResList->List->PartialResourceList.Count; i++) 2223 2217 { … … 2265 2259 2266 2260 /* Save information. */ 2267 pDevExt-> interruptLevel = pPartialData->u.Interrupt.Level;2268 pDevExt-> interruptVector = pPartialData->u.Interrupt.Vector;2269 pDevExt-> interruptAffinity = pPartialData->u.Interrupt.Affinity;2261 pDevExt->uInterruptLevel = pPartialData->u.Interrupt.Level; 2262 pDevExt->uInterruptVector = pPartialData->u.Interrupt.Vector; 2263 pDevExt->fInterruptAffinity = pPartialData->u.Interrupt.Affinity; 2270 2264 2271 2265 /* Check interrupt mode. */ 2272 2266 if (pPartialData->Flags & CM_RESOURCE_INTERRUPT_LATCHED) 2273 pDevExt-> interruptMode = Latched;2267 pDevExt->enmInterruptMode = Latched; 2274 2268 else 2275 pDevExt-> interruptMode = LevelSensitive;2269 pDevExt->enmInterruptMode = LevelSensitive; 2276 2270 break; 2277 2271 } … … 2293 2287 { 2294 2288 /* Save physical MMIO base + length for VMMDev. */ 2295 pDevExt-> vmmDevPhysMemoryAddress= pPartialData->u.Memory.Start;2296 pDevExt-> vmmDevPhysMemoryLength= (ULONG)pPartialData->u.Memory.Length;2289 pDevExt->uVmmDevMemoryPhysAddr = pPartialData->u.Memory.Start; 2290 pDevExt->cbVmmDevMemory = (ULONG)pPartialData->u.Memory.Length; 2297 2291 2298 2292 /* Save resource information. */ … … 2325 2319 2326 2320 /* Memorize the number of resources found. */ 2327 pDevExt-> pciAddressCount= rangeCount;2321 pDevExt->cPciAddresses = rangeCount; 2328 2322 return rc; 2329 2323 }
Note:
See TracChangeset
for help on using the changeset viewer.