VirtualBox

Changeset 83299 in vbox


Ignore:
Timestamp:
Mar 16, 2020 3:20:30 PM (5 years ago)
Author:
vboxsync
Message:

DevPS2: Discard input when device's serial line is disabled. Also discard queued mouse input if protocol changes.

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

Legend:

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

    r82968 r83299  
    318318    case KBD_CCMD_MOUSE_DISABLE:
    319319        s->mode |= KBD_MODE_DISABLE_MOUSE;
     320        PS2MLineDisable(&s->Aux);
    320321        break;
    321322    case KBD_CCMD_MOUSE_ENABLE:
     323        PS2MLineEnable(&s->Aux);
    322324        s->mode &= ~KBD_MODE_DISABLE_MOUSE;
    323325        /* Check for queued input. */
     326        ///@todo: Can there actually be any?
    324327        kbd_update_irq(pDevIns, s);
    325328        break;
     
    488491    case KBD_CCMD_WRITE_MOUSE:
    489492        /* Automatically enables aux interface. */
    490         s->mode &= ~KBD_MODE_DISABLE_MOUSE;
     493        if (s->mode & KBD_MODE_DISABLE_MOUSE)
     494        {
     495            PS2MLineEnable(&s->Aux);
     496            s->mode &= ~KBD_MODE_DISABLE_MOUSE;
     497        }
    491498        rc = PS2MByteToAux(pDevIns, &s->Aux, val);
    492499        if (rc == VINF_SUCCESS)
     
    923930    PKBDSTATER3  pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3);
    924931    RT_NOREF(pSSM);
     932    if (pThis->mode & KBD_MODE_DISABLE_MOUSE)
     933        PS2MLineDisable(&pThis->Aux);
     934    if (pThis->mode & KBD_MODE_DISABLE_KBD)
     935        PS2KLineDisable(&pThis->Kbd);
    925936    return PS2KR3LoadDone(pDevIns, &pThis->Kbd, &pThisCC->Kbd);
     937}
     938
     939
     940/**
     941 * Debug device info handler. Prints basic auxiliary device state.
     942 *
     943 * @param   pDevIns     Device instance which registered the info.
     944 * @param   pHlp        Callback functions for doing output.
     945 * @param   pszArgs     Argument string. Optional and specific to the handler.
     946 */
     947static DECLCALLBACK(void) kbdR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     948{
     949    PKBDSTATE    pThis   = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     950    NOREF(pszArgs);
     951
     952    pHlp->pfnPrintf(pHlp, "Keyboard controller: Active command %02X, DBB out %02X, translation %s\n",
     953                    pThis->write_cmd, pThis->dbbout, pThis->translate ? "on"  : "off");
     954
     955    pHlp->pfnPrintf(pHlp, "Mode: %02X ( ", pThis->mode);
     956    if (pThis->mode & KBD_MODE_DISABLE_KBD)
     957        pHlp->pfnPrintf(pHlp, "DISABLE_KBD ");
     958    if (pThis->mode & KBD_MODE_KBD_INT)
     959        pHlp->pfnPrintf(pHlp, "KBD_INT ");
     960    if (pThis->mode & KBD_MODE_MOUSE_INT)
     961        pHlp->pfnPrintf(pHlp, "AUX_INT ");
     962    if (pThis->mode & KBD_MODE_SYS)
     963        pHlp->pfnPrintf(pHlp, "SYS ");
     964    if (pThis->mode & KBD_MODE_NO_KEYLOCK)
     965        pHlp->pfnPrintf(pHlp, "NO_KEYLOCK ");
     966    if (pThis->mode & KBD_MODE_DISABLE_KBD)
     967        pHlp->pfnPrintf(pHlp, "DISABLE_KBD ");
     968    if (pThis->mode & KBD_MODE_DISABLE_MOUSE)
     969        pHlp->pfnPrintf(pHlp, "DISABLE_AUX ");
     970    if (pThis->mode & KBD_MODE_KCC)
     971        pHlp->pfnPrintf(pHlp, "KCC ");
     972    if (pThis->mode & KBD_MODE_RFU)
     973        pHlp->pfnPrintf(pHlp, "RFU ");
     974    pHlp->pfnPrintf(pHlp, " )\n");
     975
     976    pHlp->pfnPrintf(pHlp, "Status: %02X ( ", pThis->status);
     977    if (pThis->status & KBD_STAT_OBF)
     978        pHlp->pfnPrintf(pHlp, "OBF ");
     979    if (pThis->status & KBD_STAT_IBF)
     980        pHlp->pfnPrintf(pHlp, "IBF ");
     981    if (pThis->status & KBD_STAT_SELFTEST)
     982        pHlp->pfnPrintf(pHlp, "SELFTEST ");
     983    if (pThis->status & KBD_STAT_CMD)
     984        pHlp->pfnPrintf(pHlp, "CMD ");
     985    if (pThis->status & KBD_STAT_UNLOCKED)
     986        pHlp->pfnPrintf(pHlp, "UNLOCKED ");
     987    if (pThis->status & KBD_STAT_MOUSE_OBF)
     988        pHlp->pfnPrintf(pHlp, "AUX_OBF ");
     989    if (pThis->status & KBD_STAT_GTO)
     990        pHlp->pfnPrintf(pHlp, "GTO ");
     991    if (pThis->status & KBD_STAT_PERR)
     992        pHlp->pfnPrintf(pHlp, "PERR ");
     993    pHlp->pfnPrintf(pHlp, " )\n");
    926994}
    927995
     
    10691137                                NULL, kbdR3LoadExec, kbdR3LoadDone);
    10701138    AssertRCReturn(rc, rc);
     1139
     1140    /*
     1141     * Register debugger info callbacks.
     1142     */
     1143    PDMDevHlpDBGFInfoRegister(pDevIns, "ps2c", "Display keyboard/mouse controller state.", kbdR3InfoState);
    10711144
    10721145    /*
  • trunk/src/VBox/Devices/Input/DevPS2.h

    r82968 r83299  
    149149    /** Set if the input rate should be throttled. */
    150150    bool                fThrottleEnabled;
    151     uint8_t             abAlignment2[2];
     151    /** Set if the serial line is disabled on the KBC. */
     152    bool                fLineDisabled;
     153    uint8_t             abAlignment2[1];
    152154
    153155    /** Command delay timer. */
     
    197199int  PS2KByteFromKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t *pVal);
    198200
     201void PS2KLineDisable(PPS2K pThis);
     202void PS2KLineEnable(PPS2K pThis);
     203
    199204int  PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, PCFGMNODE pCfg);
    200205int  PS2KR3Attach(PPDMDEVINS pDevIns, PPS2KR3 pThisCC, unsigned iLUN, uint32_t fFlags);
     
    268273    /** Currently processed command (if any). */
    269274    uint8_t             u8CurrCmd;
     275    /** Set if the serial line is disabled on the KBC. */
     276    bool                fLineDisabled;
    270277    /** Set if the throttle delay is active. */
    271278    bool                fThrottleActive;
     
    341348int  PS2MByteFromAux(PPS2M pThis, uint8_t *pVal);
    342349
     350void PS2MLineDisable(PPS2M pThis);
     351void PS2MLineEnable(PPS2M pThis);
     352
    343353int  PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC);
    344354int  PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags);
  • trunk/src/VBox/Devices/Input/DevPS2K.cpp

    r82968 r83299  
    483483
    484484/**
     485 * The keyboard controller disabled the keyboard serial line.
     486 *
     487 * @param   pDevIns The device instance.
     488 * @param   pThis   The PS/2 auxiliary device shared instance data.
     489 */
     490void PS2KLineDisable(PPS2K pThis)
     491{
     492    pThis->fLineDisabled = true;
     493}
     494
     495/**
     496 * The keyboard controller enabled the keyboard serial line.
     497 *
     498 * @param   pDevIns The device instance.
     499 * @param   pThis   The PS/2 auxiliary device shared instance data.
     500 */
     501void PS2KLineEnable(PPS2K pThis)
     502{
     503    pThis->fLineDisabled = false;
     504
     505    /* If there was anything in the input queue,
     506     * consider it lost and throw it away.
     507     */
     508    PS2Q_CLEAR(&pThis->keyQ);
     509}
     510
     511/**
    485512 * Receive and process a byte sent by the keyboard controller.
    486513 *
     
    10311058    NOREF(pszArgs);
    10321059
    1033     pHlp->pfnPrintf(pHlp, "PS/2 Keyboard: scan set %d, scanning %s\n",
    1034                     pThis->u8ScanSet, pThis->fScanning ? "enabled" : "disabled");
     1060    pHlp->pfnPrintf(pHlp, "PS/2 Keyboard: scan set %d, scanning %s, serial line %s\n",
     1061                    pThis->u8ScanSet, pThis->fScanning ? "enabled" : "disabled",
     1062                    pThis->fLineDisabled ? "disabled" : "enabled");
    10351063    pHlp->pfnPrintf(pHlp, "Active command %02X\n", pThis->u8CurrCmd);
    10361064    pHlp->pfnPrintf(pHlp, "LED state %02X, Num Lock %s\n", pThis->u8LEDs,
  • trunk/src/VBox/Devices/Input/DevPS2M.cpp

    r82968 r83299  
    257257static void ps2mRateProtocolKnock(PPS2M pThis, uint8_t rate)
    258258{
     259    PS2M_PROTO          enmOldProtocol = pThis->enmProtocol;
     260
    259261    switch (pThis->enmKnockState)
    260262    {
     
    299301        pThis->enmKnockState = PS2M_KNOCK_INITIAL;
    300302    }
     303
     304    /* If the protocol changed, throw away any queued input because it now
     305     * has the wrong format, which could severely confuse the guest.
     306     */
     307    if (enmOldProtocol != pThis->enmProtocol)
     308        PS2Q_CLEAR(&pThis->evtQ);
    301309}
    302310
     
    411419   return fValid;
    412420}
     421
     422
     423/**
     424 * The keyboard controller disabled the auxiliary serial line.
     425 *
     426 * @param   pDevIns The device instance.
     427 * @param   pThis   The PS/2 auxiliary device shared instance data.
     428 */
     429void PS2MLineDisable(PPS2M pThis)
     430{
     431    pThis->fLineDisabled = true;
     432}
     433
     434/**
     435 * The keyboard controller enabled the auxiliary serial line.
     436 *
     437 * @param   pDevIns The device instance.
     438 * @param   pThis   The PS/2 auxiliary device shared instance data.
     439 */
     440void PS2MLineEnable(PPS2M pThis)
     441{
     442    pThis->fLineDisabled = false;
     443
     444    /* If there was anything in the input queue,
     445     * consider it lost and throw it away.
     446     */
     447    PS2Q_CLEAR(&pThis->evtQ);
     448}
     449
    413450
    414451/**
     
    743780
    744781    Assert(pThis->enmMode < RT_ELEMENTS(s_apcszModes));
    745     pHlp->pfnPrintf(pHlp, "PS/2 mouse state: %s, %s mode, reporting %s\n",
     782    pHlp->pfnPrintf(pHlp, "PS/2 mouse state: %s, %s mode, reporting %s, serial line %s\n",
    746783                    s_apcszModes[pThis->enmMode],
    747784                    pThis->u8State & AUX_STATE_REMOTE  ? "remote"  : "stream",
    748                     pThis->u8State & AUX_STATE_ENABLED ? "enabled" : "disabled");
     785                    pThis->u8State & AUX_STATE_ENABLED ? "enabled" : "disabled",
     786                    pThis->fLineDisabled ? "disabled" : "enabled");
    749787    Assert(pThis->enmProtocol < RT_ELEMENTS(s_apcszProtocols));
    750788    pHlp->pfnPrintf(pHlp, "Protocol: %s, scaling %u:1\n",
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