VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGR.cpp@ 6656

Last change on this file since 6656 was 6538, checked in by vboxsync, 17 years ago

Additions/R3 Guest library: created a reduced version of the library which depends on the X server runtime instead of ours, for use in old X server drivers

  • Property svn:eol-style set to native
  • Property svn:keyword set to Id
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/* $Id: VBoxGuestR3LibGR.cpp 6538 2008-01-28 19:50:14Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, GR.
4 */
5
6/*
7 * Copyright (C) 2007 innotek GmbH
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
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#ifdef VBOX_VBGLR3_XFREE86
23/* For the definitions of standard X server library functions like xalloc. */
24/* Make the headers C++-compatible */
25# define class xf86_vbox_class
26# define bool xf86_vbox_bool
27# define private xf86_vbox_private
28# define new xf86_vbox_new
29extern "C"
30{
31# include "xf86.h"
32# include "xf86_OSproc.h"
33# include "xf86Resources.h"
34# include "xf86_ansic.h"
35}
36# undef class
37# undef bool
38# undef private
39# undef new
40#else
41# include <iprt/mem.h>
42# include <iprt/assert.h>
43# include <iprt/string.h>
44#endif
45#include <iprt/err.h>
46#include <VBox/VBoxGuest.h>
47#include "VBGLR3Internal.h"
48
49
50int vbglR3GRAlloc(VMMDevRequestHeader **ppReq, uint32_t cb, VMMDevRequestType enmReqType)
51{
52 VMMDevRequestHeader *pReq;
53
54#ifdef VBOX_VBGLR3_XFREE86
55 pReq = (VMMDevRequestHeader *)xalloc(cb);
56#else
57 AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
58 AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
59 VERR_INVALID_PARAMETER);
60
61 pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
62#endif
63 if (RT_UNLIKELY(!pReq))
64 return VERR_NO_MEMORY;
65
66 pReq->size = cb;
67 pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
68 pReq->requestType = enmReqType;
69 pReq->rc = VERR_GENERAL_FAILURE;
70 pReq->reserved1 = 0;
71 pReq->reserved2 = 0;
72
73 *ppReq = pReq;
74
75 return VINF_SUCCESS;
76}
77
78
79VBGLR3DECL(int) vbglR3GRPerform(VMMDevRequestHeader *pReq)
80{
81 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_VMMREQUEST(pReq->size), pReq, pReq->size);
82}
83
84
85void vbglR3GRFree(VMMDevRequestHeader *pReq)
86{
87#ifdef VBOX_VBGLR3_XFREE86
88 xfree(pReq);
89#else
90 RTMemTmpFree(pReq);
91#endif
92}
93
Note: See TracBrowser for help on using the repository browser.

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