Changeset 62573 in vbox for trunk/src/VBox
- Timestamp:
- Jul 27, 2016 9:03:31 AM (8 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r62513 r62573 58 58 #define TARGET_I386 59 59 60 #ifndef VBOX_WITH_NEW_PS2M61 #define PCKBD_SAVED_STATE_VERSION 762 #else63 60 #define PCKBD_SAVED_STATE_VERSION 8 64 #endif65 61 66 62 #ifndef VBOX_DEVICE_STRUCT_TESTCASE … … 128 124 #define KBD_MODE_RFU 0x80 129 125 130 #ifndef VBOX_WITH_NEW_PS2M131 /* Mouse Commands */132 #define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */133 #define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */134 #define AUX_SET_RES 0xE8 /* Set resolution */135 #define AUX_GET_SCALE 0xE9 /* Get scaling factor */136 #define AUX_SET_STREAM 0xEA /* Set stream mode */137 #define AUX_POLL 0xEB /* Poll */138 #define AUX_RESET_WRAP 0xEC /* Reset wrap mode */139 #define AUX_SET_WRAP 0xEE /* Set wrap mode */140 #define AUX_SET_REMOTE 0xF0 /* Set remote mode */141 #define AUX_GET_TYPE 0xF2 /* Get type */142 #define AUX_SET_SAMPLE 0xF3 /* Set sample rate */143 #define AUX_ENABLE_DEV 0xF4 /* Enable aux device */144 #define AUX_DISABLE_DEV 0xF5 /* Disable aux device */145 #define AUX_SET_DEFAULT 0xF6146 #define AUX_RESET 0xFF /* Reset aux device */147 #define AUX_ACK 0xFA /* Command byte ACK. */148 #define AUX_NACK 0xFE /* Command byte NACK. */149 150 #define MOUSE_STATUS_REMOTE 0x40151 #define MOUSE_STATUS_ENABLED 0x20152 #define MOUSE_STATUS_SCALE21 0x10153 154 /** Supported mouse protocols */155 enum156 {157 MOUSE_PROT_PS2 = 0,158 MOUSE_PROT_IMPS2 = 3,159 MOUSE_PROT_IMEX = 4160 };161 162 /** @name Mouse flags */163 /** @{ */164 /** IMEX horizontal scroll-wheel mode is active */165 # define MOUSE_REPORT_HORIZONTAL 0x01166 /** @} */167 168 #define MOUSE_CMD_QUEUE_SIZE 8169 170 typedef struct {171 uint8_t data[MOUSE_CMD_QUEUE_SIZE];172 int rptr, wptr, count;173 } MouseCmdQueue;174 175 176 #define MOUSE_EVENT_QUEUE_SIZE 256177 178 typedef struct179 {180 uint8_t data[MOUSE_EVENT_QUEUE_SIZE];181 int rptr;182 int wptr;183 int count;184 } MouseEventQueue;185 #endif186 126 187 127 /** … … 192 132 typedef struct KBDState 193 133 { 194 #ifndef VBOX_WITH_NEW_PS2M195 MouseCmdQueue mouse_command_queue;196 MouseEventQueue mouse_event_queue;197 #endif198 134 uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ 199 135 uint8_t status; … … 203 139 int32_t translate; 204 140 int32_t xlat_state; 205 #ifndef VBOX_WITH_NEW_PS2M206 /* mouse state */207 int32_t mouse_write_cmd;208 uint8_t mouse_status;209 uint8_t mouse_resolution;210 uint8_t mouse_sample_rate;211 uint8_t mouse_wrap;212 uint8_t mouse_type; /* MOUSE_PROT_PS2, *_IMPS/2, *_IMEX */213 uint8_t mouse_detect_state;214 int32_t mouse_dx; /* current values, needed for 'poll' mode */215 int32_t mouse_dy;216 int32_t mouse_dz;217 int32_t mouse_dw;218 int32_t mouse_flags;219 uint8_t mouse_buttons;220 uint8_t mouse_buttons_reported;221 222 uint32_t Alignment0;223 #endif224 141 225 142 /** Pointer to the device instance - RC. */ … … 237 154 #endif 238 155 239 #ifdef VBOX_WITH_NEW_PS2M240 156 /** Mouse state (implemented in separate PS2M module). */ 241 157 #ifdef VBOX_DEVICE_STRUCT_TESTCASE … … 244 160 PS2M Aux; 245 161 #endif 246 #else247 /**248 * Mouse port - LUN#1.249 *250 * @implements PDMIBASE251 * @implements PDMIMOUSEPORT252 */253 struct254 {255 /** The base interface for the mouse port. */256 PDMIBASE IBase;257 /** The mouse port base interface. */258 PDMIMOUSEPORT IPort;259 260 /** The base interface of the attached mouse driver. */261 R3PTRTYPE(PPDMIBASE) pDrvBase;262 /** The mouse interface of the attached mouse driver. */263 R3PTRTYPE(PPDMIMOUSECONNECTOR) pDrv;264 } Mouse;265 #endif266 162 } KBDState; 267 163 … … 271 167 static void kbd_update_irq(KBDState *s) 272 168 { 273 #ifndef VBOX_WITH_NEW_PS2M274 MouseCmdQueue *mcq = &s->mouse_command_queue;275 MouseEventQueue *meq = &s->mouse_event_queue;276 #endif277 169 int irq12_level, irq1_level; 278 170 uint8_t val; … … 318 210 } 319 211 } 320 #ifdef VBOX_WITH_NEW_PS2M321 212 else if (!(s->mode & KBD_MODE_DISABLE_MOUSE) && PS2MByteFromAux(&s->Aux, &val) == VINF_SUCCESS) 322 213 { … … 324 215 s->status |= KBD_STAT_OBF | KBD_STAT_MOUSE_OBF; 325 216 } 326 #else327 else if ((mcq->count || meq->count) && !(s->mode & KBD_MODE_DISABLE_MOUSE))328 {329 s->status |= KBD_STAT_OBF | KBD_STAT_MOUSE_OBF;330 if (mcq->count)331 {332 s->dbbout = mcq->data[mcq->rptr];333 if (++mcq->rptr == MOUSE_CMD_QUEUE_SIZE)334 mcq->rptr = 0;335 mcq->count--;336 }337 else338 {339 s->dbbout = meq->data[meq->rptr];340 if (++meq->rptr == MOUSE_EVENT_QUEUE_SIZE)341 meq->rptr = 0;342 meq->count--;343 }344 }345 #endif346 217 } 347 218 /* Determine new IRQ state. */ … … 367 238 kbd_update_irq(s); 368 239 } 369 370 #ifndef VBOX_WITH_NEW_PS2M371 static void kbd_queue(KBDState *s, int b, int aux)372 {373 MouseCmdQueue *mcq = &s->mouse_command_queue;374 MouseEventQueue *meq = &s->mouse_event_queue;375 376 #if defined(DEBUG_MOUSE) || defined(DEBUG_KBD)377 if (aux == 1)378 LogRel3(("%s: mouse command response: 0x%02x\n", __PRETTY_FUNCTION__, b));379 else if (aux == 2)380 LogRel3(("%s: mouse event data: 0x%02x\n", __PRETTY_FUNCTION__, b));381 #ifdef DEBUG_KBD382 else383 LogRel3(("%s: kbd event: 0x%02x\n", __PRETTY_FUNCTION__, b));384 #endif385 #endif386 switch (aux)387 {388 case 0: /* keyboard */389 AssertMsgFailed(("kbd_queue() no longer supported for keyboard!\n"));390 break;391 case 1: /* mouse command response */392 if (mcq->count >= MOUSE_CMD_QUEUE_SIZE)393 return;394 mcq->data[mcq->wptr] = b;395 if (++mcq->wptr == MOUSE_CMD_QUEUE_SIZE)396 mcq->wptr = 0;397 mcq->count++;398 break;399 case 2: /* mouse event data */400 if (meq->count >= MOUSE_EVENT_QUEUE_SIZE)401 return;402 meq->data[meq->wptr] = b;403 if (++meq->wptr == MOUSE_EVENT_QUEUE_SIZE)404 meq->wptr = 0;405 meq->count++;406 break;407 default:408 AssertMsgFailed(("aux=%d\n", aux));409 }410 kbd_update_irq(s);411 }412 #endif413 240 414 241 static void kbc_dbb_out(void *opaque, uint8_t val) … … 607 434 { 608 435 KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *); 609 #ifdef VBOX_WITH_NEW_PS2M610 436 return &pThis->Aux; 611 #else 612 return NULL; 613 #endif 614 } 615 616 #ifndef VBOX_WITH_NEW_PS2M 617 static void kbd_mouse_set_reported_buttons(KBDState *s, unsigned fButtons, unsigned fButtonMask) 618 { 619 s->mouse_buttons_reported |= (fButtons & fButtonMask); 620 s->mouse_buttons_reported &= (fButtons | ~fButtonMask); 621 } 622 623 /** 624 * Send a single relative packet in 3-byte PS/2 format to the PS/2 controller. 625 * @param s keyboard state object 626 * @param dx relative X value, must be between -256 and +255 627 * @param dy relative y value, must be between -256 and +255 628 * @param fButtonsLow the state of the two first mouse buttons 629 * @param fButtonsPacked the state of the upper three mouse buttons and 630 * scroll wheel movement, packed as per the 631 * MOUSE_EXT_* defines. For standard PS/2 packets 632 * only pass the value of button 3 here. 633 */ 634 static void kbd_mouse_send_rel3_packet(KBDState *s, bool fToCmdQueue) 635 { 636 int aux = fToCmdQueue ? 1 : 2; 637 int dx1 = s->mouse_dx < 0 ? RT_MAX(s->mouse_dx, -256) 638 : RT_MIN(s->mouse_dx, 255); 639 int dy1 = s->mouse_dy < 0 ? RT_MAX(s->mouse_dy, -256) 640 : RT_MIN(s->mouse_dy, 255); 641 unsigned int b; 642 unsigned fButtonsLow = s->mouse_buttons & 0x07; 643 s->mouse_dx -= dx1; 644 s->mouse_dy -= dy1; 645 kbd_mouse_set_reported_buttons(s, fButtonsLow, 0x07); 646 LogRel3(("%s: dx1=%d, dy1=%d, fButtonsLow=0x%x\n", 647 __PRETTY_FUNCTION__, dx1, dy1, fButtonsLow)); 648 b = 0x08 | ((dx1 < 0 ? 1 : 0) << 4) | ((dy1 < 0 ? 1 : 0) << 5) 649 | fButtonsLow; 650 kbd_queue(s, b, aux); 651 kbd_queue(s, dx1 & 0xff, aux); 652 kbd_queue(s, dy1 & 0xff, aux); 653 } 654 655 static void kbd_mouse_send_imps2_byte4(KBDState *s, bool fToCmdQueue) 656 { 657 int aux = fToCmdQueue ? 1 : 2; 658 659 int dz1 = s->mouse_dz < 0 ? RT_MAX(s->mouse_dz, -127) 660 : RT_MIN(s->mouse_dz, 127); 661 LogRel3(("%s: dz1=%d\n", __PRETTY_FUNCTION__, dz1)); 662 s->mouse_dz -= dz1; 663 kbd_queue(s, dz1 & 0xff, aux); 664 } 665 666 static void kbd_mouse_send_imex_byte4(KBDState *s, bool fToCmdQueue) 667 { 668 int aux = fToCmdQueue ? 1 : 2; 669 int dz1 = 0, dw1 = 0; 670 unsigned fButtonsHigh = s->mouse_buttons & 0x18; 671 672 if (s->mouse_dw > 0) 673 dw1 = 1; 674 else if (s->mouse_dw < 0) 675 dw1 = -1; 676 else if (s->mouse_dz > 0) 677 dz1 = 1; 678 else if (s->mouse_dz < 0) 679 dz1 = -1; 680 if (s->mouse_dw && s->mouse_flags & MOUSE_REPORT_HORIZONTAL) 681 { 682 LogRel3(("%s: dw1=%d\n", __PRETTY_FUNCTION__, dw1)); 683 kbd_queue(s, 0x40 | (dw1 & 0x3f), aux); 684 } 685 else 686 { 687 LogRel3(("%s: dz1=%d, dw1=%d, fButtonsHigh=0x%x\n", 688 __PRETTY_FUNCTION__, dz1, dw1, fButtonsHigh)); 689 unsigned u4Low = dw1 > 0 ? 9 /* -7 & 0xf */ 690 : dw1 < 0 ? 7 691 : dz1 > 0 ? 1 692 : dz1 < 0 ? 0xf /* -1 & 0xf */ 693 : 0; 694 kbd_mouse_set_reported_buttons(s, fButtonsHigh, 0x18); 695 kbd_queue(s, (fButtonsHigh << 1) | u4Low, aux); 696 } 697 s->mouse_dz -= dz1; 698 s->mouse_dw -= dw1; 699 } 700 701 /** 702 * Send a single relative packet in (IM)PS/2 or IMEX format to the PS/2 703 * controller. 704 * @param s keyboard state object 705 * @param fToCmdQueue should this packet go to the command queue (or the 706 * event queue)? 707 */ 708 static void kbd_mouse_send_packet(KBDState *s, bool fToCmdQueue) 709 { 710 kbd_mouse_send_rel3_packet(s, fToCmdQueue); 711 if (s->mouse_type == MOUSE_PROT_IMPS2) 712 kbd_mouse_send_imps2_byte4(s, fToCmdQueue); 713 if (s->mouse_type == MOUSE_PROT_IMEX) 714 kbd_mouse_send_imex_byte4(s, fToCmdQueue); 715 } 716 717 #ifdef IN_RING3 718 719 static bool kbd_mouse_unreported(KBDState *s) 720 { 721 return s->mouse_dx 722 || s->mouse_dy 723 || s->mouse_dz 724 || s->mouse_dw 725 || s->mouse_buttons != s->mouse_buttons_reported; 726 } 727 728 static size_t kbd_mouse_event_queue_free(KBDState *s) 729 { 730 AssertReturn(s->mouse_event_queue.count <= MOUSE_EVENT_QUEUE_SIZE, 0); 731 return MOUSE_EVENT_QUEUE_SIZE - s->mouse_event_queue.count; 732 } 733 734 static void pc_kbd_mouse_event(void *opaque, int dx, int dy, int dz, int dw, 735 int buttons_state) 736 { 737 LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d, buttons_state=0x%x\n", 738 __PRETTY_FUNCTION__, dx, dy, dz, dw, buttons_state)); 739 KBDState *s = (KBDState*)opaque; 740 741 /* check if deltas are recorded when disabled */ 742 if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) 743 return; 744 AssertReturnVoid((buttons_state & ~0x1f) == 0); 745 746 s->mouse_dx += dx; 747 s->mouse_dy -= dy; 748 if ( (s->mouse_type == MOUSE_PROT_IMPS2) 749 || (s->mouse_type == MOUSE_PROT_IMEX)) 750 s->mouse_dz += dz; 751 if (s->mouse_type == MOUSE_PROT_IMEX) 752 s->mouse_dw += dw; 753 s->mouse_buttons = buttons_state; 754 if (!(s->mouse_status & MOUSE_STATUS_REMOTE)) 755 /* if not remote, send event. Multiple events are sent if 756 too big deltas */ 757 while ( kbd_mouse_unreported(s) 758 && kbd_mouse_event_queue_free(s) > 4) 759 kbd_mouse_send_packet(s, false); 760 } 761 762 /* Report a change in status down the driver chain */ 763 static void kbd_mouse_update_downstream_status(KBDState *pThis) 764 { 765 PPDMIMOUSECONNECTOR pDrv = pThis->Mouse.pDrv; 766 bool fEnabled = !!(pThis->mouse_status & MOUSE_STATUS_ENABLED); 767 if (pDrv) 768 pDrv->pfnReportModes(pDrv, fEnabled, false, false); 769 } 770 771 #endif /* IN_RING3 */ 772 773 static int kbd_write_mouse(KBDState *s, int val) 774 { 775 #ifdef DEBUG_MOUSE 776 LogRelFlowFunc(("kbd: write mouse 0x%02x\n", val)); 777 #endif 778 int rc = VINF_SUCCESS; 779 /* Flush the mouse command response queue. */ 780 s->mouse_command_queue.count = 0; 781 s->mouse_command_queue.rptr = 0; 782 s->mouse_command_queue.wptr = 0; 783 switch(s->mouse_write_cmd) { 784 default: 785 case -1: 786 /* mouse command */ 787 if (s->mouse_wrap) { 788 if (val == AUX_RESET_WRAP) { 789 s->mouse_wrap = 0; 790 kbd_queue(s, AUX_ACK, 1); 791 return VINF_SUCCESS; 792 } else if (val != AUX_RESET) { 793 kbd_queue(s, val, 1); 794 return VINF_SUCCESS; 795 } 796 } 797 switch(val) { 798 case AUX_SET_SCALE11: 799 s->mouse_status &= ~MOUSE_STATUS_SCALE21; 800 kbd_queue(s, AUX_ACK, 1); 801 break; 802 case AUX_SET_SCALE21: 803 s->mouse_status |= MOUSE_STATUS_SCALE21; 804 kbd_queue(s, AUX_ACK, 1); 805 break; 806 case AUX_SET_STREAM: 807 s->mouse_status &= ~MOUSE_STATUS_REMOTE; 808 kbd_queue(s, AUX_ACK, 1); 809 break; 810 case AUX_SET_WRAP: 811 s->mouse_wrap = 1; 812 kbd_queue(s, AUX_ACK, 1); 813 break; 814 case AUX_SET_REMOTE: 815 s->mouse_status |= MOUSE_STATUS_REMOTE; 816 kbd_queue(s, AUX_ACK, 1); 817 break; 818 case AUX_GET_TYPE: 819 kbd_queue(s, AUX_ACK, 1); 820 kbd_queue(s, s->mouse_type, 1); 821 break; 822 case AUX_SET_RES: 823 case AUX_SET_SAMPLE: 824 s->mouse_write_cmd = val; 825 kbd_queue(s, AUX_ACK, 1); 826 break; 827 case AUX_GET_SCALE: 828 kbd_queue(s, AUX_ACK, 1); 829 kbd_queue(s, s->mouse_status, 1); 830 kbd_queue(s, s->mouse_resolution, 1); 831 kbd_queue(s, s->mouse_sample_rate, 1); 832 break; 833 case AUX_POLL: 834 kbd_queue(s, AUX_ACK, 1); 835 kbd_mouse_send_packet(s, true); 836 break; 837 case AUX_ENABLE_DEV: 838 #ifdef IN_RING3 839 LogRelFlowFunc(("Enabling mouse device\n")); 840 s->mouse_status |= MOUSE_STATUS_ENABLED; 841 kbd_queue(s, AUX_ACK, 1); 842 kbd_mouse_update_downstream_status(s); 843 #else 844 LogRelFlowFunc(("Enabling mouse device, R0 stub\n")); 845 rc = VINF_IOM_R3_IOPORT_WRITE; 846 #endif 847 break; 848 case AUX_DISABLE_DEV: 849 #ifdef IN_RING3 850 s->mouse_status &= ~MOUSE_STATUS_ENABLED; 851 kbd_queue(s, AUX_ACK, 1); 852 /* Flush the mouse events queue. */ 853 s->mouse_event_queue.count = 0; 854 s->mouse_event_queue.rptr = 0; 855 s->mouse_event_queue.wptr = 0; 856 kbd_mouse_update_downstream_status(s); 857 #else 858 rc = VINF_IOM_R3_IOPORT_WRITE; 859 #endif 860 break; 861 case AUX_SET_DEFAULT: 862 #ifdef IN_RING3 863 s->mouse_sample_rate = 100; 864 s->mouse_resolution = 2; 865 s->mouse_status = 0; 866 kbd_queue(s, AUX_ACK, 1); 867 kbd_mouse_update_downstream_status(s); 868 #else 869 rc = VINF_IOM_R3_IOPORT_WRITE; 870 #endif 871 break; 872 case AUX_RESET: 873 #ifdef IN_RING3 874 s->mouse_sample_rate = 100; 875 s->mouse_resolution = 2; 876 s->mouse_status = 0; 877 s->mouse_type = MOUSE_PROT_PS2; 878 kbd_queue(s, AUX_ACK, 1); 879 kbd_queue(s, 0xaa, 1); 880 kbd_queue(s, s->mouse_type, 1); 881 /* Flush the mouse events queue. */ 882 s->mouse_event_queue.count = 0; 883 s->mouse_event_queue.rptr = 0; 884 s->mouse_event_queue.wptr = 0; 885 kbd_mouse_update_downstream_status(s); 886 #else 887 rc = VINF_IOM_R3_IOPORT_WRITE; 888 #endif 889 break; 890 default: 891 /* NACK all commands we don't know. 892 893 The usecase for this is the OS/2 mouse driver which will try 894 read 0xE2 in order to figure out if it's a trackpoint device 895 or not. If it doesn't get a NACK (or ACK) on the command it'll 896 do several hundred thousand status reads before giving up. This 897 is slows down the OS/2 boot up considerably. (It also seems that 898 the code is somehow vulnerable while polling like this and that 899 mouse or keyboard input at this point might screw things up badly.) 900 901 From http://www.win.tue.nl/~aeb/linux/kbd/scancodes-13.html: 902 903 Every command or data byte sent to the mouse (except for the 904 resend command fe) is ACKed with fa. If the command or data 905 is invalid, it is NACKed with fe. If the next byte is again 906 invalid, the reply is ERROR: fc. */ 907 /** @todo send error if we NACKed the previous command? */ 908 kbd_queue(s, AUX_NACK, 1); 909 break; 910 } 911 break; 912 case AUX_SET_SAMPLE: 913 s->mouse_sample_rate = val; 914 /* detect IMPS/2 or IMEX */ 915 /* And enable horizontal scrolling reporting when requested */ 916 switch(s->mouse_detect_state) { 917 default: 918 case 0: 919 if (val == 200) 920 s->mouse_detect_state = 1; 921 break; 922 case 1: 923 if (val == 100) 924 s->mouse_detect_state = 2; 925 else if (val == 200) 926 s->mouse_detect_state = 3; 927 else if ((val == 80) && s->mouse_type == MOUSE_PROT_IMEX) 928 /* enable horizontal scrolling, byte two */ 929 s->mouse_detect_state = 4; 930 else 931 s->mouse_detect_state = 0; 932 break; 933 case 2: 934 if (val == 80 && s->mouse_type < MOUSE_PROT_IMEX) 935 { 936 LogRelFlowFunc(("switching mouse device to IMPS/2 mode\n")); 937 s->mouse_type = MOUSE_PROT_IMPS2; 938 } 939 s->mouse_detect_state = 0; 940 break; 941 case 3: 942 if (val == 80) 943 { 944 LogRelFlowFunc(("switching mouse device to IMEX mode\n")); 945 s->mouse_type = MOUSE_PROT_IMEX; 946 } 947 s->mouse_detect_state = 0; 948 break; 949 case 4: 950 if (val == 40) 951 { 952 LogRelFlowFunc(("enabling IMEX horizontal scrolling reporting\n")); 953 s->mouse_flags |= MOUSE_REPORT_HORIZONTAL; 954 } 955 s->mouse_detect_state = 0; 956 break; 957 } 958 kbd_queue(s, AUX_ACK, 1); 959 s->mouse_write_cmd = -1; 960 break; 961 case AUX_SET_RES: 962 if (0 <= val && val < 4) 963 { 964 s->mouse_resolution = val; 965 kbd_queue(s, AUX_ACK, 1); 966 } 967 else 968 kbd_queue(s, AUX_NACK, 1); 969 s->mouse_write_cmd = -1; 970 break; 971 } 972 return rc; 973 } 974 #endif 437 } 975 438 976 439 static int kbd_write_data(void *opaque, uint32_t addr, uint32_t val) … … 1023 486 /* Automatically enables aux interface. */ 1024 487 s->mode &= ~KBD_MODE_DISABLE_MOUSE; 1025 #ifdef VBOX_WITH_NEW_PS2M1026 488 rc = PS2MByteToAux(&s->Aux, val); 1027 489 if (rc == VINF_SUCCESS) 1028 490 kbd_update_irq(s); 1029 #else1030 rc = kbd_write_mouse(s, val);1031 #endif1032 491 break; 1033 492 default: … … 1044 503 { 1045 504 KBDState *s = (KBDState*)opaque; 1046 #ifndef VBOX_WITH_NEW_PS2M1047 MouseCmdQueue *mcq;1048 MouseEventQueue *meq;1049 1050 s->mouse_write_cmd = -1;1051 #endif1052 505 s->mode = KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT; 1053 506 s->status = KBD_STAT_CMD | KBD_STAT_UNLOCKED; … … 1055 508 s->write_cmd = 0; 1056 509 s->translate = 0; 1057 #ifndef VBOX_WITH_NEW_PS2M1058 if (s->mouse_status)1059 {1060 s->mouse_status = 0;1061 kbd_mouse_update_downstream_status(s);1062 }1063 s->mouse_resolution = 0;1064 s->mouse_sample_rate = 0;1065 s->mouse_wrap = 0;1066 s->mouse_type = MOUSE_PROT_PS2;1067 s->mouse_detect_state = 0;1068 s->mouse_dx = 0;1069 s->mouse_dy = 0;1070 s->mouse_dz = 0;1071 s->mouse_dw = 0;1072 s->mouse_flags = 0;1073 s->mouse_buttons = 0;1074 s->mouse_buttons_reported = 0;1075 mcq = &s->mouse_command_queue;1076 mcq->rptr = 0;1077 mcq->wptr = 0;1078 mcq->count = 0;1079 meq = &s->mouse_event_queue;1080 meq->rptr = 0;1081 meq->wptr = 0;1082 meq->count = 0;1083 #endif1084 510 } 1085 511 1086 512 static void kbd_save(PSSMHANDLE pSSM, KBDState *s) 1087 513 { 1088 #ifndef VBOX_WITH_NEW_PS2M1089 uint32_t cItems;1090 int i;1091 #endif1092 1093 514 SSMR3PutU8(pSSM, s->write_cmd); 1094 515 SSMR3PutU8(pSSM, s->status); 1095 516 SSMR3PutU8(pSSM, s->mode); 1096 517 SSMR3PutU8(pSSM, s->dbbout); 1097 #ifndef VBOX_WITH_NEW_PS2M1098 SSMR3PutU32(pSSM, s->mouse_write_cmd);1099 SSMR3PutU8(pSSM, s->mouse_status);1100 SSMR3PutU8(pSSM, s->mouse_resolution);1101 SSMR3PutU8(pSSM, s->mouse_sample_rate);1102 SSMR3PutU8(pSSM, s->mouse_wrap);1103 SSMR3PutU8(pSSM, s->mouse_type);1104 SSMR3PutU8(pSSM, s->mouse_detect_state);1105 SSMR3PutU32(pSSM, s->mouse_dx);1106 SSMR3PutU32(pSSM, s->mouse_dy);1107 SSMR3PutU32(pSSM, s->mouse_dz);1108 SSMR3PutU32(pSSM, s->mouse_dw);1109 SSMR3PutU32(pSSM, s->mouse_flags);1110 SSMR3PutU8(pSSM, s->mouse_buttons);1111 SSMR3PutU8(pSSM, s->mouse_buttons_reported);1112 1113 cItems = s->mouse_command_queue.count;1114 SSMR3PutU32(pSSM, cItems);1115 for (i = s->mouse_command_queue.rptr; cItems-- > 0; i = (i + 1) % RT_ELEMENTS(s->mouse_command_queue.data))1116 SSMR3PutU8(pSSM, s->mouse_command_queue.data[i]);1117 Log(("kbd_save: %d mouse command queue items stored\n", s->mouse_command_queue.count));1118 1119 cItems = s->mouse_event_queue.count;1120 SSMR3PutU32(pSSM, cItems);1121 for (i = s->mouse_event_queue.rptr; cItems-- > 0; i = (i + 1) % RT_ELEMENTS(s->mouse_event_queue.data))1122 SSMR3PutU8(pSSM, s->mouse_event_queue.data[i]);1123 Log(("kbd_save: %d mouse event queue items stored\n", s->mouse_event_queue.count));1124 #endif1125 518 1126 519 /* terminator */ … … 1155 548 SSMR3GetU8(pSSM, &s->dbbout); 1156 549 } 1157 #ifndef VBOX_WITH_NEW_PS2M1158 SSMR3GetU32(pSSM, (uint32_t *)&s->mouse_write_cmd);1159 SSMR3GetU8(pSSM, &s->mouse_status);1160 SSMR3GetU8(pSSM, &s->mouse_resolution);1161 SSMR3GetU8(pSSM, &s->mouse_sample_rate);1162 SSMR3GetU8(pSSM, &s->mouse_wrap);1163 SSMR3GetU8(pSSM, &s->mouse_type);1164 SSMR3GetU8(pSSM, &s->mouse_detect_state);1165 SSMR3GetU32(pSSM, (uint32_t *)&s->mouse_dx);1166 SSMR3GetU32(pSSM, (uint32_t *)&s->mouse_dy);1167 SSMR3GetU32(pSSM, (uint32_t *)&s->mouse_dz);1168 if (version_id > 2)1169 {1170 SSMR3GetS32(pSSM, &s->mouse_dw);1171 SSMR3GetS32(pSSM, &s->mouse_flags);1172 }1173 SSMR3GetU8(pSSM, &s->mouse_buttons);1174 if (version_id == 4)1175 {1176 SSMR3GetU32(pSSM, &u32Dummy);1177 SSMR3GetU32(pSSM, &u32Dummy);1178 }1179 if (version_id > 3)1180 SSMR3GetU8(pSSM, &s->mouse_buttons_reported);1181 if (version_id == 4)1182 SSMR3GetU8(pSSM, &u8Dummy);1183 s->mouse_command_queue.count = 0;1184 s->mouse_command_queue.rptr = 0;1185 s->mouse_command_queue.wptr = 0;1186 s->mouse_event_queue.count = 0;1187 s->mouse_event_queue.rptr = 0;1188 s->mouse_event_queue.wptr = 0;1189 #else1190 550 if (version_id <= 7) 1191 551 { … … 1224 584 PS2MFixupState(&s->Aux, u8State, u8Rate, u8Proto); 1225 585 } 1226 #endif1227 586 1228 587 /* Determine the translation state. */ … … 1246 605 } 1247 606 1248 #ifndef VBOX_WITH_NEW_PS2M1249 rc = SSMR3GetU32(pSSM, &u32);1250 if (RT_FAILURE(rc))1251 return rc;1252 if (u32 > RT_ELEMENTS(s->mouse_command_queue.data))1253 {1254 AssertMsgFailed(("u32=%#x\n", u32));1255 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;1256 }1257 for (i = 0; i < u32; i++)1258 {1259 rc = SSMR3GetU8(pSSM, &s->mouse_command_queue.data[i]);1260 if (RT_FAILURE(rc))1261 return rc;1262 }1263 s->mouse_command_queue.wptr = u32 % RT_ELEMENTS(s->mouse_command_queue.data);1264 s->mouse_command_queue.count = u32;1265 Log(("kbd_load: %d mouse command queue items loaded\n", u32));1266 1267 rc = SSMR3GetU32(pSSM, &u32);1268 if (RT_FAILURE(rc))1269 return rc;1270 if (u32 > RT_ELEMENTS(s->mouse_event_queue.data))1271 {1272 AssertMsgFailed(("u32=%#x\n", u32));1273 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;1274 }1275 for (i = 0; i < u32; i++)1276 {1277 rc = SSMR3GetU8(pSSM, &s->mouse_event_queue.data[i]);1278 if (RT_FAILURE(rc))1279 return rc;1280 }1281 s->mouse_event_queue.wptr = u32 % RT_ELEMENTS(s->mouse_event_queue.data);1282 s->mouse_event_queue.count = u32;1283 Log(("kbd_load: %d mouse event queue items loaded\n", u32));1284 #else1285 607 if (version_id <= 7) 1286 608 { … … 1307 629 Log(("kbd_load: %d mouse command queue items discarded from old saved state\n", u32)); 1308 630 } 1309 #endif1310 631 1311 632 /* terminator */ … … 1318 639 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED; 1319 640 } 1320 #ifndef VBOX_WITH_NEW_PS2M1321 /* Resend a notification to Main if the device is active */1322 kbd_mouse_update_downstream_status(s);1323 #endif1324 641 return 0; 1325 642 } … … 1452 769 kbd_save(pSSM, pThis); 1453 770 PS2KSaveState(&pThis->Kbd, pSSM); 1454 #ifdef VBOX_WITH_NEW_PS2M1455 771 PS2MSaveState(&pThis->Aux, pSSM); 1456 #endif1457 772 return VINF_SUCCESS; 1458 773 } … … 1477 792 if (uVersion >= 6) 1478 793 rc = PS2KLoadState(&pThis->Kbd, pSSM, uVersion); 1479 #ifdef VBOX_WITH_NEW_PS2M1480 794 if (uVersion >= 8) 1481 795 rc = PS2MLoadState(&pThis->Aux, pSSM, uVersion); 1482 #endif1483 796 return rc; 1484 797 } … … 1508 821 kbd_reset(pThis); 1509 822 PS2KReset(&pThis->Kbd); 1510 #ifdef VBOX_WITH_NEW_PS2M1511 823 PS2MReset(&pThis->Aux); 1512 #endif 1513 } 1514 1515 1516 #ifndef VBOX_WITH_NEW_PS2M 1517 /* -=-=-=-=-=- Mouse: IBase -=-=-=-=-=- */ 1518 1519 /** 1520 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 1521 */ 1522 static DECLCALLBACK(void *) kbdMouseQueryInterface(PPDMIBASE pInterface, const char *pszIID) 1523 { 1524 KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Mouse.IBase); 1525 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->Mouse.IBase); 1526 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUSEPORT, &pThis->Mouse.IPort); 1527 return NULL; 1528 } 1529 1530 1531 /* -=-=-=-=-=- Mouse: IMousePort -=-=-=-=-=- */ 1532 1533 /** 1534 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent} 1535 */ 1536 static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, 1537 int32_t dy, int32_t dz, int32_t dw, 1538 uint32_t fButtons) 1539 { 1540 KBDState *pThis = RT_FROM_MEMBER(pInterface, KBDState, Mouse.IPort); 1541 int rc = PDMCritSectEnter(pThis->pDevInsR3->pCritSectRoR3, VERR_SEM_BUSY); 1542 AssertReleaseRC(rc); 1543 1544 pc_kbd_mouse_event(pThis, dx, dy, dz, dw, fButtons); 1545 1546 PDMCritSectLeave(pThis->pDevInsR3->pCritSectRoR3); 1547 return VINF_SUCCESS; 1548 } 1549 1550 /** 1551 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventAbs} 1552 */ 1553 static DECLCALLBACK(int) kbdMousePutEventAbs(PPDMIMOUSEPORT pInterface, 1554 uint32_t x, uint32_t y, int32_t dz, 1555 int32_t dw, uint32_t fButtons) 1556 { 1557 AssertFailedReturn(VERR_NOT_SUPPORTED); 1558 NOREF(pInterface); NOREF(x); NOREF(y); NOREF(dz); NOREF(dw); NOREF(fButtons); 1559 } 1560 1561 /** 1562 * @interface_method_impl{PDMIMOUSEPORT,pfnPutEventMultiTouch} 1563 */ 1564 static DECLCALLBACK(int) kbdMousePutEventMultiTouch(PPDMIMOUSEPORT pInterface, 1565 uint8_t cContacts, 1566 const uint64_t *pau64Contacts, 1567 uint32_t u32ScanTime) 1568 { 1569 AssertFailedReturn(VERR_NOT_SUPPORTED); 1570 NOREF(pInterface); NOREF(cContacts); NOREF(pau64Contacts); NOREF(u32ScanTime); 1571 } 1572 #endif 824 } 825 1573 826 1574 827 /* -=-=-=-=-=- real code -=-=-=-=-=- */ … … 1611 864 /* LUN #1: aux/mouse */ 1612 865 case 1: 1613 #ifdef VBOX_WITH_NEW_PS2M1614 866 rc = PS2MAttach(&pThis->Aux, pDevIns, iLUN, fFlags); 1615 #else1616 rc = PDMDevHlpDriverAttach(pDevIns, iLUN, &pThis->Mouse.IBase, &pThis->Mouse.pDrvBase, "Aux (Mouse) Port");1617 if (RT_SUCCESS(rc))1618 {1619 pThis->Mouse.pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Mouse.pDrvBase, PDMIMOUSECONNECTOR);1620 if (!pThis->Mouse.pDrv)1621 {1622 AssertLogRelMsgFailed(("LUN #1 doesn't have a mouse interface! rc=%Rrc\n", rc));1623 rc = VERR_PDM_MISSING_INTERFACE;1624 }1625 }1626 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)1627 {1628 Log(("%s/%d: warning: no driver attached to LUN #1!\n", pDevIns->pReg->szName, pDevIns->iInstance));1629 rc = VINF_SUCCESS;1630 }1631 else1632 AssertLogRelMsgFailed(("Failed to attach LUN #1! rc=%Rrc\n", rc));1633 #endif1634 867 break; 1635 868 … … 1697 930 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 1698 931 PS2KRelocate(&pThis->Kbd, offDelta, pDevIns); 1699 #ifdef VBOX_WITH_NEW_PS2M1700 932 PS2MRelocate(&pThis->Aux, offDelta, pDevIns); 1701 #endif1702 933 } 1703 934 … … 1741 972 return rc; 1742 973 1743 #ifdef VBOX_WITH_NEW_PS2M1744 974 rc = PS2MConstruct(&pThis->Aux, pDevIns, pThis, iInstance); 1745 975 if (RT_FAILURE(rc)) 1746 976 return rc; 1747 #else1748 pThis->Mouse.IBase.pfnQueryInterface = kbdMouseQueryInterface;1749 pThis->Mouse.IPort.pfnPutEvent = kbdMousePutEvent;1750 pThis->Mouse.IPort.pfnPutEventAbs = kbdMousePutEventAbs;1751 pThis->Mouse.IPort.pfnPutEventMultiTouch = kbdMousePutEventMultiTouch;1752 #endif1753 977 1754 978 /* -
trunk/src/VBox/Devices/Makefile.kmk
r62572 r62573 78 78 Storage/VSCSI/VSCSILunSbc.cpp \ 79 79 Storage/VSCSI/VSCSILunMmc.cpp \ 80 Storage/VSCSI/VSCSILunSsc.cpp \ 80 81 Storage/VSCSI/VSCSISense.cpp \ 81 82 Storage/VSCSI/VSCSIIoReq.cpp \ … … 139 140 EFI/DevSmc.cpp \ 140 141 Graphics/DevVGA.cpp \ 142 Graphics/Dev8514A.cpp \ 141 143 Storage/DevATA.cpp \ 142 144 PC/DevPit-i8254.cpp \ … … 187 189 endif 188 190 189 ifn1of ($(KBUILD_TARGET), darwin )191 ifn1of ($(KBUILD_TARGET), darwin win) 190 192 VBoxDD_SOURCES += Storage/HBDMgmt-generic.cpp 191 193 endif 192 194 193 195 VBoxDD_SOURCES.darwin += Storage/HBDMgmt-darwin.cpp 194 #VBoxDD_SOURCES.win += Storage/HBDMgmt-win.cppDisabled until remaining issues are sorted out196 VBoxDD_SOURCES.win += Storage/HBDMgmt-win.cpp #Disabled until remaining issues are sorted out 195 197 196 198 VBoxDD_LIBS = # more later. … … 530 532 endif 531 533 532 533 # --- Input bits. ---534 535 ifdef VBOX_WITH_NEW_PS2M536 VBoxDD_DEFS += VBOX_WITH_NEW_PS2M537 endif538 539 540 534 # --- Audio bits. --- 541 535 … … 867 861 EFI/DevSmc.cpp \ 868 862 Graphics/DevVGA.cpp \ 863 Graphics/Dev8514A.cpp \ 869 864 Input/DevPS2.cpp \ 870 865 Input/PS2K.cpp \ … … 973 968 VBoxDDGC_SOURCES += \ 974 969 Storage/DevNVMe.cpp 975 endif976 977 ifdef VBOX_WITH_NEW_PS2M978 VBoxDDRC_DEFS += VBOX_WITH_NEW_PS2M979 970 endif 980 971 … … 1037 1028 EFI/DevSmc.cpp \ 1038 1029 Graphics/DevVGA.cpp \ 1030 Graphics/Dev8514A.cpp \ 1039 1031 Input/DevPS2.cpp \ 1040 1032 Input/PS2K.cpp \ … … 1141 1133 VBoxDDR0_SOURCES += \ 1142 1134 Storage/DevNVMe.cpp 1143 endif1144 1145 ifdef VBOX_WITH_NEW_PS2M1146 VBoxDDR0_DEFS += VBOX_WITH_NEW_PS2M1147 1135 endif 1148 1136 -
trunk/src/VBox/Devices/testcase/Makefile.kmk
r62505 r62573 37 37 $(if $(VBOX_WITH_NEW_APIC),VBOX_WITH_NEW_APIC,) \ 38 38 $(if $(VBOX_WITH_NEW_IOAPIC),VBOX_WITH_NEW_IOAPIC,) \ 39 $(if $(VBOX_WITH_NEW_PS2M),VBOX_WITH_NEW_PS2M,) \40 39 $(if $(VBOX_WITH_NVME_IMPL),VBOX_WITH_NVME_IMPL,) \ 41 40 $(if $(VBOX_WITH_AUDIO_50),VBOX_WITH_AUDIO_50,) \ -
trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp
r62563 r62573 425 425 426 426 /* Input/pckbd.c */ 427 #ifndef VBOX_WITH_NEW_PS2M428 GEN_CHECK_SIZE(MouseCmdQueue);429 GEN_CHECK_OFF(MouseCmdQueue, data);430 GEN_CHECK_OFF(MouseCmdQueue, rptr);431 GEN_CHECK_OFF(MouseCmdQueue, wptr);432 GEN_CHECK_OFF(MouseCmdQueue, count);433 GEN_CHECK_SIZE(MouseEventQueue);434 GEN_CHECK_OFF(MouseEventQueue, data);435 GEN_CHECK_OFF(MouseEventQueue, rptr);436 GEN_CHECK_OFF(MouseEventQueue, wptr);437 GEN_CHECK_OFF(MouseEventQueue, count);438 #endif439 427 GEN_CHECK_SIZE(KBDState); 440 428 GEN_CHECK_OFF(KBDState, write_cmd); 441 429 GEN_CHECK_OFF(KBDState, status); 442 430 GEN_CHECK_OFF(KBDState, mode); 443 #ifndef VBOX_WITH_NEW_PS2M444 GEN_CHECK_OFF(KBDState, mouse_command_queue);445 GEN_CHECK_OFF(KBDState, mouse_event_queue);446 GEN_CHECK_OFF(KBDState, mouse_write_cmd);447 GEN_CHECK_OFF(KBDState, mouse_status);448 GEN_CHECK_OFF(KBDState, mouse_resolution);449 GEN_CHECK_OFF(KBDState, mouse_sample_rate);450 GEN_CHECK_OFF(KBDState, mouse_wrap);451 GEN_CHECK_OFF(KBDState, mouse_type);452 GEN_CHECK_OFF(KBDState, mouse_detect_state);453 GEN_CHECK_OFF(KBDState, mouse_dx);454 GEN_CHECK_OFF(KBDState, mouse_dy);455 GEN_CHECK_OFF(KBDState, mouse_dz);456 GEN_CHECK_OFF(KBDState, mouse_dw);457 GEN_CHECK_OFF(KBDState, mouse_buttons);458 #endif459 431 GEN_CHECK_OFF(KBDState, pDevInsR3); 460 432 GEN_CHECK_OFF(KBDState, pDevInsR0); … … 488 460 GEN_CHECK_OFF(PS2K, Keyboard.pDrvBase); 489 461 GEN_CHECK_OFF(PS2K, Keyboard.pDrv); 490 #ifdef VBOX_WITH_NEW_PS2M491 462 /* Input/PS2M.c */ 492 463 GEN_CHECK_SIZE(PS2M); … … 517 488 GEN_CHECK_OFF(PS2M, Mouse.pDrvBase); 518 489 GEN_CHECK_OFF(PS2M, Mouse.pDrv); 519 #else520 GEN_CHECK_OFF(KBDState, Mouse.IBase);521 GEN_CHECK_OFF(KBDState, Mouse.IPort);522 GEN_CHECK_OFF(KBDState, Mouse.pDrvBase);523 GEN_CHECK_OFF(KBDState, Mouse.pDrv);524 #endif525 490 526 491 /* Network/DevPCNet.cpp */
Note:
See TracChangeset
for help on using the changeset viewer.