Changeset 82189 in vbox for trunk/src/VBox/Devices/Input/DevPS2M.cpp
- Timestamp:
- Nov 25, 2019 5:37:49 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2M.cpp
r82173 r82189 205 205 *********************************************************************************************************************************/ 206 206 #if defined(RT_STRICT) && defined(IN_RING3) 207 static void ps2m TestAccumulation(void);207 static void ps2mR3TestAccumulation(void); 208 208 #endif 209 209 210 210 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 246 211 #ifdef IN_RING3 247 212 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/write260 * 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 302 213 /* Report a change in status down (or is it up?) the driver chain. */ 303 static void ps2m SetDriverState(PPS2M pThis, bool fEnabled)214 static void ps2mR3SetDriverState(PPS2M pThis, bool fEnabled) 304 215 { 305 216 PPDMIMOUSECONNECTOR pDrv = pThis->Mouse.pDrv; … … 309 220 310 221 /* Reset the pointing device. */ 311 static void ps2mR eset(PPS2M pThis)312 { 313 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK);314 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, 0);222 static void ps2mR3Reset(PPS2M pThis) 223 { 224 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK); 225 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, 0); 315 226 pThis->enmMode = AUX_MODE_STD; 316 227 pThis->u8CurrCmd = 0; 317 228 318 229 /// @todo move to its proper home! 319 ps2m SetDriverState(pThis, true);230 ps2mR3SetDriverState(pThis, true); 320 231 } 321 232 … … 369 280 370 281 /* Event queue, eccumulators, and button status bits are cleared. */ 371 ps2kClearQueue((GeneriQ *)&pThis->evtQ);282 PS2CmnClearQueue((GeneriQ *)&pThis->evtQ); 372 283 pThis->iAccumX = pThis->iAccumY = pThis->iAccumZ = pThis->iAccumW = pThis->fAccumB = 0; 373 284 } … … 445 356 446 357 /* 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); 450 361 451 362 /* Add fourth byte if an extended protocol is in use. */ … … 458 369 { 459 370 /* NB: Only uses 4-bit dZ range, despite using a full byte. */ 460 ps2kInsertQueue(pQueue, dZ);371 PS2CmnInsertQueue(pQueue, dZ); 461 372 pThis->iAccumZ -= dZ; 462 373 } … … 467 378 val |= dZ & 0x0f; 468 379 pThis->iAccumZ -= dZ; 469 ps2kInsertQueue(pQueue, val);380 PS2CmnInsertQueue(pQueue, val); 470 381 } 471 382 else … … 499 410 val = (fBtnState & PS2M_IMEX_BTN_MASK) << 1; 500 411 } 501 ps2kInsertQueue(pQueue, val);412 PS2CmnInsertQueue(pQueue, val); 502 413 } 503 414 } … … 549 460 550 461 /* If there's anything left in the command response queue, trash it. */ 551 ps2kClearQueue((GeneriQ *)&pThis->cmdQ);462 PS2CmnClearQueue((GeneriQ *)&pThis->cmdQ); 552 463 553 464 if (pThis->enmMode == AUX_MODE_WRAP) … … 558 469 else 559 470 { 560 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, cmd);471 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, cmd); 561 472 return VINF_SUCCESS; 562 473 } … … 573 484 case ACMD_SET_SCALE_11: 574 485 pThis->u8State &= ~AUX_STATE_SCALING; 575 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);486 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 576 487 pThis->u8CurrCmd = 0; 577 488 break; 578 489 case ACMD_SET_SCALE_21: 579 490 pThis->u8State |= AUX_STATE_SCALING; 580 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);491 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 581 492 pThis->u8CurrCmd = 0; 582 493 break; … … 584 495 /* Report current status, sample rate, and resolution. */ 585 496 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); 590 501 pThis->u8CurrCmd = 0; 591 502 break; 592 503 case ACMD_SET_STREAM: 593 504 pThis->u8State &= ~AUX_STATE_REMOTE; 594 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);505 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 595 506 pThis->u8CurrCmd = 0; 596 507 break; 597 508 case ACMD_READ_REMOTE: 598 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);509 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 599 510 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->cmdQ, false); 600 511 pThis->u8CurrCmd = 0; … … 603 514 pThis->enmMode = AUX_MODE_STD; 604 515 /* NB: Stream mode reporting remains disabled! */ 605 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);516 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 606 517 pThis->u8CurrCmd = 0; 607 518 break; … … 609 520 pThis->enmMode = AUX_MODE_WRAP; 610 521 pThis->u8State &= ~AUX_STATE_ENABLED; 611 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);522 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 612 523 pThis->u8CurrCmd = 0; 613 524 break; 614 525 case ACMD_SET_REMOTE: 615 526 pThis->u8State |= AUX_STATE_REMOTE; 616 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);527 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 617 528 pThis->u8CurrCmd = 0; 618 529 break; 619 530 case ACMD_READ_ID: 620 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);531 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 621 532 /* ImEx + horizontal is protocol 4, just like plain ImEx. */ 622 533 u8Val = pThis->enmProtocol == PS2M_PROTO_IMEX_HORZ ? PS2M_PROTO_IMEX : pThis->enmProtocol; 623 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);534 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val); 624 535 pThis->u8CurrCmd = 0; 625 536 break; … … 627 538 pThis->u8State |= AUX_STATE_ENABLED; 628 539 #ifdef IN_RING3 629 ps2m SetDriverState(pThis, true);540 ps2mR3SetDriverState(pThis, true); 630 541 #else 631 542 AssertLogRelMsgFailed(("Invalid ACMD_ENABLE outside R3!\n")); 632 543 #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); 635 546 pThis->u8CurrCmd = 0; 636 547 break; 637 548 case ACMD_DISABLE: 638 549 pThis->u8State &= ~AUX_STATE_ENABLED; 639 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);550 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 640 551 pThis->u8CurrCmd = 0; 641 552 break; 642 553 case ACMD_SET_DEFAULT: 643 554 ps2mSetDefaults(pThis); 644 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);555 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 645 556 pThis->u8CurrCmd = 0; 646 557 break; … … 653 564 pThis->u8CurrCmd = cmd; 654 565 pThis->enmMode = AUX_MODE_RESET; 655 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);566 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 656 567 if (pThis->fDelayReset) 657 568 /* Slightly delay reset completion; it might take hundreds of ms. */ … … 659 570 else 660 571 #ifdef IN_RING3 661 ps2mR eset(pThis);572 ps2mR3Reset(pThis); 662 573 #else 663 574 AssertLogRelMsgFailed(("Invalid ACMD_RESET outside R3!\n")); … … 667 578 case ACMD_SET_RES: 668 579 case ACMD_SET_SAMP_RATE: 669 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);580 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 670 581 pThis->u8CurrCmd = cmd; 671 582 break; … … 679 590 pThis->u8Resolution = cmd; 680 591 pThis->u8State &= ~AUX_STATE_RES_ERR; 681 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);592 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 682 593 pThis->u8CurrCmd = 0; 683 594 } … … 688 599 { 689 600 pThis->u8State &= ~AUX_STATE_RES_ERR; 690 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);601 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR); 691 602 pThis->u8CurrCmd = 0; 692 603 } … … 694 605 { 695 606 pThis->u8State |= AUX_STATE_RES_ERR; 696 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);607 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND); 697 608 /* NB: Current command remains unchanged. */ 698 609 } … … 705 616 ps2mSetRate(pThis, cmd); 706 617 ps2mRateProtocolKnock(pThis, cmd); 707 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);618 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK); 708 619 pThis->u8CurrCmd = 0; 709 620 } … … 714 625 { 715 626 pThis->u8State &= ~AUX_STATE_RATE_ERR; 716 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);627 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR); 717 628 pThis->u8CurrCmd = 0; 718 629 } … … 720 631 { 721 632 pThis->u8State |= AUX_STATE_RATE_ERR; 722 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);633 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND); 723 634 /* NB: Current command remains unchanged. */ 724 635 } … … 744 655 case ACMD_INVALID_10: 745 656 Log(("Unsupported command 0x%02X!\n", cmd)); 746 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);657 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND); 747 658 pThis->u8CurrCmd = 0; 748 659 break; … … 790 701 } 791 702 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 */ 707 static DECLCALLBACK(void) ps2mR3ThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 795 708 { 796 709 RT_NOREF(pDevIns, pTimer); … … 819 732 } 820 733 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 */ 741 static DECLCALLBACK(void) ps2mR3DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 825 742 { 826 743 RT_NOREF(pDevIns, pTimer); … … 830 747 831 748 Assert(pThis->u8CurrCmd == ACMD_RESET); 832 ps2mR eset(pThis);749 ps2mR3Reset(pThis); 833 750 834 751 /// @todo Might want a PS2MCompleteCommand() to push last response, clear command, and kick the KBC... … … 845 762 * @param pszArgs Argument string. Optional and specific to the handler. 846 763 */ 847 static DECLCALLBACK(void) ps2m InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)764 static DECLCALLBACK(void) ps2mR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 848 765 { 849 766 static const char *pcszModes[] = { "normal", "reset", "wrap" }; … … 875 792 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 876 793 */ 877 static DECLCALLBACK(void *) ps2m QueryInterface(PPDMIBASE pInterface, const char *pszIID)794 static DECLCALLBACK(void *) ps2mR3QueryInterface(PPDMIBASE pInterface, const char *pszIID) 878 795 { 879 796 PPS2M pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IBase); … … 897 814 * @param fButtons Depressed button mask. 898 815 */ 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 816 static int ps2mR3PutEventWorker(PPS2M pThis, int32_t dx, int32_t dy, int32_t dz, int32_t dw, uint32_t fButtons) 817 { 904 818 /* Update internal accumulators and button state. Ignore any buttons beyond 5. */ 905 819 pThis->iAccumX += dx; … … 915 829 */ 916 830 if (pThis->enmProtocol < PS2M_PROTO_IMEX_HORZ) 917 pThis->iAccumW = 0; /* No horizontal scroll. */831 pThis->iAccumW = 0; /* No horizontal scroll. */ 918 832 919 833 if (pThis->enmProtocol < PS2M_PROTO_IMEX) 920 834 { 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; 923 837 } 924 838 925 839 if (pThis->enmProtocol < PS2M_PROTO_IMPS2) 926 pThis->iAccumZ = 0; /* No vertical scroll. */840 pThis->iAccumZ = 0; /* No vertical scroll. */ 927 841 928 842 /* Report the event (if any) and start the throttle timer unless it's already running. */ … … 935 849 } 936 850 937 return rc;851 return VINF_SUCCESS; 938 852 } 939 853 … … 943 857 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent} 944 858 */ 945 static DECLCALLBACK(int) ps2m PutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, int32_t dy,946 int32_t dz, int32_t dw, uint32_t fButtons)859 static DECLCALLBACK(int) ps2mR3MousePort_PutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, int32_t dy, 860 int32_t dz, int32_t dw, uint32_t fButtons) 947 861 { 948 862 PPS2M pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IPort); … … 952 866 LogRelFlowFunc(("dX=%d dY=%d dZ=%d dW=%d buttons=%02X\n", dx, dy, dz, dw, fButtons)); 953 867 /* NB: The PS/2 Y axis direction is inverted relative to ours. */ 954 ps2m PutEventWorker(pThis, dx, -dy, dz, dw, fButtons);868 ps2mR3PutEventWorker(pThis, dx, -dy, dz, dw, fButtons); 955 869 956 870 PDMCritSectLeave(pThis->pCritSectR3); … … 961 875 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs} 962 876 */ 963 static DECLCALLBACK(int) ps2m PutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t x, uint32_t y,964 int32_t dz, int32_t dw, uint32_t fButtons)877 static DECLCALLBACK(int) ps2mR3MousePort_PutEventAbs(PPDMIMOUSEPORT pInterface, uint32_t x, uint32_t y, 878 int32_t dz, int32_t dw, uint32_t fButtons) 965 879 { 966 880 AssertFailedReturn(VERR_NOT_SUPPORTED); … … 971 885 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMultiTouch} 972 886 */ 973 static DECLCALLBACK(int) ps2m PutEventMT(PPDMIMOUSEPORT pInterface, uint8_t cContacts,974 const uint64_t *pau64Contacts, uint32_t u32ScanTime)887 static DECLCALLBACK(int) ps2mR3MousePort_PutEventMT(PPDMIMOUSEPORT pInterface, uint8_t cContacts, 888 const uint64_t *pau64Contacts, uint32_t u32ScanTime) 975 889 { 976 890 AssertFailedReturn(VERR_NOT_SUPPORTED); … … 995 909 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 996 910 */ 997 int PS2M Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)911 int PS2MR3Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 998 912 { 999 913 int rc; … … 1028 942 } 1029 943 1030 void PS2MSaveState(PPS2M pThis, PSSMHANDLE pSSM) 1031 { 944 void PS2MR3SaveState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM) 945 { 946 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1032 947 LogFlowFunc(("Saving PS2M state\n")); 1033 948 1034 949 /* 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); 1042 957 1043 958 /* 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); 1046 961 1047 962 /* Save the command delay timer. Note that the rate throttling … … 1051 966 } 1052 967 1053 int PS2MLoadState(PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion) 1054 { 1055 uint8_t u8; 1056 int rc; 968 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion) 969 { 970 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 971 uint8_t u8; 972 int rc; 1057 973 1058 974 NOREF(uVersion); … … 1060 976 1061 977 /* 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); 1067 983 pThis->enmMode = (PS2M_MODE)u8; 1068 SSMR3GetU8(pSSM, &u8);984 pHlp->pfnSSMGetU8(pSSM, &u8); 1069 985 pThis->enmProtocol = (PS2M_PROTO)u8; 1070 SSMR3GetU8(pSSM, &u8);986 pHlp->pfnSSMGetU8(pSSM, &u8); 1071 987 pThis->enmKnockState = (PS2M_KNOCK_STATE)u8; 1072 988 1073 989 /* Load the command and event queues. */ 1074 rc = ps2kLoadQueue(pSSM, (GeneriQ *)&pThis->cmdQ);990 rc = PS2CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ); 1075 991 AssertRCReturn(rc, rc); 1076 rc = ps2kLoadQueue(pSSM, (GeneriQ *)&pThis->evtQ);992 rc = PS2CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->evtQ); 1077 993 AssertRCReturn(rc, rc); 1078 994 … … 1084 1000 ps2mSetRate(pThis, pThis->u8SampleRate); 1085 1001 1086 ps2m SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));1087 1088 return rc;1089 } 1090 1091 void PS2M FixupState(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 1007 void PS2MR3FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto) 1092 1008 { 1093 1009 LogFlowFunc(("Fixing up old PS2M state version\n")); … … 1101 1017 ps2mSetRate(pThis, pThis->u8SampleRate); 1102 1018 1103 ps2m SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED));1104 } 1105 1106 void PS2MR eset(PPS2M pThis)1019 ps2mR3SetDriverState(pThis, !!(pThis->u8State & AUX_STATE_ENABLED)); 1020 } 1021 1022 void PS2MR3Reset(PPS2M pThis) 1107 1023 { 1108 1024 LogFlowFunc(("Resetting PS2M\n")); … … 1111 1027 1112 1028 /* Clear the queues. */ 1113 ps2kClearQueue((GeneriQ *)&pThis->cmdQ);1029 PS2CmnClearQueue((GeneriQ *)&pThis->cmdQ); 1114 1030 ps2mSetDefaults(pThis); /* Also clears event queue. */ 1115 1031 } 1116 1032 1117 void PS2MR elocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)1033 void PS2MR3Relocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns) 1118 1034 { 1119 1035 RT_NOREF(pDevIns, offDelta); … … 1123 1039 } 1124 1040 1125 int PS2M Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance)1041 int PS2MR3Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance) 1126 1042 { 1127 1043 RT_NOREF(iInstance); … … 1130 1046 1131 1047 #ifdef RT_STRICT 1132 ps2m TestAccumulation();1048 ps2mR3TestAccumulation(); 1133 1049 #endif 1134 1050 … … 1139 1055 pThis->cmdQ.cSize = AUX_CMD_QUEUE_SIZE; 1140 1056 1141 pThis->Mouse.IBase.pfnQueryInterface = ps2m QueryInterface;1142 pThis->Mouse.IPort.pfnPutEvent = ps2m PutEvent;1143 pThis->Mouse.IPort.pfnPutEventAbs = ps2m PutEventAbs;1144 pThis->Mouse.IPort.pfnPutEventMultiTouch = ps2m PutEventMT;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; 1145 1061 1146 1062 /* … … 1153 1069 */ 1154 1070 PTMTIMER pTimer; 1155 int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, ps2m ThrottleTimer, pThis,1071 int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, ps2mR3ThrottleTimer, pThis, 1156 1072 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Throttle Timer", &pTimer); 1157 if (RT_FAILURE(rc)) 1158 return rc; 1073 AssertRCReturn(rc, rc); 1159 1074 1160 1075 pThis->pThrottleTimerR3 = pTimer; … … 1165 1080 * Create the command delay timer. 1166 1081 */ 1167 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2m DelayTimer, pThis,1082 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2mR3DelayTimer, pThis, 1168 1083 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Delay Timer", &pTimer); 1169 if (RT_FAILURE(rc)) 1170 return rc; 1084 AssertRCReturn(rc, rc); 1171 1085 1172 1086 pThis->pDelayTimerR3 = pTimer; … … 1177 1091 * Register debugger info callbacks. 1178 1092 */ 1179 PDMDevHlpDBGFInfoRegister(pDevIns, "ps2m", "Display PS/2 mouse state.", ps2m InfoState);1093 PDMDevHlpDBGFInfoRegister(pDevIns, "ps2m", "Display PS/2 mouse state.", ps2mR3InfoState); 1180 1094 1181 1095 /// @todo Where should we do this? 1182 ps2m SetDriverState(pThis, true);1096 ps2mR3SetDriverState(pThis, true); 1183 1097 pThis->u8State = 0; 1184 1098 pThis->enmMode = AUX_MODE_STD; … … 1194 1108 /** Test the event accumulation mechanism which we use to delay events going 1195 1109 * to the guest to one per 10ms (the default PS/2 mouse event rate). This 1196 * test depends on ps2m PutEventWorker() not touching the timer if1110 * test depends on ps2mR3PutEventWorker() not touching the timer if 1197 1111 * This.fThrottleActive is true. */ 1198 1112 /** @todo if we add any more tests it might be worth using a table of test 1199 1113 * operations and checks. */ 1200 static void ps2m TestAccumulation(void)1114 static void ps2mR3TestAccumulation(void) 1201 1115 { 1202 1116 PS2M This; … … 1212 1126 * a release-press-release all within a single 10ms interval. Simulate 1213 1127 * this to check that it is handled right. */ 1214 ps2m PutEventWorker(&This, 0, 0, 0, 0, 1);1128 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1); 1215 1129 if (ps2mHaveEvents(&This)) 1216 1130 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1217 ps2m PutEventWorker(&This, 0, 0, 0, 0, 0);1131 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 0); 1218 1132 if (ps2mHaveEvents(&This)) 1219 1133 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1220 ps2m PutEventWorker(&This, 0, 0, 0, 0, 1);1221 ps2m PutEventWorker(&This, 0, 0, 0, 0, 0);1134 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1); 1135 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 0); 1222 1136 if (ps2mHaveEvents(&This)) 1223 1137 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); … … 1236 1150 /* Button hold down during mouse drags was broken at some point during 1237 1151 * testing fixes for the previous issue. Test that that works. */ 1238 ps2m PutEventWorker(&This, 0, 0, 0, 0, 1);1152 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1); 1239 1153 if (ps2mHaveEvents(&This)) 1240 1154 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);
Note:
See TracChangeset
for help on using the changeset viewer.