1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include "BIOSSettingsImpl.h"
|
---|
19 | #include "MachineImpl.h"
|
---|
20 | #include "Logging.h"
|
---|
21 | #include <iprt/cpputils.h>
|
---|
22 |
|
---|
23 | // constructor / destructor
|
---|
24 | /////////////////////////////////////////////////////////////////////////////
|
---|
25 |
|
---|
26 | HRESULT BIOSSettings::FinalConstruct()
|
---|
27 | {
|
---|
28 | return S_OK;
|
---|
29 | }
|
---|
30 |
|
---|
31 | void BIOSSettings::FinalRelease()
|
---|
32 | {
|
---|
33 | uninit ();
|
---|
34 | }
|
---|
35 |
|
---|
36 | // public initializer/uninitializer for internal purposes only
|
---|
37 | /////////////////////////////////////////////////////////////////////////////
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Initializes the audio adapter object.
|
---|
41 | *
|
---|
42 | * @returns COM result indicator
|
---|
43 | */
|
---|
44 | HRESULT BIOSSettings::init (Machine *aParent)
|
---|
45 | {
|
---|
46 | LogFlowThisFuncEnter();
|
---|
47 | LogFlowThisFunc (("aParent: %p\n", aParent));
|
---|
48 |
|
---|
49 | ComAssertRet (aParent, E_INVALIDARG);
|
---|
50 |
|
---|
51 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
52 | AutoInitSpan autoInitSpan (this);
|
---|
53 | AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
|
---|
54 |
|
---|
55 | /* share the parent weakly */
|
---|
56 | unconst (mParent) = aParent;
|
---|
57 |
|
---|
58 | mData.allocate();
|
---|
59 |
|
---|
60 | autoInitSpan.setSucceeded();
|
---|
61 |
|
---|
62 | LogFlowThisFuncLeave();
|
---|
63 | return S_OK;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Initializes the audio adapter object given another audio adapter object
|
---|
68 | * (a kind of copy constructor). This object shares data with
|
---|
69 | * the object passed as an argument.
|
---|
70 | *
|
---|
71 | * @note This object must be destroyed before the original object
|
---|
72 | * it shares data with is destroyed.
|
---|
73 | */
|
---|
74 | HRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
|
---|
75 | {
|
---|
76 | LogFlowThisFuncEnter();
|
---|
77 | LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
|
---|
78 |
|
---|
79 | ComAssertRet (aParent && that, E_INVALIDARG);
|
---|
80 |
|
---|
81 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
82 | AutoInitSpan autoInitSpan (this);
|
---|
83 | AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
|
---|
84 |
|
---|
85 | mParent = aParent;
|
---|
86 | mPeer = that;
|
---|
87 |
|
---|
88 | AutoLock thatlock (that);
|
---|
89 | mData.share (that->mData);
|
---|
90 |
|
---|
91 | autoInitSpan.setSucceeded();
|
---|
92 |
|
---|
93 | LogFlowThisFuncLeave();
|
---|
94 | return S_OK;
|
---|
95 | }
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Initializes the guest object given another guest object
|
---|
99 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
100 | * of the original object passed as an argument.
|
---|
101 | */
|
---|
102 | HRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
|
---|
103 | {
|
---|
104 | LogFlowThisFuncEnter();
|
---|
105 | LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
|
---|
106 |
|
---|
107 | ComAssertRet (aParent && that, E_INVALIDARG);
|
---|
108 |
|
---|
109 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
110 | AutoInitSpan autoInitSpan (this);
|
---|
111 | AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
|
---|
112 |
|
---|
113 | mParent = aParent;
|
---|
114 | // mPeer is left null
|
---|
115 |
|
---|
116 | AutoLock thatlock (that);
|
---|
117 | mData.attachCopy (that->mData);
|
---|
118 |
|
---|
119 | autoInitSpan.setSucceeded();
|
---|
120 |
|
---|
121 | LogFlowThisFuncLeave();
|
---|
122 | return S_OK;
|
---|
123 | }
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
127 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
128 | */
|
---|
129 | void BIOSSettings::uninit()
|
---|
130 | {
|
---|
131 | LogFlowThisFuncEnter();
|
---|
132 |
|
---|
133 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
134 | AutoUninitSpan autoUninitSpan (this);
|
---|
135 | if (autoUninitSpan.uninitDone())
|
---|
136 | return;
|
---|
137 |
|
---|
138 | mData.free();
|
---|
139 |
|
---|
140 | mPeer.setNull();
|
---|
141 | mParent.setNull();
|
---|
142 |
|
---|
143 | LogFlowThisFuncLeave();
|
---|
144 | }
|
---|
145 |
|
---|
146 | // IBIOSSettings properties
|
---|
147 | /////////////////////////////////////////////////////////////////////////////
|
---|
148 |
|
---|
149 | STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
|
---|
150 | {
|
---|
151 | if (!enabled)
|
---|
152 | return E_POINTER;
|
---|
153 |
|
---|
154 | AutoCaller autoCaller (this);
|
---|
155 | CheckComRCReturnRC (autoCaller.rc());
|
---|
156 |
|
---|
157 | AutoReaderLock alock (this);
|
---|
158 |
|
---|
159 | *enabled = mData->mLogoFadeIn;
|
---|
160 |
|
---|
161 | return S_OK;
|
---|
162 | }
|
---|
163 |
|
---|
164 | STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
|
---|
165 | {
|
---|
166 | AutoCaller autoCaller (this);
|
---|
167 | CheckComRCReturnRC (autoCaller.rc());
|
---|
168 |
|
---|
169 | /* the machine needs to be mutable */
|
---|
170 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
171 | CheckComRCReturnRC (adep.rc());
|
---|
172 |
|
---|
173 | AutoLock alock (this);
|
---|
174 |
|
---|
175 | mData.backup();
|
---|
176 | mData->mLogoFadeIn = enable;
|
---|
177 |
|
---|
178 | return S_OK;
|
---|
179 | }
|
---|
180 |
|
---|
181 | STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
|
---|
182 | {
|
---|
183 | if (!enabled)
|
---|
184 | return E_POINTER;
|
---|
185 |
|
---|
186 | AutoCaller autoCaller (this);
|
---|
187 | CheckComRCReturnRC (autoCaller.rc());
|
---|
188 |
|
---|
189 | AutoReaderLock alock (this);
|
---|
190 |
|
---|
191 | *enabled = mData->mLogoFadeOut;
|
---|
192 |
|
---|
193 | return S_OK;
|
---|
194 | }
|
---|
195 |
|
---|
196 | STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
|
---|
197 | {
|
---|
198 | AutoCaller autoCaller (this);
|
---|
199 | CheckComRCReturnRC (autoCaller.rc());
|
---|
200 |
|
---|
201 | /* the machine needs to be mutable */
|
---|
202 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
203 | CheckComRCReturnRC (adep.rc());
|
---|
204 |
|
---|
205 | AutoLock alock (this);
|
---|
206 |
|
---|
207 | mData.backup();
|
---|
208 | mData->mLogoFadeOut = enable;
|
---|
209 |
|
---|
210 | return S_OK;
|
---|
211 | }
|
---|
212 |
|
---|
213 | STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
|
---|
214 | {
|
---|
215 | if (!displayTime)
|
---|
216 | return E_POINTER;
|
---|
217 |
|
---|
218 | AutoCaller autoCaller (this);
|
---|
219 | CheckComRCReturnRC (autoCaller.rc());
|
---|
220 |
|
---|
221 | AutoReaderLock alock (this);
|
---|
222 |
|
---|
223 | *displayTime = mData->mLogoDisplayTime;
|
---|
224 |
|
---|
225 | return S_OK;
|
---|
226 | }
|
---|
227 |
|
---|
228 | STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
|
---|
229 | {
|
---|
230 | AutoCaller autoCaller (this);
|
---|
231 | CheckComRCReturnRC (autoCaller.rc());
|
---|
232 |
|
---|
233 | /* the machine needs to be mutable */
|
---|
234 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
235 | CheckComRCReturnRC (adep.rc());
|
---|
236 |
|
---|
237 | AutoLock alock (this);
|
---|
238 |
|
---|
239 | mData.backup();
|
---|
240 | mData->mLogoDisplayTime = displayTime;
|
---|
241 |
|
---|
242 | return S_OK;
|
---|
243 | }
|
---|
244 |
|
---|
245 | STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
|
---|
246 | {
|
---|
247 | if (!imagePath)
|
---|
248 | return E_POINTER;
|
---|
249 |
|
---|
250 | AutoCaller autoCaller (this);
|
---|
251 | CheckComRCReturnRC (autoCaller.rc());
|
---|
252 |
|
---|
253 | AutoReaderLock alock (this);
|
---|
254 |
|
---|
255 | mData->mLogoImagePath.cloneTo(imagePath);
|
---|
256 | return S_OK;
|
---|
257 | }
|
---|
258 |
|
---|
259 | STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(INPTR BSTR imagePath)
|
---|
260 | {
|
---|
261 | /* empty strings are not allowed as path names */
|
---|
262 | if (imagePath && !(*imagePath))
|
---|
263 | return E_INVALIDARG;
|
---|
264 |
|
---|
265 | AutoCaller autoCaller (this);
|
---|
266 | CheckComRCReturnRC (autoCaller.rc());
|
---|
267 |
|
---|
268 | /* the machine needs to be mutable */
|
---|
269 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
270 | CheckComRCReturnRC (adep.rc());
|
---|
271 |
|
---|
272 | AutoLock alock (this);
|
---|
273 |
|
---|
274 | mData.backup();
|
---|
275 | mData->mLogoImagePath = imagePath;
|
---|
276 |
|
---|
277 | return S_OK;
|
---|
278 | }
|
---|
279 |
|
---|
280 | STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
|
---|
281 | {
|
---|
282 | if (!bootMenuMode)
|
---|
283 | return E_POINTER;
|
---|
284 |
|
---|
285 | AutoCaller autoCaller (this);
|
---|
286 | CheckComRCReturnRC (autoCaller.rc());
|
---|
287 |
|
---|
288 | AutoReaderLock alock (this);
|
---|
289 |
|
---|
290 | *bootMenuMode = mData->mBootMenuMode;
|
---|
291 | return S_OK;
|
---|
292 | }
|
---|
293 |
|
---|
294 | STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
|
---|
295 | {
|
---|
296 | AutoCaller autoCaller (this);
|
---|
297 | CheckComRCReturnRC (autoCaller.rc());
|
---|
298 |
|
---|
299 | /* the machine needs to be mutable */
|
---|
300 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
301 | CheckComRCReturnRC (adep.rc());
|
---|
302 |
|
---|
303 | AutoLock alock (this);
|
---|
304 |
|
---|
305 | mData.backup();
|
---|
306 | mData->mBootMenuMode = bootMenuMode;
|
---|
307 |
|
---|
308 | return S_OK;
|
---|
309 | }
|
---|
310 |
|
---|
311 | STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
|
---|
312 | {
|
---|
313 | if (!enabled)
|
---|
314 | return E_POINTER;
|
---|
315 |
|
---|
316 | AutoCaller autoCaller (this);
|
---|
317 | CheckComRCReturnRC (autoCaller.rc());
|
---|
318 |
|
---|
319 | AutoReaderLock alock (this);
|
---|
320 |
|
---|
321 | *enabled = mData->mACPIEnabled;
|
---|
322 |
|
---|
323 | return S_OK;
|
---|
324 | }
|
---|
325 |
|
---|
326 | STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
|
---|
327 | {
|
---|
328 | AutoCaller autoCaller (this);
|
---|
329 | CheckComRCReturnRC (autoCaller.rc());
|
---|
330 |
|
---|
331 | /* the machine needs to be mutable */
|
---|
332 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
333 | CheckComRCReturnRC (adep.rc());
|
---|
334 |
|
---|
335 | AutoLock alock (this);
|
---|
336 |
|
---|
337 | mData.backup();
|
---|
338 | mData->mACPIEnabled = enable;
|
---|
339 |
|
---|
340 | return S_OK;
|
---|
341 | }
|
---|
342 |
|
---|
343 | STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
|
---|
344 | {
|
---|
345 | if (!enabled)
|
---|
346 | return E_POINTER;
|
---|
347 |
|
---|
348 | AutoCaller autoCaller (this);
|
---|
349 | CheckComRCReturnRC (autoCaller.rc());
|
---|
350 |
|
---|
351 | AutoReaderLock alock (this);
|
---|
352 |
|
---|
353 | *enabled = mData->mIOAPICEnabled;
|
---|
354 |
|
---|
355 | return S_OK;
|
---|
356 | }
|
---|
357 |
|
---|
358 | STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
|
---|
359 | {
|
---|
360 | AutoCaller autoCaller (this);
|
---|
361 | CheckComRCReturnRC (autoCaller.rc());
|
---|
362 |
|
---|
363 | /* the machine needs to be mutable */
|
---|
364 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
365 | CheckComRCReturnRC (adep.rc());
|
---|
366 |
|
---|
367 | AutoLock alock (this);
|
---|
368 |
|
---|
369 | mData.backup();
|
---|
370 | mData->mIOAPICEnabled = enable;
|
---|
371 |
|
---|
372 | return S_OK;
|
---|
373 | }
|
---|
374 |
|
---|
375 | STDMETHODIMP BIOSSettings::COMGETTER(PXEDebugEnabled)(BOOL *enabled)
|
---|
376 | {
|
---|
377 | if (!enabled)
|
---|
378 | return E_POINTER;
|
---|
379 |
|
---|
380 | AutoCaller autoCaller (this);
|
---|
381 | CheckComRCReturnRC (autoCaller.rc());
|
---|
382 |
|
---|
383 | AutoReaderLock alock (this);
|
---|
384 |
|
---|
385 | *enabled = mData->mPXEDebugEnabled;
|
---|
386 |
|
---|
387 | return S_OK;
|
---|
388 | }
|
---|
389 |
|
---|
390 | STDMETHODIMP BIOSSettings::COMSETTER(PXEDebugEnabled)(BOOL enable)
|
---|
391 | {
|
---|
392 | AutoCaller autoCaller (this);
|
---|
393 | CheckComRCReturnRC (autoCaller.rc());
|
---|
394 |
|
---|
395 | /* the machine needs to be mutable */
|
---|
396 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
397 | CheckComRCReturnRC (adep.rc());
|
---|
398 |
|
---|
399 | AutoLock alock (this);
|
---|
400 |
|
---|
401 | mData.backup();
|
---|
402 | mData->mPXEDebugEnabled = enable;
|
---|
403 |
|
---|
404 | return S_OK;
|
---|
405 | }
|
---|
406 |
|
---|
407 | STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
|
---|
408 | {
|
---|
409 | if (!offset)
|
---|
410 | return E_POINTER;
|
---|
411 |
|
---|
412 | AutoCaller autoCaller (this);
|
---|
413 | CheckComRCReturnRC (autoCaller.rc());
|
---|
414 |
|
---|
415 | AutoReaderLock alock (this);
|
---|
416 |
|
---|
417 | *offset = mData->mTimeOffset;
|
---|
418 |
|
---|
419 | return S_OK;
|
---|
420 | }
|
---|
421 |
|
---|
422 | STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
|
---|
423 | {
|
---|
424 | AutoCaller autoCaller (this);
|
---|
425 | CheckComRCReturnRC (autoCaller.rc());
|
---|
426 |
|
---|
427 | /* the machine needs to be mutable */
|
---|
428 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
429 | CheckComRCReturnRC (adep.rc());
|
---|
430 |
|
---|
431 | AutoLock alock (this);
|
---|
432 |
|
---|
433 | mData.backup();
|
---|
434 | mData->mTimeOffset = offset;
|
---|
435 |
|
---|
436 | return S_OK;
|
---|
437 | }
|
---|
438 |
|
---|
439 |
|
---|
440 | // IBIOSSettings methods
|
---|
441 | /////////////////////////////////////////////////////////////////////////////
|
---|
442 |
|
---|
443 | // public methods only for internal purposes
|
---|
444 | /////////////////////////////////////////////////////////////////////////////
|
---|
445 |
|
---|
446 | void BIOSSettings::commit()
|
---|
447 | {
|
---|
448 | AutoLock alock (this);
|
---|
449 | if (mData.isBackedUp())
|
---|
450 | {
|
---|
451 | mData.commit();
|
---|
452 | if (mPeer)
|
---|
453 | {
|
---|
454 | // attach new data to the peer and reshare it
|
---|
455 | AutoLock peerlock (mPeer);
|
---|
456 | mPeer->mData.attach (mData);
|
---|
457 | }
|
---|
458 | }
|
---|
459 | }
|
---|
460 |
|
---|
461 | void BIOSSettings::copyFrom (BIOSSettings *aThat)
|
---|
462 | {
|
---|
463 | AutoLock alock (this);
|
---|
464 |
|
---|
465 | // this will back up current data
|
---|
466 | mData.assignCopy (aThat->mData);
|
---|
467 | }
|
---|
468 |
|
---|