Changeset 82206 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 25, 2019 10:46:54 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135020
- Location:
- trunk/src/VBox/Devices/Input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r82204 r82206 442 442 } 443 443 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 456 444 static VBOXSTRICTRC kbd_write_data(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t val) 457 445 { … … 515 503 #ifdef IN_RING3 516 504 517 static int kbd_load(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PKBDSTATE s, uint32_t version_id)505 static int kbd_load(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PKBDSTATE s, PKBDSTATER3 pThisCC, uint32_t version_id) 518 506 { 519 507 uint32_t u32, i; 520 uint8_t u8Dummy;521 uint32_t u32Dummy;508 uint8_t u8Dummy; 509 uint32_t u32Dummy; 522 510 int rc; 523 511 … … 576 564 AssertLogRelRCReturn(rc, rc); 577 565 578 PS2MR3FixupState(&s->Aux, u8State, u8Rate, u8Proto);566 PS2MR3FixupState(&s->Aux, &pThisCC->Aux, u8State, u8Rate, u8Proto); 579 567 } 580 568 … … 878 866 static DECLCALLBACK(int) kbdR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 879 867 { 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); 881 870 int rc; 882 871 883 872 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); 885 874 AssertRCReturn(rc, rc); 886 875 … … 890 879 891 880 if (uVersion >= 8) 892 rc = PS2MR3LoadState(pDevIns, &pThis->Aux, pSSM, uVersion);881 rc = PS2MR3LoadState(pDevIns, &pThis->Aux, &pThisCC->Aux, pSSM, uVersion); 893 882 AssertRCReturn(rc, rc); 894 883 return rc; … … 900 889 static DECLCALLBACK(int) kbdR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 901 890 { 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); 903 893 RT_NOREF(pSSM); 904 return PS2KR3LoadDone(pDevIns, &pThis->Kbd );894 return PS2KR3LoadDone(pDevIns, &pThis->Kbd, &pThisCC->Kbd); 905 895 } 906 896 … … 913 903 static DECLCALLBACK(void) kbdR3Reset(PPDMDEVINS pDevIns) 914 904 { 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); 916 907 917 908 pThis->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT; … … 921 912 pThis->translate = 0; 922 913 923 PS2KR3Reset(pDevIns, &pThis->Kbd );914 PS2KR3Reset(pDevIns, &pThis->Kbd, &pThisCC->Kbd); 924 915 PS2MR3Reset(&pThis->Aux); 925 916 } … … 937 928 static DECLCALLBACK(int) kbdR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 938 929 { 930 PKBDSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3); 939 931 int rc; 940 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);941 932 942 933 AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG, … … 948 939 /* LUN #0: keyboard */ 949 940 case 0: 950 rc = PS2KR3Attach( &pThis->Kbd, pDevIns, iLUN, fFlags);941 rc = PS2KR3Attach(pDevIns, &pThisCC->Kbd, iLUN, fFlags); 951 942 break; 952 943 953 944 /* LUN #1: aux/mouse */ 954 945 case 1: 955 rc = PS2MR3Attach( &pThis->Aux, pDevIns, iLUN, fFlags);946 rc = PS2MR3Attach(pDevIns, &pThisCC->Aux, iLUN, fFlags); 956 947 break; 957 948 … … 981 972 /* LUN #0: keyboard */ 982 973 case 0: 983 pThis ->Keyboard.pDrv = NULL;984 pThis ->Keyboard.pDrvBase = NULL;974 pThisCC->Keyboard.pDrv = NULL; 975 pThisCC->Keyboard.pDrvBase = NULL; 985 976 break; 986 977 987 978 /* LUN #1: aux/mouse */ 988 979 case 1: 989 pThis ->Mouse.pDrv = NULL;990 pThis ->Mouse.pDrvBase = NULL;980 pThisCC->Mouse.pDrv = NULL; 981 pThisCC->Mouse.pDrvBase = NULL; 991 982 break; 992 983 … … 1007 998 { 1008 999 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); 1010 1002 int rc; 1011 1003 Assert(iInstance == 0); … … 1020 1012 * Initialize the sub-components. 1021 1013 */ 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); 1026 1018 AssertRCReturn(rc, rc); 1027 1019 … … 1089 1081 /* .uReserved0 = */ 0, 1090 1082 /* .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, 1092 1084 /* .fClass = */ PDM_DEVREG_CLASS_INPUT, 1093 1085 /* .cMaxInstances = */ 1, 1094 1086 /* .uSharedVersion = */ 42, 1095 1087 /* .cbInstanceShared = */ sizeof(KBDSTATE), 1096 /* .cbInstanceCC = */ 0,1088 /* .cbInstanceCC = */ CTX_EXPR(sizeof(KBDSTATER3), 0, 0), 1097 1089 /* .cbInstanceRC = */ 0, 1098 1090 /* .cMaxPciDevices = */ 0, -
trunk/src/VBox/Devices/Input/DevPS2.h
r82204 r82206 92 92 typedef struct PS2K 93 93 { 94 /** Pointer to parent device (keyboard controller). */95 R3PTRTYPE(PKBDSTATE) pParent;96 94 /** Set if keyboard is enabled ('scans' for input). */ 97 95 bool fScanning; … … 129 127 uint8_t abAlignment2[2]; 130 128 131 /** Command delay timer - R3 Ptr. */129 /** Command delay timer. */ 132 130 TMTIMERHANDLE hKbdDelayTimer; 133 /** Typematic timer - R3 Ptr. */131 /** Typematic timer. */ 134 132 TMTIMERHANDLE hKbdTypematicTimer; 135 133 /** Input throttle timer. */ 136 134 TMTIMERHANDLE hThrottleTimer; 137 135 } PS2K; 136 /** Pointer to the shared PS/2 keyboard instance data. */ 137 typedef PS2K *PPS2K; 138 139 140 /** 141 * The PS/2 keyboard instance data for ring-3. 142 */ 143 typedef struct PS2KR3 144 { 138 145 /** The device instance. 139 146 * @note Only for getting our bearings in interface methods. */ … … 158 165 R3PTRTYPE(PPDMIKEYBOARDCONNECTOR) pDrv; 159 166 } 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. */ 169 typedef PS2KR3 *PPS2KR3; 163 170 164 171 … … 166 173 int PS2KByteFromKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t *pVal); 167 174 168 int PS2KR3Construct(PP S2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg);169 int PS2KR3Attach(PP S2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);170 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis );175 int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, unsigned iInstance, PCFGMNODE pCfg); 176 int PS2KR3Attach(PPDMDEVINS pDevIns, PPS2KR3 pThisCC, unsigned iLUN, uint32_t fFlags); 177 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC); 171 178 void PS2KR3SaveState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM); 172 179 int PS2KR3LoadState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion); 173 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis); 174 175 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns); 176 180 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC); 177 181 /** @} */ 178 182 … … 228 232 229 233 /** 230 * The PS/2 auxiliary device instance data.234 * The shared PS/2 auxiliary device instance data. 231 235 */ 232 236 typedef struct PS2M 233 237 { 234 /** Pointer to parent device (keyboard controller). */235 R3PTRTYPE(PKBDSTATE) pParent;236 238 /** Operational state. */ 237 239 uint8_t u8State; … … 273 275 uint32_t uThrottleDelay; 274 276 275 /** The device instance.276 * @note Only for getting our bearings in interface methods. */277 PPDMDEVINSR3 pDevIns;278 279 277 /** Command delay timer. */ 280 278 TMTIMERHANDLE hDelayTimer; 281 279 /** Interrupt throttling timer. */ 282 280 TMTIMERHANDLE hThrottleTimer; 281 } PS2M; 282 /** Pointer to the shared PS/2 auxiliary device instance data. */ 283 typedef PS2M *PPS2M; 284 285 /** 286 * The PS/2 auxiliary device instance data for ring-3. 287 */ 288 typedef struct PS2MR3 289 { 290 /** The device instance. 291 * @note Only for getting our bearings in interface methods. */ 292 PPDMDEVINSR3 pDevIns; 283 293 284 294 /** … … 300 310 R3PTRTYPE(PPDMIMOUSECONNECTOR) pDrv; 301 311 } 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. */ 314 typedef PS2MR3 *PPS2MR3; 305 315 306 316 int PS2MByteToAux(PPDMDEVINS pDevIns, PPS2M pThis, uint8_t cmd); 307 317 int PS2MByteFromAux(PPS2M pThis, uint8_t *pVal); 308 318 309 int PS2MR3Construct(PP S2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance);310 int PS2MR3Attach(PP S2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);319 int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, unsigned iInstance); 320 int PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags); 311 321 void PS2MR3Reset(PPS2M pThis); 312 322 void 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 323 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, PSSMHANDLE pSSM, uint32_t uVersion); 324 void PS2MR3FixupState(PPS2M pThis, PPS2MR3 pThisCC, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto); 318 325 /** @} */ 319 326 … … 335 342 336 343 /** I/O port 60h. */ 337 IOMIOPORTHANDLE 344 IOMIOPORTHANDLE hIoPortData; 338 345 /** 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; 346 352 } KBDSTATE; 353 354 355 /** 356 * The ring-3 keyboard controller/device state. 357 */ 358 typedef 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. */ 366 typedef KBDSTATER3 *PKBDSTATER3; 347 367 348 368 -
trunk/src/VBox/Devices/Input/DevPS2K.cpp
r82200 r82206 415 415 * Notify listener about LEDs state change. 416 416 * 417 * @param pThis The PS/2 keyboard instance data.417 * @param pThisCC The PS/2 keyboard instance data for ring-3. 418 418 * @param u8State Bitfield which reflects LEDs state. 419 419 */ 420 static void ps2kR3NotifyLedsState(PPS2K pThis, uint8_t u8State) 421 { 422 420 static void ps2kR3NotifyLedsState(PPS2KR3 pThisCC, uint8_t u8State) 421 { 423 422 PDMKEYBLEDS enmLeds = PDMKEYBLEDS_NONE; 424 423 … … 430 429 enmLeds = (PDMKEYBLEDS)(enmLeds | PDMKEYBLEDS_CAPSLOCK); 431 430 432 pThis->Keyboard.pDrv->pfnLedStatusChange(pThis->Keyboard.pDrv, enmLeds); 433 431 pThisCC->Keyboard.pDrv->pfnLedStatusChange(pThisCC->Keyboard.pDrv, enmLeds); 434 432 } 435 433 … … 495 493 * 496 494 * @param pDevIns The device instance. 497 * @param pThis The PS/2 keyboard instance data.495 * @param pThis The shared PS/2 keyboard instance data. 498 496 * @param cmd The command (or data) byte. 499 497 */ … … 577 575 #else 578 576 { 579 ps2kR3NotifyLedsState(pThis, cmd); 577 PPS2KR3 pThisCC = &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Kbd; 578 ps2kR3NotifyLedsState(pThisCC, cmd); 580 579 pThis->fNumLockOn = !!(cmd & 0x02); /* Sync internal Num Lock state. */ 581 580 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); … … 626 625 * @returns VINF_SUCCESS or VINF_TRY_AGAIN. 627 626 * @param pDevIns The device instance. 628 * @param pThis The PS/2 keyboard instance data.627 * @param pThis The shared PS/2 keyboard instance data. 629 628 * @param pb Where to return the byte we've read. 630 629 * @remarks Caller must have entered the device critical section. … … 1035 1034 static DECLCALLBACK(void) ps2kR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1036 1035 { 1037 PPS2K pThis = KBDGetPS2KFromDevIns(pDevIns); 1036 PKBDSTATE pParent = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 1037 PPS2K pThis = &pParent->Kbd; 1038 1038 NOREF(pszArgs); 1039 1039 … … 1054 1054 } 1055 1055 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 1069 1056 1070 1057 /* -=-=-=-=-=- Keyboard: IKeyboardPort -=-=-=-=-=- */ … … 1129 1116 static DECLCALLBACK(int) ps2kR3KeyboardPort_PutEventHid(PPDMIKEYBOARDPORT pInterface, uint32_t u32UsageCode) 1130 1117 { 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; 1133 1121 int rc; 1134 1122 … … 1152 1140 1153 1141 1142 /* -=-=-=-=-=- Keyboard: IBase -=-=-=-=-=- */ 1143 1144 /** 1145 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 1146 */ 1147 static 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 1154 1156 /* -=-=-=-=-=- Device management -=-=-=-=-=- */ 1155 1157 … … 1164 1166 * 1165 1167 * @returns VBox status code. 1166 * @param pThis The PS/2 keyboard instance data.1167 1168 * @param pDevIns The device instance. 1169 * @param pThisCC The PS/2 keyboard instance data for ring-3. 1168 1170 * @param iLUN The logical unit which is being detached. 1169 1171 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 1170 1172 */ 1171 int PS2KR3Attach(PP S2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)1173 int PS2KR3Attach(PPDMDEVINS pDevIns, PPS2KR3 pThisCC, unsigned iLUN, uint32_t fFlags) 1172 1174 { 1173 1175 int rc; … … 1181 1183 LogFlowFunc(("iLUN=%d\n", iLUN)); 1182 1184 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"); 1184 1186 if (RT_SUCCESS(rc)) 1185 1187 { 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) 1188 1190 { 1189 1191 AssertLogRelMsgFailed(("LUN #0 doesn't have a keyboard interface! rc=%Rrc\n", rc)); … … 1314 1316 } 1315 1317 1316 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis )1318 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC) 1317 1319 { 1318 1320 /* This *must* be done after the inital load because it may trigger … … 1320 1322 */ 1321 1323 ps2kR3ReleaseKeys(pDevIns, pThis); 1322 ps2kR3NotifyLedsState(pThis , pThis->u8LEDs);1324 ps2kR3NotifyLedsState(pThisCC, pThis->u8LEDs); 1323 1325 return VINF_SUCCESS; 1324 1326 } 1325 1327 1326 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis )1328 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC) 1327 1329 { 1328 1330 LogFlowFunc(("Resetting PS2K\n")); … … 1342 1344 1343 1345 /* 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(PP S2K 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 1350 int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, unsigned iInstance, PCFGMNODE pCfg) 1349 1351 { 1350 1352 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; … … 1352 1354 LogFlowFunc(("iInstance=%u\n", iInstance)); 1353 1355 1354 pThis->pParent = pParent; 1355 pThis->pDevIns = pDevIns; 1356 pThisCC->pDevIns = pDevIns; 1356 1357 1357 1358 bool fThrottleEnabled; … … 1366 1367 pThis->cmdQ.cSize = KBD_CMD_QUEUE_SIZE; 1367 1368 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; 1370 1371 1371 1372 /* -
trunk/src/VBox/Devices/Input/DevPS2M.cpp
r82200 r82206 209 209 210 210 /* 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;211 static void ps2mR3SetDriverState(PPS2MR3 pThisCC, bool fEnabled) 212 { 213 PPDMIMOUSECONNECTOR pDrv = pThisCC->Mouse.pDrv; 214 214 if (pDrv) 215 215 pDrv->pfnReportModes(pDrv, fEnabled, false, false); … … 217 217 218 218 /* Reset the pointing device. */ 219 static void ps2mR3Reset(PPS2M pThis )219 static void ps2mR3Reset(PPS2M pThis, PPS2MR3 pThisCC) 220 220 { 221 221 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK); … … 225 225 226 226 /// @todo move to its proper home! 227 ps2mR3SetDriverState(pThis , true);227 ps2mR3SetDriverState(pThisCC, true); 228 228 } 229 229 … … 509 509 pThis->u8State |= AUX_STATE_ENABLED; 510 510 #ifdef IN_RING3 511 ps2mR3SetDriverState( pThis, true);511 ps2mR3SetDriverState(&PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux, true); 512 512 #else 513 513 AssertLogRelMsgFailed(("Invalid ACMD_ENABLE outside R3!\n")); … … 541 541 else 542 542 #ifdef IN_RING3 543 ps2mR3Reset(pThis );543 ps2mR3Reset(pThis, &PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3)->Aux); 544 544 #else 545 545 AssertLogRelMsgFailed(("Invalid ACMD_RESET outside R3!\n")); … … 712 712 static DECLCALLBACK(void) ps2mR3DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 713 713 { 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); 716 717 717 718 LogFlowFunc(("Delay timer: cmd %02X\n", pThis->u8CurrCmd)); 718 719 719 720 Assert(pThis->u8CurrCmd == ACMD_RESET); 720 ps2mR3Reset(pThis );721 ps2mR3Reset(pThis, pThisCC); 721 722 722 723 /// @todo Might want a PS2MCompleteCommand() to push last response, clear command, and kick the KBC... … … 735 736 static DECLCALLBACK(void) ps2mR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 736 737 { 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; 740 742 NOREF(pszArgs); 741 743 742 Assert(pThis->enmMode <= RT_ELEMENTS(pcszModes)); 743 Assert(pThis->enmProtocol <= RT_ELEMENTS(pcszProtocols)); 744 Assert(pThis->enmMode < RT_ELEMENTS(s_apcszModes)); 744 745 pHlp->pfnPrintf(pHlp, "PS/2 mouse state: %s, %s mode, reporting %s\n", 745 pcszModes[pThis->enmMode],746 s_apcszModes[pThis->enmMode], 746 747 pThis->u8State & AUX_STATE_REMOTE ? "remote" : "stream", 747 748 pThis->u8State & AUX_STATE_ENABLED ? "enabled" : "disabled"); 749 Assert(pThis->enmProtocol < RT_ELEMENTS(s_apcszProtocols)); 748 750 pHlp->pfnPrintf(pHlp, "Protocol: %s, scaling %u:1\n", 749 pcszProtocols[pThis->enmProtocol],751 s_apcszProtocols[pThis->enmProtocol], 750 752 pThis->u8State & AUX_STATE_SCALING ? 2 : 1); 751 753 pHlp->pfnPrintf(pHlp, "Active command %02X\n", pThis->u8CurrCmd); … … 759 761 760 762 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 775 763 /* -=-=-=-=-=- Mouse: IMousePort -=-=-=-=-=- */ 776 764 … … 834 822 int32_t dz, int32_t dw, uint32_t fButtons) 835 823 { 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; 838 827 int rc = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_SEM_BUSY); 839 828 AssertReleaseRC(rc); … … 865 854 AssertFailedReturn(VERR_NOT_SUPPORTED); 866 855 NOREF(pInterface); NOREF(cContacts); NOREF(pau64Contacts); NOREF(u32ScanTime); 856 } 857 858 859 /* -=-=-=-=-=- Mouse: IBase -=-=-=-=-=- */ 860 861 /** 862 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 863 */ 864 static 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; 867 870 } 868 871 … … 885 888 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 886 889 */ 887 int PS2MR3Attach(PP S2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)890 int PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags) 888 891 { 889 892 int rc; … … 897 900 LogFlowFunc(("iLUN=%d\n", iLUN)); 898 901 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"); 900 903 if (RT_SUCCESS(rc)) 901 904 { 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) 904 907 { 905 908 AssertLogRelMsgFailed(("LUN #1 doesn't have a mouse interface! rc=%Rrc\n", rc)); … … 942 945 } 943 946 944 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, P SSMHANDLE pSSM, uint32_t uVersion)947 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, PSSMHANDLE pSSM, uint32_t uVersion) 945 948 { 946 949 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; … … 976 979 ps2mSetRate(pThis, pThis->u8SampleRate); 977 980 978 ps2mR3SetDriverState(pThis , !!(pThis->u8State & AUX_STATE_ENABLED));981 ps2mR3SetDriverState(pThisCC, !!(pThis->u8State & AUX_STATE_ENABLED)); 979 982 980 983 return VINF_SUCCESS; 981 984 } 982 985 983 void PS2MR3FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto)986 void PS2MR3FixupState(PPS2M pThis, PPS2MR3 pThisCC, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto) 984 987 { 985 988 LogFlowFunc(("Fixing up old PS2M state version\n")); … … 993 996 ps2mSetRate(pThis, pThis->u8SampleRate); 994 997 995 ps2mR3SetDriverState(pThis , !!(pThis->u8State & AUX_STATE_ENABLED));998 ps2mR3SetDriverState(pThisCC, !!(pThis->u8State & AUX_STATE_ENABLED)); 996 999 } 997 1000 … … 1007 1010 } 1008 1011 1009 int PS2MR3Construct(PP S2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)1012 int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, unsigned iInstance) 1010 1013 { 1011 1014 RT_NOREF(iInstance); … … 1017 1020 #endif 1018 1021 1019 pThis->pParent = pParent; 1020 pThis->pDevIns = pDevIns; 1022 pThisCC->pDevIns = pDevIns; 1021 1023 1022 1024 /* Initialize the queues. */ … … 1024 1026 pThis->cmdQ.cSize = AUX_CMD_QUEUE_SIZE; 1025 1027 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; 1030 1032 1031 1033 /* … … 1049 1051 1050 1052 /// @todo Where should we do this? 1051 ps2mR3SetDriverState(pThis , true);1053 ps2mR3SetDriverState(pThisCC, true); 1052 1054 pThis->u8State = 0; 1053 1055 pThis->enmMode = AUX_MODE_STD;
Note:
See TracChangeset
for help on using the changeset viewer.