Changeset 55560 in vbox for trunk/src/VBox/Devices/Graphics
- Timestamp:
- Apr 30, 2015 2:57:47 PM (10 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
r55421 r55560 1316 1316 if(RT_SUCCESS(rc)) 1317 1317 { 1318 rc = HGSMIHostCommand ProcessAndFreeAsynch(pIns, pHostCmd, (pCmd->Flags & VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ) != 0);1318 rc = HGSMIHostCommandSubmitAndFreeAsynch(pIns, pHostCmd, RT_BOOL(pCmd->Flags & VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ)); 1319 1319 AssertRC(rc); 1320 1320 if(RT_SUCCESS(rc)) -
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
r55421 r55560 199 199 HGSMIINSTANCE *pIns; /* Backlink to the HGSMI instance. */ 200 200 201 #if 0202 /* removed to allow saved state handling */203 /* The event which is signalled when the command has been processed by the host. */204 RTSEMEVENTMULTI hEvent;205 #endif206 207 201 volatile uint32_t fl; /* Status flags of the entry. */ 208 202 209 203 HGSMIOFFSET offBuffer; /* Offset of the HGSMI buffer header in the HGSMI host heap: 210 204 * [pIns->hostHeap.area.offBase .. offLast]. */ 211 212 #if 0213 /* removed to allow saved state handling */214 /* The command completion callback. */215 PFNHGSMIHOSTFIFOCALLBACK pfnCallback;216 void *pvCallback;217 #endif218 219 205 } HGSMIHOSTFIFOENTRY; 220 206 … … 399 385 400 386 hgsmiFIFOUnlock(pIns); 401 #if 0 402 /* Inform the submitter. */ 403 if (pEntry->pfnCallback) 404 { 405 pEntry->pfnCallback (pEntry->pvCallback); 406 } 407 #else 387 408 388 hgsmiHostCommandFreeCallback(pEntry); 409 #endif 389 410 390 return true; 411 391 } … … 501 481 ASMAtomicAndU32(&pIns->pHGFlags->u32HostFlags, (~flags)); 502 482 } 503 504 #if 0505 static void hgsmiRaiseEvent (const HGSMIHOSTFIFOENTRY *pEntry)506 {507 int rc = RTSemEventMultiSignal (pEntry->hEvent);508 AssertRC(rc);509 }510 511 static int hgsmiWaitEvent (const HGSMIHOSTFIFOENTRY *pEntry)512 {513 int rc = RTSemEventMultiWait (pEntry->hEvent, RT_INDEFINITE_WAIT);514 AssertRC(rc);515 return rc;516 }517 #endif518 483 519 484 /* … … 723 688 { 724 689 pEntry->fl = HGSMI_F_HOST_FIFO_ALLOCATED; 725 #if 0726 rc = RTSemEventMultiCreate (&pEntry->hEvent);727 728 if (RT_FAILURE (rc))729 {730 RTMemFree (pEntry);731 }732 #endif733 690 } 734 691 else … … 748 705 { 749 706 NOREF (pIns); 750 #if 0751 if (pEntry->hEvent)752 {753 RTSemEventMultiDestroy (pEntry->hEvent);754 }755 #endif756 707 RTMemFree (pEntry); 757 708 } … … 786 737 } 787 738 788 static int hgsmiHostCommandFree (HGSMIINSTANCE *pIns, 789 void *pvData) 790 { 791 int rc = VINF_SUCCESS; 792 if (HGSMIAreaContainsPointer(&pIns->hostHeap.area, pvData)) 793 { 794 HGSMIHOSTFIFOENTRY *pEntry = NULL; 795 HGSMIOFFSET offBuffer = HGSMIBufferOffsetFromData(&pIns->hostHeap.area, pvData); 796 797 rc = hgsmiFIFOLock (pIns); 798 if(RT_SUCCESS(rc)) 799 { 800 /* Search the Processed list for the given offBuffer. */ 801 HGSMIHOSTFIFOENTRY *pIter; 802 RTListForEach(&pIns->hostFIFOProcessed, pIter, HGSMIHOSTFIFOENTRY, nodeEntry) 803 { 804 Assert(pIter->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED)); 805 806 if (pIter->offBuffer == offBuffer) 807 { 808 pEntry = pIter; 809 break; 810 } 739 static int hgsmiHostCommandFree(HGSMIINSTANCE *pIns, 740 void *pvData) 741 { 742 HGSMIOFFSET offBuffer = HGSMIBufferOffsetFromData(&pIns->hostHeap.area, pvData); 743 HGSMIHOSTFIFOENTRY *pEntry = NULL; 744 745 int rc = hgsmiFIFOLock(pIns); 746 if (RT_SUCCESS(rc)) 747 { 748 /* Search the Processed list for the given offBuffer. */ 749 HGSMIHOSTFIFOENTRY *pIter; 750 RTListForEach(&pIns->hostFIFOProcessed, pIter, HGSMIHOSTFIFOENTRY, nodeEntry) 751 { 752 Assert(pIter->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED)); 753 754 if (pIter->offBuffer == offBuffer) 755 { 756 pEntry = pIter; 757 break; 811 758 } 812 813 if (pEntry) 814 { 815 RTListNodeRemove(&pEntry->nodeEntry); 816 } 817 else 818 { 819 AssertLogRelMsgFailed(("HGSMI[%s]: the host frees unprocessed FIFO entry: 0x%08X\n", 820 pIns->pszName, offBuffer)); 821 } 822 823 hgsmiFIFOUnlock (pIns); 824 825 rc = hgsmiHostHeapLock (pIns); 826 if(RT_SUCCESS(rc)) 827 { 828 /* Deallocate the host heap memory. */ 829 hgsmiHostHeapDataFree(&pIns->hostHeap, pvData); 830 831 hgsmiHostHeapUnlock(pIns); 832 } 833 834 if(pEntry) 835 { 836 /* Deallocate the entry. */ 837 hgsmiHostFIFOFree (pIns, pEntry); 838 } 839 } 840 841 } 842 else 843 { 844 AssertLogRelMsgFailed(("HGSMI[%s]: the host frees invalid FIFO entry: %p\n", 845 pIns->pszName, pvData)); 846 rc = VERR_INVALID_POINTER; 847 } 848 return rc; 849 } 850 851 #if 0 852 static DECLCALLBACK(void) hgsmiHostCommandRaiseEventCallback (void *pvCallback) 759 } 760 761 if (pEntry) 762 { 763 RTListNodeRemove(&pEntry->nodeEntry); 764 } 765 else 766 { 767 AssertLogRelMsgFailed(("HGSMI[%s]: the host frees unprocessed FIFO entry: 0x%08X\n", 768 pIns->pszName, offBuffer)); 769 } 770 771 hgsmiFIFOUnlock (pIns); 772 773 rc = hgsmiHostHeapLock (pIns); 774 if (RT_SUCCESS(rc)) 775 { 776 /* Deallocate the host heap memory. */ 777 hgsmiHostHeapDataFree(&pIns->hostHeap, pvData); 778 779 hgsmiHostHeapUnlock(pIns); 780 } 781 782 if (pEntry) 783 { 784 /* Deallocate the entry. */ 785 hgsmiHostFIFOFree(pIns, pEntry); 786 } 787 } 788 789 return rc; 790 } 791 792 static DECLCALLBACK(void) hgsmiHostCommandFreeCallback (void *pvCallback) 853 793 { 854 794 /* Guest has processed the command. */ … … 858 798 859 799 /* This is a simple callback, just signal the event. */ 860 hgsmiRaiseEvent (pEntry);861 }862 #endif863 864 static DECLCALLBACK(void) hgsmiHostCommandFreeCallback (void *pvCallback)865 {866 /* Guest has processed the command. */867 HGSMIHOSTFIFOENTRY *pEntry = (HGSMIHOSTFIFOENTRY *)pvCallback;868 869 Assert(pEntry->fl == (HGSMI_F_HOST_FIFO_ALLOCATED | HGSMI_F_HOST_FIFO_PROCESSED));870 871 /* This is a simple callback, just signal the event. */872 800 hgsmiHostCommandFreeByEntry (pEntry); 873 801 } 874 802 875 static int hgsmiHostCommandWrite (HGSMIINSTANCE *pIns, HGSMIOFFSET offMem 876 #if 0 877 , PFNHGSMIHOSTFIFOCALLBACK pfnCallback, void **ppvContext 878 #endif 879 ) 880 { 803 static int hgsmiHostCommandWrite(HGSMIINSTANCE *pIns, 804 HGSMIOFFSET offBuffer) 805 { 806 AssertPtrReturn(pIns->pHGFlags, VERR_WRONG_ORDER); 807 881 808 HGSMIHOSTFIFOENTRY *pEntry; 882 883 AssertPtrReturn(pIns->pHGFlags, VERR_WRONG_ORDER); 884 int rc = hgsmiHostFIFOAlloc (pIns, &pEntry); 885 886 if (RT_SUCCESS (rc)) 809 int rc = hgsmiHostFIFOAlloc(pIns, &pEntry); 810 811 if (RT_SUCCESS(rc)) 887 812 { 888 813 /* Initialize the new entry and add it to the FIFO. */ … … 890 815 891 816 pEntry->pIns = pIns; 892 pEntry->offBuffer = offMem; 893 #if 0 894 pEntry->pfnCallback = pfnCallback; 895 pEntry->pvCallback = pEntry; 896 #endif 817 pEntry->offBuffer = offBuffer; 897 818 898 819 rc = hgsmiFIFOLock(pIns); 899 if (RT_SUCCESS (rc)) 900 { 820 if (RT_SUCCESS(rc)) 821 { 822 ASMAtomicOrU32(&pIns->pHGFlags->u32HostFlags, HGSMIHOSTFLAGS_COMMANDS_PENDING); 901 823 RTListAppend(&pIns->hostFIFO, &pEntry->nodeEntry); 902 ASMAtomicOrU32(&pIns->pHGFlags->u32HostFlags, HGSMIHOSTFLAGS_COMMANDS_PENDING);903 824 904 825 hgsmiFIFOUnlock(pIns); 905 #if 0906 *ppvContext = pEntry;907 #endif908 826 } 909 827 else … … 920 838 * Append the shared memory block to the FIFO, inform the guest. 921 839 * 922 * @param pIns Pointer to HGSMI instance, 923 * @param pv The HC memory pointer to the information. 924 * @param ppvContext Where to store a pointer, which will allow the caller 925 * to wait for the command completion. 926 * @param bDoIrq specifies whether the guest interrupt should be generated, 927 * i.e. in case the command is not urgent(e.g. some guest command completion notification that does not require post-processing) 928 * the command could be posted without raising an irq. 929 * 840 * @param pIns Pointer to HGSMI instance. 841 * @param pvData The shared memory block data pointer. 842 * @param fDoIrq Whether the guest interrupt should be generated, i.e. if the command is not 843 * urgent (e.g. some guest command completion notification that does not require 844 * post-processing) the command could be submitted without raising an irq. 930 845 * @thread EMT 931 846 */ 932 static int hgsmiHostCommandProcess (HGSMIINSTANCE *pIns, HGSMIOFFSET offBuffer, 933 #if 0 934 PFNHGSMIHOSTFIFOCALLBACK pfnCallback, void **ppvContext, 935 #endif 936 bool bDoIrq) 937 { 938 // HGSMIOFFSET offMem; 939 // 940 // int rc = hgsmiCheckMemPtr (pIns, pvMem, &offMem); 941 // 942 // if (RT_SUCCESS (rc)) 943 // { 944 /* Append the command to FIFO. */ 945 int rc = hgsmiHostCommandWrite (pIns, offBuffer 946 #if 0 947 , pfnCallback, ppvContext 948 #endif 949 ); 950 951 if (RT_SUCCESS (rc)) 952 { 953 if(bDoIrq) 954 { 955 /* Now guest can read the FIFO, the notification is informational. */ 956 hgsmiNotifyGuest (pIns); 957 } 958 } 959 // } 960 // else 961 // { 962 // AssertFailed (); 963 // } 964 965 return rc; 966 } 967 #if 0 968 static void hgsmiWait (void *pvContext) 969 { 970 HGSMIHOSTFIFOENTRY *pEntry = (HGSMIHOSTFIFOENTRY *)pvContext; 971 972 for (;;) 973 { 974 hgsmiWaitEvent (pEntry); 975 976 if (pEntry->fl & (HGSMI_F_HOST_FIFO_PROCESSED | HGSMI_F_HOST_FIFO_CANCELED)) 977 { 978 return; 979 } 980 } 981 } 982 #endif 847 static int hgsmiHostCommandSubmit(HGSMIINSTANCE *pIns, 848 void *pvData, 849 bool fDoIrq) 850 { 851 /* Append the command to FIFO. */ 852 HGSMIOFFSET offBuffer = HGSMIBufferOffsetFromData(&pIns->hostHeap.area, pvData); 853 int rc = hgsmiHostCommandWrite(pIns, offBuffer); 854 if (RT_SUCCESS(rc)) 855 { 856 if (fDoIrq) 857 { 858 /* Now guest can read the FIFO, the notification is informational. */ 859 hgsmiNotifyGuest(pIns); 860 } 861 } 862 863 return rc; 864 } 865 983 866 /** 984 867 * Allocate a shared memory buffer. The host can write command/data to the memory. … … 993 876 * @param u16ChannelInfo Command parameter. 994 877 */ 995 int HGSMIHostCommandAlloc (HGSMIINSTANCE *pIns, 996 void **ppvData, 997 HGSMISIZE cbData, 998 uint8_t u8Channel, 999 uint16_t u16ChannelInfo) 1000 { 1001 LogFlowFunc (("pIns = %p, cbData = 0x%08X(%d)\n", pIns, cbData, cbData)); 1002 1003 int rc = hgsmiHostHeapLock (pIns); 1004 if(RT_SUCCESS(rc)) 878 int HGSMIHostCommandAlloc(HGSMIINSTANCE *pIns, 879 void **ppvData, 880 HGSMISIZE cbData, 881 uint8_t u8Channel, 882 uint16_t u16ChannelInfo) 883 { 884 LogFlowFunc(("pIns = %p, cbData = %d, u8Channel %d, u16ChannelInfo 0x%04X\n", 885 pIns, cbData, u8Channel, u16ChannelInfo)); 886 887 int rc = hgsmiHostHeapLock(pIns); 888 if (RT_SUCCESS(rc)) 1005 889 { 1006 890 void *pvData = hgsmiHostHeapDataAlloc(&pIns->hostHeap, … … 1016 900 else 1017 901 { 1018 LogRel(("HGSMI[%s]: host heap allocation failed %d bytes\n", pIns->pszName, cbData));902 LogRel(("HGSMI[%s]: host heap allocation failed %d bytes\n", pIns->pszName, cbData)); 1019 903 rc = VERR_NO_MEMORY; 1020 904 } … … 1033 917 * @param pIns HGSMI instance, 1034 918 * @param pvData The pointer returned by 'HGSMIHostCommandAlloc'. 1035 * @param bDoIrq Specifies whether the guest interrupt should be generated.919 * @param fDoIrq Specifies whether the guest interrupt should be generated. 1036 920 * In case the command is not urgent (e.g. some guest command 1037 921 * completion notification that does not require post-processing) 1038 922 * the command could be posted without raising an irq. 1039 923 */ 1040 int HGSMIHostCommandProcessAndFreeAsynch (PHGSMIINSTANCE pIns, 1041 void *pvData, 1042 bool bDoIrq) 1043 { 1044 LogFlowFunc(("pIns = %p, pvData = %p\n", pIns, pvData)); 1045 1046 #if 0 1047 void *pvContext = NULL; 1048 #endif 1049 1050 HGSMIOFFSET offBuffer = HGSMIBufferOffsetFromData(&pIns->hostHeap.area, pvData); 1051 1052 int rc = hgsmiHostCommandProcess (pIns, offBuffer, 1053 #if 0 1054 hgsmiHostCommandFreeCallback, &pvContext, 1055 #endif 1056 bDoIrq); 1057 AssertRC (rc); 924 int HGSMIHostCommandSubmitAndFreeAsynch(PHGSMIINSTANCE pIns, 925 void *pvData, 926 bool fDoIrq) 927 { 928 LogFlowFunc(("pIns = %p, pvData = %p, fDoIrq = %d\n", pIns, pvData, fDoIrq)); 929 930 int rc; 931 if (HGSMIAreaContainsPointer(&pIns->hostHeap.area, pvData)) 932 { 933 rc = hgsmiHostCommandSubmit(pIns, pvData, fDoIrq); 934 } 935 else 936 { 937 AssertLogRelMsgFailed(("HGSMI[%s]: host submits invalid command %p/%p\n", 938 pIns->pszName, pvData, pIns->hostHeap.area.pu8Base)); 939 rc = VERR_INVALID_POINTER; 940 } 1058 941 1059 942 LogFlowFunc(("rc = %Rrc\n", rc)); 1060 1061 return rc; 1062 } 1063 #if 0 1064 /** 1065 * Submit the shared memory block to the guest. 1066 * 1067 * @param pIns Pointer to HGSMI instance, 1068 * @param pvMem The pointer returned by 'HGSMIHostCommandAlloc'. 1069 */ 1070 int HGSMIHostCommandProcess (HGSMIINSTANCE *pIns, 1071 void *pvMem) 1072 { 1073 LogFlowFunc(("pIns = %p, pvMem = %p\n", pIns, pvMem)); 1074 1075 VM_ASSERT_OTHER_THREAD(pIns->pVM); 1076 1077 void *pvContext = NULL; 1078 1079 HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&pIns->hostHeap, pvMem); 1080 1081 // /* Have to forward to EMT because FIFO processing is there. */ 1082 // int rc = VMR3ReqCallVoid (pIns->pVM, &pReq, RT_INDEFINITE_WAIT, 1083 // (PFNRT) hgsmiHostCommandProcess, 1084 // 3, pIns, offBuffer, &pvContext); 1085 1086 int rc = hgsmiHostCommandProcess (pIns, offBuffer, 1087 #if 0 1088 hgsmiHostCommandRaiseEventCallback, &pvContext, 1089 #endif 1090 true); 1091 AssertReleaseRC (rc); 1092 1093 if (RT_SUCCESS (rc)) 1094 { 1095 /* Wait for completion. */ 1096 hgsmiWait (pvContext); 1097 } 1098 1099 LogFlowFunc(("rc = %Rrc\n", rc)); 1100 1101 return rc; 1102 } 1103 #endif 943 return rc; 944 } 1104 945 1105 946 /** 1106 947 * Free the shared memory block. 1107 948 * 1108 * @param pIns Pointer to HGSMI instance,1109 * @param pv MemThe pointer returned by 'HGSMIHostCommandAlloc'.949 * @param pIns Pointer to HGSMI instance, 950 * @param pvData The pointer returned by 'HGSMIHostCommandAlloc'. 1110 951 */ 1111 int HGSMIHostCommandFree (HGSMIINSTANCE *pIns, 1112 void *pvMem) 1113 { 1114 LogFlowFunc(("pIns = %p, pvMem = %p\n", pIns, pvMem)); 1115 1116 return hgsmiHostCommandFree (pIns, pvMem); 952 int HGSMIHostCommandFree(HGSMIINSTANCE *pIns, 953 void *pvData) 954 { 955 LogFlowFunc(("pIns = %p, pvData = %p\n", pIns, pvData)); 956 957 int rc; 958 if (HGSMIAreaContainsPointer(&pIns->hostHeap.area, pvData)) 959 { 960 rc = hgsmiHostCommandFree(pIns, pvData); 961 } 962 else 963 { 964 AssertLogRelMsgFailed(("HGSMI[%s]: the host frees invalid FIFO entry %p/%p\n", 965 pIns->pszName, pvData, pIns->hostHeap.area.pu8Base)); 966 rc = VERR_INVALID_POINTER; 967 } 968 969 LogFlowFunc(("rc = %Rrc\n", rc)); 970 return rc; 1117 971 } 1118 972 -
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h
r55421 r55560 73 73 HGSMISIZE cbHeap); 74 74 75 int HGSMISaveStateExec (PHGSMIINSTANCE pIns, PSSMHANDLE pSSM);76 int HGSMILoadStateExec (PHGSMIINSTANCE pIns, PSSMHANDLE pSSM);77 78 75 /* 79 76 * Virtual hardware IO handlers. … … 106 103 107 104 /* Allocate a buffer in the host heap. */ 108 int HGSMIHostCommandAlloc 109 110 111 112 105 int HGSMIHostCommandAlloc(PHGSMIINSTANCE pIns, 106 void **ppvData, 107 HGSMISIZE cbData, 108 uint8_t u8Channel, 109 uint16_t u16ChannelInfo); 113 110 114 int HGSMIHostCommandProcess (PHGSMIINSTANCE pIns, 115 void *pvMem); 111 int HGSMIHostCommandSubmitAndFreeAsynch(PHGSMIINSTANCE pIns, 112 void *pvData, 113 bool fDoIrq); 116 114 117 int HGSMIHostCommandProcessAndFreeAsynch (PHGSMIINSTANCE pIns, 118 void *pvData, 119 bool bDoIrq); 120 121 int HGSMIHostCommandFree (PHGSMIINSTANCE pIns, 122 void *pvMem); 115 int HGSMIHostCommandFree(PHGSMIINSTANCE pIns, 116 void *pvData); 123 117 124 118 int HGSMIHostLoadStateExec (PHGSMIINSTANCE pIns, PSSMHANDLE pSSM, uint32_t u32Version);
Note:
See TracChangeset
for help on using the changeset viewer.