Changeset 55342 in vbox for trunk/src/VBox/Devices/Graphics/HGSMI
- Timestamp:
- Apr 20, 2015 2:19:53 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99671
- Location:
- trunk/src/VBox/Devices/Graphics/HGSMI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp
r53513 r55342 9 9 10 10 /* 11 * Copyright (C) 2006-201 2Oracle Corporation11 * Copyright (C) 2006-2015 Oracle Corporation 12 12 * 13 13 * This file is part of VirtualBox Open Source Edition (OSE), as … … 261 261 } 262 262 263 //static HGSMICHANNEL *hgsmiChannelFindById (PHGSMIINSTANCE pIns,264 // uint8_t u8Channel)265 //{266 // HGSMICHANNEL *pChannel = &pIns->Channels[u8Channel];267 //268 // if (pChannel->u8Flags & HGSMI_CH_F_REGISTERED)269 // {270 // return pChannel;271 // }272 //273 // return NULL;274 //}275 276 #if 0277 /* Verify that the given offBuffer points to a valid buffer, which is within the area.278 */279 static const HGSMIBUFFERHEADER *hgsmiVerifyBuffer (const HGSMIAREA *pArea,280 HGSMIOFFSET offBuffer)281 {282 AssertPtr(pArea);283 284 LogFlowFunc(("buffer 0x%x, area %p %x [0x%x;0x%x]\n", offBuffer, pArea->pu8Base, pArea->cbArea, pArea->offBase, pArea->offLast));285 286 if ( offBuffer < pArea->offBase287 || offBuffer > pArea->offLast)288 {289 LogFunc(("offset 0x%x is outside the area [0x%x;0x%x]!!!\n", offBuffer, pArea->offBase, pArea->offLast));290 HGSMI_STRICT_ASSERT_FAILED();291 return NULL;292 }293 294 const HGSMIBUFFERHEADER *pHeader = HGSMIOffsetToPointer (pArea, offBuffer);295 296 /* Quick check of the data size, it should be less than the maximum297 * data size for the buffer at this offset.298 */299 LogFlowFunc(("datasize check: pHeader->u32DataSize = 0x%x pArea->offLast - offBuffer = 0x%x\n", pHeader->u32DataSize, pArea->offLast - offBuffer));300 if (pHeader->u32DataSize <= pArea->offLast - offBuffer)301 {302 HGSMIBUFFERTAIL *pTail = HGSMIBufferTail (pHeader);303 304 /* At least both pHeader and pTail structures are in the area. Check the checksum. */305 uint32_t u32Checksum = HGSMIChecksum (offBuffer, pHeader, pTail);306 307 LogFlowFunc(("checksum check: u32Checksum = 0x%x pTail->u32Checksum = 0x%x\n", u32Checksum, pTail->u32Checksum));308 if (u32Checksum == pTail->u32Checksum)309 {310 LogFlowFunc(("returning %p\n", pHeader));311 return pHeader;312 }313 else314 {315 LogFunc(("invalid checksum 0x%x, expected 0x%x!!!\n", u32Checksum, pTail->u32Checksum));316 }317 }318 else319 {320 LogFunc(("invalid data size 0x%x, maximum is 0x%x!!!\n", pHeader->u32DataSize, pArea->offLast - offBuffer));321 }322 323 LogFlowFunc(("returning NULL\n"));324 HGSMI_STRICT_ASSERT_FAILED();325 return NULL;326 }327 328 /*329 * Process a guest buffer.330 * @thread EMT331 */332 static int hgsmiGuestBufferProcess (HGSMIINSTANCE *pIns,333 const HGSMICHANNEL *pChannel,334 const HGSMIBUFFERHEADER *pHeader)335 {336 LogFlowFunc(("pIns %p, pChannel %p, pHeader %p\n", pIns, pChannel, pHeader));337 338 int rc = HGSMIChannelHandlerCall (pIns,339 &pChannel->handler,340 pHeader);341 342 return rc;343 }344 #endif345 263 /* 346 264 * Virtual hardware IO handlers. … … 572 490 #endif 573 491 574 #if 0575 DECLINLINE(HGSMIOFFSET) hgsmiMemoryOffset (const HGSMIINSTANCE *pIns, const void *pv)576 {577 Assert((uint8_t *)pv >= pIns->area.pu8Base);578 Assert((uint8_t *)pv < pIns->area.pu8Base + pIns->area.cbArea);579 return (HGSMIOFFSET)((uint8_t *)pv - pIns->area.pu8Base);580 }581 #endif582 492 /* 583 493 * The host heap. … … 598 508 AssertRC (rc); 599 509 } 600 601 #if 0602 static int hgsmiHostHeapAlloc (HGSMIINSTANCE *pIns, void **ppvMem, uint32_t cb)603 {604 int rc = hgsmiHostHeapLock (pIns);605 606 if (RT_SUCCESS (rc))607 {608 if (pIns->hostHeap == NIL_RTHEAPSIMPLE)609 {610 rc = VERR_NOT_SUPPORTED;611 }612 else613 {614 /* A block structure: [header][data][tail].615 * 'header' and 'tail' is used to verify memory blocks.616 */617 uint32_t cbAlloc = HGSMIBufferRequiredSize (cb);618 619 void *pv = RTHeapSimpleAlloc (pIns->hostHeap, cbAlloc, 0);620 621 if (pv)622 {623 HGSMIBUFFERHEADER *pHdr = (HGSMIBUFFERHEADER *)pv;624 625 /* Store some information which will help to verify memory pointers. */626 pHdr->u32Signature = HGSMI_MEM_SIGNATURE;627 pHdr->cb = cb;628 pHdr->off = hgsmiMemoryOffset (pIns, pv);629 pHdr->u32HdrVerifyer = HGSMI_MEM_VERIFYER_HDR (pHdr);630 631 /* Setup the tail. */632 HGSMIBUFFERTAIL *pTail = HGSMIBufferTail (pHdr);633 634 pTail->u32TailVerifyer = HGSMI_MEM_VERIFYER_TAIL (pHdr);635 636 *ppvMem = pv;637 }638 else639 {640 rc = VERR_NO_MEMORY;641 }642 }643 644 hgsmiHostHeapUnlock (pIns);645 }646 647 return rc;648 }649 650 651 static int hgsmiHostHeapCheckBlock (HGSMIINSTANCE *pIns, void *pvMem)652 {653 int rc = hgsmiHostHeapLock (pIns);654 655 if (RT_SUCCESS (rc))656 {657 rc = hgsmiVerifyBuffer (pIns, pvMem);658 659 hgsmiHostHeapUnlock (pIns);660 }661 662 return rc;663 }664 665 static int hgsmiHostHeapFree (HGSMIINSTANCE *pIns, void *pvMem)666 {667 int rc = hgsmiHostHeapLock (pIns);668 669 if (RT_SUCCESS (rc))670 {671 RTHeapSimpleFree (pIns->hostHeap, pvMem);672 673 hgsmiHostHeapUnlock (pIns);674 }675 676 return rc;677 }678 679 static int hgsmiCheckMemPtr (HGSMIINSTANCE *pIns, void *pvMem, HGSMIOFFSET *poffMem)680 {681 int rc = hgsmiHostHeapCheckBlock (pIns, pvMem);682 683 if (RT_SUCCESS (rc))684 {685 *poffMem = hgsmiMemoryOffset (pIns, pvMem);686 }687 688 return rc;689 }690 #endif691 510 692 511 static int hgsmiHostFIFOAlloc (HGSMIINSTANCE *pIns, HGSMIHOSTFIFOENTRY **ppEntry) … … 1545 1364 /* Register a new HGSMI channel by a predefined index. 1546 1365 */ 1547 int HGSMIHostChannelRegister (PHGSMIINSTANCE pIns, 1548 uint8_t u8Channel, 1549 PFNHGSMICHANNELHANDLER pfnChannelHandler, 1550 void *pvChannelHandler, 1551 HGSMICHANNELHANDLER *pOldHandler) 1552 { 1553 LogFlowFunc(("pIns %p, u8Channel %x, pfnChannelHandler %p, pvChannelHandler %p, pOldHandler %p\n", 1554 pIns, u8Channel, pfnChannelHandler, pvChannelHandler, pOldHandler)); 1366 int HGSMIHostChannelRegister(PHGSMIINSTANCE pIns, 1367 uint8_t u8Channel, 1368 PFNHGSMICHANNELHANDLER pfnChannelHandler, 1369 void *pvChannelHandler) 1370 { 1371 LogFlowFunc(("pIns %p, u8Channel %x, pfnChannelHandler %p, pvChannelHandler %p\n", 1372 pIns, u8Channel, pfnChannelHandler, pvChannelHandler)); 1555 1373 1556 1374 AssertReturn(!HGSMI_IS_DYNAMIC_CHANNEL(u8Channel), VERR_INVALID_PARAMETER); … … 1562 1380 if (RT_SUCCESS (rc)) 1563 1381 { 1564 rc = HGSMIChannelRegister (&pIns->channelInfo, u8Channel, NULL, pfnChannelHandler, pvChannelHandler , pOldHandler);1382 rc = HGSMIChannelRegister (&pIns->channelInfo, u8Channel, NULL, pfnChannelHandler, pvChannelHandler); 1565 1383 1566 1384 hgsmiUnlock (pIns); … … 1578 1396 PFNHGSMICHANNELHANDLER pfnChannelHandler, 1579 1397 void *pvChannelHandler, 1580 uint8_t *pu8Channel, 1581 HGSMICHANNELHANDLER *pOldHandler) 1582 { 1583 LogFlowFunc(("pIns %p, pszChannel %s, pfnChannelHandler %p, pvChannelHandler %p, pu8Channel %p, pOldHandler %p\n", 1584 pIns, pszChannel, pfnChannelHandler, pvChannelHandler, pu8Channel, pOldHandler)); 1398 uint8_t *pu8Channel) 1399 { 1400 LogFlowFunc(("pIns %p, pszChannel %s, pfnChannelHandler %p, pvChannelHandler %p, pu8Channel %p\n", 1401 pIns, pszChannel, pfnChannelHandler, pvChannelHandler, pu8Channel)); 1585 1402 1586 1403 AssertPtrReturn(pIns, VERR_INVALID_PARAMETER); … … 1604 1421 if (RT_SUCCESS (rc)) 1605 1422 { 1606 rc = HGSMIChannelRegister (&pIns->channelInfo, *pu8Channel, pszName, pfnChannelHandler, pvChannelHandler , pOldHandler);1423 rc = HGSMIChannelRegister (&pIns->channelInfo, *pu8Channel, pszName, pfnChannelHandler, pvChannelHandler); 1607 1424 } 1608 1425 … … 1624 1441 return rc; 1625 1442 } 1626 1627 #if 01628 /* A wrapper to safely call the handler.1629 */1630 int HGSMIChannelHandlerCall (PHGSMIINSTANCE pIns,1631 const HGSMICHANNELHANDLER *pHandler,1632 const HGSMIBUFFERHEADER *pHeader)1633 {1634 LogFlowFunc(("pHandler %p, pIns %p, pHeader %p\n", pHandler, pIns, pHeader));1635 1636 int rc;1637 1638 if ( pHandler1639 && pHandler->pfnHandler)1640 {1641 void *pvBuffer = HGSMIBufferData (pHeader);1642 HGSMISIZE cbBuffer = pHeader->u32DataSize;1643 1644 rc = pHandler->pfnHandler (pIns, pHandler->pvHandler, pHeader->u16ChannelInfo, pvBuffer, cbBuffer);1645 }1646 else1647 {1648 /* It is a NOOP case here. */1649 rc = VINF_SUCCESS;1650 }1651 1652 LogFlowFunc(("leave rc = %Rrc\n", rc));1653 1654 return rc;1655 }1656 1657 #endif1658 1443 1659 1444 void *HGSMIOffsetToPointerHost (PHGSMIINSTANCE pIns, … … 1737 1522 return rc; 1738 1523 } 1739 1740 static HGSMICHANNELHANDLER sOldChannelHandler;1741 1524 1742 1525 int HGSMICreate (PHGSMIINSTANCE *ppIns, … … 1816 1599 HGSMI_CH_HGSMI, 1817 1600 hgsmiChannelHandler, 1818 pIns, 1819 &sOldChannelHandler); 1601 pIns); 1820 1602 1821 1603 if (RT_SUCCESS (rc)) -
trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h
r50550 r55342 6 6 7 7 /* 8 * Copyright (C) 2006-201 0Oracle Corporation8 * Copyright (C) 2006-2015 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 60 60 uint8_t u8Channel, 61 61 PFNHGSMICHANNELHANDLER pfnChannelHandler, 62 void *pvChannelHandler, 63 HGSMICHANNELHANDLER *pOldHandler); 62 void *pvChannelHandler); 64 63 65 64 int HGSMIChannelRegisterName (PHGSMIINSTANCE pIns, … … 67 66 PFNHGSMICHANNELHANDLER pfnChannelHandler, 68 67 void *pvChannelHandler, 69 uint8_t *pu8Channel, 70 HGSMICHANNELHANDLER *pOldHandler); 71 72 int HGSMIChannelHandlerCall (PHGSMIINSTANCE pIns, 73 const HGSMICHANNELHANDLER *pHandler, 74 const HGSMIBUFFERHEADER *pHeader); 75 68 uint8_t *pu8Channel); 76 69 77 70 int HGSMISetupHostHeap (PHGSMIINSTANCE pIns,
Note:
See TracChangeset
for help on using the changeset viewer.