VirtualBox

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


Ignore:
Timestamp:
Nov 25, 2019 10:46:54 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135020
Message:

DevPS2: Split up the state structures. bugref:9218

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

Legend:

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

    r82204 r82206  
    442442}
    443443
    444 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns)
    445 {
    446     PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
    447     return &pThis->Kbd;
    448 }
    449 
    450 PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns)
    451 {
    452     PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
    453     return &pThis->Aux;
    454 }
    455 
    456444static VBOXSTRICTRC kbd_write_data(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t val)
    457445{
     
    515503#ifdef IN_RING3
    516504
    517 static int kbd_load(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PKBDSTATE s, uint32_t version_id)
     505static int kbd_load(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PKBDSTATE s, PKBDSTATER3 pThisCC, uint32_t version_id)
    518506{
    519507    uint32_t    u32, i;
    520     uint8_t u8Dummy;
    521     uint32_t u32Dummy;
     508    uint8_t     u8Dummy;
     509    uint32_t    u32Dummy;
    522510    int         rc;
    523511
     
    576564        AssertLogRelRCReturn(rc, rc);
    577565
    578         PS2MR3FixupState(&s->Aux, u8State, u8Rate, u8Proto);
     566        PS2MR3FixupState(&s->Aux, &pThisCC->Aux, u8State, u8Rate, u8Proto);
    579567    }
    580568
     
    878866static DECLCALLBACK(int) kbdR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    879867{
    880     PKBDSTATE    pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     868    PKBDSTATE    pThis   = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     869    PKBDSTATER3  pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3);
    881870    int rc;
    882871
    883872    Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    884     rc = kbd_load(pDevIns->pHlpR3, pSSM, pThis, uVersion);
     873    rc = kbd_load(pDevIns->pHlpR3, pSSM, pThis, pThisCC, uVersion);
    885874    AssertRCReturn(rc, rc);
    886875
     
    890879
    891880    if (uVersion >= 8)
    892         rc = PS2MR3LoadState(pDevIns, &pThis->Aux, pSSM, uVersion);
     881        rc = PS2MR3LoadState(pDevIns, &pThis->Aux, &pThisCC->Aux, pSSM, uVersion);
    893882    AssertRCReturn(rc, rc);
    894883    return rc;
     
    900889static DECLCALLBACK(int) kbdR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    901890{
    902     PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     891    PKBDSTATE    pThis   = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     892    PKBDSTATER3  pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3);
    903893    RT_NOREF(pSSM);
    904     return PS2KR3LoadDone(pDevIns, &pThis->Kbd);
     894    return PS2KR3LoadDone(pDevIns, &pThis->Kbd, &pThisCC->Kbd);
    905895}
    906896
     
    913903static DECLCALLBACK(void)  kbdR3Reset(PPDMDEVINS pDevIns)
    914904{
    915     PKBDSTATE    pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     905    PKBDSTATE    pThis   = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     906    PKBDSTATER3  pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3);
    916907
    917908    pThis->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT;
     
    921912    pThis->translate = 0;
    922913
    923     PS2KR3Reset(pDevIns, &pThis->Kbd);
     914    PS2KR3Reset(pDevIns, &pThis->Kbd, &pThisCC->Kbd);
    924915    PS2MR3Reset(&pThis->Aux);
    925916}
     
    937928static DECLCALLBACK(int)  kbdR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    938929{
     930    PKBDSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3);
    939931    int         rc;
    940     PKBDSTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
    941932
    942933    AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
     
    948939        /* LUN #0: keyboard */
    949940        case 0:
    950             rc = PS2KR3Attach(&pThis->Kbd, pDevIns, iLUN, fFlags);
     941            rc = PS2KR3Attach(pDevIns, &pThisCC->Kbd, iLUN, fFlags);
    951942            break;
    952943
    953944        /* LUN #1: aux/mouse */
    954945        case 1:
    955             rc = PS2MR3Attach(&pThis->Aux, pDevIns, iLUN, fFlags);
     946            rc = PS2MR3Attach(pDevIns, &pThisCC->Aux, iLUN, fFlags);
    956947            break;
    957948
     
    981972        /* LUN #0: keyboard */
    982973        case 0:
    983             pThis->Keyboard.pDrv = NULL;
    984             pThis->Keyboard.pDrvBase = NULL;
     974            pThisCC->Keyboard.pDrv = NULL;
     975            pThisCC->Keyboard.pDrvBase = NULL;
    985976            break;
    986977
    987978        /* LUN #1: aux/mouse */
    988979        case 1:
    989             pThis->Mouse.pDrv = NULL;
    990             pThis->Mouse.pDrvBase = NULL;
     980            pThisCC->Mouse.pDrv = NULL;
     981            pThisCC->Mouse.pDrvBase = NULL;
    991982            break;
    992983
     
    1007998{
    1008999    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    1009     PKBDSTATE   pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     1000    PKBDSTATE   pThis   = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     1001    PKBDSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3);
    10101002    int         rc;
    10111003    Assert(iInstance == 0);
     
    10201012     * Initialize the sub-components.
    10211013     */
    1022     rc = PS2KR3Construct(&pThis->Kbd, pDevIns, pThis, iInstance, pCfg);
    1023     AssertRCReturn(rc, rc);
    1024 
    1025     rc = PS2MR3Construct(&pThis->Aux, pDevIns, pThis, iInstance);
     1014    rc = PS2KR3Construct(pDevIns, &pThis->Kbd, &pThisCC->Kbd, iInstance, pCfg);
     1015    AssertRCReturn(rc, rc);
     1016
     1017    rc = PS2MR3Construct(pDevIns, &pThis->Aux, &pThisCC->Aux, iInstance);
    10261018    AssertRCReturn(rc, rc);
    10271019
     
    10891081    /* .uReserved0 = */             0,
    10901082    /* .szName = */                 "pckbd",
    1091     /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ,
     1083    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE,
    10921084    /* .fClass = */                 PDM_DEVREG_CLASS_INPUT,
    10931085    /* .cMaxInstances = */          1,
    10941086    /* .uSharedVersion = */         42,
    10951087    /* .cbInstanceShared = */       sizeof(KBDSTATE),
    1096     /* .cbInstanceCC = */           0,
     1088    /* .cbInstanceCC = */           CTX_EXPR(sizeof(KBDSTATER3), 0, 0),
    10971089    /* .cbInstanceRC = */           0,
    10981090    /* .cMaxPciDevices = */         0,
  • trunk/src/VBox/Devices/Input/DevPS2.h

    r82204 r82206  
    9292typedef struct PS2K
    9393{
    94     /** Pointer to parent device (keyboard controller). */
    95     R3PTRTYPE(PKBDSTATE) pParent;
    9694    /** Set if keyboard is enabled ('scans' for input). */
    9795    bool                fScanning;
     
    129127    uint8_t             abAlignment2[2];
    130128
    131     /** Command delay timer - R3 Ptr. */
     129    /** Command delay timer. */
    132130    TMTIMERHANDLE       hKbdDelayTimer;
    133     /** Typematic timer - R3 Ptr. */
     131    /** Typematic timer. */
    134132    TMTIMERHANDLE       hKbdTypematicTimer;
    135133    /** Input throttle timer. */
    136134    TMTIMERHANDLE       hThrottleTimer;
    137 
     135} PS2K;
     136/** Pointer to the shared PS/2 keyboard instance data. */
     137typedef PS2K *PPS2K;
     138
     139
     140/**
     141 * The PS/2 keyboard instance data for ring-3.
     142 */
     143typedef struct PS2KR3
     144{
    138145    /** The device instance.
    139146     * @note Only for getting our bearings in interface methods. */
     
    158165        R3PTRTYPE(PPDMIKEYBOARDCONNECTOR)   pDrv;
    159166    } Keyboard;
    160 } PS2K;
    161 /** Pointer to the PS/2 keyboard instance data. */
    162 typedef PS2K *PPS2K;
     167} PS2KR3;
     168/** Pointer to the PS/2 keyboard instance data for ring-3. */
     169typedef PS2KR3 *PPS2KR3;
    163170
    164171
     
    166173int  PS2KByteFromKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t *pVal);
    167174
    168 int  PS2KR3Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg);
    169 int  PS2KR3Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
    170 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis);
     175int  PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, unsigned iInstance, PCFGMNODE pCfg);
     176int  PS2KR3Attach(PPDMDEVINS pDevIns, PPS2KR3 pThisCC, unsigned iLUN, uint32_t fFlags);
     177void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC);
    171178void PS2KR3SaveState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM);
    172179int  PS2KR3LoadState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion);
    173 int  PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis);
    174 
    175 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns);
    176 
     180int  PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC);
    177181/** @} */
    178182
     
    228232
    229233/**
    230  * The PS/2 auxiliary device instance data.
     234 * The shared PS/2 auxiliary device instance data.
    231235 */
    232236typedef struct PS2M
    233237{
    234     /** Pointer to parent device (keyboard controller). */
    235     R3PTRTYPE(PKBDSTATE) pParent;
    236238    /** Operational state. */
    237239    uint8_t             u8State;
     
    273275    uint32_t            uThrottleDelay;
    274276
    275     /** The device instance.
    276      * @note Only for getting our bearings in interface methods. */
    277     PPDMDEVINSR3        pDevIns;
    278 
    279277    /** Command delay timer. */
    280278    TMTIMERHANDLE       hDelayTimer;
    281279    /** Interrupt throttling timer. */
    282280    TMTIMERHANDLE       hThrottleTimer;
     281} PS2M;
     282/** Pointer to the shared PS/2 auxiliary device instance data. */
     283typedef PS2M *PPS2M;
     284
     285/**
     286 * The PS/2 auxiliary device instance data for ring-3.
     287 */
     288typedef struct PS2MR3
     289{
     290    /** The device instance.
     291     * @note Only for getting our bearings in interface methods. */
     292    PPDMDEVINSR3        pDevIns;
    283293
    284294    /**
     
    300310        R3PTRTYPE(PPDMIMOUSECONNECTOR)      pDrv;
    301311    } Mouse;
    302 } PS2M;
    303 /** Pointer to the PS/2 auxiliary device instance data. */
    304 typedef PS2M *PPS2M;
     312} PS2MR3;
     313/** Pointer to the PS/2 auxiliary device instance data for ring-3. */
     314typedef PS2MR3 *PPS2MR3;
    305315
    306316int  PS2MByteToAux(PPDMDEVINS pDevIns, PPS2M pThis, uint8_t cmd);
    307317int  PS2MByteFromAux(PPS2M pThis, uint8_t *pVal);
    308318
    309 int  PS2MR3Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance);
    310 int  PS2MR3Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
     319int  PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, unsigned iInstance);
     320int  PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags);
    311321void PS2MR3Reset(PPS2M pThis);
    312322void PS2MR3SaveState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM);
    313 int  PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion);
    314 void PS2MR3FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto);
    315 
    316 PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns);
    317 
     323int  PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, PSSMHANDLE pSSM, uint32_t uVersion);
     324void PS2MR3FixupState(PPS2M pThis, PPS2MR3 pThisCC, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto);
    318325/** @} */
    319326
     
    335342
    336343    /** I/O port 60h. */
    337     IOMIOPORTHANDLE             hIoPortData;
     344    IOMIOPORTHANDLE     hIoPortData;
    338345    /** I/O port 64h. */
    339     IOMIOPORTHANDLE             hIoPortCmdStatus;
    340 
    341     /** Keyboard state (implemented in separate PS2K module). */
    342     PS2K                        Kbd;
    343 
    344     /** Mouse state (implemented in separate PS2M module). */
    345     PS2M                        Aux;
     346    IOMIOPORTHANDLE     hIoPortCmdStatus;
     347
     348    /** Shared keyboard state (implemented in separate PS2K module). */
     349    PS2K                Kbd;
     350    /** Shared mouse state (implemented in separate PS2M module). */
     351    PS2M                Aux;
    346352} KBDSTATE;
     353
     354
     355/**
     356 * The ring-3 keyboard controller/device state.
     357 */
     358typedef struct KBDSTATER3
     359{
     360    /** Keyboard state for ring-3 (implemented in separate PS2K module). */
     361    PS2KR3  Kbd;
     362    /** Mouse state for ring-3 (implemented in separate PS2M module). */
     363    PS2MR3  Aux;
     364} KBDSTATER3;
     365/** Pointer to the keyboard (PS/2) controller / device state for ring-3. */
     366typedef KBDSTATER3 *PKBDSTATER3;
    347367
    348368
  • trunk/src/VBox/Devices/Input/DevPS2K.cpp

    r82200 r82206  
    415415 * Notify listener about LEDs state change.
    416416 *
    417  * @param   pThis           The PS/2 keyboard instance data.
     417 * @param   pThisCC         The PS/2 keyboard instance data for ring-3.
    418418 * @param   u8State         Bitfield which reflects LEDs state.
    419419 */
    420 static void ps2kR3NotifyLedsState(PPS2K pThis, uint8_t u8State)
    421 {
    422 
     420static void ps2kR3NotifyLedsState(PPS2KR3 pThisCC, uint8_t u8State)
     421{
    423422    PDMKEYBLEDS enmLeds = PDMKEYBLEDS_NONE;
    424423
     
    430429        enmLeds = (PDMKEYBLEDS)(enmLeds | PDMKEYBLEDS_CAPSLOCK);
    431430
    432     pThis->Keyboard.pDrv->pfnLedStatusChange(pThis->Keyboard.pDrv, enmLeds);
    433 
     431    pThisCC->Keyboard.pDrv->pfnLedStatusChange(pThisCC->Keyboard.pDrv, enmLeds);
    434432}
    435433
     
    495493 *
    496494 * @param   pDevIns The device instance.
    497  * @param   pThis   The PS/2 keyboard instance data.
     495 * @param   pThis   The shared PS/2 keyboard instance data.
    498496 * @param   cmd     The command (or data) byte.
    499497 */
     
    577575#else
    578576                    {
    579                         ps2kR3NotifyLedsState(pThis, cmd);
     577                        PPS2KR3 pThisCC = &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Kbd;
     578                        ps2kR3NotifyLedsState(pThisCC, cmd);
    580579                        pThis->fNumLockOn = !!(cmd & 0x02); /* Sync internal Num Lock state. */
    581580                        PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);
     
    626625 * @returns VINF_SUCCESS or VINF_TRY_AGAIN.
    627626 * @param   pDevIns The device instance.
    628  * @param   pThis   The PS/2 keyboard instance data.
     627 * @param   pThis   The shared PS/2 keyboard instance data.
    629628 * @param   pb      Where to return the byte we've read.
    630629 * @remarks Caller must have entered the device critical section.
     
    10351034static DECLCALLBACK(void) ps2kR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    10361035{
    1037     PPS2K   pThis = KBDGetPS2KFromDevIns(pDevIns);
     1036    PKBDSTATE   pParent = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     1037    PPS2K       pThis   = &pParent->Kbd;
    10381038    NOREF(pszArgs);
    10391039
     
    10541054}
    10551055
    1056 /* -=-=-=-=-=- Keyboard: IBase  -=-=-=-=-=- */
    1057 
    1058 /**
    1059  * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    1060  */
    1061 static DECLCALLBACK(void *) ps2kR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
    1062 {
    1063     PPS2K pThis = RT_FROM_MEMBER(pInterface, PS2K, Keyboard.IBase);
    1064     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->Keyboard.IBase);
    1065     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIKEYBOARDPORT, &pThis->Keyboard.IPort);
    1066     return NULL;
    1067 }
    1068 
    10691056
    10701057/* -=-=-=-=-=- Keyboard: IKeyboardPort  -=-=-=-=-=- */
     
    11291116static DECLCALLBACK(int) ps2kR3KeyboardPort_PutEventHid(PPDMIKEYBOARDPORT pInterface, uint32_t u32UsageCode)
    11301117{
    1131     PPS2K       pThis = RT_FROM_MEMBER(pInterface, PS2K, Keyboard.IPort);
    1132     PPDMDEVINS  pDevIns = pThis->pDevIns;
     1118    PPS2KR3     pThisCC = RT_FROM_MEMBER(pInterface, PS2KR3, Keyboard.IPort);
     1119    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     1120    PPS2K       pThis   = &PDMDEVINS_2_DATA(pDevIns, PKBDSTATE)->Kbd;
    11331121    int         rc;
    11341122
     
    11521140
    11531141
     1142/* -=-=-=-=-=- Keyboard: IBase  -=-=-=-=-=- */
     1143
     1144/**
     1145 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     1146 */
     1147static DECLCALLBACK(void *) ps2kR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
     1148{
     1149    PPS2KR3 pThisCC = RT_FROM_MEMBER(pInterface, PS2KR3, Keyboard.IBase);
     1150    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->Keyboard.IBase);
     1151    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIKEYBOARDPORT, &pThisCC->Keyboard.IPort);
     1152    return NULL;
     1153}
     1154
     1155
    11541156/* -=-=-=-=-=- Device management -=-=-=-=-=- */
    11551157
     
    11641166 *
    11651167 * @returns VBox status code.
    1166  * @param   pThis       The PS/2 keyboard instance data.
    11671168 * @param   pDevIns     The device instance.
     1169 * @param   pThisCC     The PS/2 keyboard instance data for ring-3.
    11681170 * @param   iLUN        The logical unit which is being detached.
    11691171 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    11701172 */
    1171 int PS2KR3Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     1173int PS2KR3Attach(PPDMDEVINS pDevIns, PPS2KR3 pThisCC, unsigned iLUN, uint32_t fFlags)
    11721174{
    11731175    int         rc;
     
    11811183    LogFlowFunc(("iLUN=%d\n", iLUN));
    11821184
    1183     rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->Keyboard.IBase, &pThis->Keyboard.pDrvBase, "Keyboard Port");
     1185    rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->Keyboard.IBase, &pThisCC->Keyboard.pDrvBase, "Keyboard Port");
    11841186    if (RT_SUCCESS(rc))
    11851187    {
    1186         pThis->Keyboard.pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Keyboard.pDrvBase, PDMIKEYBOARDCONNECTOR);
    1187         if (!pThis->Keyboard.pDrv)
     1188        pThisCC->Keyboard.pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->Keyboard.pDrvBase, PDMIKEYBOARDCONNECTOR);
     1189        if (!pThisCC->Keyboard.pDrv)
    11881190        {
    11891191            AssertLogRelMsgFailed(("LUN #0 doesn't have a keyboard interface! rc=%Rrc\n", rc));
     
    13141316}
    13151317
    1316 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis)
     1318int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC)
    13171319{
    13181320    /* This *must* be done after the inital load because it may trigger
     
    13201322     */
    13211323    ps2kR3ReleaseKeys(pDevIns, pThis);
    1322     ps2kR3NotifyLedsState(pThis, pThis->u8LEDs);
     1324    ps2kR3NotifyLedsState(pThisCC, pThis->u8LEDs);
    13231325    return VINF_SUCCESS;
    13241326}
    13251327
    1326 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis)
     1328void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC)
    13271329{
    13281330    LogFlowFunc(("Resetting PS2K\n"));
     
    13421344
    13431345    /* Activate the PS/2 keyboard by default. */
    1344     if (pThis->Keyboard.pDrv)
    1345         pThis->Keyboard.pDrv->pfnSetActive(pThis->Keyboard.pDrv, true);
    1346 }
    1347 
    1348 int PS2KR3Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg)
     1346    if (pThisCC->Keyboard.pDrv)
     1347        pThisCC->Keyboard.pDrv->pfnSetActive(pThisCC->Keyboard.pDrv, true /*fActive*/);
     1348}
     1349
     1350int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, unsigned iInstance, PCFGMNODE pCfg)
    13491351{
    13501352    PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
     
    13521354    LogFlowFunc(("iInstance=%u\n", iInstance));
    13531355
    1354     pThis->pParent = pParent;
    1355     pThis->pDevIns = pDevIns;
     1356    pThisCC->pDevIns = pDevIns;
    13561357
    13571358    bool fThrottleEnabled;
     
    13661367    pThis->cmdQ.cSize = KBD_CMD_QUEUE_SIZE;
    13671368
    1368     pThis->Keyboard.IBase.pfnQueryInterface = ps2kR3QueryInterface;
    1369     pThis->Keyboard.IPort.pfnPutEventHid    = ps2kR3KeyboardPort_PutEventHid;
     1369    pThisCC->Keyboard.IBase.pfnQueryInterface = ps2kR3QueryInterface;
     1370    pThisCC->Keyboard.IPort.pfnPutEventHid    = ps2kR3KeyboardPort_PutEventHid;
    13701371
    13711372    /*
  • trunk/src/VBox/Devices/Input/DevPS2M.cpp

    r82200 r82206  
    209209
    210210/* Report a change in status down (or is it up?) the driver chain. */
    211 static void ps2mR3SetDriverState(PPS2M pThis, bool fEnabled)
    212 {
    213     PPDMIMOUSECONNECTOR pDrv = pThis->Mouse.pDrv;
     211static void ps2mR3SetDriverState(PPS2MR3 pThisCC, bool fEnabled)
     212{
     213    PPDMIMOUSECONNECTOR pDrv = pThisCC->Mouse.pDrv;
    214214    if (pDrv)
    215215        pDrv->pfnReportModes(pDrv, fEnabled, false, false);
     
    217217
    218218/* Reset the pointing device. */
    219 static void ps2mR3Reset(PPS2M pThis)
     219static void ps2mR3Reset(PPS2M pThis, PPS2MR3 pThisCC)
    220220{
    221221    PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK);
     
    225225
    226226    /// @todo move to its proper home!
    227     ps2mR3SetDriverState(pThis, true);
     227    ps2mR3SetDriverState(pThisCC, true);
    228228}
    229229
     
    509509            pThis->u8State |= AUX_STATE_ENABLED;
    510510#ifdef IN_RING3
    511             ps2mR3SetDriverState(pThis, true);
     511            ps2mR3SetDriverState(&PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux, true);
    512512#else
    513513            AssertLogRelMsgFailed(("Invalid ACMD_ENABLE outside R3!\n"));
     
    541541            else
    542542#ifdef IN_RING3
    543                 ps2mR3Reset(pThis);
     543                ps2mR3Reset(pThis, &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux);
    544544#else
    545545                AssertLogRelMsgFailed(("Invalid ACMD_RESET outside R3!\n"));
     
    712712static DECLCALLBACK(void) ps2mR3DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    713713{
    714     RT_NOREF(pDevIns, pTimer);
    715     PPS2M pThis = (PS2M *)pvUser;
     714    PPS2M   pThis   = &PDMDEVINS_2_DATA(pDevIns, PKBDSTATE)->Aux;
     715    PPS2MR3 pThisCC = &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux;
     716    RT_NOREF(pvUser, pTimer);
    716717
    717718    LogFlowFunc(("Delay timer: cmd %02X\n", pThis->u8CurrCmd));
    718719
    719720    Assert(pThis->u8CurrCmd == ACMD_RESET);
    720     ps2mR3Reset(pThis);
     721    ps2mR3Reset(pThis, pThisCC);
    721722
    722723    /// @todo Might want a PS2MCompleteCommand() to push last response, clear command, and kick the KBC...
     
    735736static DECLCALLBACK(void) ps2mR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    736737{
    737     static const char   *pcszModes[] = { "normal", "reset", "wrap" };
    738     static const char   *pcszProtocols[] = { "PS/2", NULL, NULL, "ImPS/2", "ImEx", "ImEx+horizontal" };
    739     PPS2M   pThis = KBDGetPS2MFromDevIns(pDevIns);
     738    static const char * const s_apcszModes[] = { "normal", "reset", "wrap" };
     739    static const char * const s_apcszProtocols[] = { "PS/2", NULL, NULL, "ImPS/2", "ImEx", "ImEx+horizontal" };
     740    PKBDSTATE   pParent = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);
     741    PPS2M       pThis   = &pParent->Aux;
    740742    NOREF(pszArgs);
    741743
    742     Assert(pThis->enmMode <= RT_ELEMENTS(pcszModes));
    743     Assert(pThis->enmProtocol <= RT_ELEMENTS(pcszProtocols));
     744    Assert(pThis->enmMode < RT_ELEMENTS(s_apcszModes));
    744745    pHlp->pfnPrintf(pHlp, "PS/2 mouse state: %s, %s mode, reporting %s\n",
    745                     pcszModes[pThis->enmMode],
     746                    s_apcszModes[pThis->enmMode],
    746747                    pThis->u8State & AUX_STATE_REMOTE  ? "remote"  : "stream",
    747748                    pThis->u8State & AUX_STATE_ENABLED ? "enabled" : "disabled");
     749    Assert(pThis->enmProtocol < RT_ELEMENTS(s_apcszProtocols));
    748750    pHlp->pfnPrintf(pHlp, "Protocol: %s, scaling %u:1\n",
    749                     pcszProtocols[pThis->enmProtocol],
     751                    s_apcszProtocols[pThis->enmProtocol],
    750752                    pThis->u8State & AUX_STATE_SCALING ? 2 : 1);
    751753    pHlp->pfnPrintf(pHlp, "Active command %02X\n", pThis->u8CurrCmd);
     
    759761
    760762
    761 /* -=-=-=-=-=- Mouse: IBase  -=-=-=-=-=- */
    762 
    763 /**
    764  * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    765  */
    766 static DECLCALLBACK(void *) ps2mR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
    767 {
    768     PPS2M pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IBase);
    769     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->Mouse.IBase);
    770     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSEPORT, &pThis->Mouse.IPort);
    771     return NULL;
    772 }
    773 
    774 
    775763/* -=-=-=-=-=- Mouse: IMousePort  -=-=-=-=-=- */
    776764
     
    834822                                                  int32_t dz, int32_t dw, uint32_t fButtons)
    835823{
    836     PPS2M       pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IPort);
    837     PPDMDEVINS  pDevIns = pThis->pDevIns;
     824    PPS2MR3     pThisCC = RT_FROM_MEMBER(pInterface, PS2MR3, Mouse.IPort);
     825    PPDMDEVINS  pDevIns = pThisCC->pDevIns;
     826    PPS2M       pThis   = &PDMDEVINS_2_DATA(pDevIns, PKBDSTATE)->Aux;
    838827    int rc = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_SEM_BUSY);
    839828    AssertReleaseRC(rc);
     
    865854    AssertFailedReturn(VERR_NOT_SUPPORTED);
    866855    NOREF(pInterface); NOREF(cContacts); NOREF(pau64Contacts); NOREF(u32ScanTime);
     856}
     857
     858
     859/* -=-=-=-=-=- Mouse: IBase  -=-=-=-=-=- */
     860
     861/**
     862 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     863 */
     864static DECLCALLBACK(void *) ps2mR3QueryInterface(PPDMIBASE pInterface, const char *pszIID)
     865{
     866    PPS2MR3 pThisCC = RT_FROM_MEMBER(pInterface, PS2MR3, Mouse.IBase);
     867    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->Mouse.IBase);
     868    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSEPORT, &pThisCC->Mouse.IPort);
     869    return NULL;
    867870}
    868871
     
    885888 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    886889 */
    887 int PS2MR3Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     890int PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags)
    888891{
    889892    int         rc;
     
    897900    LogFlowFunc(("iLUN=%d\n", iLUN));
    898901
    899     rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->Mouse.IBase, &pThis->Mouse.pDrvBase, "Mouse Port");
     902    rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThisCC->Mouse.IBase, &pThisCC->Mouse.pDrvBase, "Mouse Port");
    900903    if (RT_SUCCESS(rc))
    901904    {
    902         pThis->Mouse.pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Mouse.pDrvBase, PDMIMOUSECONNECTOR);
    903         if (!pThis->Mouse.pDrv)
     905        pThisCC->Mouse.pDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->Mouse.pDrvBase, PDMIMOUSECONNECTOR);
     906        if (!pThisCC->Mouse.pDrv)
    904907        {
    905908            AssertLogRelMsgFailed(("LUN #1 doesn't have a mouse interface! rc=%Rrc\n", rc));
     
    942945}
    943946
    944 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion)
     947int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, PSSMHANDLE pSSM, uint32_t uVersion)
    945948{
    946949    PCPDMDEVHLPR3   pHlp = pDevIns->pHlpR3;
     
    976979    ps2mSetRate(pThis, pThis->u8SampleRate);
    977980
    978     ps2mR3SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));
     981    ps2mR3SetDriverState(pThisCC, !!(pThis->u8State & AUX_STATE_ENABLED));
    979982
    980983    return VINF_SUCCESS;
    981984}
    982985
    983 void PS2MR3FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto)
     986void PS2MR3FixupState(PPS2M pThis, PPS2MR3 pThisCC, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto)
    984987{
    985988    LogFlowFunc(("Fixing up old PS2M state version\n"));
     
    993996    ps2mSetRate(pThis, pThis->u8SampleRate);
    994997
    995     ps2mR3SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));
     998    ps2mR3SetDriverState(pThisCC, !!(pThis->u8State & AUX_STATE_ENABLED));
    996999}
    9971000
     
    10071010}
    10081011
    1009 int PS2MR3Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)
     1012int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, unsigned iInstance)
    10101013{
    10111014    RT_NOREF(iInstance);
     
    10171020#endif
    10181021
    1019     pThis->pParent = pParent;
    1020     pThis->pDevIns = pDevIns;
     1022    pThisCC->pDevIns = pDevIns;
    10211023
    10221024    /* Initialize the queues. */
     
    10241026    pThis->cmdQ.cSize = AUX_CMD_QUEUE_SIZE;
    10251027
    1026     pThis->Mouse.IBase.pfnQueryInterface     = ps2mR3QueryInterface;
    1027     pThis->Mouse.IPort.pfnPutEvent           = ps2mR3MousePort_PutEvent;
    1028     pThis->Mouse.IPort.pfnPutEventAbs        = ps2mR3MousePort_PutEventAbs;
    1029     pThis->Mouse.IPort.pfnPutEventMultiTouch = ps2mR3MousePort_PutEventMT;
     1028    pThisCC->Mouse.IBase.pfnQueryInterface     = ps2mR3QueryInterface;
     1029    pThisCC->Mouse.IPort.pfnPutEvent           = ps2mR3MousePort_PutEvent;
     1030    pThisCC->Mouse.IPort.pfnPutEventAbs        = ps2mR3MousePort_PutEventAbs;
     1031    pThisCC->Mouse.IPort.pfnPutEventMultiTouch = ps2mR3MousePort_PutEventMT;
    10301032
    10311033    /*
     
    10491051
    10501052    /// @todo Where should we do this?
    1051     ps2mR3SetDriverState(pThis, true);
     1053    ps2mR3SetDriverState(pThisCC, true);
    10521054    pThis->u8State = 0;
    10531055    pThis->enmMode = AUX_MODE_STD;
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