VirtualBox

Changeset 46767 in vbox


Ignore:
Timestamp:
Jun 24, 2013 10:06:24 PM (11 years ago)
Author:
vboxsync
Message:

Devices/Input: and reverted r86653.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/UsbMouse.cpp

    r46766 r46767  
    120120typedef struct USBHID
    121121{
    122     /** USB device instance number. */
    123     uint32_t            iInstance;
     122    /** Pointer back to the PDM USB Device instance structure. */
     123    PPDMUSBINS          pUsbIns;
    124124    /** Critical section protecting the device state. */
    125125    RTCRITSECT          CritSect;
     
    634634static int usbHidCompleteStall(PUSBHID pThis, PUSBHIDEP pEp, PVUSBURB pUrb, const char *pszWhy)
    635635{
    636     Log(("usbHidCompleteStall/#%u: pUrb=%p:%s: %s\n", pThis->iInstance, pUrb, pUrb->pszDesc, pszWhy));
     636    Log(("usbHidCompleteStall/#%u: pUrb=%p:%s: %s\n", pThis->pUsbIns->iInstance, pUrb, pUrb->pszDesc, pszWhy));
    637637
    638638    pUrb->enmStatus = VUSBSTATUS_STALL;
     
    657657static int usbHidCompleteOk(PUSBHID pThis, PVUSBURB pUrb, size_t cbData)
    658658{
    659     Log(("usbHidCompleteOk/#%u: pUrb=%p:%s cbData=%#zx\n", pThis->iInstance, pUrb, pUrb->pszDesc, cbData));
     659    Log(("usbHidCompleteOk/#%u: pUrb=%p:%s cbData=%#zx\n", pThis->pUsbIns->iInstance, pUrb, pUrb->pszDesc, cbData));
    660660
    661661    pUrb->enmStatus = VUSBSTATUS_OK;
     
    859859}
    860860
    861 
    862 static PVUSBURB usbHidUrbReapCore(PUSBHID pThis, RTMSINTERVAL cMillies)
    863 {
     861/**
     862 * @copydoc PDMUSBREG::pfnUrbReap
     863 */
     864static DECLCALLBACK(PVUSBURB) usbHidUrbReap(PPDMUSBINS pUsbIns, RTMSINTERVAL cMillies)
     865{
     866    PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);
     867    LogFlow(("usbHidUrbReap/#%u: cMillies=%u\n", pUsbIns->iInstance, cMillies));
     868
    864869    RTCritSectEnter(&pThis->CritSect);
    865870
     
    882887
    883888    if (pUrb)
    884         Log(("usbHidUrbReap/#%u: pUrb=%p:%s\n", pThis->iInstance, pUrb, pUrb->pszDesc));
     889        Log(("usbHidUrbReap/#%u: pUrb=%p:%s\n", pUsbIns->iInstance, pUrb, pUrb->pszDesc));
    885890    return pUrb;
    886891}
     
    888893
    889894/**
    890  * @copydoc PDMUSBREG::pfnUrbReap
    891  */
    892 static DECLCALLBACK(PVUSBURB) usbHidUrbReap(PPDMUSBINS pUsbIns,
    893                                             RTMSINTERVAL cMillies)
     895 * @copydoc PDMUSBREG::pfnUrbCancel
     896 */
     897static DECLCALLBACK(int) usbHidUrbCancel(PPDMUSBINS pUsbIns, PVUSBURB pUrb)
    894898{
    895899    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 static int usbHidUrbCancelCore(PUSBHID pThis, PVUSBURB pUrb)
    902 {
     900    LogFlow(("usbHidUrbCancel/#%u: pUrb=%p:%s\n", pUsbIns->iInstance, pUrb, pUrb->pszDesc));
    903901    RTCritSectEnter(&pThis->CritSect);
    904902
     
    913911}
    914912
    915 
    916 /**
    917  * @copydoc PDMUSBREG::pfnUrbCancel
    918  */
    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 }
    926913
    927914/**
     
    11621149
    11631150
    1164 static int usbHidQueueCore(PUSBHID pThis, PVUSBURB pUrb)
    1165 {
     1151/**
     1152 * @copydoc PDMUSBREG::pfnUrbQueue
     1153 */
     1154static DECLCALLBACK(int) usbHidQueue(PPDMUSBINS pUsbIns, PVUSBURB pUrb)
     1155{
     1156    PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);
     1157    LogFlow(("usbHidQueue/#%u: pUrb=%p:%s EndPt=%#x\n", pUsbIns->iInstance, pUrb, pUrb->pszDesc, pUrb->EndPt));
    11661158    RTCritSectEnter(&pThis->CritSect);
    11671159
     
    11941186
    11951187/**
    1196  * @copydoc PDMUSBREG::pfnUrbQueue
    1197  */
    1198 static DECLCALLBACK(int) usbHidQueue(PPDMUSBINS pUsbIns, PVUSBURB pUrb)
     1188 * @copydoc PDMUSBREG::pfnUsbClearHaltedEndpoint
     1189 */
     1190static DECLCALLBACK(int) usbHidUsbClearHaltedEndpoint(PPDMUSBINS pUsbIns, unsigned uEndpoint)
    11991191{
    12001192    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 static int usbHidUsbClearHaltedEndpointCore(PUSBHID pThis, unsigned uEndpoint)
    1208 {
     1193    LogFlow(("usbHidUsbClearHaltedEndpoint/#%u: uEndpoint=%#x\n", pUsbIns->iInstance, uEndpoint));
     1194
    12091195    if ((uEndpoint & ~0x80) < RT_ELEMENTS(pThis->aEps))
    12101196    {
     
    12191205
    12201206/**
    1221  * @copydoc PDMUSBREG::pfnUsbClearHaltedEndpoint
    1222  */
    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 /**
    12341207 * @copydoc PDMUSBREG::pfnUsbSetInterface
    12351208 */
    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));
     1209static DECLCALLBACK(int) usbHidUsbSetInterface(PPDMUSBINS pUsbIns, uint8_t bInterfaceNumber, uint8_t bAlternateSetting)
     1210{
     1211    LogFlow(("usbHidUsbSetInterface/#%u: bInterfaceNumber=%u bAlternateSetting=%u\n", pUsbIns->iInstance, bInterfaceNumber, bAlternateSetting));
    12421212    Assert(bAlternateSetting == 0);
    12431213    return VINF_SUCCESS;
     
    12451215
    12461216
    1247 static int usbHidUsbSetConfigurationCore(PUSBHID pThis,
    1248                                          uint8_t bConfigurationValue,
    1249                                          const void *pvOldCfgDesc,
    1250                                          const void *pvOldIfState,
    1251                                          const void *pvNewCfgDesc)
    1252 {
     1217/**
     1218 * @copydoc PDMUSBREG::pfnUsbSetConfiguration
     1219 */
     1220static DECLCALLBACK(int) usbHidUsbSetConfiguration(PPDMUSBINS pUsbIns, uint8_t bConfigurationValue,
     1221                                                   const void *pvOldCfgDesc, const void *pvOldIfState, const void *pvNewCfgDesc)
     1222{
     1223    PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);
     1224    LogFlow(("usbHidUsbSetConfiguration/#%u: bConfigurationValue=%u\n", pUsbIns->iInstance, bConfigurationValue));
    12531225    Assert(bConfigurationValue == 1);
    12541226    RTCritSectEnter(&pThis->CritSect);
     
    12581230     */
    12591231    if (pThis->bConfigurationValue == bConfigurationValue)
    1260         usbHidResetWorker(pThis, NULL, true /*fSetConfig*/);
    1261         /** @todo figure out the exact difference */
     1232        usbHidResetWorker(pThis, NULL, true /*fSetConfig*/); /** @todo figure out the exact difference */
    12621233    pThis->bConfigurationValue = bConfigurationValue;
    12631234
     
    12741245
    12751246/**
    1276  * @copydoc PDMUSBREG::pfnUsbSetConfiguration
    1277  */
    1278 static DECLCALLBACK(int) usbHidUsbSetConfiguration(PPDMUSBINS pUsbIns,
    1279                                                    uint8_t bConfigurationValue,
    1280                                                    const void *pvOldCfgDesc,
    1281                                                    const void *pvOldIfState,
    1282                                                    const void *pvNewCfgDesc)
     1247 * @copydoc PDMUSBREG::pfnUsbGetDescriptorCache
     1248 */
     1249static DECLCALLBACK(PCPDMUSBDESCCACHE) usbHidUsbGetDescriptorCache(PPDMUSBINS pUsbIns)
    12831250{
    12841251    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::pfnUsbGetDescriptorCache
    1295  */
    1296 static PCPDMUSBDESCCACHE usbHidUsbGetDescriptorCacheCore(PUSBHID pThis)
    1297 {
     1252    LogFlow(("usbHidUsbGetDescriptorCache/#%u:\n", pUsbIns->iInstance));
    12981253    if (pThis->isAbsolute) {
    12991254        return &g_UsbHidTDescCache;
     
    13051260
    13061261/**
    1307  * @copydoc PDMUSBREG::pfnUsbGetDescriptorCache
    1308  */
    1309 static DECLCALLBACK(PCPDMUSBDESCCACHE) usbHidUsbGetDescriptorCache(PPDMUSBINS
    1310                                                                         pUsbIns)
     1262 * @copydoc PDMUSBREG::pfnUsbReset
     1263 */
     1264static DECLCALLBACK(int) usbHidUsbReset(PPDMUSBINS pUsbIns, bool fResetOnLinux)
    13111265{
    13121266    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)
    1319 {
     1267    LogFlow(("usbHidUsbReset/#%u:\n", pUsbIns->iInstance));
    13201268    RTCritSectEnter(&pThis->CritSect);
    13211269
     
    13281276
    13291277/**
    1330  * @copydoc PDMUSBREG::pfnUsbReset
    1331  */
    1332 static DECLCALLBACK(int) usbHidUsbReset(PPDMUSBINS pUsbIns, bool fResetOnLinux)
     1278 * @copydoc PDMUSBREG::pfnDestruct
     1279 */
     1280static void usbHidDestruct(PPDMUSBINS pUsbIns)
    13331281{
    13341282    PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);
    1335     LogFlow(("usbHidUsbReset/#%u:\n", pUsbIns->iInstance));
    1336     return usbHidUsbResetCore(pThis);
    1337 }
    1338 
    1339 
    1340 static void usbHidDestructCore(PUSBHID pThis)
    1341 {
     1283    LogFlow(("usbHidDestruct/#%u:\n", pUsbIns->iInstance));
     1284
    13421285    if (RTCritSectIsInitialized(&pThis->CritSect))
    13431286    {
     
    13561299
    13571300/**
    1358  * @copydoc PDMUSBREG::pfnDestruct
    1359  */
    1360 static DECLCALLBACK(void) usbHidDestruct(PPDMUSBINS pUsbIns)
     1301 * @copydoc PDMUSBREG::pfnConstruct
     1302 */
     1303static DECLCALLBACK(int) usbHidConstruct(PPDMUSBINS pUsbIns, int iInstance, PCFGMNODE pCfg, PCFGMNODE pCfgGlobal)
    13611304{
    13621305    PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);
    1363     LogFlow(("usbHidDestruct/#%u:\n", pUsbIns->iInstance));
    1364     usbHidDestructCore(pThis);
    1365 }
    1366 
    1367 
    1368 static int usbHidConstructCore(PUSBHID pThis, int iInstance, bool isAbsolute,
    1369                                uint8_t u8CoordShift)
    1370 {
     1306    Log(("usbHidConstruct/#%u:\n", iInstance));
     1307
    13711308    /*
    13721309     * Perform the basic structure initialization first so the destructor
    13731310     * will not misbehave.
    13741311     */
    1375     pThis->iInstance                                = iInstance;
     1312    pThis->pUsbIns                                  = pUsbIns;
    13761313    pThis->hEvtDoneQueue                            = NIL_RTSEMEVENT;
    13771314    usbHidQueueInit(&pThis->ToHostQueue);
     
    13841321    AssertRCReturn(rc, rc);
    13851322
    1386     pThis->isAbsolute = isAbsolute;
    1387     pThis->u8CoordShift = u8CoordShift;
     1323    /*
     1324     * Validate and read the configuration.
     1325     */
     1326    rc = CFGMR3ValidateConfig(pCfg, "/", "Absolute|CoordShift", "Config", "UsbHid", iInstance);
     1327    if (RT_FAILURE(rc))
     1328        return rc;
     1329    rc = CFGMR3QueryBoolDef(pCfg, "Absolute", &pThis->isAbsolute, false);
     1330    if (RT_FAILURE(rc))
     1331        return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, N_("HID failed to query settings"));
    13881332
    13891333    pThis->Lun0.IBase.pfnQueryInterface = usbHidMouseQueryInterface;
     
    13911335    pThis->Lun0.IPort.pfnPutEventAbs    = usbHidMousePutEventAbs;
    13921336
    1393     return VINF_SUCCESS;
    1394 }
    1395 
    1396 
    1397 static void usbHidConstructFinish(PUSBHID pThis, PPDMIMOUSECONNECTOR pDrv)
    1398 {
    1399     pThis->Lun0.pDrv = pDrv;
    1400 }
    1401 
    1402 
    1403 /**
    1404  * @copydoc PDMUSBREG::pfnConstruct
    1405  */
    1406 static DECLCALLBACK(int) usbHidConstruct(PPDMUSBINS pUsbIns, int iInstance,
    1407                                          PCFGMNODE pCfg, PCFGMNODE pCfgGlobal)
    1408 {
    1409     PUSBHID pThis = PDMINS_2_DATA(pUsbIns, PUSBHID);
    1410     bool isAbsolute;
    1411     uint8_t u8CoordShift;
    1412     PPDMIMOUSECONNECTOR pDrv;
    1413     Log(("usbHidConstruct/#%u:\n", iInstance));
    1414 
    1415     /*
    1416      * Validate and read the configuration.
    1417      */
    1418     int rc = CFGMR3ValidateConfig(pCfg, "/", "Absolute|CoordShift", "Config",
    1419                                   "UsbHid", iInstance);
    1420     if (RT_FAILURE(rc))
    1421         return rc;
    1422     rc = CFGMR3QueryBoolDef(pCfg, "Absolute", &isAbsolute, false);
    1423     if (RT_FAILURE(rc))
    1424         return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS,
    1425                                    N_("HID failed to query settings"));
    1426 
    1427     rc = CFGMR3QueryU8Def(pCfg, "CoordShift", &u8CoordShift, 1);
    1428     if (RT_FAILURE(rc))
    1429         return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS,
    1430                                    N_("HID failed to query shift factor"));
    1431 
    1432     rc = usbHidConstructCore(pThis, iInstance, isAbsolute, u8CoordShift);
    1433 
    14341337    /*
    14351338     * Attach the mouse driver.
    14361339     */
    1437     rc = PDMUsbHlpDriverAttach(pUsbIns, 0 /*iLun*/, &pThis->Lun0.IBase,
    1438                                &pThis->Lun0.pDrvBase, "Mouse Port");
     1340    rc = PDMUsbHlpDriverAttach(pUsbIns, 0 /*iLun*/, &pThis->Lun0.IBase, &pThis->Lun0.pDrvBase, "Mouse Port");
    14391341    if (RT_FAILURE(rc))
    1440         return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS,
    1441                                    N_("HID failed to attach mouse driver"));
    1442 
    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                                    N_("HID failed to query mouse interface"));
    1448     usbHidConstructFinish(pThis, pDrv);
     1342        return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, N_("HID failed to attach mouse driver"));
     1343
     1344    pThis->Lun0.pDrv = PDMIBASE_QUERY_INTERFACE(pThis->Lun0.pDrvBase, PDMIMOUSECONNECTOR);
     1345    if (!pThis->Lun0.pDrv)
     1346        return PDMUsbHlpVMSetError(pUsbIns, VERR_PDM_MISSING_INTERFACE, RT_SRC_POS, N_("HID failed to query mouse interface"));
     1347
     1348    rc = CFGMR3QueryU8Def(pCfg, "CoordShift", &pThis->u8CoordShift, 1);
     1349    if (RT_FAILURE(rc))
     1350        return PDMUsbHlpVMSetError(pUsbIns, rc, RT_SRC_POS, N_("HID failed to query shift factor"));
    14491351
    14501352    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette