Changeset 26556 in vbox for trunk/src/VBox/Devices/Graphics/HGSMI
- Timestamp:
- Feb 15, 2010 10:10:11 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57735
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
r25226 r26556 152 152 HGSMILIST hostFIFOProcessed; /* Processed by the guest. */ 153 153 HGSMILIST hostFIFOFree; /* Buffers for reuse. */ 154 #ifdef VBOXVDMA 155 HGSMILIST guestCmdCompleted; /* list of completed guest commands to be returned to the guest*/ 156 #endif 154 157 RTCRITSECT hostFIFOCritSect; /* FIFO serialization lock. */ 155 158 … … 198 201 #define HGSMILISTENTRY_2_FIFOENTRY(_pe) \ 199 202 ( (HGSMIHOSTFIFOENTRY*)((uint8_t *)(_pe) - RT_OFFSETOF(HGSMIHOSTFIFOENTRY, entry)) ) 203 200 204 //AssertCompile(RT_OFFSETOF(HGSMIHOSTFIFOENTRY, entry) == 0); 201 205 … … 209 213 210 214 static DECLCALLBACK(void) hgsmiHostCommandFreeCallback (void *pvCallback); 215 216 #ifdef VBOXVDMA 217 218 typedef struct _HGSMIGUESTCOMPLENTRY 219 { 220 /* The list field. Must be the first field. */ 221 HGSMILISTENTRY entry; 222 /* guest command buffer */ 223 HGSMIOFFSET offBuffer; 224 } HGSMIGUESTCOMPLENTRY; 225 226 #define HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(_pe) \ 227 ( (HGSMIGUESTCOMPLENTRY*)((uint8_t *)(_pe) - RT_OFFSETOF(HGSMIGUESTCOMPLENTRY, entry)) ) 228 229 static void hgsmiGuestCompletionFIFOFree (HGSMIINSTANCE *pIns, HGSMIGUESTCOMPLENTRY *pEntry) 230 { 231 NOREF (pIns); 232 RTMemFree (pEntry); 233 } 234 235 static int hgsmiGuestCompletionFIFOAlloc (HGSMIINSTANCE *pIns, HGSMIGUESTCOMPLENTRY **ppEntry) 236 { 237 int rc = VINF_SUCCESS; 238 239 NOREF (pIns); 240 241 HGSMIGUESTCOMPLENTRY *pEntry = (HGSMIGUESTCOMPLENTRY *)RTMemAllocZ (sizeof (HGSMIGUESTCOMPLENTRY)); 242 243 if (pEntry) 244 *ppEntry = pEntry; 245 else 246 rc = VERR_NO_MEMORY; 247 248 return rc; 249 } 250 251 #endif 211 252 212 253 static int hgsmiLock (HGSMIINSTANCE *pIns) … … 341 382 VM_ASSERT_EMT(pIns->pVM); 342 383 384 #ifndef VBOXVDMA 343 385 /* Currently there is no functionality here. */ 344 386 NOREF(pIns); 345 387 346 388 return HGSMIOFFSET_VOID; 389 #else 390 /* use this to speedup guest cmd completion 391 * this mechanism is alternative to submitting H->G command for notification */ 392 HGSMIOFFSET offCmd = HGSMIOFFSET_VOID; 393 int rc = hgsmiFIFOLock(pIns); 394 AssertRC(rc); 395 if(RT_SUCCESS(rc)) 396 { 397 /* Get the host FIFO head entry. */ 398 HGSMILISTENTRY *pHead = pIns->guestCmdCompleted.pHead; 399 if(pHead) 400 hgsmiListRemove (&pIns->guestCmdCompleted, pHead, NULL); 401 402 if(!pIns->guestCmdCompleted.pHead) 403 pIns->pHGFlags->u32HostFlags &= (~HGSMIHOSTFLAGS_GCOMMAND_COMPLETED); 404 405 hgsmiFIFOUnlock(pIns); 406 407 if (pHead) 408 { 409 HGSMIGUESTCOMPLENTRY *pEntry = HGSMILISTENTRY_2_HGSMIGUESTCOMPLENTRY(pHead); 410 offCmd = pEntry->offBuffer; 411 412 LogFlowFunc(("host FIFO head %p.\n", pEntry)); 413 414 hgsmiGuestCompletionFIFOFree (pIns, pEntry); 415 } 416 } 417 /* Special value that means there is no host buffers to be processed. */ 418 return offCmd; 419 #endif 347 420 } 348 421 … … 1596 1669 LogFlowFunc(("leave\n")); 1597 1670 } 1671 1672 #ifdef VBOXVDMA 1673 1674 static int hgsmiGuestCommandComplete (HGSMIINSTANCE *pIns, HGSMIOFFSET offMem) 1675 { 1676 HGSMIGUESTCOMPLENTRY *pEntry; 1677 1678 int rc = hgsmiGuestCompletionFIFOAlloc (pIns, &pEntry); 1679 1680 if (RT_SUCCESS (rc)) 1681 { 1682 pEntry->offBuffer = offMem; 1683 1684 rc = hgsmiFIFOLock(pIns); 1685 if (RT_SUCCESS (rc)) 1686 { 1687 hgsmiListAppend (&pIns->guestCmdCompleted, &pEntry->entry); 1688 pIns->pHGFlags->u32HostFlags |= HGSMIHOSTFLAGS_GCOMMAND_COMPLETED; 1689 1690 hgsmiFIFOUnlock(pIns); 1691 } 1692 else 1693 { 1694 hgsmiGuestCompletionFIFOFree(pIns, pEntry); 1695 } 1696 } 1697 1698 return rc; 1699 } 1700 1701 int hgsmiCompleteGuestCommand(PHGSMIINSTANCE pIns, 1702 HGSMIOFFSET offBuffer, 1703 bool bDoIrq) 1704 { 1705 int rc = hgsmiGuestCommandComplete (pIns, offBuffer); 1706 if (RT_SUCCESS (rc)) 1707 { 1708 if(bDoIrq) 1709 { 1710 /* Now guest can read the FIFO, the notification is informational. */ 1711 hgsmiNotifyGuest (pIns); 1712 } 1713 } 1714 return rc; 1715 } 1716 1717 int HGSMICompleteGuestCommand(PHGSMIINSTANCE pIns, 1718 void *pvMem, 1719 bool bDoIrq) 1720 { 1721 LogFlowFunc(("pIns = %p, pvMem = %p\n", pIns, pvMem)); 1722 1723 VM_ASSERT_OTHER_THREAD(pIns->pVM); 1724 1725 int rc = VINF_SUCCESS; 1726 HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&pIns->hostHeap, pvMem); 1727 Assert(offBuffer != HGSMIOFFSET_VOID); 1728 if (offBuffer != HGSMIOFFSET_VOID) 1729 { 1730 rc = hgsmiCompleteGuestCommand (pIns, offBuffer, bDoIrq); 1731 AssertRC (rc); 1732 } 1733 else 1734 { 1735 LogRel(("invalid cmd offset \n")); 1736 rc = VERR_INVALID_PARAMETER; 1737 } 1738 1739 LogFlowFunc(("rc = %Rrc\n", rc)); 1740 1741 return rc; 1742 } 1743 #endif
Note:
See TracChangeset
for help on using the changeset viewer.