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 | */
|
---|
28 | static DECLVBGL(void)
|
---|
29 | vboxadd_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 |
|
---|
35 | static DECLVBGL(void)
|
---|
36 | vboxadd_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 |
|
---|
42 | DECLVBGL (int) vboxadd_cmc_call (void *opaque, uint32_t func, void *data)
|
---|
43 | {
|
---|
44 | switch (func)
|
---|
45 | {
|
---|
46 | /* this function can NOT handle cancelled requests */
|
---|
47 | case VBOXGUEST_IOCTL_HGCM_CONNECT:
|
---|
48 | return VbglHGCMConnect (data, vboxadd_hgcm_callback, opaque, 0);
|
---|
49 |
|
---|
50 | /* this function can NOT handle cancelled requests */
|
---|
51 | case VBOXGUEST_IOCTL_HGCM_DISCONNECT:
|
---|
52 | return VbglHGCMDisconnect (data, vboxadd_hgcm_callback, opaque, 0);
|
---|
53 |
|
---|
54 | /* this function can handle cancelled requests */
|
---|
55 | default:
|
---|
56 | if (VBOXGUEST_IOCTL_STRIP_SIZE(func) != VBOXGUEST_IOCTL_STRIP_SIZE(VBOXGUEST_IOCTL_HGCM_CALL(0)))
|
---|
57 | return VERR_VBGL_IOCTL_FAILED;
|
---|
58 | /* fall thru */
|
---|
59 | case VBOXGUEST_IOCTL_STRIP_SIZE (VBOXGUEST_IOCTL_HGCM_CALL (0)):
|
---|
60 | return VbglHGCMCall (data, vboxadd_hgcm_callback_interruptible, opaque, 0);
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | int vboxadd_cmc_init (void)
|
---|
65 | {
|
---|
66 | return 0;
|
---|
67 | }
|
---|
68 |
|
---|
69 | void vboxadd_cmc_fini (void)
|
---|
70 | {
|
---|
71 | }
|
---|
72 |
|
---|
73 | DECLVBGL (int)
|
---|
74 | vboxadd_cmc_ctl_guest_filter_mask (uint32_t or_mask, uint32_t not_mask)
|
---|
75 | {
|
---|
76 | int rc;
|
---|
77 | VMMDevCtlGuestFilterMask *req;
|
---|
78 |
|
---|
79 | rc = VbglGRAlloc ((VMMDevRequestHeader**) &req, sizeof (*req),
|
---|
80 | VMMDevReq_CtlGuestFilterMask);
|
---|
81 |
|
---|
82 | if (VBOX_FAILURE (rc))
|
---|
83 | {
|
---|
84 | elog ("VbglGRAlloc (CtlGuestFilterMask) failed rc=%d\n", rc);
|
---|
85 | return -1;
|
---|
86 | }
|
---|
87 |
|
---|
88 | req->u32OrMask = or_mask;
|
---|
89 | req->u32NotMask = not_mask;
|
---|
90 |
|
---|
91 | rc = VbglGRPerform (&req->header);
|
---|
92 | VbglGRFree (&req->header);
|
---|
93 | if (VBOX_FAILURE (rc))
|
---|
94 | {
|
---|
95 | elog ("VbglGRPerform (CtlGuestFilterMask) failed rc=%d\n", rc);
|
---|
96 | return -1;
|
---|
97 | }
|
---|
98 | return 0;
|
---|
99 | }
|
---|
100 |
|
---|
101 | EXPORT_SYMBOL (vboxadd_cmc_call);
|
---|
102 | EXPORT_SYMBOL (vboxadd_cmc_ctl_guest_filter_mask);
|
---|