Changeset 44626 in vbox for trunk/src/VBox/ExtPacks
- Timestamp:
- Feb 11, 2013 10:52:19 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83713
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ExtPacks/BusMouseSample/BusMouse.cpp
r44514 r44626 124 124 typedef struct MouState 125 125 { 126 /* 8255A state */ 126 /** @name 8255A state 127 * @{ */ 127 128 uint8_t port_a; 128 129 uint8_t port_b; … … 138 139 /** Timer period in milliseconds. */ 139 140 uint32_t cTimerPeriodMs; 140 /* mouse state */ 141 /** @} */ 142 143 /** @name mouse state 144 * @{ */ 141 145 int32_t disable_counter; 142 146 uint8_t mouse_enabled; … … 145 149 uint8_t mouse_buttons; 146 150 uint8_t mouse_buttons_reported; 151 /** @} */ 147 152 148 153 /** Pointer to the device instance - RC. */ … … 348 353 } 349 354 350 static int bms_write_port(MouState *pThis, uint32_t addr, uint32_t val)355 static int bms_write_port(MouState *pThis, uint32_t offPort, uint32_t uValue) 351 356 { 352 357 int rc = VINF_SUCCESS; 353 358 354 LogRel3(("%s: write port %d: 0x%02x\n", __PRETTY_FUNCTION__, addr, val)); 355 356 switch(addr) { 357 case BMS_PORT_SIG: 358 /* Update port B. */ 359 pThis->port_b = val; 360 break; 361 case BMS_PORT_DATA: 362 /* Do nothing, port A is not writable. */ 363 break; 364 case BMS_PORT_INIT: 365 pThis->ctrl_port = val; 366 break; 367 case BMS_PORT_CTRL: 368 /* Update the high nibble of port C. */ 369 pThis->port_c = (val & 0xF0) | (pThis->port_c & 0x0F); 370 bms_update_ctrl(pThis); 371 break; 372 default: 373 AssertMsgFailed(("invalid port %#x\n", addr)); 374 break; 359 LogRel3(("%s: write port %d: 0x%02x\n", __PRETTY_FUNCTION__, offPort, uValue)); 360 361 switch (offPort) 362 { 363 case BMS_PORT_SIG: 364 /* Update port B. */ 365 pThis->port_b = uValue; 366 break; 367 case BMS_PORT_DATA: 368 /* Do nothing, port A is not writable. */ 369 break; 370 case BMS_PORT_INIT: 371 pThis->ctrl_port = uValue; 372 break; 373 case BMS_PORT_CTRL: 374 /* Update the high nibble of port C. */ 375 pThis->port_c = (uValue & 0xF0) | (pThis->port_c & 0x0F); 376 bms_update_ctrl(pThis); 377 break; 378 default: 379 AssertMsgFailed(("invalid port %#x\n", offPort)); 380 break; 375 381 } 376 382 return rc; 377 383 } 378 384 379 static uint32_t bms_read_port(MouState *pThis, uint32_t addr) 380 { 381 uint32_t val; 382 383 switch(addr) { 384 case BMS_PORT_DATA: 385 /* Read port A. */ 386 val = pThis->port_a; 387 break; 388 case BMS_PORT_SIG: 389 /* Read port B. */ 390 val = pThis->port_b; 391 break; 392 case BMS_PORT_CTRL: 393 /* Read port C. */ 394 val = pThis->port_c; 395 /* Some Microsoft driver code reads the control port 10,000 times when 396 * determining the IRQ level. This can occur faster than the IRQ line 397 * transitions and the detection fails. To work around this, we force 398 * the IRQ bit to toggle every once in a while. 399 */ 400 if (pThis->irq_toggle_counter) 401 pThis->irq_toggle_counter--; 402 else 403 { 404 pThis->irq_toggle_counter = 1000; 405 val ^= BMS_IRQ_BIT(pThis->irq); 406 } 407 break; 408 case BMS_PORT_INIT: 409 /* Read the 8255A control port. */ 410 val = pThis->ctrl_port; 411 break; 412 default: 413 AssertMsgFailed(("invalid port %#x\n", addr)); 414 break; 415 } 416 LogRel3(("%s: read port %d: 0x%02x\n", __PRETTY_FUNCTION__, addr, val)); 417 return val; 385 static uint32_t bms_read_port(MouState *pThis, uint32_t offPort) 386 { 387 uint32_t uValue; 388 389 switch (offPort) 390 { 391 case BMS_PORT_DATA: 392 /* Read port A. */ 393 uValue = pThis->port_a; 394 break; 395 case BMS_PORT_SIG: 396 /* Read port B. */ 397 uValue = pThis->port_b; 398 break; 399 case BMS_PORT_CTRL: 400 /* Read port C. */ 401 uValue = pThis->port_c; 402 /* Some Microsoft driver code reads the control port 10,000 times when 403 * determining the IRQ level. This can occur faster than the IRQ line 404 * transitions and the detection fails. To work around this, we force 405 * the IRQ bit to toggle every once in a while. 406 */ 407 if (pThis->irq_toggle_counter) 408 pThis->irq_toggle_counter--; 409 else 410 { 411 pThis->irq_toggle_counter = 1000; 412 uValue ^= BMS_IRQ_BIT(pThis->irq); 413 } 414 break; 415 case BMS_PORT_INIT: 416 /* Read the 8255A control port. */ 417 uValue = pThis->ctrl_port; 418 break; 419 default: 420 AssertMsgFailed(("invalid port %#x\n", offPort)); 421 break; 422 } 423 LogRel3(("%s: read port %d: 0x%02x\n", __PRETTY_FUNCTION__, offPort, uValue)); 424 return uValue; 418 425 } 419 426
Note:
See TracChangeset
for help on using the changeset viewer.