VirtualBox

source: vbox/trunk/src/VBox/ExtPacks/BusMouseSample/VBoxBusMouseMain.cpp@ 68704

Last change on this file since 68704 was 63419, checked in by vboxsync, 8 years ago

BusMouseSample: warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/* $Id: VBoxBusMouseMain.cpp 63419 2016-08-13 17:04:36Z vboxsync $ */
2/** @file
3 * Bus Mouse main module.
4 */
5
6/*
7 * Copyright (C) 2010-2016 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{VBOXEXTPACKREG,pfnInstalled}
54// */
55// static DECLCALLBACK(void) vboxSkeletonExtPack_Installed(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
56// /**
57// * @interface_method_impl{VBOXEXTPACKREG,pfnUninstall}
58// */
59// static DECLCALLBACK(int) vboxSkeletonExtPack_Uninstall(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
60//
61// /**
62// * @interface_method_impl{VBOXEXTPACKREG,pfnVirtualBoxReady}
63// */
64// static DECLCALLBACK(void) vboxSkeletonExtPack_VirtualBoxReady(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
65//
66// /**
67// * @interface_method_impl{VBOXEXTPACKREG,pfnUnload}
68// */
69// static DECLCALLBACK(void) vboxSkeletonExtPack_Unload(PCVBOXEXTPACKREG pThis);
70// /**
71// * @interface_method_impl{VBOXEXTPACKREG,pfnVMCreated}
72// */
73// static DECLCALLBACK(int) vboxSkeletonExtPack_VMCreated(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, IMachine *pMachine);
74//
75
76/**
77 * @interface_method_impl{VBOXEXTPACKREG,pfnVMConfigureVMM
78 */
79static DECLCALLBACK(int) vboxBusMouseExtPack_VMConfigureVMM(PCVBOXEXTPACKREG pThis, IConsole *pConsole, PVM pVM)
80{
81 RT_NOREF(pThis, pConsole);
82
83 /*
84 * Find the bus mouse module and tell PDM to load it.
85 * ASSUME /PDM/Devices exists.
86 */
87 char szPath[RTPATH_MAX];
88 int rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseR3", NULL, VBOXEXTPACKMODKIND_R3, szPath, sizeof(szPath), NULL);
89 if (RT_FAILURE(rc))
90 return rc;
91
92 PCFGMNODE pCfgRoot = CFGMR3GetRoot(pVM);
93 AssertReturn(pCfgRoot, VERR_INTERNAL_ERROR_3);
94
95 PCFGMNODE pCfgDevices = CFGMR3GetChild(pCfgRoot, "PDM/Devices");
96 AssertReturn(pCfgDevices, VERR_INTERNAL_ERROR_3);
97
98 PCFGMNODE pCfgMine;
99 rc = CFGMR3InsertNode(pCfgDevices, "VBoxBusMouse", &pCfgMine);
100 AssertRCReturn(rc, rc);
101 rc = CFGMR3InsertString(pCfgMine, "Path", szPath);
102 AssertRCReturn(rc, rc);
103
104 /*
105 * Tell PDM where to find the R0 and RC modules for the bus mouse device.
106 */
107#ifdef VBOX_WITH_RAW_MODE
108 rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseRC", NULL, VBOXEXTPACKMODKIND_RC, szPath, sizeof(szPath), NULL);
109 AssertRCReturn(rc, rc);
110 RTPathStripFilename(szPath);
111 rc = CFGMR3InsertString(pCfgMine, "RCSearchPath", szPath);
112 AssertRCReturn(rc, rc);
113#endif
114
115 rc = g_pHlp->pfnFindModule(g_pHlp, "VBoxBusMouseR0", NULL, VBOXEXTPACKMODKIND_R0, szPath, sizeof(szPath), NULL);
116 AssertRCReturn(rc, rc);
117 RTPathStripFilename(szPath);
118 rc = CFGMR3InsertString(pCfgMine, "R0SearchPath", szPath);
119 AssertRCReturn(rc, rc);
120
121 return VINF_SUCCESS;
122}
123
124// /**
125// * @interface_method_impl{VBOXEXTPACKREG,pfnVMPowerOn}
126// */
127// static DECLCALLBACK(int) vboxSkeletonExtPack_VMPowerOn(PCVBOXEXTPACKREG pThis, IConsole *pConsole, PVM pVM);
128// /**
129// * @interface_method_impl{VBOXEXTPACKREG,pfnVMPowerOff}
130// */
131// static DECLCALLBACK(void) vboxSkeletonExtPack_VMPowerOff(PCVBOXEXTPACKREG pThis, IConsole *pConsole, PVM pVM);
132// /**
133// * @interface_method_impl{VBOXEXTPACKREG,pfnVMPowerOff}
134// */
135// static DECLCALLBACK(void) vboxSkeletonExtPack_QueryObject(PCVBOXEXTPACKREG pThis, PCRTUUID pObjectId);
136
137
138static const VBOXEXTPACKREG g_vboxBusMouseExtPackReg =
139{
140 VBOXEXTPACKREG_VERSION,
141 /* .uVBoxFullVersion = */ VBOX_FULL_VERSION,
142 /* .pfnInstalled = */ NULL,
143 /* .pfnUninstall = */ NULL,
144 /* .pfnVirtualBoxReady =*/ NULL,
145 /* .pfnConsoleReady = */ NULL,
146 /* .pfnUnload = */ NULL,
147 /* .pfnVMCreated = */ NULL,
148 /* .pfnVMConfigureVMM = */ vboxBusMouseExtPack_VMConfigureVMM,
149 /* .pfnVMPowerOn = */ NULL,
150 /* .pfnVMPowerOff = */ NULL,
151 /* .pfnQueryObject = */ NULL,
152 /* .pfnReserved1 = */ NULL,
153 /* .pfnReserved2 = */ NULL,
154 /* .pfnReserved3 = */ NULL,
155 /* .pfnReserved4 = */ NULL,
156 /* .pfnReserved5 = */ NULL,
157 /* .pfnReserved6 = */ NULL,
158 /* .u32Reserved7 = */ 0,
159 VBOXEXTPACKREG_VERSION
160};
161
162
163/** @callback_method_impl{FNVBOXEXTPACKREGISTER} */
164extern "C" DECLEXPORT(int) VBoxExtPackRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, PRTERRINFO pErrInfo)
165{
166 /*
167 * Check the VirtualBox version.
168 */
169 if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION))
170 return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
171 "Helper version mismatch - expected %#x got %#x",
172 VBOXEXTPACKHLP_VERSION, pHlp->u32Version);
173 if ( VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR
174 || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR)
175 return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
176 "VirtualBox version mismatch - expected %u.%u got %u.%u",
177 VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR,
178 VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion),
179 VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion));
180
181 /*
182 * We're good, save input and return the registration structure.
183 */
184 g_pHlp = pHlp;
185 *ppReg = &g_vboxBusMouseExtPackReg;
186
187 return VINF_SUCCESS;
188}
189
Note: See TracBrowser for help on using the repository browser.

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