VirtualBox

Changeset 41852 in vbox for trunk/src/VBox


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

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

Location:
trunk/src/VBox/Additions
Files:
1 added
6 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
  • trunk/src/VBox/Additions/solaris/Mouse/Makefile.kmk

    r41725 r41852  
    3333
    3434#
    35 # vboxmouse - The Mouse Integration Driver
     35# vboxms - The Mouse Integration Driver
    3636#
    37 SYSMODS.solaris     += vboxmouse
    38 vboxmouse_TEMPLATE   = VBOXGUESTR0
    39 vboxmouse_DEFS       = VBOX_WITH_HGCM VBOX_SVN_REV=$(VBOX_SVN_REV)
    40 vboxmouse_DEPS      += $(VBOX_SVN_REV_KMK)
    41 vboxmouse_SOURCES    = \
     37SYSMODS.solaris     += vboxms
     38vboxms_TEMPLATE   = VBOXGUESTR0
     39vboxms_DEFS       = VBOX_WITH_HGCM VBOX_SVN_REV=$(VBOX_SVN_REV)
     40vboxms_DEPS      += $(VBOX_SVN_REV_KMK)
     41vboxms_SOURCES    = \
    4242        vboxmouse.c
    43 vboxmouse_LIBS       = \
     43vboxms_LIBS       = \
    4444        $(VBOX_LIB_VBGL_R0)
    4545ifeq ($(KBUILD_HOST),solaris)
    46  vboxmouse_LDFLAGS         += -N drv/vboxguest -N misc/ctf
     46 vboxms_LDFLAGS         += -N drv/vboxguest -N misc/ctf
    4747else
    48  vboxmouse_SOURCES         += deps.asm
    49  vboxmouse_deps.asm_ASFLAGS = -f bin -g null
     48 vboxms_SOURCES         += deps.asm
     49 vboxms_deps.asm_ASFLAGS = -f bin -g null
    5050endif
    5151
  • trunk/src/VBox/Additions/solaris/Mouse/testcase/solaris.h

    r41705 r41852  
    335335#define RTR0Init(...) VINF_SUCCESS
    336336#define RTR0Term(...) do {} while(0)
     337#define RTR0AssertPanicSystem(...) do {} while(0)
    337338#define RTLogCreate(...) VINF_SUCCESS
    338339#define RTLogRelSetDefaultInstance(...) do {} while(0)
    339340#define RTLogDestroy(...) do {} while(0)
     341#if 0
    340342#define VBoxGuestCreateKernelSession(...) VINF_SUCCESS
    341343#define VBoxGuestCreateUserSession(...) VINF_SUCCESS
     
    348350#define VbglGRPerform(...) VINF_SUCCESS
    349351#define VbglGRFree(...) do {} while(0)
     352#endif
     353#define VbglInit(...) VINF_SUCCESS
     354#define vbglDriverOpen(...) VINF_SUCCESS
     355#define vbglDriverClose(...) do {} while(0)
     356#define vbglDriverIOCtl(...) VINF_SUCCESS
    350357#define qprocson(...) do {} while(0)
    351358#define qprocsoff(...) do {} while(0)
  • trunk/src/VBox/Additions/solaris/Mouse/vboxmouse.c

    r41705 r41852  
    7878#define DEVICE_NAME              "vboxmouse"
    7979/** The module description as seen in 'modinfo'. */
    80 #define DEVICE_DESC              "VirtualBox MouInt"
     80#define DEVICE_DESC              "VBoxMouseIntegr"
    8181
    8282
     
    102102static struct module_info g_vbmsSolModInfo =
    103103{
    104     0x0ffff,                /* module id number */
    105     "vboxmouse",
     104    0,                      /* module id number */
     105    "vboxms",
    106106    0,                      /* minimum packet size */
    107107    INFPSZ,                 /* maximum packet size accepted */
     
    159159 */
    160160static struct fmodsw g_vbmsSolStrWrapper = {
    161     "vboxmouse",
     161    "vboxms",
    162162    &g_vbmsSolStreamTab,
    163     D_MP | D_MTPERMOD
     163    D_MP
    164164};
    165165
     
    193193typedef struct
    194194{
    195     /** Pointer to the Guest Library handle for the main driver. */
    196     VBGLDRIVER         Driver;
    197195    /** The STREAMS write queue which we need for sending messages up to
    198196     * user-space. */
     
    286284
    287285/******************************************************************************
    288 *   Helper routines                                                           *
    289 ******************************************************************************/
    290 
    291 /** Calls the kernel IOCtl to report mouse status to the host on behalf of
    292  * an open session. */
    293 static int vbmsSolSetMouseStatus(VBGLDRIVER *pDriver, uint32_t fStatus)
    294 {
    295     return vbglDriverIOCtl(pDriver, VBOXGUEST_IOCTL_SET_MOUSE_STATUS, &fStatus,
    296                            sizeof(fStatus));
    297 }
    298 
    299 
    300 /******************************************************************************
    301286*   Main code                                                                 *
    302287******************************************************************************/
     
    341326     * Create a new session.
    342327     */
    343     rc = vbglDriverOpen(&pState->Driver);
    344     if (RT_SUCCESS(rc))
    345     {
    346         VBoxGuestMouseSetNotifyCallback NotifyCallback;
    347 
     328    if (VbglIsReady())
     329    {
    348330        /* Initialise user data for the queues to our state and vice-versa. */
    349331        WR(pReadQueue)->q_ptr = (char *)pState;
    350332        pReadQueue->q_ptr = (char *)pState;
    351333        /* Enable our IRQ handler. */
    352         NotifyCallback.pfnNotify = vbmsSolNotify;
    353         NotifyCallback.pvUser    = (void *)pState;
    354         vbglDriverIOCtl(&pState->Driver,
    355                         VBOXGUEST_IOCTL_SET_MOUSE_NOTIFY_CALLBACK,
    356                         &NotifyCallback, sizeof(NotifyCallback));
     334        VbglSetMouseNotifyCallback(vbmsSolNotify, (void *)pState);
    357335        qprocson(pReadQueue);
    358336        LogRel((DEVICE_NAME "::Open\n"));
     
    377355{
    378356    PVBMSSTATE pState = (PVBMSSTATE)pvState;
    379     VMMDevReqMouseStatus *pReq;
    380357    int rc;
     358    uint32_t x, y;
    381359    LogFlow((DEVICE_NAME "::NativeISRMousePollEvent:\n"));
    382360
    383     rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq),
    384                      VMMDevReq_GetMouseStatus);
    385     if (RT_FAILURE(rc))
    386         return;  /* If kernel memory is short a missed event is acceptable! */
    387     pReq->mouseFeatures = 0;
    388     pReq->pointerXPos = 0;
    389     pReq->pointerYPos = 0;
    390     rc = VbglGRPerform(&pReq->header);
     361    rc = VbglGetMouseStatus(NULL, &x, &y);
    391362    if (RT_SUCCESS(rc))
    392363    {
     
    397368        {
    398369            vbmsSolVUIDPutAbsEvent(pState, LOC_X_ABSOLUTE,
    399                                      pReq->pointerXPos * cMaxScreenX
    400                                    / VMMDEV_MOUSE_RANGE_MAX);
     370                                   x * cMaxScreenX / VMMDEV_MOUSE_RANGE_MAX);
    401371            vbmsSolVUIDPutAbsEvent(pState, LOC_Y_ABSOLUTE,
    402                                      pReq->pointerYPos * cMaxScreenY
    403                                    / VMMDEV_MOUSE_RANGE_MAX);
     372                                   y * cMaxScreenY / VMMDEV_MOUSE_RANGE_MAX);
    404373        }
    405374    }
    406     VbglGRFree(&pReq->header);
    407375}
    408376
     
    439407{
    440408    PVBMSSTATE pState = (PVBMSSTATE)pReadQueue->q_ptr;
    441     VBoxGuestMouseSetNotifyCallback NotifyCallback;
    442409
    443410    LogFlow((DEVICE_NAME "::Close\n"));
     
    451418    }
    452419
     420    VbglSetMouseStatus(0);
    453421    /* Disable our IRQ handler. */
    454     RT_ZERO(NotifyCallback);
    455     vbglDriverIOCtl(&pState->Driver,
    456                     VBOXGUEST_IOCTL_SET_MOUSE_NOTIFY_CALLBACK,
    457                     &NotifyCallback, sizeof(NotifyCallback));
     422    VbglSetMouseNotifyCallback(NULL, NULL);
    458423    qprocsoff(pReadQueue);
    459424
     
    461426     * Close the session.
    462427     */
    463     vbglDriverClose(&pState->Driver);
    464428    ASMAtomicWriteNullPtr(&pState->pWriteQueue);
    465429    pReadQueue->q_ptr = NULL;
     
    11981162            pState->cMaxScreenY = pResolution->height - 1;
    11991163            /* Note: we don't disable this again until session close. */
    1200             rc = vbmsSolSetMouseStatus(&pState->Driver,
    1201                                          VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE
    1202                                        | VMMDEV_MOUSE_NEW_PROTOCOL);
     1164            rc = VbglSetMouseStatus(  VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE
     1165                                    | VMMDEV_MOUSE_NEW_PROTOCOL);
    12031166            if (RT_SUCCESS(rc))
    12041167                return 0;
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