- Timestamp:
- Aug 26, 2009 9:50:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r22277 r22461 230 230 /** Pointer to the device instance. */ 231 231 PPDMDEVINSR0 pDevInsR0; 232 /** Critical section protecting the state. */ 233 PDMCRITSECT CritSect; 232 234 /** 233 235 * Keyboard port - LUN#0. … … 288 290 { 289 291 s->status |= KBD_STAT_OBF; 290 if ((s->mode & KBD_MODE_KBD_INT) && !(s->mode & KBD_MODE_DISABLE_KBD))292 if ((s->mode & KBD_MODE_KBD_INT) /*&& !(s->mode & KBD_MODE_DISABLE_KBD)*/) 291 293 irq1_level = 1; 292 294 } … … 1298 1300 if (cb == 1) 1299 1301 { 1300 *pu32 = kbd_read_data(PDMINS_2_DATA(pDevIns, KBDState *), Port); 1301 Log2(("kbdIOPortDataRead: Port=%#x cb=%d *pu32=%#x\n", Port, cb, *pu32)); 1302 return VINF_SUCCESS; 1302 KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *); 1303 int rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_READ); 1304 if (RT_LIKELY(rc == VINF_SUCCESS)) 1305 { 1306 *pu32 = kbd_read_data(pThis, Port); 1307 PDMCritSectLeave(&pThis->CritSect); 1308 Log2(("kbdIOPortDataRead: Port=%#x cb=%d *pu32=%#x\n", Port, cb, *pu32)); 1309 } 1310 return rc; 1303 1311 } 1304 1312 AssertMsgFailed(("Port=%#x cb=%d\n", Port, cb)); … … 1323 1331 if (cb == 1) 1324 1332 { 1325 rc = kbd_write_data(PDMINS_2_DATA(pDevIns, KBDState *), Port, u32); 1326 Log2(("kbdIOPortDataWrite: Port=%#x cb=%d u32=%#x\n", Port, cb, u32)); 1333 KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *); 1334 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_WRITE); 1335 if (RT_LIKELY(rc == VINF_SUCCESS)) 1336 { 1337 rc = kbd_write_data(pThis, Port, u32); 1338 PDMCritSectLeave(&pThis->CritSect); 1339 Log2(("kbdIOPortDataWrite: Port=%#x cb=%d u32=%#x\n", Port, cb, u32)); 1340 } 1327 1341 } 1328 1342 else … … 1347 1361 if (cb == 1) 1348 1362 { 1349 *pu32 = kbd_read_status(PDMINS_2_DATA(pDevIns, KBDState *), Port); 1350 Log2(("kbdIOPortStatusRead: Port=%#x cb=%d -> *pu32=%#x\n", Port, cb, *pu32)); 1351 return VINF_SUCCESS; 1363 KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *); 1364 int rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_READ); 1365 if (RT_LIKELY(rc == VINF_SUCCESS)) 1366 { 1367 *pu32 = kbd_read_status(pThis, Port); 1368 PDMCritSectLeave(&pThis->CritSect); 1369 Log2(("kbdIOPortStatusRead: Port=%#x cb=%d -> *pu32=%#x\n", Port, cb, *pu32)); 1370 } 1371 return rc; 1352 1372 } 1353 1373 AssertMsgFailed(("Port=%#x cb=%d\n", Port, cb)); … … 1368 1388 PDMBOTHCBDECL(int) kbdIOPortCommandWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb) 1369 1389 { 1390 int rc = VINF_SUCCESS; 1370 1391 NOREF(pvUser); 1371 1392 if (cb == 1) 1372 1393 { 1373 int rc = kbd_write_command(PDMINS_2_DATA(pDevIns, KBDState *), Port, u32); 1374 Log2(("kbdIOPortCommandWrite: Port=%#x cb=%d u32=%#x rc=%Rrc\n", Port, cb, u32, rc)); 1375 return rc; 1376 } 1377 AssertMsgFailed(("Port=%#x cb=%d\n", Port, cb)); 1378 return VINF_SUCCESS; 1394 KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *); 1395 rc = PDMCritSectEnter(&pThis->CritSect, VINF_IOM_HC_IOPORT_WRITE); 1396 if (RT_LIKELY(rc == VINF_SUCCESS)) 1397 { 1398 rc = kbd_write_command(pThis, Port, u32); 1399 PDMCritSectLeave(&pThis->CritSect); 1400 Log2(("kbdIOPortCommandWrite: Port=%#x cb=%d u32=%#x rc=%Rrc\n", Port, cb, u32, rc)); 1401 } 1402 } 1403 else 1404 AssertMsgFailed(("Port=%#x cb=%d\n", Port, cb)); 1405 return rc; 1379 1406 } 1380 1407 … … 1460 1487 { 1461 1488 KBDState *pThis = IKEYBOARDPORT_2_KBDSTATE(pInterface); 1489 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 1490 AssertReleaseRC(rc); 1462 1491 pc_kbd_put_keycode(pThis, u8KeyCode); 1492 PDMCritSectLeave(&pThis->CritSect); 1463 1493 return VINF_SUCCESS; 1464 1494 } … … 1508 1538 { 1509 1539 KBDState *pThis = IMOUSEPORT_2_KBDSTATE(pInterface); 1540 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 1541 AssertReleaseRC(rc); 1510 1542 pc_kbd_mouse_event(pThis, i32DeltaX, i32DeltaY, i32DeltaZ, fButtonStates); 1543 PDMCritSectLeave(&pThis->CritSect); 1511 1544 return VINF_SUCCESS; 1512 1545 } … … 1646 1679 } 1647 1680 1681 /** 1682 * Destruct a device instance for a VM. 1683 * 1684 * @returns VBox status. 1685 * @param pDevIns The device instance data. 1686 */ 1687 static DECLCALLBACK(int) kbdDestruct(PPDMDEVINS pDevIns) 1688 { 1689 KBDState *pThis = PDMINS_2_DATA(pDevIns, KBDState *); 1690 PDMR3CritSectDelete(&pThis->CritSect); 1691 1692 return VINF_SUCCESS; 1693 } 1648 1694 1649 1695 /** … … 1693 1739 pThis->Mouse.Base.pfnQueryInterface = kbdMouseQueryInterface; 1694 1740 pThis->Mouse.Port.pfnPutEvent = kbdMousePutEvent; 1741 1742 /* 1743 * Initialize the critical section. 1744 */ 1745 char szName[24]; 1746 RTStrPrintf(szName, sizeof(szName), "PS2KM#%d", iInstance); 1747 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, szName); 1748 if (RT_FAILURE(rc)) 1749 return rc; 1695 1750 1696 1751 /* … … 1774 1829 kbdConstruct, 1775 1830 /* pfnDestruct */ 1776 NULL,1831 kbdDestruct, 1777 1832 /* pfnRelocate */ 1778 1833 kdbRelocate,
Note:
See TracChangeset
for help on using the changeset viewer.