VirtualBox

Ignore:
Timestamp:
Apr 20, 2015 2:19:53 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99671
Message:

HGSMI: cleanup, comments.

Location:
trunk/src/VBox/Devices/Graphics/HGSMI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.cpp

    r53513 r55342  
    99
    1010/*
    11  * Copyright (C) 2006-2012 Oracle Corporation
     11 * Copyright (C) 2006-2015 Oracle Corporation
    1212 *
    1313 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    261261}
    262262
    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 0
    277 /* 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->offBase
    287         || 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 maximum
    297      * 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         else
    314         {
    315             LogFunc(("invalid checksum 0x%x, expected 0x%x!!!\n", u32Checksum, pTail->u32Checksum));
    316         }
    317     }
    318     else
    319     {
    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 EMT
    331  */
    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 #endif
    345263/*
    346264 * Virtual hardware IO handlers.
     
    572490#endif
    573491
    574 #if 0
    575 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 #endif
    582492/*
    583493 * The host heap.
     
    598508    AssertRC (rc);
    599509}
    600 
    601 #if 0
    602 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         else
    613         {
    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             else
    639             {
    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 #endif
    691510
    692511static int hgsmiHostFIFOAlloc (HGSMIINSTANCE *pIns, HGSMIHOSTFIFOENTRY **ppEntry)
     
    15451364/* Register a new HGSMI channel by a predefined index.
    15461365 */
    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));
     1366int 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));
    15551373
    15561374    AssertReturn(!HGSMI_IS_DYNAMIC_CHANNEL(u8Channel), VERR_INVALID_PARAMETER);
     
    15621380    if (RT_SUCCESS (rc))
    15631381    {
    1564         rc = HGSMIChannelRegister (&pIns->channelInfo, u8Channel, NULL, pfnChannelHandler, pvChannelHandler, pOldHandler);
     1382        rc = HGSMIChannelRegister (&pIns->channelInfo, u8Channel, NULL, pfnChannelHandler, pvChannelHandler);
    15651383
    15661384        hgsmiUnlock (pIns);
     
    15781396                              PFNHGSMICHANNELHANDLER pfnChannelHandler,
    15791397                              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));
    15851402
    15861403    AssertPtrReturn(pIns, VERR_INVALID_PARAMETER);
     
    16041421            if (RT_SUCCESS (rc))
    16051422            {
    1606                 rc = HGSMIChannelRegister (&pIns->channelInfo, *pu8Channel, pszName, pfnChannelHandler, pvChannelHandler, pOldHandler);
     1423                rc = HGSMIChannelRegister (&pIns->channelInfo, *pu8Channel, pszName, pfnChannelHandler, pvChannelHandler);
    16071424            }
    16081425
     
    16241441    return rc;
    16251442}
    1626 
    1627 #if 0
    1628 /* 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 (   pHandler
    1639         && 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     else
    1647     {
    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 #endif
    16581443
    16591444void *HGSMIOffsetToPointerHost (PHGSMIINSTANCE pIns,
     
    17371522    return rc;
    17381523}
    1739 
    1740 static HGSMICHANNELHANDLER sOldChannelHandler;
    17411524
    17421525int HGSMICreate (PHGSMIINSTANCE *ppIns,
     
    18161599                                   HGSMI_CH_HGSMI,
    18171600                                   hgsmiChannelHandler,
    1818                                    pIns,
    1819                                    &sOldChannelHandler);
     1601                                   pIns);
    18201602
    18211603    if (RT_SUCCESS (rc))
  • trunk/src/VBox/Devices/Graphics/HGSMI/HGSMIHost.h

    r50550 r55342  
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2015 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6060                          uint8_t u8Channel,
    6161                          PFNHGSMICHANNELHANDLER pfnChannelHandler,
    62                           void *pvChannelHandler,
    63                           HGSMICHANNELHANDLER *pOldHandler);
     62                          void *pvChannelHandler);
    6463
    6564int HGSMIChannelRegisterName (PHGSMIINSTANCE pIns,
     
    6766                              PFNHGSMICHANNELHANDLER pfnChannelHandler,
    6867                              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);
    7669
    7770int HGSMISetupHostHeap (PHGSMIINSTANCE pIns,
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette