VirtualBox

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

DevPS2: Saved state, prefixes, ++. bugref:9218

File:
1 edited

Legend:

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

    r82173 r82189  
    205205*********************************************************************************************************************************/
    206206#if defined(RT_STRICT) && defined(IN_RING3)
    207 static void ps2mTestAccumulation(void);
     207static void ps2mR3TestAccumulation(void);
    208208#endif
    209209
    210210
    211 /**
    212  * Clear a queue.
    213  *
    214  * @param   pQ                  Pointer to the queue.
    215  */
    216 static void ps2kClearQueue(GeneriQ *pQ)
    217 {
    218     LogFlowFunc(("Clearing queue %p\n", pQ));
    219     pQ->wpos  = pQ->rpos;
    220     pQ->cUsed = 0;
    221 }
    222 
    223 
    224 /**
    225  * Add a byte to a queue.
    226  *
    227  * @param   pQ                  Pointer to the queue.
    228  * @param   val                 The byte to store.
    229  */
    230 static void ps2kInsertQueue(GeneriQ *pQ, uint8_t val)
    231 {
    232     /* Check if queue is full. */
    233     if (pQ->cUsed >= pQ->cSize)
    234     {
    235         LogRelFlowFunc(("queue %p full (%d entries)\n", pQ, pQ->cUsed));
    236         return;
    237     }
    238     /* Insert data and update circular buffer write position. */
    239     pQ->abQueue[pQ->wpos] = val;
    240     if (++pQ->wpos == pQ->cSize)
    241         pQ->wpos = 0;   /* Roll over. */
    242     ++pQ->cUsed;
    243     LogRelFlowFunc(("inserted 0x%02X into queue %p\n", val, pQ));
    244 }
    245 
    246211#ifdef IN_RING3
    247212
    248 /**
    249  * Save a queue state.
    250  *
    251  * @param   pSSM                SSM handle to write the state to.
    252  * @param   pQ                  Pointer to the queue.
    253  */
    254 static void ps2kSaveQueue(PSSMHANDLE pSSM, GeneriQ *pQ)
    255 {
    256     uint32_t    cItems = pQ->cUsed;
    257     int         i;
    258 
    259     /* Only save the number of items. Note that the read/write
    260      * positions aren't saved as they will be rebuilt on load.
    261      */
    262     SSMR3PutU32(pSSM, cItems);
    263 
    264     LogFlow(("Storing %d items from queue %p\n", cItems, pQ));
    265 
    266     /* Save queue data - only the bytes actually used (typically zero). */
    267     for (i = pQ->rpos; cItems-- > 0; i = (i + 1) % pQ->cSize)
    268         SSMR3PutU8(pSSM, pQ->abQueue[i]);
    269 }
    270 
    271 /**
    272  * Load a queue state.
    273  *
    274  * @param   pSSM                SSM handle to read the state from.
    275  * @param   pQ                  Pointer to the queue.
    276  *
    277  * @return  int                 VBox status/error code.
    278  */
    279 static int ps2kLoadQueue(PSSMHANDLE pSSM, GeneriQ *pQ)
    280 {
    281     int         rc;
    282 
    283     /* On load, always put the read pointer at zero. */
    284     SSMR3GetU32(pSSM, &pQ->cUsed);
    285 
    286     LogFlow(("Loading %d items to queue %p\n", pQ->cUsed, pQ));
    287 
    288     if (pQ->cUsed > pQ->cSize)
    289     {
    290         AssertMsgFailed(("Saved size=%u, actual=%u\n", pQ->cUsed, pQ->cSize));
    291         return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    292     }
    293 
    294     /* Recalculate queue positions and load data in one go. */
    295     pQ->rpos = 0;
    296     pQ->wpos = pQ->cUsed;
    297     rc = SSMR3GetMem(pSSM, pQ->abQueue, pQ->cUsed);
    298 
    299     return rc;
    300 }
    301 
    302213/* Report a change in status down (or is it up?) the driver chain. */
    303 static void ps2mSetDriverState(PPS2M pThis, bool fEnabled)
     214static void ps2mR3SetDriverState(PPS2M pThis, bool fEnabled)
    304215{
    305216    PPDMIMOUSECONNECTOR pDrv = pThis->Mouse.pDrv;
     
    309220
    310221/* Reset the pointing device. */
    311 static void ps2mReset(PPS2M pThis)
    312 {
    313     ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK);
    314     ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, 0);
     222static void ps2mR3Reset(PPS2M pThis)
     223{
     224    PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK);
     225    PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, 0);
    315226    pThis->enmMode   = AUX_MODE_STD;
    316227    pThis->u8CurrCmd = 0;
    317228
    318229    /// @todo move to its proper home!
    319     ps2mSetDriverState(pThis, true);
     230    ps2mR3SetDriverState(pThis, true);
    320231}
    321232
     
    369280
    370281    /* Event queue, eccumulators, and button status bits are cleared. */
    371     ps2kClearQueue((GeneriQ *)&pThis->evtQ);
     282    PS2CmnClearQueue((GeneriQ *)&pThis->evtQ);
    372283    pThis->iAccumX = pThis->iAccumY = pThis->iAccumZ = pThis->iAccumW = pThis->fAccumB = 0;
    373284}
     
    445356
    446357    /* Send the standard 3-byte packet (always the same). */
    447     ps2kInsertQueue(pQueue, val);
    448     ps2kInsertQueue(pQueue, dX);
    449     ps2kInsertQueue(pQueue, dY);
     358    PS2CmnInsertQueue(pQueue, val);
     359    PS2CmnInsertQueue(pQueue, dX);
     360    PS2CmnInsertQueue(pQueue, dY);
    450361
    451362    /* Add fourth byte if an extended protocol is in use. */
     
    458369        {
    459370            /* NB: Only uses 4-bit dZ range, despite using a full byte. */
    460             ps2kInsertQueue(pQueue, dZ);
     371            PS2CmnInsertQueue(pQueue, dZ);
    461372            pThis->iAccumZ -= dZ;
    462373        }
     
    467378           val |= dZ & 0x0f;
    468379           pThis->iAccumZ -= dZ;
    469            ps2kInsertQueue(pQueue, val);
     380           PS2CmnInsertQueue(pQueue, val);
    470381        }
    471382        else
     
    499410               val = (fBtnState & PS2M_IMEX_BTN_MASK) << 1;
    500411            }
    501             ps2kInsertQueue(pQueue, val);
     412            PS2CmnInsertQueue(pQueue, val);
    502413        }
    503414    }
     
    549460
    550461    /* If there's anything left in the command response queue, trash it. */
    551     ps2kClearQueue((GeneriQ *)&pThis->cmdQ);
     462    PS2CmnClearQueue((GeneriQ *)&pThis->cmdQ);
    552463
    553464    if (pThis->enmMode == AUX_MODE_WRAP)
     
    558469        else
    559470        {
    560             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, cmd);
     471            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, cmd);
    561472            return VINF_SUCCESS;
    562473        }
     
    573484        case ACMD_SET_SCALE_11:
    574485            pThis->u8State &= ~AUX_STATE_SCALING;
    575             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     486            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    576487            pThis->u8CurrCmd = 0;
    577488            break;
    578489        case ACMD_SET_SCALE_21:
    579490            pThis->u8State |= AUX_STATE_SCALING;
    580             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     491            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    581492            pThis->u8CurrCmd = 0;
    582493            break;
     
    584495            /* Report current status, sample rate, and resolution. */
    585496            u8Val  = (pThis->u8State & AUX_STATE_EXTERNAL) | (pThis->fCurrB & PS2M_STD_BTN_MASK);
    586             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    587             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);
    588             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8Resolution);
    589             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8SampleRate);
     497            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     498            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);
     499            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8Resolution);
     500            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8SampleRate);
    590501            pThis->u8CurrCmd = 0;
    591502            break;
    592503        case ACMD_SET_STREAM:
    593504            pThis->u8State &= ~AUX_STATE_REMOTE;
    594             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     505            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    595506            pThis->u8CurrCmd = 0;
    596507            break;
    597508        case ACMD_READ_REMOTE:
    598             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     509            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    599510            ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->cmdQ, false);
    600511            pThis->u8CurrCmd = 0;
     
    603514            pThis->enmMode = AUX_MODE_STD;
    604515            /* NB: Stream mode reporting remains disabled! */
    605             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     516            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    606517            pThis->u8CurrCmd = 0;
    607518            break;
     
    609520            pThis->enmMode = AUX_MODE_WRAP;
    610521            pThis->u8State &= ~AUX_STATE_ENABLED;
    611             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     522            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    612523            pThis->u8CurrCmd = 0;
    613524            break;
    614525        case ACMD_SET_REMOTE:
    615526            pThis->u8State |= AUX_STATE_REMOTE;
    616             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     527            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    617528            pThis->u8CurrCmd = 0;
    618529            break;
    619530        case ACMD_READ_ID:
    620             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     531            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    621532            /* ImEx + horizontal is protocol 4, just like plain ImEx. */
    622533            u8Val = pThis->enmProtocol == PS2M_PROTO_IMEX_HORZ ? PS2M_PROTO_IMEX : pThis->enmProtocol;
    623             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);
     534            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);
    624535            pThis->u8CurrCmd = 0;
    625536            break;
     
    627538            pThis->u8State |= AUX_STATE_ENABLED;
    628539#ifdef IN_RING3
    629             ps2mSetDriverState(pThis, true);
     540            ps2mR3SetDriverState(pThis, true);
    630541#else
    631542            AssertLogRelMsgFailed(("Invalid ACMD_ENABLE outside R3!\n"));
    632543#endif
    633             ps2kClearQueue((GeneriQ *)&pThis->evtQ);
    634             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     544            PS2CmnClearQueue((GeneriQ *)&pThis->evtQ);
     545            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    635546            pThis->u8CurrCmd = 0;
    636547            break;
    637548        case ACMD_DISABLE:
    638549            pThis->u8State &= ~AUX_STATE_ENABLED;
    639             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     550            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    640551            pThis->u8CurrCmd = 0;
    641552            break;
    642553        case ACMD_SET_DEFAULT:
    643554            ps2mSetDefaults(pThis);
    644             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     555            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    645556            pThis->u8CurrCmd = 0;
    646557            break;
     
    653564            pThis->u8CurrCmd = cmd;
    654565            pThis->enmMode   = AUX_MODE_RESET;
    655             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     566            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    656567            if (pThis->fDelayReset)
    657568                /* Slightly delay reset completion; it might take hundreds of ms. */
     
    659570            else
    660571#ifdef IN_RING3
    661                 ps2mReset(pThis);
     572                ps2mR3Reset(pThis);
    662573#else
    663574                AssertLogRelMsgFailed(("Invalid ACMD_RESET outside R3!\n"));
     
    667578        case ACMD_SET_RES:
    668579        case ACMD_SET_SAMP_RATE:
    669             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     580            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    670581            pThis->u8CurrCmd = cmd;
    671582            break;
     
    679590                        pThis->u8Resolution = cmd;
    680591                        pThis->u8State &= ~AUX_STATE_RES_ERR;
    681                         ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     592                        PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    682593                        pThis->u8CurrCmd = 0;
    683594                    }
     
    688599                        {
    689600                            pThis->u8State &= ~AUX_STATE_RES_ERR;
    690                             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);
     601                            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);
    691602                            pThis->u8CurrCmd = 0;
    692603                        }
     
    694605                        {
    695606                            pThis->u8State |= AUX_STATE_RES_ERR;
    696                             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);
     607                            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);
    697608                            /* NB: Current command remains unchanged. */
    698609                        }
     
    705616                        ps2mSetRate(pThis, cmd);
    706617                        ps2mRateProtocolKnock(pThis, cmd);
    707                         ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
     618                        PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);
    708619                        pThis->u8CurrCmd = 0;
    709620                    }
     
    714625                        {
    715626                            pThis->u8State &= ~AUX_STATE_RATE_ERR;
    716                             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);
     627                            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);
    717628                            pThis->u8CurrCmd = 0;
    718629                        }
     
    720631                        {
    721632                            pThis->u8State |= AUX_STATE_RATE_ERR;
    722                             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);
     633                            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);
    723634                            /* NB: Current command remains unchanged. */
    724635                        }
     
    744655        case ACMD_INVALID_10:
    745656            Log(("Unsupported command 0x%02X!\n", cmd));
    746             ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);
     657            PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);
    747658            pThis->u8CurrCmd = 0;
    748659            break;
     
    790701}
    791702
    792 /* Event rate throttling timer to emulate the auxiliary device sampling rate.
    793  */
    794 static DECLCALLBACK(void) ps2mThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
     703/**
     704 * @callback_function_impl{FNTMTIMERDEV,
     705 * Event rate throttling timer to emulate the auxiliary device sampling rate.}
     706 */
     707static DECLCALLBACK(void) ps2mR3ThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    795708{
    796709    RT_NOREF(pDevIns, pTimer);
     
    819732}
    820733
    821 /* The auxiliary device reset is specified to take up to about 500 milliseconds. We need
    822  * to delay sending the result to the host for at least a tiny little while.
    823  */
    824 static DECLCALLBACK(void) ps2mDelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
     734/**
     735 * @callback_function_impl{FNTMTIMERDEV}
     736 *
     737 * The auxiliary device reset is specified to take up to about 500 milliseconds.
     738 * We need to delay sending the result to the host for at least a tiny little
     739 * while.
     740 */
     741static DECLCALLBACK(void) ps2mR3DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    825742{
    826743    RT_NOREF(pDevIns, pTimer);
     
    830747
    831748    Assert(pThis->u8CurrCmd == ACMD_RESET);
    832     ps2mReset(pThis);
     749    ps2mR3Reset(pThis);
    833750
    834751    /// @todo Might want a PS2MCompleteCommand() to push last response, clear command, and kick the KBC...
     
    845762 * @param   pszArgs     Argument string. Optional and specific to the handler.
    846763 */
    847 static DECLCALLBACK(void) ps2mInfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     764static DECLCALLBACK(void) ps2mR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    848765{
    849766    static const char   *pcszModes[] = { "normal", "reset", "wrap" };
     
    875792 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    876793 */
    877 static DECLCALLBACK(void *) ps2mQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     794static DECLCALLBACK(void *) ps2mR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
    878795{
    879796    PPS2M pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IBase);
     
    897814 * @param   fButtons        Depressed button mask.
    898815 */
    899 static int ps2mPutEventWorker(PPS2M pThis, int32_t dx, int32_t dy,
    900                               int32_t dz, int32_t dw, uint32_t fButtons)
    901 {
    902     int             rc = VINF_SUCCESS;
    903 
     816static int ps2mR3PutEventWorker(PPS2M pThis, int32_t dx, int32_t dy, int32_t dz, int32_t dw, uint32_t fButtons)
     817{
    904818    /* Update internal accumulators and button state. Ignore any buttons beyond 5. */
    905819    pThis->iAccumX += dx;
     
    915829     */
    916830    if (pThis->enmProtocol < PS2M_PROTO_IMEX_HORZ)
    917        pThis->iAccumW = 0; /* No horizontal scroll. */
     831        pThis->iAccumW = 0; /* No horizontal scroll. */
    918832
    919833    if (pThis->enmProtocol < PS2M_PROTO_IMEX)
    920834    {
    921        pThis->fAccumB &= PS2M_STD_BTN_MASK;   /* Only buttons 1-3. */
    922        pThis->fCurrB  &= PS2M_STD_BTN_MASK;
     835        pThis->fAccumB &= PS2M_STD_BTN_MASK;   /* Only buttons 1-3. */
     836        pThis->fCurrB  &= PS2M_STD_BTN_MASK;
    923837    }
    924838
    925839    if (pThis->enmProtocol < PS2M_PROTO_IMPS2)
    926        pThis->iAccumZ = 0; /* No vertical scroll. */
     840        pThis->iAccumZ = 0; /* No vertical scroll. */
    927841
    928842    /* Report the event (if any) and start the throttle timer unless it's already running. */
     
    935849    }
    936850
    937     return rc;
     851    return VINF_SUCCESS;
    938852}
    939853
     
    943857 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent}
    944858 */
    945 static DECLCALLBACK(int) ps2mPutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, int32_t dy,
    946                                       int32_t dz, int32_t dw, uint32_t fButtons)
     859static DECLCALLBACK(int) ps2mR3MousePort_PutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, int32_t dy,
     860                                                  int32_t dz, int32_t dw, uint32_t fButtons)
    947861{
    948862    PPS2M       pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IPort);
     
    952866    LogRelFlowFunc(("dX=%d dY=%d dZ=%d dW=%d buttons=%02X\n", dx, dy, dz, dw, fButtons));
    953867    /* NB: The PS/2 Y axis direction is inverted relative to ours. */
    954     ps2mPutEventWorker(pThis, dx, -dy, dz, dw, fButtons);
     868    ps2mR3PutEventWorker(pThis, dx, -dy, dz, dw, fButtons);
    955869
    956870    PDMCritSectLeave(pThis->pCritSectR3);
     
    961875 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs}
    962876 */
    963 static DECLCALLBACK(int) ps2mPutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t x, uint32_t y,
    964                                          int32_t dz, int32_t dw, uint32_t fButtons)
     877static DECLCALLBACK(int) ps2mR3MousePort_PutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t x, uint32_t y,
     878                                                     int32_t dz, int32_t dw, uint32_t fButtons)
    965879{
    966880    AssertFailedReturn(VERR_NOT_SUPPORTED);
     
    971885 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMultiTouch}
    972886 */
    973 static DECLCALLBACK(int) ps2mPutEventMT(PPDMIMOUSEPORT pInterface, uint8_t cContacts,
    974                                         const uint64_t *pau64Contacts, uint32_t u32ScanTime)
     887static DECLCALLBACK(int) ps2mR3MousePort_PutEventMT(PPDMIMOUSEPORT pInterface, uint8_t cContacts,
     888                                                    const uint64_t *pau64Contacts, uint32_t u32ScanTime)
    975889{
    976890    AssertFailedReturn(VERR_NOT_SUPPORTED);
     
    995909 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    996910 */
    997 int PS2MAttach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     911int PS2MR3Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    998912{
    999913    int         rc;
     
    1028942}
    1029943
    1030 void PS2MSaveState(PPS2M pThis, PSSMHANDLE pSSM)
    1031 {
     944void PS2MR3SaveState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM)
     945{
     946    PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
    1032947    LogFlowFunc(("Saving PS2M state\n"));
    1033948
    1034949    /* Save the core auxiliary device state. */
    1035     SSMR3PutU8(pSSM, pThis->u8State);
    1036     SSMR3PutU8(pSSM, pThis->u8SampleRate);
    1037     SSMR3PutU8(pSSM, pThis->u8Resolution);
    1038     SSMR3PutU8(pSSM, pThis->u8CurrCmd);
    1039     SSMR3PutU8(pSSM, pThis->enmMode);
    1040     SSMR3PutU8(pSSM, pThis->enmProtocol);
    1041     SSMR3PutU8(pSSM, pThis->enmKnockState);
     950    pHlp->pfnSSMPutU8(pSSM, pThis->u8State);
     951    pHlp->pfnSSMPutU8(pSSM, pThis->u8SampleRate);
     952    pHlp->pfnSSMPutU8(pSSM, pThis->u8Resolution);
     953    pHlp->pfnSSMPutU8(pSSM, pThis->u8CurrCmd);
     954    pHlp->pfnSSMPutU8(pSSM, pThis->enmMode);
     955    pHlp->pfnSSMPutU8(pSSM, pThis->enmProtocol);
     956    pHlp->pfnSSMPutU8(pSSM, pThis->enmKnockState);
    1042957
    1043958    /* Save the command and event queues. */
    1044     ps2kSaveQueue(pSSM, (GeneriQ *)&pThis->cmdQ);
    1045     ps2kSaveQueue(pSSM, (GeneriQ *)&pThis->evtQ);
     959    PS2CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ);
     960    PS2CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->evtQ);
    1046961
    1047962    /* Save the command delay timer. Note that the rate throttling
     
    1051966}
    1052967
    1053 int PS2MLoadState(PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion)
    1054 {
    1055     uint8_t     u8;
    1056     int         rc;
     968int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion)
     969{
     970    PCPDMDEVHLPR3   pHlp = pDevIns->pHlpR3;
     971    uint8_t         u8;
     972    int             rc;
    1057973
    1058974    NOREF(uVersion);
     
    1060976
    1061977    /* Load the basic auxiliary device state. */
    1062     SSMR3GetU8(pSSM, &pThis->u8State);
    1063     SSMR3GetU8(pSSM, &pThis->u8SampleRate);
    1064     SSMR3GetU8(pSSM, &pThis->u8Resolution);
    1065     SSMR3GetU8(pSSM, &pThis->u8CurrCmd);
    1066     SSMR3GetU8(pSSM, &u8);
     978    pHlp->pfnSSMGetU8(pSSM, &pThis->u8State);
     979    pHlp->pfnSSMGetU8(pSSM, &pThis->u8SampleRate);
     980    pHlp->pfnSSMGetU8(pSSM, &pThis->u8Resolution);
     981    pHlp->pfnSSMGetU8(pSSM, &pThis->u8CurrCmd);
     982    pHlp->pfnSSMGetU8(pSSM, &u8);
    1067983    pThis->enmMode       = (PS2M_MODE)u8;
    1068     SSMR3GetU8(pSSM, &u8);
     984    pHlp->pfnSSMGetU8(pSSM, &u8);
    1069985    pThis->enmProtocol   = (PS2M_PROTO)u8;
    1070     SSMR3GetU8(pSSM, &u8);
     986    pHlp->pfnSSMGetU8(pSSM, &u8);
    1071987    pThis->enmKnockState = (PS2M_KNOCK_STATE)u8;
    1072988
    1073989    /* Load the command and event queues. */
    1074     rc = ps2kLoadQueue(pSSM, (GeneriQ *)&pThis->cmdQ);
     990    rc = PS2CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ);
    1075991    AssertRCReturn(rc, rc);
    1076     rc = ps2kLoadQueue(pSSM, (GeneriQ *)&pThis->evtQ);
     992    rc = PS2CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->evtQ);
    1077993    AssertRCReturn(rc, rc);
    1078994
     
    10841000    ps2mSetRate(pThis, pThis->u8SampleRate);
    10851001
    1086     ps2mSetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));
    1087 
    1088     return rc;
    1089 }
    1090 
    1091 void PS2MFixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto)
     1002    ps2mR3SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));
     1003
     1004    return VINF_SUCCESS;
     1005}
     1006
     1007void PS2MR3FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto)
    10921008{
    10931009    LogFlowFunc(("Fixing up old PS2M state version\n"));
     
    11011017    ps2mSetRate(pThis, pThis->u8SampleRate);
    11021018
    1103     ps2mSetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));
    1104 }
    1105 
    1106 void PS2MReset(PPS2M pThis)
     1019    ps2mR3SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));
     1020}
     1021
     1022void PS2MR3Reset(PPS2M pThis)
    11071023{
    11081024    LogFlowFunc(("Resetting PS2M\n"));
     
    11111027
    11121028    /* Clear the queues. */
    1113     ps2kClearQueue((GeneriQ *)&pThis->cmdQ);
     1029    PS2CmnClearQueue((GeneriQ *)&pThis->cmdQ);
    11141030    ps2mSetDefaults(pThis);     /* Also clears event queue. */
    11151031}
    11161032
    1117 void PS2MRelocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)
     1033void PS2MR3Relocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)
    11181034{
    11191035    RT_NOREF(pDevIns, offDelta);
     
    11231039}
    11241040
    1125 int PS2MConstruct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)
     1041int PS2MR3Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)
    11261042{
    11271043    RT_NOREF(iInstance);
     
    11301046
    11311047#ifdef RT_STRICT
    1132     ps2mTestAccumulation();
     1048    ps2mR3TestAccumulation();
    11331049#endif
    11341050
     
    11391055    pThis->cmdQ.cSize = AUX_CMD_QUEUE_SIZE;
    11401056
    1141     pThis->Mouse.IBase.pfnQueryInterface     = ps2mQueryInterface;
    1142     pThis->Mouse.IPort.pfnPutEvent           = ps2mPutEvent;
    1143     pThis->Mouse.IPort.pfnPutEventAbs        = ps2mPutEventAbs;
    1144     pThis->Mouse.IPort.pfnPutEventMultiTouch = ps2mPutEventMT;
     1057    pThis->Mouse.IBase.pfnQueryInterface     = ps2mR3QueryInterface;
     1058    pThis->Mouse.IPort.pfnPutEvent           = ps2mR3MousePort_PutEvent;
     1059    pThis->Mouse.IPort.pfnPutEventAbs        = ps2mR3MousePort_PutEventAbs;
     1060    pThis->Mouse.IPort.pfnPutEventMultiTouch = ps2mR3MousePort_PutEventMT;
    11451061
    11461062    /*
     
    11531069     */
    11541070    PTMTIMER pTimer;
    1155     int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, ps2mThrottleTimer, pThis,
     1071    int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, ps2mR3ThrottleTimer, pThis,
    11561072                                    TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Throttle Timer", &pTimer);
    1157     if (RT_FAILURE(rc))
    1158         return rc;
     1073    AssertRCReturn(rc, rc);
    11591074
    11601075    pThis->pThrottleTimerR3 = pTimer;
     
    11651080     * Create the command delay timer.
    11661081     */
    1167     rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2mDelayTimer, pThis,
     1082    rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2mR3DelayTimer, pThis,
    11681083                                TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Delay Timer", &pTimer);
    1169     if (RT_FAILURE(rc))
    1170         return rc;
     1084    AssertRCReturn(rc, rc);
    11711085
    11721086    pThis->pDelayTimerR3 = pTimer;
     
    11771091     * Register debugger info callbacks.
    11781092     */
    1179     PDMDevHlpDBGFInfoRegister(pDevIns, "ps2m", "Display PS/2 mouse state.", ps2mInfoState);
     1093    PDMDevHlpDBGFInfoRegister(pDevIns, "ps2m", "Display PS/2 mouse state.", ps2mR3InfoState);
    11801094
    11811095    /// @todo Where should we do this?
    1182     ps2mSetDriverState(pThis, true);
     1096    ps2mR3SetDriverState(pThis, true);
    11831097    pThis->u8State = 0;
    11841098    pThis->enmMode = AUX_MODE_STD;
     
    11941108/** Test the event accumulation mechanism which we use to delay events going
    11951109 * to the guest to one per 10ms (the default PS/2 mouse event rate).  This
    1196  * test depends on ps2mPutEventWorker() not touching the timer if
     1110 * test depends on ps2mR3PutEventWorker() not touching the timer if
    11971111 * This.fThrottleActive is true. */
    11981112/** @todo if we add any more tests it might be worth using a table of test
    11991113 * operations and checks. */
    1200 static void ps2mTestAccumulation(void)
     1114static void ps2mR3TestAccumulation(void)
    12011115{
    12021116    PS2M This;
     
    12121126     * a release-press-release all within a single 10ms interval.  Simulate
    12131127     * this to check that it is handled right. */
    1214     ps2mPutEventWorker(&This, 0, 0, 0, 0, 1);
     1128    ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1);
    12151129    if (ps2mHaveEvents(&This))
    12161130        ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);
    1217     ps2mPutEventWorker(&This, 0, 0, 0, 0, 0);
     1131    ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 0);
    12181132    if (ps2mHaveEvents(&This))
    12191133        ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);
    1220     ps2mPutEventWorker(&This, 0, 0, 0, 0, 1);
    1221     ps2mPutEventWorker(&This, 0, 0, 0, 0, 0);
     1134    ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1);
     1135    ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 0);
    12221136    if (ps2mHaveEvents(&This))
    12231137        ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);
     
    12361150    /* Button hold down during mouse drags was broken at some point during
    12371151     * testing fixes for the previous issue.  Test that that works. */
    1238     ps2mPutEventWorker(&This, 0, 0, 0, 0, 1);
     1152    ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1);
    12391153    if (ps2mHaveEvents(&This))
    12401154        ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);
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