VirtualBox

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

Last change on this file since 6290 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 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 innotek GmbH
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
19#include <VBox/VBoxGuestLib.h>
20#include "VBGLInternal.h"
21#include <iprt/asm.h>
22#include <iprt/string.h>
23#include <iprt/assert.h>
24
25DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
26{
27 VMMDevRequestHeader *pReq;
28 int rc = VbglEnter ();
29
30 if (VBOX_FAILURE(rc))
31 return rc;
32
33 if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
34 {
35 dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %d\n", ppReq, cbSize));
36 return VERR_INVALID_PARAMETER;
37 }
38
39 pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize);
40 if (!pReq)
41 {
42 AssertMsgFailed(("VbglGRAlloc: no memory\n"));
43 rc = VERR_NO_MEMORY;
44 }
45 else
46 {
47 memset(pReq, 0xAA, cbSize);
48
49 pReq->size = cbSize;
50 pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
51 pReq->requestType = reqType;
52 pReq->rc = VERR_GENERAL_FAILURE;
53 pReq->reserved1 = 0;
54 pReq->reserved2 = 0;
55
56 *ppReq = pReq;
57 }
58
59 return rc;
60}
61
62DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq)
63{
64 RTCCPHYS physaddr;
65 int rc = VbglEnter ();
66
67 if (VBOX_FAILURE(rc))
68 return rc;
69
70 if (!pReq)
71 return VERR_INVALID_PARAMETER;
72
73 physaddr = VbglPhysHeapGetPhysAddr (pReq);
74 if (!physaddr)
75 {
76 rc = VERR_VBGL_INVALID_ADDR;
77 }
78 else
79 {
80 ASMOutU32(g_vbgldata.portVMMDev + PORT_VMMDEV_REQUEST_OFFSET, (uint32_t)physaddr);
81 /* Make the compiler aware that the host has changed memory. */
82 ASMCompilerBarrier();
83 rc = pReq->rc;
84 }
85 return rc;
86}
87
88DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
89{
90 int rc = VbglEnter ();
91
92 if (VBOX_FAILURE(rc))
93 return;
94
95 VbglPhysHeapFree (pReq);
96}
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