1 | /* $Id: VBoxBusMouseMainVM.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Bus Mouse main VM module.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person
|
---|
10 | * obtaining a copy of this software and associated documentation
|
---|
11 | * files (the "Software"), to deal in the Software without
|
---|
12 | * restriction, including without limitation the rights to use,
|
---|
13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
14 | * copies of the Software, and to permit persons to whom the
|
---|
15 | * Software is furnished to do so, subject to the following
|
---|
16 | * conditions:
|
---|
17 | *
|
---|
18 | * The above copyright notice and this permission notice shall be
|
---|
19 | * included in all copies or substantial portions of the Software.
|
---|
20 | *
|
---|
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
29 | */
|
---|
30 |
|
---|
31 |
|
---|
32 | /*********************************************************************************************************************************
|
---|
33 | * Header Files *
|
---|
34 | *********************************************************************************************************************************/
|
---|
35 | #include <VBox/ExtPack/ExtPack.h>
|
---|
36 |
|
---|
37 | #include <VBox/err.h>
|
---|
38 | #include <VBox/version.h>
|
---|
39 | #include <VBox/vmm/vmmr3vtable.h>
|
---|
40 | #include <iprt/string.h>
|
---|
41 | #include <iprt/param.h>
|
---|
42 | #include <iprt/path.h>
|
---|
43 |
|
---|
44 |
|
---|
45 | /*********************************************************************************************************************************
|
---|
46 | * Global Variables *
|
---|
47 | *********************************************************************************************************************************/
|
---|
48 | /** Pointer to the extension pack helpers. */
|
---|
49 | static PCVBOXEXTPACKHLP g_pHlp;
|
---|
50 |
|
---|
51 |
|
---|
52 | // /**
|
---|
53 | // * @interface_method_impl{VBOXEXTPACKVMREG,pfnConsoleReady}
|
---|
54 | // */
|
---|
55 | // static DECLCALLBACK(void) vboxBusMouseExtPackVM_ConsoleReady(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole);
|
---|
56 | //
|
---|
57 | // /**
|
---|
58 | // * @interface_method_impl{VBOXEXTPACKVMREG,pfnUnload}
|
---|
59 | // */
|
---|
60 | // static DECLCALLBACK(void) vboxBusMouseExtPackVM_Unload(PCVBOXEXTPACKVMREG pThis);
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * @interface_method_impl{VBOXEXTPACKVMREG,pfnVMConfigureVMM
|
---|
64 | */
|
---|
65 | static DECLCALLBACK(int) vboxBusMouseExtPackVM_VMConfigureVMM(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole,
|
---|
66 | PVM pVM, PCVMMR3VTABLE pVMM)
|
---|
67 | {
|
---|
68 | RT_NOREF(pThis, pConsole);
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * Find the bus mouse module and tell PDM to load it.
|
---|
72 | * ASSUME /PDM/Devices exists.
|
---|
73 | */
|
---|
74 | char szPath[RTPATH_MAX];
|
---|
75 | int rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseR3", NULL, VBOXEXTPACKMODKIND_R3, szPath, sizeof(szPath), NULL);
|
---|
76 | if (RT_FAILURE(rc))
|
---|
77 | return rc;
|
---|
78 |
|
---|
79 | PCFGMNODE pCfgRoot = pVMM->pfnCFGMR3GetRoot(pVM);
|
---|
80 | AssertReturn(pCfgRoot, VERR_INTERNAL_ERROR_3);
|
---|
81 |
|
---|
82 | PCFGMNODE pCfgDevices = pVMM->pfnCFGMR3GetChild(pCfgRoot, "PDM/Devices");
|
---|
83 | AssertReturn(pCfgDevices, VERR_INTERNAL_ERROR_3);
|
---|
84 |
|
---|
85 | PCFGMNODE pCfgMine;
|
---|
86 | rc = pVMM->pfnCFGMR3InsertNode(pCfgDevices, "VBoxBusMouse", &pCfgMine);
|
---|
87 | AssertRCReturn(rc, rc);
|
---|
88 | rc = pVMM->pfnCFGMR3InsertString(pCfgMine, "Path", szPath);
|
---|
89 | AssertRCReturn(rc, rc);
|
---|
90 |
|
---|
91 | /*
|
---|
92 | * Tell PDM where to find the R0 and RC modules for the bus mouse device.
|
---|
93 | */
|
---|
94 | #ifdef VBOX_WITH_RAW_MODE
|
---|
95 | rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseRC", NULL, VBOXEXTPACKMODKIND_RC, szPath, sizeof(szPath), NULL);
|
---|
96 | AssertRCReturn(rc, rc);
|
---|
97 | RTPathStripFilename(szPath);
|
---|
98 | rc = pVMM->pfnCFGMR3InsertString(pCfgMine, "RCSearchPath", szPath);
|
---|
99 | AssertRCReturn(rc, rc);
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseR0", NULL, VBOXEXTPACKMODKIND_R0, szPath, sizeof(szPath), NULL);
|
---|
103 | AssertRCReturn(rc, rc);
|
---|
104 | RTPathStripFilename(szPath);
|
---|
105 | rc = pVMM->pfnCFGMR3InsertString(pCfgMine, "R0SearchPath", szPath);
|
---|
106 | AssertRCReturn(rc, rc);
|
---|
107 |
|
---|
108 | return VINF_SUCCESS;
|
---|
109 | }
|
---|
110 |
|
---|
111 | // /**
|
---|
112 | // * @interface_method_impl{VBOXEXTPACKVMREG,pfnVMPowerOn}
|
---|
113 | // */
|
---|
114 | // static DECLCALLBACK(int) vboxBusMouseExtPackVM_VMPowerOn(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole, PVM pVM);
|
---|
115 | //
|
---|
116 | // /**
|
---|
117 | // * @interface_method_impl{VBOXEXTPACKVMREG,pfnVMPowerOff}
|
---|
118 | // */
|
---|
119 | // static DECLCALLBACK(void) vboxBusMouseExtPackVM_VMPowerOff(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole, PVM pVM);
|
---|
120 | //
|
---|
121 | // /**
|
---|
122 | // * @interface_method_impl{VBOXEXTPACKVMREG,pfnQueryObject}
|
---|
123 | // */
|
---|
124 | // static DECLCALLBACK(void) vboxBusMouseExtPackVM_QueryObject(PCVBOXEXTPACKVMREG pThis, PCRTUUID pObjectId);
|
---|
125 |
|
---|
126 |
|
---|
127 | static const VBOXEXTPACKVMREG g_vboxBusMouseExtPackVMReg =
|
---|
128 | {
|
---|
129 | VBOXEXTPACKVMREG_VERSION,
|
---|
130 | /* .uVBoxFullVersion = */ VBOX_FULL_VERSION,
|
---|
131 | /* .pszNlsBaseName = */ NULL,
|
---|
132 | /* .pfnConsoleReady = */ NULL,
|
---|
133 | /* .pfnUnload = */ NULL,
|
---|
134 | /* .pfnVMConfigureVMM = */ vboxBusMouseExtPackVM_VMConfigureVMM,
|
---|
135 | /* .pfnVMPowerOn = */ NULL,
|
---|
136 | /* .pfnVMPowerOff = */ NULL,
|
---|
137 | /* .pfnQueryObject = */ NULL,
|
---|
138 | /* .pfnReserved1 = */ NULL,
|
---|
139 | /* .pfnReserved2 = */ NULL,
|
---|
140 | /* .pfnReserved3 = */ NULL,
|
---|
141 | /* .pfnReserved4 = */ NULL,
|
---|
142 | /* .pfnReserved5 = */ NULL,
|
---|
143 | /* .pfnReserved6 = */ NULL,
|
---|
144 | /* .uReserved7 = */ 0,
|
---|
145 | VBOXEXTPACKVMREG_VERSION
|
---|
146 | };
|
---|
147 |
|
---|
148 |
|
---|
149 | /** @callback_method_impl{FNVBOXEXTPACKVMREGISTER} */
|
---|
150 | extern "C" DECLEXPORT(int) VBoxExtPackVMRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKVMREG *ppReg, PRTERRINFO pErrInfo)
|
---|
151 | {
|
---|
152 | /*
|
---|
153 | * Check the VirtualBox version.
|
---|
154 | */
|
---|
155 | if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION))
|
---|
156 | return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
|
---|
157 | "Helper version mismatch - expected %#x got %#x",
|
---|
158 | VBOXEXTPACKHLP_VERSION, pHlp->u32Version);
|
---|
159 | if ( VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR
|
---|
160 | || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR)
|
---|
161 | return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
|
---|
162 | "VirtualBox version mismatch - expected %u.%u got %u.%u",
|
---|
163 | VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR,
|
---|
164 | VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion),
|
---|
165 | VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion));
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * We're good, save input and return the registration structure.
|
---|
169 | */
|
---|
170 | g_pHlp = pHlp;
|
---|
171 | *ppReg = &g_vboxBusMouseExtPackVMReg;
|
---|
172 |
|
---|
173 | return VINF_SUCCESS;
|
---|
174 | }
|
---|
175 |
|
---|