Changeset 82195 in vbox
- Timestamp:
- Nov 25, 2019 7:12:32 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135009
- Location:
- trunk/src/VBox/Devices/Input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r82191 r82195 217 217 218 218 219 /* update irq and KBD_STAT_[MOUSE_]OBF */220 static void kbd_update_irq( KBDState *s)219 /** update irq and KBD_STAT_[MOUSE_]OBF */ 220 static void kbd_update_irq(PPDMDEVINS pDevIns, KBDState *s) 221 221 { 222 222 int irq12_level, irq1_level; … … 233 233 s->status &= ~KBD_STAT_MOUSE_OBF; 234 234 /* Keyboard data has priority if both kbd and aux data is available. */ 235 if (!(s->mode & KBD_MODE_DISABLE_KBD) && PS2KByteFromKbd( &s->Kbd, &val) == VINF_SUCCESS)235 if (!(s->mode & KBD_MODE_DISABLE_KBD) && PS2KByteFromKbd(pDevIns, &s->Kbd, &val) == VINF_SUCCESS) 236 236 { 237 237 bool fHaveData = true; … … 248 248 * and we keep going until the state changes or there's no more data. 249 249 */ 250 while (s->xlat_state == XS_BREAK && PS2KByteFromKbd( &s->Kbd, &val) == VINF_SUCCESS)250 while (s->xlat_state == XS_BREAK && PS2KByteFromKbd(pDevIns, &s->Kbd, &val) == VINF_SUCCESS) 251 251 { 252 252 s->xlat_state = kbcXlateAT2PC(s->xlat_state, val, &xlated_val); … … 286 286 } 287 287 288 void KBCUpdateInterrupts(void *pKbc) 289 { 290 KBDState *s = (KBDState *)pKbc; 291 kbd_update_irq(s); 292 } 293 294 static void kbc_dbb_out(void *opaque, uint8_t val) 295 { 296 KBDState *s = (KBDState*)opaque; 297 288 void KBCUpdateInterrupts(PPDMDEVINS pDevIns) 289 { 290 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 291 kbd_update_irq(pDevIns, pThis); 292 } 293 294 static void kbc_dbb_out(PKBDSTATE s, uint8_t val) 295 { 298 296 s->dbbout = val; 299 297 /* Set the OBF and raise IRQ. */ … … 303 301 } 304 302 305 static void kbc_dbb_out_aux(void *opaque, uint8_t val) 306 { 307 KBDState *s = (KBDState*)opaque; 308 303 static void kbc_dbb_out_aux(PKBDSTATE s, uint8_t val) 304 { 309 305 s->dbbout = val; 310 306 /* Set the aux OBF and raise IRQ. */ … … 314 310 } 315 311 316 static uint32_t kbd_read_status(void *opaque, uint32_t addr) 317 { 318 KBDState *s = (KBDState*)opaque; 312 static uint32_t kbd_read_status(PKBDSTATE s, uint32_t addr) 313 { 319 314 int val = s->status; 320 315 NOREF(addr); … … 326 321 } 327 322 328 static int kbd_write_command( void *opaque, uint32_t addr, uint32_t val)323 static int kbd_write_command(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t addr, uint32_t val) 329 324 { 330 325 int rc = VINF_SUCCESS; 331 KBDState *s = (KBDState*)opaque;332 326 NOREF(addr); 333 327 … … 352 346 s->mode &= ~KBD_MODE_DISABLE_MOUSE; 353 347 /* Check for queued input. */ 354 kbd_update_irq( s);348 kbd_update_irq(pDevIns, s); 355 349 break; 356 350 case KBD_CCMD_TEST_MOUSE: … … 381 375 s->mode &= ~KBD_MODE_DISABLE_KBD; 382 376 /* Check for queued input. */ 383 kbd_update_irq( s);377 kbd_update_irq(pDevIns, s); 384 378 break; 385 379 case KBD_CCMD_READ_INPORT: … … 453 447 } 454 448 455 static uint32_t kbd_read_data(void *opaque, uint32_t addr) 456 { 457 KBDState *s = (KBDState*)opaque; 449 static uint32_t kbd_read_data(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t addr) 450 { 458 451 uint32_t val; 459 452 NOREF(addr); … … 471 464 472 465 /* Check if more data is available. */ 473 kbd_update_irq( s);466 kbd_update_irq(pDevIns, s); 474 467 #ifdef DEBUG_KBD 475 468 Log(("kbd: read data=0x%02x\n", val)); … … 480 473 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns) 481 474 { 482 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);475 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 483 476 return &pThis->Kbd; 484 477 } … … 486 479 PS2M *KBDGetPS2MFromDevIns(PPDMDEVINS pDevIns) 487 480 { 488 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);481 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 489 482 return &pThis->Aux; 490 483 } 491 484 492 static int kbd_write_data( void *opaque, uint32_t addr, uint32_t val)485 static int kbd_write_data(PPDMDEVINS pDevIns, PKBDSTATE s, uint32_t addr, uint32_t val) 493 486 { 494 487 int rc = VINF_SUCCESS; 495 KBDState *s = (KBDState*)opaque;496 488 NOREF(addr); 497 489 … … 504 496 /* Automatically enables keyboard interface. */ 505 497 s->mode &= ~KBD_MODE_DISABLE_KBD; 506 rc = PS2KByteToKbd( &s->Kbd, val);498 rc = PS2KByteToKbd(pDevIns, &s->Kbd, val); 507 499 if (rc == VINF_SUCCESS) 508 kbd_update_irq( s);500 kbd_update_irq(pDevIns, s); 509 501 break; 510 502 case KBD_CCMD_WRITE_MODE: 511 503 s->mode = val; 512 504 s->translate = (s->mode & KBD_MODE_KCC) == KBD_MODE_KCC; 513 kbd_update_irq( s);505 kbd_update_irq(pDevIns, s); 514 506 break; 515 507 case KBD_CCMD_WRITE_OBUF: … … 539 531 /* Automatically enables aux interface. */ 540 532 s->mode &= ~KBD_MODE_DISABLE_MOUSE; 541 rc = PS2MByteToAux( &s->Aux, val);533 rc = PS2MByteToAux(pDevIns, &s->Aux, val); 542 534 if (rc == VINF_SUCCESS) 543 kbd_update_irq( s);535 kbd_update_irq(pDevIns, s); 544 536 break; 545 537 default: … … 706 698 RT_FALL_THRU(); 707 699 case 1: 708 *pu32 = fluff | kbd_read_data(p This, Port);700 *pu32 = fluff | kbd_read_data(pDevIns, pThis, Port); 709 701 Log2(("kbdIOPortDataRead: Port=%#x cb=%d *pu32=%#x\n", Port, cb, *pu32)); 710 702 return VINF_SUCCESS; … … 732 724 if (cb == 1 || cb == 2) 733 725 { 734 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);735 rc = kbd_write_data(p This, Port, (uint8_t)u32);726 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 727 rc = kbd_write_data(pDevIns, pThis, Port, (uint8_t)u32); 736 728 Log2(("kbdIOPortDataWrite: Port=%#x cb=%d u32=%#x\n", Port, cb, u32)); 737 729 } … … 792 784 if (cb == 1 || cb == 2) 793 785 { 794 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, KBDState *);795 rc = kbd_write_command(p This, Port, (uint8_t)u32);786 KBDState *pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 787 rc = kbd_write_command(pDevIns, pThis, Port, (uint8_t)u32); 796 788 Log2(("kbdIOPortCommandWrite: Port=%#x cb=%d u32=%#x rc=%Rrc\n", Port, cb, u32, rc)); 797 789 } … … 975 967 { 976 968 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE); 977 return PS2KR3LoadDone(&pThis->Kbd, pSSM); 969 RT_NOREF(pSSM); 970 return PS2KR3LoadDone(pDevIns, &pThis->Kbd); 978 971 } 979 972 … … 994 987 pThis->translate = 0; 995 988 996 PS2KR3Reset( &pThis->Kbd);989 PS2KR3Reset(pDevIns, &pThis->Kbd); 997 990 PS2MR3Reset(&pThis->Aux); 998 991 } … … 1071 1064 NOREF(pDevIns); NOREF(iLUN); NOREF(fFlags); 1072 1065 #endif 1073 }1074 1075 1076 /**1077 * @interface_method_impl{PDMDEVREGR3,pfnRelocate}1078 */1079 static DECLCALLBACK(void) kbdR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)1080 {1081 PKBDSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PKBDSTATE);1082 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);1083 PS2KR3Relocate(&pThis->Kbd, offDelta, pDevIns);1084 PS2MR3Relocate(&pThis->Aux, offDelta, pDevIns);1085 1066 } 1086 1067 … … 1193 1174 /* .pfnConstruct = */ kbdR3Construct, 1194 1175 /* .pfnDestruct = */ NULL, 1195 /* .pfnRelocate = */ kbdR3Relocate,1176 /* .pfnRelocate = */ NULL, 1196 1177 /* .pfnMemSetup = */ NULL, 1197 1178 /* .pfnPowerOn = */ NULL, -
trunk/src/VBox/Devices/Input/DevPS2.h
r82191 r82195 108 108 /** Selected typematic delay/rate. */ 109 109 uint8_t u8TypematicCfg; 110 uint8_t bAlignment1; 110 111 /** Usage code of current typematic key, if any. */ 111 112 uint32_t u32TypematicKey; … … 119 120 uint8_t abDepressedKeys[VBOX_USB_USAGE_ARRAY_SIZE]; 120 121 /** Typematic delay in milliseconds. */ 121 u nsigneduTypematicDelay;122 uint32_t uTypematicDelay; 122 123 /** Typematic repeat period in milliseconds. */ 123 u nsigneduTypematicRepeat;124 uint32_t uTypematicRepeat; 124 125 /** Set if the throttle delay is currently active. */ 125 126 bool fThrottleActive; 126 127 /** Set if the input rate should be throttled. */ 127 128 bool fThrottleEnabled; 128 129 uint8_t Alignment0[2]; 130 131 /** Command delay timer - RC Ptr. */ 132 PTMTIMERRC pKbdDelayTimerRC; 133 /** Typematic timer - RC Ptr. */ 134 PTMTIMERRC pKbdTypematicTimerRC; 135 /** Input throttle timer - RC Ptr. */ 136 PTMTIMERRC pThrottleTimerRC; 129 uint8_t abAlignment2[2]; 130 131 /** Command delay timer - R3 Ptr. */ 132 TMTIMERHANDLE hKbdDelayTimer; 133 /** Typematic timer - R3 Ptr. */ 134 TMTIMERHANDLE hKbdTypematicTimer; 135 /** Input throttle timer. */ 136 TMTIMERHANDLE hThrottleTimer; 137 137 138 138 /** The device critical section protecting everything - R3 Ptr */ 139 139 R3PTRTYPE(PPDMCRITSECT) pCritSectR3; 140 141 /** Command delay timer - R3 Ptr. */ 142 PTMTIMERR3 pKbdDelayTimerR3; 143 /** Typematic timer - R3 Ptr. */ 144 PTMTIMERR3 pKbdTypematicTimerR3; 145 /** Input throttle timer - R3 Ptr. */ 146 PTMTIMERR3 pThrottleTimerR3; 147 148 /** Command delay timer - R0 Ptr. */ 149 PTMTIMERR0 pKbdDelayTimerR0; 150 /** Typematic timer - R0 Ptr. */ 151 PTMTIMERR0 pKbdTypematicTimerR0; 152 /** Input throttle timer - R0 Ptr. */ 153 PTMTIMERR0 pThrottleTimerR0; 140 /** The device instance. 141 * @note Only for getting our bearings in interface methods. */ 142 PPDMDEVINSR3 pDevIns; 154 143 155 144 /** … … 176 165 177 166 178 int PS2KByteToKbd(PP S2K pThis, uint8_t cmd);179 int PS2KByteFromKbd(PP S2K pThis, uint8_t *pVal);167 int PS2KByteToKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t cmd); 168 int PS2KByteFromKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t *pVal); 180 169 181 170 int PS2KR3Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg); 182 171 int PS2KR3Attach(PPS2K pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags); 183 void PS2KR3Reset(PPS2K pThis); 184 void PS2KR3Relocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns); 172 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis); 185 173 void PS2KR3SaveState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM); 186 174 int PS2KR3LoadState(PPDMDEVINS pDevIns, PPS2K pThis, PSSMHANDLE pSSM, uint32_t uVersion); 187 int PS2KR3LoadDone(PP S2K pThis, PSSMHANDLE pSSM);175 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis); 188 176 189 177 PS2K *KBDGetPS2KFromDevIns(PPDMDEVINS pDevIns); … … 289 277 /** The device critical section protecting everything - R3 Ptr */ 290 278 R3PTRTYPE(PPDMCRITSECT) pCritSectR3; 291 /** Command delay timer - R3 Ptr. */ 292 PTMTIMERR3 pDelayTimerR3; 293 /** Interrupt throttling timer - R3 Ptr. */ 294 PTMTIMERR3 pThrottleTimerR3; 295 RTR3PTR Alignment1; 296 297 /** Command delay timer - RC Ptr. */ 298 PTMTIMERRC pDelayTimerRC; 299 /** Interrupt throttling timer - RC Ptr. */ 300 PTMTIMERRC pThrottleTimerRC; 301 302 /** Command delay timer - R0 Ptr. */ 303 PTMTIMERR0 pDelayTimerR0; 304 /** Interrupt throttling timer - R0 Ptr. */ 305 PTMTIMERR0 pThrottleTimerR0; 279 /** The device instance. 280 * @note Only for getting our bearings in interface methods. */ 281 PPDMDEVINSR3 pDevIns; 282 283 /** Command delay timer. */ 284 TMTIMERHANDLE hDelayTimer; 285 /** Interrupt throttling timer. */ 286 TMTIMERHANDLE hThrottleTimer; 306 287 307 288 /** … … 327 308 typedef PS2M *PPS2M; 328 309 329 int PS2MByteToAux(PP S2M pThis, uint8_t cmd);310 int PS2MByteToAux(PPDMDEVINS pDevIns, PPS2M pThis, uint8_t cmd); 330 311 int PS2MByteFromAux(PPS2M pThis, uint8_t *pVal); 331 312 … … 333 314 int PS2MR3Attach(PPS2M pThis, PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags); 334 315 void PS2MR3Reset(PPS2M pThis); 335 void PS2MR3Relocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns);336 316 void PS2MR3SaveState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM); 337 317 int PS2MR3LoadState(PPDMDEVINS pDevIns, PPS2M pThis, PSSMHANDLE pSSM, uint32_t uVersion); … … 374 354 375 355 /* Shared keyboard/aux internal interface. */ 376 void KBCUpdateInterrupts( void *pKbc);356 void KBCUpdateInterrupts(PPDMDEVINS pDevIns); 377 357 378 358 /** @} */ -
trunk/src/VBox/Devices/Input/DevPS2K.cpp
r82191 r82195 449 449 450 450 /** Clears the currently active typematic key, if any. */ 451 static void ps2kStopTypematicRepeat(PP S2K pThis)451 static void ps2kStopTypematicRepeat(PPDMDEVINS pDevIns, PPS2K pThis) 452 452 { 453 453 if (pThis->u32TypematicKey) … … 456 456 pThis->enmTypematicState = KBD_TMS_IDLE; 457 457 pThis->u32TypematicKey = 0; 458 TMTimerStop(pThis->CTX_SUFF(pKbdTypematicTimer));458 PDMDevHlpTimerStop(pDevIns, pThis->hKbdTypematicTimer); 459 459 } 460 460 } … … 480 480 } 481 481 482 static void ps2kSetDefaults(PP S2K pThis)482 static void ps2kSetDefaults(PPDMDEVINS pDevIns, PPS2K pThis) 483 483 { 484 484 LogFlowFunc(("Set keyboard defaults\n")); … … 488 488 ps2kSetupTypematic(pThis, KBD_DFL_RATE_DELAY); 489 489 /* Clear last typematic key?? */ 490 ps2kStopTypematicRepeat(p This);490 ps2kStopTypematicRepeat(pDevIns, pThis); 491 491 } 492 492 … … 494 494 * Receive and process a byte sent by the keyboard controller. 495 495 * 496 * @param pThis The PS/2 keyboard instance data. 497 * @param cmd The command (or data) byte. 498 */ 499 int PS2KByteToKbd(PPS2K pThis, uint8_t cmd) 496 * @param pDevIns The device instance. 497 * @param pThis The PS/2 keyboard instance data. 498 * @param cmd The command (or data) byte. 499 */ 500 int PS2KByteToKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t cmd) 500 501 { 501 502 bool fHandled = true; … … 522 523 pThis->fScanning = true; 523 524 PS2CmnClearQueue((GeneriQ *)&pThis->keyQ); 524 ps2kStopTypematicRepeat(p This);525 ps2kStopTypematicRepeat(pDevIns, pThis); 525 526 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 526 527 pThis->u8CurrCmd = 0; … … 528 529 case KCMD_DFLT_DISABLE: 529 530 pThis->fScanning = false; 530 ps2kSetDefaults(p This); /* Also clears buffer/typematic state. */531 ps2kSetDefaults(pDevIns, pThis); /* Also clears buffer/typematic state. */ 531 532 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 532 533 pThis->u8CurrCmd = 0; 533 534 break; 534 535 case KCMD_SET_DEFAULT: 535 ps2kSetDefaults(p This);536 ps2kSetDefaults(pDevIns, pThis); 536 537 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 537 538 pThis->u8CurrCmd = 0; … … 550 551 case KCMD_RESET: 551 552 pThis->u8ScanSet = 2; 552 ps2kSetDefaults(p This);553 ps2kSetDefaults(pDevIns, pThis); 553 554 /// @todo reset more? 554 555 PS2CmnInsertQueue((GeneriQ *)&pThis->cmdQ, KRSP_ACK); 555 556 pThis->u8CurrCmd = cmd; 556 557 /* Delay BAT completion; the test may take hundreds of ms. */ 557 TMTimerSetMillies(pThis->CTX_SUFF(pKbdDelayTimer), 2);558 PDMDevHlpTimerSetMillies(pDevIns, pThis->hKbdDelayTimer, 2); 558 559 break; 559 560 /* The following commands need a parameter. */ … … 616 617 } 617 618 LogFlowFunc(("Active cmd now 0x%02X; updating interrupts\n", pThis->u8CurrCmd)); 618 // KBCUpdateInterrupts(p This->pParent);619 // KBCUpdateInterrupts(pDevIns); 619 620 return VINF_SUCCESS; 620 621 } … … 624 625 * 625 626 * @returns VINF_SUCCESS or VINF_TRY_AGAIN. 626 * @param pThis The PS/2 keyboard instance data. 627 * @param pb Where to return the byte we've read. 627 * @param pDevIns The device instance. 628 * @param pThis The PS/2 keyboard instance data. 629 * @param pb Where to return the byte we've read. 628 630 * @remarks Caller must have entered the device critical section. 629 631 */ 630 int PS2KByteFromKbd(PP S2K pThis, uint8_t *pb)632 int PS2KByteFromKbd(PPDMDEVINS pDevIns, PPS2K pThis, uint8_t *pb) 631 633 { 632 634 int rc; … … 644 646 { 645 647 rc = PS2CmnRemoveQueue((GeneriQ *)&pThis->keyQ, pb); 646 if (pThis->fThrottleEnabled) { 648 if (pThis->fThrottleEnabled) 649 { 647 650 pThis->fThrottleActive = true; 648 TMTimerSetMillies(pThis->CTX_SUFF(pThrottleTimer), KBD_THROTTLE_DELAY);651 PDMDevHlpTimerSetMillies(pDevIns, pThis->hThrottleTimer, KBD_THROTTLE_DELAY); 649 652 } 650 653 } … … 656 659 #ifdef IN_RING3 657 660 658 static int ps2kR3ProcessKeyEvent(PP S2K pThis, uint32_t u32HidCode, bool fKeyDown)661 static int ps2kR3ProcessKeyEvent(PPDMDEVINS pDevIns, PPS2K pThis, uint32_t u32HidCode, bool fKeyDown) 659 662 { 660 663 key_def const *pKeyDef; … … 890 893 pThis->enmTypematicState = KBD_TMS_DELAY; 891 894 pThis->u32TypematicKey = u32HidCode; 892 TMTimerSetMillies(pThis->CTX_SUFF(pKbdTypematicTimer), pThis->uTypematicDelay);895 PDMDevHlpTimerSetMillies(pDevIns, pThis->hKbdTypematicTimer, pThis->uTypematicDelay); 893 896 Log(("Typematic delay %u ms, key %08X\n", pThis->uTypematicDelay, u32HidCode)); 894 897 } … … 906 909 pThis->enmTypematicState = KBD_TMS_IDLE; 907 910 /* For good measure, we cancel the timer, too. */ 908 TMTimerStop(pThis->CTX_SUFF(pKbdTypematicTimer));911 PDMDevHlpTimerStop(pDevIns, pThis->hKbdTypematicTimer); 909 912 Log(("Typematic action cleared for key %08X\n", u32HidCode)); 910 913 } … … 913 916 914 917 /* Poke the KBC to update its state. */ 915 KBCUpdateInterrupts(p This->pParent);918 KBCUpdateInterrupts(pDevIns); 916 919 917 920 return VINF_SUCCESS; … … 949 952 LogFlowFunc(("Have%s bytes\n", uHaveData ? "" : " no")); 950 953 if (uHaveData) 951 KBCUpdateInterrupts(p This->pParent);954 KBCUpdateInterrupts(pDevIns); 952 955 953 956 PDMCritSectLeave(pThis->pCritSectR3); … … 976 979 if (pThis->enmTypematicState == KBD_TMS_REPEAT) 977 980 { 978 ps2kR3ProcessKeyEvent(p This, pThis->u32TypematicKey, true /* Key down */ );979 TMTimerSetMillies(pThis->CTX_SUFF(pKbdTypematicTimer), pThis->uTypematicRepeat);981 ps2kR3ProcessKeyEvent(pDevIns, pThis, pThis->u32TypematicKey, true /* Key down */ ); 982 PDMDevHlpTimerSetMillies(pDevIns, pThis->hKbdTypematicTimer, pThis->uTypematicRepeat); 980 983 } 981 984 } … … 1002 1005 /// @todo Might want a PS2KCompleteCommand() to push last response, clear command, and kick the KBC... 1003 1006 /* Give the KBC a kick. */ 1004 KBCUpdateInterrupts(p This->pParent);1007 KBCUpdateInterrupts(pDevIns); 1005 1008 } 1006 1009 … … 1009 1012 * or resuming a suspended host. 1010 1013 */ 1011 static void ps2kR3ReleaseKeys(PP S2K pThis)1014 static void ps2kR3ReleaseKeys(PPDMDEVINS pDevIns, PPS2K pThis) 1012 1015 { 1013 1016 LogFlowFunc(("Releasing keys...\n")); … … 1016 1019 if (pThis->abDepressedKeys[uKey]) 1017 1020 { 1018 ps2kR3ProcessKeyEvent(p This, RT_MAKE_U32(USB_HID_KB_PAGE, uKey), false /* key up */);1021 ps2kR3ProcessKeyEvent(pDevIns, pThis, RT_MAKE_U32(USB_HID_KB_PAGE, uKey), false /* key up */); 1019 1022 pThis->abDepressedKeys[uKey] = 0; 1020 1023 } … … 1071 1074 * 1072 1075 * @returns VBox status code. 1073 * @param p This The PS2 keyboard instance data.1074 * @param u32Usage USB HID usage code with key1075 * 1076 */ 1077 static int ps2kR3PutEventWorker(PP S2K pThis, uint32_t u32Usage)1076 * @param pDevIns The device instance. 1077 * @param pThis The PS2 keyboard instance data. 1078 * @param u32Usage USB HID usage code with key press/release flag. 1079 */ 1080 static int ps2kR3PutEventWorker(PPDMDEVINS pDevIns, PPS2K pThis, uint32_t u32Usage) 1078 1081 { 1079 1082 uint32_t u32HidCode; … … 1116 1119 AssertReleaseRC(rc); 1117 1120 1118 rc = ps2kR3ProcessKeyEvent(p This, u32HidCode, fKeyDown);1121 rc = ps2kR3ProcessKeyEvent(pDevIns, pThis, u32HidCode, fKeyDown); 1119 1122 1120 1123 PDMCritSectLeave(pThis->pCritSectR3); … … 1131 1134 { 1132 1135 PPS2K pThis = RT_FROM_MEMBER(pInterface, PS2K, Keyboard.IPort); 1136 PPDMDEVINS pDevIns = pThis->pDevIns; 1133 1137 int rc; 1134 1138 … … 1141 1145 * key is allowed to use this scancode. 1142 1146 */ 1143 if (RT_UNLIKELY(u32UsageCode == KRSP_BAT_FAIL)) 1144 { 1145 ps2kR3ReleaseKeys(pThis); 1146 } 1147 if (RT_LIKELY(u32UsageCode != KRSP_BAT_FAIL)) 1148 ps2kR3PutEventWorker(pDevIns, pThis, u32UsageCode); 1147 1149 else 1148 { 1149 ps2kR3PutEventWorker(pThis, u32UsageCode); 1150 } 1150 ps2kR3ReleaseKeys(pDevIns, pThis); 1151 1151 1152 1152 PDMCritSectLeave(pThis->pCritSectR3); … … 1230 1230 * timer is *not* saved. 1231 1231 */ 1232 TMR3TimerSave(pThis->CTX_SUFF(pKbdDelayTimer), pSSM);1232 PDMDevHlpTimerSave(pDevIns, pThis->hKbdDelayTimer, pSSM); 1233 1233 1234 1234 /* Save any pressed keys. This is necessary to avoid "stuck" … … 1282 1282 1283 1283 /* Load the command delay timer, just in case. */ 1284 rc = TMR3TimerLoad(pThis->CTX_SUFF(pKbdDelayTimer), pSSM);1284 rc = PDMDevHlpTimerLoad(pDevIns, pThis->hKbdDelayTimer, pSSM); 1285 1285 AssertRCReturn(rc, rc); 1286 1286 … … 1316 1316 } 1317 1317 1318 int PS2KR3LoadDone(PPS2K pThis, PSSMHANDLE pSSM) 1319 { 1320 RT_NOREF(pSSM); 1321 1318 int PS2KR3LoadDone(PPDMDEVINS pDevIns, PPS2K pThis) 1319 { 1322 1320 /* This *must* be done after the inital load because it may trigger 1323 1321 * interrupts and change the interrupt controller state. 1324 1322 */ 1325 ps2kR3ReleaseKeys(p This);1323 ps2kR3ReleaseKeys(pDevIns, pThis); 1326 1324 ps2kR3NotifyLedsState(pThis, pThis->u8LEDs); 1327 1325 return VINF_SUCCESS; 1328 1326 } 1329 1327 1330 void PS2KR3Reset(PP S2K pThis)1328 void PS2KR3Reset(PPDMDEVINS pDevIns, PPS2K pThis) 1331 1329 { 1332 1330 LogFlowFunc(("Resetting PS2K\n")); … … 1343 1341 memset(pThis->abDepressedKeys, 0, sizeof(pThis->abDepressedKeys)); 1344 1342 PS2CmnClearQueue((GeneriQ *)&pThis->cmdQ); 1345 ps2kSetDefaults(p This); /* Also clears keystroke queue. */1343 ps2kSetDefaults(pDevIns, pThis); /* Also clears keystroke queue. */ 1346 1344 1347 1345 /* Activate the PS/2 keyboard by default. */ … … 1350 1348 } 1351 1349 1352 void PS2KR3Relocate(PPS2K pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)1353 {1354 RT_NOREF(pDevIns);1355 LogFlowFunc(("Relocating PS2K\n"));1356 pThis->pKbdDelayTimerRC = TMTimerRCPtr(pThis->pKbdDelayTimerR3);1357 pThis->pKbdTypematicTimerRC = TMTimerRCPtr(pThis->pKbdTypematicTimerR3);1358 pThis->pThrottleTimerRC = TMTimerRCPtr(pThis->pThrottleTimerR3);1359 NOREF(offDelta);1360 }1361 1362 1350 int PS2KR3Construct(PPS2K pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance, PCFGMNODE pCfg) 1363 1351 { … … 1367 1355 1368 1356 pThis->pParent = pParent; 1357 pThis->pDevIns = pDevIns; 1369 1358 1370 1359 bool fThrottleEnabled; … … 1390 1379 * Create the input rate throttling timer. 1391 1380 */ 1392 PTMTIMER pTimer; 1393 rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3ThrottleTimer, pThis, 1394 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Throttle Timer", &pTimer); 1381 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3ThrottleTimer, pThis, 1382 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Throttle Timer", &pThis->hThrottleTimer); 1395 1383 AssertRCReturn(rc, rc); 1396 1397 pThis->pThrottleTimerR3 = pTimer;1398 pThis->pThrottleTimerR0 = TMTimerR0Ptr(pTimer);1399 pThis->pThrottleTimerRC = TMTimerRCPtr(pTimer);1400 1384 1401 1385 /* 1402 1386 * Create the typematic delay/repeat timer. 1403 1387 */ 1404 rc = PDMDevHlpT MTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3TypematicTimer, pThis,1405 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Typematic Timer", &pTimer);1388 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3TypematicTimer, pThis, 1389 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Typematic Timer", &pThis->hKbdTypematicTimer); 1406 1390 AssertRCReturn(rc, rc); 1407 1408 pThis->pKbdTypematicTimerR3 = pTimer;1409 pThis->pKbdTypematicTimerR0 = TMTimerR0Ptr(pTimer);1410 pThis->pKbdTypematicTimerRC = TMTimerRCPtr(pTimer);1411 1391 1412 1392 /* 1413 1393 * Create the command delay timer. 1414 1394 */ 1415 rc = PDMDevHlpT MTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3DelayTimer, pThis,1416 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Delay Timer", &pTimer);1395 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2kR3DelayTimer, pThis, 1396 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2K Delay Timer", &pThis->hKbdDelayTimer); 1417 1397 AssertRCReturn(rc, rc); 1418 1419 pThis->pKbdDelayTimerR3 = pTimer;1420 pThis->pKbdDelayTimerR0 = TMTimerR0Ptr(pTimer);1421 pThis->pKbdDelayTimerRC = TMTimerRCPtr(pTimer);1422 1398 1423 1399 /* -
trunk/src/VBox/Devices/Input/DevPS2M.cpp
r82191 r82195 415 415 * Receive and process a byte sent by the keyboard controller. 416 416 * 417 * @param pThis The PS/2 auxiliary device instance data. 418 * @param cmd The command (or data) byte. 419 */ 420 int PS2MByteToAux(PPS2M pThis, uint8_t cmd) 417 * @param pDevIns The device instance. 418 * @param pThis The PS/2 auxiliary device instance data. 419 * @param cmd The command (or data) byte. 420 */ 421 int PS2MByteToAux(PPDMDEVINS pDevIns, PPS2M pThis, uint8_t cmd) 421 422 { 422 423 uint8_t u8Val; … … 537 538 if (pThis->fDelayReset) 538 539 /* Slightly delay reset completion; it might take hundreds of ms. */ 539 TMTimerSetMillies(pThis->CTX_SUFF(pDelayTimer), 1);540 PDMDevHlpTimerSetMillies(pDevIns, pThis->hDelayTimer, 1); 540 541 else 541 542 #ifdef IN_RING3 … … 693 694 /* Report accumulated data, poke the KBC, and start the timer. */ 694 695 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->evtQ, true); 695 KBCUpdateInterrupts(p This->pParent);696 TMTimerSetMillies(pThis->CTX_SUFF(pThrottleTimer), pThis->uThrottleDelay);696 KBCUpdateInterrupts(pDevIns); 697 PDMDevHlpTimerSetMillies(pDevIns, pThis->hThrottleTimer, pThis->uThrottleDelay); 697 698 } 698 699 else … … 721 722 /// @todo Might want a PS2MCompleteCommand() to push last response, clear command, and kick the KBC... 722 723 /* Give the KBC a kick. */ 723 KBCUpdateInterrupts(p This->pParent);724 KBCUpdateInterrupts(pDevIns); 724 725 } 725 726 … … 777 778 * 778 779 * @returns VBox status code. 779 * @param pThis The PS/2 auxiliary device instance data. 780 * @param dx X direction movement delta. 781 * @param dy Y direction movement delta. 782 * @param dz Z (vertical scroll) movement delta. 783 * @param dw W (horizontal scroll) movement delta. 784 * @param fButtons Depressed button mask. 785 */ 786 static int ps2mR3PutEventWorker(PPS2M pThis, int32_t dx, int32_t dy, int32_t dz, int32_t dw, uint32_t fButtons) 780 * @param pDevIns The device instance. 781 * @param pThis The PS/2 auxiliary device instance data. 782 * @param dx X direction movement delta. 783 * @param dy Y direction movement delta. 784 * @param dz Z (vertical scroll) movement delta. 785 * @param dw W (horizontal scroll) movement delta. 786 * @param fButtons Depressed button mask. 787 */ 788 static int ps2mR3PutEventWorker(PPDMDEVINS pDevIns, PPS2M pThis, int32_t dx, int32_t dy, int32_t dz, int32_t dw, uint32_t fButtons) 787 789 { 788 790 /* Update internal accumulators and button state. Ignore any buttons beyond 5. */ … … 814 816 { 815 817 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->evtQ, true); 816 KBCUpdateInterrupts(p This->pParent);818 KBCUpdateInterrupts(pDevIns); 817 819 pThis->fThrottleActive = true; 818 TMTimerSetMillies(pThis->CTX_SUFF(pThrottleTimer), pThis->uThrottleDelay);820 PDMDevHlpTimerSetMillies(pDevIns, pThis->hThrottleTimer, pThis->uThrottleDelay); 819 821 } 820 822 … … 831 833 { 832 834 PPS2M pThis = RT_FROM_MEMBER(pInterface, PS2M, Mouse.IPort); 833 int rc = PDMCritSectEnter(pThis->pCritSectR3, VERR_SEM_BUSY); 835 PPDMDEVINS pDevIns = pThis->pDevIns; 836 int rc = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_SEM_BUSY); 834 837 AssertReleaseRC(rc); 835 838 836 839 LogRelFlowFunc(("dX=%d dY=%d dZ=%d dW=%d buttons=%02X\n", dx, dy, dz, dw, fButtons)); 837 840 /* NB: The PS/2 Y axis direction is inverted relative to ours. */ 838 ps2mR3PutEventWorker(p This, dx, -dy, dz, dw, fButtons);839 840 PDM CritSectLeave(pThis->pCritSectR3);841 ps2mR3PutEventWorker(pDevIns, pThis, dx, -dy, dz, dw, fButtons); 842 843 PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3); 841 844 return VINF_SUCCESS; 842 845 } … … 933 936 * timer is *not* saved. 934 937 */ 935 TMR3TimerSave(pThis->CTX_SUFF(pDelayTimer), pSSM);938 PDMDevHlpTimerSave(pDevIns, pThis->hDelayTimer, pSSM); 936 939 } 937 940 … … 964 967 965 968 /* Load the command delay timer, just in case. */ 966 rc = TMR3TimerLoad(pThis->CTX_SUFF(pDelayTimer), pSSM);969 rc = PDMDevHlpTimerLoad(pDevIns, pThis->hDelayTimer, pSSM); 967 970 AssertRCReturn(rc, rc); 968 971 … … 1001 1004 } 1002 1005 1003 void PS2MR3Relocate(PPS2M pThis, RTGCINTPTR offDelta, PPDMDEVINS pDevIns)1004 {1005 RT_NOREF(pDevIns, offDelta);1006 LogFlowFunc(("Relocating PS2M\n"));1007 pThis->pDelayTimerRC = TMTimerRCPtr(pThis->pDelayTimerR3);1008 pThis->pThrottleTimerRC = TMTimerRCPtr(pThis->pThrottleTimerR3);1009 }1010 1011 1006 int PS2MR3Construct(PPS2M pThis, PPDMDEVINS pDevIns, PKBDSTATE pParent, unsigned iInstance) 1012 1007 { … … 1020 1015 1021 1016 pThis->pParent = pParent; 1017 pThis->pDevIns = pDevIns; 1022 1018 1023 1019 /* Initialize the queues. */ … … 1038 1034 * Create the input rate throttling timer. Does not use virtual time! 1039 1035 */ 1040 PTMTIMER pTimer; 1041 int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_REAL, ps2mR3ThrottleTimer, pThis, 1042 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Throttle Timer", &pTimer); 1036 int rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_REAL, ps2mR3ThrottleTimer, pThis, 1037 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Throttle Timer", &pThis->hThrottleTimer); 1043 1038 AssertRCReturn(rc, rc); 1044 1045 pThis->pThrottleTimerR3 = pTimer;1046 pThis->pThrottleTimerR0 = TMTimerR0Ptr(pTimer);1047 pThis->pThrottleTimerRC = TMTimerRCPtr(pTimer);1048 1039 1049 1040 /* 1050 1041 * Create the command delay timer. 1051 1042 */ 1052 rc = PDMDevHlpT MTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2mR3DelayTimer, pThis,1053 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Delay Timer", &pTimer);1043 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, ps2mR3DelayTimer, pThis, 1044 TMTIMER_FLAGS_DEFAULT_CRIT_SECT, "PS2M Delay Timer", &pThis->hDelayTimer); 1054 1045 AssertRCReturn(rc, rc); 1055 1056 pThis->pDelayTimerR3 = pTimer;1057 pThis->pDelayTimerR0 = TMTimerR0Ptr(pTimer);1058 pThis->pDelayTimerRC = TMTimerRCPtr(pTimer);1059 1046 1060 1047 /* … … 1096 1083 * a release-press-release all within a single 10ms interval. Simulate 1097 1084 * this to check that it is handled right. */ 1098 ps2mR3PutEventWorker( &This, 0, 0, 0, 0, 1);1085 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1); 1099 1086 if (ps2mR3HaveEvents(&This)) 1100 1087 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1101 ps2mR3PutEventWorker( &This, 0, 0, 0, 0, 0);1088 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 0); 1102 1089 if (ps2mR3HaveEvents(&This)) 1103 1090 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1104 ps2mR3PutEventWorker( &This, 0, 0, 0, 0, 1);1105 ps2mR3PutEventWorker( &This, 0, 0, 0, 0, 0);1091 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1); 1092 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 0); 1106 1093 if (ps2mR3HaveEvents(&This)) 1107 1094 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); … … 1120 1107 /* Button hold down during mouse drags was broken at some point during 1121 1108 * testing fixes for the previous issue. Test that that works. */ 1122 ps2mR3PutEventWorker( &This, 0, 0, 0, 0, 1);1109 ps2mR3PutEventWorker(NULL, &This, 0, 0, 0, 0, 1); 1123 1110 if (ps2mR3HaveEvents(&This)) 1124 1111 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true);
Note:
See TracChangeset
for help on using the changeset viewer.