- Timestamp:
- Nov 1, 2019 8:47:17 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/VMMDev
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
r81571 r81625 105 105 #ifndef IN_RC 106 106 # include <iprt/mem.h> 107 # include <iprt/memsafer.h> 107 108 #endif 108 109 #ifdef IN_RING3 … … 233 234 * Sets the IRQ (raise it or lower it) for 1.03 additions. 234 235 * 235 * @param pThis The VMMDev state. 236 * @param pDevIns The device instance. 237 * @param pThis The VMMDev shared instance data. 238 * @param pThisCC The VMMDev ring-3 instance data. 236 239 * @thread Any. 237 240 * @remarks Must be called owning the critical section. 238 241 */ 239 static void vmmdevSetIRQ_Legacy(P VMMDEV pThis)242 static void vmmdevSetIRQ_Legacy(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC) 240 243 { 241 244 if (pThis->fu32AdditionsOk) 242 245 { 243 246 /* Filter unsupported events */ 244 uint32_t fEvents = pThis->fHostEventFlags & pThis ->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask;247 uint32_t fEvents = pThis->fHostEventFlags & pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask; 245 248 246 249 Log(("vmmdevSetIRQ: fEvents=%#010x, fHostEventFlags=%#010x, u32GuestEventMask=%#010x.\n", 247 fEvents, pThis->fHostEventFlags, pThis ->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask));250 fEvents, pThis->fHostEventFlags, pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32GuestEventMask)); 248 251 249 252 /* Move event flags to VMMDev RAM */ 250 pThis ->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32HostEvents = fEvents;253 pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_03.u32HostEvents = fEvents; 251 254 252 255 uint32_t uIRQLevel = 0; … … 261 264 /* Set IRQ level for pin 0 (see NoWait comment in vmmdevMaybeSetIRQ). */ 262 265 /** @todo make IRQ pin configurable, at least a symbolic constant */ 263 PDMDevHlpPCISetIrqNoWait(p This->CTX_SUFF(pDevIns), 0, uIRQLevel);266 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, uIRQLevel); 264 267 Log(("vmmdevSetIRQ: IRQ set %d\n", uIRQLevel)); 265 268 } … … 272 275 * Sets the IRQ if there are events to be delivered. 273 276 * 274 * @param pThis The VMMDev state. 277 * @param pDevIns The device instance. 278 * @param pThis The VMMDev shared instance data. 279 * @param pThisCC The VMMDev ring-3 instance data. 275 280 * @thread Any. 276 281 * @remarks Must be called owning the critical section. 277 282 */ 278 static void vmmdevMaybeSetIRQ(P VMMDEV pThis)283 static void vmmdevMaybeSetIRQ(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC) 279 284 { 280 285 Log3(("vmmdevMaybeSetIRQ: fHostEventFlags=%#010x, fGuestFilterMask=%#010x.\n", … … 288 293 * which has already happened. 289 294 */ 290 pThis ->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;291 PDMDevHlpPCISetIrqNoWait(p This->pDevInsR3, 0, 1);295 pThisCC->pVMMDevRAMR3->V.V1_04.fHaveEvents = true; 296 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 1); 292 297 Log3(("vmmdevMaybeSetIRQ: IRQ set.\n")); 293 298 } … … 297 302 * Notifies the guest about new events (@a fAddEvents). 298 303 * 299 * @param pThis The VMMDev state. 304 * @param pDevIns The device instance. 305 * @param pThis The VMMDev shared instance data. 306 * @param pThisCC The VMMDev ring-3 instance data. 300 307 * @param fAddEvents New events to add. 301 308 * @thread Any. 302 309 * @remarks Must be called owning the critical section. 303 310 */ 304 static void vmmdevNotifyGuestWorker(P VMMDEV pThis, uint32_t fAddEvents)311 static void vmmdevNotifyGuestWorker(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents) 305 312 { 306 313 Log3(("vmmdevNotifyGuestWorker: fAddEvents=%#010x.\n", fAddEvents)); … … 321 328 322 329 if (!fHadEvents) 323 vmmdevMaybeSetIRQ(p This);330 vmmdevMaybeSetIRQ(pDevIns, pThis, pThisCC); 324 331 } 325 332 else … … 334 341 335 342 pThis->fHostEventFlags |= fAddEvents; 336 vmmdevSetIRQ_Legacy(p This);343 vmmdevSetIRQ_Legacy(pDevIns, pThis, pThisCC); 337 344 } 338 345 } … … 347 354 * This is used by VMMDev.cpp as well as VMMDevHGCM.cpp. 348 355 * 349 * @param pThis The VMMDev state. 356 * @param pDevIns The device instance. 357 * @param pThis The VMMDev shared instance data. 358 * @param pThisCC The VMMDev ring-3 instance data. 350 359 * @param fAddEvents New events to add. 351 360 * @thread Any. 352 361 */ 353 void VMMDevNotifyGuest(P VMMDEV pThis, uint32_t fAddEvents)362 void VMMDevNotifyGuest(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents) 354 363 { 355 364 Log3(("VMMDevNotifyGuest: fAddEvents=%#010x\n", fAddEvents)); … … 358 367 * Only notify the VM when it's running. 359 368 */ 360 VMSTATE enmVMState = PDMDevHlpVMState(p This->pDevInsR3);369 VMSTATE enmVMState = PDMDevHlpVMState(pDevIns); 361 370 if ( enmVMState == VMSTATE_RUNNING 362 371 || enmVMState == VMSTATE_RUNNING_LS … … 370 379 ) 371 380 { 372 PDM CritSectEnter(&pThis->CritSect, VERR_IGNORED);373 vmmdevNotifyGuestWorker(p This, fAddEvents);374 PDM CritSectLeave(&pThis->CritSect);381 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 382 vmmdevNotifyGuestWorker(pDevIns, pThis, pThisCC, fAddEvents); 383 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 375 384 } 376 385 else … … 382 391 * events the guest are interested in. 383 392 * 384 * @param pThis The VMMDev state. 393 * @param pDevIns The device instance. 394 * @param pThis The VMMDev shared instance data. 395 * @param pThisCC The VMMDev ring-3 instance data. 385 396 * @param fOrMask Events to add (VMMDEV_EVENT_XXX). Pass 0 for no 386 397 * change. … … 392 403 * controlled by the guest. 393 404 */ 394 void VMMDevCtlSetGuestFilterMask(P VMMDEV pThis, uint32_t fOrMask, uint32_t fNotMask)395 { 396 PDM CritSectEnter(&pThis->CritSect, VERR_IGNORED);405 void VMMDevCtlSetGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fOrMask, uint32_t fNotMask) 406 { 407 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 397 408 398 409 const bool fHadEvents = (pThis->fHostEventFlags & pThis->fGuestFilterMask) != 0; … … 412 423 pThis->fGuestFilterMask |= fOrMask; 413 424 pThis->fGuestFilterMask &= ~fNotMask; 414 vmmdevMaybeSetIRQ(p This);415 } 416 417 PDM CritSectLeave(&pThis->CritSect);425 vmmdevMaybeSetIRQ(pDevIns, pThis, pThisCC); 426 } 427 428 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 418 429 } 419 430 … … 426 437 * 427 438 * @returns VBox status code that the guest should see. 428 * @param pThis The VMMDev instance data. 439 * @param pDevIns The device instance. 440 * @param pThis The VMMDev shared instance data. 441 * @param pThisCC The VMMDev ring-3 instance data. 429 442 * @param pRequestHeader The header of the request to handle. 430 443 */ 431 static int vmmdevReqHandler_ReportGuestInfo(PVMMDEV pThis, VMMDevRequestHeader *pRequestHeader) 444 static int vmmdevReqHandler_ReportGuestInfo(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 445 VMMDevRequestHeader *pRequestHeader) 432 446 { 433 447 AssertMsgReturn(pRequestHeader->size == sizeof(VMMDevReportGuestInfo), ("%u\n", pRequestHeader->size), VERR_INVALID_PARAMETER); … … 444 458 vmmdevLogGuestOsInfo(&pThis->guestInfo); 445 459 446 if (pThis ->pDrv && pThis->pDrv->pfnUpdateGuestInfo)447 pThis ->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);460 if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestInfo) 461 pThisCC->pDrv->pfnUpdateGuestInfo(pThisCC->pDrv, &pThis->guestInfo); 448 462 } 449 463 … … 452 466 453 467 /* Clear our IRQ in case it was high for whatever reason. */ 454 PDMDevHlpPCISetIrqNoWait(p This->pDevInsR3, 0, 0);468 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0); 455 469 456 470 return VINF_SUCCESS; … … 462 476 * 463 477 * @returns VBox status code that the guest should see. 464 * @param pThis The VMMDev instance data. 465 */ 466 static int vmmDevReqHandler_GuestHeartbeat(PVMMDEV pThis) 478 * @param pDevIns The device instance. 479 * @param pThis The VMMDev shared instance data. 480 */ 481 static int vmmDevReqHandler_GuestHeartbeat(PPDMDEVINS pDevIns, PVMMDEV pThis) 467 482 { 468 483 int rc; 469 484 if (pThis->fHeartbeatActive) 470 485 { 471 uint64_t const nsNowTS = TMTimerGetNano(pThis->pFlatlinedTimer);486 uint64_t const nsNowTS = PDMDevHlpTimerGetNano(pDevIns, pThis->hFlatlinedTimer); 472 487 if (!pThis->fFlatlined) 473 488 { /* likely */ } … … 480 495 481 496 /* Postpone (or restart if we missed a beat) the timeout timer. */ 482 rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);497 rc = PDMDevHlpTimerSetNano(pDevIns, pThis->hFlatlinedTimer, pThis->cNsHeartbeatTimeout); 483 498 } 484 499 else … … 495 510 static DECLCALLBACK(void) vmmDevHeartbeatFlatlinedTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 496 511 { 497 RT_NOREF 1(pDevIns);512 RT_NOREF(pDevIns); 498 513 PVMMDEV pThis = (PVMMDEV)pvUser; 499 514 if (pThis->fHeartbeatActive) … … 515 530 * 516 531 * @returns VBox status code that the guest should see. 517 * @param pThis The VMMDev instance data. 532 * @param pDevIns The device instance. 533 * @param pThis The VMMDev shared instance data. 518 534 * @param pReqHdr The header of the request to handle. 519 535 */ 520 static int vmmDevReqHandler_HeartbeatConfigure(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)536 static int vmmDevReqHandler_HeartbeatConfigure(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 521 537 { 522 538 AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReqHeartbeat), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER); … … 534 550 * Activate the heartbeat monitor. 535 551 */ 536 pThis->nsLastHeartbeatTS = TMTimerGetNano(pThis->pFlatlinedTimer);537 rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);552 pThis->nsLastHeartbeatTS = PDMDevHlpTimerGetNano(pDevIns, pThis->hFlatlinedTimer); 553 rc = PDMDevHlpTimerSetNano(pDevIns, pThis->hFlatlinedTimer, pThis->cNsHeartbeatTimeout); 538 554 if (RT_SUCCESS(rc)) 539 555 LogRel(("VMMDev: Heartbeat flatline timer set to trigger after %'RU64 ns\n", pThis->cNsHeartbeatTimeout)); … … 546 562 * Deactivate the heartbeat monitor. 547 563 */ 548 rc = TMTimerStop(pThis->pFlatlinedTimer);564 rc = PDMDevHlpTimerStop(pDevIns, pThis->hFlatlinedTimer); 549 565 LogRel(("VMMDev: Heartbeat checking timer has been stopped (rc=%Rrc)\n", rc)); 550 566 } … … 564 580 * 565 581 * @returns VBox status code that the guest should see. 566 * @param p This The VMMDev instance data.582 * @param pDevIns The device instance. 567 583 * @param pReqHdr The header of the request to handle. 568 584 */ 569 static int vmmDevReqHandler_NtBugCheck(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)585 static int vmmDevReqHandler_NtBugCheck(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 570 586 { 571 587 if (pReqHdr->size == sizeof(VMMDevReqNtBugCheck)) 572 588 { 573 589 VMMDevReqNtBugCheck const *pReq = (VMMDevReqNtBugCheck const *)pReqHdr; 574 DBGFR3ReportBugCheck(PDMDevHlpGetVM(p This->pDevInsR3), PDMDevHlpGetVMCPU(pThis->pDevInsR3), DBGFEVENT_BSOD_VMMDEV,590 DBGFR3ReportBugCheck(PDMDevHlpGetVM(pDevIns), PDMDevHlpGetVMCPU(pDevIns), DBGFEVENT_BSOD_VMMDEV, 575 591 pReq->uBugCheck, pReq->auParameters[0], pReq->auParameters[1], 576 592 pReq->auParameters[2], pReq->auParameters[3]); … … 579 595 { 580 596 LogRel(("VMMDev: NT BugCheck w/o data.\n")); 581 DBGFR3ReportBugCheck(PDMDevHlpGetVM(p This->pDevInsR3), PDMDevHlpGetVMCPU(pThis->pDevInsR3), DBGFEVENT_BSOD_VMMDEV,597 DBGFR3ReportBugCheck(PDMDevHlpGetVM(pDevIns), PDMDevHlpGetVMCPU(pDevIns), DBGFEVENT_BSOD_VMMDEV, 582 598 0, 0, 0, 0, 0); 583 599 } … … 640 656 * 641 657 * @returns VBox status code that the guest should see. 642 * @param pThis The VMMDev instance data. 658 * @param pDevIns The device instance. 659 * @param pThis The VMMDev shared instance data. 660 * @param pThisCC The VMMDev ring-3 instance data. 643 661 * @param pReqHdr The header of the request to handle. 644 662 */ 645 static int vmmdevReqHandler_ReportGuestInfo2(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)663 static int vmmdevReqHandler_ReportGuestInfo2(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 646 664 { 647 665 AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReportGuestInfo2), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER); … … 729 747 strcpy(pThis->guestInfo2.szName, pszName); 730 748 731 if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo2) 732 pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, uFullVersion, pszName, pInfo2->additionsRevision, pInfo2->additionsFeatures); 749 if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestInfo2) 750 pThisCC->pDrv->pfnUpdateGuestInfo2(pThisCC->pDrv, uFullVersion, pszName, pInfo2->additionsRevision, 751 pInfo2->additionsFeatures); 733 752 734 753 /* Clear our IRQ in case it was high for whatever reason. */ 735 PDMDevHlpPCISetIrqNoWait(p This->pDevInsR3, 0, 0);754 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0); 736 755 737 756 return VINF_SUCCESS; … … 744 763 * @returns Pointer to a facility status entry on success, NULL on failure 745 764 * (table full). 746 * @param pThis The VMMDev instance data.765 * @param pThis The VMMDev shared instance data. 747 766 * @param enmFacility The facility type code. 748 767 * @param fFixed This is set when allocating the standard entries … … 812 831 * @returns Pointer to a facility status entry on success, NULL on failure 813 832 * (table full). 814 * @param pThis The VMMDev instance data.833 * @param pThis The VMMDev shared instance data. 815 834 * @param enmFacility The facility type code. 816 835 */ … … 834 853 * 835 854 * @returns VBox status code that the guest should see. 836 * @param pThis The VMMDev instance data. 855 * @param pThis The VMMDev shared instance data. 856 * @param pThisCC The VMMDev ring-3 instance data. 837 857 * @param pReqHdr The header of the request to handle. 838 858 */ 839 static int vmmdevReqHandler_ReportGuestStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)859 static int vmmdevReqHandler_ReportGuestStatus(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 840 860 { 841 861 /* … … 881 901 } 882 902 883 if (pThis ->pDrv && pThis->pDrv->pfnUpdateGuestStatus)884 pThis ->pDrv->pfnUpdateGuestStatus(pThis->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now);903 if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestStatus) 904 pThisCC->pDrv->pfnUpdateGuestStatus(pThisCC->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now); 885 905 886 906 return VINF_SUCCESS; … … 892 912 * 893 913 * @returns VBox status code that the guest should see. 894 * @param pThis The VMMDevinstance data.914 * @param pThisCC The VMMDev ring-3 instance data. 895 915 * @param pReqHdr The header of the request to handle. 896 916 */ 897 static int vmmdevReqHandler_ReportGuestUserState(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)917 static int vmmdevReqHandler_ReportGuestUserState(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 898 918 { 899 919 /* … … 903 923 AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER); 904 924 905 if ( pThis ->pDrv906 && pThis ->pDrv->pfnUpdateGuestUserState)925 if ( pThisCC->pDrv 926 && pThisCC->pDrv->pfnUpdateGuestUserState) 907 927 { 908 928 /* Play safe. */ … … 950 970 pbDetails = pbDynamic; 951 971 952 pThis ->pDrv->pfnUpdateGuestUserState(pThis->pDrv, pszUser, pszDomain, (uint32_t)pReq->status.state,953 pbDetails, pReq->status.cbDetails);972 pThisCC->pDrv->pfnUpdateGuestUserState(pThisCC->pDrv, pszUser, pszDomain, (uint32_t)pReq->status.state, 973 pbDetails, pReq->status.cbDetails); 954 974 } 955 975 … … 962 982 * 963 983 * @returns VBox status code that the guest should see. 964 * @param pThis The VMMDev instance data. 984 * @param pThis The VMMDev shared instance data. 985 * @param pThisCC The VMMDev ring-3 instance data. 965 986 * @param pReqHdr The header of the request to handle. 966 987 */ 967 static int vmmdevReqHandler_ReportGuestCapabilities(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)988 static int vmmdevReqHandler_ReportGuestCapabilities(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 968 989 { 969 990 VMMDevReqGuestCapabilities *pReq = (VMMDevReqGuestCapabilities *)pReqHdr; … … 985 1006 fu32Caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no")); 986 1007 987 if (pThis ->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)988 pThis ->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, fu32Caps);1008 if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities) 1009 pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, fu32Caps); 989 1010 } 990 1011 return VINF_SUCCESS; … … 996 1017 * 997 1018 * @returns VBox status code that the guest should see. 998 * @param pThis The VMMDev instance data. 1019 * @param pThis The VMMDev shared instance data. 1020 * @param pThisCC The VMMDev ring-3 instance data. 999 1021 * @param pReqHdr The header of the request to handle. 1000 1022 */ 1001 static int vmmdevReqHandler_SetGuestCapabilities(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1023 static int vmmdevReqHandler_SetGuestCapabilities(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1002 1024 { 1003 1025 VMMDevReqGuestCapabilities2 *pReq = (VMMDevReqGuestCapabilities2 *)pReqHdr; … … 1016 1038 pThis->fGuestCaps = fu32Caps; 1017 1039 1018 if (pThis ->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)1019 pThis ->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, fu32Caps);1040 if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities) 1041 pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, fu32Caps); 1020 1042 1021 1043 return VINF_SUCCESS; … … 1027 1049 * 1028 1050 * @returns VBox status code that the guest should see. 1029 * @param pThis The VMMDev instance data.1051 * @param pThis The VMMDev shared instance data. 1030 1052 * @param pReqHdr The header of the request to handle. 1031 1053 */ … … 1049 1071 * 1050 1072 * @returns VBox status code that the guest should see. 1051 * @param pThis The VMMDev instance data. 1073 * @param pThis The VMMDev shared instance data. 1074 * @param pThisCC The VMMDev ring-3 instance data. 1052 1075 * @param pReqHdr The header of the request to handle. 1053 1076 */ 1054 static int vmmdevReqHandler_SetMouseStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1077 static int vmmdevReqHandler_SetMouseStatus(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1055 1078 { 1056 1079 VMMDevReqMouseStatus *pReq = (VMMDevReqMouseStatus *)pReqHdr; … … 1076 1099 { 1077 1100 LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: Notifying connector\n")); 1078 pThis ->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);1101 pThisCC->pDrv->pfnUpdateMouseCapabilities(pThisCC->pDrv, pThis->fMouseCapabilities); 1079 1102 } 1080 1103 … … 1100 1123 * 1101 1124 * @returns VBox status code that the guest should see. 1102 * @param pThis The VMMDev instance data. 1125 * @param pThis The VMMDev shared instance data. 1126 * @param pThisCC The VMMDev ring-3 instance data. 1103 1127 * @param pReqHdr The header of the request to handle. 1104 1128 */ 1105 static int vmmdevReqHandler_SetPointerShape(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1129 static int vmmdevReqHandler_SetPointerShape(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1106 1130 { 1107 1131 VMMDevReqMousePointer *pReq = (VMMDevReqMousePointer *)pReqHdr; … … 1134 1158 return rc; 1135 1159 1136 pThis ->pDrv->pfnUpdatePointerShape(pThis->pDrv,1137 fVisible,1138 fAlpha,1139 pReq->xHot, pReq->yHot,1140 pReq->width, pReq->height,1141 pReq->pointerData);1160 pThisCC->pDrv->pfnUpdatePointerShape(pThisCC->pDrv, 1161 fVisible, 1162 fAlpha, 1163 pReq->xHot, pReq->yHot, 1164 pReq->width, pReq->height, 1165 pReq->pointerData); 1142 1166 } 1143 1167 else 1144 1168 { 1145 pThis ->pDrv->pfnUpdatePointerShape(pThis->pDrv,1146 fVisible,1147 0,1148 0, 0,1149 0, 0,1150 NULL);1169 pThisCC->pDrv->pfnUpdatePointerShape(pThisCC->pDrv, 1170 fVisible, 1171 0, 1172 0, 0, 1173 0, 0, 1174 NULL); 1151 1175 } 1152 1176 … … 1160 1184 * 1161 1185 * @returns VBox status code that the guest should see. 1162 * @param pThis The VMMDev instance data. 1186 * @param pDevIns The device instance. 1187 * @param pThis The VMMDev shared instance data. 1163 1188 * @param pReqHdr The header of the request to handle. 1164 1189 */ 1165 static int vmmdevReqHandler_GetHostTime(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1190 static int vmmdevReqHandler_GetHostTime(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 1166 1191 { 1167 1192 VMMDevReqHostTime *pReq = (VMMDevReqHostTime *)pReqHdr; … … 1171 1196 { 1172 1197 RTTIMESPEC now; 1173 pReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(p This->pDevInsR3, &now));1198 pReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &now)); 1174 1199 return VINF_SUCCESS; 1175 1200 } … … 1182 1207 * 1183 1208 * @returns VBox status code that the guest should see. 1184 * @param p This The VMMDev instance data.1209 * @param pDevIns The device instance. 1185 1210 * @param pReqHdr The header of the request to handle. 1186 1211 */ 1187 static int vmmdevReqHandler_GetHypervisorInfo(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1212 static int vmmdevReqHandler_GetHypervisorInfo(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 1188 1213 { 1189 1214 VMMDevReqHypervisorInfo *pReq = (VMMDevReqHypervisorInfo *)pReqHdr; 1190 1215 AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); 1191 1216 1192 return PGMR3MappingsSize(PDMDevHlpGetVM(p This->pDevInsR3), &pReq->hypervisorSize);1217 return PGMR3MappingsSize(PDMDevHlpGetVM(pDevIns), &pReq->hypervisorSize); 1193 1218 } 1194 1219 … … 1198 1223 * 1199 1224 * @returns VBox status code that the guest should see. 1200 * @param pThis The VMMDev instance data. 1225 * @param pDevIns The device instance. 1226 * @param pThis The VMMDev shared instance data. 1201 1227 * @param pReqHdr The header of the request to handle. 1202 1228 */ 1203 static int vmmdevReqHandler_SetHypervisorInfo(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1229 static int vmmdevReqHandler_SetHypervisorInfo(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 1204 1230 { 1205 1231 VMMDevReqHypervisorInfo *pReq = (VMMDevReqHypervisorInfo *)pReqHdr; … … 1207 1233 1208 1234 int rc; 1209 PVM pVM = PDMDevHlpGetVM(p This->pDevInsR3);1235 PVM pVM = PDMDevHlpGetVM(pDevIns); 1210 1236 if (pReq->hypervisorStart == 0) 1211 1237 rc = PGMR3MappingsUnfix(pVM); … … 1233 1259 * 1234 1260 * @returns VBox status code that the guest should see. 1235 * @param p This The VMMDev instance data.1261 * @param pDevIns The device instance. 1236 1262 * @param pReqHdr The header of the request to handle. 1237 1263 */ 1238 static int vmmdevReqHandler_RegisterPatchMemory(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1264 static int vmmdevReqHandler_RegisterPatchMemory(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 1239 1265 { 1240 1266 VMMDevReqPatchMemory *pReq = (VMMDevReqPatchMemory *)pReqHdr; 1241 1267 AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); 1242 1268 1243 return VMMR3RegisterPatchMemory(PDMDevHlpGetVM(p This->pDevInsR3), pReq->pPatchMem, pReq->cbPatchMem);1269 return VMMR3RegisterPatchMemory(PDMDevHlpGetVM(pDevIns), pReq->pPatchMem, pReq->cbPatchMem); 1244 1270 } 1245 1271 … … 1249 1275 * 1250 1276 * @returns VBox status code that the guest should see. 1251 * @param p This The VMMDev instance data.1277 * @param pDevIns The device instance. 1252 1278 * @param pReqHdr The header of the request to handle. 1253 1279 */ 1254 static int vmmdevReqHandler_DeregisterPatchMemory(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1280 static int vmmdevReqHandler_DeregisterPatchMemory(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 1255 1281 { 1256 1282 VMMDevReqPatchMemory *pReq = (VMMDevReqPatchMemory *)pReqHdr; 1257 1283 AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); 1258 1284 1259 return VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(p This->pDevInsR3), pReq->pPatchMem, pReq->cbPatchMem);1285 return VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pDevIns), pReq->pPatchMem, pReq->cbPatchMem); 1260 1286 } 1261 1287 … … 1265 1291 * 1266 1292 * @returns VBox status code that the guest should see. 1267 * @param pThis The VMMDev instance data. 1293 * @param pDevIns The device instance. 1294 * @param pThis The VMMDev shared instance data. 1268 1295 * @param pReqHdr The header of the request to handle. 1269 1296 */ 1270 static int vmmdevReqHandler_SetPowerStatus(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1297 static int vmmdevReqHandler_SetPowerStatus(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 1271 1298 { 1272 1299 VMMDevPowerStateRequest *pReq = (VMMDevPowerStateRequest *)pReqHdr; … … 1278 1305 { 1279 1306 LogRel(("VMMDev: Guest requests the VM to be suspended (paused)\n")); 1280 return PDMDevHlpVMSuspend(p This->pDevInsR3);1307 return PDMDevHlpVMSuspend(pDevIns); 1281 1308 } 1282 1309 … … 1284 1311 { 1285 1312 LogRel(("VMMDev: Guest requests the VM to be turned off\n")); 1286 return PDMDevHlpVMPowerOff(p This->pDevInsR3);1313 return PDMDevHlpVMPowerOff(pDevIns); 1287 1314 } 1288 1315 1289 1316 case VMMDevPowerState_SaveState: 1290 1317 { 1291 if ( true /*pThis->fAllowGuestToSaveState*/)1318 if (pThis->fAllowGuestToSaveState) 1292 1319 { 1293 1320 LogRel(("VMMDev: Guest requests the VM to be saved and powered off\n")); 1294 return PDMDevHlpVMSuspendSaveAndPowerOff(p This->pDevInsR3);1321 return PDMDevHlpVMSuspendSaveAndPowerOff(pDevIns); 1295 1322 } 1296 1323 LogRel(("VMMDev: Guest requests the VM to be saved and powered off, declined\n")); … … 1309 1336 * 1310 1337 * @returns VBox status code that the guest should see. 1311 * @param pThis The VMMDev instance data.1338 * @param pThis The VMMDev shared instance data. 1312 1339 * @param pReqHdr The header of the request to handle. 1313 1340 * @remarks Deprecated. … … 1351 1378 * 1352 1379 * @returns VBox status code that the guest should see. 1353 * @param pThis The VMMDev instance data. 1380 * @param pDevIns The device instance. 1381 * @param pThis The VMMDev shared instance data. 1382 * @param pThisCC The VMMDev ring-3 instance data. 1354 1383 * @param pReqHdr The header of the request to handle. 1355 1384 */ 1356 static int vmmdevReqHandler_GetDisplayChangeRequest2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 1385 static int vmmdevReqHandler_GetDisplayChangeRequest2(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 1386 VMMDevRequestHeader *pReqHdr) 1357 1387 { 1358 1388 VMMDevDisplayChangeRequest2 *pReq = (VMMDevDisplayChangeRequest2 *)pReqHdr; … … 1383 1413 if (pThis->displayChangeData.aRequests[i].fPending) 1384 1414 { 1385 VMMDevNotifyGuest(p This, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);1415 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST); 1386 1416 Log3(("VMMDev: another pending at %u\n", i)); 1387 1417 break; … … 1433 1463 * 1434 1464 * @returns VBox status code that the guest should see. 1435 * @param pThis The VMMDev instance data. 1465 * @param pDevIns The device instance. 1466 * @param pThis The VMMDev shared instance data. 1467 * @param pThisCC The VMMDev ring-3 instance data. 1436 1468 * @param pReqHdr The header of the request to handle. 1437 1469 */ 1438 static int vmmdevReqHandler_GetDisplayChangeRequestEx(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 1470 static int vmmdevReqHandler_GetDisplayChangeRequestEx(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 1471 VMMDevRequestHeader *pReqHdr) 1439 1472 { 1440 1473 VMMDevDisplayChangeRequestEx *pReq = (VMMDevDisplayChangeRequestEx *)pReqHdr; … … 1466 1499 if (pThis->displayChangeData.aRequests[i].fPending) 1467 1500 { 1468 VMMDevNotifyGuest(p This, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);1501 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST); 1469 1502 Log3(("VMMDev: another pending at %d\n", 1470 1503 i)); … … 1522 1555 * 1523 1556 * @returns VBox status code that the guest should see. 1524 * @param pThis The VMMDev instance data.1557 * @param pThis The VMMDev shared instance data. 1525 1558 * @param pReqHdr The header of the request to handle. 1526 1559 */ … … 1595 1628 * 1596 1629 * @returns VBox status code that the guest should see. 1597 * @param pThis The VMMDevinstance data.1630 * @param pThisCC The VMMDev ring-3 instance data. 1598 1631 * @param pReqHdr The header of the request to handle. 1599 1632 */ 1600 static int vmmdevReqHandler_VideoModeSupported(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1633 static int vmmdevReqHandler_VideoModeSupported(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1601 1634 { 1602 1635 VMMDevVideoModeSupportedRequest *pReq = (VMMDevVideoModeSupportedRequest *)pReqHdr; … … 1604 1637 1605 1638 /* forward the call */ 1606 return pThis ->pDrv->pfnVideoModeSupported(pThis->pDrv,1607 0, /* primary screen. */1608 pReq->width,1609 pReq->height,1610 pReq->bpp,1611 &pReq->fSupported);1639 return pThisCC->pDrv->pfnVideoModeSupported(pThisCC->pDrv, 1640 0, /* primary screen. */ 1641 pReq->width, 1642 pReq->height, 1643 pReq->bpp, 1644 &pReq->fSupported); 1612 1645 } 1613 1646 … … 1619 1652 * 1620 1653 * @returns VBox status code that the guest should see. 1621 * @param pThis The VMMDevinstance data.1654 * @param pThisCC The VMMDev ring-3 instance data. 1622 1655 * @param pReqHdr The header of the request to handle. 1623 1656 */ 1624 static int vmmdevReqHandler_VideoModeSupported2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1657 static int vmmdevReqHandler_VideoModeSupported2(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1625 1658 { 1626 1659 VMMDevVideoModeSupportedRequest2 *pReq = (VMMDevVideoModeSupportedRequest2 *)pReqHdr; … … 1628 1661 1629 1662 /* forward the call */ 1630 return pThis ->pDrv->pfnVideoModeSupported(pThis->pDrv,1631 pReq->display,1632 pReq->width,1633 pReq->height,1634 pReq->bpp,1635 &pReq->fSupported);1663 return pThisCC->pDrv->pfnVideoModeSupported(pThisCC->pDrv, 1664 pReq->display, 1665 pReq->width, 1666 pReq->height, 1667 pReq->bpp, 1668 &pReq->fSupported); 1636 1669 } 1637 1670 … … 1642 1675 * 1643 1676 * @returns VBox status code that the guest should see. 1644 * @param pThis The VMMDev instance data.1677 * @param pThis The VMMDev ring-3 instance data. 1645 1678 * @param pReqHdr The header of the request to handle. 1646 1679 */ 1647 static int vmmdevReqHandler_GetHeightReduction(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1680 static int vmmdevReqHandler_GetHeightReduction(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1648 1681 { 1649 1682 VMMDevGetHeightReductionRequest *pReq = (VMMDevGetHeightReductionRequest *)pReqHdr; … … 1651 1684 1652 1685 /* forward the call */ 1653 return pThis ->pDrv->pfnGetHeightReduction(pThis->pDrv, &pReq->heightReduction);1686 return pThisCC->pDrv->pfnGetHeightReduction(pThisCC->pDrv, &pReq->heightReduction); 1654 1687 } 1655 1688 … … 1659 1692 * 1660 1693 * @returns VBox status code that the guest should see. 1661 * @param pThis The VMMDev instance data. 1694 * @param pDevIns The device instance. 1695 * @param pThis The VMMDev shared instance data. 1696 * @param pThisCC The VMMDev ring-3 instance data. 1662 1697 * @param pReqHdr The header of the request to handle. 1663 1698 */ 1664 static int vmmdevReqHandler_AcknowledgeEvents(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1699 static int vmmdevReqHandler_AcknowledgeEvents(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1665 1700 { 1666 1701 VMMDevEvents *pReq = (VMMDevEvents *)pReqHdr; … … 1682 1717 1683 1718 pThis->fHostEventFlags &= ~pThis->fGuestFilterMask; 1684 pThis ->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;1685 1686 PDMDevHlpPCISetIrqNoWait(p This->CTX_SUFF(pDevIns), 0, 0);1719 pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false; 1720 1721 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0); 1687 1722 } 1688 1723 else 1689 vmmdevSetIRQ_Legacy(p This);1724 vmmdevSetIRQ_Legacy(pDevIns, pThis, pThisCC); 1690 1725 return VINF_SUCCESS; 1691 1726 } … … 1696 1731 * 1697 1732 * @returns VBox status code that the guest should see. 1698 * @param pThis The VMMDev instance data. 1733 * @param pDevIns The device instance. 1734 * @param pThis The VMMDev shared instance data. 1735 * @param pThisCC The VMMDev ring-3 instance data. 1699 1736 * @param pReqHdr The header of the request to handle. 1700 1737 */ 1701 static int vmmdevReqHandler_CtlGuestFilterMask(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)1738 static int vmmdevReqHandler_CtlGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1702 1739 { 1703 1740 VMMDevCtlGuestFilterMask *pReq = (VMMDevCtlGuestFilterMask *)pReqHdr; … … 1709 1746 * automatically when any HGCM command is issued. The guest 1710 1747 * cannot disable these notifications. */ 1711 VMMDevCtlSetGuestFilterMask(p This, pReq->u32OrMask, pReq->u32NotMask & ~VMMDEV_EVENT_HGCM);1748 VMMDevCtlSetGuestFilterMask(pDevIns, pThis, pThisCC, pReq->u32OrMask, pReq->u32NotMask & ~VMMDEV_EVENT_HGCM); 1712 1749 return VINF_SUCCESS; 1713 1750 } … … 1719 1756 * 1720 1757 * @returns VBox status code that the guest should see. 1721 * @param pThis The VMMDev instance data. 1758 * @param pDevIns The device instance. 1759 * @param pThis The VMMDev shared instance data. 1760 * @param pThisCC The VMMDev ring-3 instance data. 1722 1761 * @param pReqHdr The header of the request to handle. 1723 1762 * @param GCPhysReqHdr The guest physical address of the request header. 1724 1763 */ 1725 static int vmmdevReqHandler_HGCMConnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr) 1764 static int vmmdevReqHandler_HGCMConnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 1765 VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr) 1726 1766 { 1727 1767 VMMDevHGCMConnect *pReq = (VMMDevHGCMConnect *)pReqHdr; 1728 1768 AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this is >= ... */ 1729 1769 1730 if (pThis ->pHGCMDrv)1770 if (pThisCC->pHGCMDrv) 1731 1771 { 1732 1772 Log(("VMMDevReq_HGCMConnect\n")); 1733 return vmmdev HGCMConnect(pThis, pReq, GCPhysReqHdr);1773 return vmmdevR3HgcmConnect(pDevIns, pThis, pThisCC, pReq, GCPhysReqHdr); 1734 1774 } 1735 1775 … … 1743 1783 * 1744 1784 * @returns VBox status code that the guest should see. 1745 * @param pThis The VMMDev instance data. 1785 * @param pDevIns The device instance. 1786 * @param pThis The VMMDev shared instance data. 1787 * @param pThisCC The VMMDev ring-3 instance data. 1746 1788 * @param pReqHdr The header of the request to handle. 1747 1789 * @param GCPhysReqHdr The guest physical address of the request header. 1748 1790 */ 1749 static int vmmdevReqHandler_HGCMDisconnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr) 1791 static int vmmdevReqHandler_HGCMDisconnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 1792 VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr) 1750 1793 { 1751 1794 VMMDevHGCMDisconnect *pReq = (VMMDevHGCMDisconnect *)pReqHdr; 1752 1795 AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */ 1753 1796 1754 if (pThis ->pHGCMDrv)1797 if (pThisCC->pHGCMDrv) 1755 1798 { 1756 1799 Log(("VMMDevReq_VMMDevHGCMDisconnect\n")); 1757 return vmmdev HGCMDisconnect(pThis, pReq, GCPhysReqHdr);1800 return vmmdevR3HgcmDisconnect(pDevIns, pThis, pThisCC, pReq, GCPhysReqHdr); 1758 1801 } 1759 1802 … … 1767 1810 * 1768 1811 * @returns VBox status code that the guest should see. 1769 * @param pThis The VMMDev instance data. 1812 * @param pDevIns The device instance. 1813 * @param pThis The VMMDev shared instance data. 1814 * @param pThisCC The VMMDev ring-3 instance data. 1770 1815 * @param pReqHdr The header of the request to handle. 1771 1816 * @param GCPhysReqHdr The guest physical address of the request header. … … 1774 1819 * NULL). Set to NULL if HGCM takes lock ownership. 1775 1820 */ 1776 static int vmmdevReqHandler_HGCMCall(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr,1777 uint64_t tsArrival, PVMMDEVREQLOCK *ppLock)1821 static int vmmdevReqHandler_HGCMCall(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr, 1822 RTGCPHYS GCPhysReqHdr, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock) 1778 1823 { 1779 1824 VMMDevHGCMCall *pReq = (VMMDevHGCMCall *)pReqHdr; 1780 1825 AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); 1781 1826 1782 if (pThis ->pHGCMDrv)1827 if (pThisCC->pHGCMDrv) 1783 1828 { 1784 1829 Log2(("VMMDevReq_HGCMCall: sizeof(VMMDevHGCMRequest) = %04X\n", sizeof(VMMDevHGCMCall))); 1785 1830 Log2(("%.*Rhxd\n", pReq->header.header.size, pReq)); 1786 1831 1787 return vmmdev HGCMCall(pThis, pReq, pReq->header.header.size, GCPhysReqHdr, pReq->header.header.requestType,1788 tsArrival, ppLock);1832 return vmmdevR3HgcmCall(pDevIns, pThis, pThisCC, pReq, pReq->header.header.size, GCPhysReqHdr, 1833 pReq->header.header.requestType, tsArrival, ppLock); 1789 1834 } 1790 1835 … … 1797 1842 * 1798 1843 * @returns VBox status code that the guest should see. 1799 * @param pThis The VMMDevinstance data.1844 * @param pThisCC The VMMDev ring-3 instance data. 1800 1845 * @param pReqHdr The header of the request to handle. 1801 1846 * @param GCPhysReqHdr The guest physical address of the request header. 1802 1847 */ 1803 static int vmmdevReqHandler_HGCMCancel(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)1848 static int vmmdevReqHandler_HGCMCancel(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr) 1804 1849 { 1805 1850 VMMDevHGCMCancel *pReq = (VMMDevHGCMCancel *)pReqHdr; 1806 1851 AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */ 1807 1852 1808 if (pThis ->pHGCMDrv)1853 if (pThisCC->pHGCMDrv) 1809 1854 { 1810 1855 Log(("VMMDevReq_VMMDevHGCMCancel\n")); 1811 return vmmdev HGCMCancel(pThis, pReq, GCPhysReqHdr);1856 return vmmdevR3HgcmCancel(pThisCC, pReq, GCPhysReqHdr); 1812 1857 } 1813 1858 … … 1821 1866 * 1822 1867 * @returns VBox status code that the guest should see. 1823 * @param pThis The VMMDevinstance data.1868 * @param pThisCC The VMMDev ring-3 instance data. 1824 1869 * @param pReqHdr The header of the request to handle. 1825 1870 */ 1826 static int vmmdevReqHandler_HGCMCancel2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1871 static int vmmdevReqHandler_HGCMCancel2(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1827 1872 { 1828 1873 VMMDevHGCMCancel2 *pReq = (VMMDevHGCMCancel2 *)pReqHdr; 1829 1874 AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */ 1830 1875 1831 if (pThis ->pHGCMDrv)1876 if (pThisCC->pHGCMDrv) 1832 1877 { 1833 1878 Log(("VMMDevReq_HGCMCancel2\n")); 1834 return vmmdev HGCMCancel2(pThis, pReq->physReqToCancel);1879 return vmmdevR3HgcmCancel2(pThisCC, pReq->physReqToCancel); 1835 1880 } 1836 1881 … … 1846 1891 * 1847 1892 * @returns VBox status code that the guest should see. 1848 * @param pThis The VMMDev instance data. 1893 * @param pThis The VMMDev shared instance data. 1894 * @param pThisCC The VMMDev ring-3 instance data. 1849 1895 * @param pReqHdr The header of the request to handle. 1850 1896 */ 1851 static int vmmdevReqHandler_VideoAccelEnable(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1897 static int vmmdevReqHandler_VideoAccelEnable(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1852 1898 { 1853 1899 VMMDevVideoAccelEnable *pReq = (VMMDevVideoAccelEnable *)pReqHdr; 1854 1900 AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */ 1855 1901 1856 if (!pThis ->pDrv)1902 if (!pThisCC->pDrv) 1857 1903 { 1858 1904 Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!\n")); … … 1873 1919 1874 1920 int rc = pReq->u32Enable 1875 ? pThis ->pDrv->pfnVideoAccelEnable(pThis->pDrv, true, &pThis->pVMMDevRAMR3->vbvaMemory)1876 : pThis ->pDrv->pfnVideoAccelEnable(pThis->pDrv, false, NULL);1921 ? pThisCC->pDrv->pfnVideoAccelEnable(pThisCC->pDrv, true, &pThisCC->pVMMDevRAMR3->vbvaMemory) 1922 : pThisCC->pDrv->pfnVideoAccelEnable(pThisCC->pDrv, false, NULL); 1877 1923 1878 1924 if ( pReq->u32Enable … … 1899 1945 * 1900 1946 * @returns VBox status code that the guest should see. 1901 * @param pThis The VMMDevinstance data.1947 * @param pThisCC The VMMDev ring-3 instance data. 1902 1948 * @param pReqHdr The header of the request to handle. 1903 1949 */ 1904 static int vmmdevReqHandler_VideoAccelFlush(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1950 static int vmmdevReqHandler_VideoAccelFlush(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1905 1951 { 1906 1952 VMMDevVideoAccelFlush *pReq = (VMMDevVideoAccelFlush *)pReqHdr; 1907 1953 AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */ 1908 1954 1909 if (!pThis ->pDrv)1955 if (!pThisCC->pDrv) 1910 1956 { 1911 1957 Log(("VMMDevReq_VideoAccelFlush: Connector is NULL!!!\n")); … … 1913 1959 } 1914 1960 1915 pThis ->pDrv->pfnVideoAccelFlush(pThis->pDrv);1961 pThisCC->pDrv->pfnVideoAccelFlush(pThisCC->pDrv); 1916 1962 return VINF_SUCCESS; 1917 1963 } … … 1922 1968 * 1923 1969 * @returns VBox status code that the guest should see. 1924 * @param pThis The VMMDevinstance data.1970 * @param pThisCC The VMMDev ring-3 instance data. 1925 1971 * @param pReqHdr The header of the request to handle. 1926 1972 */ 1927 static int vmmdevReqHandler_VideoSetVisibleRegion(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)1973 static int vmmdevReqHandler_VideoSetVisibleRegion(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 1928 1974 { 1929 1975 VMMDevVideoSetVisibleRegion *pReq = (VMMDevVideoSetVisibleRegion *)pReqHdr; 1930 1976 AssertMsgReturn(pReq->header.size + sizeof(RTRECT) >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); 1931 1977 1932 if (!pThis ->pDrv)1978 if (!pThisCC->pDrv) 1933 1979 { 1934 1980 Log(("VMMDevReq_VideoSetVisibleRegion: Connector is NULL!!!\n")); … … 1946 1992 Log(("VMMDevReq_VideoSetVisibleRegion %d rectangles\n", pReq->cRect)); 1947 1993 /* forward the call */ 1948 return pThis ->pDrv->pfnSetVisibleRegion(pThis->pDrv, pReq->cRect, &pReq->Rect);1994 return pThisCC->pDrv->pfnSetVisibleRegion(pThisCC->pDrv, pReq->cRect, &pReq->Rect); 1949 1995 } 1950 1996 … … 1954 2000 * 1955 2001 * @returns VBox status code that the guest should see. 1956 * @param pThis The VMMDev instance data.2002 * @param pThis The VMMDev shared instance data. 1957 2003 * @param pReqHdr The header of the request to handle. 1958 2004 */ … … 1983 2029 * 1984 2030 * @returns VBox status code that the guest should see. 1985 * @param pThis The VMMDev instance data.2031 * @param pThis The VMMDev shared instance data. 1986 2032 * @param pReqHdr The header of the request to handle. 1987 2033 */ … … 2005 2051 * 2006 2052 * @returns VBox status code that the guest should see. 2007 * @param pThis The VMMDev instance data.2053 * @param pThis The VMMDev shared instance data. 2008 2054 * @param pReqHdr The header of the request to handle. 2009 2055 */ … … 2032 2078 * 2033 2079 * @returns VBox status code that the guest should see. 2034 * @param pThis The VMMDev instance data. 2080 * @param pDevIns The device instance. 2081 * @param pThis The VMMDev shared instance data. 2035 2082 * @param pReqHdr The header of the request to handle. 2036 2083 */ 2037 static int vmmdevReqHandler_ChangeMemBalloon(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)2084 static int vmmdevReqHandler_ChangeMemBalloon(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 2038 2085 { 2039 2086 VMMDevChangeMemBalloon *pReq = (VMMDevChangeMemBalloon *)pReqHdr; … … 2044 2091 2045 2092 Log(("VMMDevReq_ChangeMemBalloon\n")); 2046 int rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(p This->pDevInsR3), !!pReq->fInflate, pReq->cPages, pReq->aPhysPage);2093 int rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pDevIns), !!pReq->fInflate, pReq->cPages, pReq->aPhysPage); 2047 2094 if (pReq->fInflate) 2048 2095 STAM_REL_U32_INC(&pThis->StatMemBalloonChunks); … … 2057 2104 * 2058 2105 * @returns VBox status code that the guest should see. 2059 * @param pThis The VMMDev instance data.2106 * @param pThis The VMMDev shared instance data. 2060 2107 * @param pReqHdr The header of the request to handle. 2061 2108 */ … … 2084 2131 * 2085 2132 * @returns VBox status code that the guest should see. 2086 * @param pThis The VMMDevinstance data.2133 * @param pThisCC The VMMDev ring-3 instance data. 2087 2134 * @param pReqHdr The header of the request to handle. 2088 2135 */ 2089 static int vmmdevReqHandler_ReportGuestStats(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)2136 static int vmmdevReqHandler_ReportGuestStats(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 2090 2137 { 2091 2138 VMMDevReportGuestStats *pReq = (VMMDevReportGuestStats *)pReqHdr; … … 2152 2199 2153 2200 /* forward the call */ 2154 return pThis ->pDrv->pfnReportStatistics(pThis->pDrv, &pReq->guestStats);2201 return pThisCC->pDrv->pfnReportStatistics(pThisCC->pDrv, &pReq->guestStats); 2155 2202 } 2156 2203 … … 2160 2207 * 2161 2208 * @returns VBox status code that the guest should see. 2162 * @param pThis The VMMDev instance data. 2209 * @param pThis The VMMDev shared instance data. 2210 * @param pThisCC The VMMDev ring-3 instance data. 2163 2211 * @param pReqHdr The header of the request to handle. 2164 2212 */ 2165 static int vmmdevReqHandler_QueryCredentials(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)2213 static int vmmdevReqHandler_QueryCredentials(PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 2166 2214 { 2167 2215 VMMDevCredentials *pReq = (VMMDevCredentials *)pReqHdr; 2168 2216 AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); 2217 VMMDEVCREDS *pCredentials = pThisCC->pCredentials; 2218 AssertPtrReturn(pCredentials, VERR_NOT_SUPPORTED); 2169 2219 2170 2220 /* let's start by nulling out the data */ 2171 memset(pReq->szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2172 memset(pReq->szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2173 memset(pReq->szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2221 RT_ZERO(pReq->szUserName); 2222 RT_ZERO(pReq->szPassword); 2223 RT_ZERO(pReq->szDomain); 2174 2224 2175 2225 /* should we return whether we got credentials for a logon? */ 2176 2226 if (pReq->u32Flags & VMMDEV_CREDENTIALS_QUERYPRESENCE) 2177 2227 { 2178 if ( p This->pCredentials->Logon.szUserName[0]2179 || p This->pCredentials->Logon.szPassword[0]2180 || p This->pCredentials->Logon.szDomain[0])2228 if ( pCredentials->Logon.szUserName[0] 2229 || pCredentials->Logon.szPassword[0] 2230 || pCredentials->Logon.szDomain[0]) 2181 2231 pReq->u32Flags |= VMMDEV_CREDENTIALS_PRESENT; 2182 2232 else … … 2187 2237 if (pReq->u32Flags & VMMDEV_CREDENTIALS_READ) 2188 2238 { 2189 if (p This->pCredentials->Logon.szUserName[0])2190 strcpy(pReq->szUserName, pThis->pCredentials->Logon.szUserName);2191 if (p This->pCredentials->Logon.szPassword[0])2192 strcpy(pReq->szPassword, pThis->pCredentials->Logon.szPassword);2193 if (p This->pCredentials->Logon.szDomain[0])2194 strcpy(pReq->szDomain, pThis->pCredentials->Logon.szDomain);2195 if (!p This->pCredentials->Logon.fAllowInteractiveLogon)2239 if (pCredentials->Logon.szUserName[0]) 2240 RTStrCopy(pReq->szUserName, sizeof(pReq->szUserName), pCredentials->Logon.szUserName); 2241 if (pCredentials->Logon.szPassword[0]) 2242 RTStrCopy(pReq->szPassword, sizeof(pReq->szPassword), pCredentials->Logon.szPassword); 2243 if (pCredentials->Logon.szDomain[0]) 2244 RTStrCopy(pReq->szDomain, sizeof(pReq->szDomain), pCredentials->Logon.szDomain); 2245 if (!pCredentials->Logon.fAllowInteractiveLogon) 2196 2246 pReq->u32Flags |= VMMDEV_CREDENTIALS_NOLOCALLOGON; 2197 2247 else … … 2204 2254 if (pReq->u32Flags & VMMDEV_CREDENTIALS_CLEAR) 2205 2255 { 2206 memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2207 memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2208 memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2256 RT_ZERO(pCredentials->Logon.szUserName); 2257 RT_ZERO(pCredentials->Logon.szPassword); 2258 RT_ZERO(pCredentials->Logon.szDomain); 2209 2259 } 2210 2260 } … … 2213 2263 if (pReq->u32Flags & VMMDEV_CREDENTIALS_READJUDGE) 2214 2264 { 2215 if (p This->pCredentials->Judge.szUserName[0])2216 strcpy(pReq->szUserName, pThis->pCredentials->Judge.szUserName);2217 if (p This->pCredentials->Judge.szPassword[0])2218 strcpy(pReq->szPassword, pThis->pCredentials->Judge.szPassword);2219 if (p This->pCredentials->Judge.szDomain[0])2220 strcpy(pReq->szDomain, pThis->pCredentials->Judge.szDomain);2265 if (pCredentials->Judge.szUserName[0]) 2266 RTStrCopy(pReq->szUserName, sizeof(pReq->szUserName), pCredentials->Judge.szUserName); 2267 if (pCredentials->Judge.szPassword[0]) 2268 RTStrCopy(pReq->szPassword, sizeof(pReq->szPassword), pCredentials->Judge.szPassword); 2269 if (pCredentials->Judge.szDomain[0]) 2270 RTStrCopy(pReq->szDomain, sizeof(pReq->szDomain), pCredentials->Judge.szDomain); 2221 2271 } 2222 2272 … … 2224 2274 if (pReq->u32Flags & VMMDEV_CREDENTIALS_CLEARJUDGE) 2225 2275 { 2226 memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2227 memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2228 memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);2276 RT_ZERO(pCredentials->Judge.szUserName); 2277 RT_ZERO(pCredentials->Judge.szPassword); 2278 RT_ZERO(pCredentials->Judge.szDomain); 2229 2279 } 2230 2280 … … 2237 2287 * 2238 2288 * @returns VBox status code that the guest should see. 2239 * @param pThis The VMMDevinstance data.2289 * @param pThisCC The VMMDev ring-3 instance data. 2240 2290 * @param pReqHdr The header of the request to handle. 2241 2291 */ 2242 static int vmmdevReqHandler_ReportCredentialsJudgement(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)2292 static int vmmdevReqHandler_ReportCredentialsJudgement(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 2243 2293 { 2244 2294 VMMDevCredentials *pReq = (VMMDevCredentials *)pReqHdr; … … 2247 2297 /* what does the guest think about the credentials? (note: the order is important here!) */ 2248 2298 if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_DENY) 2249 pThis ->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY);2299 pThisCC->pDrv->pfnSetCredentialsJudgementResult(pThisCC->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY); 2250 2300 else if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT) 2251 pThis ->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT);2301 pThisCC->pDrv->pfnSetCredentialsJudgementResult(pThisCC->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT); 2252 2302 else if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_OK) 2253 pThis ->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK);2303 pThisCC->pDrv->pfnSetCredentialsJudgementResult(pThisCC->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK); 2254 2304 else 2255 2305 { … … 2293 2343 * 2294 2344 * @returns VBox status code that the guest should see. 2295 * @param pThis The VMMDev instance data.2345 * @param pThis The VMMDev shared instance data. 2296 2346 * @param pReqHdr The header of the request to handle. 2297 2347 */ … … 2318 2368 * 2319 2369 * @returns VBox status code that the guest should see. 2320 * @param pThis The VMMDev instance data.2370 * @param pThis The VMMDev shared instance data. 2321 2371 * @param pReqHdr The header of the request to handle. 2322 2372 */ … … 2363 2413 * 2364 2414 * @returns VBox status code that the guest should see. 2365 * @param pThis The VMMDev instance data.2415 * @param pThis The VMMDev shared instance data. 2366 2416 * @param pReqHdr The header of the request to handle. 2367 2417 */ … … 2382 2432 * 2383 2433 * @returns VBox status code that the guest should see. 2384 * @param p This The VMMDev instance data.2434 * @param pDevIns The device instance. 2385 2435 * @param pReqHdr The header of the request to handle. 2386 2436 */ 2387 static int vmmdevReqHandler_RegisterSharedModule(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)2437 static int vmmdevReqHandler_RegisterSharedModule(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 2388 2438 { 2389 2439 /* … … 2406 2456 * Forward the request to the VMM. 2407 2457 */ 2408 return PGMR3SharedModuleRegister(PDMDevHlpGetVM(p This->pDevInsR3), pReq->enmGuestOS, pReq->szName, pReq->szVersion,2458 return PGMR3SharedModuleRegister(PDMDevHlpGetVM(pDevIns), pReq->enmGuestOS, pReq->szName, pReq->szVersion, 2409 2459 pReq->GCBaseAddr, pReq->cbModule, pReq->cRegions, pReq->aRegions); 2410 2460 } … … 2414 2464 * 2415 2465 * @returns VBox status code that the guest should see. 2416 * @param p This The VMMDev instance data.2466 * @param pDevIns The device instance. 2417 2467 * @param pReqHdr The header of the request to handle. 2418 2468 */ 2419 static int vmmdevReqHandler_UnregisterSharedModule(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)2469 static int vmmdevReqHandler_UnregisterSharedModule(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 2420 2470 { 2421 2471 /* … … 2436 2486 * Forward the request to the VMM. 2437 2487 */ 2438 return PGMR3SharedModuleUnregister(PDMDevHlpGetVM(p This->pDevInsR3), pReq->szName, pReq->szVersion,2488 return PGMR3SharedModuleUnregister(PDMDevHlpGetVM(pDevIns), pReq->szName, pReq->szVersion, 2439 2489 pReq->GCBaseAddr, pReq->cbModule); 2440 2490 } … … 2444 2494 * 2445 2495 * @returns VBox status code that the guest should see. 2446 * @param p This The VMMDev instance data.2496 * @param pDevIns The device instance. 2447 2497 * @param pReqHdr The header of the request to handle. 2448 2498 */ 2449 static int vmmdevReqHandler_CheckSharedModules(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)2499 static int vmmdevReqHandler_CheckSharedModules(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 2450 2500 { 2451 2501 VMMDevSharedModuleCheckRequest *pReq = (VMMDevSharedModuleCheckRequest *)pReqHdr; 2452 2502 AssertMsgReturn(pReq->header.size == sizeof(VMMDevSharedModuleCheckRequest), 2453 2503 ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); 2454 return PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(p This->pDevInsR3));2504 return PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(pDevIns)); 2455 2505 } 2456 2506 … … 2459 2509 * 2460 2510 * @returns VBox status code that the guest should see. 2461 * @param pThis The VMMDevinstance data.2511 * @param pThisCC The VMMDev ring-3 instance data. 2462 2512 * @param pReqHdr The header of the request to handle. 2463 2513 */ 2464 static int vmmdevReqHandler_GetPageSharingStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)2514 static int vmmdevReqHandler_GetPageSharingStatus(PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr) 2465 2515 { 2466 2516 VMMDevPageSharingStatusRequest *pReq = (VMMDevPageSharingStatusRequest *)pReqHdr; … … 2469 2519 2470 2520 pReq->fEnabled = false; 2471 int rc = pThis ->pDrv->pfnIsPageFusionEnabled(pThis->pDrv, &pReq->fEnabled);2521 int rc = pThisCC->pDrv->pfnIsPageFusionEnabled(pThisCC->pDrv, &pReq->fEnabled); 2472 2522 if (RT_FAILURE(rc)) 2473 2523 pReq->fEnabled = false; … … 2480 2530 * 2481 2531 * @returns VBox status code that the guest should see. 2482 * @param p This The VMMDev instance data.2532 * @param pDevIns The device instance. 2483 2533 * @param pReqHdr The header of the request to handle. 2484 2534 */ 2485 static int vmmdevReqHandler_DebugIsPageShared(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)2535 static int vmmdevReqHandler_DebugIsPageShared(PPDMDEVINS pDevIns, VMMDevRequestHeader *pReqHdr) 2486 2536 { 2487 2537 VMMDevPageIsSharedRequest *pReq = (VMMDevPageIsSharedRequest *)pReqHdr; … … 2490 2540 2491 2541 # ifdef DEBUG 2492 return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(p This->pDevInsR3), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);2542 return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pDevIns), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags); 2493 2543 # else 2494 RT_NOREF 1(pThis);2544 RT_NOREF(pThis); 2495 2545 return VERR_NOT_IMPLEMENTED; 2496 2546 # endif … … 2504 2554 * 2505 2555 * @returns VBox status code that the guest should see. 2506 * @param pThis The VMMDev instance data. 2556 * @param pDevIns The device instance. 2557 * @param pThis The VMMDev shared instance data. 2507 2558 * @param pReqHdr Pointer to the request header. 2508 2559 */ 2509 static int vmmdevReqHandler_WriteCoreDump(P VMMDEV pThis, VMMDevRequestHeader *pReqHdr)2560 static int vmmdevReqHandler_WriteCoreDump(PPDMDEVINS pDevIns, PVMMDEV pThis, VMMDevRequestHeader *pReqHdr) 2510 2561 { 2511 2562 VMMDevReqWriteCoreDump *pReq = (VMMDevReqWriteCoreDump *)pReqHdr; … … 2550 2601 * Write the core file. 2551 2602 */ 2552 PUVM pUVM = PDMDevHlpGetUVM(p This->pDevInsR3);2603 PUVM pUVM = PDMDevHlpGetUVM(pDevIns); 2553 2604 return DBGFR3CoreWrite(pUVM, szCorePath, true /*fReplaceFile*/); 2554 2605 } … … 2558 2609 * Sets request status to VINF_HGCM_ASYNC_EXECUTE. 2559 2610 * 2611 * @param pDevIns The device instance. 2560 2612 * @param pThis The VMM device instance data. 2561 2613 * @param GCPhysReqHdr The guest physical address of the request. … … 2563 2615 * locked. 2564 2616 */ 2565 DECLINLINE(void) vmmdevReqHdrSetHgcmAsyncExecute(P VMMDEV pThis, RTGCPHYS GCPhysReqHdr, PVMMDEVREQLOCK pLock)2617 DECLINLINE(void) vmmdevReqHdrSetHgcmAsyncExecute(PPDMDEVINS pDevIns, RTGCPHYS GCPhysReqHdr, PVMMDEVREQLOCK pLock) 2566 2618 { 2567 2619 if (pLock) … … 2570 2622 { 2571 2623 int32_t rcReq = VINF_HGCM_ASYNC_EXECUTE; 2572 PDMDevHlpPhysWrite(p This->pDevInsR3, GCPhysReqHdr + RT_UOFFSETOF(VMMDevRequestHeader, rc), &rcReq, sizeof(rcReq));2624 PDMDevHlpPhysWrite(pDevIns, GCPhysReqHdr + RT_UOFFSETOF(VMMDevRequestHeader, rc), &rcReq, sizeof(rcReq)); 2573 2625 } 2574 2626 } … … 2585 2637 * 2586 2638 * @returns Port I/O handler exit code. 2587 * @param pThis The VMM device instance data. 2639 * @param pDevIns The device instance. 2640 * @param pThis The VMMDev shared instance data. 2641 * @param pThisCC The VMMDev ring-3 instance data. 2588 2642 * @param pReqHdr The request header (cached in host memory). 2589 2643 * @param GCPhysReqHdr The guest physical address of the request (for … … 2594 2648 * NULL). Set to NULL if HGCM takes lock ownership. 2595 2649 */ 2596 static int vmmdevReqDispatcher(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr, 2597 uint64_t tsArrival, uint32_t *pfPostOptimize, PVMMDEVREQLOCK *ppLock) 2650 static VBOXSTRICTRC vmmdevReqDispatcher(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, VMMDevRequestHeader *pReqHdr, 2651 RTGCPHYS GCPhysReqHdr, uint64_t tsArrival, uint32_t *pfPostOptimize, 2652 PVMMDEVREQLOCK *ppLock) 2598 2653 { 2599 2654 int rcRet = VINF_SUCCESS; … … 2603 2658 { 2604 2659 case VMMDevReq_ReportGuestInfo: 2605 pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo(p This, pReqHdr);2660 pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo(pDevIns, pThis, pThisCC, pReqHdr); 2606 2661 break; 2607 2662 2608 2663 case VMMDevReq_ReportGuestInfo2: 2609 pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo2(p This, pReqHdr);2664 pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo2(pDevIns, pThis, pThisCC, pReqHdr); 2610 2665 break; 2611 2666 2612 2667 case VMMDevReq_ReportGuestStatus: 2613 pReqHdr->rc = vmmdevReqHandler_ReportGuestStatus(pThis, p ReqHdr);2668 pReqHdr->rc = vmmdevReqHandler_ReportGuestStatus(pThis, pThisCC, pReqHdr); 2614 2669 break; 2615 2670 2616 2671 case VMMDevReq_ReportGuestUserState: 2617 pReqHdr->rc = vmmdevReqHandler_ReportGuestUserState(pThis , pReqHdr);2672 pReqHdr->rc = vmmdevReqHandler_ReportGuestUserState(pThisCC, pReqHdr); 2618 2673 break; 2619 2674 2620 2675 case VMMDevReq_ReportGuestCapabilities: 2621 pReqHdr->rc = vmmdevReqHandler_ReportGuestCapabilities(pThis, p ReqHdr);2676 pReqHdr->rc = vmmdevReqHandler_ReportGuestCapabilities(pThis, pThisCC, pReqHdr); 2622 2677 break; 2623 2678 2624 2679 case VMMDevReq_SetGuestCapabilities: 2625 pReqHdr->rc = vmmdevReqHandler_SetGuestCapabilities(pThis, p ReqHdr);2680 pReqHdr->rc = vmmdevReqHandler_SetGuestCapabilities(pThis, pThisCC, pReqHdr); 2626 2681 break; 2627 2682 2628 2683 case VMMDevReq_WriteCoreDump: 2629 pReqHdr->rc = vmmdevReqHandler_WriteCoreDump(p This, pReqHdr);2684 pReqHdr->rc = vmmdevReqHandler_WriteCoreDump(pDevIns, pThis, pReqHdr); 2630 2685 break; 2631 2686 … … 2635 2690 2636 2691 case VMMDevReq_SetMouseStatus: 2637 pReqHdr->rc = vmmdevReqHandler_SetMouseStatus(pThis, p ReqHdr);2692 pReqHdr->rc = vmmdevReqHandler_SetMouseStatus(pThis, pThisCC, pReqHdr); 2638 2693 break; 2639 2694 2640 2695 case VMMDevReq_SetPointerShape: 2641 pReqHdr->rc = vmmdevReqHandler_SetPointerShape(pThis, p ReqHdr);2696 pReqHdr->rc = vmmdevReqHandler_SetPointerShape(pThis, pThisCC, pReqHdr); 2642 2697 break; 2643 2698 2644 2699 case VMMDevReq_GetHostTime: 2645 pReqHdr->rc = vmmdevReqHandler_GetHostTime(p This, pReqHdr);2700 pReqHdr->rc = vmmdevReqHandler_GetHostTime(pDevIns, pThis, pReqHdr); 2646 2701 break; 2647 2702 2648 2703 case VMMDevReq_GetHypervisorInfo: 2649 pReqHdr->rc = vmmdevReqHandler_GetHypervisorInfo(p This, pReqHdr);2704 pReqHdr->rc = vmmdevReqHandler_GetHypervisorInfo(pDevIns, pReqHdr); 2650 2705 break; 2651 2706 2652 2707 case VMMDevReq_SetHypervisorInfo: 2653 pReqHdr->rc = vmmdevReqHandler_SetHypervisorInfo(p This, pReqHdr);2708 pReqHdr->rc = vmmdevReqHandler_SetHypervisorInfo(pDevIns, pReqHdr); 2654 2709 break; 2655 2710 2656 2711 case VMMDevReq_RegisterPatchMemory: 2657 pReqHdr->rc = vmmdevReqHandler_RegisterPatchMemory(p This, pReqHdr);2712 pReqHdr->rc = vmmdevReqHandler_RegisterPatchMemory(pDevIns, pReqHdr); 2658 2713 break; 2659 2714 2660 2715 case VMMDevReq_DeregisterPatchMemory: 2661 pReqHdr->rc = vmmdevReqHandler_DeregisterPatchMemory(p This, pReqHdr);2716 pReqHdr->rc = vmmdevReqHandler_DeregisterPatchMemory(pDevIns, pReqHdr); 2662 2717 break; 2663 2718 2664 2719 case VMMDevReq_SetPowerStatus: 2665 2720 { 2666 int rc = pReqHdr->rc = vmmdevReqHandler_SetPowerStatus(p This, pReqHdr);2721 int rc = pReqHdr->rc = vmmdevReqHandler_SetPowerStatus(pDevIns, pThis, pReqHdr); 2667 2722 if (rc != VINF_SUCCESS && RT_SUCCESS(rc)) 2668 2723 rcRet = rc; … … 2675 2730 2676 2731 case VMMDevReq_GetDisplayChangeRequest2: 2677 pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequest2(p This, pReqHdr);2732 pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequest2(pDevIns, pThis, pThisCC, pReqHdr); 2678 2733 break; 2679 2734 2680 2735 case VMMDevReq_GetDisplayChangeRequestEx: 2681 pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequestEx(p This, pReqHdr);2736 pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequestEx(pDevIns, pThis, pThisCC, pReqHdr); 2682 2737 break; 2683 2738 … … 2687 2742 2688 2743 case VMMDevReq_VideoModeSupported: 2689 pReqHdr->rc = vmmdevReqHandler_VideoModeSupported(pThis , pReqHdr);2744 pReqHdr->rc = vmmdevReqHandler_VideoModeSupported(pThisCC, pReqHdr); 2690 2745 break; 2691 2746 2692 2747 case VMMDevReq_VideoModeSupported2: 2693 pReqHdr->rc = vmmdevReqHandler_VideoModeSupported2(pThis , pReqHdr);2748 pReqHdr->rc = vmmdevReqHandler_VideoModeSupported2(pThisCC, pReqHdr); 2694 2749 break; 2695 2750 2696 2751 case VMMDevReq_GetHeightReduction: 2697 pReqHdr->rc = vmmdevReqHandler_GetHeightReduction(pThis , pReqHdr);2752 pReqHdr->rc = vmmdevReqHandler_GetHeightReduction(pThisCC, pReqHdr); 2698 2753 break; 2699 2754 2700 2755 case VMMDevReq_AcknowledgeEvents: 2701 pReqHdr->rc = vmmdevReqHandler_AcknowledgeEvents(p This, pReqHdr);2756 pReqHdr->rc = vmmdevReqHandler_AcknowledgeEvents(pDevIns, pThis, pThisCC, pReqHdr); 2702 2757 break; 2703 2758 2704 2759 case VMMDevReq_CtlGuestFilterMask: 2705 pReqHdr->rc = vmmdevReqHandler_CtlGuestFilterMask(p This, pReqHdr);2760 pReqHdr->rc = vmmdevReqHandler_CtlGuestFilterMask(pDevIns, pThis, pThisCC, pReqHdr); 2706 2761 break; 2707 2762 2708 2763 #ifdef VBOX_WITH_HGCM 2709 2764 case VMMDevReq_HGCMConnect: 2710 vmmdevReqHdrSetHgcmAsyncExecute(p This, GCPhysReqHdr, *ppLock);2711 pReqHdr->rc = vmmdevReqHandler_HGCMConnect(p This, pReqHdr, GCPhysReqHdr);2765 vmmdevReqHdrSetHgcmAsyncExecute(pDevIns, GCPhysReqHdr, *ppLock); 2766 pReqHdr->rc = vmmdevReqHandler_HGCMConnect(pDevIns, pThis, pThisCC, pReqHdr, GCPhysReqHdr); 2712 2767 Assert(pReqHdr->rc == VINF_HGCM_ASYNC_EXECUTE || RT_FAILURE_NP(pReqHdr->rc)); 2713 2768 if (RT_SUCCESS(pReqHdr->rc)) … … 2716 2771 2717 2772 case VMMDevReq_HGCMDisconnect: 2718 vmmdevReqHdrSetHgcmAsyncExecute(p This, GCPhysReqHdr, *ppLock);2719 pReqHdr->rc = vmmdevReqHandler_HGCMDisconnect(p This, pReqHdr, GCPhysReqHdr);2773 vmmdevReqHdrSetHgcmAsyncExecute(pDevIns, GCPhysReqHdr, *ppLock); 2774 pReqHdr->rc = vmmdevReqHandler_HGCMDisconnect(pDevIns, pThis, pThisCC, pReqHdr, GCPhysReqHdr); 2720 2775 Assert(pReqHdr->rc == VINF_HGCM_ASYNC_EXECUTE || RT_FAILURE_NP(pReqHdr->rc)); 2721 2776 if (RT_SUCCESS(pReqHdr->rc)) … … 2727 2782 # endif 2728 2783 case VMMDevReq_HGCMCall32: 2729 vmmdevReqHdrSetHgcmAsyncExecute(p This, GCPhysReqHdr, *ppLock);2730 pReqHdr->rc = vmmdevReqHandler_HGCMCall(p This, pReqHdr, GCPhysReqHdr, tsArrival, ppLock);2784 vmmdevReqHdrSetHgcmAsyncExecute(pDevIns, GCPhysReqHdr, *ppLock); 2785 pReqHdr->rc = vmmdevReqHandler_HGCMCall(pDevIns, pThis, pThisCC, pReqHdr, GCPhysReqHdr, tsArrival, ppLock); 2731 2786 Assert(pReqHdr->rc == VINF_HGCM_ASYNC_EXECUTE || RT_FAILURE_NP(pReqHdr->rc)); 2732 2787 if (RT_SUCCESS(pReqHdr->rc)) … … 2735 2790 2736 2791 case VMMDevReq_HGCMCancel: 2737 pReqHdr->rc = vmmdevReqHandler_HGCMCancel(pThis , pReqHdr, GCPhysReqHdr);2792 pReqHdr->rc = vmmdevReqHandler_HGCMCancel(pThisCC, pReqHdr, GCPhysReqHdr); 2738 2793 break; 2739 2794 2740 2795 case VMMDevReq_HGCMCancel2: 2741 pReqHdr->rc = vmmdevReqHandler_HGCMCancel2(pThis , pReqHdr);2796 pReqHdr->rc = vmmdevReqHandler_HGCMCancel2(pThisCC, pReqHdr); 2742 2797 break; 2743 2798 #endif /* VBOX_WITH_HGCM */ 2744 2799 2745 2800 case VMMDevReq_VideoAccelEnable: 2746 pReqHdr->rc = vmmdevReqHandler_VideoAccelEnable(pThis, p ReqHdr);2801 pReqHdr->rc = vmmdevReqHandler_VideoAccelEnable(pThis, pThisCC, pReqHdr); 2747 2802 break; 2748 2803 2749 2804 case VMMDevReq_VideoAccelFlush: 2750 pReqHdr->rc = vmmdevReqHandler_VideoAccelFlush(pThis , pReqHdr);2805 pReqHdr->rc = vmmdevReqHandler_VideoAccelFlush(pThisCC, pReqHdr); 2751 2806 break; 2752 2807 2753 2808 case VMMDevReq_VideoSetVisibleRegion: 2754 pReqHdr->rc = vmmdevReqHandler_VideoSetVisibleRegion(pThis , pReqHdr);2809 pReqHdr->rc = vmmdevReqHandler_VideoSetVisibleRegion(pThisCC, pReqHdr); 2755 2810 break; 2756 2811 … … 2768 2823 2769 2824 case VMMDevReq_ChangeMemBalloon: 2770 pReqHdr->rc = vmmdevReqHandler_ChangeMemBalloon(p This, pReqHdr);2825 pReqHdr->rc = vmmdevReqHandler_ChangeMemBalloon(pDevIns, pThis, pReqHdr); 2771 2826 break; 2772 2827 … … 2776 2831 2777 2832 case VMMDevReq_ReportGuestStats: 2778 pReqHdr->rc = vmmdevReqHandler_ReportGuestStats(pThis , pReqHdr);2833 pReqHdr->rc = vmmdevReqHandler_ReportGuestStats(pThisCC, pReqHdr); 2779 2834 break; 2780 2835 2781 2836 case VMMDevReq_QueryCredentials: 2782 pReqHdr->rc = vmmdevReqHandler_QueryCredentials(pThis, p ReqHdr);2837 pReqHdr->rc = vmmdevReqHandler_QueryCredentials(pThis, pThisCC, pReqHdr); 2783 2838 break; 2784 2839 2785 2840 case VMMDevReq_ReportCredentialsJudgement: 2786 pReqHdr->rc = vmmdevReqHandler_ReportCredentialsJudgement(pThis , pReqHdr);2841 pReqHdr->rc = vmmdevReqHandler_ReportCredentialsJudgement(pThisCC, pReqHdr); 2787 2842 break; 2788 2843 … … 2801 2856 #ifdef VBOX_WITH_PAGE_SHARING 2802 2857 case VMMDevReq_RegisterSharedModule: 2803 pReqHdr->rc = vmmdevReqHandler_RegisterSharedModule(p This, pReqHdr);2858 pReqHdr->rc = vmmdevReqHandler_RegisterSharedModule(pDevIns, pReqHdr); 2804 2859 break; 2805 2860 2806 2861 case VMMDevReq_UnregisterSharedModule: 2807 pReqHdr->rc = vmmdevReqHandler_UnregisterSharedModule(p This, pReqHdr);2862 pReqHdr->rc = vmmdevReqHandler_UnregisterSharedModule(pDevIns, pReqHdr); 2808 2863 break; 2809 2864 2810 2865 case VMMDevReq_CheckSharedModules: 2811 pReqHdr->rc = vmmdevReqHandler_CheckSharedModules(p This, pReqHdr);2866 pReqHdr->rc = vmmdevReqHandler_CheckSharedModules(pDevIns, pReqHdr); 2812 2867 break; 2813 2868 2814 2869 case VMMDevReq_GetPageSharingStatus: 2815 pReqHdr->rc = vmmdevReqHandler_GetPageSharingStatus(pThis , pReqHdr);2870 pReqHdr->rc = vmmdevReqHandler_GetPageSharingStatus(pThisCC, pReqHdr); 2816 2871 break; 2817 2872 2818 2873 case VMMDevReq_DebugIsPageShared: 2819 pReqHdr->rc = vmmdevReqHandler_DebugIsPageShared(p This, pReqHdr);2874 pReqHdr->rc = vmmdevReqHandler_DebugIsPageShared(pDevIns, pReqHdr); 2820 2875 break; 2821 2876 … … 2845 2900 2846 2901 case VMMDevReq_GuestHeartbeat: 2847 pReqHdr->rc = vmmDevReqHandler_GuestHeartbeat(p This);2902 pReqHdr->rc = vmmDevReqHandler_GuestHeartbeat(pDevIns, pThis); 2848 2903 break; 2849 2904 2850 2905 case VMMDevReq_HeartbeatConfigure: 2851 pReqHdr->rc = vmmDevReqHandler_HeartbeatConfigure(p This, pReqHdr);2906 pReqHdr->rc = vmmDevReqHandler_HeartbeatConfigure(pDevIns, pThis, pReqHdr); 2852 2907 break; 2853 2908 2854 2909 case VMMDevReq_NtBugCheck: 2855 pReqHdr->rc = vmmDevReqHandler_NtBugCheck(p This, pReqHdr);2910 pReqHdr->rc = vmmDevReqHandler_NtBugCheck(pDevIns, pReqHdr); 2856 2911 break; 2857 2912 … … 2868 2923 2869 2924 /** 2870 * @callback_method_impl{FNIOMIOPORT OUT,2925 * @callback_method_impl{FNIOMIOPORTNEWOUT, 2871 2926 * Port I/O write andler for the generic request interface.} 2872 2927 */ 2873 static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 2928 static DECLCALLBACK(VBOXSTRICTRC) 2929 vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 2874 2930 { 2875 2931 uint64_t tsArrival; 2876 2932 STAM_GET_TS(tsArrival); 2877 2933 2878 RT_NOREF2(Port, cb); 2879 PVMMDEV pThis = (PVMMDEV)pvUser; 2934 RT_NOREF(offPort, cb, pvUser); 2880 2935 2881 2936 /* … … 2904 2959 Log2(("VMMDev request issued: %d\n", requestHeader.requestType)); 2905 2960 2906 intrcRet = VINF_SUCCESS;2961 VBOXSTRICTRC rcRet = VINF_SUCCESS; 2907 2962 /* Check that is doesn't exceed the max packet size. */ 2908 2963 if (requestHeader.size <= VMMDEV_MAX_VMMDEVREQ_SIZE) 2909 2964 { 2965 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 2966 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 2967 2910 2968 /* 2911 2969 * We require the GAs to report it's information before we let it have … … 2933 2991 VMMDevRequestHeader *pRequestHeader = NULL; 2934 2992 if ( requestHeader.size <= _4K 2935 && iCpu < RT_ELEMENTS(pThis ->apReqBufs))2993 && iCpu < RT_ELEMENTS(pThisCC->apReqBufs)) 2936 2994 { 2937 pRequestHeader = pThis ->apReqBufs[iCpu];2995 pRequestHeader = pThisCC->apReqBufs[iCpu]; 2938 2996 if (pRequestHeader) 2939 2997 { /* likely */ } 2940 2998 else 2941 pThis ->apReqBufs[iCpu] = pRequestHeader = (VMMDevRequestHeader *)RTMemPageAlloc(_4K);2999 pThisCC->apReqBufs[iCpu] = pRequestHeader = (VMMDevRequestHeader *)RTMemPageAlloc(_4K); 2942 3000 } 2943 3001 else 2944 3002 { 2945 3003 Assert(iCpu != NIL_VMCPUID); 2946 STAM_REL_COUNTER_INC(&pThis ->StatReqBufAllocs);3004 STAM_REL_COUNTER_INC(&pThisCC->StatReqBufAllocs); 2947 3005 pRequestHeaderFree = pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(RT_MAX(requestHeader.size, 512)); 2948 3006 } … … 2978 3036 */ 2979 3037 uint32_t fPostOptimize = 0; 2980 PDM CritSectEnter(&pThis->CritSect, VERR_IGNORED);2981 rcRet = vmmdevReqDispatcher(p This, pRequestHeader, u32, tsArrival, &fPostOptimize, &pLock);2982 PDM CritSectLeave(&pThis->CritSect);3038 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3039 rcRet = vmmdevReqDispatcher(pDevIns, pThis, pThisCC, pRequestHeader, u32, tsArrival, &fPostOptimize, &pLock); 3040 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 2983 3041 2984 3042 /* … … 3031 3089 * that can be handled w/o going to ring-3.} 3032 3090 */ 3033 PDMBOTHCBDECL(int) vmmdevFastRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 3091 static DECLCALLBACK(VBOXSTRICTRC) 3092 vmmdevFastRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 3034 3093 { 3035 3094 #ifndef IN_RING3 3036 3095 # if 0 /* This functionality is offered through reading the port (vmmdevFastRequestIrqAck). Leaving it here for later. */ 3037 PVMMDEV pThis = (PVMMDEV)pvUser; 3038 Assert(PDMINS_2_DATA(pDevIns, PVMMDEV) == pThis); 3039 RT_NOREF2(Port, cb); 3096 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3097 RT_NOREF(pvUser, Port, cb); 3040 3098 3041 3099 /* … … 3067 3125 && uReq.Hdr.size == sizeof(uReq.Ack) 3068 3126 && cbToRead == sizeof(uReq.Ack) 3069 && pThis ->CTX_SUFF(pVMMDevRAM) != NULL)3127 && pThisCC->CTX_SUFF(pVMMDevRAM) != NULL) 3070 3128 ) 3071 3129 { … … 3075 3133 * Try grab the critical section. 3076 3134 */ 3077 int rc2 = PDM CritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_WRITE);3135 int rc2 = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VINF_IOM_R3_IOPORT_WRITE); 3078 3136 if (rc2 == VINF_SUCCESS) 3079 3137 { … … 3084 3142 3085 3143 rcStrict = PDMDevHlpPhysWrite(pDevIns, u32, &uReq, uReq.Hdr.size); 3086 PDM CritSectLeave(&pThis->CritSect);3144 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3087 3145 if (rcStrict == VINF_SUCCESS) 3088 3146 { /* likely */ } … … 3100 3158 { 3101 3159 Log(("vmmdevFastRequestHandler: size=%#x version=%#x requestType=%d (pVMMDevRAM=%p) -> R3\n", 3102 uReq.Hdr.size, uReq.Hdr.version, uReq.Hdr.requestType, pThis ->CTX_SUFF(pVMMDevRAM) ));3160 uReq.Hdr.size, uReq.Hdr.version, uReq.Hdr.requestType, pThisCC->CTX_SUFF(pVMMDevRAM) )); 3103 3161 rcStrict = VINF_IOM_R3_IOPORT_WRITE; 3104 3162 } … … 3115 3173 return VBOXSTRICTRC_VAL(rcStrict); 3116 3174 # else 3117 RT_NOREF(pDevIns, pvUser, Port, u32, cb);3175 RT_NOREF(pDevIns, pvUser, offPort, u32, cb); 3118 3176 return VINF_IOM_R3_IOPORT_WRITE; 3119 3177 # endif 3120 3178 3121 3179 #else /* IN_RING3 */ 3122 return vmmdevRequestHandler(pDevIns, pvUser, Port, u32, cb);3180 return vmmdevRequestHandler(pDevIns, pvUser, offPort, u32, cb); 3123 3181 #endif /* IN_RING3 */ 3124 3182 } … … 3126 3184 3127 3185 /** 3128 * @callback_method_impl{FNIOMIOPORT IN,3186 * @callback_method_impl{FNIOMIOPORTNEWIN, 3129 3187 * Port I/O read handler for IRQ acknowledging and getting pending events (same 3130 3188 * as VMMDevReq_AcknowledgeEvents - just faster).} 3131 3189 */ 3132 PDMBOTHCBDECL(int) vmmdevFastRequestIrqAck(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 3133 { 3134 PVMMDEV pThis = (PVMMDEV)pvUser; 3135 Assert(PDMINS_2_DATA(pDevIns, PVMMDEV) == pThis); 3136 RT_NOREF(Port); 3190 static DECLCALLBACK(VBOXSTRICTRC) 3191 vmmdevFastRequestIrqAck(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 3192 { 3193 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3194 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 3195 Assert(PDMDEVINS_2_DATA(pDevIns, PVMMDEV) == pThis); 3196 RT_NOREF(pvUser, offPort); 3137 3197 3138 3198 /* Only 32-bit accesses. */ … … 3142 3202 VBOXSTRICTRC rcStrict; 3143 3203 #ifndef IN_RING3 3144 if (pThis ->CTX_SUFF(pVMMDevRAM) != NULL)3204 if (pThisCC->CTX_SUFF(pVMMDevRAM) != NULL) 3145 3205 #endif 3146 3206 { 3147 3207 /* Enter critical section and check that the additions has been properly 3148 3208 initialized and that we're not in legacy v1.3 device mode. */ 3149 rcStrict = PDM CritSectEnter(&pThis->CritSect, VINF_IOM_R3_IOPORT_READ);3209 rcStrict = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VINF_IOM_R3_IOPORT_READ); 3150 3210 if (rcStrict == VINF_SUCCESS) 3151 3211 { … … 3169 3229 3170 3230 pThis->fHostEventFlags &= ~pThis->fGuestFilterMask; 3171 pThis ->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false;3231 pThisCC->CTX_SUFF(pVMMDevRAM)->V.V1_04.fHaveEvents = false; 3172 3232 3173 3233 PDMDevHlpPCISetIrqNoWait(pDevIns, 0, 0); … … 3180 3240 } 3181 3241 3182 PDM CritSectLeave(&pThis->CritSect);3242 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3183 3243 } 3184 3244 } … … 3187 3247 rcStrict = VINF_IOM_R3_IOPORT_READ; 3188 3248 #endif 3189 return VBOXSTRICTRC_VAL(rcStrict);3249 return rcStrict; 3190 3250 } 3191 3251 … … 3195 3255 3196 3256 /* -=-=-=-=-=- PCI Device -=-=-=-=-=- */ 3197 3198 3199 /**3200 * @callback_method_impl{FNPCIIOREGIONMAP,MMIO/MMIO2 regions}3201 */3202 static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,3203 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)3204 {3205 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);3206 LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));3207 Assert(pPciDev == pDevIns->apPciDevs[0]);3208 RT_NOREF(cb, pPciDev);3209 3210 int rc;3211 3212 if (iRegion == 1)3213 {3214 AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM, VERR_INTERNAL_ERROR);3215 Assert(pThis->pVMMDevRAMR3 != NULL);3216 if (GCPhysAddress != NIL_RTGCPHYS)3217 {3218 /*3219 * Map the MMIO2 memory.3220 */3221 pThis->GCPhysVMMDevRAM = GCPhysAddress;3222 Assert(pThis->GCPhysVMMDevRAM == GCPhysAddress);3223 rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);3224 }3225 else3226 {3227 /*3228 * It is about to be unmapped, just clean up.3229 */3230 pThis->GCPhysVMMDevRAM = NIL_RTGCPHYS32;3231 rc = VINF_SUCCESS;3232 }3233 }3234 else if (iRegion == 2)3235 {3236 AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);3237 Assert(pThis->pVMMDevHeapR3 != NULL);3238 if (GCPhysAddress != NIL_RTGCPHYS)3239 {3240 /*3241 * Map the MMIO2 memory.3242 */3243 pThis->GCPhysVMMDevHeap = GCPhysAddress;3244 Assert(pThis->GCPhysVMMDevHeap == GCPhysAddress);3245 rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);3246 if (RT_SUCCESS(rc))3247 rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, GCPhysAddress, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);3248 }3249 else3250 {3251 /*3252 * It is about to be unmapped, just clean up.3253 */3254 PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);3255 pThis->GCPhysVMMDevHeap = NIL_RTGCPHYS32;3256 rc = VINF_SUCCESS;3257 }3258 }3259 else3260 {3261 AssertMsgFailed(("%d\n", iRegion));3262 rc = VERR_INVALID_PARAMETER;3263 }3264 3265 return rc;3266 }3267 3268 3257 3269 3258 /** … … 3273 3262 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 3274 3263 { 3275 PVMMDEV pThis = PDM INS_2_DATA(pDevIns, PVMMDEV);3264 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3276 3265 LogFlow(("vmmdevIOPortRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType)); 3277 3266 RT_NOREF(pPciDev, iRegion, cb, enmType); … … 3282 3271 AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress)); 3283 3272 3284 /* 3285 * Register our port IO handlers. 3286 */ 3287 int rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1, 3288 pThis, vmmdevRequestHandler, NULL, NULL, NULL, "VMMDev Request Handler"); 3289 AssertLogRelRCReturn(rc, rc); 3290 3291 /* The fast one: */ 3292 rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST, 1, 3293 pThis, vmmdevFastRequestHandler, vmmdevFastRequestIrqAck, NULL, NULL, "VMMDev Fast R0/RC Requests"); 3294 AssertLogRelRCReturn(rc, rc); 3295 if (pThis->fRZEnabled) 3296 { 3297 rc = PDMDevHlpIOPortRegisterR0(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST, 1, 3298 PDMINS_2_DATA_R0PTR(pDevIns), "vmmdevFastRequestHandler", "vmmdevFastRequestIrqAck", 3299 NULL, NULL, "VMMDev Fast R0/RC Requests"); 3273 3274 int rc; 3275 if (GCPhysAddress != NIL_RTGCPHYS) 3276 { 3277 AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress)); 3278 3279 rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortReq, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST); 3300 3280 AssertLogRelRCReturn(rc, rc); 3301 rc = PDMDevHlpIOPortRegisterRC(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST, 1, 3302 PDMINS_2_DATA_RCPTR(pDevIns), "vmmdevFastRequestHandler", "vmmdevFastRequestIrqAck", 3303 NULL, NULL, "VMMDev Fast R0/RC Requests"); 3281 3282 rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortFast, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST_FAST); 3304 3283 AssertLogRelRCReturn(rc, rc); 3305 3284 } 3306 3285 else 3286 { 3287 rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortReq); 3288 AssertLogRelRCReturn(rc, rc); 3289 3290 rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortFast); 3291 AssertLogRelRCReturn(rc, rc); 3292 } 3307 3293 return rc; 3308 3294 } 3309 3295 3310 3296 3297 /** 3298 * @callback_method_impl{FNPCIIOREGIONMAP,VMMDev heap (MMIO2)} 3299 */ 3300 static DECLCALLBACK(int) vmmdevMmio2HeapRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion, 3301 RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType) 3302 { 3303 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 3304 LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType)); 3305 RT_NOREF(cb, pPciDev); 3306 3307 Assert(pPciDev == pDevIns->apPciDevs[0]); 3308 AssertReturn(iRegion == 2, VERR_INTERNAL_ERROR_2); 3309 AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR_3); 3310 Assert(pThisCC->pVMMDevHeapR3 != NULL); 3311 3312 int rc; 3313 if (GCPhysAddress != NIL_RTGCPHYS) 3314 { 3315 rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, GCPhysAddress, pThisCC->pVMMDevHeapR3, VMMDEV_HEAP_SIZE); 3316 AssertRC(rc); 3317 } 3318 else 3319 { 3320 rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThisCC->pVMMDevHeapR3, VMMDEV_HEAP_SIZE); 3321 AssertRCStmt(rc, rc = VINF_SUCCESS); 3322 } 3323 3324 return rc; 3325 } 3326 3311 3327 3312 3328 /* -=-=-=-=-=- Backdoor Logging and Time Sync. -=-=-=-=-=- */ 3313 3329 3314 3330 /** 3315 * @callback_method_impl{FNIOMIOPORTOUT, Backdoor Logging.} 3316 */ 3317 static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 3318 { 3319 RT_NOREF1(pvUser); 3320 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 3321 3322 if (!pThis->fBackdoorLogDisabled && cb == 1 && Port == RTLOG_DEBUG_PORT) 3331 * @callback_method_impl{FNIOMIOPORTNEWOUT, Backdoor Logging.} 3332 */ 3333 static DECLCALLBACK(VBOXSTRICTRC) 3334 vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 3335 { 3336 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3337 RT_NOREF(pvUser, offPort); 3338 Assert(offPort == 0); 3339 3340 if (!pThis->fBackdoorLogDisabled && cb == 1) 3323 3341 { 3324 3342 … … 3361 3379 3362 3380 /** 3363 * @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.} 3364 */ 3365 static DECLCALLBACK(int) vmmdevAltTimeSyncWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 3366 { 3367 RT_NOREF2(pvUser, Port); 3368 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 3381 * @callback_method_impl{FNIOMIOPORTNEWOUT, Alternative time synchronization.} 3382 */ 3383 static DECLCALLBACK(VBOXSTRICTRC) 3384 vmmdevAltTimeSyncWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 3385 { 3386 RT_NOREF(pvUser, offPort); 3387 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3369 3388 if (cb == 4) 3370 3389 { … … 3391 3410 * @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.} 3392 3411 */ 3393 static DECLCALLBACK(int) vmmdevAltTimeSyncRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb) 3394 { 3395 RT_NOREF2(pvUser, Port); 3396 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 3397 int rc; 3412 static DECLCALLBACK(VBOXSTRICTRC) 3413 vmmdevAltTimeSyncRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 3414 { 3415 RT_NOREF(pvUser, offPort); 3416 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3417 VBOXSTRICTRC rc; 3398 3418 if (cb == 4) 3399 3419 { … … 3427 3447 static DECLCALLBACK(void *) vmmdevPortQueryInterface(PPDMIBASE pInterface, const char *pszIID) 3428 3448 { 3429 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IBase);3430 3431 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis ->IBase);3432 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThis ->IPort);3449 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IBase); 3450 3451 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase); 3452 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThisCC->IPort); 3433 3453 #ifdef VBOX_WITH_HGCM 3434 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThis ->IHGCMPort);3454 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThisCC->IHGCMPort); 3435 3455 #endif 3436 3456 /* Currently only for shared folders. */ 3437 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis ->SharedFolders.ILeds);3457 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThisCC->SharedFolders.ILeds); 3438 3458 return NULL; 3439 3459 } … … 3452 3472 static DECLCALLBACK(int) vmmdevQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 3453 3473 { 3454 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, SharedFolders.ILeds);3474 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, SharedFolders.ILeds); 3455 3475 if (iLUN == 0) /* LUN 0 is shared folders */ 3456 3476 { 3457 *ppLed = &pThis ->SharedFolders.Led;3477 *ppLed = &pThisCC->SharedFolders.Led; 3458 3478 return VINF_SUCCESS; 3459 3479 } … … 3469 3489 static DECLCALLBACK(int) vmmdevIPort_QueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t *pxAbs, int32_t *pyAbs) 3470 3490 { 3471 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3491 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3492 PVMMDEV pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV); 3472 3493 3473 3494 /** @todo at the first sign of trouble in this area, just enter the critsect. … … 3488 3509 static DECLCALLBACK(int) vmmdevIPort_SetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t xAbs, int32_t yAbs) 3489 3510 { 3490 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3491 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3511 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3512 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3513 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3514 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3492 3515 3493 3516 if ( pThis->xMouseAbs != xAbs … … 3497 3520 pThis->xMouseAbs = xAbs; 3498 3521 pThis->yMouseAbs = yAbs; 3499 VMMDevNotifyGuest(p This, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);3500 } 3501 3502 PDM CritSectLeave(&pThis->CritSect);3522 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_MOUSE_POSITION_CHANGED); 3523 } 3524 3525 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3503 3526 return VINF_SUCCESS; 3504 3527 } … … 3509 3532 static DECLCALLBACK(int) vmmdevIPort_QueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pfCapabilities) 3510 3533 { 3511 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3534 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3535 PVMMDEV pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV); 3512 3536 AssertPtrReturn(pfCapabilities, VERR_INVALID_PARAMETER); 3513 3537 … … 3522 3546 vmmdevIPort_UpdateMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved) 3523 3547 { 3524 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3525 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3548 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3549 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3550 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3551 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3526 3552 3527 3553 uint32_t fOldCaps = pThis->fMouseCapabilities; … … 3535 3561 3536 3562 if (fNotify) 3537 VMMDevNotifyGuest(p This, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);3538 3539 PDM CritSectLeave(&pThis->CritSect);3563 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED); 3564 3565 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3540 3566 return VINF_SUCCESS; 3541 3567 } … … 3577 3603 vmmdevIPort_RequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t cDisplays, VMMDevDisplayDef const *paDisplays, bool fForce, bool fMayNotify) 3578 3604 { 3579 int rc = VINF_SUCCESS; 3580 3581 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3582 bool fNotifyGuest = false; 3583 3584 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3605 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3606 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3607 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3608 int rc = VINF_SUCCESS; 3609 bool fNotifyGuest = false; 3610 3611 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3585 3612 3586 3613 uint32_t i; … … 3632 3659 3633 3660 /* IRQ so the guest knows what's going on */ 3634 VMMDevNotifyGuest(p This, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);3661 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST); 3635 3662 } 3636 3663 } 3637 3664 3638 PDM CritSectLeave(&pThis->CritSect);3665 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3639 3666 return rc; 3640 3667 } … … 3645 3672 static DECLCALLBACK(int) vmmdevIPort_RequestSeamlessChange(PPDMIVMMDEVPORT pInterface, bool fEnabled) 3646 3673 { 3647 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3648 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3674 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3675 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3676 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3677 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3649 3678 3650 3679 /* Verify that the new resolution is different and that guest does not yet know about it. */ … … 3659 3688 3660 3689 /* IRQ so the guest knows what's going on */ 3661 VMMDevNotifyGuest(p This, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);3662 } 3663 3664 PDM CritSectLeave(&pThis->CritSect);3690 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST); 3691 } 3692 3693 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3665 3694 return VINF_SUCCESS; 3666 3695 } … … 3671 3700 static DECLCALLBACK(int) vmmdevIPort_SetMemoryBalloon(PPDMIVMMDEVPORT pInterface, uint32_t cMbBalloon) 3672 3701 { 3673 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3674 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3702 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3703 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3704 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3705 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3675 3706 3676 3707 /* Verify that the new resolution is different and that guest does not yet know about it. */ … … 3682 3713 3683 3714 /* IRQ so the guest knows what's going on */ 3684 VMMDevNotifyGuest(p This, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);3685 } 3686 3687 PDM CritSectLeave(&pThis->CritSect);3715 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST); 3716 } 3717 3718 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3688 3719 return VINF_SUCCESS; 3689 3720 } … … 3694 3725 static DECLCALLBACK(int) vmmdevIPort_VRDPChange(PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t uVRDPExperienceLevel) 3695 3726 { 3696 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3697 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3727 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3728 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3729 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3730 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3698 3731 3699 3732 bool fSame = (pThis->fVRDPEnabled == fVRDPEnabled); … … 3706 3739 pThis->uVRDPExperienceLevel = uVRDPExperienceLevel; 3707 3740 3708 VMMDevNotifyGuest(p This, VMMDEV_EVENT_VRDP);3709 } 3710 3711 PDM CritSectLeave(&pThis->CritSect);3741 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_VRDP); 3742 } 3743 3744 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3712 3745 return VINF_SUCCESS; 3713 3746 } … … 3718 3751 static DECLCALLBACK(int) vmmdevIPort_SetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t cSecsStatInterval) 3719 3752 { 3720 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3721 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3753 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3754 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3755 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3756 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3722 3757 3723 3758 /* Verify that the new resolution is different and that guest does not yet know about it. */ … … 3732 3767 3733 3768 /* IRQ so the guest knows what's going on */ 3734 VMMDevNotifyGuest(p This, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);3735 } 3736 3737 PDM CritSectLeave(&pThis->CritSect);3769 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST); 3770 } 3771 3772 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3738 3773 return VINF_SUCCESS; 3739 3774 } … … 3745 3780 const char *pszPassword, const char *pszDomain, uint32_t fFlags) 3746 3781 { 3747 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3782 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3783 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3784 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3785 3748 3786 AssertReturn(fFlags & (VMMDEV_SETCREDENTIALS_GUESTLOGON | VMMDEV_SETCREDENTIALS_JUDGE), VERR_INVALID_PARAMETER); 3749 3787 size_t const cchUsername = strlen(pszUsername); … … 3754 3792 AssertReturn(cchDomain < VMMDEV_CREDENTIALS_SZ_SIZE, VERR_BUFFER_OVERFLOW); 3755 3793 3756 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3794 VMMDEVCREDS *pCredentials = pThisCC->pCredentials; 3795 AssertPtrReturn(pCredentials, VERR_NOT_SUPPORTED); 3796 3797 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3757 3798 3758 3799 /* … … 3762 3803 { 3763 3804 /* memorize the data */ 3764 memcpy(p This->pCredentials->Logon.szUserName, pszUsername, cchUsername);3765 pThis ->pCredentials->Logon.szUserName[cchUsername] = '\0';3766 memcpy(p This->pCredentials->Logon.szPassword, pszPassword, cchPassword);3767 p This->pCredentials->Logon.szPassword[cchPassword] = '\0';3768 memcpy(p This->pCredentials->Logon.szDomain, pszDomain, cchDomain);3769 p This->pCredentials->Logon.szDomain[cchDomain] = '\0';3770 p This->pCredentials->Logon.fAllowInteractiveLogon = !(fFlags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON);3805 memcpy(pCredentials->Logon.szUserName, pszUsername, cchUsername); 3806 pThisCC->pCredentials->Logon.szUserName[cchUsername] = '\0'; 3807 memcpy(pCredentials->Logon.szPassword, pszPassword, cchPassword); 3808 pCredentials->Logon.szPassword[cchPassword] = '\0'; 3809 memcpy(pCredentials->Logon.szDomain, pszDomain, cchDomain); 3810 pCredentials->Logon.szDomain[cchDomain] = '\0'; 3811 pCredentials->Logon.fAllowInteractiveLogon = !(fFlags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON); 3771 3812 } 3772 3813 /* … … 3776 3817 { 3777 3818 /* memorize the data */ 3778 memcpy(p This->pCredentials->Judge.szUserName, pszUsername, cchUsername);3779 p This->pCredentials->Judge.szUserName[cchUsername] = '\0';3780 memcpy(p This->pCredentials->Judge.szPassword, pszPassword, cchPassword);3781 p This->pCredentials->Judge.szPassword[cchPassword] = '\0';3782 memcpy(p This->pCredentials->Judge.szDomain, pszDomain, cchDomain);3783 p This->pCredentials->Judge.szDomain[cchDomain] = '\0';3784 3785 VMMDevNotifyGuest(p This, VMMDEV_EVENT_JUDGE_CREDENTIALS);3786 } 3787 3788 PDM CritSectLeave(&pThis->CritSect);3819 memcpy(pCredentials->Judge.szUserName, pszUsername, cchUsername); 3820 pCredentials->Judge.szUserName[cchUsername] = '\0'; 3821 memcpy(pCredentials->Judge.szPassword, pszPassword, cchPassword); 3822 pCredentials->Judge.szPassword[cchPassword] = '\0'; 3823 memcpy(pCredentials->Judge.szDomain, pszDomain, cchDomain); 3824 pCredentials->Judge.szDomain[cchDomain] = '\0'; 3825 3826 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_JUDGE_CREDENTIALS); 3827 } 3828 3829 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3789 3830 return VINF_SUCCESS; 3790 3831 } … … 3798 3839 static DECLCALLBACK(void) vmmdevIPort_VBVAChange(PPDMIVMMDEVPORT pInterface, bool fEnabled) 3799 3840 { 3800 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3841 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3842 PVMMDEV pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV); 3801 3843 Log(("vmmdevIPort_VBVAChange: fEnabled = %d\n", fEnabled)); 3802 3844 … … 3810 3852 static DECLCALLBACK(int) vmmdevIPort_CpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage) 3811 3853 { 3812 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3813 int rc = VINF_SUCCESS; 3854 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3855 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3856 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3857 int rc = VINF_SUCCESS; 3814 3858 3815 3859 Log(("vmmdevIPort_CpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage)); 3816 3860 3817 PDM CritSectEnter(&pThis->CritSect, VERR_IGNORED);3861 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3818 3862 3819 3863 if (pThis->fCpuHotPlugEventsEnabled) … … 3822 3866 pThis->idCpuCore = idCpuCore; 3823 3867 pThis->idCpuPackage = idCpuPackage; 3824 VMMDevNotifyGuest(p This, VMMDEV_EVENT_CPU_HOTPLUG);3868 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_CPU_HOTPLUG); 3825 3869 } 3826 3870 else 3827 3871 rc = VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST; 3828 3872 3829 PDM CritSectLeave(&pThis->CritSect);3873 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3830 3874 return rc; 3831 3875 } … … 3836 3880 static DECLCALLBACK(int) vmmdevIPort_CpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage) 3837 3881 { 3838 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort); 3839 int rc = VINF_SUCCESS; 3882 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IPort); 3883 PPDMDEVINS pDevIns = pThisCC->pDevIns; 3884 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3885 int rc = VINF_SUCCESS; 3840 3886 3841 3887 Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage)); 3842 3888 3843 PDM CritSectEnter(&pThis->CritSect, VERR_IGNORED);3889 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3844 3890 3845 3891 if (pThis->fCpuHotPlugEventsEnabled) … … 3848 3894 pThis->idCpuCore = idCpuCore; 3849 3895 pThis->idCpuPackage = idCpuPackage; 3850 VMMDevNotifyGuest(p This, VMMDEV_EVENT_CPU_HOTPLUG);3896 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_CPU_HOTPLUG); 3851 3897 } 3852 3898 else 3853 3899 rc = VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST; 3854 3900 3855 PDM CritSectLeave(&pThis->CritSect);3901 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3856 3902 return rc; 3857 3903 } … … 3865 3911 static DECLCALLBACK(int) vmmdevLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 3866 3912 { 3867 RT_NOREF 1(uPass);3868 PVMMDEV pThis = PDM INS_2_DATA(pDevIns, PVMMDEV);3913 RT_NOREF(uPass); 3914 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3869 3915 3870 3916 SSMR3PutBool(pSSM, pThis->fGetHostTimeDisabled); … … 3882 3928 static DECLCALLBACK(int) vmmdevSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3883 3929 { 3884 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 3885 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 3930 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3931 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 3932 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3933 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 3886 3934 3887 3935 vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL); 3888 3936 3889 SSMR3PutU32(pSSM, 0 /*was pThis->hypervisorSize, which was always zero*/);3890 SSMR3PutU32(pSSM, pThis->fMouseCapabilities);3891 SSMR3PutS32(pSSM, pThis->xMouseAbs);3892 SSMR3PutS32(pSSM, pThis->yMouseAbs);3893 3894 SSMR3PutBool(pSSM, pThis->fNewGuestFilterMaskValid);3895 SSMR3PutU32(pSSM, pThis->fNewGuestFilterMask);3896 SSMR3PutU32(pSSM, pThis->fGuestFilterMask);3897 SSMR3PutU32(pSSM, pThis->fHostEventFlags);3937 pHlp->pfnSSMPutU32(pSSM, 0 /*was pThis->hypervisorSize, which was always zero*/); 3938 pHlp->pfnSSMPutU32(pSSM, pThis->fMouseCapabilities); 3939 pHlp->pfnSSMPutS32(pSSM, pThis->xMouseAbs); 3940 pHlp->pfnSSMPutS32(pSSM, pThis->yMouseAbs); 3941 3942 pHlp->pfnSSMPutBool(pSSM, pThis->fNewGuestFilterMaskValid); 3943 pHlp->pfnSSMPutU32(pSSM, pThis->fNewGuestFilterMask); 3944 pHlp->pfnSSMPutU32(pSSM, pThis->fGuestFilterMask); 3945 pHlp->pfnSSMPutU32(pSSM, pThis->fHostEventFlags); 3898 3946 /* The following is not strictly necessary as PGM restores MMIO2, keeping it for historical reasons. */ 3899 SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));3900 3901 SSMR3PutMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));3902 SSMR3PutU32(pSSM, pThis->fu32AdditionsOk);3903 SSMR3PutU32(pSSM, pThis->u32VideoAccelEnabled);3904 SSMR3PutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);3905 3906 SSMR3PutU32(pSSM, pThis->fGuestCaps);3947 pHlp->pfnSSMPutMem(pSSM, &pThisCC->pVMMDevRAMR3->V, sizeof(pThisCC->pVMMDevRAMR3->V)); 3948 3949 pHlp->pfnSSMPutMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo)); 3950 pHlp->pfnSSMPutU32(pSSM, pThis->fu32AdditionsOk); 3951 pHlp->pfnSSMPutU32(pSSM, pThis->u32VideoAccelEnabled); 3952 pHlp->pfnSSMPutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck); 3953 3954 pHlp->pfnSSMPutU32(pSSM, pThis->fGuestCaps); 3907 3955 3908 3956 #ifdef VBOX_WITH_HGCM 3909 vmmdev HGCMSaveState(pThis, pSSM);3957 vmmdevR3HgcmSaveState(pThisCC, pSSM); 3910 3958 #endif /* VBOX_WITH_HGCM */ 3911 3959 3912 SSMR3PutU32(pSSM, pThis->fHostCursorRequested);3913 3914 SSMR3PutU32(pSSM, pThis->guestInfo2.uFullVersion);3915 SSMR3PutU32(pSSM, pThis->guestInfo2.uRevision);3916 SSMR3PutU32(pSSM, pThis->guestInfo2.fFeatures);3917 SSMR3PutStrZ(pSSM, pThis->guestInfo2.szName);3918 SSMR3PutU32(pSSM, pThis->cFacilityStatuses);3960 pHlp->pfnSSMPutU32(pSSM, pThis->fHostCursorRequested); 3961 3962 pHlp->pfnSSMPutU32(pSSM, pThis->guestInfo2.uFullVersion); 3963 pHlp->pfnSSMPutU32(pSSM, pThis->guestInfo2.uRevision); 3964 pHlp->pfnSSMPutU32(pSSM, pThis->guestInfo2.fFeatures); 3965 pHlp->pfnSSMPutStrZ(pSSM, pThis->guestInfo2.szName); 3966 pHlp->pfnSSMPutU32(pSSM, pThis->cFacilityStatuses); 3919 3967 for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++) 3920 3968 { 3921 SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].enmFacility);3922 SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].fFlags);3923 SSMR3PutU16(pSSM, (uint16_t)pThis->aFacilityStatuses[i].enmStatus);3924 SSMR3PutS64(pSSM, RTTimeSpecGetNano(&pThis->aFacilityStatuses[i].TimeSpecTS));3969 pHlp->pfnSSMPutU32(pSSM, pThis->aFacilityStatuses[i].enmFacility); 3970 pHlp->pfnSSMPutU32(pSSM, pThis->aFacilityStatuses[i].fFlags); 3971 pHlp->pfnSSMPutU16(pSSM, (uint16_t)pThis->aFacilityStatuses[i].enmStatus); 3972 pHlp->pfnSSMPutS64(pSSM, RTTimeSpecGetNano(&pThis->aFacilityStatuses[i].TimeSpecTS)); 3925 3973 } 3926 3974 3927 3975 /* Heartbeat: */ 3928 SSMR3PutBool(pSSM, pThis->fHeartbeatActive);3929 SSMR3PutBool(pSSM, pThis->fFlatlined);3930 SSMR3PutU64(pSSM, pThis->nsLastHeartbeatTS);3931 TMR3TimerSave(pThis->pFlatlinedTimer, pSSM);3932 3933 PDM CritSectLeave(&pThis->CritSect);3976 pHlp->pfnSSMPutBool(pSSM, pThis->fHeartbeatActive); 3977 pHlp->pfnSSMPutBool(pSSM, pThis->fFlatlined); 3978 pHlp->pfnSSMPutU64(pSSM, pThis->nsLastHeartbeatTS); 3979 PDMDevHlpTimerSave(pDevIns, pThis->hFlatlinedTimer, pSSM); 3980 3981 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 3934 3982 return VINF_SUCCESS; 3935 3983 } … … 3940 3988 static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 3941 3989 { 3942 /** @todo The code load code is assuming we're always loaded into a freshly3943 * constructed VM. */3944 P VMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);3945 int rc;3990 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 3991 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 3992 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3993 int rc; 3946 3994 3947 3995 if ( uVersion > VMMDEV_SAVED_STATE_VERSION … … 3953 4001 { 3954 4002 bool f; 3955 rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);4003 rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc); 3956 4004 if (pThis->fGetHostTimeDisabled != f) 3957 4005 LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f)); 3958 4006 3959 rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);4007 rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc); 3960 4008 if (pThis->fBackdoorLogDisabled != f) 3961 4009 LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f)); 3962 4010 3963 rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);4011 rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc); 3964 4012 if (pThis->fKeepCredentials != f) 3965 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),3966 pThis->fKeepCredentials, f);3967 rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);4013 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"), 4014 pThis->fKeepCredentials, f); 4015 rc = pHlp->pfnSSMGetBool(pSSM, &f); AssertRCReturn(rc, rc); 3968 4016 if (pThis->fHeapEnabled != f) 3969 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),3970 pThis->fHeapEnabled, f);4017 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"), 4018 pThis->fHeapEnabled, f); 3971 4019 } 3972 4020 … … 3976 4024 /* state */ 3977 4025 uint32_t uIgn; 3978 SSMR3GetU32(pSSM, &uIgn);3979 SSMR3GetU32(pSSM, &pThis->fMouseCapabilities);3980 SSMR3GetS32(pSSM, &pThis->xMouseAbs);3981 SSMR3GetS32(pSSM, &pThis->yMouseAbs);3982 3983 SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMaskValid);3984 SSMR3GetU32(pSSM, &pThis->fNewGuestFilterMask);3985 SSMR3GetU32(pSSM, &pThis->fGuestFilterMask);3986 SSMR3GetU32(pSSM, &pThis->fHostEventFlags);3987 3988 // SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);4026 pHlp->pfnSSMGetU32(pSSM, &uIgn); 4027 pHlp->pfnSSMGetU32(pSSM, &pThis->fMouseCapabilities); 4028 pHlp->pfnSSMGetS32(pSSM, &pThis->xMouseAbs); 4029 pHlp->pfnSSMGetS32(pSSM, &pThis->yMouseAbs); 4030 4031 pHlp->pfnSSMGetBool(pSSM, &pThis->fNewGuestFilterMaskValid); 4032 pHlp->pfnSSMGetU32(pSSM, &pThis->fNewGuestFilterMask); 4033 pHlp->pfnSSMGetU32(pSSM, &pThis->fGuestFilterMask); 4034 pHlp->pfnSSMGetU32(pSSM, &pThis->fHostEventFlags); 4035 4036 //pHlp->pfnSSMGetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents); 3989 4037 // here be dragons (probably) 3990 SSMR3GetMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));3991 3992 SSMR3GetMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));3993 SSMR3GetU32(pSSM, &pThis->fu32AdditionsOk);3994 SSMR3GetU32(pSSM, &pThis->u32VideoAccelEnabled);4038 pHlp->pfnSSMGetMem(pSSM, &pThisCC->pVMMDevRAMR3->V, sizeof(pThisCC->pVMMDevRAMR3->V)); 4039 4040 pHlp->pfnSSMGetMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo)); 4041 pHlp->pfnSSMGetU32(pSSM, &pThis->fu32AdditionsOk); 4042 pHlp->pfnSSMGetU32(pSSM, &pThis->u32VideoAccelEnabled); 3995 4043 if (uVersion > 10) 3996 SSMR3GetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);3997 3998 rc = SSMR3GetU32(pSSM, &pThis->fGuestCaps);4044 pHlp->pfnSSMGetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck); 4045 4046 rc = pHlp->pfnSSMGetU32(pSSM, &pThis->fGuestCaps); 3999 4047 4000 4048 /* Attributes which were temporarily introduced in r30072 */ … … 4002 4050 { 4003 4051 uint32_t temp; 4004 SSMR3GetU32(pSSM, &temp);4005 rc = SSMR3GetU32(pSSM, &temp);4052 pHlp->pfnSSMGetU32(pSSM, &temp); 4053 rc = pHlp->pfnSSMGetU32(pSSM, &temp); 4006 4054 } 4007 4055 AssertRCReturn(rc, rc); 4008 4056 4009 4057 #ifdef VBOX_WITH_HGCM 4010 rc = vmmdev HGCMLoadState(pThis, pSSM, uVersion);4058 rc = vmmdevR3HgcmLoadState(pDevIns, pThis, pThisCC, pSSM, uVersion); 4011 4059 AssertRCReturn(rc, rc); 4012 4060 #endif /* VBOX_WITH_HGCM */ 4013 4061 4014 4062 if (uVersion >= 10) 4015 rc = SSMR3GetU32(pSSM, &pThis->fHostCursorRequested);4063 rc = pHlp->pfnSSMGetU32(pSSM, &pThis->fHostCursorRequested); 4016 4064 AssertRCReturn(rc, rc); 4017 4065 4018 4066 if (uVersion > VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2) 4019 4067 { 4020 SSMR3GetU32(pSSM, &pThis->guestInfo2.uFullVersion);4021 SSMR3GetU32(pSSM, &pThis->guestInfo2.uRevision);4022 SSMR3GetU32(pSSM, &pThis->guestInfo2.fFeatures);4023 rc = SSMR3GetStrZ(pSSM, &pThis->guestInfo2.szName[0], sizeof(pThis->guestInfo2.szName));4068 pHlp->pfnSSMGetU32(pSSM, &pThis->guestInfo2.uFullVersion); 4069 pHlp->pfnSSMGetU32(pSSM, &pThis->guestInfo2.uRevision); 4070 pHlp->pfnSSMGetU32(pSSM, &pThis->guestInfo2.fFeatures); 4071 rc = pHlp->pfnSSMGetStrZ(pSSM, &pThis->guestInfo2.szName[0], sizeof(pThis->guestInfo2.szName)); 4024 4072 AssertRCReturn(rc, rc); 4025 4073 } … … 4028 4076 { 4029 4077 uint32_t cFacilityStatuses; 4030 rc = SSMR3GetU32(pSSM, &cFacilityStatuses);4078 rc = pHlp->pfnSSMGetU32(pSSM, &cFacilityStatuses); 4031 4079 AssertRCReturn(rc, rc); 4032 4080 … … 4037 4085 int64_t iTimeStampNano; 4038 4086 4039 SSMR3GetU32(pSSM, &uFacility);4040 SSMR3GetU32(pSSM, &fFlags);4041 SSMR3GetU16(pSSM, &uStatus);4042 rc = SSMR3GetS64(pSSM, &iTimeStampNano);4087 pHlp->pfnSSMGetU32(pSSM, &uFacility); 4088 pHlp->pfnSSMGetU32(pSSM, &fFlags); 4089 pHlp->pfnSSMGetU16(pSSM, &uStatus); 4090 rc = pHlp->pfnSSMGetS64(pSSM, &iTimeStampNano); 4043 4091 AssertRCReturn(rc, rc); 4044 4092 … … 4058 4106 if (uVersion >= VMMDEV_SAVED_STATE_VERSION_HEARTBEAT) 4059 4107 { 4060 SSMR3GetBool(pSSM, (bool *)&pThis->fHeartbeatActive);4061 SSMR3GetBool(pSSM, (bool *)&pThis->fFlatlined);4062 SSMR3GetU64(pSSM, (uint64_t *)&pThis->nsLastHeartbeatTS);4063 rc = TMR3TimerLoad(pThis->pFlatlinedTimer, pSSM);4108 pHlp->pfnSSMGetBool(pSSM, (bool *)&pThis->fHeartbeatActive); 4109 pHlp->pfnSSMGetBool(pSSM, (bool *)&pThis->fFlatlined); 4110 pHlp->pfnSSMGetU64(pSSM, (uint64_t *)&pThis->nsLastHeartbeatTS); 4111 rc = PDMDevHlpTimerLoad(pDevIns, pThis->hFlatlinedTimer, pSSM); 4064 4112 AssertRCReturn(rc, rc); 4065 4113 if (pThis->fFlatlined) 4066 4114 LogRel(("vmmdevLoadState: Guest has flatlined. Last heartbeat %'RU64 ns before state was saved.\n", 4067 TMTimerGetNano(pThis->pFlatlinedTimer) - pThis->nsLastHeartbeatTS));4115 PDMDevHlpTimerGetNano(pDevIns, pThis->hFlatlinedTimer) - pThis->nsLastHeartbeatTS)); 4068 4116 } 4069 4117 … … 4073 4121 */ 4074 4122 Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->fMouseCapabilities)); 4075 if (pThis ->pDrv)4076 { 4077 pThis ->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);4123 if (pThisCC->pDrv) 4124 { 4125 pThisCC->pDrv->pfnUpdateMouseCapabilities(pThisCC->pDrv, pThis->fMouseCapabilities); 4078 4126 if (uVersion >= 10) 4079 pThis ->pDrv->pfnUpdatePointerShape(pThis->pDrv,4127 pThisCC->pDrv->pfnUpdatePointerShape(pThisCC->pDrv, 4080 4128 /*fVisible=*/!!pThis->fHostCursorRequested, 4081 4129 /*fAlpha=*/false, … … 4088 4136 { 4089 4137 vmmdevLogGuestOsInfo(&pThis->guestInfo); 4090 if (pThis ->pDrv)4138 if (pThisCC->pDrv) 4091 4139 { 4092 if (pThis->guestInfo2.uFullVersion && pThis ->pDrv->pfnUpdateGuestInfo2)4093 pThis ->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName,4140 if (pThis->guestInfo2.uFullVersion && pThisCC->pDrv->pfnUpdateGuestInfo2) 4141 pThisCC->pDrv->pfnUpdateGuestInfo2(pThisCC->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName, 4094 4142 pThis->guestInfo2.uRevision, pThis->guestInfo2.fFeatures); 4095 if (pThis ->pDrv->pfnUpdateGuestInfo)4096 pThis ->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);4097 4098 if (pThis ->pDrv->pfnUpdateGuestStatus)4143 if (pThisCC->pDrv->pfnUpdateGuestInfo) 4144 pThisCC->pDrv->pfnUpdateGuestInfo(pThisCC->pDrv, &pThis->guestInfo); 4145 4146 if (pThisCC->pDrv->pfnUpdateGuestStatus) 4099 4147 { 4100 4148 for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++) /* ascending order! */ 4101 4149 if ( pThis->aFacilityStatuses[i].enmStatus != VBoxGuestFacilityStatus_Inactive 4102 4150 || !pThis->aFacilityStatuses[i].fFixed) 4103 pThis ->pDrv->pfnUpdateGuestStatus(pThis->pDrv,4151 pThisCC->pDrv->pfnUpdateGuestStatus(pThisCC->pDrv, 4104 4152 pThis->aFacilityStatuses[i].enmFacility, 4105 4153 (uint16_t)pThis->aFacilityStatuses[i].enmStatus, … … 4109 4157 } 4110 4158 } 4111 if (pThis ->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)4112 pThis ->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->fGuestCaps);4159 if (pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities) 4160 pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, pThis->fGuestCaps); 4113 4161 4114 4162 return VINF_SUCCESS; … … 4124 4172 static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 4125 4173 { 4126 RT_NOREF1(pSSM); 4127 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 4174 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 4175 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 4176 RT_NOREF(pSSM); 4128 4177 4129 4178 #ifdef VBOX_WITH_HGCM 4130 int rc = vmmdev HGCMLoadStateDone(pThis);4179 int rc = vmmdevR3HgcmLoadStateDone(pDevIns, pThis, pThisCC); 4131 4180 AssertLogRelRCReturn(rc, rc); 4132 4181 #endif /* VBOX_WITH_HGCM */ … … 4134 4183 /* Reestablish the acceleration status. */ 4135 4184 if ( pThis->u32VideoAccelEnabled 4136 && pThis->pDrv) 4137 { 4138 pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, !!pThis->u32VideoAccelEnabled, &pThis->pVMMDevRAMR3->vbvaMemory); 4139 } 4140 4141 VMMDevNotifyGuest(pThis, VMMDEV_EVENT_RESTORED); 4185 && pThisCC->pDrv) 4186 pThisCC->pDrv->pfnVideoAccelEnable(pThisCC->pDrv, !!pThis->u32VideoAccelEnabled, &pThisCC->pVMMDevRAMR3->vbvaMemory); 4187 4188 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_RESTORED); 4142 4189 4143 4190 return VINF_SUCCESS; … … 4150 4197 * (Re-)initializes the MMIO2 data. 4151 4198 * 4152 * @param pThis Pointer to the VMMDevinstance data.4153 */ 4154 static void vmmdevInitRam(PVMMDEV pThis)4155 { 4156 memset(pThis ->pVMMDevRAMR3, 0, sizeof(VMMDevMemory));4157 pThis ->pVMMDevRAMR3->u32Size= sizeof(VMMDevMemory);4158 pThis ->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION;4199 * @param pThisCC The VMMDev ring-3 instance data. 4200 */ 4201 static void vmmdevInitRam(PVMMDEVCC pThisCC) 4202 { 4203 memset(pThisCC->pVMMDevRAMR3, 0, sizeof(VMMDevMemory)); 4204 pThisCC->pVMMDevRAMR3->u32Size = sizeof(VMMDevMemory); 4205 pThisCC->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION; 4159 4206 } 4160 4207 … … 4165 4212 static DECLCALLBACK(void) vmmdevReset(PPDMDEVINS pDevIns) 4166 4213 { 4167 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 4168 PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED); 4214 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 4215 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 4216 PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSect, VERR_IGNORED); 4169 4217 4170 4218 /* … … 4176 4224 /* notify the connector */ 4177 4225 Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->fMouseCapabilities)); 4178 pThis ->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->fMouseCapabilities);4226 pThisCC->pDrv->pfnUpdateMouseCapabilities(pThisCC->pDrv, pThis->fMouseCapabilities); 4179 4227 } 4180 4228 pThis->fHostCursorRequested = false; 4181 4229 4182 4230 /* re-initialize the VMMDev memory */ 4183 if (pThis ->pVMMDevRAMR3)4184 vmmdevInitRam(pThis );4231 if (pThisCC->pVMMDevRAMR3) 4232 vmmdevInitRam(pThisCC); 4185 4233 4186 4234 /* credentials have to go away (by default) */ 4187 if (!pThis->fKeepCredentials) 4188 { 4189 memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE); 4190 memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE); 4191 memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE); 4192 } 4193 memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE); 4194 memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE); 4195 memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE); 4235 VMMDEVCREDS *pCredentials = pThisCC->pCredentials; 4236 if (pCredentials) 4237 { 4238 if (!pThis->fKeepCredentials) 4239 { 4240 RT_ZERO(pCredentials->Logon.szUserName); 4241 RT_ZERO(pCredentials->Logon.szPassword); 4242 RT_ZERO(pCredentials->Logon.szDomain); 4243 } 4244 RT_ZERO(pCredentials->Judge.szUserName); 4245 RT_ZERO(pCredentials->Judge.szPassword); 4246 RT_ZERO(pCredentials->Judge.szDomain); 4247 } 4196 4248 4197 4249 /* Reset means that additions will report again. */ … … 4239 4291 #ifdef VBOX_WITH_HGCM 4240 4292 /* Clear the "HGCM event enabled" flag so the event can be automatically reenabled. */ 4241 pThis ->u32HGCMEnabled = 0;4293 pThisCC->u32HGCMEnabled = 0; 4242 4294 #endif 4243 4295 … … 4247 4299 if (pThis->fHeartbeatActive) 4248 4300 { 4249 TMTimerStop(pThis->pFlatlinedTimer);4301 PDMDevHlpTimerStop(pDevIns, pThis->hFlatlinedTimer); 4250 4302 pThis->fFlatlined = false; 4251 4303 pThis->fHeartbeatActive = true; … … 4268 4320 * Call the update functions as required. 4269 4321 */ 4270 if (fVersionChanged && pThis ->pDrv && pThis->pDrv->pfnUpdateGuestInfo)4271 pThis ->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);4272 if (fCapsChanged && pThis ->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)4273 pThis ->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->fGuestCaps);4322 if (fVersionChanged && pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestInfo) 4323 pThisCC->pDrv->pfnUpdateGuestInfo(pThisCC->pDrv, &pThis->guestInfo); 4324 if (fCapsChanged && pThisCC->pDrv && pThisCC->pDrv->pfnUpdateGuestCapabilities) 4325 pThisCC->pDrv->pfnUpdateGuestCapabilities(pThisCC->pDrv, pThis->fGuestCaps); 4274 4326 4275 4327 /* … … 4279 4331 pThis->idSession = ASMReadTSC(); 4280 4332 4281 PDM CritSectLeave(&pThis->CritSect);4333 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); 4282 4334 } 4283 4335 … … 4291 4343 if (offDelta) 4292 4344 { 4293 PVMMDEV pThis = PDM INS_2_DATA(pDevIns, PVMMDEV);4345 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 4294 4346 LogFlow(("vmmdevRelocate: offDelta=%RGv\n", offDelta)); 4295 4347 … … 4307 4359 static DECLCALLBACK(int) vmmdevDestruct(PPDMDEVINS pDevIns) 4308 4360 { 4309 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);4310 4361 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 4362 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 4311 4363 4312 4364 /* 4313 4365 * Wipe and free the credentials. 4314 4366 */ 4315 if (pThis->pCredentials) 4316 { 4317 RTMemWipeThoroughly(pThis->pCredentials, sizeof(*pThis->pCredentials), 10); 4318 RTMemFree(pThis->pCredentials); 4319 pThis->pCredentials = NULL; 4367 VMMDEVCREDS *pCredentials = pThisCC->pCredentials; 4368 pThisCC->pCredentials = NULL; 4369 if (pCredentials) 4370 { 4371 if (pThisCC->fSaferCredentials) 4372 RTMemSaferFree(pCredentials, sizeof(*pCredentials)); 4373 else 4374 { 4375 RTMemWipeThoroughly(pCredentials, sizeof(*pCredentials), 10); 4376 RTMemFree(pCredentials); 4377 } 4320 4378 } 4321 4379 … … 4324 4382 * Everything HGCM. 4325 4383 */ 4326 vmmdev HGCMDestroy(pThis);4384 vmmdevR3HgcmDestroy(pDevIns, pThisCC); 4327 4385 #endif 4328 4386 … … 4330 4388 * Free the request buffers. 4331 4389 */ 4332 for (uint32_t iCpu = 0; iCpu < RT_ELEMENTS(pThis ->apReqBufs); iCpu++)4333 { 4334 pThis->apReqBufs[iCpu] = NULL;4335 RTMemPageFree(pThis->apReqBufs[iCpu], _4K);4390 for (uint32_t iCpu = 0; iCpu < RT_ELEMENTS(pThisCC->apReqBufs); iCpu++) 4391 { 4392 RTMemPageFree(pThisCC->apReqBufs[iCpu], _4K); 4393 pThisCC->apReqBufs[iCpu] = NULL; 4336 4394 } 4337 4395 … … 4352 4410 static DECLCALLBACK(int) vmmdevConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 4353 4411 { 4354 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 4355 int rc; 4412 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 4413 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 4414 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 4415 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 4416 int rc; 4356 4417 4357 4418 Assert(iInstance == 0); 4358 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);4419 RT_NOREF(iInstance); 4359 4420 4360 4421 /* 4361 4422 * Initialize data (most of it anyway). 4362 4423 */ 4363 /* Save PDM device instance data for future reference. */ 4364 pThis->pDevInsR3 = pDevIns; 4365 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 4366 #ifdef VBOX_WITH_RAW_MODE_KEEP 4367 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 4424 pThisCC->pDevIns = pDevIns; 4425 4426 pThis->hFlatlinedTimer = NIL_TMTIMERHANDLE; 4427 pThis->hIoPortBackdoorLog = NIL_IOMIOPORTHANDLE; 4428 pThis->hIoPortAltTimesync = NIL_IOMIOPORTHANDLE; 4429 pThis->hIoPortReq = NIL_IOMIOPORTHANDLE; 4430 pThis->hIoPortFast = NIL_IOMIOPORTHANDLE; 4431 pThis->hMmio2VMMDevRAM = NIL_PGMMMIO2HANDLE; 4432 pThis->hMmio2Heap = NIL_PGMMMIO2HANDLE; 4433 #ifndef VBOX_WITHOUT_TESTING_FEATURES 4434 pThis->hIoPortTesting = NIL_IOMIOPORTHANDLE; 4435 pThis->hMmioTesting = NIL_IOMMMIOHANDLE; 4368 4436 #endif 4369 4437 … … 4397 4465 */ 4398 4466 /* IBase */ 4399 pThis ->IBase.pfnQueryInterface = vmmdevPortQueryInterface;4467 pThisCC->IBase.pfnQueryInterface = vmmdevPortQueryInterface; 4400 4468 4401 4469 /* VMMDev port */ 4402 pThis ->IPort.pfnQueryAbsoluteMouse = vmmdevIPort_QueryAbsoluteMouse;4403 pThis ->IPort.pfnSetAbsoluteMouse = vmmdevIPort_SetAbsoluteMouse ;4404 pThis ->IPort.pfnQueryMouseCapabilities = vmmdevIPort_QueryMouseCapabilities;4405 pThis ->IPort.pfnUpdateMouseCapabilities = vmmdevIPort_UpdateMouseCapabilities;4406 pThis ->IPort.pfnRequestDisplayChange = vmmdevIPort_RequestDisplayChange;4407 pThis ->IPort.pfnSetCredentials = vmmdevIPort_SetCredentials;4408 pThis ->IPort.pfnVBVAChange = vmmdevIPort_VBVAChange;4409 pThis ->IPort.pfnRequestSeamlessChange = vmmdevIPort_RequestSeamlessChange;4410 pThis ->IPort.pfnSetMemoryBalloon = vmmdevIPort_SetMemoryBalloon;4411 pThis ->IPort.pfnSetStatisticsInterval = vmmdevIPort_SetStatisticsInterval;4412 pThis ->IPort.pfnVRDPChange = vmmdevIPort_VRDPChange;4413 pThis ->IPort.pfnCpuHotUnplug = vmmdevIPort_CpuHotUnplug;4414 pThis ->IPort.pfnCpuHotPlug = vmmdevIPort_CpuHotPlug;4470 pThisCC->IPort.pfnQueryAbsoluteMouse = vmmdevIPort_QueryAbsoluteMouse; 4471 pThisCC->IPort.pfnSetAbsoluteMouse = vmmdevIPort_SetAbsoluteMouse ; 4472 pThisCC->IPort.pfnQueryMouseCapabilities = vmmdevIPort_QueryMouseCapabilities; 4473 pThisCC->IPort.pfnUpdateMouseCapabilities = vmmdevIPort_UpdateMouseCapabilities; 4474 pThisCC->IPort.pfnRequestDisplayChange = vmmdevIPort_RequestDisplayChange; 4475 pThisCC->IPort.pfnSetCredentials = vmmdevIPort_SetCredentials; 4476 pThisCC->IPort.pfnVBVAChange = vmmdevIPort_VBVAChange; 4477 pThisCC->IPort.pfnRequestSeamlessChange = vmmdevIPort_RequestSeamlessChange; 4478 pThisCC->IPort.pfnSetMemoryBalloon = vmmdevIPort_SetMemoryBalloon; 4479 pThisCC->IPort.pfnSetStatisticsInterval = vmmdevIPort_SetStatisticsInterval; 4480 pThisCC->IPort.pfnVRDPChange = vmmdevIPort_VRDPChange; 4481 pThisCC->IPort.pfnCpuHotUnplug = vmmdevIPort_CpuHotUnplug; 4482 pThisCC->IPort.pfnCpuHotPlug = vmmdevIPort_CpuHotPlug; 4415 4483 4416 4484 /* Shared folder LED */ 4417 pThis ->SharedFolders.Led.u32Magic = PDMLED_MAGIC;4418 pThis ->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;4485 pThisCC->SharedFolders.Led.u32Magic = PDMLED_MAGIC; 4486 pThisCC->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed; 4419 4487 4420 4488 #ifdef VBOX_WITH_HGCM 4421 4489 /* HGCM port */ 4422 pThis ->IHGCMPort.pfnCompleted = hgcmCompleted;4423 pThis ->IHGCMPort.pfnIsCmdRestored = hgcmIsCmdRestored;4424 pThis ->IHGCMPort.pfnIsCmdCancelled = hgcmIsCmdCancelled;4425 pThis ->IHGCMPort.pfnGetRequestor = hgcmGetRequestor;4426 pThis ->IHGCMPort.pfnGetVMMDevSessionId = hgcmGetVMMDevSessionId;4490 pThisCC->IHGCMPort.pfnCompleted = hgcmR3Completed; 4491 pThisCC->IHGCMPort.pfnIsCmdRestored = hgcmR3IsCmdRestored; 4492 pThisCC->IHGCMPort.pfnIsCmdCancelled = hgcmR3IsCmdCancelled; 4493 pThisCC->IHGCMPort.pfnGetRequestor = hgcmR3GetRequestor; 4494 pThisCC->IHGCMPort.pfnGetVMMDevSessionId = hgcmR3GetVMMDevSessionId; 4427 4495 #endif 4428 4496 4429 pThis->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThis->pCredentials)); 4430 if (!pThis->pCredentials) 4431 return VERR_NO_MEMORY; 4497 pThisCC->pCredentials = (VMMDEVCREDS *)RTMemSaferAllocZ(sizeof(*pThisCC->pCredentials)); 4498 if (pThisCC->pCredentials) 4499 pThisCC->fSaferCredentials = true; 4500 else 4501 { 4502 pThisCC->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThisCC->pCredentials)); 4503 AssertReturn(pThisCC->pCredentials, VERR_NO_MEMORY); 4504 } 4432 4505 4433 4506 … … 4436 4509 */ 4437 4510 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, 4511 "AllowGuestToSaveState|" 4438 4512 "GetHostTimeDisabled|" 4439 4513 "BackdoorLogDisabled|" 4440 4514 "KeepCredentials|" 4441 4515 "HeapEnabled|" 4442 "RZEnabled|"4443 4516 "GuestCoreDumpEnabled|" 4444 4517 "GuestCoreDumpDir|" … … 4452 4525 ""); 4453 4526 4454 rc = CFGMR3QueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false); 4527 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "AllowGuestToSaveState", &pThis->fAllowGuestToSaveState, true); 4528 if (RT_FAILURE(rc)) 4529 return PDMDEV_SET_ERROR(pDevIns, rc, 4530 N_("Configuration error: Failed querying \"AllowGuestToSaveState\" as a boolean")); 4531 4532 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false); 4455 4533 if (RT_FAILURE(rc)) 4456 4534 return PDMDEV_SET_ERROR(pDevIns, rc, 4457 4535 N_("Configuration error: Failed querying \"GetHostTimeDisabled\" as a boolean")); 4458 4536 4459 rc = CFGMR3QueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false);4537 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false); 4460 4538 if (RT_FAILURE(rc)) 4461 4539 return PDMDEV_SET_ERROR(pDevIns, rc, 4462 4540 N_("Configuration error: Failed querying \"BackdoorLogDisabled\" as a boolean")); 4463 4541 4464 rc = CFGMR3QueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false);4542 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false); 4465 4543 if (RT_FAILURE(rc)) 4466 4544 return PDMDEV_SET_ERROR(pDevIns, rc, 4467 4545 N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean")); 4468 4546 4469 rc = CFGMR3QueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true);4547 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true); 4470 4548 if (RT_FAILURE(rc)) 4471 4549 return PDMDEV_SET_ERROR(pDevIns, rc, 4472 4550 N_("Configuration error: Failed querying \"HeapEnabled\" as a boolean")); 4473 4551 4474 rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true);4552 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false); 4475 4553 if (RT_FAILURE(rc)) 4476 return PDMDEV_SET_ERROR(pDevIns, rc, 4477 N_("Configuration error: Failed querying \"RZEnabled\" as a boolean")); 4478 4479 rc = CFGMR3QueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false);4554 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean")); 4555 4556 char *pszGuestCoreDumpDir = NULL; 4557 rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir, ""); 4480 4558 if (RT_FAILURE(rc)) 4481 return PDMDEV_SET_ERROR(pDevIns, rc, 4482 N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean")); 4483 4484 char *pszGuestCoreDumpDir = NULL; 4485 rc = CFGMR3QueryStringAllocDef(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir, ""); 4486 if (RT_FAILURE(rc)) 4487 return PDMDEV_SET_ERROR(pDevIns, rc, 4488 N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string")); 4559 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string")); 4489 4560 4490 4561 RTStrCopy(pThis->szGuestCoreDumpDir, sizeof(pThis->szGuestCoreDumpDir), pszGuestCoreDumpDir); 4491 4562 MMR3HeapFree(pszGuestCoreDumpDir); 4492 4563 4493 rc = CFGMR3QueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3);4564 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3); 4494 4565 if (RT_FAILURE(rc)) 4495 4566 return PDMDEV_SET_ERROR(pDevIns, rc, 4496 4567 N_("Configuration error: Failed querying \"GuestCoreDumpCount\" as a 32-bit unsigned integer")); 4497 4568 4498 rc = CFGMR3QueryU64Def(pCfg, "HeartbeatInterval", &pThis->cNsHeartbeatInterval, VMMDEV_HEARTBEAT_DEFAULT_INTERVAL);4569 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "HeartbeatInterval", &pThis->cNsHeartbeatInterval, VMMDEV_HEARTBEAT_DEFAULT_INTERVAL); 4499 4570 if (RT_FAILURE(rc)) 4500 4571 return PDMDEV_SET_ERROR(pDevIns, rc, … … 4504 4575 N_("Configuration error: Heartbeat interval \"HeartbeatInterval\" too small")); 4505 4576 4506 rc = CFGMR3QueryU64Def(pCfg, "HeartbeatTimeout", &pThis->cNsHeartbeatTimeout, pThis->cNsHeartbeatInterval * 2);4577 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "HeartbeatTimeout", &pThis->cNsHeartbeatTimeout, pThis->cNsHeartbeatInterval * 2); 4507 4578 if (RT_FAILURE(rc)) 4508 4579 return PDMDEV_SET_ERROR(pDevIns, rc, 4509 4580 N_("Configuration error: Failed querying \"HeartbeatTimeout\" as a 64-bit unsigned integer")); 4510 4581 if (pThis->cNsHeartbeatTimeout < RT_NS_100MS) 4511 return PDMDEV_SET_ERROR(pDevIns, rc, 4512 N_("Configuration error: Heartbeat timeout \"HeartbeatTimeout\" too small")); 4582 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Heartbeat timeout \"HeartbeatTimeout\" too small")); 4513 4583 if (pThis->cNsHeartbeatTimeout <= pThis->cNsHeartbeatInterval + RT_NS_10MS) 4514 4584 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, … … 4517 4587 4518 4588 #ifndef VBOX_WITHOUT_TESTING_FEATURES 4519 rc = CFGMR3QueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false);4589 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false); 4520 4590 if (RT_FAILURE(rc)) 4521 return PDMDEV_SET_ERROR(pDevIns, rc, 4522 N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean")); 4523 rc = CFGMR3QueryBoolDef(pCfg, "TestingMMIO", &pThis->fTestingMMIO, false); 4591 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean")); 4592 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "TestingMMIO", &pThis->fTestingMMIO, false); 4524 4593 if (RT_FAILURE(rc)) 4525 return PDMDEV_SET_ERROR(pDevIns, rc, 4526 N_("Configuration error: Failed querying \"TestingMMIO\" as a boolean")); 4527 rc = CFGMR3QueryStringAllocDef(pCfg, "TestintXmlOutputFile", &pThis->pszTestingXmlOutput, NULL); 4594 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestingMMIO\" as a boolean")); 4595 rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "TestintXmlOutputFile", &pThisCC->pszTestingXmlOutput, NULL); 4528 4596 if (RT_FAILURE(rc)) 4529 4597 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestintXmlOutputFile\" as a string")); … … 4546 4614 * Register the backdoor logging port 4547 4615 */ 4548 rc = PDMDevHlpI OPortRegister(pDevIns, RTLOG_DEBUG_PORT, 1, NULL, vmmdevBackdoorLog,4549 NULL, NULL, NULL, "VMMDev backdoor logging");4616 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, RTLOG_DEBUG_PORT, 1, vmmdevBackdoorLog, NULL /*pfnIn*/, 4617 "VMMDev backdoor logging", NULL, &pThis->hIoPortBackdoorLog); 4550 4618 AssertRCReturn(rc, rc); 4551 4619 … … 4558 4626 * first. We keep it in case it comes in handy. 4559 4627 */ 4560 rc = PDMDevHlpIOPortRegister(pDevIns, 0x505, 1, NULL, 4561 vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead, 4562 NULL, NULL, "VMMDev timesync backdoor"); 4628 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, 0x505, 1, vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead, 4629 "VMMDev timesync backdoor", NULL /*paExtDescs*/, &pThis->hIoPortAltTimesync); 4563 4630 AssertRCReturn(rc, rc); 4564 4631 #endif … … 4572 4639 if (pPciDev->uDevFn != 32 || iInstance != 0) 4573 4640 Log(("!!WARNING!!: pThis->PciDev.uDevFn=%d (ignore if testcase or no started by Main)\n", pPciDev->uDevFn)); 4574 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x20, PCI_ADDRESS_SPACE_IO, vmmdevIOPortRegionMap);4575 if (RT_FAILURE(rc))4576 return rc;4577 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);4578 if (RT_FAILURE(rc))4579 return rc;4580 if (pThis->fHeapEnabled)4581 {4582 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);4583 if (RT_FAILURE(rc))4584 return rc;4585 }4586 4641 4587 4642 /* 4588 * Allocate and initialize the MMIO2 memory. 4589 * 4590 * We map the first page into raw-mode and kernel contexts so we can handle 4591 * interrupt acknowledge requests more timely. 4592 */ 4593 rc = PDMDevHlpMMIO2Register(pDevIns, pPciDev, 1 /*iRegion*/, VMMDEV_RAM_SIZE, 0 /*fFlags*/, 4594 (void **)&pThis->pVMMDevRAMR3, "VMMDev"); 4643 * The I/O ports, PCI region #0. This has two separate I/O port mappings in it, 4644 * so we have to do it via the mapper callback. 4645 */ 4646 rc = PDMDevHlpIoPortCreate(pDevIns, 1 /*cPorts*/, pPciDev, RT_MAKE_U32(0, 0), vmmdevRequestHandler, NULL /*pfnIn*/, 4647 NULL /*pvUser*/, "VMMDev Request Handler", NULL, &pThis->hIoPortReq); 4648 AssertRCReturn(rc, rc); 4649 4650 rc = PDMDevHlpIoPortCreate(pDevIns, 1 /*cPorts*/, pPciDev, RT_MAKE_U32(1, 0), vmmdevFastRequestHandler, 4651 vmmdevFastRequestIrqAck, NULL, "VMMDev Fast R0/RC Requests", NULL /*pvUser*/, &pThis->hIoPortFast); 4652 AssertRCReturn(rc, rc); 4653 4654 rc = PDMDevHlpPCIIORegionRegisterIoCustom(pDevIns, 0, 0x20, vmmdevIOPortRegionMap); 4655 AssertRCReturn(rc, rc); 4656 4657 /* 4658 * Allocate and initialize the MMIO2 memory, PCI region #1. 4659 */ 4660 rc = PDMDevHlpPCIIORegionCreateMmio2(pDevIns, 1 /*iPciRegion*/, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, "VMMDev", 4661 (void **)&pThisCC->pVMMDevRAMR3, &pThis->hMmio2VMMDevRAM); 4595 4662 if (RT_FAILURE(rc)) 4596 4663 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 4597 N_("Failed to allocate %u bytes of memory for the VMM device"), VMMDEV_RAM_SIZE); 4598 vmmdevInitRam(pThis); 4599 if (pThis->fRZEnabled) 4600 { 4601 rc = PDMDevHlpMMIO2MapKernel(pDevIns, pPciDev, 1 /*iRegion*/, 0 /*off*/, PAGE_SIZE, "VMMDev", &pThis->pVMMDevRAMR0); 4664 N_("Failed to create the %u (%#x) byte MMIO2 region for the VMM device"), 4665 VMMDEV_RAM_SIZE, VMMDEV_RAM_SIZE); 4666 vmmdevInitRam(pThisCC); 4667 4668 /* 4669 * The MMIO2 heap (used for real-mode VT-x trickery), PCI region #2. 4670 */ 4671 if (pThis->fHeapEnabled) 4672 { 4673 rc = PDMDevHlpPCIIORegionCreateMmio2Ex(pDevIns, 2 /*iPciRegion*/, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, 4674 0 /*fFlags*/, vmmdevMmio2HeapRegionMap, "VMMDev Heap", 4675 (void **)&pThisCC->pVMMDevHeapR3, &pThis->hMmio2Heap); 4602 4676 if (RT_FAILURE(rc)) 4603 4677 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 4604 N_("Failed to map first page of the VMMDev ram into kernel space: %Rrc"), rc); 4605 4606 #ifdef VBOX_WITH_RAW_MODE_KEEP 4607 rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, pPciDev, 1 /*iRegion*/, 0 /*off*/, PAGE_SIZE, "VMMDev", &pThis->pVMMDevRAMRC); 4608 if (RT_FAILURE(rc)) 4609 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 4610 N_("Failed to map first page of the VMMDev ram into raw-mode context: %Rrc"), rc); 4611 #endif 4612 } 4613 4614 /* 4615 * Allocate and initialize the MMIO2 heap. 4616 */ 4617 if (pThis->fHeapEnabled) 4618 { 4619 rc = PDMDevHlpMMIO2Register(pDevIns, pPciDev, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/, 4620 (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap"); 4621 if (RT_FAILURE(rc)) 4622 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 4623 N_("Failed to allocate %u bytes of memory for the VMM device heap"), PAGE_SIZE); 4678 N_("Failed to create the %u (%#x) bytes MMIO2 heap region for the VMM device"), 4679 VMMDEV_HEAP_SIZE, VMMDEV_HEAP_SIZE); 4624 4680 4625 4681 /* Register the memory area with PDM so HM can access it before it's mapped. */ 4626 rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThis ->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);4682 rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThisCC->pVMMDevHeapR3, VMMDEV_HEAP_SIZE); 4627 4683 AssertLogRelRCReturn(rc, rc); 4628 4684 } … … 4640 4696 * Get the corresponding connector interface 4641 4697 */ 4642 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis ->IBase, &pThis->pDrvBase, "VMM Driver Port");4698 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThisCC->IBase, &pThisCC->pDrvBase, "VMM Driver Port"); 4643 4699 if (RT_SUCCESS(rc)) 4644 4700 { 4645 pThis ->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIVMMDEVCONNECTOR);4646 AssertMsgReturn(pThis ->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);4701 pThisCC->pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIVMMDEVCONNECTOR); 4702 AssertMsgReturn(pThisCC->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE); 4647 4703 #ifdef VBOX_WITH_HGCM 4648 pThis ->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIHGCMCONNECTOR);4649 if (!pThis ->pHGCMDrv)4704 pThisCC->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->pDrvBase, PDMIHGCMCONNECTOR); 4705 if (!pThisCC->pHGCMDrv) 4650 4706 { 4651 4707 Log(("LUN #0 doesn't have a HGCM connector interface, HGCM is not supported. rc=%Rrc\n", rc)); … … 4654 4710 #endif 4655 4711 /* Query the initial balloon size. */ 4656 AssertPtr(pThis ->pDrv->pfnQueryBalloonSize);4657 rc = pThis ->pDrv->pfnQueryBalloonSize(pThis->pDrv, &pThis->cMbMemoryBalloon);4712 AssertPtr(pThisCC->pDrv->pfnQueryBalloonSize); 4713 rc = pThisCC->pDrv->pfnQueryBalloonSize(pThisCC->pDrv, &pThis->cMbMemoryBalloon); 4658 4714 AssertRC(rc); 4659 4715 … … 4672 4728 */ 4673 4729 PPDMIBASE pBase; 4674 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis ->IBase, &pBase, "Status Port");4730 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThisCC->IBase, &pBase, "Status Port"); 4675 4731 if (RT_SUCCESS(rc)) 4676 pThis ->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);4732 pThisCC->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS); 4677 4733 else if (rc != VERR_PDM_NO_ATTACHED_DRIVER) 4678 4734 { … … 4693 4749 * Create heartbeat checking timer. 4694 4750 */ 4695 rc = PDMDevHlpT MTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vmmDevHeartbeatFlatlinedTimer, pThis,4696 TMTIMER_FLAGS_NO_CRIT_SECT, "Heartbeat flatlined", &pThis->pFlatlinedTimer);4751 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vmmDevHeartbeatFlatlinedTimer, pThis, 4752 TMTIMER_FLAGS_NO_CRIT_SECT, "Heartbeat flatlined", &pThis->hFlatlinedTimer); 4697 4753 AssertRCReturn(rc, rc); 4698 4754 4699 4755 #ifdef VBOX_WITH_HGCM 4700 rc = vmmdev HGCMInit(pThis);4756 rc = vmmdevR3HgcmInit(pThisCC); 4701 4757 AssertRCReturn(rc, rc); 4702 4758 #endif … … 4711 4767 * Statistics. 4712 4768 */ 4713 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4769 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4714 4770 "Memory balloon size", "/Devices/VMMDev/BalloonChunks"); 4715 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4771 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4716 4772 "Fast IRQ acknowledgments handled in ring-3.", "/Devices/VMMDev/FastIrqAckR3"); 4717 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckRZ, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4773 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatFastIrqAckRZ, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4718 4774 "Fast IRQ acknowledgments handled in ring-0 or raw-mode.", "/Devices/VMMDev/FastIrqAckRZ"); 4719 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatSlowIrqAck, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4775 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatSlowIrqAck, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4720 4776 "Slow IRQ acknowledgments (old style).", "/Devices/VMMDev/SlowIrqAck"); 4721 PDMDevHlpSTAMRegisterF(pDevIns, &pThis ->StatReqBufAllocs, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4777 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatReqBufAllocs, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4722 4778 "Times a larger request buffer was required.", "/Devices/VMMDev/LargeReqBufAllocs"); 4723 4779 #ifdef VBOX_WITH_HGCM 4724 PDMDevHlpSTAMRegisterF(pDevIns, &pThis ->StatHgcmCmdArrival, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,4780 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmCmdArrival, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, 4725 4781 "Profiling HGCM call arrival processing", "/HGCM/MsgArrival"); 4726 PDMDevHlpSTAMRegisterF(pDevIns, &pThis ->StatHgcmCmdCompletion, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,4782 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmCmdCompletion, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, 4727 4783 "Profiling HGCM call completion processing", "/HGCM/MsgCompletion"); 4728 PDMDevHlpSTAMRegisterF(pDevIns, &pThis ->StatHgcmCmdTotal, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL,4784 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmCmdTotal, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, 4729 4785 "Profiling whole HGCM call.", "/HGCM/MsgTotal"); 4730 PDMDevHlpSTAMRegisterF(pDevIns, &pThis ->StatHgcmLargeCmdAllocs,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4786 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmLargeCmdAllocs,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4731 4787 "Times the allocation cache could not be used.", "/HGCM/LargeCmdAllocs"); 4732 PDMDevHlpSTAMRegisterF(pDevIns, &pThis ->StatHgcmFailedPageListLocking,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,4788 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->StatHgcmFailedPageListLocking,STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, 4733 4789 "Times no-bounce page list locking failed.", "/HGCM/FailedPageListLocking"); 4734 4790 #endif … … 4743 4799 } 4744 4800 4745 #endif /* IN_RING3 */ 4801 #else /* !IN_RING3 */ 4802 4803 /** 4804 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 4805 */ 4806 static DECLCALLBACK(int) vmmdevRZConstruct(PPDMDEVINS pDevIns) 4807 { 4808 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 4809 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 4810 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 4811 4812 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns)); 4813 AssertRCReturn(rc, rc); 4814 4815 #if 0 4816 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortBackdoorLog, vmmdevBackdoorLog, NULL /*pfnIn*/, NULL /*pvUser*/); 4817 AssertRCReturn(rc, rc); 4818 #endif 4819 #if 0 && defined(VMMDEV_WITH_ALT_TIMESYNC) 4820 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortAltTimesync, vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead, NULL); 4821 AssertRCReturn(rc, rc); 4822 #endif 4823 4824 /* 4825 * We map the first page of the VMMDevRAM into raw-mode and kernel contexts so we 4826 * can handle interrupt acknowledge requests more timely (vmmdevFastRequestIrqAck). 4827 */ 4828 rc = PDMDevHlpMmio2SetUpContext(pDevIns, pThis->hMmio2VMMDevRAM, 0, PAGE_SIZE, (void **)&pThisCC->CTX_SUFF(pVMMDevRAM)); 4829 AssertRCReturn(rc, rc); 4830 4831 rc = PDMDevHlpIoPortSetUpContext(pDevIns, pThis->hIoPortFast, vmmdevFastRequestHandler, vmmdevFastRequestIrqAck, NULL); 4832 AssertRCReturn(rc, rc); 4833 4834 return VINF_SUCCESS; 4835 } 4836 4837 #endif /* !IN_RING3 */ 4746 4838 4747 4839 /** … … 4758 4850 /* .uSharedVersion = */ 42, 4759 4851 /* .cbInstanceShared = */ sizeof(VMMDEV), 4760 /* .cbInstanceCC = */ 0,4761 /* .cbInstanceRC = */ 0,4852 /* .cbInstanceCC = */ sizeof(VMMDEVCC), 4853 /* .cbInstanceRC = */ sizeof(VMMDEVRC), 4762 4854 /* .cMaxPciDevices = */ 1, 4763 4855 /* .cMaxMsixVectors = */ 0, … … 4794 4886 #elif defined(IN_RING0) 4795 4887 /* .pfnEarlyConstruct = */ NULL, 4796 /* .pfnConstruct = */ NULL,4888 /* .pfnConstruct = */ vmmdevRZConstruct, 4797 4889 /* .pfnDestruct = */ NULL, 4798 4890 /* .pfnFinalDestruct = */ NULL, … … 4807 4899 /* .pfnReserved7 = */ NULL, 4808 4900 #elif defined(IN_RC) 4809 /* .pfnConstruct = */ NULL,4901 /* .pfnConstruct = */ vmmdevRZConstruct, 4810 4902 /* .pfnReserved0 = */ NULL, 4811 4903 /* .pfnReserved1 = */ NULL, -
trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp
r81571 r81625 184 184 /** The STAM_GET_TS() value when the request arrived. */ 185 185 uint64_t tsArrival; 186 /** The STAM_GET_TS() value when the hgcm Completed() is called. */186 /** The STAM_GET_TS() value when the hgcmR3Completed() is called. */ 187 187 uint64_t tsComplete; 188 188 … … 242 242 243 243 244 static int vmmdevHGCMCmdListLock(PVMMDEV pThis)245 { 246 int rc = RTCritSectEnter(&pThis ->critsectHGCMCmdList);244 DECLINLINE(int) vmmdevR3HgcmCmdListLock(PVMMDEVCC pThisCC) 245 { 246 int rc = RTCritSectEnter(&pThisCC->critsectHGCMCmdList); 247 247 AssertRC(rc); 248 248 return rc; 249 249 } 250 250 251 static void vmmdevHGCMCmdListUnlock(PVMMDEV pThis)252 { 253 int rc = RTCritSectLeave(&pThis ->critsectHGCMCmdList);251 DECLINLINE(void) vmmdevR3HgcmCmdListUnlock(PVMMDEVCC pThisCC) 252 { 253 int rc = RTCritSectLeave(&pThisCC->critsectHGCMCmdList); 254 254 AssertRC(rc); 255 255 } … … 258 258 * 259 259 * @returns Pointer to the command on success, NULL otherwise. 260 * @param pThis The VMMDevinstance data.260 * @param pThisCC The VMMDev ring-3 instance data. 261 261 * @param enmCmdType Type of the command. 262 262 * @param GCPhys The guest physical address of the HGCM request. … … 265 265 * @param fRequestor The VMMDevRequestHeader::fRequestor value. 266 266 */ 267 static PVBOXHGCMCMD vmmdev HGCMCmdAlloc(PVMMDEV pThis, VBOXHGCMCMDTYPE enmCmdType, RTGCPHYS GCPhys,268 uint32_t cbRequest, uint32_t cParms, uint32_t fRequestor)267 static PVBOXHGCMCMD vmmdevR3HgcmCmdAlloc(PVMMDEVCC pThisCC, VBOXHGCMCMDTYPE enmCmdType, RTGCPHYS GCPhys, 268 uint32_t cbRequest, uint32_t cParms, uint32_t fRequestor) 269 269 { 270 270 #if 1 … … 276 276 if (cParms <= RT_ELEMENTS(pCmdCached->aGuestParms)) 277 277 { 278 int rc = RTMemCacheAllocEx(pThis ->hHgcmCmdCache, (void **)&pCmdCached);278 int rc = RTMemCacheAllocEx(pThisCC->hHgcmCmdCache, (void **)&pCmdCached); 279 279 if (RT_SUCCESS(rc)) 280 280 { … … 298 298 return NULL; 299 299 } 300 STAM_REL_COUNTER_INC(&pThis ->StatHgcmLargeCmdAllocs);300 STAM_REL_COUNTER_INC(&pThisCC->StatHgcmLargeCmdAllocs); 301 301 302 302 #else 303 RT_NOREF(pThis );303 RT_NOREF(pThisCC); 304 304 #endif 305 305 … … 335 335 /** Deallocate VBOXHGCMCMD memory. 336 336 * 337 * @param pThis The VMMDev instance data. 337 * @param pDevIns The device instance. 338 * @param pThisCC The VMMDev ring-3 instance data. 338 339 * @param pCmd Command to deallocate. 339 340 */ 340 static void vmmdev HGCMCmdFree(PVMMDEV pThis, PVBOXHGCMCMD pCmd)341 static void vmmdevR3HgcmCmdFree(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd) 341 342 { 342 343 if (pCmd) … … 367 368 { 368 369 if (pGuestParm->u.Pages.fLocked) 369 PDMDevHlpPhysBulkReleasePageMappingLocks(p This->pDevInsR3, pGuestParm->u.Pages.cPages,370 PDMDevHlpPhysBulkReleasePageMappingLocks(pDevIns, pGuestParm->u.Pages.cPages, 370 371 pGuestParm->u.Pages.paPgLocks); 371 372 RTMemFree(pGuestParm->u.Pages.paPgLocks); … … 378 379 if (pCmd->pvReqLocked) 379 380 { 380 PDMDevHlpPhysReleasePageMappingLock(p This->pDevInsR3, &pCmd->ReqMapLock);381 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &pCmd->ReqMapLock); 381 382 pCmd->pvReqLocked = NULL; 382 383 } … … 384 385 #if 1 385 386 if (pCmd->fMemCache) 386 RTMemCacheFree(pThis ->hHgcmCmdCache, pCmd);387 RTMemCacheFree(pThisCC->hHgcmCmdCache, pCmd); 387 388 else 388 389 #endif … … 394 395 * 395 396 * @returns VBox status code. 396 * @param pThis The VMMDev instance data. 397 * @param pDevIns The device instance. 398 * @param pThis The VMMDev shared instance data. 399 * @param pThisCC The VMMDev ring-3 instance data. 397 400 * @param pCmd Command to add. 398 401 */ 399 static int vmmdev HGCMAddCommand(PVMMDEV pThis, PVBOXHGCMCMD pCmd)400 { 401 int rc = vmmdev HGCMCmdListLock(pThis);402 static int vmmdevR3HgcmAddCommand(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd) 403 { 404 int rc = vmmdevR3HgcmCmdListLock(pThisCC); 402 405 AssertRCReturn(rc, rc); 403 406 404 407 LogFlowFunc(("%p type %d\n", pCmd, pCmd->enmCmdType)); 405 408 406 RTListPrepend(&pThis ->listHGCMCmd, &pCmd->node);409 RTListPrepend(&pThisCC->listHGCMCmd, &pCmd->node); 407 410 408 411 /* Automatically enable HGCM events, if there are HGCM commands. */ … … 411 414 || pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL) 412 415 { 413 LogFunc(("u32HGCMEnabled = %d\n", pThis ->u32HGCMEnabled));414 if (ASMAtomicCmpXchgU32(&pThis ->u32HGCMEnabled, 1, 0))415 VMMDevCtlSetGuestFilterMask(p This, VMMDEV_EVENT_HGCM, 0);416 } 417 418 vmmdev HGCMCmdListUnlock(pThis);416 LogFunc(("u32HGCMEnabled = %d\n", pThisCC->u32HGCMEnabled)); 417 if (ASMAtomicCmpXchgU32(&pThisCC->u32HGCMEnabled, 1, 0)) 418 VMMDevCtlSetGuestFilterMask(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM, 0); 419 } 420 421 vmmdevR3HgcmCmdListUnlock(pThisCC); 419 422 return rc; 420 423 } … … 423 426 * 424 427 * @returns VBox status code. 425 * @param pThis The VMMDevinstance data.428 * @param pThisCC The VMMDev ring-3 instance data. 426 429 * @param pCmd Command to remove. 427 430 */ 428 static int vmmdev HGCMRemoveCommand(PVMMDEV pThis, PVBOXHGCMCMD pCmd)429 { 430 int rc = vmmdev HGCMCmdListLock(pThis);431 static int vmmdevR3HgcmRemoveCommand(PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd) 432 { 433 int rc = vmmdevR3HgcmCmdListLock(pThisCC); 431 434 AssertRCReturn(rc, rc); 432 435 … … 435 438 RTListNodeRemove(&pCmd->node); 436 439 437 vmmdev HGCMCmdListUnlock(pThis);440 vmmdevR3HgcmCmdListUnlock(pThisCC); 438 441 return rc; 439 442 } … … 449 452 * @param GCPhys The physical address of the command we're looking for. 450 453 */ 451 DECLINLINE(PVBOXHGCMCMD) vmmdev HGCMFindCommandLocked(PVMMDEV pThis, RTGCPHYS GCPhys)454 DECLINLINE(PVBOXHGCMCMD) vmmdevR3HgcmFindCommandLocked(PVMMDEVCC pThisCC, RTGCPHYS GCPhys) 452 455 { 453 456 PVBOXHGCMCMD pCmd; 454 RTListForEach(&pThis ->listHGCMCmd, pCmd, VBOXHGCMCMD, node)457 RTListForEach(&pThisCC->listHGCMCmd, pCmd, VBOXHGCMCMD, node) 455 458 { 456 459 if (pCmd->GCPhys == GCPhys) … … 465 468 * @param pCmd Destination command. 466 469 */ 467 static void vmmdev HGCMConnectFetch(const VMMDevHGCMConnect *pHGCMConnect, PVBOXHGCMCMD pCmd)470 static void vmmdevR3HgcmConnectFetch(const VMMDevHGCMConnect *pHGCMConnect, PVBOXHGCMCMD pCmd) 468 471 { 469 472 pCmd->enmRequestType = pHGCMConnect->header.header.requestType; … … 474 477 /** Handle VMMDevHGCMConnect request. 475 478 * 476 * @param pThis The VMMDev instance data. 479 * @param pDevIns The device instance. 480 * @param pThis The VMMDev shared instance data. 481 * @param pThisCC The VMMDev ring-3 instance data. 477 482 * @param pHGCMConnect The guest request (cached in host memory). 478 483 * @param GCPhys The physical address of the request. 479 484 */ 480 int vmmdev HGCMConnect(PVMMDEV pThis, const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys)481 { 482 int rc = VINF_SUCCESS; 483 484 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_CONNECT, GCPhys, pHGCMConnect->header.header.size, 0,485 pHGCMConnect->header.header.fRequestor);485 int vmmdevR3HgcmConnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 486 const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys) 487 { 488 int rc; 489 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_CONNECT, GCPhys, pHGCMConnect->header.header.size, 0, 490 pHGCMConnect->header.header.fRequestor); 486 491 if (pCmd) 487 492 { 488 vmmdev HGCMConnectFetch(pHGCMConnect, pCmd);493 vmmdevR3HgcmConnectFetch(pHGCMConnect, pCmd); 489 494 490 495 /* Only allow the guest to use existing services! */ … … 492 497 pCmd->u.connect.pLoc->type = VMMDevHGCMLoc_LocalHost_Existing; 493 498 494 vmmdev HGCMAddCommand(pThis, pCmd);495 rc = pThis ->pHGCMDrv->pfnConnect(pThis->pHGCMDrv, pCmd, pCmd->u.connect.pLoc, &pCmd->u.connect.u32ClientID);499 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 500 rc = pThisCC->pHGCMDrv->pfnConnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.connect.pLoc, &pCmd->u.connect.u32ClientID); 496 501 if (RT_FAILURE(rc)) 497 vmmdev HGCMRemoveCommand(pThis, pCmd);502 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 498 503 } 499 504 else 500 {501 505 rc = VERR_NO_MEMORY; 502 }503 506 504 507 return rc; … … 510 513 * @param pCmd Destination command. 511 514 */ 512 static void vmmdev HGCMDisconnectFetch(const VMMDevHGCMDisconnect *pHGCMDisconnect, PVBOXHGCMCMD pCmd)515 static void vmmdevR3HgcmDisconnectFetch(const VMMDevHGCMDisconnect *pHGCMDisconnect, PVBOXHGCMCMD pCmd) 513 516 { 514 517 pCmd->enmRequestType = pHGCMDisconnect->header.header.requestType; … … 518 521 /** Handle VMMDevHGCMDisconnect request. 519 522 * 520 * @param pThis The VMMDev instance data. 523 * @param pDevIns The device instance. 524 * @param pThis The VMMDev shared instance data. 525 * @param pThisCC The VMMDev ring-3 instance data. 521 526 * @param pHGCMDisconnect The guest request (cached in host memory). 522 527 * @param GCPhys The physical address of the request. 523 528 */ 524 int vmmdev HGCMDisconnect(PVMMDEV pThis, const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys)525 { 526 int rc = VINF_SUCCESS; 527 528 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_DISCONNECT, GCPhys, pHGCMDisconnect->header.header.size, 0,529 pHGCMDisconnect->header.header.fRequestor);529 int vmmdevR3HgcmDisconnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 530 const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys) 531 { 532 int rc; 533 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_DISCONNECT, GCPhys, pHGCMDisconnect->header.header.size, 0, 534 pHGCMDisconnect->header.header.fRequestor); 530 535 if (pCmd) 531 536 { 532 vmmdev HGCMDisconnectFetch(pHGCMDisconnect, pCmd);533 534 vmmdev HGCMAddCommand(pThis, pCmd);535 rc = pThis ->pHGCMDrv->pfnDisconnect (pThis->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID);537 vmmdevR3HgcmDisconnectFetch(pHGCMDisconnect, pCmd); 538 539 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 540 rc = pThisCC->pHGCMDrv->pfnDisconnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID); 536 541 if (RT_FAILURE(rc)) 537 vmmdev HGCMRemoveCommand(pThis, pCmd);542 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 538 543 } 539 544 else … … 548 553 * @param enmType Type of the LinAddr parameter. 549 554 */ 550 static uint32_t vmmdev HGCMParmTypeToDirection(HGCMFunctionParameterType enmType)555 static uint32_t vmmdevR3HgcmParmTypeToDirection(HGCMFunctionParameterType enmType) 551 556 { 552 557 if (enmType == VMMDevHGCMParmType_LinAddr_In) return VBOX_HGCM_F_PARM_DIRECTION_TO_HOST; … … 560 565 * @param pPtr Information about a pointer HGCM parameter. 561 566 */ 562 DECLINLINE(bool) vmmdev HGCMGuestBufferIsContiguous(const VBOXHGCMPARMPTR *pPtr)567 DECLINLINE(bool) vmmdevR3HgcmGuestBufferIsContiguous(const VBOXHGCMPARMPTR *pPtr) 563 568 { 564 569 if (pPtr->cPages == 1) … … 589 594 * @param pPtr Description of the source HGCM pointer parameter. 590 595 */ 591 static int vmmdevHGCMGuestBufferRead(PPDMDEVINSR3 pDevIns, void *pvDst, uint32_t cbDst, 592 const VBOXHGCMPARMPTR *pPtr) 596 static int vmmdevR3HgcmGuestBufferRead(PPDMDEVINSR3 pDevIns, void *pvDst, uint32_t cbDst, const VBOXHGCMPARMPTR *pPtr) 593 597 { 594 598 /* … … 596 600 */ 597 601 /** @todo We need a flag for indicating this. */ 598 if (vmmdev HGCMGuestBufferIsContiguous(pPtr))602 if (vmmdevR3HgcmGuestBufferIsContiguous(pPtr)) 599 603 return PDMDevHlpPhysRead(pDevIns, pPtr->paPages[0] | pPtr->offFirstPage, pvDst, cbDst); 600 604 … … 636 640 * @param cbSrc Size of the source host buffer. 637 641 */ 638 static int vmmdevHGCMGuestBufferWrite(PPDMDEVINSR3 pDevIns, const VBOXHGCMPARMPTR *pPtr, 639 const void *pvSrc, uint32_t cbSrc) 642 static int vmmdevR3HgcmGuestBufferWrite(PPDMDEVINSR3 pDevIns, const VBOXHGCMPARMPTR *pPtr, const void *pvSrc, uint32_t cbSrc) 640 643 { 641 644 int rc = VINF_SUCCESS; … … 672 675 * 673 676 * @returns VBox status code that the guest should see. 674 * @param p This The VMMDev instance data.677 * @param pDevIns The device instance. 675 678 * @param pCmd Command structure where host parameters needs initialization. 676 679 * @param pbReq The request buffer. 677 680 */ 678 static int vmmdev HGCMInitHostParameters(PVMMDEV pThis, PVBOXHGCMCMD pCmd, uint8_t const *pbReq)681 static int vmmdevR3HgcmInitHostParameters(PPDMDEVINS pDevIns, PVBOXHGCMCMD pCmd, uint8_t const *pbReq) 679 682 { 680 683 AssertReturn(pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_INTERNAL_ERROR); … … 729 732 if (pGuestParm->enmType != VMMDevHGCMParmType_ContiguousPageList) 730 733 { 731 int rc = vmmdev HGCMGuestBufferRead(pThis->pDevInsR3, pv, cbData, &pGuestParm->u.ptr);734 int rc = vmmdevR3HgcmGuestBufferRead(pDevIns, pv, cbData, &pGuestParm->u.ptr); 732 735 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc); 733 736 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); … … 735 738 else 736 739 { 737 int rc = PDMDevHlpPhysRead(p This->pDevInsR3,740 int rc = PDMDevHlpPhysRead(pDevIns, 738 741 pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage, 739 742 pv, cbData); … … 779 782 * 780 783 * @returns VBox status code that the guest should see. 781 * @param pThis The VMMDevinstance data.784 * @param pThisCC The VMMDev ring-3 instance data. 782 785 * @param pHGCMCall The HGCMCall request (cached in host memory). 783 786 * @param cbHGCMCall Size of the request. … … 787 790 * @param pcbHGCMParmStruct Where to store size of used HGCM parameter structure. 788 791 */ 789 static int vmmdev HGCMCallAlloc(PVMMDEV pThis, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPhys,790 VMMDevRequestType enmRequestType, PVBOXHGCMCMD *ppCmd, uint32_t *pcbHGCMParmStruct)792 static int vmmdevR3HgcmCallAlloc(PVMMDEVCC pThisCC, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPhys, 793 VMMDevRequestType enmRequestType, PVBOXHGCMCMD *ppCmd, uint32_t *pcbHGCMParmStruct) 791 794 { 792 795 #ifdef VBOX_WITH_64_BITS_GUESTS … … 807 810 RT_UNTRUSTED_VALIDATED_FENCE(); 808 811 809 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_CALL, GCPhys, cbHGCMCall, cParms,810 pHGCMCall->header.header.fRequestor);812 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_CALL, GCPhys, cbHGCMCall, cParms, 813 pHGCMCall->header.header.fRequestor); 811 814 if (pCmd == NULL) 812 815 return VERR_NO_MEMORY; … … 825 828 * 826 829 * @returns VBox status code that the guest should see. 827 * @param pThis The VMMDev instance data. 830 * @param pDevIns The device instance. 831 * @param pThisCC The VMMDev ring-3 instance data. 828 832 * @param pCmd The destination command. 829 833 * @param pHGCMCall The HGCMCall request (cached in host memory). … … 832 836 * @param cbHGCMParmStruct Size of used HGCM parameter structure. 833 837 */ 834 static int vmmdev HGCMCallFetchGuestParms(PVMMDEV pThis, PVBOXHGCMCMD pCmd,835 const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall,836 VMMDevRequestType enmRequestType, uint32_t cbHGCMParmStruct)838 static int vmmdevR3HgcmCallFetchGuestParms(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, PVBOXHGCMCMD pCmd, 839 const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, 840 VMMDevRequestType enmRequestType, uint32_t cbHGCMParmStruct) 837 841 { 838 842 /* … … 926 930 pGuestParm->u.ptr.offFirstPage = offFirstPage; 927 931 pGuestParm->u.ptr.cPages = cPages; 928 pGuestParm->u.ptr.fu32Direction = vmmdev HGCMParmTypeToDirection(pGuestParm->enmType);932 pGuestParm->u.ptr.fu32Direction = vmmdevR3HgcmParmTypeToDirection(pGuestParm->enmType); 929 933 930 934 if (cbData > 0) … … 948 952 */ 949 953 RTGCPHYS GCPhys; 950 int rc2 = PDMDevHlpPhysGCPtr2GCPhys(p This->pDevInsR3, GCPtr, &GCPhys);954 int rc2 = PDMDevHlpPhysGCPtr2GCPhys(pDevIns, GCPtr, &GCPhys); 951 955 if (RT_FAILURE(rc2)) 952 956 GCPhys = NIL_RTGCPHYS; … … 1046 1050 void **papvPages = (void **)&pGuestParm->u.Pages.paPgLocks[cPages]; 1047 1051 if (pPageListInfo->flags & VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST) 1048 rc = PDMDevHlpPhysBulkGCPhys2CCPtr(p This->pDevInsR3, cPages, pPageListInfo->aPages, 0 /*fFlags*/,1052 rc = PDMDevHlpPhysBulkGCPhys2CCPtr(pDevIns, cPages, pPageListInfo->aPages, 0 /*fFlags*/, 1049 1053 papvPages, pGuestParm->u.Pages.paPgLocks); 1050 1054 else 1051 rc = PDMDevHlpPhysBulkGCPhys2CCPtrReadOnly(p This->pDevInsR3, cPages, pPageListInfo->aPages, 0 /*fFlags*/,1055 rc = PDMDevHlpPhysBulkGCPhys2CCPtrReadOnly(pDevIns, cPages, pPageListInfo->aPages, 0 /*fFlags*/, 1052 1056 (void const **)papvPages, pGuestParm->u.Pages.paPgLocks); 1053 1057 if (RT_SUCCESS(rc)) … … 1061 1065 RTMemFree(pGuestParm->u.Pages.paPgLocks); 1062 1066 pGuestParm->u.Pages.paPgLocks = NULL; 1063 STAM_REL_COUNTER_INC(&pThis ->StatHgcmFailedPageListLocking);1067 STAM_REL_COUNTER_INC(&pThisCC->StatHgcmFailedPageListLocking); 1064 1068 ASSERT_GUEST_MSG_RETURN(rc == VERR_PGM_PHYS_PAGE_RESERVED, ("cPages=%u %Rrc\n", cPages, rc), rc); 1065 1069 pGuestParm->enmType = VMMDevHGCMParmType_PageList; … … 1137 1141 * 1138 1142 * @returns VBox status code that the guest should see. 1139 * @param pThis The VMMDev instance data. 1143 * @param pDevIns The device instance. 1144 * @param pThis The VMMDev shared instance data. 1145 * @param pThisCC The VMMDev ring-3 instance data. 1140 1146 * @param pHGCMCall The request to handle (cached in host memory). 1141 1147 * @param cbHGCMCall Size of the entire request (including HGCM parameters). … … 1146 1152 * NULL). Set to NULL if HGCM takes lock ownership. 1147 1153 */ 1148 int vmmdev HGCMCall(PVMMDEV pThis, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPhys,1149 VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock)1154 int vmmdevR3HgcmCall(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, 1155 RTGCPHYS GCPhys, VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock) 1150 1156 { 1151 1157 LogFunc(("client id = %d, function = %d, cParms = %d, enmRequestType = %d, fRequestor = %#x\n", pHGCMCall->u32ClientID, … … 1169 1175 PVBOXHGCMCMD pCmd; 1170 1176 uint32_t cbHGCMParmStruct; 1171 int rc = vmmdev HGCMCallAlloc(pThis, pHGCMCall, cbHGCMCall, GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct);1177 int rc = vmmdevR3HgcmCallAlloc(pThisCC, pHGCMCall, cbHGCMCall, GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct); 1172 1178 if (RT_SUCCESS(rc)) 1173 1179 { … … 1181 1187 } 1182 1188 1183 rc = vmmdev HGCMCallFetchGuestParms(pThis, pCmd, pHGCMCall, cbHGCMCall, enmRequestType, cbHGCMParmStruct);1189 rc = vmmdevR3HgcmCallFetchGuestParms(pDevIns, pThisCC, pCmd, pHGCMCall, cbHGCMCall, enmRequestType, cbHGCMParmStruct); 1184 1190 if (RT_SUCCESS(rc)) 1185 1191 { 1186 1192 /* Copy guest data to host parameters, so HGCM services can use the data. */ 1187 rc = vmmdev HGCMInitHostParameters(pThis, pCmd, (uint8_t const *)pHGCMCall);1193 rc = vmmdevR3HgcmInitHostParameters(pDevIns, pCmd, (uint8_t const *)pHGCMCall); 1188 1194 if (RT_SUCCESS(rc)) 1189 1195 { … … 1191 1197 * Pass the function call to HGCM connector for actual processing 1192 1198 */ 1193 vmmdev HGCMAddCommand(pThis, pCmd);1199 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 1194 1200 1195 1201 #if 0 /* DONT ENABLE - for performance hacking. */ … … 1197 1203 && pCmd->u.call.cParms == 5) 1198 1204 { 1199 vmmdev HGCMRemoveCommand(pThis, pCmd);1205 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 1200 1206 1201 1207 if (pCmd->pvReqLocked) … … 1212 1218 pHeader->result = VINF_SUCCESS; 1213 1219 pHeader->fu32Flags |= VBOX_HGCM_REQ_DONE; 1214 PDMDevHlpPhysWrite(p This->pDevInsR3, GCPhys, pHeader, sizeof(*pHeader));1220 PDMDevHlpPhysWrite(pDevIns, GCPhys, pHeader, sizeof(*pHeader)); 1215 1221 } 1216 vmmdev HGCMCmdFree(pThis, pCmd);1222 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 1217 1223 return VINF_HGCM_ASYNC_EXECUTE; /* ignored, but avoids assertions. */ 1218 1224 } 1219 1225 #endif 1220 1226 1221 rc = pThis ->pHGCMDrv->pfnCall(pThis->pHGCMDrv, pCmd,1222 pCmd->u.call.u32ClientID, pCmd->u.call.u32Function,1223 pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsArrival);1227 rc = pThisCC->pHGCMDrv->pfnCall(pThisCC->pHGCMDrv, pCmd, 1228 pCmd->u.call.u32ClientID, pCmd->u.call.u32Function, 1229 pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsArrival); 1224 1230 1225 1231 if (rc == VINF_HGCM_ASYNC_EXECUTE) … … 1231 1237 uint64_t tsNow; 1232 1238 STAM_GET_TS(tsNow); 1233 STAM_REL_PROFILE_ADD_PERIOD(&pThis ->StatHgcmCmdArrival, tsNow - tsArrival);1239 STAM_REL_PROFILE_ADD_PERIOD(&pThisCC->StatHgcmCmdArrival, tsNow - tsArrival); 1234 1240 #endif 1235 1241 return rc; … … 1240 1246 */ 1241 1247 LogFunc(("pfnCall rc = %Rrc\n", rc)); 1242 vmmdev HGCMRemoveCommand(pThis, pCmd);1248 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 1243 1249 } 1244 1250 } 1245 vmmdev HGCMCmdFree(pThis, pCmd);1251 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 1246 1252 } 1247 1253 return rc; … … 1252 1258 * 1253 1259 * @returns VBox status code that the guest should see. 1254 * @param pThis The VMMDevinstance data.1260 * @param pThisCC The VMMDev ring-3 instance data. 1255 1261 * @param pHGCMCancel The request to handle (cached in host memory). 1256 1262 * @param GCPhys The address of the request. … … 1258 1264 * @thread EMT 1259 1265 */ 1260 int vmmdev HGCMCancel(PVMMDEV pThis, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPhys)1266 int vmmdevR3HgcmCancel(PVMMDEVCC pThisCC, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPhys) 1261 1267 { 1262 1268 NOREF(pHGCMCancel); 1263 int rc = vmmdev HGCMCancel2(pThis, GCPhys);1269 int rc = vmmdevR3HgcmCancel2(pThisCC, GCPhys); 1264 1270 return rc == VERR_NOT_FOUND ? VERR_INVALID_PARAMETER : rc; 1265 1271 } … … 1272 1278 * @retval VERR_INVALID_PARAMETER if the request address is invalid. 1273 1279 * 1274 * @param pThis The VMMDevinstance data.1280 * @param pThisCC The VMMDev ring-3 instance data. 1275 1281 * @param GCPhys The address of the request that should be cancelled. 1276 1282 * 1277 1283 * @thread EMT 1278 1284 */ 1279 int vmmdev HGCMCancel2(PVMMDEV pThis, RTGCPHYS GCPhys)1285 int vmmdevR3HgcmCancel2(PVMMDEVCC pThisCC, RTGCPHYS GCPhys) 1280 1286 { 1281 1287 if ( GCPhys == 0 … … 1283 1289 || GCPhys == NIL_RTGCPHYS32) 1284 1290 { 1285 Log(("vmmdev HGCMCancel2: GCPhys=%#x\n", GCPhys));1291 Log(("vmmdevR3HgcmCancel2: GCPhys=%#x\n", GCPhys)); 1286 1292 return VERR_INVALID_PARAMETER; 1287 1293 } … … 1291 1297 * the lock. hgcmCompletedWorker makes assumptions about this. 1292 1298 */ 1293 int rc = vmmdev HGCMCmdListLock(pThis);1299 int rc = vmmdevR3HgcmCmdListLock(pThisCC); 1294 1300 AssertRCReturn(rc, rc); 1295 1301 1296 PVBOXHGCMCMD pCmd = vmmdev HGCMFindCommandLocked(pThis, GCPhys);1302 PVBOXHGCMCMD pCmd = vmmdevR3HgcmFindCommandLocked(pThisCC, GCPhys); 1297 1303 if (pCmd) 1298 1304 { 1299 1305 pCmd->fCancelled = true; 1300 1306 1301 Log(("vmmdev HGCMCancel2: Cancelled pCmd=%p / GCPhys=%#x\n", pCmd, GCPhys));1302 if (pThis ->pHGCMDrv)1303 pThis ->pHGCMDrv->pfnCancelled(pThis->pHGCMDrv, pCmd,1304 pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL ? pCmd->u.call.u32ClientID1305 : pCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT ? pCmd->u.connect.u32ClientID1306 : pCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT ? pCmd->u.disconnect.u32ClientID1307 : 0);1307 Log(("vmmdevR3HgcmCancel2: Cancelled pCmd=%p / GCPhys=%#x\n", pCmd, GCPhys)); 1308 if (pThisCC->pHGCMDrv) 1309 pThisCC->pHGCMDrv->pfnCancelled(pThisCC->pHGCMDrv, pCmd, 1310 pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL ? pCmd->u.call.u32ClientID 1311 : pCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT ? pCmd->u.connect.u32ClientID 1312 : pCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT ? pCmd->u.disconnect.u32ClientID 1313 : 0); 1308 1314 } 1309 1315 else 1310 1316 rc = VERR_NOT_FOUND; 1311 1317 1312 vmmdev HGCMCmdListUnlock(pThis);1318 vmmdevR3HgcmCmdListUnlock(pThisCC); 1313 1319 return rc; 1314 1320 } … … 1317 1323 * 1318 1324 * @returns VBox status code that the guest should see. 1319 * @param p This The VMMDev instance data.1325 * @param pDevIns The device instance. 1320 1326 * @param pCmd Completed call command. 1321 1327 * @param pHGCMCall The guestrequest which needs updating (cached in the host memory). … … 1323 1329 * embedded buffers. 1324 1330 */ 1325 static int vmmdev HGCMCompleteCallRequest(PVMMDEV pThis, PVBOXHGCMCMD pCmd, VMMDevHGCMCall *pHGCMCall, uint8_t *pbReq)1331 static int vmmdevR3HgcmCompleteCallRequest(PPDMDEVINS pDevIns, PVBOXHGCMCMD pCmd, VMMDevHGCMCall *pHGCMCall, uint8_t *pbReq) 1326 1332 { 1327 1333 AssertReturn(pCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_INTERNAL_ERROR); … … 1376 1382 const void *pvSrc = pHostParm->u.pointer.addr; 1377 1383 uint32_t cbSrc = pHostParm->u.pointer.size; 1378 int rc = vmmdev HGCMGuestBufferWrite(pThis->pDevInsR3, pPtr, pvSrc, cbSrc);1384 int rc = vmmdevR3HgcmGuestBufferWrite(pDevIns, pPtr, pvSrc, cbSrc); 1379 1385 if (RT_FAILURE(rc)) 1380 1386 break; … … 1422 1428 uint32_t cbSrc = pHostParm->u.pointer.size; 1423 1429 uint32_t cbToCopy = RT_MIN(cbSrc, pPtr->cbData); 1424 int rc = PDMDevHlpPhysWrite(p This->pDevInsR3, pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage,1430 int rc = PDMDevHlpPhysWrite(pDevIns, pGuestParm->u.ptr.paPages[0] | pGuestParm->u.ptr.offFirstPage, 1425 1431 pvSrc, cbToCopy); 1426 1432 if (RT_FAILURE(rc)) … … 1441 1447 if (pGuestParm->u.Pages.fLocked) 1442 1448 { 1443 PDMDevHlpPhysBulkReleasePageMappingLocks(p This->pDevInsR3, pGuestParm->u.Pages.cPages,1449 PDMDevHlpPhysBulkReleasePageMappingLocks(pDevIns, pGuestParm->u.Pages.cPages, 1444 1450 pGuestParm->u.Pages.paPgLocks); 1445 1451 pGuestParm->u.Pages.fLocked = false; … … 1467 1473 static int hgcmCompletedWorker(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd) 1468 1474 { 1469 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IHGCMPort); 1475 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort); 1476 PPDMDEVINS pDevIns = pThisCC->pDevIns; 1477 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 1470 1478 #ifdef VBOX_WITH_DTRACE 1471 uint32_t idFunction = 0;1472 uint32_t idClient = 0;1479 uint32_t idFunction = 0; 1480 uint32_t idClient = 0; 1473 1481 #endif 1474 1482 … … 1481 1489 * It it assumed that VMMDev saves state after the HGCM services (VMMDev driver 1482 1490 * attached by constructor before it registers its SSM state), and, therefore, 1483 * VBOXHGCMCMD structures are not removed by vmmdev HGCMSaveState from the list,1491 * VBOXHGCMCMD structures are not removed by vmmdevR3HgcmSaveState from the list, 1484 1492 * while HGCM uses them. 1485 1493 */ … … 1497 1505 * back to guest memory. 1498 1506 */ 1499 vmmdev HGCMRemoveCommand(pThis, pCmd);1507 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 1500 1508 1501 1509 if (RT_LIKELY(!pCmd->fCancelled)) … … 1513 1521 * The request data is not be used for anything but checking the request type. 1514 1522 */ 1515 PDMDevHlpPhysRead(p This->pDevInsR3, pCmd->GCPhys, pHeader, pCmd->cbRequest);1523 PDMDevHlpPhysRead(pDevIns, pCmd->GCPhys, pHeader, pCmd->cbRequest); 1516 1524 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 1517 1525 … … 1534 1542 { 1535 1543 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pHeader; 1536 rc = vmmdev HGCMCompleteCallRequest(pThis, pCmd, pHGCMCall, (uint8_t *)pHeader);1544 rc = vmmdevR3HgcmCompleteCallRequest(pDevIns, pCmd, pHGCMCall, (uint8_t *)pHeader); 1537 1545 #ifdef VBOX_WITH_DTRACE 1538 1546 idFunction = pCmd->u.call.u32Function; … … 1571 1579 1572 1580 /* First write back the request. */ 1573 PDMDevHlpPhysWrite(p This->pDevInsR3, pCmd->GCPhys, pHeader, pCmd->cbRequest);1581 PDMDevHlpPhysWrite(pDevIns, pCmd->GCPhys, pHeader, pCmd->cbRequest); 1574 1582 1575 1583 /* Mark request as processed. */ … … 1577 1585 1578 1586 /* Second write the flags to mark the request as processed. */ 1579 PDMDevHlpPhysWrite(p This->pDevInsR3, pCmd->GCPhys + RT_UOFFSETOF(VMMDevHGCMRequestHeader, fu32Flags),1587 PDMDevHlpPhysWrite(pDevIns, pCmd->GCPhys + RT_UOFFSETOF(VMMDevHGCMRequestHeader, fu32Flags), 1580 1588 &pHeader->fu32Flags, sizeof(pHeader->fu32Flags)); 1581 1589 1582 1590 /* Now, when the command was removed from the internal list, notify the guest. */ 1583 VMMDevNotifyGuest(p This, VMMDEV_EVENT_HGCM);1591 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM); 1584 1592 1585 1593 RTMemFree(pHeader); … … 1615 1623 { 1616 1624 VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pHeader; 1617 rc = vmmdev HGCMCompleteCallRequest(pThis, pCmd, pHGCMCall, (uint8_t *)pHeader);1625 rc = vmmdevR3HgcmCompleteCallRequest(pDevIns, pCmd, pHGCMCall, (uint8_t *)pHeader); 1618 1626 #ifdef VBOX_WITH_DTRACE 1619 1627 idFunction = pCmd->u.call.u32Function; … … 1655 1663 1656 1664 /* Now, when the command was removed from the internal list, notify the guest. */ 1657 VMMDevNotifyGuest(p This, VMMDEV_EVENT_HGCM);1665 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM); 1658 1666 } 1659 1667 1660 1668 /* Set the status to success for now, though we might consider passing 1661 along the vmmdev HGCMCompleteCallRequest errors... */1669 along the vmmdevR3HgcmCompleteCallRequest errors... */ 1662 1670 rc = VINF_SUCCESS; 1663 1671 } … … 1676 1684 /* Deallocate the command memory. */ 1677 1685 VBOXDD_HGCMCALL_COMPLETED_DONE(pCmd, idFunction, idClient, result); 1678 vmmdev HGCMCmdFree(pThis, pCmd);1686 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 1679 1687 1680 1688 #ifndef VBOX_WITHOUT_RELEASE_STATISTICS … … 1682 1690 uint64_t tsNow; 1683 1691 STAM_GET_TS(tsNow); 1684 STAM_REL_PROFILE_ADD_PERIOD(&pThis ->StatHgcmCmdCompletion, tsNow - tsComplete);1692 STAM_REL_PROFILE_ADD_PERIOD(&pThisCC->StatHgcmCmdCompletion, tsNow - tsComplete); 1685 1693 if (tsArrival != 0) 1686 STAM_REL_PROFILE_ADD_PERIOD(&pThis ->StatHgcmCmdTotal, tsNow - tsArrival);1694 STAM_REL_PROFILE_ADD_PERIOD(&pThisCC->StatHgcmCmdTotal, tsNow - tsArrival); 1687 1695 #endif 1688 1696 … … 1698 1706 * @param pCmd Completed command, which contains updated host parameters. 1699 1707 */ 1700 DECLCALLBACK(int) hgcm Completed(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd)1708 DECLCALLBACK(int) hgcmR3Completed(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmd) 1701 1709 { 1702 1710 #if 0 /* This seems to be significantly slower. Half of MsgTotal time seems to be spend here. */ 1703 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDevState, IHGCMPort);1711 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort); 1704 1712 STAM_GET_TS(pCmd->tsComplete); 1705 1713 … … 1709 1717 * efficient...? */ 1710 1718 /* Not safe to execute asynchronously; forward to EMT */ 1711 int rc = VMR3ReqCallVoidNoWait(PDMDevHlpGetVM(p This->pDevInsR3), VMCPUID_ANY,1719 int rc = VMR3ReqCallVoidNoWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY, 1712 1720 (PFNRT)hgcmCompletedWorker, 3, pInterface, result, pCmd); 1713 1721 AssertRC(rc); … … 1723 1731 * @interface_method_impl{PDMIHGCMPORT,pfnIsCmdRestored} 1724 1732 */ 1725 DECLCALLBACK(bool) hgcm IsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)1733 DECLCALLBACK(bool) hgcmR3IsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd) 1726 1734 { 1727 1735 RT_NOREF(pInterface); … … 1732 1740 * @interface_method_impl{PDMIHGCMPORT,pfnIsCmdCancelled} 1733 1741 */ 1734 DECLCALLBACK(bool) hgcm IsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd)1742 DECLCALLBACK(bool) hgcmR3IsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd) 1735 1743 { 1736 1744 RT_NOREF(pInterface); … … 1741 1749 * @interface_method_impl{PDMIHGCMPORT,pfnGetRequestor} 1742 1750 */ 1743 DECLCALLBACK(uint32_t) hgcmGetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd) 1744 { 1745 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IHGCMPort); 1751 DECLCALLBACK(uint32_t) hgcmR3GetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd) 1752 { 1753 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort); 1754 PVMMDEV pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV); 1746 1755 AssertPtrReturn(pCmd, VMMDEV_REQUESTOR_LOWEST); 1747 1756 if (pThis->guestInfo2.fFeatures & VBOXGSTINFO2_F_REQUESTOR_INFO) … … 1753 1762 * @interface_method_impl{PDMIHGCMPORT,pfnGetVMMDevSessionId} 1754 1763 */ 1755 DECLCALLBACK(uint64_t) hgcmGetVMMDevSessionId(PPDMIHGCMPORT pInterface) 1756 { 1757 PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IHGCMPort); 1764 DECLCALLBACK(uint64_t) hgcmR3GetVMMDevSessionId(PPDMIHGCMPORT pInterface) 1765 { 1766 PVMMDEVCC pThisCC = RT_FROM_MEMBER(pInterface, VMMDEVCC, IHGCMPort); 1767 PVMMDEV pThis = PDMDEVINS_2_DATA(pThisCC->pDevIns, PVMMDEV); 1758 1768 return pThis->idSession; 1759 1769 } 1760 1770 1761 /** Save information about pending HGCM requests from pThis ->listHGCMCmd.1771 /** Save information about pending HGCM requests from pThisCC->listHGCMCmd. 1762 1772 * 1763 1773 * @returns VBox status code that the guest should see. 1764 * @param pThis The VMMDevinstance data.1774 * @param pThisCC The VMMDev ring-3 instance data. 1765 1775 * @param pSSM SSM handle for SSM functions. 1766 1776 * 1767 1777 * @thread EMT 1768 1778 */ 1769 int vmmdev HGCMSaveState(PVMMDEV pThis, PSSMHANDLE pSSM)1779 int vmmdevR3HgcmSaveState(PVMMDEVCC pThisCC, PSSMHANDLE pSSM) 1770 1780 { 1771 1781 LogFlowFunc(("\n")); … … 1774 1784 uint32_t cCmds = 0; 1775 1785 PVBOXHGCMCMD pCmd; 1776 RTListForEach(&pThis ->listHGCMCmd, pCmd, VBOXHGCMCMD, node)1786 RTListForEach(&pThisCC->listHGCMCmd, pCmd, VBOXHGCMCMD, node) 1777 1787 { 1778 1788 LogFlowFunc(("pCmd %p\n", pCmd)); … … 1787 1797 if (cCmds > 0) 1788 1798 { 1789 RTListForEach(&pThis ->listHGCMCmd, pCmd, VBOXHGCMCMD, node)1799 RTListForEach(&pThisCC->listHGCMCmd, pCmd, VBOXHGCMCMD, node) 1790 1800 { 1791 1801 LogFlowFunc(("Saving %RGp, size %d\n", pCmd->GCPhys, pCmd->cbRequest)); … … 1884 1894 /** Load information about pending HGCM requests. 1885 1895 * 1886 * Allocate VBOXHGCMCMD commands and add them to pThis ->listHGCMCmd temporarily.1887 * vmmdevHGCMLoadStateDone will process the temporary list. This includes1888 * loading the correct fRequestor fields.1896 * Allocate VBOXHGCMCMD commands and add them to pThisCC->listHGCMCmd 1897 * temporarily. vmmdevR3HgcmLoadStateDone will process the temporary list. This 1898 * includes loading the correct fRequestor fields. 1889 1899 * 1890 1900 * @returns VBox status code that the guest should see. 1891 * @param pThis The VMMDev instance data. 1901 * @param pDevIns The device instance. 1902 * @param pThis The VMMDev shared instance data. 1903 * @param pThisCC The VMMDev ring-3 instance data. 1892 1904 * @param pSSM SSM handle for SSM functions. 1893 1905 * @param uVersion Saved state version. … … 1895 1907 * @thread EMT 1896 1908 */ 1897 int vmmdev HGCMLoadState(PVMMDEV pThis, PSSMHANDLE pSSM, uint32_t uVersion)1909 int vmmdevR3HgcmLoadState(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion) 1898 1910 { 1899 1911 LogFlowFunc(("\n")); 1900 1912 1901 pThis ->u32SSMVersion = uVersion; /* For vmmdevHGCMLoadStateDone */1913 pThisCC->uSavedStateVersion = uVersion; /* For vmmdevR3HgcmLoadStateDone */ 1902 1914 1903 1915 /* Read how many commands were pending. */ … … 1934 1946 AssertRCReturn(rc, rc); 1935 1947 1936 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, enmCmdType, GCPhys, cbRequest, cParms, 0 /*fRequestor*/);1948 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, enmCmdType, GCPhys, cbRequest, cParms, 0 /*fRequestor*/); 1937 1949 AssertReturn(pCmd, VERR_NO_MEMORY); 1938 1950 … … 2041 2053 /* See current version above. */ 2042 2054 if (!fCancelled) 2043 vmmdev HGCMAddCommand(pThis, pCmd);2055 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 2044 2056 else 2045 2057 { 2046 Log(("vmmdev HGCMLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n",2058 Log(("vmmdevR3HgcmLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n", 2047 2059 enmCmdType, GCPhys, cbRequest)); 2048 vmmdev HGCMCmdFree(pThis, pCmd);2060 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2049 2061 } 2050 2062 } … … 2075 2087 2076 2088 /* For uVersion <= 12, this was the size of entire command. 2077 * Now the command is reconstructed in vmmdev HGCMLoadStateDone.2089 * Now the command is reconstructed in vmmdevR3HgcmLoadStateDone. 2078 2090 */ 2079 2091 if (uVersion <= 12) … … 2087 2099 AssertRCReturn(rc, rc); 2088 2100 2089 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, enmCmdType, GCPhys, cbRequest, cLinAddrs, 0 /*fRequestor*/);2101 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, enmCmdType, GCPhys, cbRequest, cLinAddrs, 0 /*fRequestor*/); 2090 2102 AssertReturn(pCmd, VERR_NO_MEMORY); 2091 2103 … … 2125 2137 /* See current version above. */ 2126 2138 if (!fCancelled) 2127 vmmdev HGCMAddCommand(pThis, pCmd);2139 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 2128 2140 else 2129 2141 { 2130 Log(("vmmdev HGCMLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n",2142 Log(("vmmdevR3HgcmLoadState: Skipping cancelled request: enmCmdType=%d GCPhys=%#RX32 LB %#x\n", 2131 2143 enmCmdType, GCPhys, cbRequest)); 2132 vmmdev HGCMCmdFree(pThis, pCmd);2144 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2133 2145 } 2134 2146 } … … 2153 2165 LogFlowFunc(("Restoring %RGp size %x bytes\n", GCPhys, cbRequest)); 2154 2166 2155 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_LOADSTATE, GCPhys, cbRequest, 0, 0 /*fRequestor*/);2167 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_LOADSTATE, GCPhys, cbRequest, 0, 0 /*fRequestor*/); 2156 2168 AssertReturn(pCmd, VERR_NO_MEMORY); 2157 2169 2158 vmmdev HGCMAddCommand(pThis, pCmd);2170 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 2159 2171 } 2160 2172 } … … 2166 2178 * 2167 2179 * @returns VBox status code that the guest should see. 2168 * @param pThis The VMMDevinstance data.2169 * @param u 32SSMVersion The saved state version the command has been loaded from.2180 * @param pThisCC The VMMDev ring-3 instance data. 2181 * @param uSavedStateVersion The saved state version the command has been loaded from. 2170 2182 * @param pLoadedCmd Command loaded from saved state, it is imcomplete and needs restoration. 2171 2183 * @param pReq The guest request (cached in host memory). … … 2174 2186 * @param ppRestoredCmd Where to store pointer to newly allocated restored command. 2175 2187 */ 2176 static int vmmdevHGCMRestoreConnect(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd, 2177 VMMDevHGCMConnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType, 2178 VBOXHGCMCMD **ppRestoredCmd) 2179 { 2180 RT_NOREF(pThis); 2181 2182 int rc = VINF_SUCCESS; 2183 2188 static int vmmdevR3HgcmRestoreConnect(PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, const VBOXHGCMCMD *pLoadedCmd, 2189 VMMDevHGCMConnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType, 2190 VBOXHGCMCMD **ppRestoredCmd) 2191 { 2184 2192 /* Verify the request. */ 2185 2193 ASSERT_GUEST_RETURN(cbReq >= sizeof(*pReq), VERR_MISMATCH); 2186 if (u 32SSMVersion >= 9)2194 if (uSavedStateVersion >= 9) 2187 2195 ASSERT_GUEST_RETURN(pLoadedCmd->enmCmdType == VBOXHGCMCMDTYPE_CONNECT, VERR_MISMATCH); 2188 2196 2189 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_CONNECT, pLoadedCmd->GCPhys, cbReq, 0,2190 pReq->header.header.fRequestor);2197 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_CONNECT, pLoadedCmd->GCPhys, cbReq, 0, 2198 pReq->header.header.fRequestor); 2191 2199 AssertReturn(pCmd, VERR_NO_MEMORY); 2192 2200 … … 2196 2204 pCmd->enmRequestType = enmRequestType; 2197 2205 2198 vmmdevHGCMConnectFetch(pReq, pCmd); 2199 2200 if (RT_SUCCESS(rc)) 2201 *ppRestoredCmd = pCmd; 2202 2203 return rc; 2206 vmmdevR3HgcmConnectFetch(pReq, pCmd); 2207 2208 *ppRestoredCmd = pCmd; 2209 return VINF_SUCCESS; 2204 2210 } 2205 2211 … … 2207 2213 * 2208 2214 * @returns VBox status code that the guest should see. 2209 * @param pThis The VMMDevinstance data.2210 * @param u 32SSMVersion The saved state version the command has been loaded from.2215 * @param pThisCC The VMMDev ring-3 instance data. 2216 * @param uSavedStateVersion The saved state version the command has been loaded from. 2211 2217 * @param pLoadedCmd Command loaded from saved state, it is imcomplete and needs restoration. 2212 2218 * @param pReq The guest request (cached in host memory). … … 2215 2221 * @param ppRestoredCmd Where to store pointer to newly allocated restored command. 2216 2222 */ 2217 static int vmmdevHGCMRestoreDisconnect(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd, 2218 VMMDevHGCMDisconnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType, 2219 VBOXHGCMCMD **ppRestoredCmd) 2220 { 2221 RT_NOREF(pThis); 2222 2223 int rc = VINF_SUCCESS; 2224 2223 static int vmmdevR3HgcmRestoreDisconnect(PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, const VBOXHGCMCMD *pLoadedCmd, 2224 VMMDevHGCMDisconnect *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType, 2225 VBOXHGCMCMD **ppRestoredCmd) 2226 { 2225 2227 /* Verify the request. */ 2226 2228 ASSERT_GUEST_RETURN(cbReq >= sizeof(*pReq), VERR_MISMATCH); 2227 if (u 32SSMVersion >= 9)2229 if (uSavedStateVersion >= 9) 2228 2230 ASSERT_GUEST_RETURN(pLoadedCmd->enmCmdType == VBOXHGCMCMDTYPE_DISCONNECT, VERR_MISMATCH); 2229 2231 2230 PVBOXHGCMCMD pCmd = vmmdev HGCMCmdAlloc(pThis, VBOXHGCMCMDTYPE_DISCONNECT, pLoadedCmd->GCPhys, cbReq, 0,2231 pReq->header.header.fRequestor);2232 PVBOXHGCMCMD pCmd = vmmdevR3HgcmCmdAlloc(pThisCC, VBOXHGCMCMDTYPE_DISCONNECT, pLoadedCmd->GCPhys, cbReq, 0, 2233 pReq->header.header.fRequestor); 2232 2234 AssertReturn(pCmd, VERR_NO_MEMORY); 2233 2235 … … 2237 2239 pCmd->enmRequestType = enmRequestType; 2238 2240 2239 vmmdevHGCMDisconnectFetch(pReq, pCmd); 2240 2241 if (RT_SUCCESS(rc)) 2242 *ppRestoredCmd = pCmd; 2243 2244 return rc; 2241 vmmdevR3HgcmDisconnectFetch(pReq, pCmd); 2242 2243 *ppRestoredCmd = pCmd; 2244 return VINF_SUCCESS; 2245 2245 } 2246 2246 … … 2248 2248 * 2249 2249 * @returns VBox status code that the guest should see. 2250 * @param pThis The VMMDev instance data. 2251 * @param u32SSMVersion The saved state version the command has been loaded from. 2250 * @param pDevIns The device instance. 2251 * @param pThisCC The VMMDev ring-3 instance data. 2252 * @param uSavedStateVersion The saved state version the command has been loaded from. 2252 2253 * @param pLoadedCmd Command loaded from saved state, it is imcomplete and needs restoration. 2253 2254 * @param pReq The guest request (cached in host memory). … … 2256 2257 * @param ppRestoredCmd Where to store pointer to newly allocated restored command. 2257 2258 */ 2258 static int vmmdevHGCMRestoreCall(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd, 2259 VMMDevHGCMCall *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType, 2260 VBOXHGCMCMD **ppRestoredCmd) 2261 { 2262 int rc = VINF_SUCCESS; 2263 2259 static int vmmdevR3HgcmRestoreCall(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, const VBOXHGCMCMD *pLoadedCmd, 2260 VMMDevHGCMCall *pReq, uint32_t cbReq, VMMDevRequestType enmRequestType, 2261 VBOXHGCMCMD **ppRestoredCmd) 2262 { 2264 2263 /* Verify the request. */ 2265 2264 ASSERT_GUEST_RETURN(cbReq >= sizeof(*pReq), VERR_MISMATCH); 2266 if (u 32SSMVersion >= 9)2265 if (uSavedStateVersion >= 9) 2267 2266 { 2268 2267 ASSERT_GUEST_RETURN(pLoadedCmd->enmCmdType == VBOXHGCMCMDTYPE_CALL, VERR_MISMATCH); … … 2272 2271 PVBOXHGCMCMD pCmd; 2273 2272 uint32_t cbHGCMParmStruct; 2274 rc = vmmdevHGCMCallAlloc(pThis, pReq, cbReq, pLoadedCmd->GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct);2273 int rc = vmmdevR3HgcmCallAlloc(pThisCC, pReq, cbReq, pLoadedCmd->GCPhys, enmRequestType, &pCmd, &cbHGCMParmStruct); 2275 2274 if (RT_FAILURE(rc)) 2276 2275 return rc; … … 2281 2280 pCmd->enmRequestType = enmRequestType; 2282 2281 2283 rc = vmmdev HGCMCallFetchGuestParms(pThis, pCmd, pReq, cbReq, enmRequestType, cbHGCMParmStruct);2282 rc = vmmdevR3HgcmCallFetchGuestParms(pDevIns, pThisCC, pCmd, pReq, cbReq, enmRequestType, cbHGCMParmStruct); 2284 2283 if (RT_SUCCESS(rc)) 2285 2284 { 2286 2285 /* Update LinAddr parameters from pLoadedCmd. 2287 * pLoadedCmd->u.call.cParms is actually the number of LinAddrs, see vmmdev HGCMLoadState.2286 * pLoadedCmd->u.call.cParms is actually the number of LinAddrs, see vmmdevR3HgcmLoadState. 2288 2287 */ 2289 2288 uint32_t iLinAddr; … … 2291 2290 { 2292 2291 VBOXHGCMGUESTPARM * const pLoadedParm = &pLoadedCmd->u.call.paGuestParms[iLinAddr]; 2293 /* pLoadedParm->cbData is actually index of the LinAddr parameter, see vmmdev HGCMLoadState. */2292 /* pLoadedParm->cbData is actually index of the LinAddr parameter, see vmmdevR3HgcmLoadState. */ 2294 2293 const uint32_t iParm = pLoadedParm->u.ptr.cbData; 2295 2294 ASSERT_GUEST_STMT_BREAK(iParm < pCmd->u.call.cParms, rc = VERR_MISMATCH); … … 2310 2309 *ppRestoredCmd = pCmd; 2311 2310 else 2312 vmmdev HGCMCmdFree(pThis, pCmd);2311 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2313 2312 2314 2313 return rc; … … 2319 2318 * 2320 2319 * @returns VBox status code that the guest should see. 2321 * @param pThis The VMMDev instance data. 2322 * @param u32SSMVersion Saved state version. 2320 * @param pDevIns The device instance. 2321 * @param pThisCC The VMMDev ring-3 instance data. 2322 * @param uSavedStateVersion Saved state version. 2323 2323 * @param pLoadedCmd HGCM command which needs restoration. 2324 2324 * @param pReqHdr The request (cached in host memory). … … 2326 2326 * @param ppRestoredCmd Where to store pointer to restored command. 2327 2327 */ 2328 static int vmmdev HGCMRestoreCommand(PVMMDEV pThis, uint32_t u32SSMVersion, const VBOXHGCMCMD *pLoadedCmd,2329 const VMMDevHGCMRequestHeader *pReqHdr, uint32_t cbReq,2330 VBOXHGCMCMD **ppRestoredCmd)2331 { 2332 int rc = VINF_SUCCESS;2328 static int vmmdevR3HgcmRestoreCommand(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC, uint32_t uSavedStateVersion, 2329 const VBOXHGCMCMD *pLoadedCmd, const VMMDevHGCMRequestHeader *pReqHdr, uint32_t cbReq, 2330 VBOXHGCMCMD **ppRestoredCmd) 2331 { 2332 int rc; 2333 2333 2334 2334 /* Verify the request. */ … … 2342 2342 { 2343 2343 VMMDevHGCMConnect *pReq = (VMMDevHGCMConnect *)pReqHdr; 2344 rc = vmmdevHGCMRestoreConnect(pThis, u32SSMVersion, pLoadedCmd, pReq, cbReq, enmRequestType, 2345 ppRestoredCmd); 2344 rc = vmmdevR3HgcmRestoreConnect(pThisCC, uSavedStateVersion, pLoadedCmd, pReq, cbReq, enmRequestType, ppRestoredCmd); 2346 2345 break; 2347 2346 } … … 2350 2349 { 2351 2350 VMMDevHGCMDisconnect *pReq = (VMMDevHGCMDisconnect *)pReqHdr; 2352 rc = vmmdevHGCMRestoreDisconnect(pThis, u32SSMVersion, pLoadedCmd, pReq, cbReq, enmRequestType, 2353 ppRestoredCmd); 2351 rc = vmmdevR3HgcmRestoreDisconnect(pThisCC, uSavedStateVersion, pLoadedCmd, pReq, cbReq, enmRequestType, ppRestoredCmd); 2354 2352 break; 2355 2353 } … … 2361 2359 { 2362 2360 VMMDevHGCMCall *pReq = (VMMDevHGCMCall *)pReqHdr; 2363 rc = vmmdevHGCMRestoreCall(pThis, u32SSMVersion, pLoadedCmd, pReq, cbReq, enmRequestType, 2364 ppRestoredCmd); 2361 rc = vmmdevR3HgcmRestoreCall(pDevIns, pThisCC, uSavedStateVersion, pLoadedCmd, pReq, cbReq, enmRequestType, ppRestoredCmd); 2365 2362 break; 2366 2363 } … … 2376 2373 * 2377 2374 * @returns VBox status code. 2378 * @param pThis The VMMDev instance data. 2375 * @param pDevIns The device instance. 2376 * @param pThis The VMMDev shared instance data. 2377 * @param pThisCC The VMMDev ring-3 instance data. 2379 2378 * 2380 2379 * @thread EMT 2381 2380 */ 2382 int vmmdev HGCMLoadStateDone(PVMMDEV pThis)2381 int vmmdevR3HgcmLoadStateDone(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC) 2383 2382 { 2384 2383 /* 2385 2384 * Resubmit pending HGCM commands to services. 2386 2385 * 2387 * pThis ->pHGCMCmdList contains commands loaded by vmmdevHGCMLoadState.2386 * pThisCC->pHGCMCmdList contains commands loaded by vmmdevR3HgcmLoadState. 2388 2387 * 2389 2388 * Legacy saved states (pre VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS) … … 2403 2402 /* Get local copy of the list of loaded commands. */ 2404 2403 RTLISTANCHOR listLoadedCommands; 2405 RTListMove(&listLoadedCommands, &pThis ->listHGCMCmd);2404 RTListMove(&listLoadedCommands, &pThisCC->listHGCMCmd); 2406 2405 2407 2406 /* Resubmit commands. */ … … 2420 2419 */ 2421 2420 VMMDevHGCMRequestHeader *pReqHdr = (VMMDevHGCMRequestHeader *)RTMemAlloc(pCmd->cbRequest); 2422 AssertBreakStmt(pReqHdr, vmmdev HGCMCmdFree(pThis, pCmd); rcFunc = VERR_NO_MEMORY);2423 2424 PDMDevHlpPhysRead(p This->pDevInsR3, pCmd->GCPhys, pReqHdr, pCmd->cbRequest);2421 AssertBreakStmt(pReqHdr, vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); rcFunc = VERR_NO_MEMORY); 2422 2423 PDMDevHlpPhysRead(pDevIns, pCmd->GCPhys, pReqHdr, pCmd->cbRequest); 2425 2424 RT_UNTRUSTED_NONVOLATILE_COPY_FENCE(); 2426 2425 2427 if (pThis ->pHGCMDrv)2426 if (pThisCC->pHGCMDrv) 2428 2427 { 2429 2428 /* 2430 2429 * Reconstruct legacy commands. 2431 2430 */ 2432 if (RT_LIKELY( pThis ->u32SSMVersion >= VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS2431 if (RT_LIKELY( pThisCC->uSavedStateVersion >= VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS 2433 2432 && !pCmd->fRestoreFromGuestMem)) 2434 2433 { /* likely */ } … … 2436 2435 { 2437 2436 PVBOXHGCMCMD pRestoredCmd = NULL; 2438 rcCmd = vmmdev HGCMRestoreCommand(pThis, pThis->u32SSMVersion, pCmd,2439 pReqHdr, pCmd->cbRequest, &pRestoredCmd);2437 rcCmd = vmmdevR3HgcmRestoreCommand(pDevIns, pThisCC, pThisCC->uSavedStateVersion, pCmd, 2438 pReqHdr, pCmd->cbRequest, &pRestoredCmd); 2440 2439 if (RT_SUCCESS(rcCmd)) 2441 2440 { 2442 Assert(pCmd != pRestoredCmd); /* vmmdev HGCMRestoreCommand must allocate restored command. */2443 vmmdev HGCMCmdFree(pThis, pCmd);2441 Assert(pCmd != pRestoredCmd); /* vmmdevR3HgcmRestoreCommand must allocate restored command. */ 2442 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2444 2443 pCmd = pRestoredCmd; 2445 2444 } … … 2453 2452 case VBOXHGCMCMDTYPE_CONNECT: 2454 2453 { 2455 vmmdev HGCMAddCommand(pThis, pCmd);2456 rcCmd = pThis ->pHGCMDrv->pfnConnect(pThis->pHGCMDrv, pCmd, pCmd->u.connect.pLoc,2457 &pCmd->u.connect.u32ClientID);2454 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 2455 rcCmd = pThisCC->pHGCMDrv->pfnConnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.connect.pLoc, 2456 &pCmd->u.connect.u32ClientID); 2458 2457 if (RT_FAILURE(rcCmd)) 2459 vmmdev HGCMRemoveCommand(pThis, pCmd);2458 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 2460 2459 break; 2461 2460 } … … 2463 2462 case VBOXHGCMCMDTYPE_DISCONNECT: 2464 2463 { 2465 vmmdev HGCMAddCommand(pThis, pCmd);2466 rcCmd = pThis ->pHGCMDrv->pfnDisconnect(pThis->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID);2464 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 2465 rcCmd = pThisCC->pHGCMDrv->pfnDisconnect(pThisCC->pHGCMDrv, pCmd, pCmd->u.disconnect.u32ClientID); 2467 2466 if (RT_FAILURE(rcCmd)) 2468 vmmdev HGCMRemoveCommand(pThis, pCmd);2467 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 2469 2468 break; 2470 2469 } … … 2472 2471 case VBOXHGCMCMDTYPE_CALL: 2473 2472 { 2474 rcCmd = vmmdev HGCMInitHostParameters(pThis, pCmd, (uint8_t const *)pReqHdr);2473 rcCmd = vmmdevR3HgcmInitHostParameters(pDevIns, pCmd, (uint8_t const *)pReqHdr); 2475 2474 if (RT_SUCCESS(rcCmd)) 2476 2475 { 2477 vmmdev HGCMAddCommand(pThis, pCmd);2476 vmmdevR3HgcmAddCommand(pDevIns, pThis, pThisCC, pCmd); 2478 2477 2479 2478 /* Pass the function call to HGCM connector for actual processing */ 2480 2479 uint64_t tsNow; 2481 2480 STAM_GET_TS(tsNow); 2482 rcCmd = pThis ->pHGCMDrv->pfnCall(pThis->pHGCMDrv, pCmd,2483 pCmd->u.call.u32ClientID, pCmd->u.call.u32Function,2484 pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsNow);2481 rcCmd = pThisCC->pHGCMDrv->pfnCall(pThisCC->pHGCMDrv, pCmd, 2482 pCmd->u.call.u32ClientID, pCmd->u.call.u32Function, 2483 pCmd->u.call.cParms, pCmd->u.call.paHostParms, tsNow); 2485 2484 if (RT_FAILURE(rcCmd)) 2486 2485 { 2487 2486 LogFunc(("pfnCall rc = %Rrc\n", rcCmd)); 2488 vmmdev HGCMRemoveCommand(pThis, pCmd);2487 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 2489 2488 } 2490 2489 } … … 2510 2509 2511 2510 /* Write back only the header. */ 2512 PDMDevHlpPhysWrite(p This->pDevInsR3, pCmd->GCPhys, pReqHdr, sizeof(*pReqHdr));2513 2514 VMMDevNotifyGuest(p This, VMMDEV_EVENT_HGCM);2511 PDMDevHlpPhysWrite(pDevIns, pCmd->GCPhys, pReqHdr, sizeof(*pReqHdr)); 2512 2513 VMMDevNotifyGuest(pDevIns, pThis, pThisCC, VMMDEV_EVENT_HGCM); 2515 2514 2516 2515 /* Deallocate the command memory. */ 2517 vmmdev HGCMCmdFree(pThis, pCmd);2516 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2518 2517 } 2519 2518 … … 2526 2525 { 2527 2526 RTListNodeRemove(&pCmd->node); 2528 vmmdev HGCMCmdFree(pThis, pCmd);2527 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2529 2528 } 2530 2529 } … … 2535 2534 2536 2535 /** 2537 * Counterpart to vmmdevHGCMInit(). 2538 * 2539 * @param pThis The VMMDev instance data. 2540 */ 2541 void vmmdevHGCMDestroy(PVMMDEV pThis) 2536 * Counterpart to vmmdevR3HgcmInit(). 2537 * 2538 * @param pDevIns The device instance. 2539 * @param pThisCC The VMMDev ring-3 instance data. 2540 */ 2541 void vmmdevR3HgcmDestroy(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC) 2542 2542 { 2543 2543 LogFlowFunc(("\n")); 2544 2544 2545 if (RTCritSectIsInitialized(&pThis ->critsectHGCMCmdList))2545 if (RTCritSectIsInitialized(&pThisCC->critsectHGCMCmdList)) 2546 2546 { 2547 2547 PVBOXHGCMCMD pCmd, pNext; 2548 RTListForEachSafe(&pThis ->listHGCMCmd, pCmd, pNext, VBOXHGCMCMD, node)2549 { 2550 vmmdev HGCMRemoveCommand(pThis, pCmd);2551 vmmdev HGCMCmdFree(pThis, pCmd);2548 RTListForEachSafe(&pThisCC->listHGCMCmd, pCmd, pNext, VBOXHGCMCMD, node) 2549 { 2550 vmmdevR3HgcmRemoveCommand(pThisCC, pCmd); 2551 vmmdevR3HgcmCmdFree(pDevIns, pThisCC, pCmd); 2552 2552 } 2553 2553 2554 RTCritSectDelete(&pThis ->critsectHGCMCmdList);2554 RTCritSectDelete(&pThisCC->critsectHGCMCmdList); 2555 2555 } 2556 2556 2557 2557 AssertCompile(NIL_RTMEMCACHE == (RTMEMCACHE)0); 2558 if (pThis ->hHgcmCmdCache != NIL_RTMEMCACHE)2559 { 2560 RTMemCacheDestroy(pThis ->hHgcmCmdCache);2561 pThis ->hHgcmCmdCache = NIL_RTMEMCACHE;2558 if (pThisCC->hHgcmCmdCache != NIL_RTMEMCACHE) 2559 { 2560 RTMemCacheDestroy(pThisCC->hHgcmCmdCache); 2561 pThisCC->hHgcmCmdCache = NIL_RTMEMCACHE; 2562 2562 } 2563 2563 } … … 2570 2570 * 2571 2571 * @returns VBox status code. 2572 * @param pThis The VMMDevinstance data.2573 */ 2574 int vmmdev HGCMInit(PVMMDEV pThis)2572 * @param pThisCC The VMMDev ring-3 instance data. 2573 */ 2574 int vmmdevR3HgcmInit(PVMMDEVCC pThisCC) 2575 2575 { 2576 2576 LogFlowFunc(("\n")); 2577 2577 2578 RTListInit(&pThis ->listHGCMCmd);2579 2580 int rc = RTCritSectInit(&pThis ->critsectHGCMCmdList);2578 RTListInit(&pThisCC->listHGCMCmd); 2579 2580 int rc = RTCritSectInit(&pThisCC->critsectHGCMCmdList); 2581 2581 AssertLogRelRCReturn(rc, rc); 2582 2582 2583 rc = RTMemCacheCreate(&pThis ->hHgcmCmdCache, sizeof(VBOXHGCMCMDCACHED), 64, _1M, NULL, NULL, NULL, 0);2583 rc = RTMemCacheCreate(&pThisCC->hHgcmCmdCache, sizeof(VBOXHGCMCMDCACHED), 64, _1M, NULL, NULL, NULL, 0); 2584 2584 AssertLogRelRCReturn(rc, rc); 2585 2585 2586 pThis ->u32HGCMEnabled = 0;2586 pThisCC->u32HGCMEnabled = 0; 2587 2587 2588 2588 return VINF_SUCCESS; -
trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.h
r81571 r81625 25 25 26 26 RT_C_DECLS_BEGIN 27 int vmmdevHGCMConnect(PVMMDEV pVMMDevState, const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPtr);28 int vmmdevHGCMDisconnect(PVMMDEV pVMMDevState, const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPtr);29 int vmmdevHGCMCall(PVMMDEV pVMMDevState, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, RTGCPHYS GCPtr,30 VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock);31 int vmmdevHGCMCancel(PVMMDEV pVMMDevState, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPtr);32 int vmmdevHGCMCancel2(PVMMDEV pVMMDevState, RTGCPHYS GCPtr);27 int vmmdevR3HgcmConnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 28 const VMMDevHGCMConnect *pHGCMConnect, RTGCPHYS GCPhys); 29 int vmmdevR3HgcmDisconnect(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, 30 const VMMDevHGCMDisconnect *pHGCMDisconnect, RTGCPHYS GCPhys); 31 int vmmdevR3HgcmCall(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, const VMMDevHGCMCall *pHGCMCall, uint32_t cbHGCMCall, 32 RTGCPHYS GCPhys, VMMDevRequestType enmRequestType, uint64_t tsArrival, PVMMDEVREQLOCK *ppLock); 33 33 34 DECLCALLBACK(int) hgcmCompleted(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr); 35 DECLCALLBACK(bool) hgcmIsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd); 36 DECLCALLBACK(bool) hgcmIsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd); 37 DECLCALLBACK(uint32_t) hgcmGetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd); 38 DECLCALLBACK(uint64_t) hgcmGetVMMDevSessionId(PPDMIHGCMPORT pInterface); 34 int vmmdevR3HgcmCancel(PVMMDEVCC pThisCC, const VMMDevHGCMCancel *pHGCMCancel, RTGCPHYS GCPhys); 35 int vmmdevR3HgcmCancel2(PVMMDEVCC pThisCC, RTGCPHYS GCPhys); 39 36 40 int vmmdevHGCMSaveState(PVMMDEV pVMMDevState, PSSMHANDLE pSSM); 41 int vmmdevHGCMLoadState(PVMMDEV pVMMDevState, PSSMHANDLE pSSM, uint32_t u32Version); 42 int vmmdevHGCMLoadStateDone(PVMMDEV pVMMDevState); 37 DECLCALLBACK(int) hgcmR3Completed(PPDMIHGCMPORT pInterface, int32_t result, PVBOXHGCMCMD pCmdPtr); 38 DECLCALLBACK(bool) hgcmR3IsCmdRestored(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd); 39 DECLCALLBACK(bool) hgcmR3IsCmdCancelled(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd); 40 DECLCALLBACK(uint32_t) hgcmR3GetRequestor(PPDMIHGCMPORT pInterface, PVBOXHGCMCMD pCmd); 41 DECLCALLBACK(uint64_t) hgcmR3GetVMMDevSessionId(PPDMIHGCMPORT pInterface); 43 42 44 void vmmdevHGCMDestroy(PVMMDEV pThis); 45 int vmmdevHGCMInit(PVMMDEV pThis); 43 int vmmdevR3HgcmSaveState(PVMMDEVCC pThisCC, PSSMHANDLE pSSM); 44 int vmmdevR3HgcmLoadState(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion); 45 int vmmdevR3HgcmLoadStateDone(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC); 46 47 void vmmdevR3HgcmDestroy(PPDMDEVINS pDevIns, PVMMDEVCC pThisCC); 48 int vmmdevR3HgcmInit(PVMMDEVCC pThisCC); 46 49 RT_C_DECLS_END 47 50 -
trunk/src/VBox/Devices/VMMDev/VMMDevState.h
r81571 r81625 137 137 uint32_t fHostCursorRequested; 138 138 139 /** Pointer to device instance - R3 poitner. */140 PPDMDEVINSR3 pDevInsR3;141 /** Pointer to device instance - R0 pointer. */142 PPDMDEVINSR0 pDevInsR0;143 144 /** LUN\#0 + Status: VMMDev port base interface. */145 PDMIBASE IBase;146 /** LUN\#0: VMMDev port interface. */147 PDMIVMMDEVPORT IPort;148 #ifdef VBOX_WITH_HGCM149 /** LUN\#0: HGCM port interface. */150 PDMIHGCMPORT IHGCMPort;151 //# if HC_ARCH_BITS == 32152 // RTR3PTR R3PtrAlignment1;153 //# endif154 #endif155 /** Pointer to base interface of the driver. */156 R3PTRTYPE(PPDMIBASE) pDrvBase;157 /** VMMDev connector interface */158 R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;159 #ifdef VBOX_WITH_HGCM160 /** HGCM connector interface */161 R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv;162 #endif163 139 /** message buffer for backdoor logging. */ 164 140 char szMsg[512]; … … 185 161 bool fNewGuestFilterMaskValid; 186 162 /** Alignment padding. */ 187 bool afAlignment3[7]; 188 189 /** GC physical address of VMMDev RAM area */ 190 RTGCPHYS32 GCPhysVMMDevRAM; 191 /** R3 pointer to VMMDev RAM area */ 192 R3PTRTYPE(VMMDevMemory *) pVMMDevRAMR3; 193 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */ 194 R0PTRTYPE(VMMDevMemory *) pVMMDevRAMR0; 195 #ifdef VBOX_WITH_RAW_MODE_KEEP 196 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */ 197 RCPTRTYPE(VMMDevMemory *) pVMMDevRAMRC; 198 RTRCPTR RCPtrAlignment3b; 199 #endif 200 201 /** R3 pointer to VMMDev Heap RAM area. */ 202 R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3; 203 /** GC physical address of VMMDev Heap RAM area */ 204 RTGCPHYS32 GCPhysVMMDevHeap; 163 bool afAlignment3[3]; 205 164 206 165 /** Information reported by guest via VMMDevReportGuestInfo generic request. … … 236 195 DISPLAYCHANGEDATA displayChangeData; 237 196 238 /** Pointer to the credentials. */239 R3PTRTYPE(VMMDEVCREDS *) pCredentials;240 241 #if HC_ARCH_BITS == 32242 uint32_t uAlignment4;243 #endif244 245 197 /** memory balloon change request */ 246 198 uint32_t cMbMemoryBalloon; … … 271 223 uint64_t msLatchedHostTime; 272 224 bool fTimesyncBackdoorLo; 225 bool afAlignment6[1]; 226 #else 273 227 bool afAlignment6[2]; 274 #e lse275 bool afAlignment6[1+2]; 276 #endif 277 228 #endif 229 230 /** Set if guest should be allowed to trigger state save and power off. */ 231 bool fAllowGuestToSaveState; 278 232 /** Set if GetHostTime should fail. 279 233 * Loaded from the GetHostTimeDisabled configuration value. */ … … 292 246 /** Number of additional cores to keep around. */ 293 247 uint32_t cGuestCoreDumps; 294 295 #ifdef VBOX_WITH_HGCM296 /** List of pending HGCM requests (VBOXHGCMCMD). */297 RTLISTANCHORR3 listHGCMCmd;298 /** Critical section to protect the list. */299 RTCRITSECT critsectHGCMCmdList;300 /** Whether the HGCM events are already automatically enabled. */301 uint32_t u32HGCMEnabled;302 /** Saved state version of restored commands. */303 uint32_t u32SSMVersion;304 RTMEMCACHE hHgcmCmdCache;305 STAMPROFILE StatHgcmCmdArrival;306 STAMPROFILE StatHgcmCmdCompletion;307 STAMPROFILE StatHgcmCmdTotal;308 STAMCOUNTER StatHgcmLargeCmdAllocs;309 STAMCOUNTER StatHgcmFailedPageListLocking;310 #endif /* VBOX_WITH_HGCM */311 STAMCOUNTER StatReqBufAllocs;312 313 /** Per CPU request 4K sized buffers, allocated as needed. */314 R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT];315 316 /** Status LUN: Shared folders LED */317 struct318 {319 /** The LED. */320 PDMLED Led;321 /** The LED ports. */322 PDMILEDPORTS ILeds;323 /** Partner of ILeds. */324 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;325 } SharedFolders;326 248 327 249 /** FLag whether CPU hotplug events are monitored */ … … 338 260 uint32_t StatMemBalloonChunks; 339 261 340 /** Set if RC/R0 is enabled. */341 bool fRZEnabled;342 262 /** Set if testing is enabled. */ 343 263 bool fTestingEnabled; … … 345 265 bool fTestingMMIO; 346 266 /** Alignment padding. */ 347 bool afPadding9[HC_ARCH_BITS == 32 ? 1 : 5];267 bool afPadding9[HC_ARCH_BITS == 32 ? 2 : 6]; 348 268 #ifndef VBOX_WITHOUT_TESTING_FEATURES 349 269 /** The high timestamp value. */ … … 383 303 uint8_t abReadBack[VMMDEV_TESTING_READBACK_SIZE]; 384 304 } TestingData; 385 /** The XML output file name (can be a named pipe, doesn't matter to us). */ 386 R3PTRTYPE(char *) pszTestingXmlOutput; 387 /** Testing instance for dealing with the output. */ 388 RTTEST hTestingTest; 305 306 /** Handle for the I/O ports used by the testing component. */ 307 IOMIOPORTHANDLE hIoPortTesting; 308 /** Handle for the MMIO region used by the testing component. */ 309 IOMMMIOHANDLE hMmioTesting; 389 310 #endif /* !VBOX_WITHOUT_TESTING_FEATURES */ 390 311 … … 406 327 uint64_t cNsHeartbeatTimeout; 407 328 /** Timer for signalling a flatlined guest. */ 408 PTMTIMERR3 pFlatlinedTimer;329 TMTIMERHANDLE hFlatlinedTimer; 409 330 /** @} */ 331 332 /** Handle for the backdoor logging I/O port. */ 333 IOMIOPORTHANDLE hIoPortBackdoorLog; 334 /** Handle for the alternative timesync I/O port. */ 335 IOMIOPORTHANDLE hIoPortAltTimesync; 336 /** Handle for the VMM request I/O port (PCI region \#0). */ 337 IOMIOPORTHANDLE hIoPortReq; 338 /** Handle for the fast VMM request I/O port (PCI region \#0). */ 339 IOMIOPORTHANDLE hIoPortFast; 340 /** Handle for the VMMDev RAM (PCI region \#1). */ 341 PGMMMIO2HANDLE hMmio2VMMDevRAM; 342 /** Handle for the VMMDev Heap (PCI region \#2). */ 343 PGMMMIO2HANDLE hMmio2Heap; 410 344 } VMMDEV; 411 /** Pointer to the VMM device state. */345 /** Pointer to the shared VMM device state. */ 412 346 typedef VMMDEV *PVMMDEV; 413 347 AssertCompileMemberAlignment(VMMDEV, CritSect, 8); … … 421 355 422 356 423 void VMMDevNotifyGuest(VMMDEV *pVMMDevState, uint32_t u32EventMask); 424 void VMMDevCtlSetGuestFilterMask(VMMDEV *pVMMDevState, uint32_t u32OrMask, uint32_t u32NotMask); 357 /** 358 * State structure for the VMM device, ring-3 edition. 359 */ 360 typedef struct VMMDEVR3 361 { 362 /** LUN\#0 + Status: VMMDev port base interface. */ 363 PDMIBASE IBase; 364 /** LUN\#0: VMMDev port interface. */ 365 PDMIVMMDEVPORT IPort; 366 #ifdef VBOX_WITH_HGCM 367 /** LUN\#0: HGCM port interface. */ 368 PDMIHGCMPORT IHGCMPort; 369 /** HGCM connector interface */ 370 R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv; 371 #endif 372 /** Pointer to base interface of the driver. */ 373 R3PTRTYPE(PPDMIBASE) pDrvBase; 374 /** VMMDev connector interface */ 375 R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv; 376 /** Pointer to the device instance. 377 * @note Only for interface methods to get their bearings. */ 378 PPDMDEVINSR3 pDevIns; 379 380 /** R3 pointer to VMMDev RAM area */ 381 R3PTRTYPE(VMMDevMemory *) pVMMDevRAMR3; 382 383 /** R3 pointer to VMMDev Heap RAM area. */ 384 R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3; 385 386 /** Pointer to the credentials. */ 387 R3PTRTYPE(VMMDEVCREDS *) pCredentials; 388 /** Set if pCredentials is using the RTMemSafer allocator, clear if heap. */ 389 bool fSaferCredentials; 390 bool afAlignment[7]; 391 392 #ifdef VBOX_WITH_HGCM 393 /** Critical section to protect the list. */ 394 RTCRITSECT critsectHGCMCmdList; 395 /** List of pending HGCM requests (VBOXHGCMCMD). */ 396 RTLISTANCHORR3 listHGCMCmd; 397 /** Whether the HGCM events are already automatically enabled. */ 398 uint32_t u32HGCMEnabled; 399 /** Saved state version of restored commands. */ 400 uint32_t uSavedStateVersion; 401 RTMEMCACHE hHgcmCmdCache; 402 STAMPROFILE StatHgcmCmdArrival; 403 STAMPROFILE StatHgcmCmdCompletion; 404 STAMPROFILE StatHgcmCmdTotal; 405 STAMCOUNTER StatHgcmLargeCmdAllocs; 406 STAMCOUNTER StatHgcmFailedPageListLocking; 407 #endif /* VBOX_WITH_HGCM */ 408 STAMCOUNTER StatReqBufAllocs; 409 /** Per CPU request 4K sized buffers, allocated as needed. */ 410 R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT]; 411 412 /** Status LUN: Shared folders LED */ 413 struct 414 { 415 /** The LED. */ 416 PDMLED Led; 417 /** The LED ports. */ 418 PDMILEDPORTS ILeds; 419 /** Partner of ILeds. */ 420 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector; 421 } SharedFolders; 422 423 #ifndef VBOX_WITHOUT_TESTING_FEATURES 424 /** The XML output file name (can be a named pipe, doesn't matter to us). */ 425 R3PTRTYPE(char *) pszTestingXmlOutput; 426 /** Testing instance for dealing with the output. */ 427 RTTEST hTestingTest; 428 #endif 429 } VMMDEVR3; 430 /** Pointer to the ring-3 VMM device state. */ 431 typedef VMMDEVR3 *PVMMDEVR3; 432 433 434 /** 435 * State structure for the VMM device, ring-0 edition. 436 */ 437 typedef struct VMMDEVR0 438 { 439 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */ 440 R0PTRTYPE(VMMDevMemory *) pVMMDevRAMR0; 441 } VMMDEVR0; 442 /** Pointer to the ring-0 VMM device state. */ 443 typedef VMMDEVR0 *PVMMDEVR0; 444 445 446 /** 447 * State structure for the VMM device, raw-mode edition. 448 */ 449 typedef struct VMMDEVRC 450 { 451 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */ 452 RCPTRTYPE(VMMDevMemory *) pVMMDevRAMRC; 453 } VMMDEVRC; 454 /** Pointer to the raw-mode VMM device state. */ 455 typedef VMMDEVRC *PVMMDEVRC; 456 457 458 /** @typedef VMMDEVCC 459 * The VMMDEV device data for the current context. */ 460 typedef CTX_SUFF(VMMDEV) VMMDEVCC; 461 /** @typedef PVMMDEVCC 462 * Pointer to the VMMDEV device for the current context. */ 463 typedef CTX_SUFF(PVMMDEV) PVMMDEVCC; 464 465 466 void VMMDevNotifyGuest(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents); 467 void VMMDevCtlSetGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fOrMask, uint32_t fNotMask); 425 468 426 469 -
trunk/src/VBox/Devices/VMMDev/VMMDevTesting.cpp
r81571 r81625 48 48 49 49 /** 50 * @callback_method_impl{FNIOMMMIO WRITE}51 */ 52 PDMBOTHCBDECL(int) vmmdevTestingMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)50 * @callback_method_impl{FNIOMMMIONEWWRITE} 51 */ 52 static DECLCALLBACK(VBOXSTRICTRC) vmmdevTestingMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb) 53 53 { 54 54 RT_NOREF_PV(pvUser); 55 55 56 switch ( GCPhysAddr)56 switch (off) 57 57 { 58 case VMMDEV_TESTING_MMIO_ NOP_R3:58 case VMMDEV_TESTING_MMIO_OFF_NOP_R3: 59 59 #ifndef IN_RING3 60 60 return VINF_IOM_R3_MMIO_WRITE; 61 61 #endif 62 case VMMDEV_TESTING_MMIO_ NOP:62 case VMMDEV_TESTING_MMIO_OFF_NOP: 63 63 return VINF_SUCCESS; 64 64 … … 68 68 * Readback register (64 bytes wide). 69 69 */ 70 uint32_t off = GCPhysAddr - VMMDEV_TESTING_MMIO_BASE;71 70 if ( ( off >= VMMDEV_TESTING_MMIO_OFF_READBACK 72 71 && off + cb <= VMMDEV_TESTING_MMIO_OFF_READBACK + VMMDEV_TESTING_READBACK_SIZE) … … 77 76 ) 78 77 { 79 PVMMDEV pThis = PDM INS_2_DATA(pDevIns, PVMMDEV);78 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 80 79 off &= VMMDEV_TESTING_READBACK_SIZE - 1; 81 80 switch (cb) … … 101 100 * Odd NOP accesses. 102 101 */ 103 case VMMDEV_TESTING_MMIO_ NOP_R3 + 1:104 case VMMDEV_TESTING_MMIO_ NOP_R3 + 2:105 case VMMDEV_TESTING_MMIO_ NOP_R3 + 3:106 case VMMDEV_TESTING_MMIO_ NOP_R3 + 4:107 case VMMDEV_TESTING_MMIO_ NOP_R3 + 5:108 case VMMDEV_TESTING_MMIO_ NOP_R3 + 6:109 case VMMDEV_TESTING_MMIO_ NOP_R3 + 7:102 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 1: 103 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 2: 104 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 3: 105 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 4: 106 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 5: 107 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 6: 108 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 7: 110 109 #ifndef IN_RING3 111 110 return VINF_IOM_R3_MMIO_WRITE; 112 111 #endif 113 case VMMDEV_TESTING_MMIO_ NOP + 1:114 case VMMDEV_TESTING_MMIO_ NOP + 2:115 case VMMDEV_TESTING_MMIO_ NOP + 3:116 case VMMDEV_TESTING_MMIO_ NOP + 4:117 case VMMDEV_TESTING_MMIO_ NOP + 5:118 case VMMDEV_TESTING_MMIO_ NOP + 6:119 case VMMDEV_TESTING_MMIO_ NOP + 7:112 case VMMDEV_TESTING_MMIO_OFF_NOP + 1: 113 case VMMDEV_TESTING_MMIO_OFF_NOP + 2: 114 case VMMDEV_TESTING_MMIO_OFF_NOP + 3: 115 case VMMDEV_TESTING_MMIO_OFF_NOP + 4: 116 case VMMDEV_TESTING_MMIO_OFF_NOP + 5: 117 case VMMDEV_TESTING_MMIO_OFF_NOP + 6: 118 case VMMDEV_TESTING_MMIO_OFF_NOP + 7: 120 119 return VINF_SUCCESS; 121 120 } … … 125 124 126 125 /** 127 * @callback_method_impl{FNIOMMMIO READ}128 */ 129 PDMBOTHCBDECL(int) vmmdevTestingMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)126 * @callback_method_impl{FNIOMMMIONEWREAD} 127 */ 128 static DECLCALLBACK(VBOXSTRICTRC) vmmdevTestingMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb) 130 129 { 131 130 RT_NOREF_PV(pvUser); 132 131 133 switch ( GCPhysAddr)132 switch (off) 134 133 { 135 case VMMDEV_TESTING_MMIO_ NOP_R3:134 case VMMDEV_TESTING_MMIO_OFF_NOP_R3: 136 135 #ifndef IN_RING3 137 136 return VINF_IOM_R3_MMIO_READ; 138 137 #endif 139 138 /* fall thru. */ 140 case VMMDEV_TESTING_MMIO_ NOP:139 case VMMDEV_TESTING_MMIO_OFF_NOP: 141 140 switch (cb) 142 141 { … … 165 164 * Readback register (64 bytes wide). 166 165 */ 167 uint32_t off = GCPhysAddr - VMMDEV_TESTING_MMIO_BASE;168 166 if ( ( off >= VMMDEV_TESTING_MMIO_OFF_READBACK 169 167 && off + cb <= VMMDEV_TESTING_MMIO_OFF_READBACK + 64) … … 174 172 ) 175 173 { 176 PVMMDEV pThis = PDM INS_2_DATA(pDevIns, PVMMDEV);174 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 177 175 off &= 0x3f; 178 176 switch (cb) … … 197 195 * Odd NOP accesses (for 16-bit code mainly). 198 196 */ 199 case VMMDEV_TESTING_MMIO_ NOP_R3 + 1:200 case VMMDEV_TESTING_MMIO_ NOP_R3 + 2:201 case VMMDEV_TESTING_MMIO_ NOP_R3 + 3:202 case VMMDEV_TESTING_MMIO_ NOP_R3 + 4:203 case VMMDEV_TESTING_MMIO_ NOP_R3 + 5:204 case VMMDEV_TESTING_MMIO_ NOP_R3 + 6:205 case VMMDEV_TESTING_MMIO_ NOP_R3 + 7:197 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 1: 198 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 2: 199 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 3: 200 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 4: 201 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 5: 202 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 6: 203 case VMMDEV_TESTING_MMIO_OFF_NOP_R3 + 7: 206 204 #ifndef IN_RING3 207 205 return VINF_IOM_R3_MMIO_READ; 208 206 #endif 209 case VMMDEV_TESTING_MMIO_ NOP + 1:210 case VMMDEV_TESTING_MMIO_ NOP + 2:211 case VMMDEV_TESTING_MMIO_ NOP + 3:212 case VMMDEV_TESTING_MMIO_ NOP + 4:213 case VMMDEV_TESTING_MMIO_ NOP + 5:214 case VMMDEV_TESTING_MMIO_ NOP + 6:215 case VMMDEV_TESTING_MMIO_ NOP + 7:207 case VMMDEV_TESTING_MMIO_OFF_NOP + 1: 208 case VMMDEV_TESTING_MMIO_OFF_NOP + 2: 209 case VMMDEV_TESTING_MMIO_OFF_NOP + 3: 210 case VMMDEV_TESTING_MMIO_OFF_NOP + 4: 211 case VMMDEV_TESTING_MMIO_OFF_NOP + 5: 212 case VMMDEV_TESTING_MMIO_OFF_NOP + 6: 213 case VMMDEV_TESTING_MMIO_OFF_NOP + 7: 216 214 { 217 215 static uint8_t const s_abNopValue[8] = … … 228 226 229 227 memset(pv, 0xff, cb); 230 memcpy(pv, &s_abNopValue[ GCPhysAddr & 7], RT_MIN(8 - (GCPhysAddr& 7), cb));228 memcpy(pv, &s_abNopValue[off & 7], RT_MIN(8 - (off & 7), cb)); 231 229 return VINF_SUCCESS; 232 230 } … … 291 289 292 290 /** 293 * @callback_method_impl{FNIOMIOPORTOUT} 294 */ 295 PDMBOTHCBDECL(int) vmmdevTestingIoWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32, unsigned cb) 291 * @callback_method_impl{FNIOMIOPORTNEWOUT} 292 */ 293 static DECLCALLBACK(VBOXSTRICTRC) 294 vmmdevTestingIoWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 296 295 { 297 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 296 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 297 #ifdef IN_RING3 298 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 299 #endif 298 300 RT_NOREF_PV(pvUser); 299 301 300 switch ( uPort)302 switch (offPort) 301 303 { 302 304 /* 303 305 * The NOP I/O ports are used for performance measurements. 304 306 */ 305 case VMMDEV_TESTING_IOPORT_NOP :307 case VMMDEV_TESTING_IOPORT_NOP - VMMDEV_TESTING_IOPORT_BASE: 306 308 switch (cb) 307 309 { … … 316 318 return VINF_SUCCESS; 317 319 318 case VMMDEV_TESTING_IOPORT_NOP_R3 :320 case VMMDEV_TESTING_IOPORT_NOP_R3 - VMMDEV_TESTING_IOPORT_BASE: 319 321 switch (cb) 320 322 { … … 333 335 334 336 /* The timestamp I/O ports are read-only. */ 335 case VMMDEV_TESTING_IOPORT_TS_LOW :336 case VMMDEV_TESTING_IOPORT_TS_HIGH :337 case VMMDEV_TESTING_IOPORT_TS_LOW - VMMDEV_TESTING_IOPORT_BASE: 338 case VMMDEV_TESTING_IOPORT_TS_HIGH - VMMDEV_TESTING_IOPORT_BASE: 337 339 break; 338 340 … … 341 343 * (We have to allow WORD writes for 286, 186 and 8086 execution modes.) 342 344 */ 343 case VMMDEV_TESTING_IOPORT_CMD :345 case VMMDEV_TESTING_IOPORT_CMD - VMMDEV_TESTING_IOPORT_BASE: 344 346 if (cb == 2) 345 347 { … … 359 361 * The data port. Used of providing data for a command. 360 362 */ 361 case VMMDEV_TESTING_IOPORT_DATA :363 case VMMDEV_TESTING_IOPORT_DATA - VMMDEV_TESTING_IOPORT_BASE: 362 364 { 363 365 uint32_t uCmd = pThis->u32TestingCmd; … … 386 388 case VMMDEV_TESTING_CMD_INIT: 387 389 VMMDEV_TESTING_OUTPUT(("testing: INIT '%s'\n", pThis->TestingData.String.sz)); 388 if (pThis ->hTestingTest != NIL_RTTEST)390 if (pThisCC->hTestingTest != NIL_RTTEST) 389 391 { 390 RTTestChangeName(pThis ->hTestingTest, pThis->TestingData.String.sz);391 RTTestBanner(pThis ->hTestingTest);392 RTTestChangeName(pThisCC->hTestingTest, pThis->TestingData.String.sz); 393 RTTestBanner(pThisCC->hTestingTest); 392 394 } 393 395 break; 394 396 case VMMDEV_TESTING_CMD_SUB_NEW: 395 397 VMMDEV_TESTING_OUTPUT(("testing: SUB_NEW '%s'\n", pThis->TestingData.String.sz)); 396 if (pThis ->hTestingTest != NIL_RTTEST)397 RTTestSub(pThis ->hTestingTest, pThis->TestingData.String.sz);398 if (pThisCC->hTestingTest != NIL_RTTEST) 399 RTTestSub(pThisCC->hTestingTest, pThis->TestingData.String.sz); 398 400 break; 399 401 case VMMDEV_TESTING_CMD_FAILED: 400 if (pThis ->hTestingTest != NIL_RTTEST)401 RTTestFailed(pThis ->hTestingTest, "%s", pThis->TestingData.String.sz);402 if (pThisCC->hTestingTest != NIL_RTTEST) 403 RTTestFailed(pThisCC->hTestingTest, "%s", pThis->TestingData.String.sz); 402 404 VMMDEV_TESTING_OUTPUT(("testing: FAILED '%s'\n", pThis->TestingData.String.sz)); 403 405 break; 404 406 case VMMDEV_TESTING_CMD_SKIPPED: 405 if (pThis ->hTestingTest != NIL_RTTEST)407 if (pThisCC->hTestingTest != NIL_RTTEST) 406 408 { 407 409 if (off) 408 RTTestSkipped(pThis ->hTestingTest, "%s", pThis->TestingData.String.sz);410 RTTestSkipped(pThisCC->hTestingTest, "%s", pThis->TestingData.String.sz); 409 411 else 410 RTTestSkipped(pThis ->hTestingTest, NULL);412 RTTestSkipped(pThisCC->hTestingTest, NULL); 411 413 } 412 414 VMMDEV_TESTING_OUTPUT(("testing: SKIPPED '%s'\n", pThis->TestingData.String.sz)); 413 415 break; 414 416 case VMMDEV_TESTING_CMD_PRINT: 415 if (pThis ->hTestingTest != NIL_RTTEST && off)416 RTTestPrintf(pThis ->hTestingTest, RTTESTLVL_ALWAYS, "%s", pThis->TestingData.String.sz);417 if (pThisCC->hTestingTest != NIL_RTTEST && off) 418 RTTestPrintf(pThisCC->hTestingTest, RTTESTLVL_ALWAYS, "%s", pThis->TestingData.String.sz); 417 419 VMMDEV_TESTING_OUTPUT(("testing: '%s'\n", pThis->TestingData.String.sz)); 418 420 break; … … 454 456 if (uCmd == VMMDEV_TESTING_CMD_TERM) 455 457 { 456 if (pThis ->hTestingTest != NIL_RTTEST)458 if (pThisCC->hTestingTest != NIL_RTTEST) 457 459 { 458 while (RTTestErrorCount(pThis ->hTestingTest) < u32)459 RTTestErrorInc(pThis ->hTestingTest); /* A bit stupid, but does the trick. */460 RTTestSubDone(pThis ->hTestingTest);461 RTTestSummaryAndDestroy(pThis ->hTestingTest);462 pThis ->hTestingTest = NIL_RTTEST;460 while (RTTestErrorCount(pThisCC->hTestingTest) < u32) 461 RTTestErrorInc(pThisCC->hTestingTest); /* A bit stupid, but does the trick. */ 462 RTTestSubDone(pThisCC->hTestingTest); 463 RTTestSummaryAndDestroy(pThisCC->hTestingTest); 464 pThisCC->hTestingTest = NIL_RTTEST; 463 465 } 464 466 VMMDEV_TESTING_OUTPUT(("testing: TERM - %u errors\n", u32)); … … 466 468 else 467 469 { 468 if (pThis ->hTestingTest != NIL_RTTEST)470 if (pThisCC->hTestingTest != NIL_RTTEST) 469 471 { 470 while (RTTestSubErrorCount(pThis ->hTestingTest) < u32)471 RTTestErrorInc(pThis ->hTestingTest); /* A bit stupid, but does the trick. */472 RTTestSubDone(pThis ->hTestingTest);472 while (RTTestSubErrorCount(pThisCC->hTestingTest) < u32) 473 RTTestErrorInc(pThisCC->hTestingTest); /* A bit stupid, but does the trick. */ 474 RTTestSubDone(pThisCC->hTestingTest); 473 475 } 474 476 VMMDEV_TESTING_OUTPUT(("testing: SUB_DONE - %u errors\n", u32)); … … 535 537 enmUnit = RTTESTUNIT_NONE; 536 538 } 537 if (pThis ->hTestingTest != NIL_RTTEST)538 RTTestValue(pThis ->hTestingTest, pThis->TestingData.Value.szName,539 if (pThisCC->hTestingTest != NIL_RTTEST) 540 RTTestValue(pThisCC->hTestingTest, pThis->TestingData.Value.szName, 539 541 pThis->TestingData.Value.u64Value.u, enmUnit); 540 542 … … 591 593 592 594 /** 593 * @callback_method_impl{FNIOMIOPORTIN} 594 */ 595 PDMBOTHCBDECL(int) vmmdevTestingIoRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t *pu32, unsigned cb) 595 * @callback_method_impl{FNIOMIOPORTNEWIN} 596 */ 597 static DECLCALLBACK(VBOXSTRICTRC) 598 vmmdevTestingIoRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 596 599 { 597 PVMMDEV pThis = PDM INS_2_DATA(pDevIns, PVMMDEV);600 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 598 601 RT_NOREF_PV(pvUser); 599 602 600 switch ( uPort)603 switch (offPort) 601 604 { 602 605 /* 603 606 * The NOP I/O ports are used for performance measurements. 604 607 */ 605 case VMMDEV_TESTING_IOPORT_NOP :608 case VMMDEV_TESTING_IOPORT_NOP - VMMDEV_TESTING_IOPORT_BASE: 606 609 switch (cb) 607 610 { … … 617 620 return VINF_SUCCESS; 618 621 619 case VMMDEV_TESTING_IOPORT_NOP_R3 :622 case VMMDEV_TESTING_IOPORT_NOP_R3 - VMMDEV_TESTING_IOPORT_BASE: 620 623 switch (cb) 621 624 { … … 641 644 * gives you a 64-bit timestamp value. 642 645 */ 643 case VMMDEV_TESTING_IOPORT_TS_LOW :646 case VMMDEV_TESTING_IOPORT_TS_LOW - VMMDEV_TESTING_IOPORT_BASE: 644 647 if (cb == 4) 645 648 { … … 651 654 break; 652 655 653 case VMMDEV_TESTING_IOPORT_TS_HIGH :656 case VMMDEV_TESTING_IOPORT_TS_HIGH - VMMDEV_TESTING_IOPORT_BASE: 654 657 if (cb == 4) 655 658 { … … 662 665 * The command and data registers are write-only. 663 666 */ 664 case VMMDEV_TESTING_IOPORT_CMD :665 case VMMDEV_TESTING_IOPORT_DATA :667 case VMMDEV_TESTING_IOPORT_CMD - VMMDEV_TESTING_IOPORT_BASE: 668 case VMMDEV_TESTING_IOPORT_DATA - VMMDEV_TESTING_IOPORT_BASE: 666 669 break; 667 670 … … 684 687 void vmmdevTestingTerminate(PPDMDEVINS pDevIns) 685 688 { 686 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 689 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 690 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 687 691 if (!pThis->fTestingEnabled) 688 692 return; 689 693 690 if (pThis ->hTestingTest != NIL_RTTEST)694 if (pThisCC->hTestingTest != NIL_RTTEST) 691 695 { 692 RTTestFailed(pThis ->hTestingTest, "Still open at vmmdev destruction.");693 RTTestSummaryAndDestroy(pThis ->hTestingTest);694 pThis ->hTestingTest = NIL_RTTEST;696 RTTestFailed(pThisCC->hTestingTest, "Still open at vmmdev destruction."); 697 RTTestSummaryAndDestroy(pThisCC->hTestingTest); 698 pThisCC->hTestingTest = NIL_RTTEST; 695 699 } 696 700 } … … 705 709 int vmmdevTestingInitialize(PPDMDEVINS pDevIns) 706 710 { 707 PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV); 708 int rc; 711 PVMMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PVMMDEV); 712 PVMMDEVCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVMMDEVCC); 713 int rc; 709 714 710 715 if (!pThis->fTestingEnabled) … … 717 722 * tests interfaces. Optional, needs to be explicitly enabled. 718 723 */ 719 rc = PDMDevHlpMMIORegister(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NULL /*pvUser*/, 720 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 721 vmmdevTestingMmioWrite, vmmdevTestingMmioRead, "VMMDev Testing"); 724 rc = PDMDevHlpMmioCreateAndMap(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, 725 vmmdevTestingMmioWrite, vmmdevTestingMmioRead, 726 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 727 "VMMDev Testing", &pThis->hMmioTesting); 722 728 AssertRCReturn(rc, rc); 723 if (pThis->fRZEnabled)724 {725 rc = PDMDevHlpMMIORegisterR0(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NIL_RTR0PTR /*pvUser*/,726 "vmmdevTestingMmioWrite", "vmmdevTestingMmioRead");727 AssertRCReturn(rc, rc);728 rc = PDMDevHlpMMIORegisterRC(pDevIns, VMMDEV_TESTING_MMIO_BASE, VMMDEV_TESTING_MMIO_SIZE, NIL_RTRCPTR /*pvUser*/,729 "vmmdevTestingMmioWrite", "vmmdevTestingMmioRead");730 AssertRCReturn(rc, rc);731 }732 729 } 733 730 … … 736 733 * Register the I/O ports used for testing. 737 734 */ 738 rc = PDMDevHlpIOPortRegister(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NULL, 739 vmmdevTestingIoWrite, 740 vmmdevTestingIoRead, 741 NULL /*pfnOutStr*/, 742 NULL /*pfnInStr*/, 743 "VMMDev Testing"); 735 rc = PDMDevHlpIoPortCreateAndMap(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, 736 vmmdevTestingIoWrite, vmmdevTestingIoRead, "VMMDev Testing", NULL /*paExtDescs*/, 737 &pThis->hIoPortTesting); 744 738 AssertRCReturn(rc, rc); 745 if (pThis->fRZEnabled)746 {747 rc = PDMDevHlpIOPortRegisterR0(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NIL_RTR0PTR /*pvUser*/,748 "vmmdevTestingIoWrite",749 "vmmdevTestingIoRead",750 NULL /*pszOutStr*/,751 NULL /*pszInStr*/,752 "VMMDev Testing");753 AssertRCReturn(rc, rc);754 rc = PDMDevHlpIOPortRegisterRC(pDevIns, VMMDEV_TESTING_IOPORT_BASE, VMMDEV_TESTING_IOPORT_COUNT, NIL_RTRCPTR /*pvUser*/,755 "vmmdevTestingIoWrite",756 "vmmdevTestingIoRead",757 NULL /*pszOutStr*/,758 NULL /*pszInStr*/,759 "VMMDev Testing");760 AssertRCReturn(rc, rc);761 }762 739 763 740 /* … … 765 742 */ 766 743 rc = RTTestCreateEx("VMMDevTesting", RTTEST_C_USE_ENV | RTTEST_C_NO_TLS | RTTEST_C_XML_DELAY_TOP_TEST, 767 RTTESTLVL_INVALID, -1 /*iNativeTestPipe*/, pThis ->pszTestingXmlOutput, &pThis->hTestingTest);744 RTTESTLVL_INVALID, -1 /*iNativeTestPipe*/, pThisCC->pszTestingXmlOutput, &pThisCC->hTestingTest); 768 745 if (RT_FAILURE(rc)) 769 746 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, "Error creating testing instance");
Note:
See TracChangeset
for help on using the changeset viewer.