VirtualBox

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

Last change on this file since 26425 was 26425, checked in by vboxsync, 15 years ago

alternative license for VBoxGuestLib is CDDL

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