VirtualBox

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

Last change on this file since 24349 was 21211, checked in by vboxsync, 16 years ago

VBoxGuest.h,VBoxGuestLib: Moved the VbglR3 API out of VBoxGuest.h and did some cleanup.

  • Property svn:eol-style set to native
  • Property svn:keyword set to Id
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1/* $Id: VBoxGuestR3LibGR.cpp 21211 2009-07-03 15:12:24Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, GR.
4 */
5
6/*
7 * Copyright (C) 2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#ifdef VBOX_VBGLR3_XFREE86
27/* Rather than try to resolve all the header file conflicts, I will just
28 prototype what we need here. */
29# define xalloc(size) Xalloc((unsigned long)(size))
30# define xfree(ptr) Xfree((pointer)(ptr))
31typedef void *pointer;
32extern "C" pointer Xalloc(unsigned long /*amount*/);
33extern "C" void Xfree(pointer /*ptr*/);
34#else
35# include <iprt/mem.h>
36# include <iprt/assert.h>
37# include <iprt/string.h>
38#endif
39#include <iprt/err.h>
40#include "VBGLR3Internal.h"
41
42
43int vbglR3GRAlloc(VMMDevRequestHeader **ppReq, uint32_t cb, VMMDevRequestType enmReqType)
44{
45 VMMDevRequestHeader *pReq;
46
47#ifdef VBOX_VBGLR3_XFREE86
48 pReq = (VMMDevRequestHeader *)xalloc(cb);
49#else
50 AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
51 AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
52 VERR_INVALID_PARAMETER);
53
54 pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
55#endif
56 if (RT_UNLIKELY(!pReq))
57 return VERR_NO_MEMORY;
58
59 pReq->size = cb;
60 pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
61 pReq->requestType = enmReqType;
62 pReq->rc = VERR_GENERAL_FAILURE;
63 pReq->reserved1 = 0;
64 pReq->reserved2 = 0;
65
66 *ppReq = pReq;
67
68 return VINF_SUCCESS;
69}
70
71
72VBGLR3DECL(int) vbglR3GRPerform(VMMDevRequestHeader *pReq)
73{
74 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_VMMREQUEST(pReq->size), pReq, pReq->size);
75}
76
77
78void vbglR3GRFree(VMMDevRequestHeader *pReq)
79{
80#ifdef VBOX_VBGLR3_XFREE86
81 xfree(pReq);
82#else
83 RTMemTmpFree(pReq);
84#endif
85}
86
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