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