Changeset 82191 in vbox for trunk/src/VBox/Devices/Input
- Timestamp:
- Nov 25, 2019 5:48:55 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Input
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r82190 r82191 54 54 #include "DevPS2.h" 55 55 56 57 /********************************************************************************************************************************* 58 * Defined Constants And Macros * 59 *********************************************************************************************************************************/ 56 60 /* Do not remove this (unless eliminating the corresponding ifdefs), it will 57 61 * cause instant triple faults when booting Windows VMs. */ … … 59 63 60 64 #define PCKBD_SAVED_STATE_VERSION 8 61 62 #ifndef VBOX_DEVICE_STRUCT_TESTCASE63 64 65 /*********************************************************************************************************************************66 * Internal Functions *67 *********************************************************************************************************************************/68 RT_C_DECLS_BEGIN69 PDMBOTHCBDECL(int) kbdIOPortDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);70 PDMBOTHCBDECL(int) kbdIOPortDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);71 PDMBOTHCBDECL(int) kbdIOPortStatusRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb);72 PDMBOTHCBDECL(int) kbdIOPortCommandWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb);73 RT_C_DECLS_END74 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */75 65 76 66 /* debug PC keyboard */ … … 125 115 126 116 117 /********************************************************************************************************************************* 118 * Structures and Typedefs * 119 *********************************************************************************************************************************/ 120 /** AT to PC scancode translator state. */ 121 typedef enum 122 { 123 XS_IDLE, /**< Starting state. */ 124 XS_BREAK, /**< F0 break byte was received. */ 125 XS_HIBIT /**< Break code still active. */ 126 } xlat_state_t; 127 128 129 /********************************************************************************************************************************* 130 * Global Variables * 131 *********************************************************************************************************************************/ 132 /* Table used by the keyboard controller to optionally translate the incoming 133 * keyboard data. Note that the translation is designed for essentially taking 134 * Scan Set 2 input and producing Scan Set 1 output, but can be turned on and 135 * off regardless of what the keyboard is sending. 136 */ 137 static uint8_t const g_aAT2PC[128] = 138 { 139 0xff,0x43,0x41,0x3f,0x3d,0x3b,0x3c,0x58,0x64,0x44,0x42,0x40,0x3e,0x0f,0x29,0x59, 140 0x65,0x38,0x2a,0x70,0x1d,0x10,0x02,0x5a,0x66,0x71,0x2c,0x1f,0x1e,0x11,0x03,0x5b, 141 0x67,0x2e,0x2d,0x20,0x12,0x05,0x04,0x5c,0x68,0x39,0x2f,0x21,0x14,0x13,0x06,0x5d, 142 0x69,0x31,0x30,0x23,0x22,0x15,0x07,0x5e,0x6a,0x72,0x32,0x24,0x16,0x08,0x09,0x5f, 143 0x6b,0x33,0x25,0x17,0x18,0x0b,0x0a,0x60,0x6c,0x34,0x35,0x26,0x27,0x19,0x0c,0x61, 144 0x6d,0x73,0x28,0x74,0x1a,0x0d,0x62,0x6e,0x3a,0x36,0x1c,0x1b,0x75,0x2b,0x63,0x76, 145 0x55,0x56,0x77,0x78,0x79,0x7a,0x0e,0x7b,0x7c,0x4f,0x7d,0x4b,0x47,0x7e,0x7f,0x6f, 146 0x52,0x53,0x50,0x4c,0x4d,0x48,0x01,0x45,0x57,0x4e,0x51,0x4a,0x37,0x49,0x46,0x54 147 }; 148 149 150 151 /********************************************************************************************************************************* 152 * Internal Functions * 153 *********************************************************************************************************************************/ 154 RT_C_DECLS_BEGIN 155 PDMBOTHCBDECL(int) kbdIOPortDataRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb); 156 PDMBOTHCBDECL(int) kbdIOPortDataWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 157 PDMBOTHCBDECL(int) kbdIOPortStatusRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb); 158 PDMBOTHCBDECL(int) kbdIOPortCommandWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb); 159 RT_C_DECLS_END 160 161 162 /** 163 * Convert an AT (Scan Set 2) scancode to PC (Scan Set 1). 164 * 165 * @param state Current state of the translator 166 * (xlat_state_t). 167 * @param scanIn Incoming scan code. 168 * @param pScanOut Pointer to outgoing scan code. The 169 * contents are only valid if returned 170 * state is not XS_BREAK. 171 * 172 * @return xlat_state_t New state of the translator. 173 */ 174 static int32_t kbcXlateAT2PC(int32_t state, uint8_t scanIn, uint8_t *pScanOut) 175 { 176 uint8_t scan_in; 177 uint8_t scan_out; 178 179 Assert(pScanOut); 180 Assert(state == XS_IDLE || state == XS_BREAK || state == XS_HIBIT); 181 182 /* Preprocess the scan code for a 128-entry translation table. */ 183 if (scanIn == 0x83) /* Check for F7 key. */ 184 scan_in = 0x02; 185 else if (scanIn == 0x84) /* Check for SysRq key. */ 186 scan_in = 0x7f; 187 else 188 scan_in = scanIn; 189 190 /* Values 0x80 and above are passed through, except for 0xF0 191 * which indicates a key release. 192 */ 193 if (scan_in < 0x80) 194 { 195 scan_out = g_aAT2PC[scan_in]; 196 /* Turn into break code if required. */ 197 if (state == XS_BREAK || state == XS_HIBIT) 198 scan_out |= 0x80; 199 200 state = XS_IDLE; 201 } 202 else 203 { 204 /* NB: F0 E0 10 will be translated to E0 E5 (high bit set on last byte)! */ 205 if (scan_in == 0xF0) /* Check for break code. */ 206 state = XS_BREAK; 207 else if (state == XS_BREAK) 208 state = XS_HIBIT; /* Remember the break bit. */ 209 scan_out = scan_in; 210 } 211 LogFlowFunc(("scan code %02X translated to %02X; new state is %d\n", 212 scanIn, scan_out, state)); 213 214 *pScanOut = scan_out; 215 return state; 216 } 217 127 218 128 219 /* update irq and KBD_STAT_[MOUSE_]OBF */ … … 151 242 uint8_t xlated_val; 152 243 153 s->xlat_state = XlateAT2PC(s->xlat_state, val, &xlated_val);244 s->xlat_state = kbcXlateAT2PC(s->xlat_state, val, &xlated_val); 154 245 val = xlated_val; 155 246 … … 159 250 while (s->xlat_state == XS_BREAK && PS2KByteFromKbd(&s->Kbd, &val) == VINF_SUCCESS) 160 251 { 161 s->xlat_state = XlateAT2PC(s->xlat_state, val, &xlated_val);252 s->xlat_state = kbcXlateAT2PC(s->xlat_state, val, &xlated_val); 162 253 val = xlated_val; 163 254 } -
trunk/src/VBox/Devices/Input/DevPS2.h
r82190 r82191 376 376 void KBCUpdateInterrupts(void *pKbc); 377 377 378 379 ///@todo: This should live with the KBC implementation.380 /** AT to PC scancode translator state. */381 typedef enum382 {383 XS_IDLE, /**< Starting state. */384 XS_BREAK, /**< F0 break byte was received. */385 XS_HIBIT /**< Break code still active. */386 } xlat_state_t;387 388 int32_t XlateAT2PC(int32_t state, uint8_t scanIn, uint8_t *pScanOut);389 390 378 /** @} */ 391 379 -
trunk/src/VBox/Devices/Input/DevPS2K.cpp
r82190 r82191 108 108 * Structures and Typedefs * 109 109 *********************************************************************************************************************************/ 110 #ifndef VBOX_DEVICE_STRUCT_TESTCASE111 112 110 /* Key type flags. */ 113 111 #define KF_E0 0x01 /* E0 prefix. */ … … 1433 1431 #endif /* IN _RING3 */ 1434 1432 1435 /// @todo The following should live with the KBC implementation.1436 1437 /* Table used by the keyboard controller to optionally translate the incoming1438 * keyboard data. Note that the translation is designed for essentially taking1439 * Scan Set 2 input and producing Scan Set 1 output, but can be turned on and1440 * off regardless of what the keyboard is sending.1441 */1442 static uint8_t aAT2PC[128] = {1443 0xff,0x43,0x41,0x3f,0x3d,0x3b,0x3c,0x58,0x64,0x44,0x42,0x40,0x3e,0x0f,0x29,0x59,1444 0x65,0x38,0x2a,0x70,0x1d,0x10,0x02,0x5a,0x66,0x71,0x2c,0x1f,0x1e,0x11,0x03,0x5b,1445 0x67,0x2e,0x2d,0x20,0x12,0x05,0x04,0x5c,0x68,0x39,0x2f,0x21,0x14,0x13,0x06,0x5d,1446 0x69,0x31,0x30,0x23,0x22,0x15,0x07,0x5e,0x6a,0x72,0x32,0x24,0x16,0x08,0x09,0x5f,1447 0x6b,0x33,0x25,0x17,0x18,0x0b,0x0a,0x60,0x6c,0x34,0x35,0x26,0x27,0x19,0x0c,0x61,1448 0x6d,0x73,0x28,0x74,0x1a,0x0d,0x62,0x6e,0x3a,0x36,0x1c,0x1b,0x75,0x2b,0x63,0x76,1449 0x55,0x56,0x77,0x78,0x79,0x7a,0x0e,0x7b,0x7c,0x4f,0x7d,0x4b,0x47,0x7e,0x7f,0x6f,1450 0x52,0x53,0x50,0x4c,0x4d,0x48,0x01,0x45,0x57,0x4e,0x51,0x4a,0x37,0x49,0x46,0x541451 };1452 1453 /**1454 * Convert an AT (Scan Set 2) scancode to PC (Scan Set 1).1455 *1456 * @param state Current state of the translator1457 * (xlat_state_t).1458 * @param scanIn Incoming scan code.1459 * @param pScanOut Pointer to outgoing scan code. The1460 * contents are only valid if returned1461 * state is not XS_BREAK.1462 *1463 * @return xlat_state_t New state of the translator.1464 */1465 int32_t XlateAT2PC(int32_t state, uint8_t scanIn, uint8_t *pScanOut)1466 {1467 uint8_t scan_in;1468 uint8_t scan_out;1469 1470 Assert(pScanOut);1471 Assert(state == XS_IDLE || state == XS_BREAK || state == XS_HIBIT);1472 1473 /* Preprocess the scan code for a 128-entry translation table. */1474 if (scanIn == 0x83) /* Check for F7 key. */1475 scan_in = 0x02;1476 else if (scanIn == 0x84) /* Check for SysRq key. */1477 scan_in = 0x7f;1478 else1479 scan_in = scanIn;1480 1481 /* Values 0x80 and above are passed through, except for 0xF01482 * which indicates a key release.1483 */1484 if (scan_in < 0x80)1485 {1486 scan_out = aAT2PC[scan_in];1487 /* Turn into break code if required. */1488 if (state == XS_BREAK || state == XS_HIBIT)1489 scan_out |= 0x80;1490 1491 state = XS_IDLE;1492 }1493 else1494 {1495 /* NB: F0 E0 10 will be translated to E0 E5 (high bit set on last byte)! */1496 if (scan_in == 0xF0) /* Check for break code. */1497 state = XS_BREAK;1498 else if (state == XS_BREAK)1499 state = XS_HIBIT; /* Remember the break bit. */1500 scan_out = scan_in;1501 }1502 LogFlowFunc(("scan code %02X translated to %02X; new state is %d\n",1503 scanIn, scan_out, state));1504 1505 *pScanOut = scan_out;1506 return state;1507 }1508 1509 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */ -
trunk/src/VBox/Devices/Input/DevPS2M.cpp
r82190 r82191 196 196 #define ARSP_RESEND 0xFE /* Requesting resend. */ 197 197 /** @} */ 198 199 200 #ifndef VBOX_DEVICE_STRUCT_TESTCASE201 198 202 199 … … 668 665 669 666 /** Is there any state change to send as events to the guest? */ 670 static uint32_t ps2m HaveEvents(PPS2M pThis)667 static uint32_t ps2mR3HaveEvents(PPS2M pThis) 671 668 { 672 669 return pThis->iAccumX || pThis->iAccumY || pThis->iAccumZ || pThis->iAccumW … … 689 686 690 687 /* If more movement is accumulated, report it and restart the timer. */ 691 uHaveEvents = ps2m HaveEvents(pThis);688 uHaveEvents = ps2mR3HaveEvents(pThis); 692 689 LogFlowFunc(("Have%s events\n", uHaveEvents ? "" : " no")); 693 690 … … 814 811 815 812 /* Report the event (if any) and start the throttle timer unless it's already running. */ 816 if (!pThis->fThrottleActive && ps2m HaveEvents(pThis))813 if (!pThis->fThrottleActive && ps2mR3HaveEvents(pThis)) 817 814 { 818 815 ps2mReportAccumulatedEvents(pThis, (GeneriQ *)&pThis->evtQ, true); … … 1100 1097 * this to check that it is handled right. */ 1101 1098 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1); 1102 if (ps2m HaveEvents(&This))1099 if (ps2mR3HaveEvents(&This)) 1103 1100 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1104 1101 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 0); 1105 if (ps2m HaveEvents(&This))1102 if (ps2mR3HaveEvents(&This)) 1106 1103 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1107 1104 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1); 1108 1105 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 0); 1109 if (ps2m HaveEvents(&This))1106 if (ps2mR3HaveEvents(&This)) 1110 1107 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1111 if (ps2m HaveEvents(&This))1108 if (ps2mR3HaveEvents(&This)) 1112 1109 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1113 1110 for (i = 0; i < 12; ++i) … … 1124 1121 * testing fixes for the previous issue. Test that that works. */ 1125 1122 ps2mR3PutEventWorker(&This, 0, 0, 0, 0, 1); 1126 if (ps2m HaveEvents(&This))1123 if (ps2mR3HaveEvents(&This)) 1127 1124 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1128 if (ps2m HaveEvents(&This))1125 if (ps2mR3HaveEvents(&This)) 1129 1126 ps2mReportAccumulatedEvents(&This, (GeneriQ *)&This.evtQ, true); 1130 1127 for (i = 0; i < 3; ++i) … … 1141 1138 #endif /* RT_STRICT && IN_RING3 */ 1142 1139 1143 #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
Note:
See TracChangeset
for help on using the changeset viewer.