VirtualBox

Ignore:
Timestamp:
Jun 20, 2012 3:59:57 PM (13 years ago)
Author:
vboxsync
Message:

Additions/common and solaris/vboxmouse: large code drop.

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Init.cpp

    r41783 r41852  
    3333#include <iprt/string.h>
    3434#include <iprt/assert.h>
     35#include <iprt/semaphore.h>
    3536
    3637/*******************************************************************************
     
    4142
    4243/**
    43  * Used by vbglQueryVMMDevPort and VbglInit to try get the host feature mask and
     44 * Used by vbglQueryDriverInfo and VbglInit to try get the host feature mask and
    4445 * version information (g_vbgldata::hostVersion).
    4546 *
     
    7879 *
    7980 */
    80 static void vbglQueryVMMDevPort (void)
     81static void vbglQueryDriverInfo (void)
    8182{
    8283    int rc = VINF_SUCCESS;
    8384
    84     VBGLDRIVER driver;
    85 
    86     rc = vbglDriverOpen (&driver);
     85    rc = RTSemFastMutexRequest(g_vbgldata.mutexDriverInit);
     86   
     87    if (RT_FAILURE(rc))
     88        return;
     89
     90    if (g_vbgldata.status == VbglStatusReady)
     91    {
     92        RTSemFastMutexRelease(g_vbgldata.mutexDriverInit);
     93        return;
     94    }
     95
     96    rc = vbglDriverOpen(&g_vbgldata.driver);
    8797
    8898    if (RT_SUCCESS(rc))
     
    93103        VBoxGuestPortInfo port;
    94104
    95         rc = vbglDriverIOCtl (&driver, VBOXGUEST_IOCTL_GETVMMDEVPORT, &port, sizeof (port));
     105        rc = vbglDriverIOCtl (&g_vbgldata.driver,
     106                              VBOXGUEST_IOCTL_GETVMMDEVPORT, &port,
     107                              sizeof (port));
    96108
    97109        if (RT_SUCCESS (rc))
     
    106118            vbglR0QueryHostVersion();
    107119        }
    108 
    109         vbglDriverClose (&driver);
    110     }
    111 
    112     dprintf (("vbglQueryVMMDevPort rc = %d\n", rc));
     120    }
     121    RTSemFastMutexRelease(g_vbgldata.mutexDriverInit);
     122    dprintf (("vbglQueryDriverInfo rc = %d\n", rc));
    113123}
    114124#endif /* !VBGL_VBOXGUEST */
     
    128138    if (g_vbgldata.status == VbglStatusInitializing)
    129139    {
    130         vbglQueryVMMDevPort ();
     140        vbglQueryDriverInfo ();
    131141    }
    132142#endif
     
    234244    if (RT_SUCCESS(rc))
    235245    {
    236         /* Try to obtain VMMDev port via IOCTL to VBoxGuest main driver. */
    237         vbglQueryVMMDevPort ();
     246        rc = RTSemFastMutexCreate(&g_vbgldata.mutexDriverInit);
     247        if (RT_SUCCESS(rc))
     248        {
     249            /* Try to obtain VMMDev port via IOCTL to VBoxGuest main driver. */
     250            vbglQueryDriverInfo ();
    238251
    239252# ifdef VBOX_WITH_HGCM
    240         rc = vbglR0HGCMInit ();
     253            rc = vbglR0HGCMInit ();
    241254# endif /* VBOX_WITH_HGCM */
     255
     256            if (RT_FAILURE(rc))
     257            {
     258                RTSemFastMutexDestroy(g_vbgldata.mutexDriverInit);
     259                g_vbgldata.mutexDriverInit = NIL_RTSEMFASTMUTEX;
     260            }
     261        }
    242262
    243263        if (RT_FAILURE(rc))
     
    245265            vbglTerminateCommon ();
    246266        }
     267       
    247268    }
    248269
    249270    return rc;
     271}
     272
     273DECLVBGL(bool) VbglIsReady(void)
     274{
     275    return(g_vbgldata.status == VbglStatusReady);
    250276}
    251277
     
    257283
    258284    vbglTerminateCommon ();
     285    vbglDriverClose(&g_vbgldata.driver);
     286    RTSemFastMutexDestroy(g_vbgldata.mutexDriverInit);
     287    g_vbgldata.mutexDriverInit = NIL_RTSEMFASTMUTEX;
    259288
    260289    return;
    261290}
    262291
     292int vbglGetDriver(VBGLDRIVER **ppDriver)
     293{
     294    if (g_vbgldata.status != VbglStatusReady)
     295    {
     296        vbglQueryDriverInfo();
     297        if (g_vbgldata.status != VbglStatusReady)
     298            return VERR_TRY_AGAIN;
     299    }
     300    *ppDriver = &g_vbgldata.driver;
     301    return VINF_SUCCESS;
     302}
     303
    263304#endif /* !VBGL_VBOXGUEST */
    264 
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r41477 r41852  
    6161        PhysHeap.cpp \
    6262        Init.cpp \
     63        Mouse.cpp \
    6364        VMMDev.cpp \
    6465        HGCM.cpp \
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h

    r40901 r41852  
    101101#ifndef VBGL_VBOXGUEST
    102102    /**
     103     * Handle for the main driver instance.
     104     * @{
     105     */
     106
     107    RTSEMFASTMUTEX mutexDriverInit;
     108
     109    VBGLDRIVER driver;
     110
     111    /** @} */
     112
     113    /**
    103114     * Fast heap for HGCM handles data.
    104115     * @{
     
    156167#endif /* VBOX_WITH_HGCM */
    157168
     169#ifndef VBGL_VBOXGUEST
     170/**
     171 * Get a handle to the main VBoxGuest driver.
     172 * @returns VERR_TRY_AGAIN if the main driver has not yet been loaded.
     173 */
     174int vbglGetDriver(VBGLDRIVER **ppDriver);
     175#endif
     176
    158177#endif /* !___VBoxGuestLib_VBGLInternal_h */
    159178
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