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 | */
|
---|
29 | static DECLVBGL(void)
|
---|
30 | vboxadd_hgcm_callback (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
|
---|
31 | {
|
---|
32 | VBoxDevice *dev = pvData;
|
---|
33 | if (u32Data == RT_INDEFINITE_WAIT)
|
---|
34 | wait_event (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
|
---|
35 | else
|
---|
36 | wait_event_timeout (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE,
|
---|
37 | msecs_to_jiffies (u32Data));
|
---|
38 | }
|
---|
39 |
|
---|
40 | static DECLVBGL(void)
|
---|
41 | vboxadd_hgcm_callback_interruptible (VMMDevHGCMRequestHeader *pHeader, void *pvData, uint32_t u32Data)
|
---|
42 | {
|
---|
43 | VBoxDevice *dev = pvData;
|
---|
44 | if (u32Data == RT_INDEFINITE_WAIT)
|
---|
45 | wait_event_interruptible (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
|
---|
46 | else
|
---|
47 | wait_event_interruptible_timeout (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE,
|
---|
48 | msecs_to_jiffies (u32Data));
|
---|
49 | }
|
---|
50 |
|
---|
51 | DECLVBGL (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, RT_INDEFINITE_WAIT);
|
---|
59 | /* this function can handle cancelled requests */
|
---|
60 | else if ( VBOXGUEST_IOCTL_STRIP_SIZE(func)
|
---|
61 | == VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL_TIMED(0)))
|
---|
62 | {
|
---|
63 | VBoxGuestHGCMCallInfoTimed *pCallInfo;
|
---|
64 | pCallInfo = (VBoxGuestHGCMCallInfoTimed *) data;
|
---|
65 | if (pCallInfo->fInterruptible)
|
---|
66 | rc = VbglHGCMCall (&pCallInfo->info, vboxadd_hgcm_callback_interruptible,
|
---|
67 | opaque, pCallInfo->u32Timeout);
|
---|
68 | else
|
---|
69 | rc = VbglHGCMCall (&pCallInfo->info, vboxadd_hgcm_callback,
|
---|
70 | opaque, pCallInfo->u32Timeout);
|
---|
71 | }
|
---|
72 | else switch (func)
|
---|
73 | {
|
---|
74 | /* this function can NOT handle cancelled requests */
|
---|
75 | case VBOXGUEST_IOCTL_HGCM_CONNECT:
|
---|
76 | rc = VbglHGCMConnect (data, vboxadd_hgcm_callback, opaque, RT_INDEFINITE_WAIT);
|
---|
77 | break;
|
---|
78 |
|
---|
79 | /* this function can NOT handle cancelled requests */
|
---|
80 | case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
|
---|
81 | rc = VbglHGCMDisconnect (data, vboxadd_hgcm_callback, opaque, RT_INDEFINITE_WAIT);
|
---|
82 | break;
|
---|
83 |
|
---|
84 | default:
|
---|
85 | rc = VERR_VBGL_IOCTL_FAILED;
|
---|
86 | }
|
---|
87 | return rc;
|
---|
88 | }
|
---|
89 |
|
---|
90 | int vboxadd_cmc_init (void)
|
---|
91 | {
|
---|
92 | return 0;
|
---|
93 | }
|
---|
94 |
|
---|
95 | void vboxadd_cmc_fini (void)
|
---|
96 | {
|
---|
97 | }
|
---|
98 |
|
---|
99 | DECLVBGL (int)
|
---|
100 | vboxadd_cmc_ctl_guest_filter_mask (uint32_t or_mask, uint32_t not_mask)
|
---|
101 | {
|
---|
102 | int rc;
|
---|
103 | VMMDevCtlGuestFilterMask *req;
|
---|
104 |
|
---|
105 | rc = VbglGRAlloc ((VMMDevRequestHeader**) &req, sizeof (*req),
|
---|
106 | VMMDevReq_CtlGuestFilterMask);
|
---|
107 |
|
---|
108 | if (RT_FAILURE (rc))
|
---|
109 | {
|
---|
110 | elog ("VbglGRAlloc (CtlGuestFilterMask) failed rc=%d\n", rc);
|
---|
111 | return -1;
|
---|
112 | }
|
---|
113 |
|
---|
114 | req->u32OrMask = or_mask;
|
---|
115 | req->u32NotMask = not_mask;
|
---|
116 |
|
---|
117 | rc = VbglGRPerform (&req->header);
|
---|
118 | VbglGRFree (&req->header);
|
---|
119 | if (RT_FAILURE (rc))
|
---|
120 | {
|
---|
121 | elog ("VbglGRPerform (CtlGuestFilterMask) failed rc=%d\n", rc);
|
---|
122 | return -1;
|
---|
123 | }
|
---|
124 | return 0;
|
---|
125 | }
|
---|
126 |
|
---|
127 | EXPORT_SYMBOL (vboxadd_cmc_call);
|
---|
128 | EXPORT_SYMBOL (vboxadd_cmc_ctl_guest_filter_mask);
|
---|