VirtualBox

Changeset 49787 in vbox for trunk/src


Ignore:
Timestamp:
Dec 5, 2013 11:26:00 AM (11 years ago)
Author:
vboxsync
Message:

OS X host: HID LEDs sync: move built-in keyboard resume code from VBoxUSB.kext to VBoxDrv.kext.

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.cpp

    r49779 r49787  
    3939# include <iprt/err.h>
    4040# include <iprt/semaphore.h>
    41 # include <VBox/usblib.h>
     41# include <VBox/sup.h>
    4242#endif
    4343
     
    12701270    IOReturn      rc = kIOReturnError;
    12711271
    1272     USBLibResumeBuiltInKeyboard();
     1272    /* Try to resume built-in keyboard. Abort if failed in order to avoid GUI freezes. */
     1273    int rc1 = SUPR3ResumeBuiltinKeyboard();
     1274    if (RT_FAILURE(rc1))
     1275        return rc1;
    12731276
    12741277    valueRef = IOHIDValueCreateWithIntegerValue(kCFAllocatorDefault, element, 0, (fEnabled) ? 1 : 0);
     
    12941297    CFIndex       integerValue;
    12951298
    1296     USBLibResumeBuiltInKeyboard();
     1299    /* Try to resume built-in keyboard. Abort if failed in order to avoid GUI freezes. */
     1300    int rc1 = SUPR3ResumeBuiltinKeyboard();
     1301    if (RT_FAILURE(rc1))
     1302        return rc1;
    12971303
    12981304    rc = IOHIDDeviceGetValue(hidDevice, element, &valueRef);
     
    19151921    VBoxHidsState_t *pHidState;
    19161922
    1917     USBLibInit();
    1918 
    19191923    pHidState = (VBoxHidsState_t *)malloc(sizeof(VBoxHidsState_t));
    19201924    AssertReturn(pHidState, NULL);
     
    20582062    free(pHidState);
    20592063
    2060     USBLibTerm();
    2061 
    20622064    return rc2;
    20632065#else /* !VBOX_WITH_KBD_LEDS_SYNC */
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r49786 r49787  
    139139                                                  RTCPUID idCpu, uint8_t idApic, uint64_t iTick);
    140140static void                 supdrvGipInitCpu(PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pCpu, uint64_t u64NanoTS);
     141static int                  supdrvIOCtl_ResumeBuiltinKbd(void);
    141142
    142143
     
    19041905        }
    19051906
     1907        case SUP_CTL_CODE_NO_SIZE(SUP_IOCTL_RESUME_BUILTIN_KBD):
     1908        {
     1909            /* validate */
     1910            REQ_CHECK_SIZES(SUP_IOCTL_RESUME_BUILTIN_KBD);
     1911
     1912            pReqHdr->rc = supdrvIOCtl_ResumeBuiltinKbd();
     1913            return 0;
     1914        }
    19061915
    19071916        default:
     
    61406149}
    61416150
     6151/**
     6152 * Resume built-in keyboard on MacBook Air and Pro hosts.
     6153 * If there is no built-in keyboard device, return success anyway.
     6154 *
     6155 * @returns 0 on Mac OS X platform, VERR_NOT_IMPLEMENTED on the other ones.
     6156 */
     6157static int supdrvIOCtl_ResumeBuiltinKbd(void)
     6158{
     6159#if defined(RT_OS_DARWIN)
     6160    return supdrvDarwinResumeBuiltinKbd();
     6161#else
     6162    return VERR_NOT_IMPLEMENTED;
     6163#endif
     6164}
     6165
  • trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h

    r49634 r49787  
    194194 *          - Remove RTSpinlockReleaseNoInts.
    195195 */
    196 #define SUPDRV_IOC_VERSION                              0x001a0006
     196#define SUPDRV_IOC_VERSION                              0x001a0007
    197197
    198198/** SUP_IOCTL_COOKIE. */
     
    14381438/** @} */
    14391439
     1440/** @name SUP_IOCTL_RESUME_BUILTIN_KBD
     1441 * Resume built-in keyboard (make sense on MacBook Air/Pro hosts only).
     1442 *
     1443 * @{
     1444 */
     1445#define SUP_IOCTL_RESUME_BUILTIN_KBD                    SUP_CTL_CODE_SIZE(35, SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE)
     1446#define SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE               sizeof(SUPREQHDR)
     1447#define SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE_IN            sizeof(SUPREQHDR)
     1448#define SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE_OUT           sizeof(SUPREQHDR)
     1449/** @} */
     1450
    14401451
    14411452#pragma pack()                          /* paranoia */
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r49634 r49787  
    749749#endif /* SUPDRV_WITH_MSR_PROBER */
    750750
     751#if defined(RT_OS_DARWIN)
     752int VBOXCALL    supdrvDarwinResumeBuiltinKbd(void);
     753#endif
    751754
    752755/*******************************************************************************
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r49634 r49787  
    21332133}
    21342134
     2135
     2136SUPR3DECL(int) SUPR3ResumeBuiltinKeyboard(void)
     2137{
     2138#ifdef RT_OS_DARWIN
     2139    /*
     2140     * Issue IOCtl to the SUPDRV kernel module.
     2141     */
     2142    SUPREQHDR Req;
     2143    Req.u32Cookie       = g_u32Cookie;
     2144    Req.u32SessionCookie= g_u32SessionCookie;
     2145    Req.cbIn            = SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE_IN;
     2146    Req.cbOut           = SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE_OUT;
     2147    Req.fFlags          = SUPREQHDR_FLAGS_DEFAULT;
     2148    Req.rc              = VERR_INTERNAL_ERROR;
     2149    int rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_RESUME_BUILTIN_KBD, &Req, SUP_IOCTL_RESUME_BUILTIN_KBD_SIZE);
     2150    if (RT_SUCCESS(rc))
     2151        rc = Req.rc;
     2152    return rc;
     2153#else /* !RT_OS_DARWIN */
     2154    return VERR_NOT_SUPPORTED;
     2155#endif
     2156}
     2157
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r49767 r49787  
    6767#include <IOKit/pwr_mgt/RootDomain.h>
    6868#include <IOKit/IODeviceTreeSupport.h>
     69#include <IOKit/usb/IOUSBHIDDriver.h>
    6970
    7071#ifdef VBOX_WITH_HOST_VMX
     
    11431144
    11441145
     1146/**
     1147 * Resume built-in keyboard on MacBook Air and Pro hosts.
     1148 * If there is no built-in keyboard device, return success anyway.
     1149 */
     1150int VBOXCALL    supdrvDarwinResumeBuiltinKbd(void)
     1151{
     1152    /*
     1153     * AppleUSBTCKeyboard KEXT is responsible for built-in keyboard management.
     1154     * We resume keyboard by accessing to its IOService. */
     1155    OSDictionary *pDictionary = IOService::serviceMatching("AppleUSBTCKeyboard");
     1156    if (pDictionary)
     1157    {
     1158        OSIterator     *pIter;
     1159        IOUSBHIDDriver *pDriver;
     1160
     1161        pIter = IOService::getMatchingServices(pDictionary);
     1162        if (pIter)
     1163        {
     1164            while ((pDriver = (IOUSBHIDDriver *)pIter->getNextObject()))
     1165                pDriver->SuspendPort(false, 0);
     1166
     1167            pIter->release();
     1168        }
     1169        pDictionary->release();
     1170    }
     1171
     1172    return 0;
     1173}
     1174
     1175
    11451176
    11461177/**
  • trunk/src/VBox/HostDrivers/VBoxUSB/darwin/USBLib-darwin.cpp

    r49779 r49787  
    190190}
    191191
    192 USBLIB_DECL(void) USBLibResumeBuiltInKeyboard(void)
    193 {
    194 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
    195     kern_return_t kr = IOConnectMethodStructureIStructureO(g_Connection,
    196                                                            VBOXUSBMETHOD_RESUME_BUILTIN_KBD,
    197                                                            0,
    198                                                            NULL,
    199                                                            NULL,
    200                                                            NULL);
    201 #else  /* 10.5 and later */
    202     kern_return_t kr = IOConnectCallStructMethod(g_Connection,
    203                                                  VBOXUSBMETHOD_RESUME_BUILTIN_KBD,
    204                                                  NULL, 0,
    205                                                  NULL, NULL);
    206 #endif /* 10.5 and later */
    207     AssertMsg(kr == kIOReturnSuccess, ("kr=%#x\n", kr));
    208     NOREF(kr);
    209 }
  • trunk/src/VBox/HostDrivers/VBoxUSB/darwin/VBoxUSB.cpp

    r49779 r49787  
    6060#include <IOKit/usb/IOUSBInterface.h>
    6161#include <IOKit/usb/IOUSBUserClient.h>
    62 #include <IOKit/usb/IOUSBHIDDriver.h>
    6362
    6463/* private: */
     
    141140    IOReturn addFilter(PUSBFILTER pFilter, PVBOXUSBADDFILTEROUT pOut, IOByteCount cbFilter, IOByteCount *pcbOut);
    142141    IOReturn removeFilter(uintptr_t *puId, int *prc, IOByteCount cbIn, IOByteCount *pcbOut);
    143     IOReturn resumeBuiltInKbd(void *unused1, void *unused2, IOByteCount unused3, IOByteCount *unused4, void *unused5, void *unused6);
    144142    /** @} */
    145143
     
    790788            sizeof(int)                                             /* count1 - size of the output (rc) */
    791789        },
    792         /* [VBOXUSBMETHOD_RESUME_BUILTIN_KBD] = */
    793         {
    794             (IOService *)0,                                         /* object */
    795             (IOMethod)&org_virtualbox_VBoxUSBClient::resumeBuiltInKbd, /* func */
    796             kIOUCScalarIScalarO,                                    /* flags - scalar input (count0) and scalar output (count1) */
    797             0,                                                      /* count0 - # of input parameters */
    798             0                                                       /* count1 - # of output parameters */
    799         },
    800790    };
    801791
     
    903893}
    904894
    905 IOReturn
    906 org_virtualbox_VBoxUSBClient::resumeBuiltInKbd(void *unused1, void *unused2, IOByteCount unused3, IOByteCount *unused4, void *unused5, void *unused6)
    907 {
    908     (void)unused1;
    909     (void)unused2;
    910     (void)unused3;
    911     (void)unused4;
    912     (void)unused5;
    913     (void)unused6;
    914 
    915     OSDictionary *pDictionary;
    916 
    917     VBOXUSB_LOCK();
    918 
    919     pDictionary = IOService::serviceMatching("AppleUSBTCKeyboard");
    920     if (pDictionary)
    921     {
    922         OSIterator     *pIter;
    923         IOUSBHIDDriver *pDriver;
    924 
    925         pIter = IOService::getMatchingServices(pDictionary);
    926         if (pIter)
    927         {
    928             while ((pDriver = (IOUSBHIDDriver *)pIter->getNextObject()))
    929                 pDriver->SuspendPort(false, 0);
    930 
    931             pIter->release();
    932         }
    933 
    934         pDictionary->release();
    935     }
    936 
    937     VBOXUSB_UNLOCK();
    938 
    939     return kIOReturnSuccess;
    940 }
    941895
    942896/**
  • trunk/src/VBox/HostDrivers/VBoxUSB/darwin/VBoxUSBInterface.h

    r49779 r49787  
    3030    /** org_virtualbox_VBoxUSBClient::removeFilter */
    3131    VBOXUSBMETHOD_REMOVE_FILTER,
    32     /** org_virtualbox_VBoxUSBClient::resumeBuiltInKbd */
    33     VBOXUSBMETHOD_RESUME_BUILTIN_KBD,
    3432    /** End/max. */
    3533    VBOXUSBMETHOD_END
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