VirtualBox

source: vbox/trunk/src/VBox/ExtPacks/BusMouseSample/VBoxBusMouseMainVM.cpp@ 68828

最後變更 在這個檔案從68828是 68828,由 vboxsync 提交於 7 年 前

ExtPack: Split up main module of extension pack, have a mandatory one for VBoxSVC and an optional one for the VM process. This finally eliminates the need to drag VBoxVMM into VBoxSVC on some platforms. Many other small cleanups, including reliably calling the unload hook from within a VM process, copy/paste with forgotten adjustments (e.g. extpacks still talking about skeleton) and spelling fixes.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.7 KB
 
1/* $Id: VBoxBusMouseMainVM.cpp 68828 2017-09-22 14:15:57Z vboxsync $ */
2/** @file
3 * Bus Mouse main VM module.
4 */
5
6/*
7 * Copyright (C) 2010-2017 Oracle Corporation
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/cfgm.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. */
49static 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 */
65static DECLCALLBACK(int) vboxBusMouseExtPackVM_VMConfigureVMM(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole, PVM pVM)
66{
67 RT_NOREF(pThis, pConsole);
68
69 /*
70 * Find the bus mouse module and tell PDM to load it.
71 * ASSUME /PDM/Devices exists.
72 */
73 char szPath[RTPATH_MAX];
74 int rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseR3", NULL, VBOXEXTPACKMODKIND_R3, szPath, sizeof(szPath), NULL);
75 if (RT_FAILURE(rc))
76 return rc;
77
78 PCFGMNODE pCfgRoot = CFGMR3GetRoot(pVM);
79 AssertReturn(pCfgRoot, VERR_INTERNAL_ERROR_3);
80
81 PCFGMNODE pCfgDevices = CFGMR3GetChild(pCfgRoot, "PDM/Devices");
82 AssertReturn(pCfgDevices, VERR_INTERNAL_ERROR_3);
83
84 PCFGMNODE pCfgMine;
85 rc = CFGMR3InsertNode(pCfgDevices, "VBoxBusMouse", &pCfgMine);
86 AssertRCReturn(rc, rc);
87 rc = CFGMR3InsertString(pCfgMine, "Path", szPath);
88 AssertRCReturn(rc, rc);
89
90 /*
91 * Tell PDM where to find the R0 and RC modules for the bus mouse device.
92 */
93#ifdef VBOX_WITH_RAW_MODE
94 rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseRC", NULL, VBOXEXTPACKMODKIND_RC, szPath, sizeof(szPath), NULL);
95 AssertRCReturn(rc, rc);
96 RTPathStripFilename(szPath);
97 rc = CFGMR3InsertString(pCfgMine, "RCSearchPath", szPath);
98 AssertRCReturn(rc, rc);
99#endif
100
101 rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseR0", NULL, VBOXEXTPACKMODKIND_R0, szPath, sizeof(szPath), NULL);
102 AssertRCReturn(rc, rc);
103 RTPathStripFilename(szPath);
104 rc = CFGMR3InsertString(pCfgMine, "R0SearchPath", szPath);
105 AssertRCReturn(rc, rc);
106
107 return VINF_SUCCESS;
108}
109
110// /**
111// * @interface_method_impl{VBOXEXTPACKVMREG,pfnVMPowerOn}
112// */
113// static DECLCALLBACK(int) vboxBusMouseExtPackVM_VMPowerOn(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole, PVM pVM);
114//
115// /**
116// * @interface_method_impl{VBOXEXTPACKVMREG,pfnVMPowerOff}
117// */
118// static DECLCALLBACK(void) vboxBusMouseExtPackVM_VMPowerOff(PCVBOXEXTPACKVMREG pThis, VBOXEXTPACK_IF_CS(IConsole) *pConsole, PVM pVM);
119//
120// /**
121// * @interface_method_impl{VBOXEXTPACKVMREG,pfnQueryObject}
122// */
123// static DECLCALLBACK(void) vboxBusMouseExtPackVM_QueryObject(PCVBOXEXTPACKVMREG pThis, PCRTUUID pObjectId);
124
125
126static const VBOXEXTPACKVMREG g_vboxBusMouseExtPackVMReg =
127{
128 VBOXEXTPACKVMREG_VERSION,
129 /* .uVBoxFullVersion = */ VBOX_FULL_VERSION,
130 /* .pfnConsoleReady = */ NULL,
131 /* .pfnUnload = */ NULL,
132 /* .pfnVMConfigureVMM = */ vboxBusMouseExtPackVM_VMConfigureVMM,
133 /* .pfnVMPowerOn = */ NULL,
134 /* .pfnVMPowerOff = */ NULL,
135 /* .pfnQueryObject = */ NULL,
136 /* .pfnReserved1 = */ NULL,
137 /* .pfnReserved2 = */ NULL,
138 /* .pfnReserved3 = */ NULL,
139 /* .pfnReserved4 = */ NULL,
140 /* .pfnReserved5 = */ NULL,
141 /* .pfnReserved6 = */ NULL,
142 /* .u32Reserved7 = */ 0,
143 VBOXEXTPACKVMREG_VERSION
144};
145
146
147/** @callback_method_impl{FNVBOXEXTPACKVMREGISTER} */
148extern "C" DECLEXPORT(int) VBoxExtPackVMRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKVMREG *ppReg, PRTERRINFO pErrInfo)
149{
150 /*
151 * Check the VirtualBox version.
152 */
153 if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION))
154 return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
155 "Helper version mismatch - expected %#x got %#x",
156 VBOXEXTPACKHLP_VERSION, pHlp->u32Version);
157 if ( VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR
158 || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR)
159 return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
160 "VirtualBox version mismatch - expected %u.%u got %u.%u",
161 VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR,
162 VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion),
163 VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion));
164
165 /*
166 * We're good, save input and return the registration structure.
167 */
168 g_pHlp = pHlp;
169 *ppReg = &g_vboxBusMouseExtPackVMReg;
170
171 return VINF_SUCCESS;
172}
173
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette