VirtualBox

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

Last change on this file since 463 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 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 InnoTek Systemberatung 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 as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#include <VBox/VBoxGuestLib.h>
24#include "VBGLInternal.h"
25#include <iprt/asm.h>
26
27#if defined(__LINUX__) && defined(__KERNEL__)
28#include <linux/string.h>
29#else
30#include <string.h>
31#endif
32
33DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
34{
35 int rc = VbglEnter ();
36
37 if (VBOX_FAILURE(rc))
38 {
39 return rc;
40 }
41
42 if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
43 {
44 dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %d\n", ppReq, cbSize));
45 return VERR_INVALID_PARAMETER;
46 }
47
48 VMMDevRequestHeader *pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize);
49
50 if (!pReq)
51 {
52 dprintf(("VbglGRAlloc: no memory\n"));
53 rc = VERR_NO_MEMORY;
54 }
55 else
56 {
57 memset(pReq, 0xAA, cbSize);
58
59 pReq->size = cbSize;
60 pReq->version = VMMDEV_REQUEST_HEADER_VERSION;
61 pReq->requestType = reqType;
62 pReq->rc = VERR_GENERAL_FAILURE;
63 pReq->reserved1 = 0;
64 pReq->reserved2 = 0;
65
66 *ppReq = pReq;
67 }
68
69 return rc;
70}
71
72DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq)
73{
74 int rc = VbglEnter ();
75
76 if (VBOX_FAILURE(rc))
77 {
78 return rc;
79 }
80
81 if (!pReq)
82 {
83 return VERR_INVALID_PARAMETER;
84 }
85
86 if (g_vbgldata.portVMMDev == 0)
87 {
88 return VERR_VBGL_NOT_INITIALIZED;
89 }
90
91 RTCCPHYS physaddr = VbglPhysHeapGetPhysAddr (pReq);
92
93 if (!physaddr)
94 {
95 rc = VERR_VBGL_INVALID_ADDR;
96 }
97 else
98 {
99 ASMOutU32(g_vbgldata.portVMMDev + PORT_VMMDEV_REQUEST_OFFSET, (uint32_t)physaddr);
100
101 rc = pReq->rc;
102 }
103 return rc;
104}
105
106DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq)
107{
108 int rc = VbglEnter ();
109
110 if (VBOX_FAILURE(rc))
111 {
112 return;
113 }
114
115 VbglPhysHeapFree (pReq);
116}
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