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