VirtualBox

source: vbox/trunk/src/VBox/Main/BIOSSettingsImpl.cpp@ 5528

Last change on this file since 5528 was 5361, checked in by vboxsync, 17 years ago

Added option to emulate PIIX4 IDE controller. Defaults to PIIX4 for new VMs
and to PIIX3 when no setting is present in XML.

  • Property svn:eol-style set to native
File size: 11.6 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "BIOSSettingsImpl.h"
19#include "MachineImpl.h"
20#include "Logging.h"
21#include <iprt/cpputils.h>
22
23// constructor / destructor
24/////////////////////////////////////////////////////////////////////////////
25
26HRESULT BIOSSettings::FinalConstruct()
27{
28 return S_OK;
29}
30
31void BIOSSettings::FinalRelease()
32{
33 uninit ();
34}
35
36// public initializer/uninitializer for internal purposes only
37/////////////////////////////////////////////////////////////////////////////
38
39/**
40 * Initializes the audio adapter object.
41 *
42 * @returns COM result indicator
43 */
44HRESULT BIOSSettings::init (Machine *aParent)
45{
46 LogFlowThisFuncEnter();
47 LogFlowThisFunc (("aParent: %p\n", aParent));
48
49 ComAssertRet (aParent, E_INVALIDARG);
50
51 /* Enclose the state transition NotReady->InInit->Ready */
52 AutoInitSpan autoInitSpan (this);
53 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
54
55 /* share the parent weakly */
56 unconst (mParent) = aParent;
57
58 mData.allocate();
59
60 autoInitSpan.setSucceeded();
61
62 LogFlowThisFuncLeave();
63 return S_OK;
64}
65
66/**
67 * Initializes the audio adapter object given another audio adapter object
68 * (a kind of copy constructor). This object shares data with
69 * the object passed as an argument.
70 *
71 * @note This object must be destroyed before the original object
72 * it shares data with is destroyed.
73 */
74HRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
75{
76 LogFlowThisFuncEnter();
77 LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
78
79 ComAssertRet (aParent && that, E_INVALIDARG);
80
81 /* Enclose the state transition NotReady->InInit->Ready */
82 AutoInitSpan autoInitSpan (this);
83 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
84
85 mParent = aParent;
86 mPeer = that;
87
88 AutoLock thatlock (that);
89 mData.share (that->mData);
90
91 autoInitSpan.setSucceeded();
92
93 LogFlowThisFuncLeave();
94 return S_OK;
95}
96
97/**
98 * Initializes the guest object given another guest object
99 * (a kind of copy constructor). This object makes a private copy of data
100 * of the original object passed as an argument.
101 */
102HRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
103{
104 LogFlowThisFuncEnter();
105 LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
106
107 ComAssertRet (aParent && that, E_INVALIDARG);
108
109 /* Enclose the state transition NotReady->InInit->Ready */
110 AutoInitSpan autoInitSpan (this);
111 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
112
113 mParent = aParent;
114 // mPeer is left null
115
116 AutoLock thatlock (that);
117 mData.attachCopy (that->mData);
118
119 autoInitSpan.setSucceeded();
120
121 LogFlowThisFuncLeave();
122 return S_OK;
123}
124
125/**
126 * Uninitializes the instance and sets the ready flag to FALSE.
127 * Called either from FinalRelease() or by the parent when it gets destroyed.
128 */
129void BIOSSettings::uninit()
130{
131 LogFlowThisFuncEnter();
132
133 /* Enclose the state transition Ready->InUninit->NotReady */
134 AutoUninitSpan autoUninitSpan (this);
135 if (autoUninitSpan.uninitDone())
136 return;
137
138 mData.free();
139
140 mPeer.setNull();
141 mParent.setNull();
142
143 LogFlowThisFuncLeave();
144}
145
146// IBIOSSettings properties
147/////////////////////////////////////////////////////////////////////////////
148
149STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
150{
151 if (!enabled)
152 return E_POINTER;
153
154 AutoCaller autoCaller (this);
155 CheckComRCReturnRC (autoCaller.rc());
156
157 AutoReaderLock alock (this);
158
159 *enabled = mData->mLogoFadeIn;
160
161 return S_OK;
162}
163
164STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
165{
166 AutoCaller autoCaller (this);
167 CheckComRCReturnRC (autoCaller.rc());
168
169 /* the machine needs to be mutable */
170 Machine::AutoMutableStateDependency adep (mParent);
171 CheckComRCReturnRC (adep.rc());
172
173 AutoLock alock (this);
174
175 mData.backup();
176 mData->mLogoFadeIn = enable;
177
178 return S_OK;
179}
180
181STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
182{
183 if (!enabled)
184 return E_POINTER;
185
186 AutoCaller autoCaller (this);
187 CheckComRCReturnRC (autoCaller.rc());
188
189 AutoReaderLock alock (this);
190
191 *enabled = mData->mLogoFadeOut;
192
193 return S_OK;
194}
195
196STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
197{
198 AutoCaller autoCaller (this);
199 CheckComRCReturnRC (autoCaller.rc());
200
201 /* the machine needs to be mutable */
202 Machine::AutoMutableStateDependency adep (mParent);
203 CheckComRCReturnRC (adep.rc());
204
205 AutoLock alock (this);
206
207 mData.backup();
208 mData->mLogoFadeOut = enable;
209
210 return S_OK;
211}
212
213STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
214{
215 if (!displayTime)
216 return E_POINTER;
217
218 AutoCaller autoCaller (this);
219 CheckComRCReturnRC (autoCaller.rc());
220
221 AutoReaderLock alock (this);
222
223 *displayTime = mData->mLogoDisplayTime;
224
225 return S_OK;
226}
227
228STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
229{
230 AutoCaller autoCaller (this);
231 CheckComRCReturnRC (autoCaller.rc());
232
233 /* the machine needs to be mutable */
234 Machine::AutoMutableStateDependency adep (mParent);
235 CheckComRCReturnRC (adep.rc());
236
237 AutoLock alock (this);
238
239 mData.backup();
240 mData->mLogoDisplayTime = displayTime;
241
242 return S_OK;
243}
244
245STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
246{
247 if (!imagePath)
248 return E_POINTER;
249
250 AutoCaller autoCaller (this);
251 CheckComRCReturnRC (autoCaller.rc());
252
253 AutoReaderLock alock (this);
254
255 mData->mLogoImagePath.cloneTo(imagePath);
256 return S_OK;
257}
258
259STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(INPTR BSTR imagePath)
260{
261 /* empty strings are not allowed as path names */
262 if (imagePath && !(*imagePath))
263 return E_INVALIDARG;
264
265 AutoCaller autoCaller (this);
266 CheckComRCReturnRC (autoCaller.rc());
267
268 /* the machine needs to be mutable */
269 Machine::AutoMutableStateDependency adep (mParent);
270 CheckComRCReturnRC (adep.rc());
271
272 AutoLock alock (this);
273
274 mData.backup();
275 mData->mLogoImagePath = imagePath;
276
277 return S_OK;
278}
279
280STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
281{
282 if (!bootMenuMode)
283 return E_POINTER;
284
285 AutoCaller autoCaller (this);
286 CheckComRCReturnRC (autoCaller.rc());
287
288 AutoReaderLock alock (this);
289
290 *bootMenuMode = mData->mBootMenuMode;
291 return S_OK;
292}
293
294STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
295{
296 AutoCaller autoCaller (this);
297 CheckComRCReturnRC (autoCaller.rc());
298
299 /* the machine needs to be mutable */
300 Machine::AutoMutableStateDependency adep (mParent);
301 CheckComRCReturnRC (adep.rc());
302
303 AutoLock alock (this);
304
305 mData.backup();
306 mData->mBootMenuMode = bootMenuMode;
307
308 return S_OK;
309}
310
311STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
312{
313 if (!enabled)
314 return E_POINTER;
315
316 AutoCaller autoCaller (this);
317 CheckComRCReturnRC (autoCaller.rc());
318
319 AutoReaderLock alock (this);
320
321 *enabled = mData->mACPIEnabled;
322
323 return S_OK;
324}
325
326STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
327{
328 AutoCaller autoCaller (this);
329 CheckComRCReturnRC (autoCaller.rc());
330
331 /* the machine needs to be mutable */
332 Machine::AutoMutableStateDependency adep (mParent);
333 CheckComRCReturnRC (adep.rc());
334
335 AutoLock alock (this);
336
337 mData.backup();
338 mData->mACPIEnabled = enable;
339
340 return S_OK;
341}
342
343STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
344{
345 if (!enabled)
346 return E_POINTER;
347
348 AutoCaller autoCaller (this);
349 CheckComRCReturnRC (autoCaller.rc());
350
351 AutoReaderLock alock (this);
352
353 *enabled = mData->mIOAPICEnabled;
354
355 return S_OK;
356}
357
358STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
359{
360 AutoCaller autoCaller (this);
361 CheckComRCReturnRC (autoCaller.rc());
362
363 /* the machine needs to be mutable */
364 Machine::AutoMutableStateDependency adep (mParent);
365 CheckComRCReturnRC (adep.rc());
366
367 AutoLock alock (this);
368
369 mData.backup();
370 mData->mIOAPICEnabled = enable;
371
372 return S_OK;
373}
374
375STDMETHODIMP BIOSSettings::COMGETTER(PXEDebugEnabled)(BOOL *enabled)
376{
377 if (!enabled)
378 return E_POINTER;
379
380 AutoCaller autoCaller (this);
381 CheckComRCReturnRC (autoCaller.rc());
382
383 AutoReaderLock alock (this);
384
385 *enabled = mData->mPXEDebugEnabled;
386
387 return S_OK;
388}
389
390STDMETHODIMP BIOSSettings::COMSETTER(PXEDebugEnabled)(BOOL enable)
391{
392 AutoCaller autoCaller (this);
393 CheckComRCReturnRC (autoCaller.rc());
394
395 /* the machine needs to be mutable */
396 Machine::AutoMutableStateDependency adep (mParent);
397 CheckComRCReturnRC (adep.rc());
398
399 AutoLock alock (this);
400
401 mData.backup();
402 mData->mPXEDebugEnabled = enable;
403
404 return S_OK;
405}
406
407STDMETHODIMP BIOSSettings::COMGETTER(IDEControllerType)(IDEControllerType_T *aControllerType)
408{
409 if (!aControllerType)
410 return E_POINTER;
411
412 AutoCaller autoCaller (this);
413 CheckComRCReturnRC (autoCaller.rc());
414
415 AutoReaderLock alock (this);
416
417 *aControllerType = mData->mIDEControllerType;
418
419 return S_OK;
420}
421
422STDMETHODIMP BIOSSettings::COMSETTER(IDEControllerType)(IDEControllerType_T aControllerType)
423{
424 AutoCaller autoCaller (this);
425 CheckComRCReturnRC (autoCaller.rc());
426
427 /* the machine needs to be mutable */
428 Machine::AutoMutableStateDependency adep (mParent);
429 CheckComRCReturnRC (adep.rc());
430
431 AutoLock alock (this);
432
433 /* make sure the value is allowed */
434 switch (aControllerType)
435 {
436 case IDEControllerType_IDEControllerPIIX3:
437 case IDEControllerType_IDEControllerPIIX4:
438 break;
439 default:
440 return setError (E_FAIL,
441 tr("Invalid IDE controller type '%d'"),
442 aControllerType);
443 }
444
445 mData.backup();
446
447 mData->mIDEControllerType = aControllerType;
448
449 return S_OK;
450}
451
452STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
453{
454 if (!offset)
455 return E_POINTER;
456
457 AutoCaller autoCaller (this);
458 CheckComRCReturnRC (autoCaller.rc());
459
460 AutoReaderLock alock (this);
461
462 *offset = mData->mTimeOffset;
463
464 return S_OK;
465}
466
467STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
468{
469 AutoCaller autoCaller (this);
470 CheckComRCReturnRC (autoCaller.rc());
471
472 /* the machine needs to be mutable */
473 Machine::AutoMutableStateDependency adep (mParent);
474 CheckComRCReturnRC (adep.rc());
475
476 AutoLock alock (this);
477
478 mData.backup();
479 mData->mTimeOffset = offset;
480
481 return S_OK;
482}
483
484
485// IBIOSSettings methods
486/////////////////////////////////////////////////////////////////////////////
487
488// public methods only for internal purposes
489/////////////////////////////////////////////////////////////////////////////
490
491void BIOSSettings::commit()
492{
493 AutoLock alock (this);
494 if (mData.isBackedUp())
495 {
496 mData.commit();
497 if (mPeer)
498 {
499 // attach new data to the peer and reshare it
500 AutoLock peerlock (mPeer);
501 mPeer->mData.attach (mData);
502 }
503 }
504}
505
506void BIOSSettings::copyFrom (BIOSSettings *aThat)
507{
508 AutoLock alock (this);
509
510 // this will back up current data
511 mData.assignCopy (aThat->mData);
512}
513
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette