1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "BIOSSettingsImpl.h"
|
---|
23 | #include "MachineImpl.h"
|
---|
24 | #include "Logging.h"
|
---|
25 | #include "GuestOSTypeImpl.h"
|
---|
26 |
|
---|
27 | #include <iprt/cpputils.h>
|
---|
28 | #include <VBox/settings.h>
|
---|
29 |
|
---|
30 | // constructor / destructor
|
---|
31 | /////////////////////////////////////////////////////////////////////////////
|
---|
32 |
|
---|
33 | HRESULT BIOSSettings::FinalConstruct()
|
---|
34 | {
|
---|
35 | return S_OK;
|
---|
36 | }
|
---|
37 |
|
---|
38 | void BIOSSettings::FinalRelease()
|
---|
39 | {
|
---|
40 | uninit ();
|
---|
41 | }
|
---|
42 |
|
---|
43 | // public initializer/uninitializer for internal purposes only
|
---|
44 | /////////////////////////////////////////////////////////////////////////////
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Initializes the audio adapter object.
|
---|
48 | *
|
---|
49 | * @returns COM result indicator
|
---|
50 | */
|
---|
51 | HRESULT BIOSSettings::init (Machine *aParent)
|
---|
52 | {
|
---|
53 | LogFlowThisFuncEnter();
|
---|
54 | LogFlowThisFunc (("aParent: %p\n", aParent));
|
---|
55 |
|
---|
56 | ComAssertRet (aParent, E_INVALIDARG);
|
---|
57 |
|
---|
58 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
59 | AutoInitSpan autoInitSpan (this);
|
---|
60 | AssertReturn (autoInitSpan.isOk(), E_FAIL);
|
---|
61 |
|
---|
62 | /* share the parent weakly */
|
---|
63 | unconst (mParent) = aParent;
|
---|
64 |
|
---|
65 | mData.allocate();
|
---|
66 |
|
---|
67 | autoInitSpan.setSucceeded();
|
---|
68 |
|
---|
69 | LogFlowThisFuncLeave();
|
---|
70 | return S_OK;
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Initializes the audio adapter object given another audio adapter object
|
---|
75 | * (a kind of copy constructor). This object shares data with
|
---|
76 | * the object passed as an argument.
|
---|
77 | *
|
---|
78 | * @note This object must be destroyed before the original object
|
---|
79 | * it shares data with is destroyed.
|
---|
80 | */
|
---|
81 | HRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
|
---|
82 | {
|
---|
83 | LogFlowThisFuncEnter();
|
---|
84 | LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
|
---|
85 |
|
---|
86 | ComAssertRet (aParent && that, E_INVALIDARG);
|
---|
87 |
|
---|
88 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
89 | AutoInitSpan autoInitSpan (this);
|
---|
90 | AssertReturn (autoInitSpan.isOk(), E_FAIL);
|
---|
91 |
|
---|
92 | mParent = aParent;
|
---|
93 | mPeer = that;
|
---|
94 |
|
---|
95 | AutoWriteLock thatlock (that);
|
---|
96 | mData.share (that->mData);
|
---|
97 |
|
---|
98 | autoInitSpan.setSucceeded();
|
---|
99 |
|
---|
100 | LogFlowThisFuncLeave();
|
---|
101 | return S_OK;
|
---|
102 | }
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Initializes the guest object given another guest object
|
---|
106 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
107 | * of the original object passed as an argument.
|
---|
108 | */
|
---|
109 | HRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
|
---|
110 | {
|
---|
111 | LogFlowThisFuncEnter();
|
---|
112 | LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
|
---|
113 |
|
---|
114 | ComAssertRet (aParent && that, E_INVALIDARG);
|
---|
115 |
|
---|
116 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
117 | AutoInitSpan autoInitSpan (this);
|
---|
118 | AssertReturn (autoInitSpan.isOk(), E_FAIL);
|
---|
119 |
|
---|
120 | mParent = aParent;
|
---|
121 | // mPeer is left null
|
---|
122 |
|
---|
123 | AutoWriteLock thatlock (that);
|
---|
124 | mData.attachCopy (that->mData);
|
---|
125 |
|
---|
126 | autoInitSpan.setSucceeded();
|
---|
127 |
|
---|
128 | LogFlowThisFuncLeave();
|
---|
129 | return S_OK;
|
---|
130 | }
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
134 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
135 | */
|
---|
136 | void BIOSSettings::uninit()
|
---|
137 | {
|
---|
138 | LogFlowThisFuncEnter();
|
---|
139 |
|
---|
140 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
141 | AutoUninitSpan autoUninitSpan (this);
|
---|
142 | if (autoUninitSpan.uninitDone())
|
---|
143 | return;
|
---|
144 |
|
---|
145 | mData.free();
|
---|
146 |
|
---|
147 | mPeer.setNull();
|
---|
148 | mParent.setNull();
|
---|
149 |
|
---|
150 | LogFlowThisFuncLeave();
|
---|
151 | }
|
---|
152 |
|
---|
153 | // IBIOSSettings properties
|
---|
154 | /////////////////////////////////////////////////////////////////////////////
|
---|
155 |
|
---|
156 | STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
|
---|
157 | {
|
---|
158 | if (!enabled)
|
---|
159 | return E_POINTER;
|
---|
160 |
|
---|
161 | AutoCaller autoCaller (this);
|
---|
162 | CheckComRCReturnRC (autoCaller.rc());
|
---|
163 |
|
---|
164 | AutoReadLock alock (this);
|
---|
165 |
|
---|
166 | *enabled = mData->mLogoFadeIn;
|
---|
167 |
|
---|
168 | return S_OK;
|
---|
169 | }
|
---|
170 |
|
---|
171 | STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
|
---|
172 | {
|
---|
173 | AutoCaller autoCaller (this);
|
---|
174 | CheckComRCReturnRC (autoCaller.rc());
|
---|
175 |
|
---|
176 | /* the machine needs to be mutable */
|
---|
177 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
178 | CheckComRCReturnRC (adep.rc());
|
---|
179 |
|
---|
180 | AutoWriteLock alock (this);
|
---|
181 |
|
---|
182 | mData.backup();
|
---|
183 | mData->mLogoFadeIn = enable;
|
---|
184 |
|
---|
185 | return S_OK;
|
---|
186 | }
|
---|
187 |
|
---|
188 | STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
|
---|
189 | {
|
---|
190 | if (!enabled)
|
---|
191 | return E_POINTER;
|
---|
192 |
|
---|
193 | AutoCaller autoCaller (this);
|
---|
194 | CheckComRCReturnRC (autoCaller.rc());
|
---|
195 |
|
---|
196 | AutoReadLock alock (this);
|
---|
197 |
|
---|
198 | *enabled = mData->mLogoFadeOut;
|
---|
199 |
|
---|
200 | return S_OK;
|
---|
201 | }
|
---|
202 |
|
---|
203 | STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
|
---|
204 | {
|
---|
205 | AutoCaller autoCaller (this);
|
---|
206 | CheckComRCReturnRC (autoCaller.rc());
|
---|
207 |
|
---|
208 | /* the machine needs to be mutable */
|
---|
209 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
210 | CheckComRCReturnRC (adep.rc());
|
---|
211 |
|
---|
212 | AutoWriteLock alock (this);
|
---|
213 |
|
---|
214 | mData.backup();
|
---|
215 | mData->mLogoFadeOut = enable;
|
---|
216 |
|
---|
217 | return S_OK;
|
---|
218 | }
|
---|
219 |
|
---|
220 | STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
|
---|
221 | {
|
---|
222 | if (!displayTime)
|
---|
223 | return E_POINTER;
|
---|
224 |
|
---|
225 | AutoCaller autoCaller (this);
|
---|
226 | CheckComRCReturnRC (autoCaller.rc());
|
---|
227 |
|
---|
228 | AutoReadLock alock (this);
|
---|
229 |
|
---|
230 | *displayTime = mData->mLogoDisplayTime;
|
---|
231 |
|
---|
232 | return S_OK;
|
---|
233 | }
|
---|
234 |
|
---|
235 | STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
|
---|
236 | {
|
---|
237 | AutoCaller autoCaller (this);
|
---|
238 | CheckComRCReturnRC (autoCaller.rc());
|
---|
239 |
|
---|
240 | /* the machine needs to be mutable */
|
---|
241 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
242 | CheckComRCReturnRC (adep.rc());
|
---|
243 |
|
---|
244 | AutoWriteLock alock (this);
|
---|
245 |
|
---|
246 | mData.backup();
|
---|
247 | mData->mLogoDisplayTime = displayTime;
|
---|
248 |
|
---|
249 | return S_OK;
|
---|
250 | }
|
---|
251 |
|
---|
252 | STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
|
---|
253 | {
|
---|
254 | if (!imagePath)
|
---|
255 | return E_POINTER;
|
---|
256 |
|
---|
257 | AutoCaller autoCaller (this);
|
---|
258 | CheckComRCReturnRC (autoCaller.rc());
|
---|
259 |
|
---|
260 | AutoReadLock alock (this);
|
---|
261 |
|
---|
262 | mData->mLogoImagePath.cloneTo(imagePath);
|
---|
263 | return S_OK;
|
---|
264 | }
|
---|
265 |
|
---|
266 | STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(IN_BSTR imagePath)
|
---|
267 | {
|
---|
268 | /* empty strings are not allowed as path names */
|
---|
269 | if (imagePath && !(*imagePath))
|
---|
270 | return E_INVALIDARG;
|
---|
271 |
|
---|
272 | AutoCaller autoCaller (this);
|
---|
273 | CheckComRCReturnRC (autoCaller.rc());
|
---|
274 |
|
---|
275 | /* the machine needs to be mutable */
|
---|
276 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
277 | CheckComRCReturnRC (adep.rc());
|
---|
278 |
|
---|
279 | AutoWriteLock alock (this);
|
---|
280 |
|
---|
281 | mData.backup();
|
---|
282 | mData->mLogoImagePath = imagePath;
|
---|
283 |
|
---|
284 | return S_OK;
|
---|
285 | }
|
---|
286 |
|
---|
287 | STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
|
---|
288 | {
|
---|
289 | if (!bootMenuMode)
|
---|
290 | return E_POINTER;
|
---|
291 |
|
---|
292 | AutoCaller autoCaller (this);
|
---|
293 | CheckComRCReturnRC (autoCaller.rc());
|
---|
294 |
|
---|
295 | AutoReadLock alock (this);
|
---|
296 |
|
---|
297 | *bootMenuMode = mData->mBootMenuMode;
|
---|
298 | return S_OK;
|
---|
299 | }
|
---|
300 |
|
---|
301 | STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
|
---|
302 | {
|
---|
303 | AutoCaller autoCaller (this);
|
---|
304 | CheckComRCReturnRC (autoCaller.rc());
|
---|
305 |
|
---|
306 | /* the machine needs to be mutable */
|
---|
307 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
308 | CheckComRCReturnRC (adep.rc());
|
---|
309 |
|
---|
310 | AutoWriteLock alock (this);
|
---|
311 |
|
---|
312 | mData.backup();
|
---|
313 | mData->mBootMenuMode = bootMenuMode;
|
---|
314 |
|
---|
315 | return S_OK;
|
---|
316 | }
|
---|
317 |
|
---|
318 | STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
|
---|
319 | {
|
---|
320 | if (!enabled)
|
---|
321 | return E_POINTER;
|
---|
322 |
|
---|
323 | AutoCaller autoCaller (this);
|
---|
324 | CheckComRCReturnRC (autoCaller.rc());
|
---|
325 |
|
---|
326 | AutoReadLock alock (this);
|
---|
327 |
|
---|
328 | *enabled = mData->mACPIEnabled;
|
---|
329 |
|
---|
330 | return S_OK;
|
---|
331 | }
|
---|
332 |
|
---|
333 | STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
|
---|
334 | {
|
---|
335 | AutoCaller autoCaller (this);
|
---|
336 | CheckComRCReturnRC (autoCaller.rc());
|
---|
337 |
|
---|
338 | /* the machine needs to be mutable */
|
---|
339 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
340 | CheckComRCReturnRC (adep.rc());
|
---|
341 |
|
---|
342 | AutoWriteLock alock (this);
|
---|
343 |
|
---|
344 | mData.backup();
|
---|
345 | mData->mACPIEnabled = enable;
|
---|
346 |
|
---|
347 | return S_OK;
|
---|
348 | }
|
---|
349 |
|
---|
350 | STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
|
---|
351 | {
|
---|
352 | if (!enabled)
|
---|
353 | return E_POINTER;
|
---|
354 |
|
---|
355 | AutoCaller autoCaller (this);
|
---|
356 | CheckComRCReturnRC (autoCaller.rc());
|
---|
357 |
|
---|
358 | AutoReadLock alock (this);
|
---|
359 |
|
---|
360 | *enabled = mData->mIOAPICEnabled;
|
---|
361 |
|
---|
362 | return S_OK;
|
---|
363 | }
|
---|
364 |
|
---|
365 | STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
|
---|
366 | {
|
---|
367 | AutoCaller autoCaller (this);
|
---|
368 | CheckComRCReturnRC (autoCaller.rc());
|
---|
369 |
|
---|
370 | /* the machine needs to be mutable */
|
---|
371 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
372 | CheckComRCReturnRC (adep.rc());
|
---|
373 |
|
---|
374 | AutoWriteLock alock (this);
|
---|
375 |
|
---|
376 | mData.backup();
|
---|
377 | mData->mIOAPICEnabled = enable;
|
---|
378 |
|
---|
379 | return S_OK;
|
---|
380 | }
|
---|
381 |
|
---|
382 | STDMETHODIMP BIOSSettings::COMGETTER(PXEDebugEnabled)(BOOL *enabled)
|
---|
383 | {
|
---|
384 | if (!enabled)
|
---|
385 | return E_POINTER;
|
---|
386 |
|
---|
387 | AutoCaller autoCaller (this);
|
---|
388 | CheckComRCReturnRC (autoCaller.rc());
|
---|
389 |
|
---|
390 | AutoReadLock alock (this);
|
---|
391 |
|
---|
392 | *enabled = mData->mPXEDebugEnabled;
|
---|
393 |
|
---|
394 | return S_OK;
|
---|
395 | }
|
---|
396 |
|
---|
397 | STDMETHODIMP BIOSSettings::COMSETTER(PXEDebugEnabled)(BOOL enable)
|
---|
398 | {
|
---|
399 | AutoCaller autoCaller (this);
|
---|
400 | CheckComRCReturnRC (autoCaller.rc());
|
---|
401 |
|
---|
402 | /* the machine needs to be mutable */
|
---|
403 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
404 | CheckComRCReturnRC (adep.rc());
|
---|
405 |
|
---|
406 | AutoWriteLock alock (this);
|
---|
407 |
|
---|
408 | mData.backup();
|
---|
409 | mData->mPXEDebugEnabled = enable;
|
---|
410 |
|
---|
411 | return S_OK;
|
---|
412 | }
|
---|
413 |
|
---|
414 | STDMETHODIMP BIOSSettings::COMGETTER(IDEControllerType)(IDEControllerType_T *aControllerType)
|
---|
415 | {
|
---|
416 | CheckComArgOutPointerValid(aControllerType);
|
---|
417 |
|
---|
418 | AutoCaller autoCaller (this);
|
---|
419 | CheckComRCReturnRC (autoCaller.rc());
|
---|
420 |
|
---|
421 | AutoReadLock alock (this);
|
---|
422 |
|
---|
423 | *aControllerType = mData->mIDEControllerType;
|
---|
424 |
|
---|
425 | return S_OK;
|
---|
426 | }
|
---|
427 |
|
---|
428 | STDMETHODIMP BIOSSettings::COMSETTER(IDEControllerType)(IDEControllerType_T aControllerType)
|
---|
429 | {
|
---|
430 | AutoCaller autoCaller (this);
|
---|
431 | CheckComRCReturnRC (autoCaller.rc());
|
---|
432 |
|
---|
433 | /* the machine needs to be mutable */
|
---|
434 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
435 | CheckComRCReturnRC (adep.rc());
|
---|
436 |
|
---|
437 | AutoWriteLock alock (this);
|
---|
438 |
|
---|
439 | /* make sure the value is allowed */
|
---|
440 | switch (aControllerType)
|
---|
441 | {
|
---|
442 | case IDEControllerType_PIIX3:
|
---|
443 | case IDEControllerType_PIIX4:
|
---|
444 | break;
|
---|
445 | default:
|
---|
446 | return setError (E_INVALIDARG,
|
---|
447 | tr("Invalid IDE controller type '%d'"),
|
---|
448 | aControllerType);
|
---|
449 | }
|
---|
450 |
|
---|
451 | mData.backup();
|
---|
452 |
|
---|
453 | mData->mIDEControllerType = aControllerType;
|
---|
454 |
|
---|
455 | return S_OK;
|
---|
456 | }
|
---|
457 |
|
---|
458 | STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
|
---|
459 | {
|
---|
460 | if (!offset)
|
---|
461 | return E_POINTER;
|
---|
462 |
|
---|
463 | AutoCaller autoCaller (this);
|
---|
464 | CheckComRCReturnRC (autoCaller.rc());
|
---|
465 |
|
---|
466 | AutoReadLock alock (this);
|
---|
467 |
|
---|
468 | *offset = mData->mTimeOffset;
|
---|
469 |
|
---|
470 | return S_OK;
|
---|
471 | }
|
---|
472 |
|
---|
473 | STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
|
---|
474 | {
|
---|
475 | AutoCaller autoCaller (this);
|
---|
476 | CheckComRCReturnRC (autoCaller.rc());
|
---|
477 |
|
---|
478 | /* the machine needs to be mutable */
|
---|
479 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
480 | CheckComRCReturnRC (adep.rc());
|
---|
481 |
|
---|
482 | AutoWriteLock alock (this);
|
---|
483 |
|
---|
484 | mData.backup();
|
---|
485 | mData->mTimeOffset = offset;
|
---|
486 |
|
---|
487 | return S_OK;
|
---|
488 | }
|
---|
489 |
|
---|
490 |
|
---|
491 | // IBIOSSettings methods
|
---|
492 | /////////////////////////////////////////////////////////////////////////////
|
---|
493 |
|
---|
494 | // public methods only for internal purposes
|
---|
495 | /////////////////////////////////////////////////////////////////////////////
|
---|
496 |
|
---|
497 | /**
|
---|
498 | * Loads settings from the given machine node.
|
---|
499 | * May be called once right after this object creation.
|
---|
500 | *
|
---|
501 | * @param aMachineNode <Machine> node.
|
---|
502 | *
|
---|
503 | * @note Locks this object for writing.
|
---|
504 | */
|
---|
505 | HRESULT BIOSSettings::loadSettings (const settings::Key &aMachineNode)
|
---|
506 | {
|
---|
507 | using namespace settings;
|
---|
508 |
|
---|
509 | AssertReturn (!aMachineNode.isNull(), E_FAIL);
|
---|
510 |
|
---|
511 | AutoCaller autoCaller (this);
|
---|
512 | AssertComRCReturnRC (autoCaller.rc());
|
---|
513 |
|
---|
514 | AutoWriteLock alock (this);
|
---|
515 |
|
---|
516 | /* Note: we assume that the default values for attributes of optional
|
---|
517 | * nodes are assigned in the Data::Data() constructor and don't do it
|
---|
518 | * here. It implies that this method may only be called after constructing
|
---|
519 | * a new BIOSSettings object while all its data fields are in the default
|
---|
520 | * values. Exceptions are fields whose creation time defaults don't match
|
---|
521 | * values that should be applied when these fields are not explicitly set
|
---|
522 | * in the settings file (for backwards compatibility reasons). This takes
|
---|
523 | * place when a setting of a newly created object must default to A while
|
---|
524 | * the same setting of an object loaded from the old settings file must
|
---|
525 | * default to B. */
|
---|
526 |
|
---|
527 | /* BIOS node (required) */
|
---|
528 | Key biosNode = aMachineNode.key ("BIOS");
|
---|
529 |
|
---|
530 | /* ACPI (required) */
|
---|
531 | {
|
---|
532 | Key acpiNode = biosNode.key ("ACPI");
|
---|
533 |
|
---|
534 | mData->mACPIEnabled = acpiNode.value <bool> ("enabled");
|
---|
535 | }
|
---|
536 |
|
---|
537 | /* IOAPIC (optional) */
|
---|
538 | {
|
---|
539 | Key ioapicNode = biosNode.findKey ("IOAPIC");
|
---|
540 | if (!ioapicNode.isNull())
|
---|
541 | mData->mIOAPICEnabled = ioapicNode.value <bool> ("enabled");
|
---|
542 | }
|
---|
543 |
|
---|
544 | /* Logo (optional) */
|
---|
545 | {
|
---|
546 | Key logoNode = biosNode.findKey ("Logo");
|
---|
547 | if (!logoNode.isNull())
|
---|
548 | {
|
---|
549 | mData->mLogoFadeIn = logoNode.value <bool> ("fadeIn");
|
---|
550 | mData->mLogoFadeOut = logoNode.value <bool> ("fadeOut");
|
---|
551 | mData->mLogoDisplayTime = logoNode.value <ULONG> ("displayTime");
|
---|
552 | mData->mLogoImagePath = logoNode.stringValue ("imagePath");
|
---|
553 | }
|
---|
554 | }
|
---|
555 |
|
---|
556 | /* boot menu (optional) */
|
---|
557 | {
|
---|
558 | Key bootMenuNode = biosNode.findKey ("BootMenu");
|
---|
559 | if (!bootMenuNode.isNull())
|
---|
560 | {
|
---|
561 | mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
|
---|
562 | const char *modeStr = bootMenuNode.stringValue ("mode");
|
---|
563 |
|
---|
564 | if (strcmp (modeStr, "Disabled") == 0)
|
---|
565 | mData->mBootMenuMode = BIOSBootMenuMode_Disabled;
|
---|
566 | else if (strcmp (modeStr, "MenuOnly") == 0)
|
---|
567 | mData->mBootMenuMode = BIOSBootMenuMode_MenuOnly;
|
---|
568 | else if (strcmp (modeStr, "MessageAndMenu") == 0)
|
---|
569 | mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
|
---|
570 | else
|
---|
571 | ComAssertMsgFailedRet (("Invalid boot menu mode '%s'", modeStr),
|
---|
572 | E_FAIL);
|
---|
573 | }
|
---|
574 | }
|
---|
575 |
|
---|
576 | /* PXE debug logging (optional) */
|
---|
577 | {
|
---|
578 | Key pxedebugNode = biosNode.findKey ("PXEDebug");
|
---|
579 | if (!pxedebugNode.isNull())
|
---|
580 | mData->mPXEDebugEnabled = pxedebugNode.value <bool> ("enabled");
|
---|
581 | }
|
---|
582 |
|
---|
583 | /* time offset (optional) */
|
---|
584 | {
|
---|
585 | Key timeOffsetNode = biosNode.findKey ("TimeOffset");
|
---|
586 | if (!timeOffsetNode.isNull())
|
---|
587 | mData->mTimeOffset = timeOffsetNode.value <LONG64> ("value");
|
---|
588 | }
|
---|
589 |
|
---|
590 | /* IDE controller type (optional, for old machines that lack this node,
|
---|
591 | * defaults to PIIX3) */
|
---|
592 | {
|
---|
593 | mData->mIDEControllerType = IDEControllerType_PIIX3;
|
---|
594 |
|
---|
595 | Key ideControllerNode = biosNode.findKey ("IDEController");
|
---|
596 | if (!ideControllerNode.isNull())
|
---|
597 | {
|
---|
598 | const char *typeStr = ideControllerNode.stringValue ("type");
|
---|
599 | if (strcmp (typeStr, "PIIX3") == 0)
|
---|
600 | mData->mIDEControllerType = IDEControllerType_PIIX3;
|
---|
601 | else if (strcmp (typeStr, "PIIX4") == 0)
|
---|
602 | mData->mIDEControllerType = IDEControllerType_PIIX4;
|
---|
603 | else
|
---|
604 | ComAssertMsgFailedRet (("Invalid boot menu mode '%s'", typeStr),
|
---|
605 | E_FAIL);
|
---|
606 | }
|
---|
607 | }
|
---|
608 |
|
---|
609 | return S_OK;
|
---|
610 | }
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * Saves settings to the given machine node.
|
---|
614 | *
|
---|
615 | * @param aMachineNode <Machine> node.
|
---|
616 | *
|
---|
617 | * @note Locks this object for reading.
|
---|
618 | */
|
---|
619 | HRESULT BIOSSettings::saveSettings (settings::Key &aMachineNode)
|
---|
620 | {
|
---|
621 | using namespace settings;
|
---|
622 |
|
---|
623 | AssertReturn (!aMachineNode.isNull(), E_FAIL);
|
---|
624 |
|
---|
625 | AutoCaller autoCaller (this);
|
---|
626 | AssertComRCReturnRC (autoCaller.rc());
|
---|
627 |
|
---|
628 | AutoReadLock alock (this);
|
---|
629 |
|
---|
630 | Key biosNode = aMachineNode.createKey ("BIOS");
|
---|
631 |
|
---|
632 | /* ACPI */
|
---|
633 | {
|
---|
634 | Key acpiNode = biosNode.createKey ("ACPI");
|
---|
635 | acpiNode.setValue <bool> ("enabled", !!mData->mACPIEnabled);
|
---|
636 | }
|
---|
637 |
|
---|
638 | /* IOAPIC */
|
---|
639 | {
|
---|
640 | Key ioapicNode = biosNode.createKey ("IOAPIC");
|
---|
641 | ioapicNode.setValue <bool> ("enabled", !!mData->mIOAPICEnabled);
|
---|
642 | }
|
---|
643 |
|
---|
644 | /* BIOS logo (optional) **/
|
---|
645 | {
|
---|
646 | Key logoNode = biosNode.createKey ("Logo");
|
---|
647 | logoNode.setValue <bool> ("fadeIn", !!mData->mLogoFadeIn);
|
---|
648 | logoNode.setValue <bool> ("fadeOut", !!mData->mLogoFadeOut);
|
---|
649 | logoNode.setValue <ULONG> ("displayTime", mData->mLogoDisplayTime);
|
---|
650 | logoNode.setValueOr <Bstr> ("imagePath", mData->mLogoImagePath, Bstr::Null);
|
---|
651 | }
|
---|
652 |
|
---|
653 | /* boot menu (optional) */
|
---|
654 | {
|
---|
655 | Key bootMenuNode = biosNode.createKey ("BootMenu");
|
---|
656 | const char *modeStr = NULL;
|
---|
657 | switch (mData->mBootMenuMode)
|
---|
658 | {
|
---|
659 | case BIOSBootMenuMode_Disabled:
|
---|
660 | modeStr = "Disabled";
|
---|
661 | break;
|
---|
662 | case BIOSBootMenuMode_MenuOnly:
|
---|
663 | modeStr = "MenuOnly";
|
---|
664 | break;
|
---|
665 | case BIOSBootMenuMode_MessageAndMenu:
|
---|
666 | modeStr = "MessageAndMenu";
|
---|
667 | break;
|
---|
668 | default:
|
---|
669 | ComAssertMsgFailedRet (("Invalid boot menu type: %d",
|
---|
670 | mData->mBootMenuMode),
|
---|
671 | E_FAIL);
|
---|
672 | }
|
---|
673 | bootMenuNode.setStringValue ("mode", modeStr);
|
---|
674 | }
|
---|
675 |
|
---|
676 | /* time offset (optional) */
|
---|
677 | {
|
---|
678 | Key timeOffsetNode = biosNode.createKey ("TimeOffset");
|
---|
679 | timeOffsetNode.setValue <LONG64> ("value", mData->mTimeOffset);
|
---|
680 | }
|
---|
681 |
|
---|
682 | /* PXE debug flag (optional) */
|
---|
683 | {
|
---|
684 | Key pxedebugNode = biosNode.createKey ("PXEDebug");
|
---|
685 | pxedebugNode.setValue <bool> ("enabled", !!mData->mPXEDebugEnabled);
|
---|
686 | }
|
---|
687 |
|
---|
688 | /* IDE controller type */
|
---|
689 | {
|
---|
690 | Key ideControllerNode = biosNode.createKey ("IDEController");
|
---|
691 | const char *ideControllerTypeStr = NULL;
|
---|
692 | switch (mData->mIDEControllerType)
|
---|
693 | {
|
---|
694 | case IDEControllerType_PIIX3:
|
---|
695 | ideControllerTypeStr = "PIIX3";
|
---|
696 | break;
|
---|
697 | case IDEControllerType_PIIX4:
|
---|
698 | ideControllerTypeStr = "PIIX4";
|
---|
699 | break;
|
---|
700 | default:
|
---|
701 | ComAssertMsgFailedRet (("Invalid IDE Controller type: %d",
|
---|
702 | mData->mIDEControllerType),
|
---|
703 | E_FAIL);
|
---|
704 | }
|
---|
705 | ideControllerNode.setStringValue ("type", ideControllerTypeStr);
|
---|
706 | }
|
---|
707 |
|
---|
708 | return S_OK;
|
---|
709 | }
|
---|
710 |
|
---|
711 | void BIOSSettings::commit()
|
---|
712 | {
|
---|
713 | /* sanity */
|
---|
714 | AutoCaller autoCaller (this);
|
---|
715 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
716 |
|
---|
717 | /* sanity too */
|
---|
718 | AutoCaller peerCaller (mPeer);
|
---|
719 | AssertComRCReturnVoid (peerCaller.rc());
|
---|
720 |
|
---|
721 | /* lock both for writing since we modify both (mPeer is "master" so locked
|
---|
722 | * first) */
|
---|
723 | AutoMultiWriteLock2 alock (mPeer, this);
|
---|
724 |
|
---|
725 | if (mData.isBackedUp())
|
---|
726 | {
|
---|
727 | mData.commit();
|
---|
728 | if (mPeer)
|
---|
729 | {
|
---|
730 | /* attach new data to the peer and reshare it */
|
---|
731 | AutoWriteLock peerlock (mPeer);
|
---|
732 | mPeer->mData.attach (mData);
|
---|
733 | }
|
---|
734 | }
|
---|
735 | }
|
---|
736 |
|
---|
737 | void BIOSSettings::copyFrom (BIOSSettings *aThat)
|
---|
738 | {
|
---|
739 | AssertReturnVoid (aThat != NULL);
|
---|
740 |
|
---|
741 | /* sanity */
|
---|
742 | AutoCaller autoCaller (this);
|
---|
743 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
744 |
|
---|
745 | /* sanity too */
|
---|
746 | AutoCaller thatCaller (aThat);
|
---|
747 | AssertComRCReturnVoid (thatCaller.rc());
|
---|
748 |
|
---|
749 | /* peer is not modified, lock it for reading (aThat is "master" so locked
|
---|
750 | * first) */
|
---|
751 | AutoMultiLock2 alock (aThat->rlock(), this->wlock());
|
---|
752 |
|
---|
753 | /* this will back up current data */
|
---|
754 | mData.assignCopy (aThat->mData);
|
---|
755 | }
|
---|
756 |
|
---|
757 | void BIOSSettings::applyDefaults (GuestOSType *aOsType)
|
---|
758 | {
|
---|
759 | AssertReturnVoid (aOsType != NULL);
|
---|
760 |
|
---|
761 | /* sanity */
|
---|
762 | AutoCaller autoCaller (this);
|
---|
763 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
764 |
|
---|
765 | AutoWriteLock alock (this);
|
---|
766 |
|
---|
767 | /* Initialize default BIOS settings here */
|
---|
768 | mData->mIOAPICEnabled = aOsType->recommendedIOAPIC();
|
---|
769 | }
|
---|
770 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|