VirtualBox

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

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

s/VBOX_SUCCESS/RT_SUCCESS/g s/VBOX_FAILURE/RT_FAILURE/g - VBOX_SUCCESS and VBOX_FAILURE have *NOT* been retired (because old habbits die hard) just sligtly deprecated.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/** @file
2 *
3 * VBoxGuestLib - A support library for VirtualBox guest additions:
4 * Generic VMMDev request management
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#include <VBox/VBoxGuestLib.h>
24#include "VBGLInternal.h"
25#include <iprt/asm.h>
26#include <iprt/string.h>
27#include <iprt/assert.h>
28
29DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
30{
31 VMMDevRequestHeader *pReq;
32 int rc = VbglEnter ();
33
34 if (RT_FAILURE(rc))
35 return rc;
36
37 if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
38 {
39 dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %d\n", ppReq, cbSize));
40 return VERR_INVALID_PARAMETER;
41 }
42
43 pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize);
44 if (!pReq)
45 {
46 AssertMsgFailed(("VbglGRAlloc: no memory\n"));
47 rc = VERR_NO_MEMORY;
48 }
49 else
50 {
51 memset(pReq, 0xAA, cbSize);
52
53 pReq->size = cbSize;
54 pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
55 pReq->requestType = reqType;
56 pReq->rc = VERR_GENERAL_FAILURE;
57 pReq->reserved1 = 0;
58 pReq->reserved2 = 0;
59
60 *ppReq = pReq;
61 }
62
63 return rc;
64}
65
66DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq)
67{
68 RTCCPHYS physaddr;
69 int rc = VbglEnter ();
70
71 if (RT_FAILURE(rc))
72 return rc;
73
74 if (!pReq)
75 return VERR_INVALID_PARAMETER;
76
77 physaddr = VbglPhysHeapGetPhysAddr (pReq);
78 if ( !physaddr
79 || (physaddr >> 32) != 0) /* Port IO is 32 bit. */
80 {
81 rc = VERR_VBGL_INVALID_ADDR;
82 }
83 else
84 {
85 ASMOutU32(g_vbgldata.portVMMDev + PORT_VMMDEV_REQUEST_OFFSET, (uint32_t)physaddr);
86 /* Make the compiler aware that the host has changed memory. */
87 ASMCompilerBarrier();
88 rc = pReq->rc;
89 }
90 return rc;
91}
92
93DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
94{
95 int rc = VbglEnter ();
96
97 if (RT_FAILURE(rc))
98 return;
99
100 VbglPhysHeapFree (pReq);
101}
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