Changeset 82208 in vbox
- Timestamp:
- Nov 25, 2019 11:41:15 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135022
- Location:
- trunk/src/VBox/Devices/Input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r82206 r82208 718 718 * Clear a queue. 719 719 * 720 * @param pQ Pointer to the queue. 721 */ 722 void PS2CmnClearQueue(GeneriQ *pQ) 723 { 724 LogFlowFunc(("Clearing queue %p\n", pQ)); 725 pQ->wpos = pQ->rpos; 726 pQ->cUsed = 0; 720 * @param pQHdr The queue header. 721 * @param cElements The queue size. 722 */ 723 void PS2CmnClearQueue(PPS2QHDR pQHdr, size_t cElements) 724 { 725 Assert(cElements > 0); 726 LogFlowFunc(("Clearing queue %p\n", pQHdr)); 727 pQHdr->wpos = pQHdr->rpos = pQHdr->rpos % cElements; 728 pQHdr->cUsed = 0; 727 729 } 728 730 … … 731 733 * Add a byte to a queue. 732 734 * 733 * @param pQ Pointer to the queue. 734 * @param val The byte to store. 735 */ 736 void PS2CmnInsertQueue(GeneriQ *pQ, uint8_t val) 737 { 738 /* Check if queue is full. */ 739 if (pQ->cUsed >= pQ->cSize) 740 { 741 LogRelFlowFunc(("queue %p full (%d entries)\n", pQ, pQ->cUsed)); 742 return; 743 } 744 /* Insert data and update circular buffer write position. */ 745 pQ->abQueue[pQ->wpos] = val; 746 if (++pQ->wpos == pQ->cSize) 747 pQ->wpos = 0; /* Roll over. */ 748 ++pQ->cUsed; 749 LogRelFlowFunc(("inserted 0x%02X into queue %p\n", val, pQ)); 735 * @param pQHdr The queue header. 736 * @param cElements The queue size. 737 * @param abElements The queue element array. 738 * @param bValue The byte to store. 739 */ 740 void PS2CmnInsertQueue(PPS2QHDR pQHdr, size_t cElements, uint8_t *pbElements, uint8_t bValue) 741 { 742 Assert(cElements > 0); 743 744 /* Check that the queue is not full. */ 745 uint32_t cUsed = pQHdr->cUsed; 746 if (cUsed < cElements) 747 { 748 /* Insert data and update circular buffer write position. */ 749 uint32_t wpos = pQHdr->wpos % cElements; 750 pbElements[wpos] = bValue; 751 752 wpos += 1; 753 if (wpos < cElements) 754 pQHdr->wpos = wpos; 755 else 756 pQHdr->wpos = 0; /* Roll over. */ 757 pQHdr->cUsed = cUsed + 1; 758 759 LogRelFlowFunc(("inserted %#04x into queue %p\n", bValue, pQHdr)); 760 } 761 else 762 { 763 Assert(cUsed == cElements); 764 LogRelFlowFunc(("queue %p full (%zu entries)\n", pQHdr, cElements)); 765 } 750 766 } 751 767 … … 753 769 * Retrieve a byte from a queue. 754 770 * 755 * @param pQ Pointer to the queue. 756 * @param pVal Pointer to storage for the byte. 771 * @param pQHdr The queue header. 772 * @param cElements The queue size. 773 * @param abElements The queue element array. 774 * @param pbValue Where to return the byte on success. 757 775 * 758 776 * @retval VINF_TRY_AGAIN if queue is empty, 759 777 * @retval VINF_SUCCESS if a byte was read. 760 778 */ 761 int PS2CmnRemoveQueue( GeneriQ *pQ, uint8_t *pVal)779 int PS2CmnRemoveQueue(PPS2QHDR pQHdr, size_t cElements, uint8_t const *pbElements, uint8_t *pbValue) 762 780 { 763 781 int rc; 764 782 765 Assert(pVal); 766 if (pQ->cUsed) 767 { 768 *pVal = pQ->abQueue[pQ->rpos]; 769 if (++pQ->rpos == pQ->cSize) 770 pQ->rpos = 0; /* Roll over. */ 771 --pQ->cUsed; 772 LogFlowFunc(("removed 0x%02X from queue %p\n", *pVal, pQ)); 783 Assert(cElements > 0); 784 Assert(pbValue); 785 786 uint32_t cUsed = (uint32_t)RT_MIN(pQHdr->cUsed, cElements); 787 if (cUsed > 0) 788 { 789 uint32_t rpos = pQHdr->rpos % cElements; 790 *pbValue = pbElements[rpos]; 791 792 rpos += 1; 793 if (rpos < cElements) 794 pQHdr->rpos = rpos; 795 else 796 pQHdr->rpos = 0; /* Roll over. */ 797 pQHdr->cUsed = cUsed - 1; 798 799 LogFlowFunc(("removed 0x%02X from queue %p\n", *pbValue, pQHdr)); 773 800 rc = VINF_SUCCESS; 774 801 } 775 802 else 776 803 { 777 LogFlowFunc(("queue %p empty\n", pQ ));804 LogFlowFunc(("queue %p empty\n", pQHdr)); 778 805 rc = VINF_TRY_AGAIN; 779 806 } … … 786 813 * Save a queue state. 787 814 * 788 * @param pHlp The device helpers. 789 * @param pSSM SSM handle to write the state to. 790 * @param pQ Pointer to the queue. 791 */ 792 void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ) 793 { 794 uint32_t cItems = pQ->cUsed; 795 uint32_t i; 815 * @param pHlp The device helpers. 816 * @param pSSM SSM handle to write the state to. 817 * @param pQHdr The queue header. 818 * @param cElements The queue size. 819 * @param abElements The queue element array. 820 */ 821 void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PPS2QHDR pQHdr, size_t cElements, uint8_t const *pbElements) 822 { 823 uint32_t cItems = (uint32_t)RT_MIN(pQHdr->cUsed, cElements); 796 824 797 825 /* Only save the number of items. Note that the read/write … … 800 828 pHlp->pfnSSMPutU32(pSSM, cItems); 801 829 802 LogFlow(("Storing % d items from queue %p\n", cItems, pQ));830 LogFlow(("Storing %u items from queue %p\n", cItems, pQHdr)); 803 831 804 832 /* Save queue data - only the bytes actually used (typically zero). */ 805 for ( i = pQ->rpos % pQ->cSize; cItems-- > 0; i = (i + 1) % pQ->cSize)806 pHlp->pfnSSMPutU8(pSSM, p Q->abQueue[i]);833 for (uint32_t i = pQHdr->rpos % cElements; cItems-- > 0; i = (i + 1) % cElements) 834 pHlp->pfnSSMPutU8(pSSM, pbElements[i]); 807 835 } 808 836 … … 810 838 * Load a queue state. 811 839 * 812 * @param pHlp The device helpers. 813 * @param pSSM SSM handle to read the state from. 814 * @param pQ Pointer to the queue. 840 * @param pHlp The device helpers. 841 * @param pSSM SSM handle to read the state from. 842 * @param pQHdr The queue header. 843 * @param cElements The queue size. 844 * @param abElements The queue element array. 815 845 * 816 846 * @returns VBox status/error code. 817 847 */ 818 int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ) 819 { 820 int rc; 821 848 int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PPS2QHDR pQHdr, size_t cElements, uint8_t *pbElements) 849 { 822 850 /* On load, always put the read pointer at zero. */ 823 rc = pHlp->pfnSSMGetU32(pSSM, &pQ->cUsed); 824 AssertRCReturn(rc, rc); 825 826 LogFlow(("Loading %d items to queue %p\n", pQ->cUsed, pQ)); 827 828 AssertMsgReturn(pQ->cUsed <= pQ->cSize, ("Saved size=%u, actual=%u\n", pQ->cUsed, pQ->cSize), 851 uint32_t cUsed; 852 int rc = pHlp->pfnSSMGetU32(pSSM, &cUsed); 853 AssertRCReturn(rc, rc); 854 855 LogFlow(("Loading %u items to queue %p\n", cUsed, pQHdr)); 856 857 AssertMsgReturn(cUsed <= cElements, ("Saved size=%u, actual=%zu\n", cUsed, cElements), 829 858 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 830 859 831 860 /* Recalculate queue positions and load data in one go. */ 832 pQ->rpos = 0; 833 pQ->wpos = pQ->cUsed; 834 return pHlp->pfnSSMGetMem(pSSM, pQ->abQueue, pQ->cUsed); 861 pQHdr->rpos = 0; 862 pQHdr->wpos = cUsed; 863 pQHdr->cUsed = cUsed; 864 return pHlp->pfnSSMGetMem(pSSM, pbElements, cUsed); 835 865 } 836 866 … … 1001 1031 PKBDSTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PKBDSTATER3); 1002 1032 int rc; 1033 RT_NOREF(iInstance); 1034 1003 1035 Assert(iInstance == 0); 1004 1036 … … 1012 1044 * Initialize the sub-components. 1013 1045 */ 1014 rc = PS2KR3Construct(pDevIns, &pThis->Kbd, &pThisCC->Kbd, iInstance,pCfg);1015 AssertRCReturn(rc, rc); 1016 1017 rc = PS2MR3Construct(pDevIns, &pThis->Aux, &pThisCC->Aux , iInstance);1046 rc = PS2KR3Construct(pDevIns, &pThis->Kbd, &pThisCC->Kbd, pCfg); 1047 AssertRCReturn(rc, rc); 1048 1049 rc = PS2MR3Construct(pDevIns, &pThis->Aux, &pThisCC->Aux); 1018 1050 AssertRCReturn(rc, rc); 1019 1051 -
trunk/src/VBox/Devices/Input/DevPS2.h
r82206 r82208 29 29 typedef struct KBDSTATE *PKBDSTATE; 30 30 31 32 /** @name PS/2 Input Queue Primitive 33 * @{ */ 34 typedef struct PS2QHDR 35 { 36 uint32_t volatile rpos; 37 uint32_t volatile wpos; 38 uint32_t volatile cUsed; 39 } PS2QHDR; 40 /** Pointer to a queue header. */ 41 typedef PS2QHDR *PPS2QHDR; 42 31 43 /** Define a simple PS/2 input device queue. */ 32 #define DEF_PS2Q_TYPE(name, size) \ 33 typedef struct { \ 34 uint32_t rpos; \ 35 uint32_t wpos; \ 36 uint32_t cUsed; \ 37 uint32_t cSize; \ 44 #define DEF_PS2Q_TYPE(name, size) \ 45 typedef struct { \ 46 PS2QHDR Hdr; \ 38 47 uint8_t abQueue[size]; \ 39 48 } name 40 49 41 DEF_PS2Q_TYPE(GeneriQ, 1); 42 void PS2CmnClearQueue(GeneriQ *pQ); 43 void PS2CmnInsertQueue(GeneriQ *pQ, uint8_t val); 44 int PS2CmnRemoveQueue(GeneriQ *pQ, uint8_t *pVal); 45 void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ); 46 int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, GeneriQ *pQ); 50 void PS2CmnClearQueue(PPS2QHDR pQHdr, size_t cElements); 51 void PS2CmnInsertQueue(PPS2QHDR pQHdr, size_t cElements, uint8_t *pbElements, uint8_t bValue); 52 int PS2CmnRemoveQueue(PPS2QHDR pQHdr, size_t cElements, uint8_t const *pbElements, uint8_t *pbValue); 53 void PS2CmnR3SaveQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PPS2QHDR pQHdr, size_t cElements, uint8_t const *pbElements); 54 int PS2CmnR3LoadQueue(PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM, PPS2QHDR pQHdr, size_t cElements, uint8_t *pbElements); 55 56 #define PS2Q_CLEAR(a_pQueue) \ 57 PS2CmnClearQueue(&(a_pQueue)->Hdr, RT_ELEMENTS((a_pQueue)->abQueue)) 58 #define PS2Q_INSERT(a_pQueue, a_bValue) \ 59 PS2CmnInsertQueue(&(a_pQueue)->Hdr, RT_ELEMENTS((a_pQueue)->abQueue), (a_pQueue)->abQueue, (a_bValue)) 60 #define PS2Q_REMOVE(a_pQueue, a_pbValue) \ 61 PS2CmnRemoveQueue(&(a_pQueue)->Hdr, RT_ELEMENTS((a_pQueue)->abQueue), (a_pQueue)->abQueue, (a_pbValue)) 62 #define PS2Q_SAVE(a_pHlp, a_pSSM, a_pQueue) \ 63 PS2CmnR3SaveQueue((a_pHlp), (a_pSSM), &(a_pQueue)->Hdr, RT_ELEMENTS((a_pQueue)->abQueue), (a_pQueue)->abQueue) 64 #define PS2Q_LOAD(a_pHlp, a_pSSM, a_pQueue) \ 65 PS2CmnR3LoadQueue((a_pHlp), (a_pSSM), &(a_pQueue)->Hdr, RT_ELEMENTS((a_pQueue)->abQueue), (a_pQueue)->abQueue) 66 #define PS2Q_SIZE(a_pQueue) RT_ELEMENTS((a_pQueue)->abQueue) 67 #define PS2Q_COUNT(a_pQueue) ((a_pQueue)->Hdr.cUsed) 68 #define PS2Q_RD_POS(a_pQueue) ((a_pQueue)->Hdr.rpos) 69 #define PS2Q_WR_POS(a_pQueue) ((a_pQueue)->Hdr.wpos) 70 /** @} */ 47 71 48 72 … … 173 197 int PS2KByteFromKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t *pVal); 174 198 175 int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, unsigned iInstance,PCFGMNODE pCfg);199 int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, PCFGMNODE pCfg); 176 200 int PS2KR3Attach(PPDMDEVINS pDevIns, PPS2KR3 pThisCC, unsigned iLUN, uint32_t fFlags); 177 201 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC); … … 317 341 int PS2MByteFromAux(PPS2M pThis, uint8_t *pVal); 318 342 319 int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC , unsigned iInstance);343 int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC); 320 344 int PS2MR3Attach(PPDMDEVINS pDevIns, PPS2MR3 pThisCC, unsigned iLUN, uint32_t fFlags); 321 345 void PS2MR3Reset(PPS2M pThis); -
trunk/src/VBox/Devices/Input/DevPS2K.cpp
r82206 r82208 380 380 * Add a null-terminated byte sequence to a queue if there is enough room. 381 381 * 382 * @param pQ Pointer to the queue. 383 * @param pStr Pointer to the bytes to store. 384 * @param uReserve Number of bytes that must still remain 385 * available in queue. 386 * @return int VBox status/error code. 387 */ 388 static int ps2kR3InsertStrQueue(GeneriQ *pQ, const uint8_t *pStr, uint32_t uReserve) 389 { 390 uint32_t cbStr; 391 unsigned i; 392 393 cbStr = (uint32_t)strlen((const char *)pStr); 394 382 * @param pQueue Pointer to the queue. 383 * @param pStr Pointer to the bytes to store. 384 * @param cbReserve Number of bytes that must still remain available in 385 * queue. 386 * @return VBox status/error code. 387 */ 388 static int ps2kR3InsertStrQueue(KbdKeyQ *pQueue, const uint8_t *pStr, uint32_t cbReserve) 389 { 395 390 /* Check if queue has enough room. */ 396 if (pQ->cUsed + uReserve + cbStr >= pQ->cSize) 397 { 398 LogRelFlowFunc(("queue %p full (%u entries, want room for %u), cannot insert %u entries\n", 399 pQ, pQ->cUsed, uReserve, cbStr)); 391 size_t const cbStr = (uint32_t)strlen((const char *)pStr); 392 uint32_t cUsed = RT_MIN(pQueue->Hdr.cUsed, RT_ELEMENTS(pQueue->abQueue)); 393 if (cUsed + cbReserve + cbStr >= RT_ELEMENTS(pQueue->abQueue)) 394 { 395 LogRelFlowFunc(("queue %p (KbdKeyQ) full (%u entries, want room for %u), cannot insert %zu entries\n", 396 pQueue, cUsed, cbReserve, cbStr)); 400 397 return VERR_BUFFER_OVERFLOW; 401 398 } 402 399 403 400 /* Insert byte sequence and update circular buffer write position. */ 404 for (i = 0; i < cbStr; ++i) { 405 pQ->abQueue[pQ->wpos] = pStr[i]; 406 if (++pQ->wpos == pQ->cSize) 407 pQ->wpos = 0; /* Roll over. */ 408 } 409 pQ->cUsed += cbStr; 410 LogRelFlowFunc(("inserted %u bytes into queue %p\n", cbStr, pQ)); 401 uint32_t wpos = pQueue->Hdr.wpos % RT_ELEMENTS(pQueue->abQueue); 402 for (size_t i = 0; i < cbStr; i++) 403 { 404 pQueue->abQueue[wpos] = pStr[i]; 405 wpos += 1; 406 if (wpos < RT_ELEMENTS(pQueue->abQueue)) 407 { /* likely */ } 408 else 409 wpos = 0; /* Roll over. */ 410 } 411 412 pQueue->Hdr.wpos = wpos; 413 pQueue->Hdr.cUsed = cUsed + (uint32_t)cbStr; 414 415 LogRelFlowFunc(("inserted %u bytes into queue %p (KbdKeyQ)\n", cbStr, pQueue)); 411 416 return VINF_SUCCESS; 412 417 } … … 430 435 431 436 pThisCC->Keyboard.pDrv->pfnLedStatusChange(pThisCC->Keyboard.pDrv, enmLeds); 432 }433 434 /**435 * Query the number of items currently in a queue.436 *437 * @param pQ Pointer to the queue.438 *439 * @return uint32_t Number of items in queue.440 */441 static uint32_t ps2R3kInQueue(GeneriQ *pQ)442 {443 return pQ->cUsed;444 437 } 445 438 … … 481 474 { 482 475 LogFlowFunc(("Set keyboard defaults\n")); 483 PS2 CmnClearQueue((GeneriQ *)&pThis->keyQ);476 PS2Q_CLEAR(&pThis->keyQ); 484 477 /* Set default Scan Set 3 typematic values. */ 485 478 /* Set default typematic rate/delay. */ … … 509 502 { 510 503 case KCMD_ECHO: 511 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ECHO);504 PS2Q_INSERT(&pThis->cmdQ, KRSP_ECHO); 512 505 pThis->u8CurrCmd = 0; 513 506 break; 514 507 case KCMD_READ_ID: 515 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);516 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ID1);517 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ID2);508 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 509 PS2Q_INSERT(&pThis->cmdQ, KRSP_ID1); 510 PS2Q_INSERT(&pThis->cmdQ, KRSP_ID2); 518 511 pThis->u8CurrCmd = 0; 519 512 break; 520 513 case KCMD_ENABLE: 521 514 pThis->fScanning = true; 522 PS2 CmnClearQueue((GeneriQ *)&pThis->keyQ);515 PS2Q_CLEAR(&pThis->keyQ); 523 516 ps2kStopTypematicRepeat(pDevIns, pThis); 524 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);517 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 525 518 pThis->u8CurrCmd = 0; 526 519 break; … … 528 521 pThis->fScanning = false; 529 522 ps2kSetDefaults(pDevIns, pThis); /* Also clears buffer/typematic state. */ 530 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);523 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 531 524 pThis->u8CurrCmd = 0; 532 525 break; 533 526 case KCMD_SET_DEFAULT: 534 527 ps2kSetDefaults(pDevIns, pThis); 535 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);528 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 536 529 pThis->u8CurrCmd = 0; 537 530 break; … … 541 534 case KCMD_ALL_TMB: 542 535 /// @todo Set the key types here. 543 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);536 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 544 537 pThis->u8CurrCmd = 0; 545 538 break; … … 551 544 ps2kSetDefaults(pDevIns, pThis); 552 545 /// @todo reset more? 553 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);546 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 554 547 pThis->u8CurrCmd = cmd; 555 548 /* Delay BAT completion; the test may take hundreds of ms. */ … … 563 556 case KCMD_TYPE_MK_BRK: 564 557 case KCMD_TYPE_MAKE: 565 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);558 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 566 559 pThis->u8CurrCmd = cmd; 567 560 break; … … 578 571 ps2kR3NotifyLedsState(pThisCC, cmd); 579 572 pThis->fNumLockOn = !!(cmd & 0x02); /* Sync internal Num Lock state. */ 580 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);573 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 581 574 pThis->u8LEDs = cmd; 582 575 pThis->u8CurrCmd = 0; … … 585 578 break; 586 579 case KCMD_SCANSET: 587 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);580 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 588 581 if (cmd == 0) 589 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8ScanSet);582 PS2Q_INSERT(&pThis->cmdQ, pThis->u8ScanSet); 590 583 else if (cmd < 4) 591 584 { … … 598 591 case KCMD_RATE_DELAY: 599 592 ps2kSetupTypematic(pThis, cmd); 600 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK);593 PS2Q_INSERT(&pThis->cmdQ, KRSP_ACK); 601 594 pThis->u8CurrCmd = 0; 602 595 break; … … 611 604 case KCMD_INVALID_1: 612 605 case KCMD_INVALID_2: 613 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_RESEND);606 PS2Q_INSERT(&pThis->cmdQ, KRSP_RESEND); 614 607 pThis->u8CurrCmd = 0; 615 608 break; … … 640 633 * the command queue is empty. 641 634 */ 642 rc = PS2 CmnRemoveQueue((GeneriQ *)&pThis->cmdQ, pb);635 rc = PS2Q_REMOVE(&pThis->cmdQ, pb); 643 636 if (rc != VINF_SUCCESS && !pThis->u8CurrCmd && pThis->fScanning) 644 637 if (!pThis->fThrottleActive) 645 638 { 646 rc = PS2 CmnRemoveQueue((GeneriQ *)&pThis->keyQ, pb);639 rc = PS2Q_REMOVE(&pThis->keyQ, pb); 647 640 if (pThis->fThrottleEnabled) 648 641 { … … 800 793 /* Feed the bytes to the queue if there is room. */ 801 794 /// @todo Send overrun code if sequence won't fit? 802 ps2kR3InsertStrQueue( (GeneriQ *)&pThis->keyQ, abCodes, 0);795 ps2kR3InsertStrQueue(&pThis->keyQ, abCodes, 0); 803 796 } 804 797 else if (!(pKeyDef->keyFlags & (KF_NB | KF_PB))) … … 855 848 /* Feed the bytes to the queue if there is room. */ 856 849 /// @todo Send overrun code if sequence won't fit? 857 ps2kR3InsertStrQueue( (GeneriQ *)&pThis->keyQ, abCodes, 0);850 ps2kR3InsertStrQueue(&pThis->keyQ, abCodes, 0); 858 851 } 859 852 } … … 880 873 /* Feed the bytes to the queue if there is room. */ 881 874 /// @todo Send overrun code if sequence won't fit? 882 ps2kR3InsertStrQueue( (GeneriQ *)&pThis->keyQ, abCodes, 0);875 ps2kR3InsertStrQueue(&pThis->keyQ, abCodes, 0); 883 876 } 884 877 … … 948 941 */ 949 942 pThis->fThrottleActive = false; 950 uHaveData = ps2R3kInQueue((GeneriQ *)&pThis->keyQ);943 uHaveData = PS2Q_COUNT(&pThis->keyQ); 951 944 LogFlowFunc(("Have%s bytes\n", uHaveData ? "" : " no")); 952 945 if (uHaveData) … … 998 991 999 992 AssertMsg(pThis->u8CurrCmd == KCMD_RESET, ("u8CurrCmd=%02x\n", pThis->u8CurrCmd)); 1000 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_BAT_OK);993 PS2Q_INSERT(&pThis->cmdQ, KRSP_BAT_OK); 1001 994 pThis->fScanning = true; /* BAT completion enables scanning! */ 1002 995 pThis->u8CurrCmd = 0; … … 1046 1039 pThis->uTypematicDelay, pThis->uTypematicRepeat); 1047 1040 pHlp->pfnPrintf(pHlp, "Command queue: %d items (%d max)\n", 1048 pThis->cmdQ.cUsed, pThis->cmdQ.cSize);1041 PS2Q_COUNT(&pThis->cmdQ), PS2Q_SIZE(&pThis->cmdQ)); 1049 1042 pHlp->pfnPrintf(pHlp, "Input queue : %d items (%d max)\n", 1050 pThis->keyQ.cUsed, pThis->keyQ.cSize);1043 PS2Q_COUNT(&pThis->keyQ), PS2Q_SIZE(&pThis->keyQ)); 1051 1044 if (pThis->enmTypematicState != KBD_TMS_IDLE) 1052 1045 pHlp->pfnPrintf(pHlp, "Active typematic key %08X (%s)\n", pThis->u32TypematicKey, … … 1224 1217 1225 1218 /* Save the command and keystroke queues. */ 1226 PS2 CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ);1227 PS2 CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->keyQ);1219 PS2Q_SAVE(pHlp, pSSM, &pThis->cmdQ); 1220 PS2Q_SAVE(pHlp, pSSM, &pThis->keyQ); 1228 1221 1229 1222 /* Save the command delay timer. Note that the typematic repeat … … 1276 1269 1277 1270 /* Load the command and keystroke queues. */ 1278 rc = PS2 CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ);1271 rc = PS2Q_LOAD(pHlp, pSSM, &pThis->cmdQ); 1279 1272 AssertRCReturn(rc, rc); 1280 rc = PS2 CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->keyQ);1273 rc = PS2Q_LOAD(pHlp, pSSM, &pThis->keyQ); 1281 1274 AssertRCReturn(rc, rc); 1282 1275 … … 1340 1333 /* Clear queues and any pressed keys. */ 1341 1334 memset(pThis->abDepressedKeys, 0, sizeof(pThis->abDepressedKeys)); 1342 PS2 CmnClearQueue((GeneriQ *)&pThis->cmdQ);1335 PS2Q_CLEAR(&pThis->cmdQ); 1343 1336 ps2kSetDefaults(pDevIns, pThis); /* Also clears keystroke queue. */ 1344 1337 … … 1348 1341 } 1349 1342 1350 int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, unsigned iInstance, PCFGMNODE pCfg) 1351 { 1343 int PS2KR3Construct(PPDMDEVINS pDevIns, PPS2K pThis, PPS2KR3 pThisCC, PCFGMNODE pCfg) 1344 { 1345 LogFlowFunc(("\n")); 1352 1346 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1353 RT_NOREF(pDevIns, iInstance); 1354 LogFlowFunc(("iInstance=%u\n", iInstance)); 1355 1356 pThisCC->pDevIns = pDevIns; 1357 1347 1348 /* 1349 * Read configuration. 1350 */ 1358 1351 bool fThrottleEnabled; 1359 1352 int rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "KbdThrottleEnabled", &fThrottleEnabled, true); … … 1363 1356 pThis->fThrottleEnabled = fThrottleEnabled; 1364 1357 1365 /* Initialize the queues. */1366 pThis->keyQ.cSize = KBD_KEY_QUEUE_SIZE;1367 pThis->cmdQ.cSize = KBD_CMD_QUEUE_SIZE;1368 1358 /* 1359 * Initialize state. 1360 */ 1361 pThisCC->pDevIns = pDevIns; 1369 1362 pThisCC->Keyboard.IBase.pfnQueryInterface = ps2kR3QueryInterface; 1370 1363 pThisCC->Keyboard.IPort.pfnPutEventHid = ps2kR3KeyboardPort_PutEventHid; … … 1374 1367 */ 1375 1368 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3ThrottleTimer, pThis, 1376 1369 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Throttle Timer", &pThis->hThrottleTimer); 1377 1370 AssertRCReturn(rc, rc); 1378 1371 -
trunk/src/VBox/Devices/Input/DevPS2M.cpp
r82206 r82208 219 219 static void ps2mR3Reset(PPS2M pThis, PPS2MR3 pThisCC) 220 220 { 221 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_BAT_OK);222 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, 0);221 PS2Q_INSERT(&pThis->cmdQ, ARSP_BAT_OK); 222 PS2Q_INSERT(&pThis->cmdQ, 0); 223 223 pThis->enmMode = AUX_MODE_STD; 224 224 pThis->u8CurrCmd = 0; … … 250 250 251 251 /* Event queue, eccumulators, and button status bits are cleared. */ 252 PS2 CmnClearQueue((GeneriQ *)&pThis->evtQ);252 PS2Q_CLEAR(&pThis->evtQ); 253 253 pThis->iAccumX = pThis->iAccumY = pThis->iAccumZ = pThis->iAccumW = pThis->fAccumB = 0; 254 254 } … … 306 306 #define PS2M_IMEX_BTN_MASK (RT_BIT(3) | RT_BIT(4)) 307 307 308 /* Report accumulated movement and button presses, then clear the accumulators. */309 static void ps2mReportAccumulatedEvents(PPS2M pThis, GeneriQ *pQueue, bool fAccumBtns)308 /** Report accumulated movement and button presses, then clear the accumulators. */ 309 static void ps2mReportAccumulatedEvents(PPS2M pThis, PPS2QHDR pQHdr, size_t cQElements, uint8_t *pbQElements, bool fAccumBtns) 310 310 { 311 311 uint32_t fBtnState = fAccumBtns ? pThis->fAccumB : pThis->fCurrB; … … 326 326 327 327 /* Send the standard 3-byte packet (always the same). */ 328 PS2CmnInsertQueue(pQ ueue, val);329 PS2CmnInsertQueue(pQ ueue, dX);330 PS2CmnInsertQueue(pQ ueue, dY);328 PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, val); 329 PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, dX); 330 PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, dY); 331 331 332 332 /* Add fourth byte if an extended protocol is in use. */ … … 339 339 { 340 340 /* NB: Only uses 4-bit dZ range, despite using a full byte. */ 341 PS2CmnInsertQueue(pQ ueue, dZ);341 PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, dZ); 342 342 pThis->iAccumZ -= dZ; 343 343 } … … 348 348 val |= dZ & 0x0f; 349 349 pThis->iAccumZ -= dZ; 350 PS2CmnInsertQueue(pQ ueue, val);350 PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, val); 351 351 } 352 352 else … … 380 380 val = (fBtnState & PS2M_IMEX_BTN_MASK) << 1; 381 381 } 382 PS2CmnInsertQueue(pQ ueue, val);382 PS2CmnInsertQueue(pQHdr, cQElements, pbQElements, val); 383 383 } 384 384 } … … 431 431 432 432 /* If there's anything left in the command response queue, trash it. */ 433 PS2 CmnClearQueue((GeneriQ *)&pThis->cmdQ);433 PS2Q_CLEAR(&pThis->cmdQ); 434 434 435 435 if (pThis->enmMode == AUX_MODE_WRAP) … … 440 440 else 441 441 { 442 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, cmd);442 PS2Q_INSERT(&pThis->cmdQ, cmd); 443 443 return VINF_SUCCESS; 444 444 } … … 455 455 case ACMD_SET_SCALE_11: 456 456 pThis->u8State &= ~AUX_STATE_SCALING; 457 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);457 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 458 458 pThis->u8CurrCmd = 0; 459 459 break; 460 460 case ACMD_SET_SCALE_21: 461 461 pThis->u8State |= AUX_STATE_SCALING; 462 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);462 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 463 463 pThis->u8CurrCmd = 0; 464 464 break; … … 466 466 /* Report current status, sample rate, and resolution. */ 467 467 u8Val = (pThis->u8State & AUX_STATE_EXTERNAL) | (pThis->fCurrB & PS2M_STD_BTN_MASK); 468 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);469 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);470 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8Resolution);471 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, pThis->u8SampleRate);468 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 469 PS2Q_INSERT(&pThis->cmdQ, u8Val); 470 PS2Q_INSERT(&pThis->cmdQ, pThis->u8Resolution); 471 PS2Q_INSERT(&pThis->cmdQ, pThis->u8SampleRate); 472 472 pThis->u8CurrCmd = 0; 473 473 break; 474 474 case ACMD_SET_STREAM: 475 475 pThis->u8State &= ~AUX_STATE_REMOTE; 476 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);476 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 477 477 pThis->u8CurrCmd = 0; 478 478 break; 479 479 case ACMD_READ_REMOTE: 480 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);481 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->cmdQ, false);480 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 481 ps2mReportAccumulatedEvents(pThis, &pThis->cmdQ.Hdr, RT_ELEMENTS(pThis->cmdQ.abQueue), pThis->cmdQ.abQueue, false); 482 482 pThis->u8CurrCmd = 0; 483 483 break; … … 485 485 pThis->enmMode = AUX_MODE_STD; 486 486 /* NB: Stream mode reporting remains disabled! */ 487 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);487 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 488 488 pThis->u8CurrCmd = 0; 489 489 break; … … 491 491 pThis->enmMode = AUX_MODE_WRAP; 492 492 pThis->u8State &= ~AUX_STATE_ENABLED; 493 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);493 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 494 494 pThis->u8CurrCmd = 0; 495 495 break; 496 496 case ACMD_SET_REMOTE: 497 497 pThis->u8State |= AUX_STATE_REMOTE; 498 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);498 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 499 499 pThis->u8CurrCmd = 0; 500 500 break; 501 501 case ACMD_READ_ID: 502 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);502 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 503 503 /* ImEx + horizontal is protocol 4, just like plain ImEx. */ 504 504 u8Val = pThis->enmProtocol == PS2M_PROTO_IMEX_HORZ ? PS2M_PROTO_IMEX : pThis->enmProtocol; 505 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, u8Val);505 PS2Q_INSERT(&pThis->cmdQ, u8Val); 506 506 pThis->u8CurrCmd = 0; 507 507 break; … … 513 513 AssertLogRelMsgFailed(("Invalid ACMD_ENABLE outside R3!\n")); 514 514 #endif 515 PS2 CmnClearQueue((GeneriQ *)&pThis->evtQ);516 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);515 PS2Q_CLEAR(&pThis->evtQ); 516 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 517 517 pThis->u8CurrCmd = 0; 518 518 break; 519 519 case ACMD_DISABLE: 520 520 pThis->u8State &= ~AUX_STATE_ENABLED; 521 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);521 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 522 522 pThis->u8CurrCmd = 0; 523 523 break; 524 524 case ACMD_SET_DEFAULT: 525 525 ps2mSetDefaults(pThis); 526 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);526 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 527 527 pThis->u8CurrCmd = 0; 528 528 break; … … 535 535 pThis->u8CurrCmd = cmd; 536 536 pThis->enmMode = AUX_MODE_RESET; 537 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);537 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 538 538 if (pThis->fDelayReset) 539 539 /* Slightly delay reset completion; it might take hundreds of ms. */ … … 549 549 case ACMD_SET_RES: 550 550 case ACMD_SET_SAMP_RATE: 551 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);551 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 552 552 pThis->u8CurrCmd = cmd; 553 553 break; … … 561 561 pThis->u8Resolution = cmd; 562 562 pThis->u8State &= ~AUX_STATE_RES_ERR; 563 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);563 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 564 564 pThis->u8CurrCmd = 0; 565 565 } … … 570 570 { 571 571 pThis->u8State &= ~AUX_STATE_RES_ERR; 572 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);572 PS2Q_INSERT(&pThis->cmdQ, ARSP_ERROR); 573 573 pThis->u8CurrCmd = 0; 574 574 } … … 576 576 { 577 577 pThis->u8State |= AUX_STATE_RES_ERR; 578 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);578 PS2Q_INSERT(&pThis->cmdQ, ARSP_RESEND); 579 579 /* NB: Current command remains unchanged. */ 580 580 } … … 587 587 ps2mSetRate(pThis, cmd); 588 588 ps2mRateProtocolKnock(pThis, cmd); 589 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ACK);589 PS2Q_INSERT(&pThis->cmdQ, ARSP_ACK); 590 590 pThis->u8CurrCmd = 0; 591 591 } … … 596 596 { 597 597 pThis->u8State &= ~AUX_STATE_RATE_ERR; 598 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_ERROR);598 PS2Q_INSERT(&pThis->cmdQ, ARSP_ERROR); 599 599 pThis->u8CurrCmd = 0; 600 600 } … … 602 602 { 603 603 pThis->u8State |= AUX_STATE_RATE_ERR; 604 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);604 PS2Q_INSERT(&pThis->cmdQ, ARSP_RESEND); 605 605 /* NB: Current command remains unchanged. */ 606 606 } … … 626 626 case ACMD_INVALID_10: 627 627 Log(("Unsupported command 0x%02X!\n", cmd)); 628 PS2 CmnInsertQueue((GeneriQ *)&pThis->cmdQ, ARSP_RESEND);628 PS2Q_INSERT(&pThis->cmdQ, ARSP_RESEND); 629 629 pThis->u8CurrCmd = 0; 630 630 break; … … 654 654 */ 655 655 /// @todo Probably should flush/not fill queue if stream mode reporting disabled?! 656 rc = PS2 CmnRemoveQueue((GeneriQ *)&pThis->cmdQ, pb);656 rc = PS2Q_REMOVE(&pThis->cmdQ, pb); 657 657 if (rc != VINF_SUCCESS && !pThis->u8CurrCmd && (pThis->u8State & AUX_STATE_ENABLED)) 658 rc = PS2 CmnRemoveQueue((GeneriQ *)&pThis->evtQ, pb);658 rc = PS2Q_REMOVE(&pThis->evtQ, pb); 659 659 660 660 LogFlowFunc(("mouse sends 0x%02x (%svalid data)\n", *pb, rc == VINF_SUCCESS ? "" : "not ")); … … 693 693 { 694 694 /* Report accumulated data, poke the KBC, and start the timer. */ 695 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->evtQ, true);695 ps2mReportAccumulatedEvents(pThis, &pThis->evtQ.Hdr, RT_ELEMENTS(pThis->evtQ.abQueue), pThis->evtQ.abQueue, true); 696 696 KBCUpdateInterrupts(pDevIns); 697 697 PDMDevHlpTimerSetMillies(pDevIns, pThis->hThrottleTimer, pThis->uThrottleDelay); … … 755 755 pThis->u8SampleRate, 1 << pThis->u8Resolution); 756 756 pHlp->pfnPrintf(pHlp, "Command queue: %d items (%d max)\n", 757 pThis->cmdQ.cUsed, pThis->cmdQ.cSize);757 PS2Q_COUNT(&pThis->cmdQ), PS2Q_SIZE(&pThis->cmdQ)); 758 758 pHlp->pfnPrintf(pHlp, "Event queue : %d items (%d max)\n", 759 pThis->evtQ.cUsed, pThis->evtQ.cSize);759 PS2Q_COUNT(&pThis->evtQ), PS2Q_SIZE(&pThis->evtQ)); 760 760 } 761 761 … … 804 804 if (!pThis->fThrottleActive && ps2mR3HaveEvents(pThis)) 805 805 { 806 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->evtQ, true);806 ps2mReportAccumulatedEvents(pThis, &pThis->evtQ.Hdr, RT_ELEMENTS(pThis->evtQ.abQueue), pThis->evtQ.abQueue, true); 807 807 KBCUpdateInterrupts(pDevIns); 808 808 pThis->fThrottleActive = true; … … 936 936 937 937 /* Save the command and event queues. */ 938 PS2 CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ);939 PS2 CmnR3SaveQueue(pHlp, pSSM, (GeneriQ *)&pThis->evtQ);938 PS2Q_SAVE(pHlp, pSSM, &pThis->cmdQ); 939 PS2Q_SAVE(pHlp, pSSM, &pThis->evtQ); 940 940 941 941 /* Save the command delay timer. Note that the rate throttling … … 967 967 968 968 /* Load the command and event queues. */ 969 rc = PS2 CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->cmdQ);969 rc = PS2Q_LOAD(pHlp, pSSM, &pThis->cmdQ); 970 970 AssertRCReturn(rc, rc); 971 rc = PS2 CmnR3LoadQueue(pHlp, pSSM, (GeneriQ *)&pThis->evtQ);971 rc = PS2Q_LOAD(pHlp, pSSM, &pThis->evtQ); 972 972 AssertRCReturn(rc, rc); 973 973 … … 1006 1006 1007 1007 /* Clear the queues. */ 1008 PS2 CmnClearQueue((GeneriQ *)&pThis->cmdQ);1008 PS2Q_CLEAR(&pThis->cmdQ); 1009 1009 ps2mSetDefaults(pThis); /* Also clears event queue. */ 1010 1010 } 1011 1011 1012 int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC, unsigned iInstance) 1013 { 1014 RT_NOREF(iInstance); 1015 1016 LogFlowFunc(("iInstance=%u\n", iInstance)); 1017 1012 int PS2MR3Construct(PPDMDEVINS pDevIns, PPS2M pThis, PPS2MR3 pThisCC) 1013 { 1014 LogFlowFunc(("\n")); 1018 1015 #ifdef RT_STRICT 1019 1016 ps2mR3TestAccumulation(); 1020 1017 #endif 1021 1018 1022 pThisCC->pDevIns = pDevIns; 1023 1024 /* Initialize the queues. */ 1025 pThis->evtQ.cSize = AUX_EVT_QUEUE_SIZE; 1026 pThis->cmdQ.cSize = AUX_CMD_QUEUE_SIZE; 1027 1019 /* 1020 * Initialize the state. 1021 */ 1022 pThisCC->pDevIns = pDevIns; 1028 1023 pThisCC->Mouse.IBase.pfnQueryInterface = ps2mR3QueryInterface; 1029 1024 pThisCC->Mouse.IPort.pfnPutEvent = ps2mR3MousePort_PutEvent; … … 1077 1072 1078 1073 RT_ZERO(This); 1079 This.evtQ.cSize = AUX_EVT_QUEUE_SIZE;1080 1074 This.u8State = AUX_STATE_ENABLED; 1081 1075 This.fThrottleActive = true; … … 1085 1079 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1); 1086 1080 if (ps2mR3HaveEvents(&This)) 1087 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);1081 ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true); 1088 1082 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 0); 1089 1083 if (ps2mR3HaveEvents(&This)) 1090 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);1084 ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true); 1091 1085 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1); 1092 1086 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 0); 1093 1087 if (ps2mR3HaveEvents(&This)) 1094 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);1088 ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true); 1095 1089 if (ps2mR3HaveEvents(&This)) 1096 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);1090 ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true); 1097 1091 for (i = 0; i < 12; ++i) 1098 1092 { … … 1109 1103 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1); 1110 1104 if (ps2mR3HaveEvents(&This)) 1111 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);1105 ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true); 1112 1106 if (ps2mR3HaveEvents(&This)) 1113 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);1107 ps2mReportAccumulatedEvents(&This, &This.evtQ.Hdr, RT_ELEMENTS(This.evtQ.abQueue), This.evtQ.abQueue, true); 1114 1108 for (i = 0; i < 3; ++i) 1115 1109 {
Note:
See TracChangeset
for help on using the changeset viewer.