vbox的更動 38377 路徑 trunk/src/VBox/Devices/Input/DevPS2.cpp
- 時間撮記:
- 2011-8-9 下午12:01:37 (13 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r37466 r38377 199 199 uint8_t status; 200 200 uint8_t mode; 201 uint8_t dbbout; /* data buffer byte */ 201 202 /* keyboard state */ 202 203 int32_t kbd_write_cmd; … … 311 312 s->status &= ~KBD_STAT_MOUSE_OBF; 312 313 /* Keyboard data has priority if both kbd and aux data is available. */ 313 if (q->count != 0)314 if (q->count && !(s->mode & KBD_MODE_DISABLE_KBD)) 314 315 { 315 316 s->status |= KBD_STAT_OBF; 317 s->dbbout = q->data[q->rptr]; 318 if (++q->rptr == KBD_QUEUE_SIZE) 319 q->rptr = 0; 320 q->count--; 316 321 } 317 else if ( mcq->count != 0 || meq->count != 0)322 else if ((mcq->count || meq->count) /*&& !(s->mode & KBD_MODE_DISABLE_MOUSE)*/) 318 323 { 319 324 s->status |= KBD_STAT_OBF | KBD_STAT_MOUSE_OBF; 325 if (mcq->count) 326 { 327 s->dbbout = mcq->data[mcq->rptr]; 328 if (++mcq->rptr == MOUSE_CMD_QUEUE_SIZE) 329 mcq->rptr = 0; 330 mcq->count--; 331 } 332 else 333 { 334 s->dbbout = meq->data[meq->rptr]; 335 if (++meq->rptr == MOUSE_EVENT_QUEUE_SIZE) 336 meq->rptr = 0; 337 meq->count--; 338 } 320 339 } 321 340 } … … 404 423 #endif /* IN_RING3 */ 405 424 425 static void kbc_dbb_out(void *opaque, uint8_t val) 426 { 427 KBDState *s = (KBDState*)opaque; 428 429 s->dbbout = val; 430 /* Set the OBF and raise IRQ. */ 431 s->status |= KBD_STAT_OBF; 432 if (s->mode & KBD_MODE_KBD_INT) 433 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 1, 1); 434 } 435 406 436 static uint32_t kbd_read_status(void *opaque, uint32_t addr) 407 437 { … … 425 455 switch(val) { 426 456 case KBD_CCMD_READ_MODE: 427 kb d_queue(s, s->mode, 0);457 kbc_dbb_out(s, s->mode); 428 458 break; 429 459 case KBD_CCMD_WRITE_MODE: … … 439 469 case KBD_CCMD_MOUSE_ENABLE: 440 470 s->mode &= ~KBD_MODE_DISABLE_MOUSE; 471 /* Check for queued input. */ 472 kbd_update_irq(s); 441 473 break; 442 474 case KBD_CCMD_TEST_MOUSE: 443 kb d_queue(s, 0x00,0);475 kbc_dbb_out(s, 0x00); 444 476 break; 445 477 case KBD_CCMD_SELF_TEST: 478 /* Enable the A20 line - that is the power-on state(!). */ 479 # ifndef IN_RING3 480 if (!PDMDevHlpA20IsEnabled(s->CTX_SUFF(pDevIns))) 481 { 482 rc = VINF_IOM_HC_IOPORT_WRITE; 483 break; 484 } 485 # else /* IN_RING3 */ 486 PDMDevHlpA20Set(s->CTX_SUFF(pDevIns), true); 487 # endif /* IN_RING3 */ 446 488 s->status |= KBD_STAT_SELFTEST; 447 kbd_queue(s, 0x55, 0); 489 s->mode |= KBD_MODE_DISABLE_KBD; 490 kbc_dbb_out(s, 0x55); 448 491 break; 449 492 case KBD_CCMD_KBD_TEST: 450 kb d_queue(s, 0x00,0);493 kbc_dbb_out(s, 0x00); 451 494 break; 452 495 case KBD_CCMD_KBD_DISABLE: 453 496 s->mode |= KBD_MODE_DISABLE_KBD; 454 kbd_update_irq(s);455 497 break; 456 498 case KBD_CCMD_KBD_ENABLE: 457 499 s->mode &= ~KBD_MODE_DISABLE_KBD; 500 /* Check for queued input. */ 458 501 kbd_update_irq(s); 459 502 break; 460 503 case KBD_CCMD_READ_INPORT: 461 kb d_queue(s, 0x00,0);504 kbc_dbb_out(s, 0x00); 462 505 break; 463 506 case KBD_CCMD_READ_OUTPORT: … … 472 515 if (s->status & KBD_STAT_MOUSE_OBF) 473 516 val |= 0x20; 474 kb d_queue(s, val, 0);517 kbc_dbb_out(s, val); 475 518 break; 476 519 #ifdef TARGET_I386 … … 495 538 /* Keyboard clock line is zero IFF keyboard is disabled */ 496 539 val = (s->mode & KBD_MODE_DISABLE_KBD) ? 0 : 1; 497 kb d_queue(s, val, 0);540 kbc_dbb_out(s, val); 498 541 break; 499 542 case KBD_CCMD_RESET: … … 516 559 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: 517 560 case 0x38: case 0x39: case 0x3a: case 0x3b: case 0x3c: case 0x3d: case 0x3e: case 0x3f: 518 kb d_queue(s, 0, 0);561 kbc_dbb_out(s, 0); 519 562 Log(("kbd: reading non-standard RAM addr %#x\n", val & 0x1f)); 520 563 break; … … 529 572 { 530 573 KBDState *s = (KBDState*)opaque; 531 KBDQueue *q; 532 MouseCmdQueue *mcq; 533 MouseEventQueue *meq; 534 int val, index, aux; 535 536 q = &s->queue; 537 mcq = &s->mouse_command_queue; 538 meq = &s->mouse_event_queue; 539 if (q->count == 0 && mcq->count == 0 && meq->count == 0) { 540 /* NOTE: if no data left, we return the last keyboard one 541 (needed for EMM386) */ 542 /* XXX: need a timer to do things correctly */ 543 index = q->rptr - 1; 544 if (index < 0) 545 index = KBD_QUEUE_SIZE - 1; 546 val = q->data[index]; 547 } else { 548 aux = (s->status & KBD_STAT_MOUSE_OBF); 549 if (!aux) 550 { 551 val = q->data[q->rptr]; 552 if (++q->rptr == KBD_QUEUE_SIZE) 553 q->rptr = 0; 554 q->count--; 555 } 556 else 557 { 558 if (mcq->count) 559 { 560 val = mcq->data[mcq->rptr]; 561 if (++mcq->rptr == MOUSE_CMD_QUEUE_SIZE) 562 mcq->rptr = 0; 563 mcq->count--; 564 } 565 else 566 { 567 val = meq->data[meq->rptr]; 568 if (++meq->rptr == MOUSE_EVENT_QUEUE_SIZE) 569 meq->rptr = 0; 570 meq->count--; 571 } 572 } 573 /* reading deasserts IRQ */ 574 if (aux) 575 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 12, 0); 576 else 577 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 1, 0); 578 /* Reading data clears the OBF bits, too. */ 579 s->status &= ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF); 580 } 581 /* reassert IRQs if data left */ 574 uint32_t val; 575 576 /* Return the current DBB contents. */ 577 val = s->dbbout; 578 579 /* Reading the DBB deasserts IRQs... */ 580 if (s->status & KBD_STAT_MOUSE_OBF) 581 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 12, 0); 582 else 583 PDMDevHlpISASetIrq(s->CTX_SUFF(pDevIns), 1, 0); 584 /* ...and clears the OBF bits. */ 585 s->status &= ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF); 586 587 /* Check if more data is available. */ 582 588 kbd_update_irq(s); 583 589 #ifdef DEBUG_KBD … … 591 597 s->scan_enabled = 1; 592 598 s->scancode_set = 2; 599 /* Flush the keyboard queue. */ 600 s->queue.count = 0; 601 s->queue.rptr = 0; 602 s->queue.wptr = 0; 593 603 } 594 604 … … 1055 1065 switch(s->write_cmd) { 1056 1066 case 0: 1067 /* Automatically enables keyboard interface. */ 1068 s->mode &= ~KBD_MODE_DISABLE_KBD; 1057 1069 rc = kbd_write_keyboard(s, val); 1058 1070 break;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器