VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/module/cmc.c@ 14218

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

Additions/Linux: remove Linux-specific guest R0 HGCM hack and add VBOXGUEST_IOCTL_CALL_TIMEOUT support for Linux

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/** @file
2 *
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
17 * Clara, CA 95054 USA or visit http://www.sun.com if you need
18 * additional information or have any questions.
19 */
20
21#include "the-linux-kernel.h"
22#include "vboxmod.h"
23
24/**
25 * HGCM
26 *
27 */
28static DECLVBGL(void)
29vboxadd_hgcm_callback (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
30{
31 VBoxDevice *dev = pvData;
32 wait_event (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
33}
34
35static DECLVBGL(void)
36vboxadd_hgcm_callback_interruptible (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
37{
38 VBoxDevice *dev = pvData;
39 wait_event_interruptible (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
40}
41
42static DECLVBGL(void)
43vboxadd_hgcm_callback_timeout (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
44{
45 VBoxDevice *dev = pvData;
46 wait_event_interruptible_timeout (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE,
47 msecs_to_jiffies (u32Data));
48}
49
50DECLVBGL (int) vboxadd_cmc_call (void *opaque, uint32_t func, void *data)
51{
52 int rc = VINF_SUCCESS;
53
54 /* this function can handle cancelled requests */
55 if ( VBOXGUEST_IOCTL_STRIP_SIZE(func)
56 == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL(0)))
57 rc = VbglHGCMCall (data, vboxadd_hgcm_callback_interruptible, opaque, 0);
58 /* this function can handle cancelled requests */
59 else if ( VBOXGUEST_IOCTL_STRIP_SIZE(func)
60 == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMEOUT(0)))
61 {
62 VBoxGuestHGCMCallInfoTimeout *pCallInfo;
63 pCallInfo = (VBoxGuestHGCMCallInfoTimeout *) data;
64 rc = VbglHGCMCall (&pCallInfo->info, vboxadd_hgcm_callback_timeout,
65 opaque, pCallInfo->u32Timeout);
66 }
67 else switch (func)
68 {
69 /* this function can NOT handle cancelled requests */
70 case VBOXGUEST_IOCTL_HGCM_CONNECT:
71 rc = VbglHGCMConnect (data, vboxadd_hgcm_callback, opaque, 0);
72 break;
73
74 /* this function can NOT handle cancelled requests */
75 case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
76 rc = VbglHGCMDisconnect (data, vboxadd_hgcm_callback, opaque, 0);
77 break;
78
79 default:
80 rc = VERR_VBGL_IOCTL_FAILED;
81 }
82 return rc;
83}
84
85int vboxadd_cmc_init (void)
86{
87 return 0;
88}
89
90void vboxadd_cmc_fini (void)
91{
92}
93
94DECLVBGL (int)
95vboxadd_cmc_ctl_guest_filter_mask (uint32_t or_mask, uint32_t not_mask)
96{
97 int rc;
98 VMMDevCtlGuestFilterMask *req;
99
100 rc = VbglGRAlloc ((VMMDevRequestHeader**) &req, sizeof (*req),
101 VMMDevReq_CtlGuestFilterMask);
102
103 if (RT_FAILURE (rc))
104 {
105 elog ("VbglGRAlloc (CtlGuestFilterMask) failed rc=%d\n", rc);
106 return -1;
107 }
108
109 req->u32OrMask = or_mask;
110 req->u32NotMask = not_mask;
111
112 rc = VbglGRPerform (&req->header);
113 VbglGRFree (&req->header);
114 if (RT_FAILURE (rc))
115 {
116 elog ("VbglGRPerform (CtlGuestFilterMask) failed rc=%d\n", rc);
117 return -1;
118 }
119 return 0;
120}
121
122EXPORT_SYMBOL (vboxadd_cmc_call);
123EXPORT_SYMBOL (vboxadd_cmc_ctl_guest_filter_mask);
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