VirtualBox

Changeset 21461 in vbox for trunk/src


Ignore:
Timestamp:
Jul 9, 2009 10:13:37 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49879
Message:

VBoxGuestLib: Implemented detection of physical page list support.

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

Legend:

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

    r21226 r21461  
    2828{
    2929    VMMDevRequestHeader *pReq;
    30     int rc = VbglEnter ();
     30    int rc = vbglR0Enter ();
    3131
    3232    if (RT_FAILURE(rc))
     
    6565{
    6666    RTCCPHYS physaddr;
    67     int rc = VbglEnter ();
     67    int rc = vbglR0Enter ();
    6868
    6969    if (RT_FAILURE(rc))
     
    9191DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
    9292{
    93     int rc = VbglEnter ();
     93    int rc = vbglR0Enter ();
    9494
    9595    if (RT_FAILURE(rc))
  • trunk/src/VBox/Additions/common/VBoxGuestLib/HGCM.cpp

    r21261 r21461  
    3434#define VBGL_HGCM_ASSERTMsg AssertReleaseMsg
    3535
    36 int vbglHGCMInit (void)
    37 {
    38     RTSemFastMutexCreate(&g_vbgldata.mutexHGCMHandle);
    39 
    40     return VINF_SUCCESS;
    41 }
    42 
    43 int vbglHGCMTerminate (void)
     36/**
     37 * Initializes the HGCM VBGL bits.
     38 *
     39 * @return VBox status code.
     40 */
     41int vbglR0HGCMInit (void)
     42{
     43    return RTSemFastMutexCreate(&g_vbgldata.mutexHGCMHandle);
     44}
     45
     46/**
     47 * Initializes the HGCM VBGL bits.
     48 *
     49 * @return VBox status code.
     50 */
     51int vbglR0HGCMTerminate (void)
    4452{
    4553    RTSemFastMutexDestroy(g_vbgldata.mutexHGCMHandle);
     54    g_vbgldata.mutexHGCMHandle = NIL_RTSEMFASTMUTEX;
    4655
    4756    return VINF_SUCCESS;
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Init.cpp

    r21211 r21461  
    2020 */
    2121
    22 
     22/*******************************************************************************
     23*   Header Files                                                               *
     24*******************************************************************************/
    2325#define VBGL_DECL_DATA
    2426#include "VBGLInternal.h"
     
    2729#include <iprt/assert.h>
    2830
     31/*******************************************************************************
     32*   Global Variables                                                           *
     33*******************************************************************************/
     34/** The global VBGL instance data.  */
    2935VBGLDATA g_vbgldata;
    3036
     37/**
     38 * Used by vbglQueryVMMDevPort and VbglInit to try get the host feature mask and
     39 * version information (g_vbgldata::hostVersion).
     40 *
     41 * This was first implemented by the host in 3.1 and we quietly ignore failures
     42 * for that reason.
     43 */
     44static void vbglR0QueryHostVersion (void)
     45{
     46    VMMDevReqHostVersion *pReq;
     47
     48    int rc = VbglGRAlloc ((VMMDevRequestHeader **) &pReq, sizeof (*pReq), VMMDevReq_GetHostVersion);
     49
     50    if (RT_SUCCESS (rc))
     51    {
     52        rc = VbglGRPerform (&pReq->header);
     53
     54        if (RT_SUCCESS (rc))
     55        {
     56            g_vbgldata.hostVersion = *pReq;
     57            Log (("vbglR0QueryHostVersion: %u.%u.%ur%u %#x\n",
     58                  pReq->major, pReq->minor, pReq->build, pReq->revision, pReq->features));
     59        }
     60
     61        VbglGRFree (&pReq->header);
     62    }
     63}
     64
    3165#ifndef VBGL_VBOXGUEST
    32 /* The guest library uses lazy initialization for VMMDev port and memory,
     66/**
     67 * The guest library uses lazy initialization for VMMDev port and memory,
    3368 * because these values are provided by the VBoxGuest driver and it might
    3469 * be loaded later than other drivers.
     70 *
    3571 * The VbglEnter checks the current library status, tries to retrive these
    3672 * values and fails if they are unavailable.
     73 *
    3774 */
    3875static void vbglQueryVMMDevPort (void)
     
    4683    if (RT_SUCCESS(rc))
    4784    {
     85        /*
     86         * Try query the port info.
     87         */
    4888        VBoxGuestPortInfo port;
    4989
     
    5898
    5999            g_vbgldata.status = VbglStatusReady;
     100
     101            vbglR0QueryHostVersion();
    60102        }
    61103
     
    65107    dprintf (("vbglQueryVMMDevPort rc = %d\n", rc));
    66108}
    67 #endif
    68 
    69 int VbglEnter (void)
     109#endif /* !VBGL_VBOXGUEST */
     110
     111/**
     112 * Checks if VBGL has been initialized.
     113 *
     114 * The the client library, this will lazily complete the initialization.
     115 *
     116 * @return VINF_SUCCESS or VERR_VBGL_NOT_INITIALIZED.
     117 */
     118int vbglR0Enter (void)
    70119{
    71120    int rc;
     
    121170    int rc = VINF_SUCCESS;
    122171
     172# ifdef RT_OS_WINDOWS /** @todo r=bird: this doesn't make sense. Is there something special going on on windows? */
    123173    dprintf(("vbglInit: starts g_vbgldata.status %d\n", g_vbgldata.status));
    124174
     
    129179        return rc;
    130180    }
     181# else
     182    dprintf(("vbglInit: starts\n"));
     183# endif
    131184
    132185    rc = vbglInitCommon ();
     
    138191
    139192        g_vbgldata.status = VbglStatusReady;
     193
     194        vbglR0QueryHostVersion();
    140195    }
    141196    else
     
    175230        vbglQueryVMMDevPort ();
    176231
    177 #ifdef VBOX_WITH_HGCM
    178         rc = vbglHGCMInit ();
    179 #endif /* VBOX_WITH_HGCM */
     232# ifdef VBOX_WITH_HGCM
     233        rc = vbglR0HGCMInit ();
     234# endif /* VBOX_WITH_HGCM */
    180235
    181236        if (RT_FAILURE(rc))
     
    192247    vbglTerminateCommon ();
    193248
    194 #ifdef VBOX_WITH_HGCM
    195     vbglHGCMTerminate ();
    196 #endif
     249# ifdef VBOX_WITH_HGCM
     250    vbglR0HGCMTerminate ();
     251# endif
    197252
    198253    return;
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r21271 r21461  
    5858        VMMDev.cpp \
    5959        HGCM.cpp \
    60         VBoxCalls.c
     60        VBoxCalls.c \
     61        VbglR0CanUsePhysPageList.cpp
     62
    6163
    6264#
     
    7375        Init.cpp \
    7476        VMMDev.cpp \
    75         HGCMInternal.cpp
     77        HGCMInternal.cpp \
     78        VbglR0CanUsePhysPageList.cpp
    7679
    7780#
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h

    r21227 r21461  
    2929#include <VBox/log.h>
    3030
    31 /** @todo dprintf() -> Log() */
     31
     32#ifdef RT_OS_WINDOWS /** @todo dprintf() -> Log() */
    3233#if (defined(DEBUG) && !defined(NO_LOGGING)) || defined(LOG_ENABLED)
    3334# define dprintf(a) RTLogBackdoorPrintf a
     
    3536# define dprintf(a) do {} while (0)
    3637#endif
     38#else
     39# define dprintf(a) Log(a)
     40#endif
    3741
    3842#include "SysHlp.h"
    3943
    40 #pragma pack(4)
     44#pragma pack(4) /** @todo r=bird: What do we need packing for here? None of these structures are shared between drivers AFAIK. */
    4145
    4246struct _VBGLPHYSHEAPBLOCK;
     
    6064};
    6165
     66/**
     67 * Global VBGL ring-0 data.
     68 * Lives in VbglR0Init.cpp.
     69 */
    6270typedef struct _VBGLDATA
    6371{
     
    8088    /** @} */
    8189
     90    /**
     91     * The host version data.
     92     */
     93    VMMDevReqHostVersion hostVersion;
     94
     95
    8296#ifndef VBGL_VBOXGUEST
    8397    /**
     
    94108} VBGLDATA;
    95109
     110
    96111#pragma pack()
    97112
     
    100115#endif
    101116
    102 /* Check if library has been initialized before entering
    103  * a public library function.
     117/**
     118 * Internal macro for checking whether we can pass phyical page lists to the
     119 * host.
     120 *
     121 * ASSUMES that vbglR0Enter has been called already.
    104122 */
    105 int VbglEnter (void);
     123#define VBGLR0_CAN_USE_PHYS_PAGE_LIST() \
     124    ( !!(g_vbgldata.hostVersion.features & VMMDEV_HVF_HGCM_PHYS_PAGE_LIST) )
     125
     126int vbglR0Enter (void);
    106127
    107128#ifdef VBOX_WITH_HGCM
    108129# ifndef VBGL_VBOXGUEST
    109 /* Initialize HGCM subsystem. */
    110 int vbglHGCMInit (void);
    111 /* Terminate HGCM subsystem. */
    112 int vbglHGCMTerminate (void);
     130int vbglR0HGCMInit (void);
     131int vbglR0HGCMTerminate (void);
    113132# endif
    114133#endif /* VBOX_WITH_HGCM */
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp

    r21211 r21461  
    2424DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory)
    2525{
    26     int rc = VbglEnter ();
     26    int rc = vbglR0Enter ();
    2727
    2828    if (RT_FAILURE(rc))
Note: See TracChangeset for help on using the changeset viewer.

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