VirtualBox

Changeset 58178 in vbox


Ignore:
Timestamp:
Oct 12, 2015 11:40:57 AM (9 years ago)
Author:
vboxsync
Message:

VbglInit -> VbglInitPrimary & VbglInitClient. VBoxGuestLib/Init.cpp cleanups and positive thinking.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLib.h

    r58154 r58178  
    9494# define DECLVBGL(type) DECLR0VBGL(type)
    9595
    96 typedef uint32_t VBGLIOPORT; /**< @todo r=bird: We have RTIOPORT (uint16_t) for this. */
    97 
    9896
    9997# ifdef VBGL_VBOXGUEST
     
    105103 * @return VBox status code.
    106104 */
    107 DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, struct VMMDevMemory *pVMMDevMemory);
     105DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, struct VMMDevMemory *pVMMDevMemory);
    108106
    109107# else
     
    115113 * @return VBox status code.
    116114 */
    117 DECLVBGL(int) VbglInit (void);
     115DECLVBGL(int) VbglInitClient(void);
    118116
    119117# endif
     
    122120 * The library termination function.
    123121 */
    124 DECLVBGL(void) VbglTerminate (void);
     122DECLVBGL(void) VbglTerminate(void);
    125123
    126124
     
    132130 * Allocate memory for generic request and initialize the request header.
    133131 *
    134  * @param ppReq    pointer to resulting memory address.
    135  * @param cbSize   size of memory block required for the request.
    136  * @param reqType  the generic request type.
    137  *
    138  * @return VBox status code.
    139  */
    140 DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType);
     132 * @returns VBox status code.
     133 * @param   ppReq       Where to return the pointer to the allocated memory.
     134 * @param   cbReq       Size of memory block required for the request.
     135 * @param   enmReqType  the generic request type.
     136 */
     137DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, uint32_t cbReq, VMMDevRequestType enmReqType);
    141138
    142139/**
     
    147144 * @return VBox status code.
    148145 */
    149 DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq);
     146DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq);
    150147
    151148/**
     
    156153 * @return VBox status code.
    157154 */
    158 DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq);
     155DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq);
    159156
    160157/**
     
    168165 * @return VBox status code.
    169166 */
    170 DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq);
     167DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq);
    171168/** @} */
    172169
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r57848 r58178  
    74627462    NTSTATUS Status = STATUS_SUCCESS;
    74637463    /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
    7464     int rc = VbglInit();
     7464    int rc = VbglInitClient();
    74657465    if (RT_SUCCESS(rc))
    74667466    {
     
    75927592    else
    75937593    {
    7594         WARN(("VbglInit failed, rc(%d)", rc));
     7594        WARN(("VbglInitClient failed, rc(%d)", rc));
    75957595        Status = STATUS_UNSUCCESSFUL;
    75967596    }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/xpdm/VBoxMPDriver.cpp

    r56431 r58178  
    130130
    131131    /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */
    132     rc = VbglInit();
     132    rc = VbglInitClient();
    133133    VBOXMP_WARN_VPS(rc);
    134134
  • trunk/src/VBox/Additions/WINNT/Mouse/NT4/VBoxPS2NT.cpp

    r42154 r58178  
    21372137    ASSERT(status == STATUS_SUCCESS);
    21382138
    2139     int rcVBox = VbglInit();
     2139    int rcVBox = VbglInitClient();
    21402140    if (RT_FAILURE(rcVBox))
    21412141    {
  • trunk/src/VBox/Additions/WINNT/Mouse/NT5/VBoxMFInternal.cpp

    r44529 r58178  
    333333        if (!vboxIsVBGLInited() && !vboxIsVBGLInitFailed())
    334334        {
    335             int rc = VbglInit();
     335            int rc = VbglInitClient();
    336336
    337337            if (RT_SUCCESS(rc))
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r58089 r58178  
    10651065     * made by the VMM.
    10661066     */
    1067     rc = VbglInit(pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory);
     1067    rc = VbglInitPrimary(pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory);
    10681068    if (RT_SUCCESS(rc))
    10691069    {
  • trunk/src/VBox/Additions/common/VBoxGuestLib/GenericRequest.cpp

    r56294 r58178  
    3131#include <iprt/string.h>
    3232
    33 DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq)
     33
     34DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq)
    3435{
    3536    size_t cbReqExpected;
    3637
    37     if (!pReq || cbReq < sizeof (VMMDevRequestHeader))
     38    if (RT_UNLIKELY(!pReq || cbReq < sizeof(VMMDevRequestHeader)))
    3839    {
    3940        dprintf(("VbglGRVerify: Invalid parameter: pReq = %p, cbReq = %zu\n", pReq, cbReq));
     
    4142    }
    4243
    43     if (pReq->size > cbReq)
     44    if (RT_UNLIKELY(pReq->size > cbReq))
    4445    {
    4546        dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq));
     
    4950    /* The request size must correspond to the request type. */
    5051    cbReqExpected = vmmdevGetRequestSize(pReq->requestType);
    51 
    52     if (cbReq < cbReqExpected)
     52    if (RT_UNLIKELY(cbReq < cbReqExpected))
    5353    {
    5454        dprintf(("VbglGRVerify: buffer size %zu < expected size %zu\n", cbReq, cbReqExpected));
     
    5858    if (cbReqExpected == cbReq)
    5959    {
    60         /* This is most likely a fixed size request, and in this case the request size
    61          * must be also equal to the expected size.
     60        /*
     61         * This is most likely a fixed size request, and in this case the
     62         * request size must be also equal to the expected size.
    6263         */
    63         if (pReq->size != cbReqExpected)
     64        if (RT_UNLIKELY(pReq->size != cbReqExpected))
    6465        {
    6566            dprintf(("VbglGRVerify: request size %u != expected size %zu\n", pReq->size, cbReqExpected));
     
    8283#else
    8384        || pReq->requestType == VMMDevReq_HGCMCall
    84 #endif /* VBOX_WITH_64_BITS_GUESTS */
     85#endif
    8586        || pReq->requestType == VMMDevReq_RegisterSharedModule
    8687        || pReq->requestType == VMMDevReq_ReportGuestUserState
     
    8990        || pReq->requestType == VMMDevReq_VideoSetVisibleRegion)
    9091    {
    91         if (cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE)
     92        if (RT_UNLIKELY(cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE))
    9293        {
    9394            dprintf(("VbglGRVerify: VMMDevReq_LogString: buffer size %zu too big\n", cbReq));
    94             return VERR_BUFFER_OVERFLOW; /* @todo is this error code ok? */
     95            return VERR_BUFFER_OVERFLOW; /** @todo is this error code ok? */
    9596        }
    9697    }
     
    9899    {
    99100        dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq));
    100         return VERR_IO_BAD_LENGTH; /* @todo is this error code ok? */
     101        return VERR_IO_BAD_LENGTH; /** @todo is this error code ok? */
    101102    }
    102103
     
    104105}
    105106
    106 DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
     107DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, uint32_t cbReq, VMMDevRequestType enmReqType)
    107108{
    108     VMMDevRequestHeader *pReq;
    109     int rc = vbglR0Enter ();
     109    int rc = vbglR0Enter();
     110    if (RT_SUCCESS(rc))
     111    {
     112        if (ppReq && cbReq >= sizeof(VMMDevRequestHeader))
     113        {
     114            VMMDevRequestHeader *pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc(cbReq);
     115            AssertMsgReturn(pReq, ("VbglGRAlloc: no memory (cbReq=%u)\n", cbReq), VERR_NO_MEMORY);
     116            memset(pReq, 0xAA, cbReq);
    110117
    111     if (RT_FAILURE(rc))
    112         return rc;
     118            pReq->size        = cbReq;
     119            pReq->version     = VMMDEV_REQUEST_HEADER_VERSION;
     120            pReq->requestType = enmReqType;
     121            pReq->rc          = VERR_GENERAL_FAILURE;
     122            pReq->reserved1   = 0;
     123            pReq->reserved2   = 0;
    113124
    114     if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
    115     {
    116         dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %u\n", ppReq, cbSize));
    117         return VERR_INVALID_PARAMETER;
    118     }
    119 
    120     pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize);
    121     if (!pReq)
    122     {
    123         AssertMsgFailed(("VbglGRAlloc: no memory\n"));
    124         rc = VERR_NO_MEMORY;
    125     }
    126     else
    127     {
    128         memset(pReq, 0xAA, cbSize);
    129 
    130         pReq->size        = cbSize;
    131         pReq->version     = VMMDEV_REQUEST_HEADER_VERSION;
    132         pReq->requestType = reqType;
    133         pReq->rc          = VERR_GENERAL_FAILURE;
    134         pReq->reserved1   = 0;
    135         pReq->reserved2   = 0;
    136 
    137         *ppReq = pReq;
    138     }
    139 
    140     return rc;
    141 }
    142 
    143 DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq)
    144 {
    145     RTCCPHYS physaddr;
    146     int rc = vbglR0Enter ();
    147 
    148     if (RT_FAILURE(rc))
    149         return rc;
    150 
    151     if (!pReq)
    152         return VERR_INVALID_PARAMETER;
    153 
    154     physaddr = VbglPhysHeapGetPhysAddr (pReq);
    155     if (  !physaddr
    156        || (physaddr >> 32) != 0) /* Port IO is 32 bit. */
    157     {
    158         rc = VERR_VBGL_INVALID_ADDR;
    159     }
    160     else
    161     {
    162         ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)physaddr);
    163         /* Make the compiler aware that the host has changed memory. */
    164         ASMCompilerBarrier();
    165         rc = pReq->rc;
     125            *ppReq = pReq;
     126            rc = VINF_SUCCESS;
     127        }
     128        else
     129        {
     130            dprintf(("VbglGRAlloc: Invalid parameter: ppReq=%p cbReq=%u\n", ppReq, cbReq));
     131            rc = VERR_INVALID_PARAMETER;
     132        }
    166133    }
    167134    return rc;
    168135}
    169136
    170 DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
     137DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq)
    171138{
    172     int rc = vbglR0Enter ();
    173 
    174     if (RT_FAILURE(rc))
    175         return;
    176 
    177     VbglPhysHeapFree (pReq);
     139    int rc = vbglR0Enter();
     140    if (RT_SUCCESS(rc))
     141    {
     142        if (pReq)
     143        {
     144            RTCCPHYS PhysAddr = VbglPhysHeapGetPhysAddr(pReq);
     145            if (   PhysAddr != 0
     146                && PhysAddr < _4G) /* Port IO is 32 bit. */
     147            {
     148                ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr);
     149                /* Make the compiler aware that the host has changed memory. */
     150                ASMCompilerBarrier();
     151                rc = pReq->rc;
     152            }
     153            else
     154                rc = VERR_VBGL_INVALID_ADDR;
     155        }
     156        else
     157            rc = VERR_INVALID_PARAMETER;
     158    }
     159    return rc;
    178160}
    179161
     162DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq)
     163{
     164    int rc = vbglR0Enter();
     165    if (RT_SUCCESS(rc))
     166        VbglPhysHeapFree(pReq);
     167}
     168
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Init.cpp

    r57358 r58178  
    113113            dprintf (("port = 0x%04X, mem = %p\n", port.portAddress, port.pVMMDevMemory));
    114114
    115             g_vbgldata.portVMMDev = port.portAddress;
     115            g_vbgldata.portVMMDev = (RTIOPORT)port.portAddress;
    116116            g_vbgldata.pVMMDevMemory = port.pVMMDevMemory;
    117117
     
    187187#ifdef VBGL_VBOXGUEST
    188188
    189 DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)
     189DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)
    190190{
    191191    int rc = VINF_SUCCESS;
     
    194194    dprintf(("vbglInit: starts g_vbgldata.status %d\n", g_vbgldata.status));
    195195
    196     if (g_vbgldata.status == VbglStatusInitializing
     196    if (   g_vbgldata.status == VbglStatusInitializing
    197197        || g_vbgldata.status == VbglStatusReady)
    198198    {
     
    233233#else /* !VBGL_VBOXGUEST */
    234234
    235 DECLVBGL(int) VbglInit (void)
     235DECLVBGL(int) VbglInitClient(void)
    236236{
    237237    int rc = VINF_SUCCESS;
    238238
    239     if (g_vbgldata.status == VbglStatusInitializing
     239    if (   g_vbgldata.status == VbglStatusInitializing
    240240        || g_vbgldata.status == VbglStatusReady)
    241241    {
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h

    r56294 r58178  
    7373 * Lives in VbglR0Init.cpp.
    7474 */
    75 typedef struct _VBGLDATA
     75typedef struct VBGLDATA
    7676{
    7777    enum VbglLibStatus status;
    7878
    79     VBGLIOPORT portVMMDev;
     79    RTIOPORT portVMMDev;
    8080
    8181    VMMDevMemory *pVMMDevMemory;
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.c

    r57358 r58178  
    6565    int rc = VINF_SUCCESS;
    6666
    67     rc = VbglInit ();
     67    rc = VbglInitClient();
    6868    return rc;
    6969}
  • trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInit.cpp

    r57358 r58178  
    6464 * The caller will do the necessary AttachDD and calling of the 16 bit
    6565 * IDC to initialize the g_VBoxGuestIDC global. Perhaps we should move
    66  * this bit to VbglInit? It's just that it's so much simpler to do it
     66 * this bit to VbglInitClient? It's just that it's so much simpler to do it
    6767 * while we're on the way here...
    6868 *
    6969 */
    70 DECLASM(void)
    71 VBoxSFR0Init(void)
     70DECLASM(void) VBoxSFR0Init(void)
    7271{
    7372    Log(("VBoxSFR0Init: g_fpfnDevHlp=%lx u32Version=%RX32 u32Session=%RX32 pfnServiceEP=%p g_u32Info=%u (%#x)\n",
     
    8483        if (RT_SUCCESS(rc))
    8584        {
    86             rc = VbglInit();
     85            rc = VbglInitClient();
    8786            if (RT_SUCCESS(rc))
    8887            {
  • trunk/src/VBox/Additions/solaris/Mouse/testcase/solaris.h

    r41852 r58178  
    351351#define VbglGRFree(...) do {} while(0)
    352352#endif
    353 #define VbglInit(...) VINF_SUCCESS
     353#define VbglInitClient(...) VINF_SUCCESS
    354354#define vbglDriverOpen(...) VINF_SUCCESS
    355355#define vbglDriverClose(...) do {} while(0)
  • trunk/src/VBox/Additions/solaris/Mouse/vboxms.c

    r57605 r58178  
    471471         * init, and create a new session.
    472472         */
    473         rc = VbglInit();
     473        rc = VbglInitClient();
    474474        if (RT_SUCCESS(rc))
    475475        {
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