Changeset 46758 in vbox for trunk/src/VBox/Devices/Input
- Timestamp:
- Jun 24, 2013 3:44:55 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Input/UsbMouse.cpp
r46730 r46758 28 28 #include <iprt/string.h> 29 29 #include <iprt/uuid.h> 30 #include "VBoxDD.h" 30 #ifndef TESTCASE 31 # include "VBoxDD.h" 32 #endif 31 33 32 34 … … 887 889 888 890 889 /**890 * @copydoc PDMUSBREG::pfnUrbReap891 */892 static DECLCALLBACK(PVUSBURB) usbHidUrbReap(PPDMUSBINS pUsbIns,893 RTMSINTERVAL cMillies)894 {895 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);896 LogFlow(("usbHidUrbReap/#%u: cMillies=%u\n", pThis->iInstance, cMillies));897 return usbHidUrbReapCore(pThis, cMillies);898 }899 900 901 891 static int usbHidUrbCancelCore(PUSBHID pThis, PVUSBURB pUrb) 902 892 { … … 913 903 } 914 904 915 916 /**917 * @copydoc PDMUSBREG::pfnUrbCancel918 */919 static DECLCALLBACK(int) usbHidUrbCancel(PPDMUSBINS pUsbIns, PVUSBURB pUrb)920 {921 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);922 LogFlow(("usbHidUrbCancel/#%u: pUrb=%p:%s\n", pThis->iInstance, pUrb,923 pUrb->pszDesc));924 return usbHidUrbCancelCore(pThis, pUrb);925 }926 905 927 906 /** … … 1193 1172 1194 1173 1195 /**1196 * @copydoc PDMUSBREG::pfnUrbQueue1197 */1198 static DECLCALLBACK(int) usbHidQueue(PPDMUSBINS pUsbIns, PVUSBURB pUrb)1199 {1200 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);1201 LogFlow(("usbHidQueue/#%u: pUrb=%p:%s EndPt=%#x\n", pUsbIns->iInstance,1202 pUrb, pUrb->pszDesc, pUrb->EndPt));1203 return usbHidQueueCore(pThis, pUrb);1204 }1205 1206 1207 1174 static int usbHidUsbClearHaltedEndpointCore(PUSBHID pThis, unsigned uEndpoint) 1208 1175 { … … 1214 1181 } 1215 1182 1216 return VINF_SUCCESS;1217 }1218 1219 1220 /**1221 * @copydoc PDMUSBREG::pfnUsbClearHaltedEndpoint1222 */1223 static DECLCALLBACK(int) usbHidUsbClearHaltedEndpoint(PPDMUSBINS pUsbIns,1224 unsigned uEndpoint)1225 {1226 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);1227 LogFlow(("usbHidUsbClearHaltedEndpoint/#%u: uEndpoint=%#x\n",1228 pUsbIns->iInstance, uEndpoint));1229 return usbHidUsbClearHaltedEndpointCore(pThis, uEndpoint);1230 }1231 1232 1233 /**1234 * @copydoc PDMUSBREG::pfnUsbSetInterface1235 */1236 static DECLCALLBACK(int) usbHidUsbSetInterface(PPDMUSBINS pUsbIns,1237 uint8_t bInterfaceNumber,1238 uint8_t bAlternateSetting)1239 {1240 LogFlow(("usbHidUsbSetInterface/#%u: bInterfaceNumber=%u bAlternateSetting=%u\n",1241 pUsbIns->iInstance, bInterfaceNumber, bAlternateSetting));1242 Assert(bAlternateSetting == 0);1243 1183 return VINF_SUCCESS; 1244 1184 } … … 1273 1213 1274 1214 1275 /**1276 * @copydoc PDMUSBREG::pfnUsbSetConfiguration1277 */1278 static DECLCALLBACK(int) usbHidUsbSetConfiguration(PPDMUSBINS pUsbIns,1279 uint8_t bConfigurationValue,1280 const void *pvOldCfgDesc,1281 const void *pvOldIfState,1282 const void *pvNewCfgDesc)1283 {1284 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);1285 LogFlow(("usbHidUsbSetConfiguration/#%u: bConfigurationValue=%u\n",1286 pUsbIns->iInstance, bConfigurationValue));1287 return usbHidUsbSetConfigurationCore(pThis, bConfigurationValue,1288 pvOldCfgDesc, pvOldIfState,1289 pvNewCfgDesc);1290 }1291 1292 1293 /**1294 * @copydoc PDMUSBREG::pfnUsbGetDescriptorCache1295 */1296 1215 static PCPDMUSBDESCCACHE usbHidUsbGetDescriptorCacheCore(PUSBHID pThis) 1297 1216 { … … 1304 1223 1305 1224 1306 /** 1307 * @copydoc PDMUSBREG::pfnUsbGetDescriptorCache 1308 */ 1309 static DECLCALLBACK(PCPDMUSBDESCCACHE) usbHidUsbGetDescriptorCache(PPDMUSBINS 1310 pUsbIns) 1311 { 1312 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1313 LogFlow(("usbHidUsbGetDescriptorCache/#%u:\n", pUsbIns->iInstance)); 1314 return usbHidUsbGetDescriptorCacheCore(pThis); 1315 } 1316 1317 1318 static DECLCALLBACK(int) usbHidUsbResetCore(PUSBHID pThis) 1225 static int usbHidUsbResetCore(PUSBHID pThis) 1319 1226 { 1320 1227 RTCritSectEnter(&pThis->CritSect); … … 1324 1231 RTCritSectLeave(&pThis->CritSect); 1325 1232 return rc; 1326 }1327 1328 1329 /**1330 * @copydoc PDMUSBREG::pfnUsbReset1331 */1332 static DECLCALLBACK(int) usbHidUsbReset(PPDMUSBINS pUsbIns, bool fResetOnLinux)1333 {1334 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);1335 LogFlow(("usbHidUsbReset/#%u:\n", pUsbIns->iInstance));1336 return usbHidUsbResetCore(pThis);1337 1233 } 1338 1234 … … 1352 1248 pThis->hEvtDoneQueue = NIL_RTSEMEVENT; 1353 1249 } 1354 }1355 1356 1357 /**1358 * @copydoc PDMUSBREG::pfnDestruct1359 */1360 static DECLCALLBACK(void) usbHidDestruct(PPDMUSBINS pUsbIns)1361 {1362 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);1363 LogFlow(("usbHidDestruct/#%u:\n", pUsbIns->iInstance));1364 usbHidDestructCore(pThis);1365 1250 } 1366 1251 … … 1395 1280 1396 1281 1397 static void usbHidConstructFinish(PUSBHID pThis, PPDMIMOUSECONNECTOR pDrv) 1398 { 1399 pThis->Lun0.pDrv = pDrv; 1282 static int usbHidConstructFinish(PUSBHID pThis) 1283 { 1284 pThis->Lun0.pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Lun0.pDrvBase, 1285 PDMIMOUSECONNECTOR); 1286 return pThis->Lun0.pDrv ? VINF_SUCCESS : VERR_PDM_MISSING_INTERFACE; 1287 } 1288 1289 1290 #ifndef TESTCASE 1291 /** 1292 * @copydoc PDMUSBREG::pfnUrbReap 1293 */ 1294 static DECLCALLBACK(PVUSBURB) usbHidUrbReap(PPDMUSBINS pUsbIns, 1295 RTMSINTERVAL cMillies) 1296 { 1297 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1298 LogFlow(("usbHidUrbReap/#%u: cMillies=%u\n", pThis->iInstance, cMillies)); 1299 return usbHidUrbReapCore(pThis, cMillies); 1300 } 1301 1302 1303 /** 1304 * @copydoc PDMUSBREG::pfnUrbCancel 1305 */ 1306 static DECLCALLBACK(int) usbHidUrbCancel(PPDMUSBINS pUsbIns, PVUSBURB pUrb) 1307 { 1308 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1309 LogFlow(("usbHidUrbCancel/#%u: pUrb=%p:%s\n", pThis->iInstance, pUrb, 1310 pUrb->pszDesc)); 1311 return usbHidUrbCancelCore(pThis, pUrb); 1312 } 1313 1314 1315 /** 1316 * @copydoc PDMUSBREG::pfnUrbQueue 1317 */ 1318 static DECLCALLBACK(int) usbHidQueue(PPDMUSBINS pUsbIns, PVUSBURB pUrb) 1319 { 1320 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1321 LogFlow(("usbHidQueue/#%u: pUrb=%p:%s EndPt=%#x\n", pUsbIns->iInstance, 1322 pUrb, pUrb->pszDesc, pUrb->EndPt)); 1323 return usbHidQueueCore(pThis, pUrb); 1324 } 1325 1326 1327 /** 1328 * @copydoc PDMUSBREG::pfnUsbClearHaltedEndpoint 1329 */ 1330 static DECLCALLBACK(int) usbHidUsbClearHaltedEndpoint(PPDMUSBINS pUsbIns, 1331 unsigned uEndpoint) 1332 { 1333 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1334 LogFlow(("usbHidUsbClearHaltedEndpoint/#%u: uEndpoint=%#x\n", 1335 pUsbIns->iInstance, uEndpoint)); 1336 return usbHidUsbClearHaltedEndpointCore(pThis, uEndpoint); 1337 } 1338 1339 1340 /** 1341 * @copydoc PDMUSBREG::pfnUsbSetInterface 1342 */ 1343 static DECLCALLBACK(int) usbHidUsbSetInterface(PPDMUSBINS pUsbIns, 1344 uint8_t bInterfaceNumber, 1345 uint8_t bAlternateSetting) 1346 { 1347 LogFlow(("usbHidUsbSetInterface/#%u: bInterfaceNumber=%u bAlternateSetting=%u\n", 1348 pUsbIns->iInstance, bInterfaceNumber, bAlternateSetting)); 1349 Assert(bAlternateSetting == 0); 1350 return VINF_SUCCESS; 1351 } 1352 1353 1354 /** 1355 * @copydoc PDMUSBREG::pfnUsbSetConfiguration 1356 */ 1357 static DECLCALLBACK(int) usbHidUsbSetConfiguration(PPDMUSBINS pUsbIns, 1358 uint8_t bConfigurationValue, 1359 const void *pvOldCfgDesc, 1360 const void *pvOldIfState, 1361 const void *pvNewCfgDesc) 1362 { 1363 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1364 LogFlow(("usbHidUsbSetConfiguration/#%u: bConfigurationValue=%u\n", 1365 pUsbIns->iInstance, bConfigurationValue)); 1366 return usbHidUsbSetConfigurationCore(pThis, bConfigurationValue, 1367 pvOldCfgDesc, pvOldIfState, 1368 pvNewCfgDesc); 1369 } 1370 1371 1372 /** 1373 * @copydoc PDMUSBREG::pfnUsbGetDescriptorCache 1374 */ 1375 static DECLCALLBACK(PCPDMUSBDESCCACHE) usbHidUsbGetDescriptorCache(PPDMUSBINS 1376 pUsbIns) 1377 { 1378 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1379 LogFlow(("usbHidUsbGetDescriptorCache/#%u:\n", pUsbIns->iInstance)); 1380 return usbHidUsbGetDescriptorCacheCore(pThis); 1381 } 1382 1383 1384 /** 1385 * @copydoc PDMUSBREG::pfnUsbReset 1386 */ 1387 static DECLCALLBACK(int) usbHidUsbReset(PPDMUSBINS pUsbIns, bool fResetOnLinux) 1388 { 1389 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1390 LogFlow(("usbHidUsbReset/#%u:\n", pUsbIns->iInstance)); 1391 return usbHidUsbResetCore(pThis); 1392 } 1393 1394 1395 /** 1396 * @copydoc PDMUSBREG::pfnDestruct 1397 */ 1398 static DECLCALLBACK(void) usbHidDestruct(PPDMUSBINS pUsbIns) 1399 { 1400 PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID); 1401 LogFlow(("usbHidDestruct/#%u:\n", pUsbIns->iInstance)); 1402 usbHidDestructCore(pThis); 1400 1403 } 1401 1404 … … 1410 1413 bool isAbsolute; 1411 1414 uint8_t u8CoordShift; 1412 PPDMIMOUSECONNECTOR pDrv;1413 1415 Log(("usbHidConstruct/#%u:\n", iInstance)); 1414 1416 … … 1431 1433 1432 1434 rc = usbHidConstructCore(pThis, iInstance, isAbsolute, u8CoordShift); 1435 if (RT_FAILURE(rc)) /* Already asserted previously. */ 1436 return rc; 1433 1437 1434 1438 /* … … 1441 1445 N_("HID failed to attach mouse driver")); 1442 1446 1443 pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Lun0.pDrvBase, PDMIMOUSECONNECTOR); 1444 if (!pDrv) 1445 return PDMUsbHlpVMSetError(pUsbIns, VERR_PDM_MISSING_INTERFACE, 1446 RT_SRC_POS, 1447 rc = usbHidConstructFinish(pThis); 1448 if (RT_FAILURE(rc)) 1449 return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, 1447 1450 N_("HID failed to query mouse interface")); 1448 usbHidConstructFinish(pThis, pDrv);1449 1451 1450 1452 return VINF_SUCCESS; … … 1516 1518 PDM_USBREG_VERSION 1517 1519 }; 1520 1521 #else /* TESTCASE */ 1522 1523 # include "testcase/tstUsbMouse.h" 1524 1525 static int tstUsbMouseConstruct(PUSBHID pThis, int iInstance, bool isAbsolute, 1526 uint8_t u8CoordShift, PPDMIBASE pConnectorBase, 1527 PPDMIBASE *ppBase) 1528 { 1529 int rc = usbHidConstructCore(pThis, iInstance, isAbsolute, u8CoordShift); 1530 if (RT_SUCCESS(rc)) 1531 { 1532 *ppBase = &pThis->Lun0.IBase; 1533 pThis->Lun0.pDrvBase = pConnectorBase; 1534 rc = usbHidConstructFinish(pThis); 1535 if (RT_SUCCESS(rc)) 1536 return VINF_SUCCESS; 1537 } 1538 RTMemFree(pThis); 1539 return rc; 1540 } 1541 1542 TSTUSBMOUSEREG g_TstUsbMouseReg = 1543 { 1544 sizeof(USBHID), 1545 tstUsbMouseConstruct, 1546 usbHidDestructCore, 1547 usbHidUsbResetCore, 1548 usbHidUsbGetDescriptorCacheCore, 1549 usbHidUsbSetConfigurationCore, 1550 usbHidUsbClearHaltedEndpointCore, 1551 usbHidQueueCore, 1552 usbHidUrbCancelCore, 1553 usbHidUrbReapCore 1554 }; 1555 1556 #endif /* TESTCASE */
Note:
See TracChangeset
for help on using the changeset viewer.