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 | case IDEControllerType_ICH6:
|
---|
445 | break;
|
---|
446 | default:
|
---|
447 | return setError (E_INVALIDARG,
|
---|
448 | tr("Invalid IDE controller type '%d'"),
|
---|
449 | aControllerType);
|
---|
450 | }
|
---|
451 |
|
---|
452 | mData.backup();
|
---|
453 |
|
---|
454 | mData->mIDEControllerType = aControllerType;
|
---|
455 |
|
---|
456 | return S_OK;
|
---|
457 | }
|
---|
458 |
|
---|
459 | STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
|
---|
460 | {
|
---|
461 | if (!offset)
|
---|
462 | return E_POINTER;
|
---|
463 |
|
---|
464 | AutoCaller autoCaller (this);
|
---|
465 | CheckComRCReturnRC (autoCaller.rc());
|
---|
466 |
|
---|
467 | AutoReadLock alock (this);
|
---|
468 |
|
---|
469 | *offset = mData->mTimeOffset;
|
---|
470 |
|
---|
471 | return S_OK;
|
---|
472 | }
|
---|
473 |
|
---|
474 | STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
|
---|
475 | {
|
---|
476 | AutoCaller autoCaller (this);
|
---|
477 | CheckComRCReturnRC (autoCaller.rc());
|
---|
478 |
|
---|
479 | /* the machine needs to be mutable */
|
---|
480 | Machine::AutoMutableStateDependency adep (mParent);
|
---|
481 | CheckComRCReturnRC (adep.rc());
|
---|
482 |
|
---|
483 | AutoWriteLock alock (this);
|
---|
484 |
|
---|
485 | mData.backup();
|
---|
486 | mData->mTimeOffset = offset;
|
---|
487 |
|
---|
488 | return S_OK;
|
---|
489 | }
|
---|
490 |
|
---|
491 |
|
---|
492 | // IBIOSSettings methods
|
---|
493 | /////////////////////////////////////////////////////////////////////////////
|
---|
494 |
|
---|
495 | // public methods only for internal purposes
|
---|
496 | /////////////////////////////////////////////////////////////////////////////
|
---|
497 |
|
---|
498 | /**
|
---|
499 | * Loads settings from the given machine node.
|
---|
500 | * May be called once right after this object creation.
|
---|
501 | *
|
---|
502 | * @param aMachineNode <Machine> node.
|
---|
503 | *
|
---|
504 | * @note Locks this object for writing.
|
---|
505 | */
|
---|
506 | HRESULT BIOSSettings::loadSettings (const settings::Key &aMachineNode)
|
---|
507 | {
|
---|
508 | using namespace settings;
|
---|
509 |
|
---|
510 | AssertReturn (!aMachineNode.isNull(), E_FAIL);
|
---|
511 |
|
---|
512 | AutoCaller autoCaller (this);
|
---|
513 | AssertComRCReturnRC (autoCaller.rc());
|
---|
514 |
|
---|
515 | AutoWriteLock alock (this);
|
---|
516 |
|
---|
517 | /* Note: we assume that the default values for attributes of optional
|
---|
518 | * nodes are assigned in the Data::Data() constructor and don't do it
|
---|
519 | * here. It implies that this method may only be called after constructing
|
---|
520 | * a new BIOSSettings object while all its data fields are in the default
|
---|
521 | * values. Exceptions are fields whose creation time defaults don't match
|
---|
522 | * values that should be applied when these fields are not explicitly set
|
---|
523 | * in the settings file (for backwards compatibility reasons). This takes
|
---|
524 | * place when a setting of a newly created object must default to A while
|
---|
525 | * the same setting of an object loaded from the old settings file must
|
---|
526 | * default to B. */
|
---|
527 |
|
---|
528 | /* BIOS node (required) */
|
---|
529 | Key biosNode = aMachineNode.key ("BIOS");
|
---|
530 |
|
---|
531 | /* ACPI (required) */
|
---|
532 | {
|
---|
533 | Key acpiNode = biosNode.key ("ACPI");
|
---|
534 |
|
---|
535 | mData->mACPIEnabled = acpiNode.value <bool> ("enabled");
|
---|
536 | }
|
---|
537 |
|
---|
538 | /* IOAPIC (optional) */
|
---|
539 | {
|
---|
540 | Key ioapicNode = biosNode.findKey ("IOAPIC");
|
---|
541 | if (!ioapicNode.isNull())
|
---|
542 | mData->mIOAPICEnabled = ioapicNode.value <bool> ("enabled");
|
---|
543 | }
|
---|
544 |
|
---|
545 | /* Logo (optional) */
|
---|
546 | {
|
---|
547 | Key logoNode = biosNode.findKey ("Logo");
|
---|
548 | if (!logoNode.isNull())
|
---|
549 | {
|
---|
550 | mData->mLogoFadeIn = logoNode.value <bool> ("fadeIn");
|
---|
551 | mData->mLogoFadeOut = logoNode.value <bool> ("fadeOut");
|
---|
552 | mData->mLogoDisplayTime = logoNode.value <ULONG> ("displayTime");
|
---|
553 | mData->mLogoImagePath = logoNode.stringValue ("imagePath");
|
---|
554 | }
|
---|
555 | }
|
---|
556 |
|
---|
557 | /* boot menu (optional) */
|
---|
558 | {
|
---|
559 | Key bootMenuNode = biosNode.findKey ("BootMenu");
|
---|
560 | if (!bootMenuNode.isNull())
|
---|
561 | {
|
---|
562 | mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
|
---|
563 | const char *modeStr = bootMenuNode.stringValue ("mode");
|
---|
564 |
|
---|
565 | if (strcmp (modeStr, "Disabled") == 0)
|
---|
566 | mData->mBootMenuMode = BIOSBootMenuMode_Disabled;
|
---|
567 | else if (strcmp (modeStr, "MenuOnly") == 0)
|
---|
568 | mData->mBootMenuMode = BIOSBootMenuMode_MenuOnly;
|
---|
569 | else if (strcmp (modeStr, "MessageAndMenu") == 0)
|
---|
570 | mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
|
---|
571 | else
|
---|
572 | ComAssertMsgFailedRet (("Invalid boot menu mode '%s'", modeStr),
|
---|
573 | E_FAIL);
|
---|
574 | }
|
---|
575 | }
|
---|
576 |
|
---|
577 | /* PXE debug logging (optional) */
|
---|
578 | {
|
---|
579 | Key pxedebugNode = biosNode.findKey ("PXEDebug");
|
---|
580 | if (!pxedebugNode.isNull())
|
---|
581 | mData->mPXEDebugEnabled = pxedebugNode.value <bool> ("enabled");
|
---|
582 | }
|
---|
583 |
|
---|
584 | /* time offset (optional) */
|
---|
585 | {
|
---|
586 | Key timeOffsetNode = biosNode.findKey ("TimeOffset");
|
---|
587 | if (!timeOffsetNode.isNull())
|
---|
588 | mData->mTimeOffset = timeOffsetNode.value <LONG64> ("value");
|
---|
589 | }
|
---|
590 |
|
---|
591 | /* IDE controller type (optional, for old machines that lack this node,
|
---|
592 | * defaults to PIIX3) */
|
---|
593 | {
|
---|
594 | mData->mIDEControllerType = IDEControllerType_PIIX3;
|
---|
595 |
|
---|
596 | Key ideControllerNode = biosNode.findKey ("IDEController");
|
---|
597 | if (!ideControllerNode.isNull())
|
---|
598 | {
|
---|
599 | const char *typeStr = ideControllerNode.stringValue ("type");
|
---|
600 | if (strcmp (typeStr, "PIIX3") == 0)
|
---|
601 | mData->mIDEControllerType = IDEControllerType_PIIX3;
|
---|
602 | else if (strcmp (typeStr, "PIIX4") == 0)
|
---|
603 | mData->mIDEControllerType = IDEControllerType_PIIX4;
|
---|
604 | else if (strcmp (typeStr, "ICH6") == 0)
|
---|
605 | mData->mIDEControllerType = IDEControllerType_ICH6;
|
---|
606 | else
|
---|
607 | ComAssertMsgFailedRet (("Invalid boot menu mode '%s'", typeStr),
|
---|
608 | E_FAIL);
|
---|
609 | }
|
---|
610 | }
|
---|
611 |
|
---|
612 | return S_OK;
|
---|
613 | }
|
---|
614 |
|
---|
615 | /**
|
---|
616 | * Saves settings to the given machine node.
|
---|
617 | *
|
---|
618 | * @param aMachineNode <Machine> node.
|
---|
619 | *
|
---|
620 | * @note Locks this object for reading.
|
---|
621 | */
|
---|
622 | HRESULT BIOSSettings::saveSettings (settings::Key &aMachineNode)
|
---|
623 | {
|
---|
624 | using namespace settings;
|
---|
625 |
|
---|
626 | AssertReturn (!aMachineNode.isNull(), E_FAIL);
|
---|
627 |
|
---|
628 | AutoCaller autoCaller (this);
|
---|
629 | AssertComRCReturnRC (autoCaller.rc());
|
---|
630 |
|
---|
631 | AutoReadLock alock (this);
|
---|
632 |
|
---|
633 | Key biosNode = aMachineNode.createKey ("BIOS");
|
---|
634 |
|
---|
635 | /* ACPI */
|
---|
636 | {
|
---|
637 | Key acpiNode = biosNode.createKey ("ACPI");
|
---|
638 | acpiNode.setValue <bool> ("enabled", !!mData->mACPIEnabled);
|
---|
639 | }
|
---|
640 |
|
---|
641 | /* IOAPIC */
|
---|
642 | {
|
---|
643 | Key ioapicNode = biosNode.createKey ("IOAPIC");
|
---|
644 | ioapicNode.setValue <bool> ("enabled", !!mData->mIOAPICEnabled);
|
---|
645 | }
|
---|
646 |
|
---|
647 | /* BIOS logo (optional) **/
|
---|
648 | {
|
---|
649 | Key logoNode = biosNode.createKey ("Logo");
|
---|
650 | logoNode.setValue <bool> ("fadeIn", !!mData->mLogoFadeIn);
|
---|
651 | logoNode.setValue <bool> ("fadeOut", !!mData->mLogoFadeOut);
|
---|
652 | logoNode.setValue <ULONG> ("displayTime", mData->mLogoDisplayTime);
|
---|
653 | logoNode.setValueOr <Bstr> ("imagePath", mData->mLogoImagePath, Bstr::Null);
|
---|
654 | }
|
---|
655 |
|
---|
656 | /* boot menu (optional) */
|
---|
657 | {
|
---|
658 | Key bootMenuNode = biosNode.createKey ("BootMenu");
|
---|
659 | const char *modeStr = NULL;
|
---|
660 | switch (mData->mBootMenuMode)
|
---|
661 | {
|
---|
662 | case BIOSBootMenuMode_Disabled:
|
---|
663 | modeStr = "Disabled";
|
---|
664 | break;
|
---|
665 | case BIOSBootMenuMode_MenuOnly:
|
---|
666 | modeStr = "MenuOnly";
|
---|
667 | break;
|
---|
668 | case BIOSBootMenuMode_MessageAndMenu:
|
---|
669 | modeStr = "MessageAndMenu";
|
---|
670 | break;
|
---|
671 | default:
|
---|
672 | ComAssertMsgFailedRet (("Invalid boot menu type: %d",
|
---|
673 | mData->mBootMenuMode),
|
---|
674 | E_FAIL);
|
---|
675 | }
|
---|
676 | bootMenuNode.setStringValue ("mode", modeStr);
|
---|
677 | }
|
---|
678 |
|
---|
679 | /* time offset (optional) */
|
---|
680 | {
|
---|
681 | Key timeOffsetNode = biosNode.createKey ("TimeOffset");
|
---|
682 | timeOffsetNode.setValue <LONG64> ("value", mData->mTimeOffset);
|
---|
683 | }
|
---|
684 |
|
---|
685 | /* PXE debug flag (optional) */
|
---|
686 | {
|
---|
687 | Key pxedebugNode = biosNode.createKey ("PXEDebug");
|
---|
688 | pxedebugNode.setValue <bool> ("enabled", !!mData->mPXEDebugEnabled);
|
---|
689 | }
|
---|
690 |
|
---|
691 | /* IDE controller type */
|
---|
692 | {
|
---|
693 | Key ideControllerNode = biosNode.createKey ("IDEController");
|
---|
694 | const char *ideControllerTypeStr = NULL;
|
---|
695 | switch (mData->mIDEControllerType)
|
---|
696 | {
|
---|
697 | case IDEControllerType_PIIX3:
|
---|
698 | ideControllerTypeStr = "PIIX3";
|
---|
699 | break;
|
---|
700 | case IDEControllerType_PIIX4:
|
---|
701 | ideControllerTypeStr = "PIIX4";
|
---|
702 | break;
|
---|
703 | case IDEControllerType_ICH6:
|
---|
704 | ideControllerTypeStr = "ICH6";
|
---|
705 | break;
|
---|
706 | default:
|
---|
707 | ComAssertMsgFailedRet (("Invalid IDE Controller type: %d",
|
---|
708 | mData->mIDEControllerType),
|
---|
709 | E_FAIL);
|
---|
710 | }
|
---|
711 | ideControllerNode.setStringValue ("type", ideControllerTypeStr);
|
---|
712 | }
|
---|
713 |
|
---|
714 | return S_OK;
|
---|
715 | }
|
---|
716 |
|
---|
717 | void BIOSSettings::commit()
|
---|
718 | {
|
---|
719 | /* sanity */
|
---|
720 | AutoCaller autoCaller (this);
|
---|
721 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
722 |
|
---|
723 | /* sanity too */
|
---|
724 | AutoCaller peerCaller (mPeer);
|
---|
725 | AssertComRCReturnVoid (peerCaller.rc());
|
---|
726 |
|
---|
727 | /* lock both for writing since we modify both (mPeer is "master" so locked
|
---|
728 | * first) */
|
---|
729 | AutoMultiWriteLock2 alock (mPeer, this);
|
---|
730 |
|
---|
731 | if (mData.isBackedUp())
|
---|
732 | {
|
---|
733 | mData.commit();
|
---|
734 | if (mPeer)
|
---|
735 | {
|
---|
736 | /* attach new data to the peer and reshare it */
|
---|
737 | AutoWriteLock peerlock (mPeer);
|
---|
738 | mPeer->mData.attach (mData);
|
---|
739 | }
|
---|
740 | }
|
---|
741 | }
|
---|
742 |
|
---|
743 | void BIOSSettings::copyFrom (BIOSSettings *aThat)
|
---|
744 | {
|
---|
745 | AssertReturnVoid (aThat != NULL);
|
---|
746 |
|
---|
747 | /* sanity */
|
---|
748 | AutoCaller autoCaller (this);
|
---|
749 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
750 |
|
---|
751 | /* sanity too */
|
---|
752 | AutoCaller thatCaller (aThat);
|
---|
753 | AssertComRCReturnVoid (thatCaller.rc());
|
---|
754 |
|
---|
755 | /* peer is not modified, lock it for reading (aThat is "master" so locked
|
---|
756 | * first) */
|
---|
757 | AutoMultiLock2 alock (aThat->rlock(), this->wlock());
|
---|
758 |
|
---|
759 | /* this will back up current data */
|
---|
760 | mData.assignCopy (aThat->mData);
|
---|
761 | }
|
---|
762 |
|
---|
763 | void BIOSSettings::applyDefaults (GuestOSType *aOsType)
|
---|
764 | {
|
---|
765 | AssertReturnVoid (aOsType != NULL);
|
---|
766 |
|
---|
767 | /* sanity */
|
---|
768 | AutoCaller autoCaller (this);
|
---|
769 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
770 |
|
---|
771 | AutoWriteLock alock (this);
|
---|
772 |
|
---|
773 | /* Initialize default BIOS settings here */
|
---|
774 | mData->mIOAPICEnabled = aOsType->recommendedIOAPIC();
|
---|
775 | }
|
---|
776 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|