VirtualBox

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

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

Additions/linux: fix the kernel module on Linux 2.4

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 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#include "waitcompat.h"
24
25/**
26 * HGCM
27 *
28 */
29static DECLVBGL(void)
30vboxadd_hgcm_callback (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
31{
32 VBoxDevice *dev = pvData;
33 wait_event (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
34}
35
36static DECLVBGL(void)
37vboxadd_hgcm_callback_interruptible (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
38{
39 VBoxDevice *dev = pvData;
40 wait_event_interruptible (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
41}
42
43static DECLVBGL(void)
44vboxadd_hgcm_callback_timeout (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
45{
46 VBoxDevice *dev = pvData;
47 wait_event_interruptible_timeout (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE,
48 msecs_to_jiffies (u32Data));
49}
50
51DECLVBGL (int) vboxadd_cmc_call (void *opaque, uint32_t func, void *data)
52{
53 int rc = VINF_SUCCESS;
54
55 /* this function can handle cancelled requests */
56 if ( VBOXGUEST_IOCTL_STRIP_SIZE(func)
57 == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL(0)))
58 rc = VbglHGCMCall (data, vboxadd_hgcm_callback_interruptible, opaque, 0);
59 /* this function can handle cancelled requests */
60 else if ( VBOXGUEST_IOCTL_STRIP_SIZE(func)
61 == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMEOUT(0)))
62 {
63 VBoxGuestHGCMCallInfoTimeout *pCallInfo;
64 pCallInfo = (VBoxGuestHGCMCallInfoTimeout *) data;
65 rc = VbglHGCMCall (&pCallInfo->info, vboxadd_hgcm_callback_timeout,
66 opaque, pCallInfo->u32Timeout);
67 }
68 else switch (func)
69 {
70 /* this function can NOT handle cancelled requests */
71 case VBOXGUEST_IOCTL_HGCM_CONNECT:
72 rc = VbglHGCMConnect (data, vboxadd_hgcm_callback, opaque, 0);
73 break;
74
75 /* this function can NOT handle cancelled requests */
76 case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
77 rc = VbglHGCMDisconnect (data, vboxadd_hgcm_callback, opaque, 0);
78 break;
79
80 default:
81 rc = VERR_VBGL_IOCTL_FAILED;
82 }
83 return rc;
84}
85
86int vboxadd_cmc_init (void)
87{
88 return 0;
89}
90
91void vboxadd_cmc_fini (void)
92{
93}
94
95DECLVBGL (int)
96vboxadd_cmc_ctl_guest_filter_mask (uint32_t or_mask, uint32_t not_mask)
97{
98 int rc;
99 VMMDevCtlGuestFilterMask *req;
100
101 rc = VbglGRAlloc ((VMMDevRequestHeader**) &req, sizeof (*req),
102 VMMDevReq_CtlGuestFilterMask);
103
104 if (RT_FAILURE (rc))
105 {
106 elog ("VbglGRAlloc (CtlGuestFilterMask) failed rc=%d\n", rc);
107 return -1;
108 }
109
110 req->u32OrMask = or_mask;
111 req->u32NotMask = not_mask;
112
113 rc = VbglGRPerform (&req->header);
114 VbglGRFree (&req->header);
115 if (RT_FAILURE (rc))
116 {
117 elog ("VbglGRPerform (CtlGuestFilterMask) failed rc=%d\n", rc);
118 return -1;
119 }
120 return 0;
121}
122
123EXPORT_SYMBOL (vboxadd_cmc_call);
124EXPORT_SYMBOL (vboxadd_cmc_ctl_guest_filter_mask);
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