Changeset 70600 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jan 16, 2018 3:56:12 PM (7 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
r70597 r70600 2245 2245 const uint64_t u64ScreenSize = (uint64_t)screen.u32LineSize * screen.u32Height; 2246 2246 if ( screen.u32StartOffset <= pView->u32ViewSize 2247 && u64ScreenSize <= pView->u32MaxScreenSize2247 && u64ScreenSize <= pView->u32MaxScreenSize 2248 2248 && screen.u32StartOffset <= pView->u32ViewSize - (uint32_t)u64ScreenSize) 2249 2249 { … … 2252 2252 } 2253 2253 2254 /** @todo why not use "%#RX" instead of "0x%RX"? */ 2255 LogRelFlow(("VBVA: InfoScreen: invalid data! size 0x%RX64, max 0x%RX32\n", 2254 LogRelFlow(("VBVA: InfoScreen: invalid data! size %#RX64, max %#RX32\n", 2256 2255 u64ScreenSize, pView->u32MaxScreenSize)); 2257 2256 } 2258 2257 } 2259 2258 else 2260 { 2261 LogRelFlow(("VBVA: InfoScreen: invalid data! index %RU32(%RU32)\n", screen.u32ViewIndex, 2262 pCtx->cViews)); 2263 } 2259 LogRelFlow(("VBVA: InfoScreen: invalid data! index %RU32(%RU32)\n", screen.u32ViewIndex, pCtx->cViews)); 2264 2260 2265 2261 return VERR_INVALID_PARAMETER; -
trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
r70597 r70600 202 202 203 203 204 /** 205 * List selector for VBoxVBVAExHCtlSubmit(), vdmaVBVACtlSubmit(). 206 */ 207 typedef enum 208 { 209 VBVAEXHOSTCTL_SOURCE_GUEST = 0, 210 VBVAEXHOSTCTL_SOURCE_HOST 211 } VBVAEXHOSTCTL_SOURCE; 212 213 204 214 /********************************************************************************************************************************* 205 215 * Internal Functions * 206 216 *********************************************************************************************************************************/ 207 217 #ifdef VBOX_WITH_CRHGSMI 208 static int vdmaVBVANotifyDisable(PVGASTATE pVGAState); 209 218 static int vdmaVBVANotifyDisable(PVGASTATE pVGAState); 210 219 static void VBoxVBVAExHPDataCompleteCmd(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint32_t cbCmd); 211 220 static void VBoxVBVAExHPDataCompleteCtl(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL *pCtl, int rc); 221 static int VBoxVDMAThreadEventNotify(PVBOXVDMATHREAD pThread); 222 static int vboxVDMACmdExecBpbTransfer(PVBOXVDMAHOST pVdma, const VBOXVDMACMD_DMA_BPB_TRANSFER *pTransfer, uint32_t cbBuffer); 223 static int vdmaVBVACtlSubmitSync(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL *pCtl, VBVAEXHOSTCTL_SOURCE enmSource); 224 static DECLCALLBACK(void) vdmaVBVACtlSubmitSyncCompletion(VBVAEXHOSTCONTEXT *pVbva, struct VBVAEXHOSTCTL *pCtl, 225 int rc, void *pvContext); 212 226 213 227 /* VBoxVBVAExHP**, i.e. processor functions, can NOT be called concurrently with each other, 214 228 * can be called concurrently with istelf as well as with other VBoxVBVAEx** functions except Init/Start/Term aparently */ 215 static int VBoxVBVAExHSCheckCommands(struct VBVAEXHOSTCONTEXT *pCmdVbva);216 217 static int VBoxVBVAExHSInit(struct VBVAEXHOSTCONTEXT *pCmdVbva);218 static int VBoxVBVAExHSEnable(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVABUFFER *pVBVA);219 static int VBoxVBVAExHSDisable(struct VBVAEXHOSTCONTEXT *pCmdVbva);220 static void VBoxVBVAExHSTerm(struct VBVAEXHOSTCONTEXT *pCmdVbva);221 static int VBoxVBVAExHSSaveState(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM);222 static int VBoxVBVAExHSLoadState(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM, uint32_t u32Version);223 224 229 #endif /* VBOX_WITH_CRHGSMI */ 225 230 … … 228 233 #ifdef VBOX_WITH_CRHGSMI 229 234 230 static VBVAEXHOSTCTL* VBoxVBVAExHCtlAlloc(VBVAEXHOSTCONTEXT *pCmdVbva) 235 /** 236 * Creates a host control command. 237 */ 238 static VBVAEXHOSTCTL *VBoxVBVAExHCtlCreate(VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL_TYPE enmType) 231 239 { 232 240 # ifndef VBOXVDBG_MEMCACHE_DISABLE 233 return(VBVAEXHOSTCTL*)RTMemCacheAlloc(pCmdVbva->CtlCache);241 VBVAEXHOSTCTL *pCtl = (VBVAEXHOSTCTL*)RTMemCacheAlloc(pCmdVbva->CtlCache); 234 242 # else 235 return (VBVAEXHOSTCTL*)RTMemAlloc(sizeof(VBVAEXHOSTCTL));243 VBVAEXHOSTCTL *pCtl = (VBVAEXHOSTCTL*)RTMemAlloc(sizeof(VBVAEXHOSTCTL)); 236 244 # endif 237 } 238 245 if (pCtl) 246 { 247 RT_ZERO(*pCtl); 248 pCtl->enmType = enmType; 249 } 250 else 251 WARN(("VBoxVBVAExHCtlAlloc failed\n")); 252 return pCtl; 253 } 254 255 /** 256 * Destroys a host control command. 257 */ 239 258 static void VBoxVBVAExHCtlFree(VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL *pCtl) 240 259 { … … 246 265 } 247 266 248 static VBVAEXHOSTCTL *VBoxVBVAExHCtlCreate(VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL_TYPE enmType) 249 { 250 VBVAEXHOSTCTL* pCtl = VBoxVBVAExHCtlAlloc(pCmdVbva); 251 if (!pCtl) 252 { 253 WARN(("VBoxVBVAExHCtlAlloc failed\n")); 254 return NULL; 255 } 256 257 pCtl->enmType = enmType; 258 return pCtl; 259 } 260 267 268 269 /** 270 * Works the VBVA state. 271 */ 261 272 static int vboxVBVAExHSProcessorAcquire(struct VBVAEXHOSTCONTEXT *pCmdVbva) 262 273 { … … 264 275 265 276 if (ASMAtomicCmpXchgS32(&pCmdVbva->i32State, VBVAEXHOSTCONTEXT_STATE_PROCESSING, VBVAEXHOSTCONTEXT_STATE_LISTENING)) 266 277 return VINF_SUCCESS; 267 278 return VERR_SEM_BUSY; 268 279 } 269 280 270 static VBVAEXHOSTCTL* vboxVBVAExHPCheckCtl(struct VBVAEXHOSTCONTEXT *pCmdVbva, bool *pfHostCtl, bool fHostOnlyMode) 281 /** 282 * Worker for vboxVBVAExHPDataGet() and VBoxVBVAExHPCheckHostCtlOnDisable() that 283 * gets the next control command. 284 * 285 * @returns Pointer to command if found, NULL if not. 286 * @param pCmdVbva The VBVA command context. 287 * @param pfHostCtl Where to indicate whether it's a host or guest 288 * control command. 289 * @param fHostOnlyMode Whether to only fetch host commands, or both. 290 */ 291 static VBVAEXHOSTCTL *vboxVBVAExHPCheckCtl(struct VBVAEXHOSTCONTEXT *pCmdVbva, bool *pfHostCtl, bool fHostOnlyMode) 271 292 { 272 293 Assert(pCmdVbva->i32State == VBVAEXHOSTCONTEXT_STATE_PROCESSING); … … 278 299 if (RT_SUCCESS(rc)) 279 300 { 280 VBVAEXHOSTCTL *pCtl = RTListGetFirst(&pCmdVbva->HostCtlList, VBVAEXHOSTCTL, Node);301 VBVAEXHOSTCTL *pCtl = RTListGetFirst(&pCmdVbva->HostCtlList, VBVAEXHOSTCTL, Node); 281 302 if (pCtl) 282 303 *pfHostCtl = true; … … 304 325 } 305 326 else 306 WARN(("RTCritSectEnter failed % d\n", rc));327 WARN(("RTCritSectEnter failed %Rrc\n", rc)); 307 328 308 329 return NULL; 309 330 } 310 331 311 static VBVAEXHOSTCTL* VBoxVBVAExHPCheckHostCtlOnDisable(struct VBVAEXHOSTCONTEXT *pCmdVbva) 332 /** 333 * Worker for vboxVDMACrHgcmHandleEnableRemainingHostCommand(). 334 */ 335 static VBVAEXHOSTCTL *VBoxVBVAExHPCheckHostCtlOnDisable(struct VBVAEXHOSTCONTEXT *pCmdVbva) 312 336 { 313 337 bool fHostCtl = false; 314 VBVAEXHOSTCTL *pCtl = vboxVBVAExHPCheckCtl(pCmdVbva, &fHostCtl, true);338 VBVAEXHOSTCTL *pCtl = vboxVBVAExHPCheckCtl(pCmdVbva, &fHostCtl, true); 315 339 Assert(!pCtl || fHostCtl); 316 340 return pCtl; … … 333 357 } 334 358 359 /** 360 * Works the VBVA state in response to VBVAEXHOSTCTL_TYPE_HH_INTERNAL_RESUME. 361 */ 335 362 static int VBoxVBVAExHPResume(struct VBVAEXHOSTCONTEXT *pCmdVbva) 336 363 { … … 345 372 } 346 373 374 /** 375 * Worker for vboxVBVAExHPDataGet that processes PAUSE and RESUME requests. 376 * 377 * Unclear why these cannot be handled the normal way. 378 * 379 * @returns true if handled, false if not. 380 * @param pCmdVbva The VBVA context. 381 * @param pCtl The host control command. 382 */ 347 383 static bool vboxVBVAExHPCheckProcessCtlInternal(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL* pCtl) 348 384 { … … 366 402 } 367 403 404 /** 405 * Works the VBVA state. 406 */ 368 407 static void vboxVBVAExHPProcessorRelease(struct VBVAEXHOSTCONTEXT *pCmdVbva) 369 408 { … … 373 412 } 374 413 414 /** 415 * Works the VBVA state. 416 */ 375 417 static void vboxVBVAExHPHgEventSet(struct VBVAEXHOSTCONTEXT *pCmdVbva) 376 418 { … … 380 422 } 381 423 424 /** 425 * Works the VBVA state. 426 */ 382 427 static void vboxVBVAExHPHgEventClear(struct VBVAEXHOSTCONTEXT *pCmdVbva) 383 428 { … … 457 502 } 458 503 504 /** 505 * Control command completion routine used by many. 506 */ 459 507 static void VBoxVBVAExHPDataCompleteCtl(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL *pCtl, int rc) 460 508 { … … 489 537 return VBVAEXHOST_DATA_TYPE_HOSTCTL; 490 538 } 491 continue; 539 continue; /* Processed by vboxVBVAExHPCheckProcessCtlInternal, get next. */ 492 540 } 493 541 *ppCmd = (uint8_t*)pCtl; … … 511 559 default: 512 560 /* this is something really unexpected, i.e. most likely guest has written something incorrect to the VBVA buffer */ 513 WARN(("Warning: vboxVBVAExHCmdGet returned unexpected status % d\n", rc));561 WARN(("Warning: vboxVBVAExHCmdGet returned unexpected status %Rrc\n", rc)); 514 562 return VBVAEXHOST_DATA_TYPE_NO_DATA; 515 563 } … … 557 605 } 558 606 607 /** 608 * Checks for pending VBVA command or (internal) control command. 609 */ 559 610 DECLINLINE(bool) vboxVBVAExHSHasCommands(struct VBVAEXHOSTCONTEXT *pCmdVbva) 560 611 { 561 612 VBVABUFFER *pVBVA = pCmdVbva->pVBVA; 562 563 613 if (pVBVA) 564 614 { … … 570 620 } 571 621 572 return !!ASMAtomicReadU32(&pCmdVbva->u32cCtls);622 return ASMAtomicReadU32(&pCmdVbva->u32cCtls) > 0; 573 623 } 574 624 … … 599 649 } 600 650 651 /** 652 * Worker for vboxVDMAConstruct() that initializes the give VBVA host context. 653 */ 601 654 static int VBoxVBVAExHSInit(struct VBVAEXHOSTCONTEXT *pCmdVbva) 602 655 { 603 memset(pCmdVbva, 0, sizeof (*pCmdVbva));656 RT_ZERO(*pCmdVbva); 604 657 int rc = RTCritSectInit(&pCmdVbva->CltCritSect); 605 658 if (RT_SUCCESS(rc)) … … 607 660 # ifndef VBOXVDBG_MEMCACHE_DISABLE 608 661 rc = RTMemCacheCreate(&pCmdVbva->CtlCache, sizeof (VBVAEXHOSTCTL), 609 610 611 612 613 614 615 662 0, /* size_t cbAlignment */ 663 UINT32_MAX, /* uint32_t cMaxObjects */ 664 NULL, /* PFNMEMCACHECTOR pfnCtor*/ 665 NULL, /* PFNMEMCACHEDTOR pfnDtor*/ 666 NULL, /* void *pvUser*/ 667 0 /* uint32_t fFlags*/ 668 ); 616 669 if (RT_SUCCESS(rc)) 617 670 # endif … … 619 672 RTListInit(&pCmdVbva->GuestCtlList); 620 673 RTListInit(&pCmdVbva->HostCtlList); 621 pCmdVbva->i32State = VBVAEXHOSTCONTEXT_STATE_PROCESSING;674 pCmdVbva->i32State = VBVAEXHOSTCONTEXT_STATE_PROCESSING; 622 675 pCmdVbva->i32EnableState = VBVAEXHOSTCONTEXT_ESTATE_DISABLED; 623 676 return VINF_SUCCESS; 624 677 } 625 678 # ifndef VBOXVDBG_MEMCACHE_DISABLE 626 else 627 WARN(("RTMemCacheCreate failed %d\n", rc)); 679 WARN(("RTMemCacheCreate failed %Rrc\n", rc)); 628 680 # endif 629 681 } 630 682 else 631 WARN(("RTCritSectInit failed % d\n", rc));683 WARN(("RTCritSectInit failed %Rrc\n", rc)); 632 684 633 685 return rc; 634 686 } 635 687 688 /** 689 * Checks if VBVA state is some form of enabled. 690 */ 636 691 DECLINLINE(bool) VBoxVBVAExHSIsEnabled(struct VBVAEXHOSTCONTEXT *pCmdVbva) 637 692 { 638 return (ASMAtomicUoReadS32(&pCmdVbva->i32EnableState) >= VBVAEXHOSTCONTEXT_ESTATE_PAUSED); 639 } 640 693 return ASMAtomicUoReadS32(&pCmdVbva->i32EnableState) >= VBVAEXHOSTCONTEXT_ESTATE_PAUSED; 694 } 695 696 /** 697 * Checks if VBVA state is disabled. 698 */ 641 699 DECLINLINE(bool) VBoxVBVAExHSIsDisabled(struct VBVAEXHOSTCONTEXT *pCmdVbva) 642 700 { 643 return (ASMAtomicUoReadS32(&pCmdVbva->i32EnableState) == VBVAEXHOSTCONTEXT_ESTATE_DISABLED); 644 } 645 701 return ASMAtomicUoReadS32(&pCmdVbva->i32EnableState) == VBVAEXHOSTCONTEXT_ESTATE_DISABLED; 702 } 703 704 /** 705 * Worker for vdmaVBVAEnableProcess(). 706 * 707 * @thread VDMA 708 */ 646 709 static int VBoxVBVAExHSEnable(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVABUFFER *pVBVA) 647 710 { … … 658 721 } 659 722 723 /** 724 * Works the enable state. 725 * @thread VDMA, CR, EMT, ... 726 */ 660 727 static int VBoxVBVAExHSDisable(struct VBVAEXHOSTCONTEXT *pCmdVbva) 661 728 { … … 667 734 } 668 735 736 /** 737 * Worker for vboxVDMADestruct() and vboxVDMAConstruct(). 738 */ 669 739 static void VBoxVBVAExHSTerm(struct VBVAEXHOSTCONTEXT *pCmdVbva) 670 740 { … … 685 755 # endif 686 756 687 memset(pCmdVbva, 0, sizeof (*pCmdVbva)); 688 } 689 757 RT_ZERO(*pCmdVbva); 758 } 759 760 761 /** 762 * Worker for vboxVBVAExHSSaveStateLocked(). 763 * @thread VDMA 764 */ 690 765 static int vboxVBVAExHSSaveGuestCtl(struct VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL* pCtl, uint8_t* pu8VramBase, PSSMHANDLE pSSM) 691 766 { … … 701 776 } 702 777 778 /** 779 * Worker for VBoxVBVAExHSSaveState(). 780 * @thread VDMA 781 */ 703 782 static int vboxVBVAExHSSaveStateLocked(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM) 704 783 { … … 723 802 } 724 803 725 726 /** Saves state 804 /** 805 * Handles VBVAEXHOSTCTL_TYPE_HH_SAVESTATE for vboxVDMACrHostCtlProcess, saving 806 * state on the VDMA thread. 807 * 727 808 * @returns - same as VBoxVBVAExHSCheckCommands, or failure on load state fail 809 * @thread VDMA 728 810 */ 729 811 static int VBoxVBVAExHSSaveState(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM) 730 812 { 731 813 int rc = RTCritSectEnter(&pCmdVbva->CltCritSect); 732 if (RT_FAILURE(rc)) 733 { 734 WARN(("RTCritSectEnter failed %d\n", rc)); 735 return rc; 736 } 814 AssertRCReturn(rc, rc); 737 815 738 816 rc = vboxVBVAExHSSaveStateLocked(pCmdVbva, pu8VramBase, pSSM); 739 817 if (RT_FAILURE(rc)) 740 WARN(("vboxVBVAExHSSaveStateLocked failed % d\n", rc));818 WARN(("vboxVBVAExHSSaveStateLocked failed %Rrc\n", rc)); 741 819 742 820 RTCritSectLeave(&pCmdVbva->CltCritSect); 743 744 821 return rc; 745 822 } 746 823 824 825 /** 826 * Worker for vboxVBVAExHSLoadStateLocked. 827 * @retval VINF_EOF if end stuff to load. 828 * @thread VDMA 829 */ 747 830 static int vboxVBVAExHSLoadGuestCtl(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM, uint32_t u32Version) 748 831 { … … 755 838 return VINF_EOF; 756 839 757 VBVAEXHOSTCTL *pHCtl = VBoxVBVAExHCtlCreate(pCmdVbva, (VBVAEXHOSTCTL_TYPE)u32);840 VBVAEXHOSTCTL *pHCtl = VBoxVBVAExHCtlCreate(pCmdVbva, (VBVAEXHOSTCTL_TYPE)u32); 758 841 if (!pHCtl) 759 842 { … … 776 859 } 777 860 778 861 /** 862 * Worker for VBoxVBVAExHSLoadState. 863 * @thread VDMA 864 */ 779 865 static int vboxVBVAExHSLoadStateLocked(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM, uint32_t u32Version) 780 866 { … … 786 872 787 873 int rc; 788 789 do{874 do 875 { 790 876 rc = vboxVBVAExHSLoadGuestCtl(pCmdVbva, pu8VramBase, pSSM, u32Version); 791 877 AssertLogRelRCReturn(rc, rc); 792 } while ( VINF_EOF != rc);878 } while (rc != VINF_EOF); 793 879 794 880 return VINF_SUCCESS; 795 881 } 796 882 797 /** Loads state 883 /** 884 * Handles VBVAEXHOSTCTL_TYPE_HH_LOADSTATE for vboxVDMACrHostCtlProcess(), 885 * loading state on the VDMA thread. 886 * 798 887 * @returns - same as VBoxVBVAExHSCheckCommands, or failure on load state fail 888 * @thread VDMA 799 889 */ 800 890 static int VBoxVBVAExHSLoadState(struct VBVAEXHOSTCONTEXT *pCmdVbva, uint8_t* pu8VramBase, PSSMHANDLE pSSM, uint32_t u32Version) … … 802 892 Assert(VGA_SAVEDSTATE_VERSION_3D <= u32Version); 803 893 int rc = RTCritSectEnter(&pCmdVbva->CltCritSect); 804 if (RT_FAILURE(rc)) 805 { 806 WARN(("RTCritSectEnter failed %d\n", rc)); 807 return rc; 808 } 894 AssertRCReturn(rc, rc); 809 895 810 896 rc = vboxVBVAExHSLoadStateLocked(pCmdVbva, pu8VramBase, pSSM, u32Version); 811 897 if (RT_FAILURE(rc)) 812 WARN(("vboxVBVAExHSSaveStateLocked failed % d\n", rc));898 WARN(("vboxVBVAExHSSaveStateLocked failed %Rrc\n", rc)); 813 899 814 900 RTCritSectLeave(&pCmdVbva->CltCritSect); 815 816 901 return rc; 817 902 } 818 903 819 typedef enum 820 { 821 VBVAEXHOSTCTL_SOURCE_GUEST = 0, 822 VBVAEXHOSTCTL_SOURCE_HOST 823 } VBVAEXHOSTCTL_SOURCE; 824 825 904 905 906 /** 907 * Queues a control command to the VDMA worker thread. 908 * 909 * The @a enmSource argument decides which list (guest/host) it's queued on. 910 * 911 */ 826 912 static int VBoxVBVAExHCtlSubmit(VBVAEXHOSTCONTEXT *pCmdVbva, VBVAEXHOSTCTL* pCtl, VBVAEXHOSTCTL_SOURCE enmSource, 827 913 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 828 914 { 829 if (!VBoxVBVAExHSIsEnabled(pCmdVbva)) 915 int rc; 916 if (VBoxVBVAExHSIsEnabled(pCmdVbva)) 917 { 918 pCtl->pfnComplete = pfnComplete; 919 pCtl->pvComplete = pvComplete; 920 921 rc = RTCritSectEnter(&pCmdVbva->CltCritSect); 922 if (RT_SUCCESS(rc)) 923 { 924 /* Recheck that we're enabled after we've got the lock. */ 925 if (VBoxVBVAExHSIsEnabled(pCmdVbva)) 926 { 927 /* Queue it. */ 928 if (enmSource > VBVAEXHOSTCTL_SOURCE_GUEST) 929 RTListAppend(&pCmdVbva->HostCtlList, &pCtl->Node); 930 else 931 RTListAppend(&pCmdVbva->GuestCtlList, &pCtl->Node); 932 ASMAtomicIncU32(&pCmdVbva->u32cCtls); 933 934 RTCritSectLeave(&pCmdVbva->CltCritSect); 935 936 /* Work the state or something. */ 937 rc = VBoxVBVAExHSCheckCommands(pCmdVbva); 938 } 939 else 940 { 941 RTCritSectLeave(&pCmdVbva->CltCritSect); 942 Log(("cmd vbva not enabled (race)\n")); 943 rc = VERR_INVALID_STATE; 944 } 945 } 946 else 947 AssertRC(rc); 948 } 949 else 830 950 { 831 951 Log(("cmd vbva not enabled\n")); 832 return VERR_INVALID_STATE; 833 } 834 835 pCtl->pfnComplete = pfnComplete; 836 pCtl->pvComplete = pvComplete; 837 838 int rc = RTCritSectEnter(&pCmdVbva->CltCritSect); 952 rc = VERR_INVALID_STATE; 953 } 954 return rc; 955 } 956 957 /** 958 * Submits the control command and notifies the VDMA thread. 959 */ 960 static int vdmaVBVACtlSubmit(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL *pCtl, VBVAEXHOSTCTL_SOURCE enmSource, 961 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete) 962 { 963 int rc = VBoxVBVAExHCtlSubmit(&pVdma->CmdVbva, pCtl, enmSource, pfnComplete, pvComplete); 839 964 if (RT_SUCCESS(rc)) 840 965 { 841 if (!VBoxVBVAExHSIsEnabled(pCmdVbva)) 842 { 843 Log(("cmd vbva not enabled\n")); 844 RTCritSectLeave(&pCmdVbva->CltCritSect); 845 return VERR_INVALID_STATE; 846 } 847 848 if (enmSource > VBVAEXHOSTCTL_SOURCE_GUEST) 849 RTListAppend(&pCmdVbva->HostCtlList, &pCtl->Node); 850 else 851 RTListAppend(&pCmdVbva->GuestCtlList, &pCtl->Node); 852 853 ASMAtomicIncU32(&pCmdVbva->u32cCtls); 854 855 RTCritSectLeave(&pCmdVbva->CltCritSect); 856 857 rc = VBoxVBVAExHSCheckCommands(pCmdVbva); 966 if (rc == VINF_SUCCESS) 967 return VBoxVDMAThreadEventNotify(&pVdma->Thread); 968 Assert(rc == VINF_ALREADY_INITIALIZED); 858 969 } 859 970 else 860 WARN(("RTCritSectEnter failed %d\n", rc));971 Log(("VBoxVBVAExHCtlSubmit failed %Rrc\n", rc)); 861 972 862 973 return rc; 863 974 } 975 864 976 865 977 /** … … 870 982 Assert(pThread->u32State == VBOXVDMATHREAD_STATE_CREATING); 871 983 PFNVBOXVDMATHREAD_CHANGED pfnChanged = pThread->pfnChanged; 872 void *pvChanged= pThread->pvChanged;984 void *pvChanged = pThread->pvChanged; 873 985 874 986 pThread->pfnChanged = NULL; 875 pThread->pvChanged = NULL;987 pThread->pvChanged = NULL; 876 988 877 989 ASMAtomicWriteU32(&pThread->u32State, VBOXVDMATHREAD_STATE_CREATED); … … 888 1000 Assert(pThread->u32State == VBOXVDMATHREAD_STATE_TERMINATING); 889 1001 PFNVBOXVDMATHREAD_CHANGED pfnChanged = pThread->pfnChanged; 890 void *pvChanged= pThread->pvChanged;1002 void *pvChanged = pThread->pvChanged; 891 1003 892 1004 pThread->pfnChanged = NULL; 893 pThread->pvChanged = NULL;1005 pThread->pvChanged = NULL; 894 1006 895 1007 if (pfnChanged) … … 910 1022 void VBoxVDMAThreadInit(PVBOXVDMATHREAD pThread) 911 1023 { 912 memset(pThread, 0, sizeof (*pThread));1024 RT_ZERO(*pThread); 913 1025 pThread->u32State = VBOXVDMATHREAD_STATE_TERMINATED; 914 1026 } … … 924 1036 case VBOXVDMATHREAD_STATE_TERMINATED: 925 1037 return VINF_SUCCESS; 1038 926 1039 case VBOXVDMATHREAD_STATE_TERMINATING: 927 1040 { 928 1041 int rc = RTThreadWait(pThread->hWorkerThread, RT_INDEFINITE_WAIT, NULL); 929 if ( !RT_SUCCESS(rc))1042 if (RT_SUCCESS(rc)) 930 1043 { 931 WARN(("RTThreadWait failed %d\n", rc)); 932 return rc; 1044 RTSemEventDestroy(pThread->hEvent); 1045 pThread->hEvent = NIL_RTSEMEVENT; 1046 pThread->hWorkerThread = NIL_RTTHREAD; 1047 ASMAtomicWriteU32(&pThread->u32State, VBOXVDMATHREAD_STATE_TERMINATED); 933 1048 } 934 935 RTSemEventDestroy(pThread->hEvent); 936 937 ASMAtomicWriteU32(&pThread->u32State, VBOXVDMATHREAD_STATE_TERMINATED); 938 return VINF_SUCCESS; 939 } 1049 else 1050 WARN(("RTThreadWait failed %Rrc\n", rc)); 1051 return rc; 1052 } 1053 940 1054 default: 941 1055 WARN(("invalid state")); … … 951 1065 { 952 1066 int rc = VBoxVDMAThreadCleanup(pThread); 953 if (RT_FAILURE(rc))954 {955 WARN(("VBoxVDMAThreadCleanup failed %d\n", rc));956 return rc;957 }958 959 rc = RTSemEventCreate(&pThread->hEvent);960 1067 if (RT_SUCCESS(rc)) 961 1068 { 962 pThread->u32State = VBOXVDMATHREAD_STATE_CREATING; 1069 rc = RTSemEventCreate(&pThread->hEvent); 1070 pThread->u32State = VBOXVDMATHREAD_STATE_CREATING; 963 1071 pThread->pfnChanged = pfnCreated; 964 pThread->pvChanged = pvCreated;1072 pThread->pvChanged = pvCreated; 965 1073 rc = RTThreadCreate(&pThread->hWorkerThread, pfnThread, pvThread, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "VDMA"); 966 1074 if (RT_SUCCESS(rc)) 967 1075 return VINF_SUCCESS; 968 WARN(("RTThreadCreate failed %d\n", rc)); 969 1076 1077 WARN(("RTThreadCreate failed %Rrc\n", rc)); 970 1078 RTSemEventDestroy(pThread->hEvent); 1079 pThread->hEvent = NIL_RTSEMEVENT; 1080 pThread->hWorkerThread = NIL_RTTHREAD; 1081 pThread->u32State = VBOXVDMATHREAD_STATE_TERMINATED; 971 1082 } 972 1083 else 973 WARN(("RTSemEventCreate failed %d\n", rc)); 974 975 pThread->u32State = VBOXVDMATHREAD_STATE_TERMINATED; 976 1084 WARN(("VBoxVDMAThreadCleanup failed %Rrc\n", rc)); 977 1085 return rc; 978 1086 } 979 1087 980 DECLINLINE(int) VBoxVDMAThreadEventNotify(PVBOXVDMATHREAD pThread) 1088 /** 1089 * Notifies the VDMA thread. 1090 * @thread !VDMA 1091 */ 1092 static int VBoxVDMAThreadEventNotify(PVBOXVDMATHREAD pThread) 981 1093 { 982 1094 int rc = RTSemEventSignal(pThread->hEvent); … … 985 1097 } 986 1098 987 DECLINLINE(int) VBoxVDMAThreadEventWait(PVBOXVDMATHREAD pThread, RTMSINTERVAL cMillies) 988 { 989 int rc = RTSemEventWait(pThread->hEvent, cMillies); 990 AssertRC(rc); 991 return rc; 992 } 993 994 int VBoxVDMAThreadTerm(PVBOXVDMATHREAD pThread, PFNVBOXVDMATHREAD_CHANGED pfnTerminated, void*pvTerminated, bool fNotify) 995 { 996 int rc; 997 do 1099 /** 1100 * State worker for VBVAEXHOSTCTL_TYPE_HH_ON_HGCM_UNLOAD & 1101 * VBVAEXHOSTCTL_TYPE_GHH_DISABLE in vboxVDMACrHostCtlProcess(), and 1102 * VBVAEXHOSTCTL_TYPE_GHH_DISABLE in vboxVDMACrGuestCtlProcess(). 1103 * 1104 * @thread VDMA 1105 */ 1106 static int VBoxVDMAThreadTerm(PVBOXVDMATHREAD pThread, PFNVBOXVDMATHREAD_CHANGED pfnTerminated, void *pvTerminated, bool fNotify) 1107 { 1108 for (;;) 998 1109 { 999 1110 uint32_t u32State = ASMAtomicUoReadU32(&pThread->u32State); … … 1002 1113 case VBOXVDMATHREAD_STATE_CREATED: 1003 1114 pThread->pfnChanged = pfnTerminated; 1004 pThread->pvChanged = pvTerminated;1115 pThread->pvChanged = pvTerminated; 1005 1116 ASMAtomicWriteU32(&pThread->u32State, VBOXVDMATHREAD_STATE_TERMINATING); 1006 1117 if (fNotify) 1007 1118 { 1008 rc = VBoxVDMAThreadEventNotify(pThread);1119 int rc = VBoxVDMAThreadEventNotify(pThread); 1009 1120 AssertRC(rc); 1010 1121 } 1011 1122 return VINF_SUCCESS; 1123 1012 1124 case VBOXVDMATHREAD_STATE_TERMINATING: 1013 1125 case VBOXVDMATHREAD_STATE_TERMINATED: 1014 {1015 1126 WARN(("thread is marked to termination or terminated\nn")); 1016 1127 return VERR_INVALID_STATE; 1017 } 1128 1018 1129 case VBOXVDMATHREAD_STATE_CREATING: 1019 {1020 1130 /* wait till the thread creation is completed */ 1021 1131 WARN(("concurrent thread create/destron\n")); 1022 1132 RTThreadYield(); 1023 1133 continue; 1024 } 1134 1025 1135 default: 1026 1136 WARN(("invalid state")); 1027 1137 return VERR_INVALID_STATE; 1028 1138 } 1029 } while (1); 1030 1031 WARN(("should never be here\n")); 1032 return VERR_INTERNAL_ERROR; 1033 } 1034 1035 static int vdmaVBVACtlSubmitSync(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL *pCtl, VBVAEXHOSTCTL_SOURCE enmSource); 1036 1139 } 1140 } 1141 1142 1143 1144 /* 1145 * 1146 * 1147 * vboxVDMACrCtlPost / vboxVDMACrCtlPostAsync 1148 * vboxVDMACrCtlPost / vboxVDMACrCtlPostAsync 1149 * vboxVDMACrCtlPost / vboxVDMACrCtlPostAsync 1150 * 1151 * 1152 */ 1153 1154 /** Completion callback for vboxVDMACrCtlPostAsync(). */ 1037 1155 typedef DECLCALLBACK(void) FNVBOXVDMACRCTL_CALLBACK(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void* pvContext); 1156 /** Pointer to a vboxVDMACrCtlPostAsync completion callback. */ 1038 1157 typedef FNVBOXVDMACRCTL_CALLBACK *PFNVBOXVDMACRCTL_CALLBACK; 1039 1158 1159 /** 1160 * Private wrapper around VBOXVDMACMD_CHROMIUM_CTL. 1161 */ 1040 1162 typedef struct VBOXVDMACMD_CHROMIUM_CTL_PRIVATE 1041 1163 { 1042 uint32_t cRefs; 1043 int32_t rc; 1044 PFNVBOXVDMACRCTL_CALLBACK pfnCompletion; 1045 void *pvCompletion; 1046 VBOXVDMACMD_CHROMIUM_CTL Cmd; 1164 uint32_t uMagic; /**< VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC */ 1165 uint32_t cRefs; 1166 int32_t volatile rc; 1167 PFNVBOXVDMACRCTL_CALLBACK pfnCompletion; 1168 void *pvCompletion; 1169 RTSEMEVENT hEvtDone; 1170 VBOXVDMACMD_CHROMIUM_CTL Cmd; 1047 1171 } VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, *PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE; 1048 1049 # define VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(_p) ((PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, Cmd))) 1050 1172 /** Magic number for VBOXVDMACMD_CHROMIUM_CTL_PRIVATE (Michael Wolff). */ 1173 # define VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC UINT32_C(0x19530827) 1174 1175 /** Converts from a VBOXVDMACMD_CHROMIUM_CTL::Cmd pointer to a pointer to the 1176 * containing structure. */ 1177 # define VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(_p) RT_FROM_MEMBER(pCmd, VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, Cmd) 1178 1179 /** 1180 * Creates a VBOXVDMACMD_CHROMIUM_CTL_PRIVATE instance. 1181 */ 1051 1182 static PVBOXVDMACMD_CHROMIUM_CTL vboxVDMACrCtlCreate(VBOXVDMACMD_CHROMIUM_CTL_TYPE enmCmd, uint32_t cbCmd) 1052 1183 { 1053 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = (PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE)RTMemAllocZ(cbCmd + RT_OFFSETOF(VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, Cmd));1054 Assert(pHdr);1184 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr; 1185 pHdr = (PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE)RTMemAllocZ(cbCmd + RT_OFFSETOF(VBOXVDMACMD_CHROMIUM_CTL_PRIVATE, Cmd)); 1055 1186 if (pHdr) 1056 1187 { 1057 pHdr->cRefs = 1; 1058 pHdr->rc = VERR_NOT_IMPLEMENTED; 1188 pHdr->uMagic = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC; 1189 pHdr->cRefs = 1; 1190 pHdr->rc = VERR_NOT_IMPLEMENTED; 1191 pHdr->hEvtDone = NIL_RTSEMEVENT; 1059 1192 pHdr->Cmd.enmType = enmCmd; 1060 pHdr->Cmd.cbCmd = cbCmd;1193 pHdr->Cmd.cbCmd = cbCmd; 1061 1194 return &pHdr->Cmd; 1062 1195 } 1063 1064 1196 return NULL; 1065 1197 } 1066 1198 1067 DECLINLINE(void) vboxVDMACrCtlRelease (PVBOXVDMACMD_CHROMIUM_CTL pCmd) 1199 /** 1200 * Releases a reference to a VBOXVDMACMD_CHROMIUM_CTL_PRIVATE instance. 1201 */ 1202 DECLINLINE(void) vboxVDMACrCtlRelease(PVBOXVDMACMD_CHROMIUM_CTL pCmd) 1068 1203 { 1069 1204 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd); 1205 Assert(pHdr->uMagic == VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC); 1206 1070 1207 uint32_t cRefs = ASMAtomicDecU32(&pHdr->cRefs); 1071 1208 if (!cRefs) 1209 { 1210 pHdr->uMagic = ~VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC; 1211 if (pHdr->hEvtDone != NIL_RTSEMEVENT) 1212 { 1213 RTSemEventDestroy(pHdr->hEvtDone); 1214 pHdr->hEvtDone = NIL_RTSEMEVENT; 1215 } 1072 1216 RTMemFree(pHdr); 1073 } 1074 1075 #if 0 /* unused */ 1217 } 1218 } 1219 1220 /** 1221 * Releases a reference to a VBOXVDMACMD_CHROMIUM_CTL_PRIVATE instance. 1222 */ 1076 1223 DECLINLINE(void) vboxVDMACrCtlRetain(PVBOXVDMACMD_CHROMIUM_CTL pCmd) 1077 1224 { 1078 1225 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd); 1079 ASMAtomicIncU32(&pHdr->cRefs); 1080 } 1081 #endif /* unused */ 1082 1083 DECLINLINE(int) vboxVDMACrCtlGetRc (PVBOXVDMACMD_CHROMIUM_CTL pCmd) 1226 Assert(pHdr->uMagic == VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC); 1227 1228 uint32_t cRefs = ASMAtomicIncU32(&pHdr->cRefs); 1229 Assert(cRefs > 1); 1230 Assert(cRefs < _1K); 1231 RT_NOREF_PV(cRefs); 1232 } 1233 1234 /** 1235 * Gets the result from our private chromium control command. 1236 * 1237 * @returns status code. 1238 * @param pCmd The command. 1239 */ 1240 DECLINLINE(int) vboxVDMACrCtlGetRc(PVBOXVDMACMD_CHROMIUM_CTL pCmd) 1084 1241 { 1085 1242 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd); 1243 Assert(pHdr->uMagic == VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC); 1086 1244 return pHdr->rc; 1087 1245 } 1088 1246 1089 static DECLCALLBACK(void) vboxVDMACrCtlCbSetEvent(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void* pvContext) 1090 { 1247 /** 1248 * @interface_method_impl{PDMIDISPLAYVBVACALLBACKS,pfnCrHgsmiControlCompleteAsync, 1249 * Some indirect completion magic, you gotta love this code! } 1250 */ 1251 DECLCALLBACK(int) vboxVDMACrHgsmiControlCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc) 1252 { 1253 PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface); 1254 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd); 1255 Assert(pHdr->uMagic == VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC); 1256 1257 pHdr->rc = rc; 1258 if (pHdr->pfnCompletion) 1259 pHdr->pfnCompletion(pVGAState, pCmd, pHdr->pvCompletion); 1260 return VINF_SUCCESS; 1261 } 1262 1263 /** 1264 * @callback_method_impl{FNCRCTLCOMPLETION, 1265 * Completion callback for vboxVDMACrCtlPost. } 1266 */ 1267 static DECLCALLBACK(void) vboxVDMACrCtlCbSetEvent(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void *pvContext) 1268 { 1269 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = (PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE)pvContext; 1270 Assert(pHdr == VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd)); 1271 Assert(pHdr->uMagic == VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_MAGIC); 1091 1272 RT_NOREF(pVGAState, pCmd); 1092 RTSemEventSignal((RTSEMEVENT)pvContext); 1093 } 1094 1095 # if 0 /** @todo vboxVDMACrCtlCbReleaseCmd is unused */ 1096 static DECLCALLBACK(void) vboxVDMACrCtlCbReleaseCmd(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, void* pvContext) 1097 { 1098 RT_NOREF(pVGAState, pvContext); 1099 vboxVDMACrCtlRelease(pCmd); 1100 } 1101 # endif 1102 1103 static int vboxVDMACrCtlPostAsync (PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, uint32_t cbCmd,PFNVBOXVDMACRCTL_CALLBACK pfnCompletion, void *pvCompletion)1273 1274 int rc = RTSemEventSignal(pHdr->hEvtDone); 1275 AssertRC(rc); 1276 1277 vboxVDMACrCtlRelease(&pHdr->Cmd); 1278 } 1279 1280 /** 1281 * Worker for vboxVDMACrCtlPost(). 1282 */ 1283 static int vboxVDMACrCtlPostAsync(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, uint32_t cbCmd, 1284 PFNVBOXVDMACRCTL_CALLBACK pfnCompletion, void *pvCompletion) 1104 1285 { 1105 1286 if ( pVGAState->pDrv … … 1108 1289 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd); 1109 1290 pHdr->pfnCompletion = pfnCompletion; 1110 pHdr->pvCompletion = pvCompletion;1291 pHdr->pvCompletion = pvCompletion; 1111 1292 pVGAState->pDrv->pfnCrHgsmiControlProcess(pVGAState->pDrv, pCmd, cbCmd); 1112 1293 return VINF_SUCCESS; 1113 1294 } 1114 # ifdef DEBUG_misha1115 Assert(0);1116 # endif1117 1295 return VERR_NOT_SUPPORTED; 1118 1296 } … … 1123 1301 static int vboxVDMACrCtlPost(PVGASTATE pVGAState, PVBOXVDMACMD_CHROMIUM_CTL pCmd, uint32_t cbCmd) 1124 1302 { 1125 RTSEMEVENT hComplEvent; 1126 int rc = RTSemEventCreate(&hComplEvent); 1303 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pHdr = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd); 1304 1305 /* Allocate the semaphore. */ 1306 Assert(pHdr->hEvtDone == NIL_RTSEMEVENT); 1307 int rc = RTSemEventCreate(&pHdr->hEvtDone); 1308 AssertRCReturn(rc, rc); 1309 1310 /* Grab a reference for the completion routine. */ 1311 vboxVDMACrCtlRetain(&pHdr->Cmd); 1312 1313 /* Submit and wait for it. */ 1314 rc = vboxVDMACrCtlPostAsync(pVGAState, pCmd, cbCmd, vboxVDMACrCtlCbSetEvent, pHdr); 1127 1315 AssertRC(rc); 1128 1316 if (RT_SUCCESS(rc)) 1129 { 1130 rc = vboxVDMACrCtlPostAsync(pVGAState, pCmd, cbCmd, vboxVDMACrCtlCbSetEvent, (void*)hComplEvent); 1131 # ifdef DEBUG_misha 1132 AssertRC(rc); 1133 # endif 1134 if (RT_SUCCESS(rc)) 1135 { 1136 rc = RTSemEventWaitNoResume(hComplEvent, RT_INDEFINITE_WAIT); 1137 AssertRC(rc); 1138 if (RT_SUCCESS(rc)) 1139 { 1140 RTSemEventDestroy(hComplEvent); 1141 } 1142 } 1143 else 1144 { 1145 /* the command is completed */ 1146 RTSemEventDestroy(hComplEvent); 1147 } 1148 } 1317 rc = RTSemEventWaitNoResume(pHdr->hEvtDone, RT_INDEFINITE_WAIT); 1318 else 1319 vboxVDMACrCtlRelease(pCmd); 1149 1320 return rc; 1150 1321 } 1151 1322 1323 1324 /** 1325 * Structure for passing data between vboxVDMACrHgcmSubmitSync() and the 1326 * completion routine vboxVDMACrHgcmSubmitSyncCompletion(). 1327 */ 1152 1328 typedef struct VDMA_VBVA_CTL_CYNC_COMPLETION 1153 1329 { 1154 int rc;1330 int volatile rc; 1155 1331 RTSEMEVENT hEvent; 1156 1332 } VDMA_VBVA_CTL_CYNC_COMPLETION; 1157 1333 1158 static DECLCALLBACK(void) vboxVDMACrHgcmSubmitSyncCompletion(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion) 1159 { 1160 RT_NOREF(pCmd, cbCmd); 1334 /** 1335 * @callback_method_impl{FNCRCTLCOMPLETION, 1336 * Completion callback for vboxVDMACrHgcmSubmitSync() that signals the 1337 * waiting thread.} 1338 */ 1339 static DECLCALLBACK(void) vboxVDMACrHgcmSubmitSyncCompletion(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, int rc, void *pvCompletion) 1340 { 1161 1341 VDMA_VBVA_CTL_CYNC_COMPLETION *pData = (VDMA_VBVA_CTL_CYNC_COMPLETION*)pvCompletion; 1162 1342 pData->rc = rc; 1163 1343 rc = RTSemEventSignal(pData->hEvent); 1164 if (!RT_SUCCESS(rc)) 1165 WARN(("RTSemEventSignal failed %d\n", rc)); 1166 } 1167 1344 AssertLogRelRC(rc); 1345 1346 RT_NOREF(pCmd, cbCmd); 1347 } 1348 1349 /** 1350 * Worker for vboxVDMACrHgcmHandleEnable() and vdmaVBVAEnableProcess() that 1351 * works pVGAState->pDrv->pfnCrHgcmCtlSubmit. 1352 * 1353 * @thread VDMA 1354 */ 1168 1355 static int vboxVDMACrHgcmSubmitSync(struct VBOXVDMAHOST *pVdma, VBOXCRCMDCTL* pCtl, uint32_t cbCtl) 1169 1356 { … … 1173 1360 if (!RT_SUCCESS(rc)) 1174 1361 { 1175 WARN(("RTSemEventCreate failed % d\n", rc));1362 WARN(("RTSemEventCreate failed %Rrc\n", rc)); 1176 1363 return rc; 1177 1364 } … … 1189 1376 if (!RT_SUCCESS(rc)) 1190 1377 { 1191 WARN(("pfnCrHgcmCtlSubmit command failed % d\n", rc));1378 WARN(("pfnCrHgcmCtlSubmit command failed %Rrc\n", rc)); 1192 1379 } 1193 1380 1194 1381 } 1195 1382 else 1196 WARN(("RTSemEventWait failed % d\n", rc));1383 WARN(("RTSemEventWait failed %Rrc\n", rc)); 1197 1384 } 1198 1385 else 1199 WARN(("pfnCrHgcmCtlSubmit failed % d\n", rc));1386 WARN(("pfnCrHgcmCtlSubmit failed %Rrc\n", rc)); 1200 1387 1201 1388 … … 1205 1392 } 1206 1393 1394 1395 /** 1396 * Worker for vboxVDMAReset(). 1397 */ 1207 1398 static int vdmaVBVACtlDisableSync(PVBOXVDMAHOST pVdma) 1208 1399 { 1209 1400 VBVAEXHOSTCTL HCtl; 1401 RT_ZERO(HCtl); 1210 1402 HCtl.enmType = VBVAEXHOSTCTL_TYPE_GHH_DISABLE; 1211 1403 int rc = vdmaVBVACtlSubmitSync(pVdma, &HCtl, VBVAEXHOSTCTL_SOURCE_HOST); 1212 if (RT_FAILURE(rc)) 1213 { 1214 Log(("vdmaVBVACtlSubmitSync failed %d\n", rc)); 1215 return rc; 1216 } 1217 1218 vgaUpdateDisplayAll(pVdma->pVGAState, /* fFailOnResize = */ false); 1219 1220 return VINF_SUCCESS; 1221 } 1222 1223 static DECLCALLBACK(uint8_t*) vboxVDMACrHgcmHandleEnableRemainingHostCommand(HVBOXCRCMDCTL_REMAINING_HOST_COMMAND hClient, uint32_t *pcbCtl, int prevCmdRc) 1404 if (RT_SUCCESS(rc)) 1405 vgaUpdateDisplayAll(pVdma->pVGAState, /* fFailOnResize = */ false); 1406 else 1407 Log(("vdmaVBVACtlSubmitSync failed %Rrc\n", rc)); 1408 return rc; 1409 } 1410 1411 1412 /** 1413 * @interface_method_impl{VBOXCRCMDCTL_HGCMENABLE_DATA,pfnRHCmd, 1414 * Used by vboxVDMACrHgcmNotifyTerminatingCb() and called by 1415 * crVBoxServerCrCmdDisablePostProcess() during crServerTearDown() to drain 1416 * command queues or something.} 1417 */ 1418 static DECLCALLBACK(uint8_t *) 1419 vboxVDMACrHgcmHandleEnableRemainingHostCommand(HVBOXCRCMDCTL_REMAINING_HOST_COMMAND hClient, uint32_t *pcbCtl, int prevCmdRc) 1224 1420 { 1225 1421 struct VBOXVDMAHOST *pVdma = hClient; 1422 1226 1423 if (!pVdma->pCurRemainingHostCtl) 1227 { 1228 /* disable VBVA, all subsequent host commands will go HGCM way */ 1229 VBoxVBVAExHSDisable(&pVdma->CmdVbva); 1230 } 1424 VBoxVBVAExHSDisable(&pVdma->CmdVbva); /* disable VBVA, all subsequent host commands will go HGCM way */ 1231 1425 else 1232 {1233 1426 VBoxVBVAExHPDataCompleteCtl(&pVdma->CmdVbva, pVdma->pCurRemainingHostCtl, prevCmdRc); 1234 }1235 1427 1236 1428 pVdma->pCurRemainingHostCtl = VBoxVBVAExHPCheckHostCtlOnDisable(&pVdma->CmdVbva); … … 1245 1437 } 1246 1438 1439 /** 1440 * @interface_method_impl{VBOXCRCMDCTL_HGCMDISABLE_DATA,pfnNotifyTermDone, 1441 * Called by crServerTearDown().} 1442 */ 1247 1443 static DECLCALLBACK(void) vboxVDMACrHgcmNotifyTerminatingDoneCb(HVBOXCRCMDCTL_NOTIFY_TERMINATING hClient) 1248 1444 { … … 1256 1452 } 1257 1453 1258 static DECLCALLBACK(int) vboxVDMACrHgcmNotifyTerminatingCb(HVBOXCRCMDCTL_NOTIFY_TERMINATING hClient, VBOXCRCMDCTL_HGCMENABLE_DATA *pHgcmEnableData) 1454 /** 1455 * @interface_method_impl{VBOXCRCMDCTL_HGCMDISABLE_DATA,pfnNotifyTerm, 1456 * Called by crServerTearDown().} 1457 */ 1458 static DECLCALLBACK(int) vboxVDMACrHgcmNotifyTerminatingCb(HVBOXCRCMDCTL_NOTIFY_TERMINATING hClient, 1459 VBOXCRCMDCTL_HGCMENABLE_DATA *pHgcmEnableData) 1259 1460 { 1260 1461 struct VBOXVDMAHOST *pVdma = hClient; 1462 1261 1463 VBVAEXHOSTCTL HCtl; 1464 RT_ZERO(HCtl); 1262 1465 HCtl.enmType = VBVAEXHOSTCTL_TYPE_HH_ON_HGCM_UNLOAD; 1263 1466 int rc = vdmaVBVACtlSubmitSync(pVdma, &HCtl, VBVAEXHOSTCTL_SOURCE_HOST); 1264 1467 1265 pHgcmEnableData->hRHCmd = pVdma;1468 pHgcmEnableData->hRHCmd = pVdma; 1266 1469 pHgcmEnableData->pfnRHCmd = vboxVDMACrHgcmHandleEnableRemainingHostCommand; 1267 1470 1268 if (RT_FAILURE(rc)) 1269 { 1270 if (rc == VERR_INVALID_STATE) 1271 rc = VINF_SUCCESS; 1272 else 1273 WARN(("vdmaVBVACtlSubmitSync failed %d\n", rc)); 1274 } 1471 if (rc == VERR_INVALID_STATE) 1472 rc = VINF_SUCCESS; 1473 else if (RT_FAILURE(rc)) 1474 WARN(("vdmaVBVACtlSubmitSync failed %Rrc\n", rc)); 1275 1475 1276 1476 return rc; 1277 1477 } 1278 1478 1479 /** 1480 * Worker for vdmaVBVAEnableProcess() and vdmaVBVADisableProcess(). 1481 * 1482 * @thread VDMA 1483 */ 1279 1484 static int vboxVDMACrHgcmHandleEnable(struct VBOXVDMAHOST *pVdma) 1280 1485 { 1281 1486 VBOXCRCMDCTL_ENABLE Enable; 1282 Enable.Hdr.enmType = VBOXCRCMDCTL_TYPE_ENABLE; 1283 Enable.Data.hRHCmd = pVdma; 1487 RT_ZERO(Enable); 1488 Enable.Hdr.enmType = VBOXCRCMDCTL_TYPE_ENABLE; 1489 Enable.Data.hRHCmd = pVdma; 1284 1490 Enable.Data.pfnRHCmd = vboxVDMACrHgcmHandleEnableRemainingHostCommand; 1285 1491 … … 1293 1499 1294 1500 Assert(VBoxVBVAExHSIsEnabled(&pVdma->CmdVbva)); 1295 WARN(("vboxVDMACrHgcmSubmitSync failed %d\n", rc)); 1296 1501 WARN(("vboxVDMACrHgcmSubmitSync failed %Rrc\n", rc)); 1297 1502 return rc; 1298 1503 } 1299 1504 1505 /** 1506 * Handles VBVAEXHOSTCTL_TYPE_GHH_ENABLE and VBVAEXHOSTCTL_TYPE_GHH_ENABLE_PAUSED 1507 * for vboxVDMACrGuestCtlProcess(). 1508 * 1509 * @thread VDMA 1510 */ 1300 1511 static int vdmaVBVAEnableProcess(struct VBOXVDMAHOST *pVdma, uint32_t u32Offset) 1301 1512 { … … 1306 1517 } 1307 1518 1519 /** @todo r=bird: This needs a closer look! */ 1308 1520 VBVABUFFER *pVBVA = (VBVABUFFER *)HGSMIOffsetToPointerHost(pVdma->pHgsmi, u32Offset); 1309 1521 if (!pVBVA) 1310 1522 { 1311 WARN(("invalid offset %d \n", u32Offset));1523 WARN(("invalid offset %d (%#x)\n", u32Offset, u32Offset)); 1312 1524 return VERR_INVALID_PARAMETER; 1313 1525 } … … 1323 1535 1324 1536 VBOXCRCMDCTL_DISABLE Disable; 1325 Disable.Hdr.enmType = VBOXCRCMDCTL_TYPE_DISABLE;1326 Disable.Data.hNotifyTerm = pVdma;1327 Disable.Data.pfnNotifyTerm = vboxVDMACrHgcmNotifyTerminatingCb;1537 Disable.Hdr.enmType = VBOXCRCMDCTL_TYPE_DISABLE; 1538 Disable.Data.hNotifyTerm = pVdma; 1539 Disable.Data.pfnNotifyTerm = vboxVDMACrHgcmNotifyTerminatingCb; 1328 1540 Disable.Data.pfnNotifyTermDone = vboxVDMACrHgcmNotifyTerminatingDoneCb; 1329 1541 rc = vboxVDMACrHgcmSubmitSync(pVdma, &Disable.Hdr, sizeof (Disable)); … … 1332 1544 PVGASTATE pVGAState = pVdma->pVGAState; 1333 1545 VBOXCRCMD_SVRENABLE_INFO Info; 1334 Info.hCltScr = pVGAState->pDrv;1335 Info.pfnCltScrUpdateBegin = pVGAState->pDrv->pfnVBVAUpdateBegin;1546 Info.hCltScr = pVGAState->pDrv; 1547 Info.pfnCltScrUpdateBegin = pVGAState->pDrv->pfnVBVAUpdateBegin; 1336 1548 Info.pfnCltScrUpdateProcess = pVGAState->pDrv->pfnVBVAUpdateProcess; 1337 Info.pfnCltScrUpdateEnd = pVGAState->pDrv->pfnVBVAUpdateEnd;1549 Info.pfnCltScrUpdateEnd = pVGAState->pDrv->pfnVBVAUpdateEnd; 1338 1550 rc = pVdma->CrSrvInfo.pfnEnable(pVdma->CrSrvInfo.hSvr, &Info); 1339 1551 if (RT_SUCCESS(rc)) 1340 1552 return VINF_SUCCESS; 1341 else 1342 WARN(("pfnEnable failed %d\n", rc)); 1343 1553 1554 WARN(("pfnEnable failed %Rrc\n", rc)); 1344 1555 vboxVDMACrHgcmHandleEnable(pVdma); 1345 1556 } 1346 1557 else 1347 WARN(("vboxVDMACrHgcmSubmitSync failed % d\n", rc));1558 WARN(("vboxVDMACrHgcmSubmitSync failed %Rrc\n", rc)); 1348 1559 1349 1560 VBoxVBVAExHSDisable(&pVdma->CmdVbva); 1350 1561 } 1351 1562 else 1352 WARN(("VBoxVBVAExHSEnable failed % d\n", rc));1563 WARN(("VBoxVBVAExHSEnable failed %Rrc\n", rc)); 1353 1564 1354 1565 return rc; 1355 1566 } 1356 1567 1568 /** 1569 * Worker for several vboxVDMACrHostCtlProcess() commands. 1570 * 1571 * @returns IPRT status code. 1572 * @param pVdma The VDMA channel. 1573 * @param fDoHgcmEnable ??? 1574 * @thread VDMA 1575 */ 1357 1576 static int vdmaVBVADisableProcess(struct VBOXVDMAHOST *pVdma, bool fDoHgcmEnable) 1358 1577 { … … 1388 1607 1389 1608 VBOXCRCMD_SVRENABLE_INFO Info; 1390 Info.hCltScr = pVGAState->pDrv;1391 Info.pfnCltScrUpdateBegin = pVGAState->pDrv->pfnVBVAUpdateBegin;1609 Info.hCltScr = pVGAState->pDrv; 1610 Info.pfnCltScrUpdateBegin = pVGAState->pDrv->pfnVBVAUpdateBegin; 1392 1611 Info.pfnCltScrUpdateProcess = pVGAState->pDrv->pfnVBVAUpdateProcess; 1393 Info.pfnCltScrUpdateEnd = pVGAState->pDrv->pfnVBVAUpdateEnd;1394 pVdma->CrSrvInfo.pfnEnable(pVdma->CrSrvInfo.hSvr, &Info); 1612 Info.pfnCltScrUpdateEnd = pVGAState->pDrv->pfnVBVAUpdateEnd; 1613 pVdma->CrSrvInfo.pfnEnable(pVdma->CrSrvInfo.hSvr, &Info); /** @todo ignoring return code */ 1395 1614 } 1396 1615 } 1397 1616 else 1398 WARN(("pfnDisable failed % d\n", rc));1617 WARN(("pfnDisable failed %Rrc\n", rc)); 1399 1618 1400 1619 return rc; 1401 1620 } 1402 1621 1622 /** 1623 * Handles VBVAEXHOST_DATA_TYPE_HOSTCTL for vboxVDMAWorkerThread. 1624 * 1625 * @returns VBox status code. 1626 * @param pVdma The VDMA channel. 1627 * @param pCmd The control command to process. Should be 1628 * safe, i.e. not shared with guest. 1629 * @param pfContinue Where to return whether to continue or not. 1630 * @thread VDMA 1631 */ 1403 1632 static int vboxVDMACrHostCtlProcess(struct VBOXVDMAHOST *pVdma, VBVAEXHOSTCTL *pCmd, bool *pfContinue) 1404 1633 { 1405 1634 *pfContinue = true; 1406 1635 1636 int rc; 1407 1637 switch (pCmd->enmType) 1408 1638 { 1639 /* 1640 * See vdmaVBVACtlOpaqueHostSubmit() and its callers. 1641 */ 1409 1642 case VBVAEXHOSTCTL_TYPE_GHH_BE_OPAQUE: 1410 { 1411 if (!VBoxVBVAExHSIsEnabled(&pVdma->CmdVbva)) 1643 if (VBoxVBVAExHSIsEnabled(&pVdma->CmdVbva)) 1412 1644 { 1645 if (pVdma->CrSrvInfo.pfnHostCtl) 1646 return pVdma->CrSrvInfo.pfnHostCtl(pVdma->CrSrvInfo.hSvr, pCmd->u.cmd.pu8Cmd, pCmd->u.cmd.cbCmd); 1413 1647 WARN(("VBVAEXHOSTCTL_TYPE_GHH_BE_OPAQUE for disabled vdma VBVA\n")); 1414 return VERR_INVALID_STATE;1415 1648 } 1416 if (!pVdma->CrSrvInfo.pfnHostCtl) 1649 else 1650 WARN(("VBVAEXHOSTCTL_TYPE_GHH_BE_OPAQUE for HGCM-less mode\n")); 1651 return VERR_INVALID_STATE; 1652 1653 /* 1654 * See vdmaVBVACtlDisableSync(). 1655 */ 1656 case VBVAEXHOSTCTL_TYPE_GHH_DISABLE: 1657 rc = vdmaVBVADisableProcess(pVdma, true /* fDoHgcmEnable */); 1658 if (RT_SUCCESS(rc)) 1659 rc = VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, false /* fNotify */ ); 1660 else 1661 WARN(("vdmaVBVADisableProcess failed %Rrc\n", rc)); 1662 return rc; 1663 1664 /* 1665 * See vboxVDMACrHgcmNotifyTerminatingCb(). 1666 */ 1667 case VBVAEXHOSTCTL_TYPE_HH_ON_HGCM_UNLOAD: 1668 rc = vdmaVBVADisableProcess(pVdma, false /* fDoHgcmEnable */); 1669 if (RT_SUCCESS(rc)) 1417 1670 { 1418 /* Should not be. */ 1419 WARN(("VBVAEXHOSTCTL_TYPE_GHH_BE_OPAQUE for HGCM-less mode\n")); 1420 return VERR_INVALID_STATE; 1671 rc = VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, true /* fNotify */); 1672 if (RT_SUCCESS(rc)) 1673 *pfContinue = false; 1674 else 1675 WARN(("VBoxVDMAThreadTerm failed %Rrc\n", rc)); 1421 1676 } 1422 return pVdma->CrSrvInfo.pfnHostCtl(pVdma->CrSrvInfo.hSvr, pCmd->u.cmd.pu8Cmd, pCmd->u.cmd.cbCmd); 1423 } 1424 case VBVAEXHOSTCTL_TYPE_GHH_DISABLE: 1425 { 1426 int rc = vdmaVBVADisableProcess(pVdma, true); 1427 if (RT_FAILURE(rc)) 1677 else 1678 WARN(("vdmaVBVADisableProcess failed %Rrc\n", rc)); 1679 return rc; 1680 1681 /* 1682 * See vboxVDMASaveStateExecPerform(). 1683 */ 1684 case VBVAEXHOSTCTL_TYPE_HH_SAVESTATE: 1685 rc = VBoxVBVAExHSSaveState(&pVdma->CmdVbva, pVdma->pVGAState->vram_ptrR3, pCmd->u.state.pSSM); 1686 if (RT_SUCCESS(rc)) 1428 1687 { 1429 WARN(("vdmaVBVADisableProcess failed %d\n", rc)); 1430 return rc; 1688 VGA_SAVED_STATE_PUT_MARKER(pCmd->u.state.pSSM, 4); 1689 if (pVdma->CrSrvInfo.pfnSaveState) 1690 rc = pVdma->CrSrvInfo.pfnSaveState(pVdma->CrSrvInfo.hSvr, pCmd->u.state.pSSM); 1431 1691 } 1432 1433 return VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, false); 1434 } 1435 case VBVAEXHOSTCTL_TYPE_HH_ON_HGCM_UNLOAD: 1436 { 1437 int rc = vdmaVBVADisableProcess(pVdma, false); 1438 if (RT_FAILURE(rc)) 1692 else 1693 WARN(("VBoxVBVAExHSSaveState failed %Rrc\n", rc)); 1694 return rc; 1695 1696 /* 1697 * See vboxVDMASaveLoadExecPerform(). 1698 */ 1699 case VBVAEXHOSTCTL_TYPE_HH_LOADSTATE: 1700 rc = VBoxVBVAExHSLoadState(&pVdma->CmdVbva, pVdma->pVGAState->vram_ptrR3, pCmd->u.state.pSSM, pCmd->u.state.u32Version); 1701 if (RT_SUCCESS(rc)) 1439 1702 { 1440 WARN(("vdmaVBVADisableProcess failed %d\n", rc)); 1441 return rc; 1703 VGA_SAVED_STATE_GET_MARKER_RETURN_ON_MISMATCH(pCmd->u.state.pSSM, pCmd->u.state.u32Version, 4); 1704 if (pVdma->CrSrvInfo.pfnLoadState) 1705 { 1706 rc = pVdma->CrSrvInfo.pfnLoadState(pVdma->CrSrvInfo.hSvr, pCmd->u.state.pSSM, pCmd->u.state.u32Version); 1707 if (RT_FAILURE(rc)) 1708 WARN(("pfnLoadState failed %Rrc\n", rc)); 1709 } 1442 1710 } 1443 1444 rc = VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, true); 1445 if (RT_FAILURE(rc)) 1446 { 1447 WARN(("VBoxVDMAThreadTerm failed %d\n", rc)); 1448 return rc; 1449 } 1450 1451 *pfContinue = false; 1452 return VINF_SUCCESS; 1453 } 1454 case VBVAEXHOSTCTL_TYPE_HH_SAVESTATE: 1711 else 1712 WARN(("VBoxVBVAExHSLoadState failed %Rrc\n", rc)); 1713 return rc; 1714 1715 /* 1716 * See vboxVDMASaveLoadDone(). 1717 */ 1718 case VBVAEXHOSTCTL_TYPE_HH_LOADSTATE_DONE: 1455 1719 { 1456 1720 PVGASTATE pVGAState = pVdma->pVGAState; 1457 uint8_t * pu8VramBase = pVGAState->vram_ptrR3;1458 int rc = VBoxVBVAExHSSaveState(&pVdma->CmdVbva, pu8VramBase, pCmd->u.state.pSSM);1459 if (RT_FAILURE(rc))1460 {1461 WARN(("VBoxVBVAExHSSaveState failed %d\n", rc));1462 return rc;1463 }1464 VGA_SAVED_STATE_PUT_MARKER(pCmd->u.state.pSSM, 4);1465 1466 if (!pVdma->CrSrvInfo.pfnSaveState)1467 {1468 /* Done. */1469 return VINF_SUCCESS;1470 }1471 1472 return pVdma->CrSrvInfo.pfnSaveState(pVdma->CrSrvInfo.hSvr, pCmd->u.state.pSSM);1473 }1474 case VBVAEXHOSTCTL_TYPE_HH_LOADSTATE:1475 {1476 PVGASTATE pVGAState = pVdma->pVGAState;1477 uint8_t * pu8VramBase = pVGAState->vram_ptrR3;1478 1479 int rc = VBoxVBVAExHSLoadState(&pVdma->CmdVbva, pu8VramBase, pCmd->u.state.pSSM, pCmd->u.state.u32Version);1480 if (RT_FAILURE(rc))1481 {1482 WARN(("VBoxVBVAExHSSaveState failed %d\n", rc));1483 return rc;1484 }1485 1486 VGA_SAVED_STATE_GET_MARKER_RETURN_ON_MISMATCH(pCmd->u.state.pSSM, pCmd->u.state.u32Version, 4);1487 if (!pVdma->CrSrvInfo.pfnLoadState)1488 {1489 /* Done. */1490 return VINF_SUCCESS;1491 }1492 1493 rc = pVdma->CrSrvInfo.pfnLoadState(pVdma->CrSrvInfo.hSvr, pCmd->u.state.pSSM, pCmd->u.state.u32Version);1494 if (RT_FAILURE(rc))1495 {1496 WARN(("pfnLoadState failed %d\n", rc));1497 return rc;1498 }1499 1500 return VINF_SUCCESS;1501 }1502 case VBVAEXHOSTCTL_TYPE_HH_LOADSTATE_DONE:1503 {1504 PVGASTATE pVGAState = pVdma->pVGAState;1505 1506 1721 for (uint32_t i = 0; i < pVGAState->cMonitors; ++i) 1507 1722 { 1508 1723 VBVAINFOSCREEN CurScreen; 1509 VBVAINFOVIEW CurView; 1510 1511 int rc = VBVAGetInfoViewAndScreen(pVGAState, i, &CurView, &CurScreen); 1512 if (RT_FAILURE(rc)) 1513 { 1514 WARN(("VBVAGetInfoViewAndScreen failed %d\n", rc)); 1515 return rc; 1516 } 1724 VBVAINFOVIEW CurView; 1725 rc = VBVAGetInfoViewAndScreen(pVGAState, i, &CurView, &CurScreen); 1726 AssertLogRelMsgRCReturn(rc, ("VBVAGetInfoViewAndScreen [screen #%u] -> %#x\n", i, rc), rc); 1517 1727 1518 1728 rc = VBVAInfoScreen(pVGAState, &CurScreen); 1519 if (RT_FAILURE(rc)) 1520 { 1521 WARN(("VBVAInfoScreen failed %d\n", rc)); 1522 return rc; 1523 } 1729 AssertLogRelMsgRCReturn(rc, ("VBVAInfoScreen [screen #%u] -> %#x\n", i, rc), rc); 1524 1730 } 1525 1731 1526 1732 return VINF_SUCCESS; 1527 1733 } 1734 1528 1735 default: 1529 1736 WARN(("unexpected host ctl type %d\n", pCmd->enmType)); … … 1532 1739 } 1533 1740 1741 /** 1742 * Worker for vboxVDMACrGuestCtlResizeEntryProcess. 1743 * 1744 * @returns VINF_SUCCESS or VERR_INVALID_PARAMETER. 1745 * @param pVGAState The VGA device state. 1746 * @param pScreen The screen info (safe copy). 1747 */ 1534 1748 static int vboxVDMASetupScreenInfo(PVGASTATE pVGAState, VBVAINFOSCREEN *pScreen) 1535 1749 { 1536 const uint32_t u32ViewIndex= pScreen->u32ViewIndex;1537 const uint16_t u16Flags= pScreen->u16Flags;1538 1539 if ( u16Flags & VBVA_SCREEN_F_DISABLED)1540 { 1541 if ( u32ViewIndex< pVGAState->cMonitors1542 || u32ViewIndex== UINT32_C(0xFFFFFFFF))1750 const uint32_t idxView = pScreen->u32ViewIndex; 1751 const uint16_t fFlags = pScreen->u16Flags; 1752 1753 if (fFlags & VBVA_SCREEN_F_DISABLED) 1754 { 1755 if ( idxView < pVGAState->cMonitors 1756 || idxView == UINT32_C(0xFFFFFFFF)) 1543 1757 { 1544 1758 RT_ZERO(*pScreen); 1545 pScreen->u32ViewIndex = u32ViewIndex;1546 pScreen->u16Flags = VBVA_SCREEN_F_ACTIVE | VBVA_SCREEN_F_DISABLED;1759 pScreen->u32ViewIndex = idxView; 1760 pScreen->u16Flags = VBVA_SCREEN_F_ACTIVE | VBVA_SCREEN_F_DISABLED; 1547 1761 return VINF_SUCCESS; 1548 1762 } … … 1550 1764 else 1551 1765 { 1552 if (u16Flags & VBVA_SCREEN_F_BLANK2) 1553 { 1554 if ( u32ViewIndex >= pVGAState->cMonitors 1555 && u32ViewIndex != UINT32_C(0xFFFFFFFF)) 1556 { 1766 if (fFlags & VBVA_SCREEN_F_BLANK2) 1767 { 1768 if ( idxView >= pVGAState->cMonitors 1769 && idxView != UINT32_C(0xFFFFFFFF)) 1557 1770 return VERR_INVALID_PARAMETER; 1558 }1559 1771 1560 1772 /* Special case for blanking using current video mode. … … 1562 1774 */ 1563 1775 RT_ZERO(*pScreen); 1564 pScreen->u32ViewIndex = u32ViewIndex;1565 pScreen->u16Flags = u16Flags;1776 pScreen->u32ViewIndex = idxView; 1777 pScreen->u16Flags = fFlags; 1566 1778 return VINF_SUCCESS; 1567 1779 } 1568 1780 1569 if ( u32ViewIndex< pVGAState->cMonitors1781 if ( idxView < pVGAState->cMonitors 1570 1782 && pScreen->u16BitsPerPixel <= 32 1571 1783 && pScreen->u32Width <= UINT16_MAX … … 1578 1790 const uint64_t u64ScreenSize = (uint64_t)pScreen->u32LineSize * pScreen->u32Height; 1579 1791 if ( pScreen->u32StartOffset <= pVGAState->vram_size 1580 && u64ScreenSize <= pVGAState->vram_size1792 && u64ScreenSize <= pVGAState->vram_size 1581 1793 && pScreen->u32StartOffset <= pVGAState->vram_size - (uint32_t)u64ScreenSize) 1582 {1583 1794 return VINF_SUCCESS; 1584 }1585 1795 } 1586 1796 } 1587 1797 } 1588 1798 1799 LogFunc(("Failed\n")); 1589 1800 return VERR_INVALID_PARAMETER; 1590 1801 } … … 1622 1833 if (RT_FAILURE(rc)) 1623 1834 { 1624 WARN(("pfnResize failed % d\n", rc));1835 WARN(("pfnResize failed %Rrc\n", rc)); 1625 1836 return rc; 1626 1837 } … … 1629 1840 /* A fake view which contains the current screen for the 2D VBVAInfoView. */ 1630 1841 VBVAINFOVIEW View; 1631 View.u32ViewOffset = 0;1632 View.u32ViewSize = Screen.u32LineSize * Screen.u32Height + Screen.u32StartOffset;1842 View.u32ViewOffset = 0; 1843 View.u32ViewSize = Screen.u32LineSize * Screen.u32Height + Screen.u32StartOffset; 1633 1844 View.u32MaxScreenSize = Screen.u32LineSize * Screen.u32Height; 1634 1845 … … 1636 1847 1637 1848 for (int i = ASMBitFirstSet(aTargetMap, pVGAState->cMonitors); 1638 1639 1849 i >= 0; 1850 i = ASMBitNextSet(aTargetMap, pVGAState->cMonitors, i)) 1640 1851 { 1641 1852 Screen.u32ViewIndex = i; … … 1659 1870 if (RT_FAILURE(rc)) 1660 1871 { 1661 WARN(("VBVAInfoView failed % d\n", rc));1872 WARN(("VBVAInfoView failed %Rrc\n", rc)); 1662 1873 break; 1663 1874 } … … 1667 1878 if (RT_FAILURE(rc)) 1668 1879 { 1669 WARN(("VBVAInfoScreen failed % d\n", rc));1880 WARN(("VBVAInfoScreen failed %Rrc\n", rc)); 1670 1881 break; 1671 1882 } … … 1682 1893 * @returns VBox status code. 1683 1894 * @param pVdma The VDMA channel. 1684 * @param pCmd The command to process. 1895 * @param pCmd The command to process. Maybe safe (not shared 1896 * with guest). 1685 1897 * 1686 1898 * @thread VDMA … … 1725 1937 if (RT_FAILURE(rc)) 1726 1938 { 1727 WARN(("vboxVDMACrGuestCtlResizeEntryProcess failed % d\n", rc));1939 WARN(("vboxVDMACrGuestCtlResizeEntryProcess failed %Rrc\n", rc)); 1728 1940 return rc; 1729 1941 } … … 1757 1969 if (RT_SUCCESS(rc)) 1758 1970 return VINF_SUCCESS; 1759 WARN(("VBoxVBVAExHPPause failed % d\n", rc));1971 WARN(("VBoxVBVAExHPPause failed %Rrc\n", rc)); 1760 1972 } 1761 1973 else 1762 WARN(("vdmaVBVAEnableProcess failed % d\n", rc));1974 WARN(("vdmaVBVAEnableProcess failed %Rrc\n", rc)); 1763 1975 return rc; 1764 1976 } … … 1769 1981 case VBVAEXHOSTCTL_TYPE_GHH_DISABLE: 1770 1982 { 1771 int rc = vdmaVBVADisableProcess(pVdma, true );1983 int rc = vdmaVBVADisableProcess(pVdma, true /* fDoHgcmEnable */); 1772 1984 if (RT_FAILURE(rc)) 1773 1985 { 1774 WARN(("vdmaVBVADisableProcess failed % d\n", rc));1986 WARN(("vdmaVBVADisableProcess failed %Rrc\n", rc)); 1775 1987 return rc; 1776 1988 } … … 1780 1992 (PFNRT)vgaUpdateDisplayAll, 2, pVdma->pVGAState, /* fFailOnResize = */ false); 1781 1993 1782 return VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, false );1994 return VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, false /* fNotify */); 1783 1995 } 1784 1996 1785 1997 default: 1786 WARN(("unexpected ctl type % d\n", pCmd->enmType));1998 WARN(("unexpected ctl type %Rrc\n", pCmd->enmType)); 1787 1999 return VERR_INVALID_PARAMETER; 1788 2000 } … … 1814 2026 } 1815 2027 else 1816 WARN(("PDMDevHlpPhysGCPhys2CCPtrReadOnly failed % d", rc));2028 WARN(("PDMDevHlpPhysGCPhys2CCPtrReadOnly failed %Rrc", rc)); 1817 2029 } 1818 2030 else … … 1826 2038 } 1827 2039 else 1828 WARN(("PDMDevHlpPhysGCPhys2CCPtr failed % d", rc));2040 WARN(("PDMDevHlpPhysGCPhys2CCPtr failed %Rrc", rc)); 1829 2041 } 1830 2042 … … 2016 2228 if (!RT_SUCCESS(rc)) 2017 2229 { 2018 WARN(("PDMDevHlpPhysGCPhys2CCPtrReadOnly failed % d\n", rc));2230 WARN(("PDMDevHlpPhysGCPhys2CCPtrReadOnly failed %Rrc\n", rc)); 2019 2231 return -1; 2020 2232 } … … 2125 2337 } 2126 2338 2339 /** 2340 * Worker for vboxVDMAConstruct(). 2341 */ 2127 2342 static int vboxVDMACrCtlHgsmiSetup(struct VBOXVDMAHOST *pVdma) 2128 2343 { 2129 PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pCmd = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)2130 vboxVDMACrCtlCreate (VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP, sizeof(*pCmd));2131 int rc = VERR_NO_MEMORY;2344 PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pCmd; 2345 pCmd = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)vboxVDMACrCtlCreate(VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP, sizeof(*pCmd)); 2346 int rc; 2132 2347 if (pCmd) 2133 2348 { … … 2145 2360 pVdma->CrSrvInfo = pCmd->CrCmdServerInfo; 2146 2361 else if (rc != VERR_NOT_SUPPORTED) 2147 WARN(("vboxVDMACrCtlGetRc returned % d\n", rc));2362 WARN(("vboxVDMACrCtlGetRc returned %Rrc\n", rc)); 2148 2363 } 2149 2364 else 2150 WARN(("vboxVDMACrCtlPost failed % d\n", rc));2365 WARN(("vboxVDMACrCtlPost failed %Rrc\n", rc)); 2151 2366 2152 2367 vboxVDMACrCtlRelease(&pCmd->Hdr); 2153 2368 } 2369 else 2370 rc = VERR_NO_MEMORY; 2154 2371 2155 2372 if (!RT_SUCCESS(rc)) … … 2158 2375 return rc; 2159 2376 } 2160 2161 static int vboxVDMACmdExecBpbTransfer(PVBOXVDMAHOST pVdma, const VBOXVDMACMD_DMA_BPB_TRANSFER *pTransfer, uint32_t cbBuffer);2162 2377 2163 2378 /** … … 2244 2459 } 2245 2460 2246 int vboxVDMACrHgsmiCommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc) 2247 { 2248 PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface); 2249 PHGSMIINSTANCE pIns = pVGAState->pHGSMI; 2250 VBOXVDMACMD *pDmaHdr = VBOXVDMACMD_FROM_BODY(pCmd); 2251 VBOXVDMACBUF_DR *pDr = VBOXVDMACBUF_DR_FROM_TAIL(pDmaHdr); 2461 /** 2462 * @interface_method_impl{PDMIDISPLAYVBVACALLBACKS,pfnCrHgsmiControlCompleteAsync, 2463 * Some indirect completion magic, you gotta love this code! } 2464 */ 2465 DECLCALLBACK(int) vboxVDMACrHgsmiCommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd, int rc) 2466 { 2467 PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface); 2468 PHGSMIINSTANCE pIns = pVGAState->pHGSMI; 2469 VBOXVDMACMD *pDmaHdr = VBOXVDMACMD_FROM_BODY(pCmd); 2470 VBOXVDMACBUF_DR *pDr = VBOXVDMACBUF_DR_FROM_TAIL(pDmaHdr); 2471 2252 2472 AssertRC(rc); 2253 2473 pDr->rc = rc; … … 2256 2476 rc = VBoxSHGSMICommandComplete(pIns, pDr); 2257 2477 AssertRC(rc); 2478 2258 2479 return rc; 2259 }2260 2261 int vboxVDMACrHgsmiControlCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd, int rc)2262 {2263 PVGASTATE pVGAState = PPDMIDISPLAYVBVACALLBACKS_2_PVGASTATE(pInterface);2264 PVBOXVDMACMD_CHROMIUM_CTL_PRIVATE pCmdPrivate = VBOXVDMACMD_CHROMIUM_CTL_PRIVATE_FROM_CTL(pCmd);2265 pCmdPrivate->rc = rc;2266 if (pCmdPrivate->pfnCompletion)2267 {2268 pCmdPrivate->pfnCompletion(pVGAState, pCmd, pCmdPrivate->pvCompletion);2269 }2270 return VINF_SUCCESS;2271 2480 } 2272 2481 … … 2680 2889 } 2681 2890 RT_FALL_THRU(); 2891 2682 2892 case VBVAEXHOST_DATA_TYPE_NO_DATA: 2683 rc = VBoxVDMAThreadEventWait(&pVdma->Thread, RT_INDEFINITE_WAIT);2684 Assert RC(rc);2893 rc = RTSemEventWaitNoResume(pVdma->Thread.hEvent, RT_INDEFINITE_WAIT); 2894 AssertMsg(RT_SUCCESS(rc) || rc == VERR_INTERRUPTED, ("%Rrc\n", rc)); 2685 2895 break; 2686 2896 … … 2702 2912 * @param cbCmd Number of valid bytes at @a pCmd. This is at least 2703 2913 * sizeof(VBOXVDMACBUF_DR). 2914 * @thread VDMA 2704 2915 */ 2705 2916 static void vboxVDMACommandProcess(PVBOXVDMAHOST pVdma, PVBOXVDMACBUF_DR pCmd, uint32_t cbCmd) … … 2855 3066 } 2856 3067 2857 WARN(("RTCritSectInit failed % d\n", rc));3068 WARN(("RTCritSectInit failed %Rrc\n", rc)); 2858 3069 VBoxVBVAExHSTerm(&pVdma->CmdVbva); 2859 3070 } 2860 3071 else 2861 WARN(("VBoxVBVAExHSInit failed % d\n", rc));3072 WARN(("VBoxVBVAExHSInit failed %Rrc\n", rc)); 2862 3073 RTSemEventMultiDestroy(pVdma->HostCrCtlCompleteEvent); 2863 3074 } 2864 3075 else 2865 WARN(("RTSemEventMultiCreate failed % d\n", rc));3076 WARN(("RTSemEventMultiCreate failed %Rrc\n", rc)); 2866 3077 #endif 2867 3078 /* the timer is cleaned up automatically */ … … 2986 3197 #ifdef VBOX_WITH_CRHGSMI 2987 3198 2988 static DECLCALLBACK(void) vdmaVBVACtlSubmitSyncCompletion(VBVAEXHOSTCONTEXT *pVbva, struct VBVAEXHOSTCTL *pCtl, int rc, void *pvContext);2989 2990 static int vdmaVBVACtlSubmit(PVBOXVDMAHOST pVdma, VBVAEXHOSTCTL* pCtl, VBVAEXHOSTCTL_SOURCE enmSource,2991 PFNVBVAEXHOSTCTL_COMPLETE pfnComplete, void *pvComplete)2992 {2993 int rc = VBoxVBVAExHCtlSubmit(&pVdma->CmdVbva, pCtl, enmSource, pfnComplete, pvComplete);2994 if (RT_SUCCESS(rc))2995 {2996 if (rc == VINF_SUCCESS)2997 return VBoxVDMAThreadEventNotify(&pVdma->Thread);2998 Assert(rc == VINF_ALREADY_INITIALIZED);2999 }3000 else3001 Log(("VBoxVBVAExHCtlSubmit failed %d\n", rc));3002 3003 return rc;3004 }3005 3006 3199 /** 3007 3200 * @callback_method_impl{FNVBVAEXHOSTCTL_COMPLETE, … … 3040 3233 3041 3234 VBoxVBVAExHCtlFree(&pVdma->CmdVbva, pHCtl); 3042 Log(("vdmaVBVACtlSubmit failed rc %d\n", rc));3235 Log(("vdmaVBVACtlSubmit failed %Rrc\n", rc)); 3043 3236 } 3044 3237 else … … 3063 3256 return VINF_SUCCESS; 3064 3257 3065 WARN(("vdmaVBVACtlGenericSubmit failed % d\n", rc));3258 WARN(("vdmaVBVACtlGenericSubmit failed %Rrc\n", rc)); 3066 3259 pCtl->i32Result = rc; 3067 3260 rc = VBoxSHGSMICommandComplete(pVdma->pHgsmi, pCtl); … … 3099 3292 rc = pVGAState->pDrv->pfnCrHgcmCtlSubmit(pVGAState->pDrv, pCmd, cbCmd, pfnCompletion, pvCompletion); 3100 3293 if (!RT_SUCCESS(rc)) 3101 WARN(("pfnCrHgsmiControlProcess failed % d\n", rc));3294 WARN(("pfnCrHgsmiControlProcess failed %Rrc\n", rc)); 3102 3295 3103 3296 return rc; 3104 3297 } 3105 WARN(("vdmaVBVACtlGenericSubmit failed % d\n", rc));3298 WARN(("vdmaVBVACtlGenericSubmit failed %Rrc\n", rc)); 3106 3299 return rc; 3107 3300 } … … 3120 3313 if (!RT_SUCCESS(rc)) 3121 3314 { 3122 WARN(("pfnVBVAEnable failed % d\n", rc));3315 WARN(("pfnVBVAEnable failed %Rrc\n", rc)); 3123 3316 for (uint32_t j = 0; j < i; j++) 3124 3317 { … … 3171 3364 } 3172 3365 else if (RT_FAILURE(rc)) 3173 WARN(("vboxVDMACrGuestCtlProcess failed % d\n", rc));3366 WARN(("vboxVDMACrGuestCtlProcess failed %Rrc\n", rc)); 3174 3367 } 3175 3368 else 3176 WARN(("vdmaVBVACtlThreadCreatedEnable is passed % d\n", rc));3369 WARN(("vdmaVBVACtlThreadCreatedEnable is passed %Rrc\n", rc)); 3177 3370 3178 3371 VBoxVBVAExHPDataCompleteCtl(&pVdma->CmdVbva, pHCtl, rc); … … 3224 3417 if (!RT_SUCCESS(rc)) 3225 3418 { 3226 WARN(("RTSemEventCreate failed % d\n", rc));3419 WARN(("RTSemEventCreate failed %Rrc\n", rc)); 3227 3420 return rc; 3228 3421 } … … 3236 3429 rc = Data.rc; 3237 3430 if (!RT_SUCCESS(rc)) 3238 WARN(("vdmaVBVACtlSubmitSyncCompletion returned % d\n", rc));3431 WARN(("vdmaVBVACtlSubmitSyncCompletion returned %Rrc\n", rc)); 3239 3432 } 3240 3433 else 3241 WARN(("RTSemEventWait failed % d\n", rc));3434 WARN(("RTSemEventWait failed %Rrc\n", rc)); 3242 3435 } 3243 3436 else 3244 WARN(("vdmaVBVACtlSubmit failed % d\n", rc));3437 WARN(("vdmaVBVACtlSubmit failed %Rrc\n", rc)); 3245 3438 3246 3439 RTSemEventDestroy(Data.hEvent); … … 3276 3469 return VINF_SUCCESS; 3277 3470 3278 WARN(("vdmaVBVACtlSubmit failed rc % d\n", rc));3471 WARN(("vdmaVBVACtlSubmit failed rc %Rrc\n", rc)); 3279 3472 VBoxVBVAExHCtlFree(&pVdma->CmdVbva, pHCtl); 3280 3473 return rc; … … 3303 3496 return VINF_SUCCESS; 3304 3497 3305 WARN(("vdmaVBVACtlEnableDisableSubmitInternal failed % d\n", rc));3498 WARN(("vdmaVBVACtlEnableDisableSubmitInternal failed %Rrc\n", rc)); 3306 3499 pEnable->Hdr.i32Result = rc; 3307 3500 rc = VBoxSHGSMICommandComplete(pVdma->pHgsmi, &pEnable->Hdr); … … 3322 3515 rc = RTSemEventSignal(pData->hEvent); 3323 3516 if (!RT_SUCCESS(rc)) 3324 WARN(("RTSemEventSignal failed % d\n", rc));3517 WARN(("RTSemEventSignal failed %Rrc\n", rc)); 3325 3518 } 3326 3519 … … 3333 3526 if (!RT_SUCCESS(rc)) 3334 3527 { 3335 WARN(("RTSemEventCreate failed % d\n", rc));3528 WARN(("RTSemEventCreate failed %Rrc\n", rc)); 3336 3529 return rc; 3337 3530 } … … 3345 3538 rc = Data.rc; 3346 3539 if (!RT_SUCCESS(rc)) 3347 WARN(("vdmaVBVACtlSubmitSyncCompletion returned % d\n", rc));3540 WARN(("vdmaVBVACtlSubmitSyncCompletion returned %Rrc\n", rc)); 3348 3541 } 3349 3542 else 3350 WARN(("RTSemEventWait failed % d\n", rc));3543 WARN(("RTSemEventWait failed %Rrc\n", rc)); 3351 3544 } 3352 3545 else 3353 Log(("vdmaVBVACtlSubmit failed % d\n", rc));3546 Log(("vdmaVBVACtlSubmit failed %Rrc\n", rc)); 3354 3547 3355 3548 RTSemEventDestroy(Data.hEvent); … … 3463 3656 } 3464 3657 else 3465 WARN(("RTCritSectEnter failed % d\n", rc));3658 WARN(("RTCritSectEnter failed %Rrc\n", rc)); 3466 3659 3467 3660 return rc; … … 3492 3685 else 3493 3686 { 3494 WARN(("RTCritSectEnter failed % d\n", rc));3687 WARN(("RTCritSectEnter failed %Rrc\n", rc)); 3495 3688 break; 3496 3689 } … … 3518 3711 if (!RT_SUCCESS(rc)) 3519 3712 { 3520 WARN(("vdmaVBVACtlOpaqueHostSubmit failed % d", rc));3713 WARN(("vdmaVBVACtlOpaqueHostSubmit failed %Rrc", rc)); 3521 3714 return rc; 3522 3715 } … … 3548 3741 rc = Data.rc; 3549 3742 if (!RT_SUCCESS(rc)) 3550 WARN(("host call failed % d", rc));3743 WARN(("host call failed %Rrc", rc)); 3551 3744 3552 3745 return rc; … … 3654 3847 if (rc != VERR_INVALID_STATE) 3655 3848 { 3656 WARN(("vdmaVBVAPause failed % d\n", rc));3849 WARN(("vdmaVBVAPause failed %Rrc\n", rc)); 3657 3850 return rc; 3658 3851 } … … 3663 3856 3664 3857 PVGASTATE pVGAState = pVdma->pVGAState; 3665 PVBOXVDMACMD_CHROMIUM_CTL pCmd = (PVBOXVDMACMD_CHROMIUM_CTL)vboxVDMACrCtlCreate( 3666 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_BEGIN, sizeof (*pCmd)); 3667 Assert(pCmd); 3858 PVBOXVDMACMD_CHROMIUM_CTL pCmd; 3859 pCmd = (PVBOXVDMACMD_CHROMIUM_CTL)vboxVDMACrCtlCreate(VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_BEGIN, sizeof(*pCmd)); 3668 3860 if (pCmd) 3669 3861 { … … 3671 3863 AssertRC(rc); 3672 3864 if (RT_SUCCESS(rc)) 3673 {3674 3865 rc = vboxVDMACrCtlGetRc(pCmd); 3675 }3676 3866 vboxVDMACrCtlRelease(pCmd); 3677 3867 return rc; … … 3693 3883 if (rc != VERR_INVALID_STATE) 3694 3884 { 3695 WARN(("vdmaVBVAResume failed % d\n", rc));3885 WARN(("vdmaVBVAResume failed %Rrc\n", rc)); 3696 3886 return rc; 3697 3887 } … … 3702 3892 3703 3893 PVGASTATE pVGAState = pVdma->pVGAState; 3704 PVBOXVDMACMD_CHROMIUM_CTL pCmd = (PVBOXVDMACMD_CHROMIUM_CTL)vboxVDMACrCtlCreate(3705 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END, sizeof(*pCmd));3894 PVBOXVDMACMD_CHROMIUM_CTL pCmd; 3895 pCmd = (PVBOXVDMACMD_CHROMIUM_CTL)vboxVDMACrCtlCreate(VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END, sizeof(*pCmd)); 3706 3896 Assert(pCmd); 3707 3897 if (pCmd) … … 3710 3900 AssertRC(rc); 3711 3901 if (RT_SUCCESS(rc)) 3712 {3713 3902 rc = vboxVDMACrCtlGetRc(pCmd); 3714 }3715 3903 vboxVDMACrCtlRelease(pCmd); 3716 3904 return rc; … … 3796 3984 /** @todo r=bird: BTW. would be great if you put in a couple of comments here and there explaining what 3797 3985 * the purpose of this code is. */ 3798 VBVAEXHOSTCTL *pHCtl = VBoxVBVAExHCtlCreate(&pVdma->CmdVbva, VBVAEXHOSTCTL_TYPE_HH_LOADSTATE_DONE);3986 VBVAEXHOSTCTL *pHCtl = VBoxVBVAExHCtlCreate(&pVdma->CmdVbva, VBVAEXHOSTCTL_TYPE_HH_LOADSTATE_DONE); 3799 3987 if (!pHCtl) 3800 3988 { … … 3811 3999 if (RT_FAILURE(rc)) 3812 4000 { 3813 Log(("vdmaVBVACtlSubmit failed rc %d\n", rc));4001 Log(("vdmaVBVACtlSubmit failed %Rrc\n", rc)); 3814 4002 VBoxVBVAExHCtlFree(&pVdma->CmdVbva, pHCtl); 3815 4003 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.