VirtualBox

Changeset 82190 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 25, 2019 5:44:40 PM (5 years ago)
Author:
vboxsync
Message:

DevPS2: ps2kRemoveQueue is common to both DevPS2M.cpp and DevPS2K.cpp, share it! bugref:9218

Location:
trunk/src/VBox/Devices/Input
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/DevPS2.cpp

    r82189 r82190  
    745745}
    746746
     747/**
     748 * Retrieve a byte from a queue.
     749 *
     750 * @param   pQ                  Pointer to the queue.
     751 * @param   pVal                Pointer to storage for the byte.
     752 *
     753 * @retval  VINF_TRY_AGAIN if queue is empty,
     754 * @retval  VINF_SUCCESS if a byte was read.
     755 */
     756int PS2CmnRemoveQueue(GeneriQ *pQ, uint8_t *pVal)
     757{
     758    int rc;
     759
     760    Assert(pVal);
     761    if (pQ->cUsed)
     762    {
     763        *pVal = pQ->abQueue[pQ->rpos];
     764        if (++pQ->rpos == pQ->cSize)
     765            pQ->rpos = 0;   /* Roll over. */
     766        --pQ->cUsed;
     767        LogFlowFunc(("removed 0x%02X from queue %p\n", *pVal, pQ));
     768        rc = VINF_SUCCESS;
     769    }
     770    else
     771    {
     772        LogFlowFunc(("queue %p empty\n", pQ));
     773        rc = VINF_TRY_AGAIN;
     774    }
     775    return rc;
     776}
     777
    747778#ifdef IN_RING3
    748779
     
    778809 * @param   pQ                  Pointer to the queue.
    779810 *
    780  * @return  int                VBox status/error code.
     811 * @returns VBox status/error code.
    781812 */
    782813int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ)
  • trunk/src/VBox/Devices/Input/DevPS2.h

    r82189 r82190  
    4242void PS2CmnClearQueue(GeneriQ *pQ);
    4343void PS2CmnInsertQueue(GeneriQ *pQ, uint8_t val);
     44int  PS2CmnRemoveQueue(GeneriQ *pQ, uint8_t *pVal);
    4445void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ);
    4546int  PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ);
  • trunk/src/VBox/Devices/Input/DevPS2K.cpp

    r82189 r82190  
    450450#endif /* IN_RING3 */
    451451
    452 /**
    453  * Retrieve a byte from a queue.
    454  *
    455  * @param   pQ                  Pointer to the queue.
    456  * @param   pVal                Pointer to storage for the byte.
    457  *
    458  * @return  int                 VINF_TRY_AGAIN if queue is empty,
    459  *                              VINF_SUCCESS if a byte was read.
    460  */
    461 static int ps2kRemoveQueue(GeneriQ *pQ, uint8_t *pVal)
    462 {
    463     int     rc = VINF_TRY_AGAIN;
    464 
    465     Assert(pVal);
    466     if (pQ->cUsed)
    467     {
    468         *pVal = pQ->abQueue[pQ->rpos];
    469         if (++pQ->rpos == pQ->cSize)
    470             pQ->rpos = 0;   /* Roll over. */
    471         --pQ->cUsed;
    472         rc = VINF_SUCCESS;
    473         LogFlowFunc(("removed 0x%02X from queue %p\n", *pVal, pQ));
    474     } else
    475         LogFlowFunc(("queue %p empty\n", pQ));
    476     return rc;
    477 }
    478 
    479 /* Clears the currently active typematic key, if any. */
     452/** Clears the currently active typematic key, if any. */
    480453static void ps2kStopTypematicRepeat(PPS2K pThis)
    481454{
     
    489462}
    490463
    491 /* Convert encoded typematic value to milliseconds. Note that the values are rated
     464/** Convert encoded typematic value to milliseconds. Note that the values are rated
    492465 * with +/- 20% accuracy, so there's no need for high precision.
    493466 */
     
    668641     * the command queue is empty.
    669642     */
    670     rc = ps2kRemoveQueue((GeneriQ *)&pThis->cmdQ, pb);
     643    rc = PS2CmnRemoveQueue((GeneriQ *)&pThis->cmdQ, pb);
    671644    if (rc != VINF_SUCCESS && !pThis->u8CurrCmd && pThis->fScanning)
    672645        if (!pThis->fThrottleActive)
    673646        {
    674             rc = ps2kRemoveQueue((GeneriQ *)&pThis->keyQ, pb);
     647            rc = PS2CmnRemoveQueue((GeneriQ *)&pThis->keyQ, pb);
    675648            if (pThis->fThrottleEnabled) {
    676649                pThis->fThrottleActive = true;
  • trunk/src/VBox/Devices/Input/DevPS2M.cpp

    r82189 r82190  
    232232
    233233#endif /* IN_RING3 */
    234 
    235 /**
    236  * Retrieve a byte from a queue.
    237  *
    238  * @param   pQ                  Pointer to the queue.
    239  * @param   pVal                Pointer to storage for the byte.
    240  *
    241  * @return  int                 VINF_TRY_AGAIN if queue is empty,
    242  *                              VINF_SUCCESS if a byte was read.
    243  */
    244 static int ps2kRemoveQueue(GeneriQ *pQ, uint8_t *pVal)
    245 {
    246     int     rc = VINF_TRY_AGAIN;
    247 
    248     Assert(pVal);
    249     if (pQ->cUsed)
    250     {
    251         *pVal = pQ->abQueue[pQ->rpos];
    252         if (++pQ->rpos == pQ->cSize)
    253             pQ->rpos = 0;   /* Roll over. */
    254         --pQ->cUsed;
    255         rc = VINF_SUCCESS;
    256         LogFlowFunc(("removed 0x%02X from queue %p\n", *pVal, pQ));
    257     } else
    258         LogFlowFunc(("queue %p empty\n", pQ));
    259     return rc;
    260 }
    261234
    262235static void ps2mSetRate(PPS2M pThis, uint8_t rate)
     
    683656     */
    684657    /// @todo Probably should flush/not fill queue if stream mode reporting disabled?!
    685     rc = ps2kRemoveQueue((GeneriQ *)&pThis->cmdQ, pb);
     658    rc = PS2CmnRemoveQueue((GeneriQ *)&pThis->cmdQ, pb);
    686659    if (rc != VINF_SUCCESS && !pThis->u8CurrCmd && (pThis->u8State & AUX_STATE_ENABLED))
    687         rc = ps2kRemoveQueue((GeneriQ *)&pThis->evtQ, pb);
     660        rc = PS2CmnRemoveQueue((GeneriQ *)&pThis->evtQ, pb);
    688661
    689662    LogFlowFunc(("mouse sends 0x%02x (%svalid data)\n", *pb, rc == VINF_SUCCESS ? "" : "not "));
Note: See TracChangeset for help on using the changeset viewer.

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