- Timestamp:
- Nov 25, 2019 5:37:49 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r82173 r82189 462 462 #ifdef IN_RING3 463 463 464 static void kbd_reset(void *opaque) 465 { 466 KBDState *s = (KBDState*)opaque; 467 s->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT; 468 s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED; 469 /* Resetting everything, keyword was not working right on NT4 reboot. */ 470 s->write_cmd = 0; 471 s->translate = 0; 472 } 473 474 static void kbd_save(PSSMHANDLE pSSM, KBDState *s) 475 { 476 SSMR3PutU8(pSSM, s->write_cmd); 477 SSMR3PutU8(pSSM, s->status); 478 SSMR3PutU8(pSSM, s->mode); 479 SSMR3PutU8(pSSM, s->dbbout); 480 481 /* terminator */ 482 SSMR3PutU32(pSSM, UINT32_MAX); 483 } 484 485 static int kbd_load(PSSMHANDLE pSSM, KBDState *s, uint32_t version_id) 464 static int kbd_load(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, KBDState *s, uint32_t version_id) 486 465 { 487 466 uint32_t u32, i; … … 498 477 if (version_id < 2 || version_id > PCKBD_SAVED_STATE_VERSION) 499 478 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 500 SSMR3GetU8(pSSM, &s->write_cmd);501 SSMR3GetU8(pSSM, &s->status);502 SSMR3GetU8(pSSM, &s->mode);479 pHlp->pfnSSMGetU8(pSSM, &s->write_cmd); 480 pHlp->pfnSSMGetU8(pSSM, &s->status); 481 pHlp->pfnSSMGetU8(pSSM, &s->mode); 503 482 if (version_id <= 5) 504 483 { 505 SSMR3GetU32(pSSM, &u32Dummy);506 SSMR3GetU32(pSSM, &u32Dummy);484 pHlp->pfnSSMGetU32(pSSM, &u32Dummy); 485 pHlp->pfnSSMGetU32(pSSM, &u32Dummy); 507 486 } 508 487 else 509 488 { 510 SSMR3GetU8(pSSM, &s->dbbout);489 pHlp->pfnSSMGetU8(pSSM, &s->dbbout); 511 490 } 512 491 if (version_id <= 7) … … 517 496 uint8_t u8Proto; 518 497 519 SSMR3GetU32(pSSM, &u32Dummy);520 SSMR3GetU8(pSSM, &u8State);521 SSMR3GetU8(pSSM, &u8Dummy);522 SSMR3GetU8(pSSM, &u8Rate);523 SSMR3GetU8(pSSM, &u8Dummy);524 SSMR3GetU8(pSSM, &u8Proto);525 SSMR3GetU8(pSSM, &u8Dummy);526 SSMR3GetS32(pSSM, &i32Dummy);527 SSMR3GetS32(pSSM, &i32Dummy);528 SSMR3GetS32(pSSM, &i32Dummy);498 pHlp->pfnSSMGetU32(pSSM, &u32Dummy); 499 pHlp->pfnSSMGetU8(pSSM, &u8State); 500 pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 501 pHlp->pfnSSMGetU8(pSSM, &u8Rate); 502 pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 503 pHlp->pfnSSMGetU8(pSSM, &u8Proto); 504 pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 505 pHlp->pfnSSMGetS32(pSSM, &i32Dummy); 506 pHlp->pfnSSMGetS32(pSSM, &i32Dummy); 507 pHlp->pfnSSMGetS32(pSSM, &i32Dummy); 529 508 if (version_id > 2) 530 509 { 531 SSMR3GetS32(pSSM, &i32Dummy);532 SSMR3GetS32(pSSM, &i32Dummy);510 pHlp->pfnSSMGetS32(pSSM, &i32Dummy); 511 pHlp->pfnSSMGetS32(pSSM, &i32Dummy); 533 512 } 534 rc = SSMR3GetU8(pSSM, &u8Dummy);513 rc = pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 535 514 if (version_id == 4) 536 515 { 537 SSMR3GetU32(pSSM, &u32Dummy);538 rc = SSMR3GetU32(pSSM, &u32Dummy);516 pHlp->pfnSSMGetU32(pSSM, &u32Dummy); 517 rc = pHlp->pfnSSMGetU32(pSSM, &u32Dummy); 539 518 } 540 519 if (version_id > 3) 541 rc = SSMR3GetU8(pSSM, &u8Dummy);520 rc = pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 542 521 if (version_id == 4) 543 rc = SSMR3GetU8(pSSM, &u8Dummy);522 rc = pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 544 523 AssertLogRelRCReturn(rc, rc); 545 524 546 PS2M FixupState(&s->Aux, u8State, u8Rate, u8Proto);525 PS2MR3FixupState(&s->Aux, u8State, u8Rate, u8Proto); 547 526 } 548 527 … … 555 534 if (version_id <= 5) 556 535 { 557 rc = SSMR3GetU32(pSSM, &u32);536 rc = pHlp->pfnSSMGetU32(pSSM, &u32); 558 537 if (RT_FAILURE(rc)) 559 538 return rc; 560 539 for (i = 0; i < u32; i++) 561 540 { 562 rc = SSMR3GetU8(pSSM, &u8Dummy);541 rc = pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 563 542 if (RT_FAILURE(rc)) 564 543 return rc; … … 569 548 if (version_id <= 7) 570 549 { 571 rc = SSMR3GetU32(pSSM, &u32);550 rc = pHlp->pfnSSMGetU32(pSSM, &u32); 572 551 if (RT_FAILURE(rc)) 573 552 return rc; 574 553 for (i = 0; i < u32; i++) 575 554 { 576 rc = SSMR3GetU8(pSSM, &u8Dummy);555 rc = pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 577 556 if (RT_FAILURE(rc)) 578 557 return rc; … … 580 559 Log(("kbd_load: %d mouse event queue items discarded from old saved state\n", u32)); 581 560 582 rc = SSMR3GetU32(pSSM, &u32);561 rc = pHlp->pfnSSMGetU32(pSSM, &u32); 583 562 if (RT_FAILURE(rc)) 584 563 return rc; 585 564 for (i = 0; i < u32; i++) 586 565 { 587 rc = SSMR3GetU8(pSSM, &u8Dummy);566 rc = pHlp->pfnSSMGetU8(pSSM, &u8Dummy); 588 567 if (RT_FAILURE(rc)) 589 568 return rc; … … 593 572 594 573 /* terminator */ 595 rc = SSMR3GetU32(pSSM, &u32);574 rc = pHlp->pfnSSMGetU32(pSSM, &u32); 596 575 if (RT_FAILURE(rc)) 597 576 return rc; … … 603 582 return 0; 604 583 } 584 605 585 #endif /* IN_RING3 */ 606 586 … … 624 604 { 625 605 uint32_t fluff = 0; 626 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);606 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 627 607 628 608 NOREF(pvUser); … … 684 664 { 685 665 uint32_t fluff = 0; 686 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);666 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 687 667 688 668 NOREF(pvUser); … … 730 710 } 731 711 712 /** 713 * Clear a queue. 714 * 715 * @param pQ Pointer to the queue. 716 */ 717 void PS2CmnClearQueue(GeneriQ *pQ) 718 { 719 LogFlowFunc(("Clearing queue %p\n", pQ)); 720 pQ->wpos = pQ->rpos; 721 pQ->cUsed = 0; 722 } 723 724 725 /** 726 * Add a byte to a queue. 727 * 728 * @param pQ Pointer to the queue. 729 * @param val The byte to store. 730 */ 731 void PS2CmnInsertQueue(GeneriQ *pQ, uint8_t val) 732 { 733 /* Check if queue is full. */ 734 if (pQ->cUsed >= pQ->cSize) 735 { 736 LogRelFlowFunc(("queue %p full (%d entries)\n", pQ, pQ->cUsed)); 737 return; 738 } 739 /* Insert data and update circular buffer write position. */ 740 pQ->abQueue[pQ->wpos] = val; 741 if (++pQ->wpos == pQ->cSize) 742 pQ->wpos = 0; /* Roll over. */ 743 ++pQ->cUsed; 744 LogRelFlowFunc(("inserted 0x%02X into queue %p\n", val, pQ)); 745 } 746 732 747 #ifdef IN_RING3 733 748 734 749 /** 735 * Saves a state of the keyboard device. 750 * Save a queue state. 751 * 752 * @param pHlp The device helpers. 753 * @param pSSM SSM handle to write the state to. 754 * @param pQ Pointer to the queue. 755 */ 756 void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ) 757 { 758 uint32_t cItems = pQ->cUsed; 759 uint32_t i; 760 761 /* Only save the number of items. Note that the read/write 762 * positions aren't saved as they will be rebuilt on load. 763 */ 764 pHlp->pfnSSMPutU32(pSSM, cItems); 765 766 LogFlow(("Storing %d items from queue %p\n", cItems, pQ)); 767 768 /* Save queue data - only the bytes actually used (typically zero). */ 769 for (i = pQ->rpos % pQ->cSize; cItems-- > 0; i = (i + 1) % pQ->cSize) 770 pHlp->pfnSSMPutU8(pSSM, pQ->abQueue[i]); 771 } 772 773 /** 774 * Load a queue state. 775 * 776 * @param pHlp The device helpers. 777 * @param pSSM SSM handle to read the state from. 778 * @param pQ Pointer to the queue. 779 * 780 * @return int VBox status/error code. 781 */ 782 int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ) 783 { 784 int rc; 785 786 /* On load, always put the read pointer at zero. */ 787 rc = pHlp->pfnSSMGetU32(pSSM, &pQ->cUsed); 788 AssertRCReturn(rc, rc); 789 790 LogFlow(("Loading %d items to queue %p\n", pQ->cUsed, pQ)); 791 792 AssertMsgReturn(pQ->cUsed <= pQ->cSize, ("Saved size=%u, actual=%u\n", pQ->cUsed, pQ->cSize), 793 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 794 795 /* Recalculate queue positions and load data in one go. */ 796 pQ->rpos = 0; 797 pQ->wpos = pQ->cUsed; 798 return pHlp->pfnSSMGetMem(pSSM, pQ->abQueue, pQ->cUsed); 799 } 800 801 802 /** 803 * @callback_method_impl{FNSSMDEVSAVEEXEC, Saves a state of the keyboard device.} 736 804 * 737 805 * @returns VBox status code. … … 739 807 * @param pSSM The handle to save the state to. 740 808 */ 741 static DECLCALLBACK(int) kbdSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 742 { 743 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *); 744 kbd_save(pSSM, pThis); 745 PS2KSaveState(&pThis->Kbd, pSSM); 746 PS2MSaveState(&pThis->Aux, pSSM); 809 static DECLCALLBACK(int) kbdR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 810 { 811 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 812 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 813 814 pHlp->pfnSSMPutU8(pSSM, pThis->write_cmd); 815 pHlp->pfnSSMPutU8(pSSM, pThis->status); 816 pHlp->pfnSSMPutU8(pSSM, pThis->mode); 817 pHlp->pfnSSMPutU8(pSSM, pThis->dbbout); 818 /* terminator */ 819 pHlp->pfnSSMPutU32(pSSM, UINT32_MAX); 820 821 PS2KR3SaveState(pDevIns, &pThis->Kbd, pSSM); 822 PS2MR3SaveState(pDevIns, &pThis->Aux, pSSM); 747 823 return VINF_SUCCESS; 748 824 } … … 750 826 751 827 /** 752 * Loads a saved keyboard device state. 753 * 754 * @returns VBox status code. 755 * @param pDevIns The device instance. 756 * @param pSSM The handle to the saved state. 757 * @param uVersion The data unit version number. 758 * @param uPass The data pass. 759 */ 760 static DECLCALLBACK(int) kbdLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 761 { 762 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *); 828 * @callback_method_impl{FNSSMDEVLOADEXEC, Loads a saved keyboard device state.} 829 */ 830 static DECLCALLBACK(int) kbdR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 831 { 832 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 763 833 int rc; 764 834 765 835 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 766 rc = kbd_load(pSSM, pThis, uVersion); 836 rc = kbd_load(pDevIns->pHlpR3, pSSM, pThis, uVersion); 837 AssertRCReturn(rc, rc); 838 767 839 if (uVersion >= 6) 768 rc = PS2KLoadState(&pThis->Kbd, pSSM, uVersion); 840 rc = PS2KR3LoadState(pDevIns, &pThis->Kbd, pSSM, uVersion); 841 AssertRCReturn(rc, rc); 842 769 843 if (uVersion >= 8) 770 rc = PS2MLoadState(&pThis->Aux, pSSM, uVersion); 844 rc = PS2MR3LoadState(pDevIns, &pThis->Aux, pSSM, uVersion); 845 AssertRCReturn(rc, rc); 771 846 return rc; 772 847 } … … 775 850 * @callback_method_impl{FNSSMDEVLOADDONE, Key state fix-up after loading} 776 851 */ 777 static DECLCALLBACK(int) kbdLoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 778 { 779 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *); 780 int rc; 781 782 rc = PS2KLoadDone(&pThis->Kbd, pSSM); 783 return rc; 852 static DECLCALLBACK(int) kbdR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 853 { 854 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 855 return PS2KR3LoadDone(&pThis->Kbd, pSSM); 784 856 } 785 857 … … 790 862 * @param pDevIns The device instance data. 791 863 */ 792 static DECLCALLBACK(void) kbdReset(PPDMDEVINS pDevIns) 793 { 794 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *); 795 796 kbd_reset(pThis); 797 PS2KReset(&pThis->Kbd); 798 PS2MReset(&pThis->Aux); 864 static DECLCALLBACK(void) kbdR3Reset(PPDMDEVINS pDevIns) 865 { 866 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 867 868 pThis->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT; 869 pThis->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED; 870 /* Resetting everything, keyword was not working right on NT4 reboot. */ 871 pThis->write_cmd = 0; 872 pThis->translate = 0; 873 874 PS2KR3Reset(&pThis->Kbd); 875 PS2MR3Reset(&pThis->Aux); 799 876 } 800 877 … … 804 881 805 882 /** 806 * Attach command. 807 * 808 * This is called to let the device attach to a driver for a specified LUN 809 * during runtime. This is not called during VM construction, the device 810 * constructor have to attach to all the available drivers. 811 * 812 * This is like plugging in the keyboard or mouse after turning on the PC. 813 * 814 * @returns VBox status code. 815 * @param pDevIns The device instance. 816 * @param iLUN The logical unit which is being detached. 817 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 883 * @interface_method_impl{PDMDEVREGR3,pfnAttach} 884 * 818 885 * @remark The keyboard controller doesn't support this action, this is just 819 886 * implemented to try out the driver<->device structure. 820 887 */ 821 static DECLCALLBACK(int) kbd Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)888 static DECLCALLBACK(int) kbdR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 822 889 { 823 890 int rc; 824 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);891 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 825 892 826 893 AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG, … … 832 899 /* LUN #0: keyboard */ 833 900 case 0: 834 rc = PS2KAttach(&pThis->Kbd, pDevIns, iLUN, fFlags); 835 if (RT_FAILURE(rc)) 836 return rc; 901 rc = PS2KR3Attach(&pThis->Kbd, pDevIns, iLUN, fFlags); 837 902 break; 838 903 839 904 /* LUN #1: aux/mouse */ 840 905 case 1: 841 rc = PS2M Attach(&pThis->Aux, pDevIns, iLUN, fFlags);906 rc = PS2MR3Attach(&pThis->Aux, pDevIns, iLUN, fFlags); 842 907 break; 843 908 … … 852 917 853 918 /** 854 * Detach notification. 855 * 856 * This is called when a driver is detaching itself from a LUN of the device. 857 * The device should adjust it's state to reflect this. 858 * 859 * This is like unplugging the network cable to use it for the laptop or 860 * something while the PC is still running. 861 * 862 * @param pDevIns The device instance. 863 * @param iLUN The logical unit which is being detached. 864 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 919 * @interface_method_impl{PDMDEVREGR3,pfnDetach} 865 920 * @remark The keyboard controller doesn't support this action, this is just 866 921 * implemented to try out the driver<->device structure. 867 922 */ 868 static DECLCALLBACK(void) kbd Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)923 static DECLCALLBACK(void) kbdR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 869 924 { 870 925 #if 0 … … 872 927 * Reset the interfaces and update the controller state. 873 928 */ 874 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);929 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 875 930 switch (iLUN) 876 931 { … … 898 953 899 954 /** 900 * @ copydoc FNPDMDEVRELOCATE901 */ 902 static DECLCALLBACK(void) kbdR elocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)903 { 904 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);955 * @interface_method_impl{PDMDEVREGR3,pfnRelocate} 956 */ 957 static DECLCALLBACK(void) kbdR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 958 { 959 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 905 960 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 906 PS2KRelocate(&pThis->Kbd, offDelta, pDevIns); 907 PS2MRelocate(&pThis->Aux, offDelta, pDevIns); 908 } 909 910 911 /** 912 * @interface_method_impl{PDMDEVREG,pfnConstruct} 913 */ 914 static DECLCALLBACK(int) kbdConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 915 { 916 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *); 961 PS2KR3Relocate(&pThis->Kbd, offDelta, pDevIns); 962 PS2MR3Relocate(&pThis->Aux, offDelta, pDevIns); 963 } 964 965 966 /** 967 * @interface_method_impl{PDMDEVREGR3,pfnConstruct} 968 */ 969 static DECLCALLBACK(int) kbdR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 970 { 971 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 972 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 917 973 int rc; 918 bool fGCEnabled;919 bool fR0Enabled;920 974 Assert(iInstance == 0); 921 922 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);923 975 924 976 /* 925 977 * Validate and read the configuration. 926 978 */ 927 if (!CFGMR3AreValuesValid(pCfg, "GCEnabled\0R0Enabled\0KbdThrottleEnabled\0")) 928 return VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES; 929 rc = CFGMR3QueryBoolDef(pCfg, "GCEnabled", &fGCEnabled, true); 930 if (RT_FAILURE(rc)) 931 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to query \"GCEnabled\" from the config")); 932 rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &fR0Enabled, true); 933 if (RT_FAILURE(rc)) 934 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to query \"R0Enabled\" from the config")); 935 Log(("pckbd: fGCEnabled=%RTbool fR0Enabled=%RTbool\n", fGCEnabled, fR0Enabled)); 936 979 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "KbdThrottleEnabled", ""); 980 Log(("pckbd: fRCEnabled=%RTbool fR0Enabled=%RTbool\n", pDevIns->fRCEnabled, pDevIns->fR0Enabled)); 937 981 938 982 /* … … 943 987 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 944 988 945 rc = PS2KConstruct(&pThis->Kbd, pDevIns, pThis, iInstance, pCfg); 946 if (RT_FAILURE(rc)) 947 return rc; 948 949 rc = PS2MConstruct(&pThis->Aux, pDevIns, pThis, iInstance); 950 if (RT_FAILURE(rc)) 951 return rc; 989 rc = PS2KR3Construct(&pThis->Kbd, pDevIns, pThis, iInstance, pCfg); 990 AssertRCReturn(rc, rc); 991 992 rc = PS2MR3Construct(&pThis->Aux, pDevIns, pThis, iInstance); 993 AssertRCReturn(rc, rc); 952 994 953 995 /* 954 * Register I/O ports , save state, keyboard event handler and mouse event handlers.996 * Register I/O ports. 955 997 */ 956 998 rc = PDMDevHlpIOPortRegister(pDevIns, 0x60, 1, NULL, kbdIOPortDataWrite, kbdIOPortDataRead, NULL, NULL, "PC Keyboard - Data"); 957 if (RT_FAILURE(rc)) 958 return rc; 999 AssertRCReturn(rc, rc); 959 1000 rc = PDMDevHlpIOPortRegister(pDevIns, 0x64, 1, NULL, kbdIOPortCommandWrite, kbdIOPortStatusRead, NULL, NULL, "PC Keyboard - Command / Status"); 960 if (RT_FAILURE(rc)) 961 return rc; 962 if (fGCEnabled) 1001 AssertRCReturn(rc, rc); 1002 if (pDevIns->fRCEnabled) 963 1003 { 964 1004 rc = PDMDevHlpIOPortRegisterRC(pDevIns, 0x60, 1, 0, "kbdIOPortDataWrite", "kbdIOPortDataRead", NULL, NULL, "PC Keyboard - Data"); … … 969 1009 return rc; 970 1010 } 971 if ( fR0Enabled)1011 if (pDevIns->fR0Enabled) 972 1012 { 973 1013 rc = PDMDevHlpIOPortRegisterR0(pDevIns, 0x60, 1, 0, "kbdIOPortDataWrite", "kbdIOPortDataRead", NULL, NULL, "PC Keyboard - Data"); … … 978 1018 return rc; 979 1019 } 1020 1021 /* 1022 * Saved state. 1023 */ 980 1024 rc = PDMDevHlpSSMRegisterEx(pDevIns, PCKBD_SAVED_STATE_VERSION, sizeof(*pThis), NULL, 981 1025 NULL, NULL, NULL, 982 NULL, kbdSaveExec, NULL, 983 NULL, kbdLoadExec, kbdLoadDone); 984 if (RT_FAILURE(rc)) 985 return rc; 1026 NULL, kbdR3SaveExec, NULL, 1027 NULL, kbdR3LoadExec, kbdR3LoadDone); 1028 AssertRCReturn(rc, rc); 986 1029 987 1030 /* 988 1031 * Attach to the keyboard and mouse drivers. 989 1032 */ 990 rc = kbdAttach(pDevIns, 0 /* keyboard LUN # */, PDM_TACH_FLAGS_NOT_HOT_PLUG); 991 if (RT_FAILURE(rc)) 992 return rc; 993 rc = kbdAttach(pDevIns, 1 /* aux/mouse LUN # */, PDM_TACH_FLAGS_NOT_HOT_PLUG); 994 if (RT_FAILURE(rc)) 995 return rc; 1033 rc = kbdR3Attach(pDevIns, 0 /* keyboard LUN # */, PDM_TACH_FLAGS_NOT_HOT_PLUG); 1034 AssertRCReturn(rc, rc); 1035 rc = kbdR3Attach(pDevIns, 1 /* aux/mouse LUN # */, PDM_TACH_FLAGS_NOT_HOT_PLUG); 1036 AssertRCReturn(rc, rc); 996 1037 997 1038 /* 998 1039 * Initialize the device state. 999 1040 */ 1000 kbdR eset(pDevIns);1041 kbdR3Reset(pDevIns); 1001 1042 1002 1043 return VINF_SUCCESS; … … 1028 1069 /* .pszRCMod = */ "VBoxDDRC.rc", 1029 1070 /* .pszR0Mod = */ "VBoxDDR0.r0", 1030 /* .pfnConstruct = */ kbd Construct,1071 /* .pfnConstruct = */ kbdR3Construct, 1031 1072 /* .pfnDestruct = */ NULL, 1032 /* .pfnRelocate = */ kbdR elocate,1073 /* .pfnRelocate = */ kbdR3Relocate, 1033 1074 /* .pfnMemSetup = */ NULL, 1034 1075 /* .pfnPowerOn = */ NULL, 1035 /* .pfnReset = */ kbdR eset,1076 /* .pfnReset = */ kbdR3Reset, 1036 1077 /* .pfnSuspend = */ NULL, 1037 1078 /* .pfnResume = */ NULL, 1038 /* .pfnAttach = */ kbd Attach,1039 /* .pfnDetach = */ kbd Detach,1079 /* .pfnAttach = */ kbdR3Attach, 1080 /* .pfnDetach = */ kbdR3Detach, 1040 1081 /* .pfnQueryInterface = */ NULL, 1041 1082 /* .pfnInitComplete = */ NULL, -
trunk/src/VBox/Devices/Input/DevPS2.h
r82173 r82189 40 40 41 41 DEF_PS2Q_TYPE(GeneriQ, 1); 42 void PS2CmnClearQueue(GeneriQ *pQ); 43 void PS2CmnInsertQueue(GeneriQ *pQ, uint8_t val); 44 void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ); 45 int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ); 42 46 43 47 … … 174 178 int PS2KByteFromKbd(PPS2K pThis, uint8_t *pVal); 175 179 176 int PS2K Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg);177 int PS2K Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);178 void PS2KR eset(PPS2K pThis);179 void PS2KR elocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns);180 void PS2K SaveState(PPS2K pThis, PSSMHANDLE pSSM);181 int PS2K LoadState(PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion);182 int PS2K LoadDone(PPS2K pThis, PSSMHANDLE pSSM);180 int PS2KR3Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg); 181 int PS2KR3Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags); 182 void PS2KR3Reset(PPS2K pThis); 183 void PS2KR3Relocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns); 184 void PS2KR3SaveState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM); 185 int PS2KR3LoadState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion); 186 int PS2KR3LoadDone(PPS2K pThis, PSSMHANDLE pSSM); 183 187 184 188 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns); … … 325 329 int PS2MByteFromAux(PPS2M pThis, uint8_t *pVal); 326 330 327 int PS2M Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance);328 int PS2M Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);329 void PS2MR eset(PPS2M pThis);330 void PS2MR elocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns);331 void PS2M SaveState(PPS2M pThis, PSSMHANDLE pSSM);332 int PS2M LoadState(PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion);333 void PS2M FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto);331 int PS2MR3Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance); 332 int PS2MR3Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags); 333 void PS2MR3Reset(PPS2M pThis); 334 void PS2MR3Relocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns); 335 void PS2MR3SaveState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM); 336 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion); 337 void PS2MR3FixupState(PPS2M pThis, uint8_t u8State, uint8_t u8Rate, uint8_t u8Proto); 334 338 335 339 PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns); -
trunk/src/VBox/Devices/Input/DevPS2K.cpp
r82173 r82189 377 377 #endif /* IN_RING3 */ 378 378 379 380 381 /**382 * Clear a queue.383 *384 * @param pQ Pointer to the queue.385 */386 static void ps2kClearQueue(GeneriQ *pQ)387 {388 LogFlowFunc(("Clearing queue %p\n", pQ));389 pQ->wpos = pQ->rpos;390 pQ->cUsed = 0;391 }392 393 394 /**395 * Add a byte to a queue.396 *397 * @param pQ Pointer to the queue.398 * @param val The byte to store.399 */400 static void ps2kInsertQueue(GeneriQ *pQ, uint8_t val)401 {402 /* Check if queue is full. */403 if (pQ->cUsed >= pQ->cSize)404 {405 LogRelFlowFunc(("queue %p full (%d entries)\n", pQ, pQ->cUsed));406 return;407 }408 /* Insert data and update circular buffer write position. */409 pQ->abQueue[pQ->wpos] = val;410 if (++pQ->wpos == pQ->cSize)411 pQ->wpos = 0; /* Roll over. */412 ++pQ->cUsed;413 LogRelFlowFunc(("inserted 0x%02X into queue %p\n", val, pQ));414 }415 416 379 #ifdef IN_RING3 417 380 … … 425 388 * @return int VBox status/error code. 426 389 */ 427 static int ps2k InsertStrQueue(GeneriQ *pQ, const uint8_t *pStr, uint32_t uReserve)390 static int ps2kR3InsertStrQueue(GeneriQ *pQ, const uint8_t *pStr, uint32_t uReserve) 428 391 { 429 392 uint32_t cbStr; … … 452 415 453 416 /** 454 * Save a queue state.455 *456 * @param pSSM SSM handle to write the state to.457 * @param pQ Pointer to the queue.458 */459 static void ps2kSaveQueue(PSSMHANDLE pSSM, GeneriQ *pQ)460 {461 uint32_t cItems = pQ->cUsed;462 int i;463 464 /* Only save the number of items. Note that the read/write465 * positions aren't saved as they will be rebuilt on load.466 */467 SSMR3PutU32(pSSM, cItems);468 469 LogFlow(("Storing %d items from queue %p\n", cItems, pQ));470 471 /* Save queue data - only the bytes actually used (typically zero). */472 for (i = pQ->rpos; cItems-- > 0; i = (i + 1) % pQ->cSize)473 SSMR3PutU8(pSSM, pQ->abQueue[i]);474 }475 476 /**477 * Load a queue state.478 *479 * @param pSSM SSM handle to read the state from.480 * @param pQ Pointer to the queue.481 *482 * @return int VBox status/error code.483 */484 static int ps2kLoadQueue(PSSMHANDLE pSSM, GeneriQ *pQ)485 {486 /* On load, always put the read pointer at zero. */487 int rc = SSMR3GetU32(pSSM, &pQ->cUsed);488 AssertRCReturn(rc, rc);489 LogFlow(("Loading %u items to queue %p\n", pQ->cUsed, pQ));490 AssertMsgReturn(pQ->cUsed <= pQ->cSize, ("Saved size=%u, actual=%u\n", pQ->cUsed, pQ->cSize),491 VERR_SSM_DATA_UNIT_FORMAT_CHANGED);492 493 /* Recalculate queue positions and load data in one go. */494 pQ->rpos = 0;495 pQ->wpos = pQ->cUsed;496 rc = SSMR3GetMem(pSSM, pQ->abQueue, pQ->cUsed);497 498 return rc;499 }500 501 /**502 417 * Notify listener about LEDs state change. 503 418 * … … 505 420 * @param u8State Bitfield which reflects LEDs state. 506 421 */ 507 static void ps2k NotifyLedsState(PPS2K pThis, uint8_t u8State)422 static void ps2kR3NotifyLedsState(PPS2K pThis, uint8_t u8State) 508 423 { 509 424 … … 528 443 * @return uint32_t Number of items in queue. 529 444 */ 530 static uint32_t ps2 kInQueue(GeneriQ *pQ)445 static uint32_t ps2R3kInQueue(GeneriQ *pQ) 531 446 { 532 447 return pQ->cUsed; … … 597 512 { 598 513 LogFlowFunc(("Set keyboard defaults\n")); 599 ps2kClearQueue((GeneriQ *)&pThis->keyQ);514 PS2CmnClearQueue((GeneriQ *)&pThis->keyQ); 600 515 /* Set default Scan Set 3 typematic values. */ 601 516 /* Set default typematic rate/delay. */ … … 624 539 { 625 540 case KCMD_ECHO: 626 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ECHO);541 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ECHO); 627 542 pThis->u8CurrCmd = 0; 628 543 break; 629 544 case KCMD_READ_ID: 630 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);631 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ID1);632 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ID2);545 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 546 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ID1); 547 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ID2); 633 548 pThis->u8CurrCmd = 0; 634 549 break; 635 550 case KCMD_ENABLE: 636 551 pThis->fScanning = true; 637 ps2kClearQueue((GeneriQ *)&pThis->keyQ);552 PS2CmnClearQueue((GeneriQ *)&pThis->keyQ); 638 553 ps2kStopTypematicRepeat(pThis); 639 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);554 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 640 555 pThis->u8CurrCmd = 0; 641 556 break; … … 643 558 pThis->fScanning = false; 644 559 ps2kSetDefaults(pThis); /* Also clears buffer/typematic state. */ 645 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);560 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 646 561 pThis->u8CurrCmd = 0; 647 562 break; 648 563 case KCMD_SET_DEFAULT: 649 564 ps2kSetDefaults(pThis); 650 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);565 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 651 566 pThis->u8CurrCmd = 0; 652 567 break; … … 656 571 case KCMD_ALL_TMB: 657 572 /// @todo Set the key types here. 658 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);573 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 659 574 pThis->u8CurrCmd = 0; 660 575 break; … … 666 581 ps2kSetDefaults(pThis); 667 582 /// @todo reset more? 668 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);583 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 669 584 pThis->u8CurrCmd = cmd; 670 585 /* Delay BAT completion; the test may take hundreds of ms. */ … … 678 593 case KCMD_TYPE_MK_BRK: 679 594 case KCMD_TYPE_MAKE: 680 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);595 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 681 596 pThis->u8CurrCmd = cmd; 682 597 break; … … 690 605 #else 691 606 { 692 ps2k NotifyLedsState(pThis, cmd);607 ps2kR3NotifyLedsState(pThis, cmd); 693 608 pThis->fNumLockOn = !!(cmd & 0x02); /* Sync internal Num Lock state. */ 694 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);609 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 695 610 pThis->u8LEDs = cmd; 696 611 pThis->u8CurrCmd = 0; … … 699 614 break; 700 615 case KCMD_SCANSET: 701 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);616 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 702 617 if (cmd == 0) 703 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8ScanSet);618 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8ScanSet); 704 619 else if (cmd < 4) 705 620 { … … 712 627 case KCMD_RATE_DELAY: 713 628 ps2kSetupTypematic(pThis, cmd); 714 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);629 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 715 630 pThis->u8CurrCmd = 0; 716 631 break; … … 725 640 case KCMD_INVALID_1: 726 641 case KCMD_INVALID_2: 727 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_RESEND);642 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_RESEND); 728 643 pThis->u8CurrCmd = 0; 729 644 break; … … 770 685 #ifdef IN_RING3 771 686 772 static int ps2k ProcessKeyEvent(PPS2K pThis, uint32_t u32HidCode, bool fKeyDown)687 static int ps2kR3ProcessKeyEvent(PPS2K pThis, uint32_t u32HidCode, bool fKeyDown) 773 688 { 774 689 key_def const *pKeyDef; … … 912 827 /* Feed the bytes to the queue if there is room. */ 913 828 /// @todo Send overrun code if sequence won't fit? 914 ps2k InsertStrQueue((GeneriQ *)&pThis->keyQ, abCodes, 0);829 ps2kR3InsertStrQueue((GeneriQ *)&pThis->keyQ, abCodes, 0); 915 830 } 916 831 else if (!(pKeyDef->keyFlags & (KF_NB | KF_PB))) … … 967 882 /* Feed the bytes to the queue if there is room. */ 968 883 /// @todo Send overrun code if sequence won't fit? 969 ps2k InsertStrQueue((GeneriQ *)&pThis->keyQ, abCodes, 0);884 ps2kR3InsertStrQueue((GeneriQ *)&pThis->keyQ, abCodes, 0); 970 885 } 971 886 } … … 992 907 /* Feed the bytes to the queue if there is room. */ 993 908 /// @todo Send overrun code if sequence won't fit? 994 ps2k InsertStrQueue((GeneriQ *)&pThis->keyQ, abCodes, 0);909 ps2kR3InsertStrQueue((GeneriQ *)&pThis->keyQ, abCodes, 0); 995 910 } 996 911 … … 1032 947 } 1033 948 1034 /* Throttling timer to emulate the finite keyboard communication speed. A PS/2 keyboard is 949 /** 950 * @callback_function_impl{FNTMTIMERDEV} 951 * 952 * Throttling timer to emulate the finite keyboard communication speed. A PS/2 keyboard is 1035 953 * limited by the serial link speed and cannot send much more than 1,000 bytes per second. 1036 954 * Some software (notably Borland Pascal and programs built with its run-time) relies on … … 1043 961 * done because it would needlessly slow things down. 1044 962 */ 1045 static DECLCALLBACK(void) ps2k ThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)963 static DECLCALLBACK(void) ps2kR3ThrottleTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1046 964 { 1047 965 RT_NOREF(pDevIns, pTimer); … … 1057 975 */ 1058 976 pThis->fThrottleActive = false; 1059 uHaveData = ps2 kInQueue((GeneriQ *)&pThis->keyQ);977 uHaveData = ps2R3kInQueue((GeneriQ *)&pThis->keyQ); 1060 978 LogFlowFunc(("Have%s bytes\n", uHaveData ? "" : " no")); 1061 979 if (uHaveData) … … 1065 983 } 1066 984 1067 /* Timer handler for emulating typematic keys. Note that only the last key 1068 * held down repeats (if typematic). 1069 */ 1070 static DECLCALLBACK(void) ps2kTypematicTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 985 /** 986 * @callback_function_impl{FNTMTIMERDEV, 987 * Timer handler for emulating typematic keys.} 988 * 989 * @note Note that only the last key held down repeats (if typematic). 990 */ 991 static DECLCALLBACK(void) ps2kR3TypematicTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1071 992 { 1072 993 RT_NOREF(pDevIns, pTimer); … … 1084 1005 if (pThis->enmTypematicState == KBD_TMS_REPEAT) 1085 1006 { 1086 ps2k ProcessKeyEvent(pThis, pThis->u32TypematicKey, true /* Key down */ );1007 ps2kR3ProcessKeyEvent(pThis, pThis->u32TypematicKey, true /* Key down */ ); 1087 1008 TMTimerSetMillies(pThis->CTX_SUFF(pKbdTypematicTimer), pThis->uTypematicRepeat); 1088 1009 } … … 1090 1011 } 1091 1012 1092 /* The keyboard BAT is specified to take several hundred milliseconds. We need 1013 /** 1014 * @callback_function_impl{FNTMTIMERDEV} 1015 * 1016 * The keyboard BAT is specified to take several hundred milliseconds. We need 1093 1017 * to delay sending the result to the host for at least a tiny little while. 1094 1018 */ 1095 static DECLCALLBACK(void) ps2k DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)1019 static DECLCALLBACK(void) ps2kR3DelayTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1096 1020 { 1097 1021 RT_NOREF(pDevIns, pTimer); … … 1101 1025 1102 1026 AssertMsg(pThis->u8CurrCmd == KCMD_RESET, ("u8CurrCmd=%02x\n", pThis->u8CurrCmd)); 1103 ps2kInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_BAT_OK);1027 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_BAT_OK); 1104 1028 pThis->fScanning = true; /* BAT completion enables scanning! */ 1105 1029 pThis->u8CurrCmd = 0; … … 1114 1038 * or resuming a suspended host. 1115 1039 */ 1116 static void ps2kR eleaseKeys(PPS2K pThis)1040 static void ps2kR3ReleaseKeys(PPS2K pThis) 1117 1041 { 1118 1042 LogFlowFunc(("Releasing keys...\n")); … … 1121 1045 if (pThis->abDepressedKeys[uKey]) 1122 1046 { 1123 ps2k ProcessKeyEvent(pThis, RT_MAKE_U32(USB_HID_KB_PAGE, uKey), false /* key up */);1047 ps2kR3ProcessKeyEvent(pThis, RT_MAKE_U32(USB_HID_KB_PAGE, uKey), false /* key up */); 1124 1048 pThis->abDepressedKeys[uKey] = 0; 1125 1049 } … … 1135 1059 * @param pszArgs Argument string. Optional and specific to the handler. 1136 1060 */ 1137 static DECLCALLBACK(void) ps2k InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)1061 static DECLCALLBACK(void) ps2kR3InfoState(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1138 1062 { 1139 1063 PPS2K pThis = KBDGetPS2KFromDevIns(pDevIns); … … 1161 1085 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 1162 1086 */ 1163 static DECLCALLBACK(void *) ps2k QueryInterface(PPDMIBASE pInterface, const char *pszIID)1087 static DECLCALLBACK(void *) ps2kR3QueryInterface(PPDMIBASE pInterface, const char *pszIID) 1164 1088 { 1165 1089 PPS2K pThis = RT_FROM_MEMBER(pInterface, PS2K, Keyboard.IBase); … … 1180 1104 * press/release flag. 1181 1105 */ 1182 static int ps2k PutEventWorker(PPS2K pThis, uint32_t u32Usage)1106 static int ps2kR3PutEventWorker(PPS2K pThis, uint32_t u32Usage) 1183 1107 { 1184 1108 uint32_t u32HidCode; … … 1221 1145 AssertReleaseRC(rc); 1222 1146 1223 rc = ps2k ProcessKeyEvent(pThis, u32HidCode, fKeyDown);1147 rc = ps2kR3ProcessKeyEvent(pThis, u32HidCode, fKeyDown); 1224 1148 1225 1149 PDMCritSectLeave(pThis->pCritSectR3); … … 1229 1153 } 1230 1154 1231 static DECLCALLBACK(int) ps2kPutEventWrapper(PPDMIKEYBOARDPORT pInterface, uint32_t u32UsageCode) 1155 1156 /** 1157 * @interface_method_impl{PDMIKEYBOARDPORT,pfnPutEventHid} 1158 */ 1159 static DECLCALLBACK(int) ps2kR3KeyboardPort_PutEventHid(PPDMIKEYBOARDPORT pInterface, uint32_t u32UsageCode) 1232 1160 { 1233 1161 PPS2K pThis = RT_FROM_MEMBER(pInterface, PS2K, Keyboard.IPort); … … 1244 1172 if (RT_UNLIKELY(u32UsageCode == KRSP_BAT_FAIL)) 1245 1173 { 1246 ps2kR eleaseKeys(pThis);1174 ps2kR3ReleaseKeys(pThis); 1247 1175 } 1248 1176 else 1249 1177 { 1250 ps2k PutEventWorker(pThis, u32UsageCode);1178 ps2kR3PutEventWorker(pThis, u32UsageCode); 1251 1179 } 1252 1180 … … 1272 1200 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 1273 1201 */ 1274 int PS2K Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)1202 int PS2KR3Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 1275 1203 { 1276 1204 int rc; … … 1305 1233 } 1306 1234 1307 void PS2KSaveState(PPS2K pThis, PSSMHANDLE pSSM) 1308 { 1309 uint32_t cPressed = 0; 1310 uint32_t cbTMSSize = 0; 1235 void PS2KR3SaveState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM) 1236 { 1237 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1238 uint32_t cPressed = 0; 1239 uint32_t cbTMSSize = 0; 1311 1240 1312 1241 LogFlowFunc(("Saving PS2K state\n")); 1313 1242 1314 1243 /* Save the basic keyboard state. */ 1315 SSMR3PutU8(pSSM, pThis->u8CurrCmd);1316 SSMR3PutU8(pSSM, pThis->u8LEDs);1317 SSMR3PutU8(pSSM, pThis->u8TypematicCfg);1318 SSMR3PutU8(pSSM, (uint8_t)pThis->u32TypematicKey);1319 SSMR3PutU8(pSSM, pThis->u8Modifiers);1320 SSMR3PutU8(pSSM, pThis->u8ScanSet);1321 SSMR3PutU8(pSSM, pThis->enmTypematicState);1322 SSMR3PutBool(pSSM, pThis->fNumLockOn);1323 SSMR3PutBool(pSSM, pThis->fScanning);1244 pHlp->pfnSSMPutU8(pSSM, pThis->u8CurrCmd); 1245 pHlp->pfnSSMPutU8(pSSM, pThis->u8LEDs); 1246 pHlp->pfnSSMPutU8(pSSM, pThis->u8TypematicCfg); 1247 pHlp->pfnSSMPutU8(pSSM, (uint8_t)pThis->u32TypematicKey); 1248 pHlp->pfnSSMPutU8(pSSM, pThis->u8Modifiers); 1249 pHlp->pfnSSMPutU8(pSSM, pThis->u8ScanSet); 1250 pHlp->pfnSSMPutU8(pSSM, pThis->enmTypematicState); 1251 pHlp->pfnSSMPutBool(pSSM, pThis->fNumLockOn); 1252 pHlp->pfnSSMPutBool(pSSM, pThis->fScanning); 1324 1253 1325 1254 /* Save the command and keystroke queues. */ 1326 ps2kSaveQueue(pSSM, (GeneriQ *)&pThis->cmdQ);1327 ps2kSaveQueue(pSSM, (GeneriQ *)&pThis->keyQ);1255 PS2CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ); 1256 PS2CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->keyQ); 1328 1257 1329 1258 /* Save the command delay timer. Note that the typematic repeat … … 1339 1268 ++cPressed; 1340 1269 1341 SSMR3PutU32(pSSM, cPressed);1270 pHlp->pfnSSMPutU32(pSSM, cPressed); 1342 1271 1343 1272 for (unsigned uKey = 0; uKey < sizeof(pThis->abDepressedKeys); ++uKey) 1344 1273 if (pThis->abDepressedKeys[uKey]) 1345 SSMR3PutU8(pSSM, uKey);1274 pHlp->pfnSSMPutU8(pSSM, uKey); 1346 1275 1347 1276 /* Save the typematic settings for Scan Set 3. */ 1348 SSMR3PutU32(pSSM, cbTMSSize);1277 pHlp->pfnSSMPutU32(pSSM, cbTMSSize); 1349 1278 /* Currently not implemented. */ 1350 1279 } 1351 1280 1352 int PS2KLoadState(PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion) 1353 { 1354 uint8_t u8; 1355 uint32_t cPressed; 1356 uint32_t cbTMSSize; 1357 int rc; 1281 int PS2KR3LoadState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion) 1282 { 1283 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1284 uint8_t u8; 1285 uint32_t cPressed; 1286 uint32_t cbTMSSize; 1287 int rc; 1358 1288 1359 1289 NOREF(uVersion); … … 1361 1291 1362 1292 /* Load the basic keyboard state. */ 1363 SSMR3GetU8(pSSM, &pThis->u8CurrCmd);1364 SSMR3GetU8(pSSM, &pThis->u8LEDs);1365 SSMR3GetU8(pSSM, &pThis->u8TypematicCfg);1366 SSMR3GetU8(pSSM, &u8);1293 pHlp->pfnSSMGetU8(pSSM, &pThis->u8CurrCmd); 1294 pHlp->pfnSSMGetU8(pSSM, &pThis->u8LEDs); 1295 pHlp->pfnSSMGetU8(pSSM, &pThis->u8TypematicCfg); 1296 pHlp->pfnSSMGetU8(pSSM, &u8); 1367 1297 /* Reconstruct the 32-bit code from the 8-bit value in saved state. */ 1368 1298 pThis->u32TypematicKey = u8 ? RT_MAKE_U32(USB_HID_KB_PAGE, u8) : 0; 1369 SSMR3GetU8(pSSM, &pThis->u8Modifiers);1370 SSMR3GetU8(pSSM, &pThis->u8ScanSet);1371 SSMR3GetU8(pSSM, &u8);1299 pHlp->pfnSSMGetU8(pSSM, &pThis->u8Modifiers); 1300 pHlp->pfnSSMGetU8(pSSM, &pThis->u8ScanSet); 1301 pHlp->pfnSSMGetU8(pSSM, &u8); 1372 1302 pThis->enmTypematicState = (tmatic_state_t)u8; 1373 SSMR3GetBool(pSSM, &pThis->fNumLockOn);1374 SSMR3GetBool(pSSM, &pThis->fScanning);1303 pHlp->pfnSSMGetBool(pSSM, &pThis->fNumLockOn); 1304 pHlp->pfnSSMGetBool(pSSM, &pThis->fScanning); 1375 1305 1376 1306 /* Load the command and keystroke queues. */ 1377 rc = ps2kLoadQueue(pSSM, (GeneriQ *)&pThis->cmdQ);1307 rc = PS2CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ); 1378 1308 AssertRCReturn(rc, rc); 1379 rc = ps2kLoadQueue(pSSM, (GeneriQ *)&pThis->keyQ);1309 rc = PS2CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->keyQ); 1380 1310 AssertRCReturn(rc, rc); 1381 1311 … … 1388 1318 1389 1319 /* Fake key up events for keys that were held down at the time the state was saved. */ 1390 rc = SSMR3GetU32(pSSM, &cPressed);1320 rc = pHlp->pfnSSMGetU32(pSSM, &cPressed); 1391 1321 AssertRCReturn(rc, rc); 1392 1322 … … 1396 1326 for (unsigned i = 0; i < cPressed; ++i) 1397 1327 { 1398 rc = SSMR3GetU8(pSSM, &u8);1328 rc = pHlp->pfnSSMGetU8(pSSM, &u8); 1399 1329 AssertRCReturn(rc, rc); 1400 1330 pThis->abDepressedKeys[u8] = 1; … … 1403 1333 1404 1334 /* Load typematic settings for Scan Set 3. */ 1405 rc = SSMR3GetU32(pSSM, &cbTMSSize);1335 rc = pHlp->pfnSSMGetU32(pSSM, &cbTMSSize); 1406 1336 AssertRCReturn(rc, rc); 1407 1337 1408 1338 while (cbTMSSize--) 1409 1339 { 1410 rc = SSMR3GetU8(pSSM, &u8);1340 rc = pHlp->pfnSSMGetU8(pSSM, &u8); 1411 1341 AssertRCReturn(rc, rc); 1412 1342 } … … 1415 1345 } 1416 1346 1417 int PS2K LoadDone(PPS2K pThis, PSSMHANDLE pSSM)1347 int PS2KR3LoadDone(PPS2K pThis, PSSMHANDLE pSSM) 1418 1348 { 1419 1349 RT_NOREF(pSSM); … … 1422 1352 * interrupts and change the interrupt controller state. 1423 1353 */ 1424 ps2kR eleaseKeys(pThis);1425 ps2k NotifyLedsState(pThis, pThis->u8LEDs);1354 ps2kR3ReleaseKeys(pThis); 1355 ps2kR3NotifyLedsState(pThis, pThis->u8LEDs); 1426 1356 return VINF_SUCCESS; 1427 1357 } 1428 1358 1429 void PS2KR eset(PPS2K pThis)1359 void PS2KR3Reset(PPS2K pThis) 1430 1360 { 1431 1361 LogFlowFunc(("Resetting PS2K\n")); … … 1441 1371 /* Clear queues and any pressed keys. */ 1442 1372 memset(pThis->abDepressedKeys, 0, sizeof(pThis->abDepressedKeys)); 1443 ps2kClearQueue((GeneriQ *)&pThis->cmdQ);1373 PS2CmnClearQueue((GeneriQ *)&pThis->cmdQ); 1444 1374 ps2kSetDefaults(pThis); /* Also clears keystroke queue. */ 1445 1375 … … 1449 1379 } 1450 1380 1451 void PS2KR elocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)1381 void PS2KR3Relocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns) 1452 1382 { 1453 1383 RT_NOREF(pDevIns); … … 1459 1389 } 1460 1390 1461 int PS2KConstruct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg) 1462 { 1391 int PS2KR3Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg) 1392 { 1393 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1463 1394 RT_NOREF(pDevIns, iInstance); 1464 1395 LogFlowFunc(("iInstance=%u\n", iInstance)); … … 1467 1398 1468 1399 bool fThrottleEnabled; 1469 int rc = CFGMR3QueryBoolDef(pCfg, "KbdThrottleEnabled", &fThrottleEnabled, true);1400 int rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "KbdThrottleEnabled", &fThrottleEnabled, true); 1470 1401 if (RT_FAILURE(rc)) 1471 1402 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to query \"KbdThrottleEnabled\" from the config")); 1472 Log(("KbdThrottleEnabled=% u\n", fThrottleEnabled));1403 Log(("KbdThrottleEnabled=%RTbool\n", fThrottleEnabled)); 1473 1404 pThis->fThrottleEnabled = fThrottleEnabled; 1474 1405 … … 1477 1408 pThis->cmdQ.cSize = KBD_CMD_QUEUE_SIZE; 1478 1409 1479 pThis->Keyboard.IBase.pfnQueryInterface = ps2k QueryInterface;1480 pThis->Keyboard.IPort.pfnPutEventHid = ps2k PutEventWrapper;1410 pThis->Keyboard.IBase.pfnQueryInterface = ps2kR3QueryInterface; 1411 pThis->Keyboard.IPort.pfnPutEventHid = ps2kR3KeyboardPort_PutEventHid; 1481 1412 1482 1413 /* … … 1489 1420 */ 1490 1421 PTMTIMER pTimer; 1491 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2k ThrottleTimer, pThis,1422 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3ThrottleTimer, pThis, 1492 1423 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Throttle Timer", &pTimer); 1493 if (RT_FAILURE(rc)) 1494 return rc; 1424 AssertRCReturn(rc, rc); 1495 1425 1496 1426 pThis->pThrottleTimerR3 = pTimer; … … 1501 1431 * Create the typematic delay/repeat timer. 1502 1432 */ 1503 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2k TypematicTimer, pThis,1433 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3TypematicTimer, pThis, 1504 1434 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Typematic Timer", &pTimer); 1505 if (RT_FAILURE(rc)) 1506 return rc; 1435 AssertRCReturn(rc, rc); 1507 1436 1508 1437 pThis->pKbdTypematicTimerR3 = pTimer; … … 1513 1442 * Create the command delay timer. 1514 1443 */ 1515 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2k DelayTimer, pThis,1444 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3DelayTimer, pThis, 1516 1445 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Delay Timer", &pTimer); 1517 if (RT_FAILURE(rc)) 1518 return rc; 1446 AssertRCReturn(rc, rc); 1519 1447 1520 1448 pThis->pKbdDelayTimerR3 = pTimer; … … 1525 1453 * Register debugger info callbacks. 1526 1454 */ 1527 PDMDevHlpDBGFInfoRegister(pDevIns, "ps2k", "Display PS/2 keyboard state.", ps2k InfoState);1455 PDMDevHlpDBGFInfoRegister(pDevIns, "ps2k", "Display PS/2 keyboard state.", ps2kR3InfoState); 1528 1456 1529 1457 return rc; 1530 1458 } 1531 1459 1532 #endif 1460 #endif /* IN _RING3 */ 1533 1461 1534 1462 /// @todo The following should live with the KBC implementation. -
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.