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 "GuestOSTypeImpl.h"
|
---|
25 |
|
---|
26 | #include <iprt/cpp/utils.h>
|
---|
27 | #include <VBox/settings.h>
|
---|
28 |
|
---|
29 | #include "AutoStateDep.h"
|
---|
30 | #include "AutoCaller.h"
|
---|
31 | #include "Logging.h"
|
---|
32 |
|
---|
33 | ////////////////////////////////////////////////////////////////////////////////
|
---|
34 | //
|
---|
35 | // BIOSSettings private data definition
|
---|
36 | //
|
---|
37 | ////////////////////////////////////////////////////////////////////////////////
|
---|
38 |
|
---|
39 | struct BIOSSettings::Data
|
---|
40 | {
|
---|
41 | Data()
|
---|
42 | { }
|
---|
43 |
|
---|
44 | ComObjPtr<Machine, ComWeakRef> pMachine;
|
---|
45 | ComObjPtr<BIOSSettings> pPeer;
|
---|
46 |
|
---|
47 | // use the XML settings structure in the members for simplicity
|
---|
48 | Backupable<settings::BIOSSettings> bd;
|
---|
49 | };
|
---|
50 |
|
---|
51 | // constructor / destructor
|
---|
52 | /////////////////////////////////////////////////////////////////////////////
|
---|
53 |
|
---|
54 | HRESULT BIOSSettings::FinalConstruct()
|
---|
55 | {
|
---|
56 | return S_OK;
|
---|
57 | }
|
---|
58 |
|
---|
59 | void BIOSSettings::FinalRelease()
|
---|
60 | {
|
---|
61 | uninit ();
|
---|
62 | }
|
---|
63 |
|
---|
64 | // public initializer/uninitializer for internal purposes only
|
---|
65 | /////////////////////////////////////////////////////////////////////////////
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * Initializes the audio adapter object.
|
---|
69 | *
|
---|
70 | * @returns COM result indicator
|
---|
71 | */
|
---|
72 | HRESULT BIOSSettings::init(Machine *aParent)
|
---|
73 | {
|
---|
74 | LogFlowThisFuncEnter();
|
---|
75 | LogFlowThisFunc(("aParent: %p\n", aParent));
|
---|
76 |
|
---|
77 | ComAssertRet (aParent, E_INVALIDARG);
|
---|
78 |
|
---|
79 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
80 | AutoInitSpan autoInitSpan(this);
|
---|
81 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
82 |
|
---|
83 | m = new Data();
|
---|
84 |
|
---|
85 | /* share the parent weakly */
|
---|
86 | unconst(m->pMachine) = aParent;
|
---|
87 |
|
---|
88 | m->bd.allocate();
|
---|
89 |
|
---|
90 | autoInitSpan.setSucceeded();
|
---|
91 |
|
---|
92 | LogFlowThisFuncLeave();
|
---|
93 | return S_OK;
|
---|
94 | }
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Initializes the audio adapter object given another audio adapter object
|
---|
98 | * (a kind of copy constructor). This object shares data with
|
---|
99 | * the object passed as an argument.
|
---|
100 | *
|
---|
101 | * @note This object must be destroyed before the original object
|
---|
102 | * it shares data with is destroyed.
|
---|
103 | */
|
---|
104 | HRESULT BIOSSettings::init(Machine *aParent, BIOSSettings *that)
|
---|
105 | {
|
---|
106 | LogFlowThisFuncEnter();
|
---|
107 | LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
|
---|
108 |
|
---|
109 | ComAssertRet (aParent && that, E_INVALIDARG);
|
---|
110 |
|
---|
111 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
112 | AutoInitSpan autoInitSpan(this);
|
---|
113 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
114 |
|
---|
115 | m = new Data();
|
---|
116 |
|
---|
117 | m->pMachine = aParent;
|
---|
118 | m->pPeer = that;
|
---|
119 |
|
---|
120 | AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS);
|
---|
121 | m->bd.share(that->m->bd);
|
---|
122 |
|
---|
123 | autoInitSpan.setSucceeded();
|
---|
124 |
|
---|
125 | LogFlowThisFuncLeave();
|
---|
126 | return S_OK;
|
---|
127 | }
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * Initializes the guest object given another guest object
|
---|
131 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
132 | * of the original object passed as an argument.
|
---|
133 | */
|
---|
134 | HRESULT BIOSSettings::initCopy(Machine *aParent, BIOSSettings *that)
|
---|
135 | {
|
---|
136 | LogFlowThisFuncEnter();
|
---|
137 | LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
|
---|
138 |
|
---|
139 | ComAssertRet (aParent && that, E_INVALIDARG);
|
---|
140 |
|
---|
141 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
142 | AutoInitSpan autoInitSpan(this);
|
---|
143 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
144 |
|
---|
145 | m = new Data();
|
---|
146 |
|
---|
147 | m->pMachine = aParent;
|
---|
148 | // mPeer is left null
|
---|
149 |
|
---|
150 | AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS);
|
---|
151 | m->bd.attachCopy(that->m->bd);
|
---|
152 |
|
---|
153 | autoInitSpan.setSucceeded();
|
---|
154 |
|
---|
155 | LogFlowThisFuncLeave();
|
---|
156 | return S_OK;
|
---|
157 | }
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
161 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
162 | */
|
---|
163 | void BIOSSettings::uninit()
|
---|
164 | {
|
---|
165 | LogFlowThisFuncEnter();
|
---|
166 |
|
---|
167 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
168 | AutoUninitSpan autoUninitSpan(this);
|
---|
169 | if (autoUninitSpan.uninitDone())
|
---|
170 | return;
|
---|
171 |
|
---|
172 | m->bd.free();
|
---|
173 |
|
---|
174 | m->pPeer.setNull();
|
---|
175 | m->pMachine.setNull();
|
---|
176 |
|
---|
177 | delete m;
|
---|
178 | m = NULL;
|
---|
179 |
|
---|
180 | LogFlowThisFuncLeave();
|
---|
181 | }
|
---|
182 |
|
---|
183 | // IBIOSSettings properties
|
---|
184 | /////////////////////////////////////////////////////////////////////////////
|
---|
185 |
|
---|
186 | STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
|
---|
187 | {
|
---|
188 | if (!enabled)
|
---|
189 | return E_POINTER;
|
---|
190 |
|
---|
191 | AutoCaller autoCaller(this);
|
---|
192 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
193 |
|
---|
194 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
195 |
|
---|
196 | *enabled = m->bd->fLogoFadeIn;
|
---|
197 |
|
---|
198 | return S_OK;
|
---|
199 | }
|
---|
200 |
|
---|
201 | STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
|
---|
202 | {
|
---|
203 | AutoCaller autoCaller(this);
|
---|
204 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
205 |
|
---|
206 | /* the machine needs to be mutable */
|
---|
207 | AutoMutableStateDependency adep(m->pMachine);
|
---|
208 | if (FAILED(adep.rc())) return adep.rc();
|
---|
209 |
|
---|
210 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
211 |
|
---|
212 | m->bd.backup();
|
---|
213 | m->bd->fLogoFadeIn = enable;
|
---|
214 |
|
---|
215 | alock.release();
|
---|
216 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
217 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
218 |
|
---|
219 | return S_OK;
|
---|
220 | }
|
---|
221 |
|
---|
222 | STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
|
---|
223 | {
|
---|
224 | if (!enabled)
|
---|
225 | return E_POINTER;
|
---|
226 |
|
---|
227 | AutoCaller autoCaller(this);
|
---|
228 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
229 |
|
---|
230 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
231 |
|
---|
232 | *enabled = m->bd->fLogoFadeOut;
|
---|
233 |
|
---|
234 | return S_OK;
|
---|
235 | }
|
---|
236 |
|
---|
237 | STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
|
---|
238 | {
|
---|
239 | AutoCaller autoCaller(this);
|
---|
240 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
241 |
|
---|
242 | /* the machine needs to be mutable */
|
---|
243 | AutoMutableStateDependency adep(m->pMachine);
|
---|
244 | if (FAILED(adep.rc())) return adep.rc();
|
---|
245 |
|
---|
246 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
247 |
|
---|
248 | m->bd.backup();
|
---|
249 | m->bd->fLogoFadeOut = enable;
|
---|
250 |
|
---|
251 | alock.release();
|
---|
252 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
253 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
254 |
|
---|
255 | return S_OK;
|
---|
256 | }
|
---|
257 |
|
---|
258 | STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
|
---|
259 | {
|
---|
260 | if (!displayTime)
|
---|
261 | return E_POINTER;
|
---|
262 |
|
---|
263 | AutoCaller autoCaller(this);
|
---|
264 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
265 |
|
---|
266 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
267 |
|
---|
268 | *displayTime = m->bd->ulLogoDisplayTime;
|
---|
269 |
|
---|
270 | return S_OK;
|
---|
271 | }
|
---|
272 |
|
---|
273 | STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
|
---|
274 | {
|
---|
275 | AutoCaller autoCaller(this);
|
---|
276 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
277 |
|
---|
278 | /* the machine needs to be mutable */
|
---|
279 | AutoMutableStateDependency adep(m->pMachine);
|
---|
280 | if (FAILED(adep.rc())) return adep.rc();
|
---|
281 |
|
---|
282 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
283 |
|
---|
284 | m->bd.backup();
|
---|
285 | m->bd->ulLogoDisplayTime = displayTime;
|
---|
286 |
|
---|
287 | alock.release();
|
---|
288 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
289 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
290 |
|
---|
291 | return S_OK;
|
---|
292 | }
|
---|
293 |
|
---|
294 | STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
|
---|
295 | {
|
---|
296 | if (!imagePath)
|
---|
297 | return E_POINTER;
|
---|
298 |
|
---|
299 | AutoCaller autoCaller(this);
|
---|
300 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
301 |
|
---|
302 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
303 |
|
---|
304 | m->bd->strLogoImagePath.cloneTo(imagePath);
|
---|
305 | return S_OK;
|
---|
306 | }
|
---|
307 |
|
---|
308 | STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(IN_BSTR imagePath)
|
---|
309 | {
|
---|
310 | /* NULL strings are not allowed */
|
---|
311 | if (!imagePath)
|
---|
312 | return E_INVALIDARG;
|
---|
313 |
|
---|
314 | AutoCaller autoCaller(this);
|
---|
315 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
316 |
|
---|
317 | /* the machine needs to be mutable */
|
---|
318 | AutoMutableStateDependency adep(m->pMachine);
|
---|
319 | if (FAILED(adep.rc())) return adep.rc();
|
---|
320 |
|
---|
321 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
322 |
|
---|
323 | m->bd.backup();
|
---|
324 | m->bd->strLogoImagePath = imagePath;
|
---|
325 |
|
---|
326 | alock.release();
|
---|
327 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
328 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
329 |
|
---|
330 | return S_OK;
|
---|
331 | }
|
---|
332 |
|
---|
333 | STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
|
---|
334 | {
|
---|
335 | if (!bootMenuMode)
|
---|
336 | return E_POINTER;
|
---|
337 |
|
---|
338 | AutoCaller autoCaller(this);
|
---|
339 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
340 |
|
---|
341 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
342 |
|
---|
343 | *bootMenuMode = m->bd->biosBootMenuMode;
|
---|
344 | return S_OK;
|
---|
345 | }
|
---|
346 |
|
---|
347 | STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
|
---|
348 | {
|
---|
349 | AutoCaller autoCaller(this);
|
---|
350 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
351 |
|
---|
352 | /* the machine needs to be mutable */
|
---|
353 | AutoMutableStateDependency adep(m->pMachine);
|
---|
354 | if (FAILED(adep.rc())) return adep.rc();
|
---|
355 |
|
---|
356 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
357 |
|
---|
358 | m->bd.backup();
|
---|
359 | m->bd->biosBootMenuMode = bootMenuMode;
|
---|
360 |
|
---|
361 | alock.release();
|
---|
362 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
363 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
364 |
|
---|
365 | return S_OK;
|
---|
366 | }
|
---|
367 |
|
---|
368 | STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
|
---|
369 | {
|
---|
370 | if (!enabled)
|
---|
371 | return E_POINTER;
|
---|
372 |
|
---|
373 | AutoCaller autoCaller(this);
|
---|
374 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
375 |
|
---|
376 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
377 |
|
---|
378 | *enabled = m->bd->fACPIEnabled;
|
---|
379 |
|
---|
380 | return S_OK;
|
---|
381 | }
|
---|
382 |
|
---|
383 | STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
|
---|
384 | {
|
---|
385 | AutoCaller autoCaller(this);
|
---|
386 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
387 |
|
---|
388 | /* the machine needs to be mutable */
|
---|
389 | AutoMutableStateDependency adep(m->pMachine);
|
---|
390 | if (FAILED(adep.rc())) return adep.rc();
|
---|
391 |
|
---|
392 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
393 |
|
---|
394 | m->bd.backup();
|
---|
395 | m->bd->fACPIEnabled = enable;
|
---|
396 |
|
---|
397 | alock.release();
|
---|
398 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
399 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
400 |
|
---|
401 | return S_OK;
|
---|
402 | }
|
---|
403 |
|
---|
404 | STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
|
---|
405 | {
|
---|
406 | if (!enabled)
|
---|
407 | return E_POINTER;
|
---|
408 |
|
---|
409 | AutoCaller autoCaller(this);
|
---|
410 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
411 |
|
---|
412 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
413 |
|
---|
414 | *enabled = m->bd->fIOAPICEnabled;
|
---|
415 |
|
---|
416 | return S_OK;
|
---|
417 | }
|
---|
418 |
|
---|
419 | STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
|
---|
420 | {
|
---|
421 | AutoCaller autoCaller(this);
|
---|
422 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
423 |
|
---|
424 | /* the machine needs to be mutable */
|
---|
425 | AutoMutableStateDependency adep(m->pMachine);
|
---|
426 | if (FAILED(adep.rc())) return adep.rc();
|
---|
427 |
|
---|
428 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
429 |
|
---|
430 | m->bd.backup();
|
---|
431 | m->bd->fIOAPICEnabled = enable;
|
---|
432 |
|
---|
433 | alock.release();
|
---|
434 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
435 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
436 |
|
---|
437 | return S_OK;
|
---|
438 | }
|
---|
439 |
|
---|
440 | STDMETHODIMP BIOSSettings::COMGETTER(PXEDebugEnabled)(BOOL *enabled)
|
---|
441 | {
|
---|
442 | if (!enabled)
|
---|
443 | return E_POINTER;
|
---|
444 |
|
---|
445 | AutoCaller autoCaller(this);
|
---|
446 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
447 |
|
---|
448 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
449 |
|
---|
450 | *enabled = m->bd->fPXEDebugEnabled;
|
---|
451 |
|
---|
452 | return S_OK;
|
---|
453 | }
|
---|
454 |
|
---|
455 | STDMETHODIMP BIOSSettings::COMSETTER(PXEDebugEnabled)(BOOL enable)
|
---|
456 | {
|
---|
457 | AutoCaller autoCaller(this);
|
---|
458 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
459 |
|
---|
460 | /* the machine needs to be mutable */
|
---|
461 | AutoMutableStateDependency adep(m->pMachine);
|
---|
462 | if (FAILED(adep.rc())) return adep.rc();
|
---|
463 |
|
---|
464 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
465 |
|
---|
466 | m->bd.backup();
|
---|
467 | m->bd->fPXEDebugEnabled = enable;
|
---|
468 |
|
---|
469 | alock.release();
|
---|
470 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
471 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
472 |
|
---|
473 | return S_OK;
|
---|
474 | }
|
---|
475 |
|
---|
476 | STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
|
---|
477 | {
|
---|
478 | if (!offset)
|
---|
479 | return E_POINTER;
|
---|
480 |
|
---|
481 | AutoCaller autoCaller(this);
|
---|
482 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
483 |
|
---|
484 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
485 |
|
---|
486 | *offset = m->bd->llTimeOffset;
|
---|
487 |
|
---|
488 | return S_OK;
|
---|
489 | }
|
---|
490 |
|
---|
491 | STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
|
---|
492 | {
|
---|
493 | AutoCaller autoCaller(this);
|
---|
494 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
495 |
|
---|
496 | /* the machine needs to be mutable */
|
---|
497 | AutoMutableStateDependency adep(m->pMachine);
|
---|
498 | if (FAILED(adep.rc())) return adep.rc();
|
---|
499 |
|
---|
500 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
501 |
|
---|
502 | m->bd.backup();
|
---|
503 | m->bd->llTimeOffset = offset;
|
---|
504 |
|
---|
505 | alock.release();
|
---|
506 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
507 | m->pMachine->setModified(Machine::IsModified_BIOS);
|
---|
508 |
|
---|
509 | return S_OK;
|
---|
510 | }
|
---|
511 |
|
---|
512 |
|
---|
513 | // IBIOSSettings methods
|
---|
514 | /////////////////////////////////////////////////////////////////////////////
|
---|
515 |
|
---|
516 | // public methods only for internal purposes
|
---|
517 | /////////////////////////////////////////////////////////////////////////////
|
---|
518 |
|
---|
519 | /**
|
---|
520 | * Loads settings from the given machine node.
|
---|
521 | * May be called once right after this object creation.
|
---|
522 | *
|
---|
523 | * @param aMachineNode <Machine> node.
|
---|
524 | *
|
---|
525 | * @note Locks this object for writing.
|
---|
526 | */
|
---|
527 | HRESULT BIOSSettings::loadSettings(const settings::BIOSSettings &data)
|
---|
528 | {
|
---|
529 | AutoCaller autoCaller(this);
|
---|
530 | AssertComRCReturnRC(autoCaller.rc());
|
---|
531 |
|
---|
532 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
533 |
|
---|
534 | // simply copy
|
---|
535 | *m->bd.data() = data;
|
---|
536 |
|
---|
537 | return S_OK;
|
---|
538 | }
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Saves settings to the given machine node.
|
---|
542 | *
|
---|
543 | * @param aMachineNode <Machine> node.
|
---|
544 | *
|
---|
545 | * @note Locks this object for reading.
|
---|
546 | */
|
---|
547 | HRESULT BIOSSettings::saveSettings(settings::BIOSSettings &data)
|
---|
548 | {
|
---|
549 | AutoCaller autoCaller(this);
|
---|
550 | AssertComRCReturnRC(autoCaller.rc());
|
---|
551 |
|
---|
552 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
553 |
|
---|
554 | data = *m->bd.data();
|
---|
555 |
|
---|
556 | return S_OK;
|
---|
557 | }
|
---|
558 |
|
---|
559 | void BIOSSettings::rollback()
|
---|
560 | {
|
---|
561 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
562 | m->bd.rollback();
|
---|
563 | }
|
---|
564 |
|
---|
565 | void BIOSSettings::commit()
|
---|
566 | {
|
---|
567 | /* sanity */
|
---|
568 | AutoCaller autoCaller(this);
|
---|
569 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
570 |
|
---|
571 | /* sanity too */
|
---|
572 | AutoCaller peerCaller(m->pPeer);
|
---|
573 | AssertComRCReturnVoid(peerCaller.rc());
|
---|
574 |
|
---|
575 | /* lock both for writing since we modify both (mPeer is "master" so locked
|
---|
576 | * first) */
|
---|
577 | AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
|
---|
578 |
|
---|
579 | if (m->bd.isBackedUp())
|
---|
580 | {
|
---|
581 | m->bd.commit();
|
---|
582 | if (m->pPeer)
|
---|
583 | {
|
---|
584 | /* attach new data to the peer and reshare it */
|
---|
585 | AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
|
---|
586 | m->pPeer->m->bd.attach(m->bd);
|
---|
587 | }
|
---|
588 | }
|
---|
589 | }
|
---|
590 |
|
---|
591 | void BIOSSettings::copyFrom (BIOSSettings *aThat)
|
---|
592 | {
|
---|
593 | AssertReturnVoid (aThat != NULL);
|
---|
594 |
|
---|
595 | /* sanity */
|
---|
596 | AutoCaller autoCaller(this);
|
---|
597 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
598 |
|
---|
599 | /* sanity too */
|
---|
600 | AutoCaller thatCaller (aThat);
|
---|
601 | AssertComRCReturnVoid (thatCaller.rc());
|
---|
602 |
|
---|
603 | /* peer is not modified, lock it for reading (aThat is "master" so locked
|
---|
604 | * first) */
|
---|
605 | AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
606 | AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
|
---|
607 |
|
---|
608 | /* this will back up current data */
|
---|
609 | m->bd.assignCopy(aThat->m->bd);
|
---|
610 | }
|
---|
611 |
|
---|
612 | void BIOSSettings::applyDefaults (GuestOSType *aOsType)
|
---|
613 | {
|
---|
614 | AssertReturnVoid (aOsType != NULL);
|
---|
615 |
|
---|
616 | /* sanity */
|
---|
617 | AutoCaller autoCaller(this);
|
---|
618 | AssertComRCReturnVoid (autoCaller.rc());
|
---|
619 |
|
---|
620 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
621 |
|
---|
622 | /* Initialize default BIOS settings here */
|
---|
623 | m->bd->fIOAPICEnabled = aOsType->recommendedIOAPIC();
|
---|
624 | }
|
---|
625 |
|
---|
626 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|