51
51
HRESULT BIOSSettings::init (Machine *aParent)
53
53
LogFlowThisFuncEnter();
54
LogFlowThisFunc (("aParent: %p\n", aParent));
54
LogFlowThisFunc(("aParent: %p\n", aParent));
56
56
ComAssertRet (aParent, E_INVALIDARG);
58
58
/* Enclose the state transition NotReady->InInit->Ready */
59
AutoInitSpan autoInitSpan (this);
60
AssertReturn (autoInitSpan.isOk(), E_FAIL);
59
AutoInitSpan autoInitSpan(this);
60
AssertReturn(autoInitSpan.isOk(), E_FAIL);
62
62
/* share the parent weakly */
63
unconst (mParent) = aParent;
63
unconst(mParent) = aParent;
81
81
HRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
83
83
LogFlowThisFuncEnter();
84
LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
84
LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
86
86
ComAssertRet (aParent && that, E_INVALIDARG);
88
88
/* Enclose the state transition NotReady->InInit->Ready */
89
AutoInitSpan autoInitSpan (this);
90
AssertReturn (autoInitSpan.isOk(), E_FAIL);
89
AutoInitSpan autoInitSpan(this);
90
AssertReturn(autoInitSpan.isOk(), E_FAIL);
109
109
HRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
111
111
LogFlowThisFuncEnter();
112
LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
112
LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
114
114
ComAssertRet (aParent && that, E_INVALIDARG);
116
116
/* Enclose the state transition NotReady->InInit->Ready */
117
AutoInitSpan autoInitSpan (this);
118
AssertReturn (autoInitSpan.isOk(), E_FAIL);
117
AutoInitSpan autoInitSpan(this);
118
AssertReturn(autoInitSpan.isOk(), E_FAIL);
120
120
mParent = aParent;
121
121
// mPeer is left null
171
171
STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
173
AutoCaller autoCaller (this);
174
CheckComRCReturnRC (autoCaller.rc());
173
AutoCaller autoCaller(this);
174
CheckComRCReturnRC(autoCaller.rc());
176
176
/* the machine needs to be mutable */
177
177
Machine::AutoMutableStateDependency adep (mParent);
178
CheckComRCReturnRC (adep.rc());
178
CheckComRCReturnRC(adep.rc());
180
AutoWriteLock alock (this);
180
AutoWriteLock alock(this);
183
183
mData->mLogoFadeIn = enable;
203
203
STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
205
AutoCaller autoCaller (this);
206
CheckComRCReturnRC (autoCaller.rc());
205
AutoCaller autoCaller(this);
206
CheckComRCReturnRC(autoCaller.rc());
208
208
/* the machine needs to be mutable */
209
209
Machine::AutoMutableStateDependency adep (mParent);
210
CheckComRCReturnRC (adep.rc());
210
CheckComRCReturnRC(adep.rc());
212
AutoWriteLock alock (this);
212
AutoWriteLock alock(this);
215
215
mData->mLogoFadeOut = enable;
235
235
STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
237
AutoCaller autoCaller (this);
238
CheckComRCReturnRC (autoCaller.rc());
237
AutoCaller autoCaller(this);
238
CheckComRCReturnRC(autoCaller.rc());
240
240
/* the machine needs to be mutable */
241
241
Machine::AutoMutableStateDependency adep (mParent);
242
CheckComRCReturnRC (adep.rc());
242
CheckComRCReturnRC(adep.rc());
244
AutoWriteLock alock (this);
244
AutoWriteLock alock(this);
247
247
mData->mLogoDisplayTime = displayTime;
266
266
STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(IN_BSTR imagePath)
268
/* empty strings are not allowed as path names */
269
if (imagePath && !(*imagePath))
268
/* NULL strings are not allowed */
270
270
return E_INVALIDARG;
272
AutoCaller autoCaller (this);
273
CheckComRCReturnRC (autoCaller.rc());
272
AutoCaller autoCaller(this);
273
CheckComRCReturnRC(autoCaller.rc());
275
275
/* the machine needs to be mutable */
276
276
Machine::AutoMutableStateDependency adep (mParent);
277
CheckComRCReturnRC (adep.rc());
277
CheckComRCReturnRC(adep.rc());
279
AutoWriteLock alock (this);
279
AutoWriteLock alock(this);
282
282
mData->mLogoImagePath = imagePath;
301
301
STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
303
AutoCaller autoCaller (this);
304
CheckComRCReturnRC (autoCaller.rc());
303
AutoCaller autoCaller(this);
304
CheckComRCReturnRC(autoCaller.rc());
306
306
/* the machine needs to be mutable */
307
307
Machine::AutoMutableStateDependency adep (mParent);
308
CheckComRCReturnRC (adep.rc());
308
CheckComRCReturnRC(adep.rc());
310
AutoWriteLock alock (this);
310
AutoWriteLock alock(this);
313
313
mData->mBootMenuMode = bootMenuMode;
333
333
STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
335
AutoCaller autoCaller (this);
336
CheckComRCReturnRC (autoCaller.rc());
335
AutoCaller autoCaller(this);
336
CheckComRCReturnRC(autoCaller.rc());
338
338
/* the machine needs to be mutable */
339
339
Machine::AutoMutableStateDependency adep (mParent);
340
CheckComRCReturnRC (adep.rc());
340
CheckComRCReturnRC(adep.rc());
342
AutoWriteLock alock (this);
342
AutoWriteLock alock(this);
345
345
mData->mACPIEnabled = enable;
365
365
STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
367
AutoCaller autoCaller (this);
368
CheckComRCReturnRC (autoCaller.rc());
367
AutoCaller autoCaller(this);
368
CheckComRCReturnRC(autoCaller.rc());
370
370
/* the machine needs to be mutable */
371
371
Machine::AutoMutableStateDependency adep (mParent);
372
CheckComRCReturnRC (adep.rc());
372
CheckComRCReturnRC(adep.rc());
374
AutoWriteLock alock (this);
374
AutoWriteLock alock(this);
377
377
mData->mIOAPICEnabled = enable;
397
397
STDMETHODIMP BIOSSettings::COMSETTER(PXEDebugEnabled)(BOOL enable)
399
AutoCaller autoCaller (this);
400
CheckComRCReturnRC (autoCaller.rc());
399
AutoCaller autoCaller(this);
400
CheckComRCReturnRC(autoCaller.rc());
402
402
/* the machine needs to be mutable */
403
403
Machine::AutoMutableStateDependency adep (mParent);
404
CheckComRCReturnRC (adep.rc());
404
CheckComRCReturnRC(adep.rc());
406
AutoWriteLock alock (this);
406
AutoWriteLock alock(this);
409
409
mData->mPXEDebugEnabled = enable;
429
429
STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
431
AutoCaller autoCaller (this);
432
CheckComRCReturnRC (autoCaller.rc());
431
AutoCaller autoCaller(this);
432
CheckComRCReturnRC(autoCaller.rc());
434
434
/* the machine needs to be mutable */
435
435
Machine::AutoMutableStateDependency adep (mParent);
436
CheckComRCReturnRC (adep.rc());
436
CheckComRCReturnRC(adep.rc());
438
AutoWriteLock alock (this);
438
AutoWriteLock alock(this);
441
441
mData->mTimeOffset = offset;
459
459
* @note Locks this object for writing.
461
HRESULT BIOSSettings::loadSettings (const settings::Key &aMachineNode)
461
HRESULT BIOSSettings::loadSettings(const settings::BIOSSettings &data)
463
using namespace settings;
465
AssertReturn (!aMachineNode.isNull(), E_FAIL);
467
AutoCaller autoCaller (this);
468
AssertComRCReturnRC (autoCaller.rc());
470
AutoWriteLock alock (this);
472
/* Note: we assume that the default values for attributes of optional
473
* nodes are assigned in the Data::Data() constructor and don't do it
474
* here. It implies that this method may only be called after constructing
475
* a new BIOSSettings object while all its data fields are in the default
476
* values. Exceptions are fields whose creation time defaults don't match
477
* values that should be applied when these fields are not explicitly set
478
* in the settings file (for backwards compatibility reasons). This takes
479
* place when a setting of a newly created object must default to A while
480
* the same setting of an object loaded from the old settings file must
483
/* BIOS node (required) */
484
Key biosNode = aMachineNode.key ("BIOS");
486
/* ACPI (required) */
488
Key acpiNode = biosNode.key ("ACPI");
490
mData->mACPIEnabled = acpiNode.value <bool> ("enabled");
493
/* IOAPIC (optional) */
495
Key ioapicNode = biosNode.findKey ("IOAPIC");
496
if (!ioapicNode.isNull())
497
mData->mIOAPICEnabled = ioapicNode.value <bool> ("enabled");
500
/* Logo (optional) */
502
Key logoNode = biosNode.findKey ("Logo");
503
if (!logoNode.isNull())
505
mData->mLogoFadeIn = logoNode.value <bool> ("fadeIn");
506
mData->mLogoFadeOut = logoNode.value <bool> ("fadeOut");
507
mData->mLogoDisplayTime = logoNode.value <ULONG> ("displayTime");
508
mData->mLogoImagePath = logoNode.stringValue ("imagePath");
512
/* boot menu (optional) */
514
Key bootMenuNode = biosNode.findKey ("BootMenu");
515
if (!bootMenuNode.isNull())
517
mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
518
const char *modeStr = bootMenuNode.stringValue ("mode");
520
if (strcmp (modeStr, "Disabled") == 0)
521
mData->mBootMenuMode = BIOSBootMenuMode_Disabled;
522
else if (strcmp (modeStr, "MenuOnly") == 0)
523
mData->mBootMenuMode = BIOSBootMenuMode_MenuOnly;
524
else if (strcmp (modeStr, "MessageAndMenu") == 0)
525
mData->mBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
527
ComAssertMsgFailedRet (("Invalid boot menu mode '%s'", modeStr),
532
/* PXE debug logging (optional) */
534
Key pxedebugNode = biosNode.findKey ("PXEDebug");
535
if (!pxedebugNode.isNull())
536
mData->mPXEDebugEnabled = pxedebugNode.value <bool> ("enabled");
539
/* time offset (optional) */
541
Key timeOffsetNode = biosNode.findKey ("TimeOffset");
542
if (!timeOffsetNode.isNull())
543
mData->mTimeOffset = timeOffsetNode.value <LONG64> ("value");
463
AutoCaller autoCaller(this);
464
AssertComRCReturnRC(autoCaller.rc());
466
AutoWriteLock alock(this);
468
mData->mACPIEnabled = data.fACPIEnabled;
469
mData->mIOAPICEnabled = data.fIOAPICEnabled;
471
mData->mLogoFadeIn = data.fLogoFadeIn;
472
mData->mLogoFadeOut = data.fLogoFadeOut;
473
mData->mLogoDisplayTime = data.ulLogoDisplayTime;
474
mData->mLogoImagePath = data.strLogoImagePath;
476
mData->mBootMenuMode = data.biosBootMenuMode;
478
mData->mPXEDebugEnabled = data.fPXEDebugEnabled;
479
mData->mTimeOffset = data.llTimeOffset;
554
489
* @note Locks this object for reading.
556
HRESULT BIOSSettings::saveSettings (settings::Key &aMachineNode)
491
HRESULT BIOSSettings::saveSettings(settings::BIOSSettings &data)
558
using namespace settings;
560
AssertReturn (!aMachineNode.isNull(), E_FAIL);
562
AutoCaller autoCaller (this);
563
AssertComRCReturnRC (autoCaller.rc());
565
AutoReadLock alock (this);
567
Key biosNode = aMachineNode.createKey ("BIOS");
571
Key acpiNode = biosNode.createKey ("ACPI");
572
acpiNode.setValue <bool> ("enabled", !!mData->mACPIEnabled);
577
Key ioapicNode = biosNode.createKey ("IOAPIC");
578
ioapicNode.setValue <bool> ("enabled", !!mData->mIOAPICEnabled);
581
/* BIOS logo (optional) **/
583
Key logoNode = biosNode.createKey ("Logo");
584
logoNode.setValue <bool> ("fadeIn", !!mData->mLogoFadeIn);
585
logoNode.setValue <bool> ("fadeOut", !!mData->mLogoFadeOut);
586
logoNode.setValue <ULONG> ("displayTime", mData->mLogoDisplayTime);
587
logoNode.setValueOr <Bstr> ("imagePath", mData->mLogoImagePath, Bstr::Null);
590
/* boot menu (optional) */
592
Key bootMenuNode = biosNode.createKey ("BootMenu");
593
const char *modeStr = NULL;
594
switch (mData->mBootMenuMode)
596
case BIOSBootMenuMode_Disabled:
597
modeStr = "Disabled";
599
case BIOSBootMenuMode_MenuOnly:
600
modeStr = "MenuOnly";
602
case BIOSBootMenuMode_MessageAndMenu:
603
modeStr = "MessageAndMenu";
606
ComAssertMsgFailedRet (("Invalid boot menu type: %d",
607
mData->mBootMenuMode),
610
bootMenuNode.setStringValue ("mode", modeStr);
613
/* time offset (optional) */
615
Key timeOffsetNode = biosNode.createKey ("TimeOffset");
616
timeOffsetNode.setValue <LONG64> ("value", mData->mTimeOffset);
619
/* PXE debug flag (optional) */
621
Key pxedebugNode = biosNode.createKey ("PXEDebug");
622
pxedebugNode.setValue <bool> ("enabled", !!mData->mPXEDebugEnabled);
493
AutoCaller autoCaller(this);
494
AssertComRCReturnRC(autoCaller.rc());
496
AutoReadLock alock(this);
498
data.fACPIEnabled = !!mData->mACPIEnabled;
499
data.fIOAPICEnabled = !!mData->mIOAPICEnabled;
501
data.fLogoFadeIn = !!mData->mLogoFadeIn;
502
data.fLogoFadeOut = !!mData->mLogoFadeOut;
503
data.ulLogoDisplayTime = mData->mLogoDisplayTime;
504
data.strLogoImagePath = mData->mLogoImagePath;
506
data.biosBootMenuMode = mData->mBootMenuMode;
507
data.fPXEDebugEnabled = !!mData->mPXEDebugEnabled;
508
data.llTimeOffset = mData->mTimeOffset;