VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibCrOgl.cpp@ 68645

Last change on this file since 68645 was 68645, checked in by vboxsync, 7 years ago

Merged VBGLInternal.h and VBoxGuestR0LibInternal.h into the latter.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: VBoxGuestR0LibCrOgl.cpp 68645 2017-09-05 14:17:02Z vboxsync $ */
2/** @file
3 * VBoxGuestLib - Ring-3 Support Library for VirtualBox guest additions, Chromium OpenGL Service.
4 */
5
6/*
7 * Copyright (C) 2012-2016 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#endif
31
32/*********************************************************************************************************************************
33* Header Files *
34*********************************************************************************************************************************/
35#include <iprt/string.h>
36#include "VBoxGuestR0LibInternal.h"
37
38
39DECLVBGL(int) VbglR0CrCtlCreate(VBGLCRCTLHANDLE *phCtl)
40{
41 int rc;
42
43 if (phCtl)
44 {
45 struct VBGLHGCMHANDLEDATA *pHandleData = vbglR0HGCMHandleAlloc();
46 if (pHandleData)
47 {
48 rc = VbglR0IdcOpen(&pHandleData->IdcHandle,
49 VBGL_IOC_VERSION /*uReqVersion*/,
50 VBGL_IOC_VERSION & UINT32_C(0xffff0000) /*uMinVersion*/,
51 NULL /*puSessionVersion*/, NULL /*puDriverVersion*/, NULL /*uDriverRevision*/);
52 if (RT_SUCCESS(rc))
53 {
54 *phCtl = pHandleData;
55 return VINF_SUCCESS;
56 }
57
58 vbglR0HGCMHandleFree(pHandleData);
59 }
60 else
61 rc = VERR_NO_MEMORY;
62
63 *phCtl = NULL;
64 }
65 else
66 rc = VERR_INVALID_PARAMETER;
67
68 return rc;
69}
70
71DECLVBGL(int) VbglR0CrCtlDestroy(VBGLCRCTLHANDLE hCtl)
72{
73 VbglR0IdcClose(&hCtl->IdcHandle);
74
75 vbglR0HGCMHandleFree(hCtl);
76
77 return VINF_SUCCESS;
78}
79
80DECLVBGL(int) VbglR0CrCtlConConnect(VBGLCRCTLHANDLE hCtl, HGCMCLIENTID *pidClient)
81{
82 VBGLIOCHGCMCONNECT info;
83 int rc;
84
85 if (!hCtl || !pidClient)
86 return VERR_INVALID_PARAMETER;
87
88 RT_ZERO(info);
89 VBGLREQHDR_INIT(&info.Hdr, HGCM_CONNECT);
90 info.u.In.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
91 RTStrCopy(info.u.In.Loc.u.host.achName, sizeof(info.u.In.Loc.u.host.achName), "VBoxSharedCrOpenGL");
92 rc = VbglR0IdcCall(&hCtl->IdcHandle, VBGL_IOCTL_HGCM_CONNECT, &info.Hdr, sizeof(info));
93 if (RT_SUCCESS(rc))
94 {
95 Assert(info.u.Out.idClient);
96 *pidClient = info.u.Out.idClient;
97 return rc;
98 }
99
100 AssertRC(rc);
101 *pidClient = 0;
102 return rc;
103}
104
105DECLVBGL(int) VbglR0CrCtlConDisconnect(VBGLCRCTLHANDLE hCtl, HGCMCLIENTID idClient)
106{
107 VBGLIOCHGCMDISCONNECT info;
108 VBGLREQHDR_INIT(&info.Hdr, HGCM_DISCONNECT);
109 info.u.In.idClient = idClient;
110 return VbglR0IdcCall(&hCtl->IdcHandle, VBGL_IOCTL_HGCM_DISCONNECT, &info.Hdr, sizeof(info));
111}
112
113DECLVBGL(int) VbglR0CrCtlConCallRaw(VBGLCRCTLHANDLE hCtl, PVBGLIOCHGCMCALL pCallInfo, int cbCallInfo)
114{
115 return VbglR0IdcCallRaw(&hCtl->IdcHandle, VBGL_IOCTL_HGCM_CALL(cbCallInfo), &pCallInfo->Hdr, cbCallInfo);
116}
117
118DECLVBGL(int) VbglR0CrCtlConCall(VBGLCRCTLHANDLE hCtl, PVBGLIOCHGCMCALL pCallInfo, int cbCallInfo)
119{
120 int rc = VbglR0IdcCallRaw(&hCtl->IdcHandle, VBGL_IOCTL_HGCM_CALL(cbCallInfo), &pCallInfo->Hdr, cbCallInfo);
121 if (RT_SUCCESS(rc))
122 rc = pCallInfo->Hdr.rc;
123 return rc;
124}
125
126DECLVBGL(int) VbglR0CrCtlConCallUserDataRaw(VBGLCRCTLHANDLE hCtl, PVBGLIOCHGCMCALL pCallInfo, int cbCallInfo)
127{
128 return VbglR0IdcCallRaw(&hCtl->IdcHandle, VBGL_IOCTL_HGCM_CALL_WITH_USER_DATA(cbCallInfo), &pCallInfo->Hdr, cbCallInfo);
129}
130
Note: See TracBrowser for help on using the repository browser.

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