Changeset 70115 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 13, 2017 4:12:33 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119664
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r70104 r70115 502 502 503 503 /** 504 * Global initialisation stuff (PnP + NT4 legacy). 505 * 506 * @param pDevObj Device object. 507 * @param pIrp Request packet. 508 */ 509 #ifndef TARGET_NT4 510 static NTSTATUS vgdrvNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp) 511 #else 512 static NTSTATUS vgdrvNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath) 513 #endif 514 { 515 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension; 516 #ifndef TARGET_NT4 517 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 518 LogFlowFunc(("ENTER: pDevObj=%p pIrp=%p\n", pDevObj, pIrp)); 519 #else 520 LogFlowFunc(("ENTER: pDrvObj=%p pDevObj=%p pRegPath=%p\n", pDrvObj, pDevObj, pRegPath)); 521 #endif 504 * Global initialization stuff. 505 * 506 * @param pDevExt Our device extension data. 507 * @param pDevObj The device object. 508 * @param pIrp The request packet if NT5+, NULL for NT4 and earlier. 509 * @param pDrvObj The driver object for NT4, NULL for NT5+. 510 * @param pRegPath The registry path for NT4, NULL for NT5+. 511 */ 512 static NTSTATUS vgdrvNtInit(PVBOXGUESTDEVEXTWIN pDevExt, PDEVICE_OBJECT pDevObj, 513 PIRP pIrp, PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath) 514 { 515 LogFlowFunc(("ENTER: pDevExt=%p pDevObj=%p pIrq=%p pDrvObj=%p pRegPath=%p\n", pDevExt, pDevObj, pIrp, pDrvObj, pRegPath)); 522 516 523 517 NTSTATUS rcNt; 524 #ifdef TARGET_NT4 525 /* 526 * Let's have a look at what our PCI adapter offers. 527 */ 528 LogFlowFunc(("Starting to scan PCI resources of VBoxGuest ...\n")); 529 530 /* Assign the PCI resources. */ 531 PCM_RESOURCE_LIST pResourceList = NULL; 532 UNICODE_STRING classNameString; 533 RtlInitUnicodeString(&classNameString, L"VBoxGuestAdapter"); 534 rcNt = HalAssignSlotResources(pRegPath, &classNameString, pDrvObj, pDevObj, 535 PCIBus, pDevExt->uBus, pDevExt->uSlot, &pResourceList); 518 if (!pIrp) 519 { 520 #if ARCH_BITS == 32 521 /* 522 * NT4: Let's have a look at what our PCI adapter offers. 523 */ 524 LogFlowFunc(("Starting to scan PCI resources of VBoxGuest ...\n")); 525 526 /* Assign the PCI resources. */ 527 UNICODE_STRING ClassName; 528 RtlInitUnicodeString(&ClassName, L"VBoxGuestAdapter"); 529 PCM_RESOURCE_LIST pResourceList = NULL; 530 rcNt = HalAssignSlotResources(pRegPath, &ClassName, pDrvObj, pDevObj, 531 PCIBus, pDevExt->uBus, pDevExt->uSlot, &pResourceList); 536 532 # ifdef LOG_ENABLED 537 if (pResourceList && pResourceList->Count > 0)538 vgdrvNtShowDeviceResources(&pResourceList->List[0].PartialResourceList);533 if (pResourceList && pResourceList->Count > 0) 534 vgdrvNtShowDeviceResources(&pResourceList->List[0].PartialResourceList); 539 535 # endif 540 if (NT_SUCCESS(rcNt)) 541 rcNt = vgdrvNtScanPCIResourceList(pResourceList, pDevExt); 542 #else 536 if (NT_SUCCESS(rcNt)) 537 rcNt = vgdrvNtScanPCIResourceList(pResourceList, pDevExt); 538 # else /* ARCH_BITS != 32 */ 539 RT_NOREF(pDrvObj, pRegPath); 540 rcNt = STATUS_INTERNAL_ERROR; 541 # endif /* ARCH_BITS != 32 */ 542 } 543 else 544 { 545 /* 546 * NT5+: Scan the PCI resource list from the IRP. 547 */ 548 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 543 549 # ifdef LOG_ENABLED 544 if (pStack->Parameters.StartDevice.AllocatedResources->Count > 0)545 vgdrvNtShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);550 if (pStack->Parameters.StartDevice.AllocatedResources->Count > 0) 551 vgdrvNtShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList); 546 552 # endif 547 rcNt = vgdrvNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt);548 #endif 553 rcNt = vgdrvNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt); 554 } 549 555 if (NT_SUCCESS(rcNt)) 550 556 { … … 599 605 */ 600 606 LogFlowFunc(("Initializing DPC/ISR (pDevObj=%p)...\n", pDevExt->pDeviceObject)); 601 602 607 IoInitializeDpcRequest(pDevExt->pDeviceObject, vgdrvNtDpcHandler); 603 #ifdef TARGET_NT4 604 ULONG uInterruptVector = UINT32_MAX; 605 KIRQL irqLevel = UINT8_MAX; 606 /* Get an interrupt vector. */ 607 /* Only proceed if the device provides an interrupt. */ 608 if ( pDevExt->uInterruptLevel 609 || pDevExt->uInterruptVector) 610 { 611 LogFlowFunc(("Getting interrupt vector (HAL): Bus=%u, IRQL=%u, Vector=%u\n", 612 pDevExt->uBus, pDevExt->uInterruptLevel, pDevExt->uInterruptVector)); 613 614 uInterruptVector = HalGetInterruptVector(PCIBus, 615 pDevExt->uBus, 616 pDevExt->uInterruptLevel, 617 pDevExt->uInterruptVector, 618 &irqLevel, 619 &pDevExt->fInterruptAffinity); 620 LogFlowFunc(("HalGetInterruptVector returns vector=%u\n", uInterruptVector)); 621 if (uInterruptVector == 0) 622 LogFunc(("No interrupt vector found!\n")); 608 609 ULONG uInterruptVector = pDevExt->uInterruptVector; 610 KIRQL uHandlerIrql = (KIRQL)pDevExt->uInterruptLevel; 611 if (!pIrp) 612 { 613 #if ARCH_BITS == 32 614 /* NT4: Get an interrupt vector. Only proceed if the device provides an interrupt. */ 615 if ( uInterruptVector 616 || pDevExt->uInterruptLevel) 617 { 618 LogFlowFunc(("Getting interrupt vector (HAL): Bus=%u, IRQL=%u, Vector=%u\n", 619 pDevExt->uBus, pDevExt->uInterruptLevel, pDevExt->uInterruptVector)); 620 uInterruptVector = HalGetInterruptVector(PCIBus, 621 pDevExt->uBus, 622 pDevExt->uInterruptLevel, 623 pDevExt->uInterruptVector, 624 &uHandlerIrql, 625 &pDevExt->fInterruptAffinity); 626 LogFlowFunc(("HalGetInterruptVector returns vector=%u\n", uInterruptVector)); 627 } 628 else 629 LogFunc(("Device does not provide an interrupt!\n")); 630 #endif 623 631 } 624 else 625 LogFunc(("Device does not provide an interrupt!\n")); 626 #endif 627 if (pDevExt->uInterruptVector) 628 { 629 #ifdef TARGET_NT4 630 LogFlowFunc(("Connecting interrupt (IntVector=%#u), IrqLevel=%u) ...\n", uInterruptVector, irqLevel)); 631 #else 632 LogFlowFunc(("Connecting interrupt (IntVector=%#u), IrqLevel=%u) ...\n", pDevExt->uInterruptVector, pDevExt->uInterruptLevel)); 633 #endif 632 if (uInterruptVector) 633 { 634 LogFlowFunc(("Connecting interrupt (IntVector=%#u), uHandlerIrql=%u) ...\n", uInterruptVector, uHandlerIrql)); 634 635 635 636 rcNt = IoConnectInterrupt(&pDevExt->pInterruptObject, /* Out: interrupt object. */ 636 (PKSERVICE_ROUTINE)vgdrvNtIsrHandler,/* Our ISR handler. */637 vgdrvNtIsrHandler, /* Our ISR handler. */ 637 638 pDevExt, /* Device context. */ 638 639 NULL, /* Optional spinlock. */ 639 #ifdef TARGET_NT4640 640 uInterruptVector, /* Interrupt vector. */ 641 irqLevel, /* Interrupt level. */ 642 irqLevel, /* Interrupt level. */ 643 #else 644 pDevExt->uInterruptVector, /* Interrupt vector. */ 645 (KIRQL)pDevExt->uInterruptLevel, /* Interrupt level. */ 646 (KIRQL)pDevExt->uInterruptLevel, /* Interrupt level. */ 647 #endif 648 pDevExt->enmInterruptMode, /* LevelSensitive or Latched. */ 641 uHandlerIrql, /* Irql. */ 642 uHandlerIrql, /* SynchronizeIrql. */ 643 pDevExt->enmInterruptMode, /* LevelSensitive or Latched. */ 649 644 TRUE, /* Shareable interrupt. */ 650 pDevExt->fInterruptAffinity, 645 pDevExt->fInterruptAffinity, /* CPU affinity. */ 651 646 FALSE); /* Don't save FPU stack. */ 652 647 if (NT_ERROR(rcNt)) … … 699 694 * Find our virtual PCI device 700 695 */ 701 ULONG uuBusNumber;696 ULONG uBus; 702 697 PCI_SLOT_NUMBER uSlot; 703 NTSTATUS rc = vgdrvNt4FindPciDevice(&u uBusNumber, &uSlot);698 NTSTATUS rc = vgdrvNt4FindPciDevice(&uBus, &uSlot); 704 699 if (NT_ERROR(rc)) 705 700 { … … 711 706 * Create device. 712 707 */ 713 UNICODE_STRING szDevName;714 RtlInitUnicodeString(& szDevName, VBOXGUEST_DEVICE_NAME_NT);708 UNICODE_STRING DevName; 709 RtlInitUnicodeString(&DevName, VBOXGUEST_DEVICE_NAME_NT); 715 710 PDEVICE_OBJECT pDeviceObject = NULL; 716 rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), & szDevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject);711 rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), &DevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject); 717 712 if (NT_SUCCESS(rc)) 718 713 { … … 721 716 UNICODE_STRING DosName; 722 717 RtlInitUnicodeString(&DosName, VBOXGUEST_DEVICE_NAME_DOS); 723 rc = IoCreateSymbolicLink(&DosName, & szDevName);718 rc = IoCreateSymbolicLink(&DosName, &DevName); 724 719 if (NT_SUCCESS(rc)) 725 720 { … … 740 735 741 736 /* Store bus and slot number we've queried before. */ 742 pDevExt->uBus = u uBusNumber;737 pDevExt->uBus = uBus; 743 738 pDevExt->uSlot = uSlot.u.AsULONG; 744 739 745 # ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION740 # ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 746 741 rc = hlpRegisterBugCheckCallback(pDevExt); 747 #endif 748 749 /* Do the actual VBox init ... */ 742 # endif 750 743 if (NT_SUCCESS(rc)) 751 744 { 752 rc = vgdrvNtInit(pDrvObj, pDeviceObject, pRegPath); 745 /* Do the actual VBox init ... */ 746 rc = vgdrvNtInit(pDevExt, pDeviceObject, NULL /*pIrp*/, pDrvObj, pRegPath); 753 747 if (NT_SUCCESS(rc)) 754 748 { … … 1030 1024 1031 1025 if (pStack->Parameters.StartDevice.AllocatedResources) 1032 rc = vgdrvNtInit(pDev Obj, pIrp);1026 rc = vgdrvNtInit(pDevExt, pDevObj, pIrp, NULL, NULL); 1033 1027 else 1034 1028 { … … 1190 1184 Log(("vgdrvNtNt5PlusPnP: QUERY_STOP_DEVICE\n")); 1191 1185 1192 # ifdef VBOX_REBOOT_ON_UNINSTALL 1186 # ifdef VBOX_REBOOT_ON_UNINSTALL /** @todo r=bird: this code and log msg is pointless as rc = success and status will be overwritten below. */ 1193 1187 Log(("vgdrvNtNt5PlusPnP: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n")); 1194 1188 pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL; … … 1288 1282 case PowerDeviceD0: 1289 1283 break; 1290 default: /* Shut up MSC */ break; 1284 default: /* Shut up MSC */ 1285 break; 1291 1286 } 1292 1287 break; 1293 default: /* Shut up MSC */ break; 1288 default: /* Shut up MSC */ 1289 break; 1294 1290 } 1295 1291 break; … … 1924 1920 * @param pContext Context specific pointer. 1925 1921 */ 1926 static void vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext)1922 static void NTAPI vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext) 1927 1923 { 1928 1924 RT_NOREF3(pDPC, pIrp, pContext); … … 1957 1953 * @param pServiceContext Context specific pointer. 1958 1954 */ 1959 static BOOLEAN vgdrvNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)1955 static BOOLEAN NTAPI vgdrvNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext) 1960 1956 { 1961 1957 RT_NOREF1(pInterrupt);
Note:
See TracChangeset
for help on using the changeset viewer.