1 | /** @file
|
---|
2 | *
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #if 0
|
---|
22 | #ifndef bool /* Linux 2.6.19 C++ nightmare */
|
---|
23 | #define bool bool_type
|
---|
24 | #define true true_type
|
---|
25 | #define false false_type
|
---|
26 | #define _Bool int
|
---|
27 | #define bool_cmc_c
|
---|
28 | #endif
|
---|
29 | #include <linux/autoconf.h>
|
---|
30 | #include <linux/version.h>
|
---|
31 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
|
---|
32 | # undef ALIGN
|
---|
33 | #endif
|
---|
34 | #ifndef KBUILD_STR
|
---|
35 | # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
|
---|
36 | # define KBUILD_STR(s) s
|
---|
37 | # else
|
---|
38 | # define KBUILD_STR(s) #s
|
---|
39 | # endif
|
---|
40 | #endif
|
---|
41 | /* Make (at least) RHEL3U5 happy. */
|
---|
42 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
|
---|
43 | // # define EXPORT_SYMTAB
|
---|
44 | #endif
|
---|
45 | #include <linux/module.h>
|
---|
46 | #include <linux/kernel.h>
|
---|
47 | #include <linux/fs.h>
|
---|
48 | #include <linux/mm.h>
|
---|
49 | #include <linux/wait.h>
|
---|
50 | #include <linux/pci.h>
|
---|
51 | #include <linux/delay.h>
|
---|
52 | #include <linux/interrupt.h>
|
---|
53 | #include <linux/completion.h>
|
---|
54 | #include <asm/uaccess.h>
|
---|
55 | #ifdef bool_cmc_c
|
---|
56 | #undef bool
|
---|
57 | #undef true
|
---|
58 | #undef false
|
---|
59 | #undef _Bool
|
---|
60 | #undef bool_cmc_c
|
---|
61 | #endif
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #include "the-linux-kernel.h"
|
---|
65 |
|
---|
66 | // What is this for?
|
---|
67 | // bird: see comment on the other #undef.
|
---|
68 | #undef ALIGN
|
---|
69 | #include "vboxmod.h"
|
---|
70 | /* #include "waitcompat.h" */
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * HGCM
|
---|
74 | *
|
---|
75 | */
|
---|
76 | static DECLVBGL(void)
|
---|
77 | vboxadd_hgcm_callback (
|
---|
78 | VMMDevHGCMRequestHeader *pHeader,
|
---|
79 | void *pvData,
|
---|
80 | uint32_t u32Data
|
---|
81 | )
|
---|
82 | {
|
---|
83 | VBoxDevice *dev = pvData;
|
---|
84 |
|
---|
85 | wait_event (dev->eventq, pHeader->fu32Flags & VBOX_HGCM_REQ_DONE);
|
---|
86 | }
|
---|
87 |
|
---|
88 | static int vboxadd_hgcm_connect (
|
---|
89 | VBoxDevice *dev,
|
---|
90 | VBoxGuestHGCMConnectInfo *info
|
---|
91 | )
|
---|
92 | {
|
---|
93 | int rc = VbglHGCMConnect (info, vboxadd_hgcm_callback, dev, 0);
|
---|
94 | return rc;
|
---|
95 | }
|
---|
96 |
|
---|
97 | static int vboxadd_hgcm_disconnect (
|
---|
98 | VBoxDevice *dev,
|
---|
99 | VBoxGuestHGCMDisconnectInfo *info
|
---|
100 | )
|
---|
101 | {
|
---|
102 | int rc = VbglHGCMDisconnect (info, vboxadd_hgcm_callback, dev, 0);
|
---|
103 | return rc;
|
---|
104 | }
|
---|
105 |
|
---|
106 | static int vboxadd_hgcm_call (
|
---|
107 | VBoxDevice *dev,
|
---|
108 | VBoxGuestHGCMCallInfo *info
|
---|
109 | )
|
---|
110 | {
|
---|
111 | int rc = VbglHGCMCall (info, vboxadd_hgcm_callback, dev, 0);
|
---|
112 | return rc;
|
---|
113 | }
|
---|
114 |
|
---|
115 | DECLVBGL (int) vboxadd_cmc_call (void *opaque, uint32_t func, void *data)
|
---|
116 | {
|
---|
117 | switch (func)
|
---|
118 | {
|
---|
119 | case IOCTL_VBOXGUEST_HGCM_CONNECT:
|
---|
120 | return vboxadd_hgcm_connect (opaque, data);
|
---|
121 |
|
---|
122 | case IOCTL_VBOXGUEST_HGCM_DISCONNECT:
|
---|
123 | return vboxadd_hgcm_disconnect (opaque, data);
|
---|
124 |
|
---|
125 | case IOCTL_VBOXGUEST_HGCM_CALL:
|
---|
126 | return vboxadd_hgcm_call (opaque, data);
|
---|
127 |
|
---|
128 | default:
|
---|
129 | return VERR_VBGL_IOCTL_FAILED;
|
---|
130 | }
|
---|
131 | }
|
---|
132 |
|
---|
133 | int vboxadd_cmc_init (void)
|
---|
134 | {
|
---|
135 | return 0;
|
---|
136 | }
|
---|
137 |
|
---|
138 | void vboxadd_cmc_fini (void)
|
---|
139 | {
|
---|
140 | }
|
---|
141 |
|
---|
142 | DECLVBGL (int)
|
---|
143 | vboxadd_cmc_ctl_guest_filter_mask (uint32_t or_mask, uint32_t not_mask)
|
---|
144 | {
|
---|
145 | int rc;
|
---|
146 | VMMDevCtlGuestFilterMask *req;
|
---|
147 |
|
---|
148 | rc = VbglGRAlloc ((VMMDevRequestHeader**) &req, sizeof (*req),
|
---|
149 | VMMDevReq_CtlGuestFilterMask);
|
---|
150 |
|
---|
151 | if (VBOX_FAILURE (rc)) {
|
---|
152 | elog ("VbglGRAlloc (CtlGuestFilterMask) failed rc=%d\n", rc);
|
---|
153 | return -1;
|
---|
154 | }
|
---|
155 |
|
---|
156 | req->u32OrMask = or_mask;
|
---|
157 | req->u32NotMask = not_mask;
|
---|
158 |
|
---|
159 | rc = VbglGRPerform (&req->header);
|
---|
160 | VbglGRFree (&req->header);
|
---|
161 | if (VBOX_FAILURE (rc)) {
|
---|
162 | elog ("VbglGRPerform (CtlGuestFilterMask) failed rc=%d\n", rc);
|
---|
163 | return -1;
|
---|
164 | }
|
---|
165 | return 0;
|
---|
166 | }
|
---|
167 |
|
---|
168 | EXPORT_SYMBOL (vboxadd_cmc_call);
|
---|
169 | EXPORT_SYMBOL (vboxadd_cmc_ctl_guest_filter_mask);
|
---|