~ubuntu-branches/ubuntu/quantal/virtualbox/quantal

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibCrOgl.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-05 12:41:55 UTC
  • mfrom: (3.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120405124155-i7b39tv5ddwhubbe
Tags: 4.1.12-dfsg-2
* Upstream has replaced the 4.1.12 tarball with a new one that fixes a
  crash when creating host only interfaces. (Closes: #667460)
  - Add 36-tarball-respin.patch which contains the diff between the old
    and the new tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 * VBoxGuestLib - Central calls header.
 
3
 */
 
4
 
 
5
/*
 
6
 * Copyright (C) 2012 Oracle Corporation
 
7
 *
 
8
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
9
 * available from http://www.virtualbox.org. This file is free software;
 
10
 * you can redistribute it and/or modify it under the terms of the GNU
 
11
 * General Public License (GPL) as published by the Free Software
 
12
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
13
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
14
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
15
 *
 
16
 * The contents of this file may alternatively be used under the terms
 
17
 * of the Common Development and Distribution License Version 1.0
 
18
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 
19
 * VirtualBox OSE distribution, in which case the provisions of the
 
20
 * CDDL are applicable instead of those of the GPL.
 
21
 *
 
22
 * You may elect to license modified versions of this file under the
 
23
 * terms and conditions of either the GPL or the CDDL or both.
 
24
 */
 
25
 
 
26
/* Entire file is ifdef'ed with !VBGL_VBOXGUEST */
 
27
#ifdef VBGL_VBOXGUEST
 
28
# error "VBGL_VBOXGUEST should not be defined"
 
29
#else
 
30
#include "VBoxGuestR0LibCrOgl.h"
 
31
 
 
32
#include <iprt/string.h>
 
33
 
 
34
#include "VBGLInternal.h"
 
35
 
 
36
struct VBGLHGCMHANDLEDATA *vbglHGCMHandleAlloc (void);
 
37
void vbglHGCMHandleFree (struct VBGLHGCMHANDLEDATA *pHandle);
 
38
 
 
39
DECLVBGL(int) vboxCrCtlCreate(HVBOXCRCTL *phCtl)
 
40
{
 
41
    int rc;
 
42
    struct VBGLHGCMHANDLEDATA *pHandleData;
 
43
 
 
44
    if (!phCtl)
 
45
        return VERR_INVALID_PARAMETER;
 
46
 
 
47
    pHandleData = vbglHGCMHandleAlloc ();
 
48
 
 
49
    rc = VINF_SUCCESS;
 
50
 
 
51
    if (!pHandleData)
 
52
    {
 
53
        rc = VERR_NO_MEMORY;
 
54
    }
 
55
    else
 
56
    {
 
57
        rc = vbglDriverOpen (&pHandleData->driver);
 
58
 
 
59
        if (RT_SUCCESS(rc))
 
60
        {
 
61
            *phCtl = pHandleData;
 
62
            return VINF_SUCCESS;
 
63
        }
 
64
 
 
65
        vbglHGCMHandleFree (pHandleData);
 
66
    }
 
67
 
 
68
    *phCtl = NULL;
 
69
    return rc;
 
70
}
 
71
 
 
72
DECLVBGL(int) vboxCrCtlDestroy(HVBOXCRCTL hCtl)
 
73
{
 
74
    vbglDriverClose(&hCtl->driver);
 
75
 
 
76
    vbglHGCMHandleFree(hCtl);
 
77
 
 
78
    return VINF_SUCCESS;
 
79
}
 
80
 
 
81
DECLVBGL(int) vboxCrCtlConConnect(HVBOXCRCTL hCtl, uint32_t *pu32ClientID)
 
82
{
 
83
    VBoxGuestHGCMConnectInfo info;
 
84
    int rc;
 
85
 
 
86
    if (!hCtl || !pu32ClientID)
 
87
        return VERR_INVALID_PARAMETER;
 
88
 
 
89
    memset(&info, 0, sizeof (info));
 
90
    info.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
 
91
    RTStrCopy(info.Loc.u.host.achName, sizeof (info.Loc.u.host.achName), "VBoxSharedCrOpenGL");
 
92
    rc = vbglDriverIOCtl (&hCtl->driver, VBOXGUEST_IOCTL_HGCM_CONNECT, &info, sizeof (info));
 
93
    if (RT_SUCCESS(rc))
 
94
        *pu32ClientID = info.u32ClientID;
 
95
    else
 
96
        *pu32ClientID = 0;
 
97
    return rc;
 
98
}
 
99
 
 
100
DECLVBGL(int) vboxCrCtlConDisconnect(HVBOXCRCTL hCtl, uint32_t u32ClientID)
 
101
{
 
102
    VBoxGuestHGCMDisconnectInfo info;
 
103
    memset (&info, 0, sizeof (info));
 
104
    info.u32ClientID = u32ClientID;
 
105
    return vbglDriverIOCtl (&hCtl->driver, VBOXGUEST_IOCTL_HGCM_DISCONNECT, &info, sizeof (info));
 
106
}
 
107
 
 
108
DECLVBGL(int) vboxCrCtlConCall(HVBOXCRCTL hCtl, struct VBoxGuestHGCMCallInfo *pCallInfo, int cbCallInfo)
 
109
{
 
110
    return vbglDriverIOCtl (&hCtl->driver, VBOXGUEST_IOCTL_HGCM_CALL(cbCallInfo), pCallInfo, cbCallInfo);
 
111
}
 
112
 
 
113
DECLVBGL(int) vboxCrCtlConCallUserData(HVBOXCRCTL hCtl, struct VBoxGuestHGCMCallInfo *pCallInfo, int cbCallInfo)
 
114
{
 
115
    return vbglDriverIOCtl (&hCtl->driver, VBOXGUEST_IOCTL_HGCM_CALL_USERDATA(cbCallInfo), pCallInfo, cbCallInfo);
 
116
}
 
117
 
 
118
#endif /* #ifndef VBGL_VBOXGUEST */