VirtualBox

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

Last change on this file since 19420 was 10553, checked in by vboxsync, 16 years ago

More IOCTLs.

  • 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 10553 2008-07-11 20:11:27Z 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 <VBox/VBoxGuest.h>
41#include "VBGLR3Internal.h"
42
43
44int vbglR3GRAlloc(VMMDevRequestHeader **ppReq, uint32_t cb, VMMDevRequestType enmReqType)
45{
46 VMMDevRequestHeader *pReq;
47
48#ifdef VBOX_VBGLR3_XFREE86
49 pReq = (VMMDevRequestHeader *)xalloc(cb);
50#else
51 AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
52 AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
53 VERR_INVALID_PARAMETER);
54
55 pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
56#endif
57 if (RT_UNLIKELY(!pReq))
58 return VERR_NO_MEMORY;
59
60 pReq->size = cb;
61 pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
62 pReq->requestType = enmReqType;
63 pReq->rc = VERR_GENERAL_FAILURE;
64 pReq->reserved1 = 0;
65 pReq->reserved2 = 0;
66
67 *ppReq = pReq;
68
69 return VINF_SUCCESS;
70}
71
72
73VBGLR3DECL(int) vbglR3GRPerform(VMMDevRequestHeader *pReq)
74{
75 return vbglR3DoIOCtl(VBOXGUEST_IOCTL_VMMREQUEST(pReq->size), pReq, pReq->size);
76}
77
78
79void vbglR3GRFree(VMMDevRequestHeader *pReq)
80{
81#ifdef VBOX_VBGLR3_XFREE86
82 xfree(pReq);
83#else
84 RTMemTmpFree(pReq);
85#endif
86}
87
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