Changeset 70220 in vbox for trunk/src/VBox
- Timestamp:
- Dec 19, 2017 11:33:36 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r70219 r70220 574 574 * and init the common device extension bits. 575 575 */ 576 void *pvMMIOBase = NULL;577 uint32_t cbMMIO = 0;576 void *pvMMIOBase = NULL; 577 uint32_t cbMMIO = 0; 578 578 rcNt = vgdrvNtMapVMMDevMemory(pDevExt, 579 579 pDevExt->uVmmDevMemoryPhysAddr, … … 593 593 vgdrvNtVersionToOSType(g_enmVGDrvNtVer), 594 594 VMMDEV_EVENT_MOUSE_POSITION_CHANGED); 595 if (RT_FAILURE(vrc)) 595 if (RT_SUCCESS(vrc)) 596 { 597 vrc = VbglR0GRAlloc((VMMDevRequestHeader **)&pDevExt->pPowerStateRequest, 598 sizeof(VMMDevPowerStateRequest), VMMDevReq_SetPowerStatus); 599 if (RT_SUCCESS(vrc)) 600 { 601 /* 602 * Register DPC and ISR. 603 */ 604 LogFlowFunc(("Initializing DPC/ISR (pDevObj=%p)...\n", pDevExt->pDeviceObject)); 605 IoInitializeDpcRequest(pDevExt->pDeviceObject, vgdrvNtDpcHandler); 606 607 ULONG uInterruptVector = pDevExt->uInterruptVector; 608 KIRQL uHandlerIrql = (KIRQL)pDevExt->uInterruptLevel; 609 #ifdef TARGET_NT4 610 if (!pIrp) 611 { 612 /* NT4: Get an interrupt vector. Only proceed if the device provides an interrupt. */ 613 if ( uInterruptVector 614 || pDevExt->uInterruptLevel) 615 { 616 LogFlowFunc(("Getting interrupt vector (HAL): Bus=%u, IRQL=%u, Vector=%u\n", 617 pDevExt->uBus, pDevExt->uInterruptLevel, pDevExt->uInterruptVector)); 618 uInterruptVector = HalGetInterruptVector(PCIBus, 619 pDevExt->uBus, 620 pDevExt->uInterruptLevel, 621 pDevExt->uInterruptVector, 622 &uHandlerIrql, 623 &pDevExt->fInterruptAffinity); 624 LogFlowFunc(("HalGetInterruptVector returns vector=%u\n", uInterruptVector)); 625 } 626 else 627 LogFunc(("Device does not provide an interrupt!\n")); 628 } 629 #endif 630 if (uInterruptVector) 631 { 632 LogFlowFunc(("Connecting interrupt (IntVector=%#u), uHandlerIrql=%u) ...\n", 633 uInterruptVector, uHandlerIrql)); 634 635 rcNt = IoConnectInterrupt(&pDevExt->pInterruptObject, /* Out: interrupt object. */ 636 vgdrvNtIsrHandler, /* Our ISR handler. */ 637 pDevExt, /* Device context. */ 638 NULL, /* Optional spinlock. */ 639 uInterruptVector, /* Interrupt vector. */ 640 uHandlerIrql, /* Irql. */ 641 uHandlerIrql, /* SynchronizeIrql. */ 642 pDevExt->enmInterruptMode, /* LevelSensitive or Latched. */ 643 TRUE, /* Shareable interrupt. */ 644 pDevExt->fInterruptAffinity, /* CPU affinity. */ 645 FALSE); /* Don't save FPU stack. */ 646 if (NT_ERROR(rcNt)) 647 LogFunc(("Could not connect interrupt: rcNt=%#x!\n", rcNt)); 648 } 649 else 650 LogFunc(("No interrupt vector found!\n")); 651 if (NT_SUCCESS(rcNt)) 652 { 653 /* 654 * Once we've read configuration from register and host, we're finally read. 655 */ 656 /** @todo clean up guest ring-3 logging, keeping it separate from the kernel to avoid sharing limits with it. */ 657 pDevExt->Core.fLoggingEnabled = true; 658 vgdrvNtReadConfiguration(pDevExt); 659 660 /* Ready to rumble! */ 661 LogRelFunc(("Device is ready!\n")); 662 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_WORKING); 663 return STATUS_SUCCESS; 664 } 665 pDevExt->pInterruptObject = NULL; 666 667 VbglR0GRFree(&pDevExt->pPowerStateRequest->header); 668 pDevExt->pPowerStateRequest = NULL; 669 } 670 else 671 { 672 LogFunc(("Alloc for pPowerStateRequest failed, vrc=%Rrc\n", vrc)); 673 rcNt = STATUS_UNSUCCESSFUL; 674 } 675 676 VGDrvCommonDeleteDevExt(&pDevExt->Core); 677 } 678 else 596 679 { 597 680 LogFunc(("Could not init device extension, vrc=%Rrc\n", vrc)); 598 681 rcNt = STATUS_DEVICE_CONFIGURATION_ERROR; 599 682 } 683 vgdrvNtUnmapVMMDevMemory(pDevExt); 600 684 } 601 685 else 602 686 LogFunc(("Could not map physical address of VMMDev, rcNt=%#x\n", rcNt)); 603 687 } 604 605 if (NT_SUCCESS(rcNt))606 {607 int vrc = VbglR0GRAlloc((VMMDevRequestHeader **)&pDevExt->pPowerStateRequest,608 sizeof(VMMDevPowerStateRequest), VMMDevReq_SetPowerStatus);609 if (RT_FAILURE(vrc))610 {611 LogFunc(("Alloc for pPowerStateRequest failed, vrc=%Rrc\n", vrc));612 rcNt = STATUS_UNSUCCESSFUL;613 }614 }615 616 if (NT_SUCCESS(rcNt))617 {618 /*619 * Register DPC and ISR.620 */621 LogFlowFunc(("Initializing DPC/ISR (pDevObj=%p)...\n", pDevExt->pDeviceObject));622 IoInitializeDpcRequest(pDevExt->pDeviceObject, vgdrvNtDpcHandler);623 624 ULONG uInterruptVector = pDevExt->uInterruptVector;625 KIRQL uHandlerIrql = (KIRQL)pDevExt->uInterruptLevel;626 #ifdef TARGET_NT4627 if (!pIrp)628 {629 /* NT4: Get an interrupt vector. Only proceed if the device provides an interrupt. */630 if ( uInterruptVector631 || pDevExt->uInterruptLevel)632 {633 LogFlowFunc(("Getting interrupt vector (HAL): Bus=%u, IRQL=%u, Vector=%u\n",634 pDevExt->uBus, pDevExt->uInterruptLevel, pDevExt->uInterruptVector));635 uInterruptVector = HalGetInterruptVector(PCIBus,636 pDevExt->uBus,637 pDevExt->uInterruptLevel,638 pDevExt->uInterruptVector,639 &uHandlerIrql,640 &pDevExt->fInterruptAffinity);641 LogFlowFunc(("HalGetInterruptVector returns vector=%u\n", uInterruptVector));642 }643 else644 LogFunc(("Device does not provide an interrupt!\n"));645 }646 #endif647 if (uInterruptVector)648 {649 LogFlowFunc(("Connecting interrupt (IntVector=%#u), uHandlerIrql=%u) ...\n", uInterruptVector, uHandlerIrql));650 651 rcNt = IoConnectInterrupt(&pDevExt->pInterruptObject, /* Out: interrupt object. */652 vgdrvNtIsrHandler, /* Our ISR handler. */653 pDevExt, /* Device context. */654 NULL, /* Optional spinlock. */655 uInterruptVector, /* Interrupt vector. */656 uHandlerIrql, /* Irql. */657 uHandlerIrql, /* SynchronizeIrql. */658 pDevExt->enmInterruptMode, /* LevelSensitive or Latched. */659 TRUE, /* Shareable interrupt. */660 pDevExt->fInterruptAffinity, /* CPU affinity. */661 FALSE); /* Don't save FPU stack. */662 if (NT_ERROR(rcNt))663 LogFunc(("Could not connect interrupt: rcNt=%#x!\n", rcNt));664 }665 else666 LogFunc(("No interrupt vector found!\n"));667 }668 669 if (NT_SUCCESS(rcNt))670 {671 /*672 * Once we've read configuration from register and host, we're finally read.673 */674 pDevExt->Core.fLoggingEnabled = true; /** @todo clean up guest ring-3 logging, keeping it separate from the kernel to avoid sharing limits with it. */675 vgdrvNtReadConfiguration(pDevExt);676 677 /* Ready to rumble! */678 LogRelFunc(("Device is ready!\n"));679 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_WORKING);680 }681 else682 pDevExt->pInterruptObject = NULL;683 684 /** @todo r=bird: The error cleanup here is completely missing. We'll leak a685 * whole bunch of things... */686 688 687 689 LogFunc(("Returned with rcNt=%#x\n", rcNt)); … … 854 856 static NTSTATUS vgdrvNtNt5PlusAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj) 855 857 { 856 NTSTATUS rc;857 858 LogFlowFuncEnter(); 858 859 … … 863 864 RtlInitUnicodeString(&DevName, VBOXGUEST_DEVICE_NAME_NT); 864 865 PDEVICE_OBJECT pDeviceObject = NULL; 865 rc= IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), &DevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject);866 if (NT_SUCCESS(rc ))866 NTSTATUS rcNt = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), &DevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject); 867 if (NT_SUCCESS(rcNt)) 867 868 { 868 869 /* … … 871 872 UNICODE_STRING DosName; 872 873 RtlInitUnicodeString(&DosName, VBOXGUEST_DEVICE_NAME_DOS); 873 rc = IoCreateSymbolicLink(&DosName, &DevName);874 if (NT_SUCCESS(rc ))874 rcNt = IoCreateSymbolicLink(&DosName, &DevName); 875 if (NT_SUCCESS(rcNt)) 875 876 { 876 877 /* … … 896 897 vgdrvNtBugCheckCallback(pDevExt); /* Ignore failure! */ 897 898 #endif 898 if (NT_SUCCESS(rc ))899 if (NT_SUCCESS(rcNt)) 899 900 { 900 /* VBoxGuestPower is pageable; ensure we are not called at elevated IRQL*/901 /* Ensure we are not called at elevated IRQL, even if our code isn't pagable any more. */ 901 902 pDeviceObject->Flags |= DO_POWER_PAGABLE; 902 903 903 904 /* Driver is ready now. */ 904 905 pDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; 905 LogFlowFunc(("Returning with rc =%#x (success)\n", rc));906 return rc ;906 LogFlowFunc(("Returning with rcNt=%#x (success)\n", rcNt)); 907 return rcNt; 907 908 } 908 909 … … 912 913 { 913 914 LogFunc(("IoAttachDeviceToDeviceStack did not give a nextLowerDriver!\n")); 914 rc = STATUS_DEVICE_NOT_CONNECTED;915 rcNt = STATUS_DEVICE_NOT_CONNECTED; 915 916 } 916 917 … … 919 920 } 920 921 else 921 LogFunc(("IoCreateSymbolicLink failed with rc =%#x!\n", rc));922 LogFunc(("IoCreateSymbolicLink failed with rcNt=%#x!\n", rcNt)); 922 923 IoDeleteDevice(pDeviceObject); 923 924 } 924 925 else 925 LogFunc(("IoCreateDevice failed with rc=%#x!\n", rc)); 926 927 LogFunc(("Returning with rc=%#x\n", rc)); 928 return rc; 929 } 926 LogFunc(("IoCreateDevice failed with rcNt=%#x!\n", rcNt)); 927 928 LogFunc(("Returning with rcNt=%#x\n", rcNt)); 929 return rcNt; 930 } 931 930 932 931 933 /** … … 962 964 IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vgdrvNt5PlusPnpIrpComplete, &Event, TRUE, TRUE, TRUE); 963 965 964 NTSTATUS rc = IoCallDriver(pDevObj, pIrp); 965 966 if (rc == STATUS_PENDING) 966 NTSTATUS rcNt = IoCallDriver(pDevObj, pIrp); 967 if (rcNt == STATUS_PENDING) 967 968 { 968 969 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); 969 rc = pIrp->IoStatus.Status;970 rcNt = pIrp->IoStatus.Status; 970 971 } 971 972 972 973 if ( !fStrict 973 && (rc == STATUS_NOT_SUPPORTED || rc== STATUS_INVALID_DEVICE_REQUEST))974 { 975 rc = STATUS_SUCCESS;976 } 977 978 Log(("vgdrvNt5PlusPnPSendIrpSynchronously: Returning 0x%x\n", rc));979 return rc ;974 && (rcNt == STATUS_NOT_SUPPORTED || rcNt == STATUS_INVALID_DEVICE_REQUEST)) 975 { 976 rcNt = STATUS_SUCCESS; 977 } 978 979 Log(("vgdrvNt5PlusPnPSendIrpSynchronously: Returning %#x\n", rcNt)); 980 return rcNt; 980 981 } 981 982 … … 1048 1049 } 1049 1050 } 1050 1051 1051 if (NT_ERROR(rc)) 1052 {1053 1052 Log(("vgdrvNtNt5PlusPnP: START_DEVICE: Error: rc = 0x%x\n", rc)); 1054 1055 /* Need to unmap memory in case of errors ... */1056 /** @todo r=bird: vgdrvNtInit maps it and is responsible for cleaning up its own friggin mess...1057 * Fix it instead of kind of working around things there!! */1058 vgdrvNtUnmapVMMDevMemory(pDevExt);1059 }1060 1053 break; 1061 1054 }
Note:
See TracChangeset
for help on using the changeset viewer.