1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
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 |
|
---|
18 | #include "GuestOSTypeImpl.h"
|
---|
19 | #include "AutoCaller.h"
|
---|
20 | #include "Logging.h"
|
---|
21 | #include <iprt/cpp/utils.h>
|
---|
22 |
|
---|
23 | // constructor / destructor
|
---|
24 | /////////////////////////////////////////////////////////////////////////////
|
---|
25 |
|
---|
26 | GuestOSType::GuestOSType()
|
---|
27 | : mOSType(VBOXOSTYPE_Unknown)
|
---|
28 | , mOSHint(VBOXOSHINT_NONE)
|
---|
29 | , mRAMSize(0), mVRAMSize(0)
|
---|
30 | , mHDDSize(0), mMonitorCount(0)
|
---|
31 | , mNetworkAdapterType(NetworkAdapterType_Am79C973)
|
---|
32 | , mNumSerialEnabled(0)
|
---|
33 | , mDvdStorageControllerType(StorageControllerType_PIIX3)
|
---|
34 | , mDvdStorageBusType(StorageBus_IDE)
|
---|
35 | , mHdStorageControllerType(StorageControllerType_PIIX3)
|
---|
36 | , mHdStorageBusType(StorageBus_IDE)
|
---|
37 | , mChipsetType(ChipsetType_PIIX3)
|
---|
38 | , mAudioControllerType(AudioControllerType_AC97)
|
---|
39 | {
|
---|
40 | }
|
---|
41 |
|
---|
42 | GuestOSType::~GuestOSType()
|
---|
43 | {
|
---|
44 | }
|
---|
45 |
|
---|
46 | HRESULT GuestOSType::FinalConstruct()
|
---|
47 | {
|
---|
48 | return S_OK;
|
---|
49 | }
|
---|
50 |
|
---|
51 | void GuestOSType::FinalRelease()
|
---|
52 | {
|
---|
53 | uninit();
|
---|
54 | }
|
---|
55 |
|
---|
56 | // public initializer/uninitializer for internal purposes only
|
---|
57 | /////////////////////////////////////////////////////////////////////////////
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Initializes the guest OS type object.
|
---|
61 | *
|
---|
62 | * @returns COM result indicator
|
---|
63 | * @param aFamilyId os family short name string
|
---|
64 | * @param aFamilyDescription os family name string
|
---|
65 | * @param aId os short name string
|
---|
66 | * @param aDescription os name string
|
---|
67 | * @param aOSType global OS type ID
|
---|
68 | * @param aOSHint os configuration hint
|
---|
69 | * @param aRAMSize recommended RAM size in megabytes
|
---|
70 | * @param aVRAMSize recommended video memory size in megabytes
|
---|
71 | * @param aHDDSize recommended HDD size in bytes
|
---|
72 | */
|
---|
73 | HRESULT GuestOSType::init(const Global::OSType &ostype)/*const char *aFamilyId, const char *aFamilyDescription,
|
---|
74 | const char *aId, const char *aDescription,
|
---|
75 | VBOXOSTYPE aOSType, uint32_t aOSHint,
|
---|
76 | uint32_t aRAMSize, uint32_t aVRAMSize, uint64_t aHDDSize,
|
---|
77 | NetworkAdapterType_T aNetworkAdapterType,
|
---|
78 | uint32_t aNumSerialEnabled,
|
---|
79 | StorageControllerType_T aDvdStorageControllerType,
|
---|
80 | StorageBus_T aDvdStorageBusType,
|
---|
81 | StorageControllerType_T aHdStorageControllerType,
|
---|
82 | StorageBus_T aHdStorageBusType,
|
---|
83 | ChipsetType_T aChipsetType
|
---|
84 | AudioControllerType_T aAudioControllerType*/
|
---|
85 | {
|
---|
86 | #if 0
|
---|
87 | LogFlowThisFunc(("aFamilyId='%s', aFamilyDescription='%s', "
|
---|
88 | "aId='%s', aDescription='%s', "
|
---|
89 | "aType=%d, aOSHint=%x, "
|
---|
90 | "aRAMSize=%d, aVRAMSize=%d, aHDDSize=%lld, "
|
---|
91 | "aNetworkAdapterType=%d, aNumSerialEnabled=%d, "
|
---|
92 | "aStorageControllerType=%d\n",
|
---|
93 | aFamilyId, aFamilyDescription,
|
---|
94 | aId, aDescription,
|
---|
95 | aOSType, aOSHint,
|
---|
96 | aRAMSize, aVRAMSize, aHDDSize,
|
---|
97 | aNetworkAdapterType,
|
---|
98 | aNumSerialEnabled,
|
---|
99 | aStorageControllerType));
|
---|
100 | #endif
|
---|
101 |
|
---|
102 | ComAssertRet(ostype.familyId && ostype.familyDescription && ostype.id && ostype.description, E_INVALIDARG);
|
---|
103 |
|
---|
104 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
105 | AutoInitSpan autoInitSpan(this);
|
---|
106 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
107 |
|
---|
108 | unconst(mFamilyID) = ostype.familyId;
|
---|
109 | unconst(mFamilyDescription) = ostype.familyDescription;
|
---|
110 | unconst(mID) = ostype.id;
|
---|
111 | unconst(mDescription) = ostype.description;
|
---|
112 | unconst(mOSType) = ostype.osType;
|
---|
113 | unconst(mOSHint) = ostype.osHint;
|
---|
114 | unconst(mRAMSize) = ostype.recommendedRAM;
|
---|
115 | unconst(mVRAMSize) = ostype.recommendedVRAM;
|
---|
116 | unconst(mHDDSize) = ostype.recommendedHDD;
|
---|
117 | unconst(mNetworkAdapterType) = ostype.networkAdapterType;
|
---|
118 | unconst(mNumSerialEnabled) = ostype.numSerialEnabled;
|
---|
119 | unconst(mDvdStorageControllerType) = ostype.dvdStorageControllerType;
|
---|
120 | unconst(mDvdStorageBusType) = ostype.dvdStorageBusType;
|
---|
121 | unconst(mHdStorageControllerType) = ostype.hdStorageControllerType;
|
---|
122 | unconst(mHdStorageBusType) = ostype.hdStorageBusType;
|
---|
123 | unconst(mChipsetType) = ostype.chipsetType;
|
---|
124 | unconst(mAudioControllerType) = ostype.audioControllerType;
|
---|
125 |
|
---|
126 | /* Confirm a successful initialization when it's the case */
|
---|
127 | autoInitSpan.setSucceeded();
|
---|
128 |
|
---|
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 GuestOSType::uninit()
|
---|
137 | {
|
---|
138 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
139 | AutoUninitSpan autoUninitSpan(this);
|
---|
140 | if (autoUninitSpan.uninitDone())
|
---|
141 | return;
|
---|
142 | }
|
---|
143 |
|
---|
144 | // IGuestOSType properties
|
---|
145 | /////////////////////////////////////////////////////////////////////////////
|
---|
146 |
|
---|
147 | STDMETHODIMP GuestOSType::COMGETTER(FamilyId)(BSTR *aFamilyId)
|
---|
148 | {
|
---|
149 | CheckComArgOutPointerValid(aFamilyId);
|
---|
150 |
|
---|
151 | AutoCaller autoCaller(this);
|
---|
152 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
153 |
|
---|
154 | /* mFamilyID is constant during life time, no need to lock */
|
---|
155 | mFamilyID.cloneTo(aFamilyId);
|
---|
156 |
|
---|
157 | return S_OK;
|
---|
158 | }
|
---|
159 |
|
---|
160 | STDMETHODIMP GuestOSType::COMGETTER(FamilyDescription)(BSTR *aFamilyDescription)
|
---|
161 | {
|
---|
162 | CheckComArgOutPointerValid(aFamilyDescription);
|
---|
163 |
|
---|
164 | AutoCaller autoCaller(this);
|
---|
165 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
166 |
|
---|
167 | /* mFamilyDescription is constant during life time, no need to lock */
|
---|
168 | mFamilyDescription.cloneTo(aFamilyDescription);
|
---|
169 |
|
---|
170 | return S_OK;
|
---|
171 | }
|
---|
172 |
|
---|
173 | STDMETHODIMP GuestOSType::COMGETTER(Id)(BSTR *aId)
|
---|
174 | {
|
---|
175 | CheckComArgOutPointerValid(aId);
|
---|
176 |
|
---|
177 | AutoCaller autoCaller(this);
|
---|
178 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
179 |
|
---|
180 | /* mID is constant during life time, no need to lock */
|
---|
181 | mID.cloneTo(aId);
|
---|
182 |
|
---|
183 | return S_OK;
|
---|
184 | }
|
---|
185 |
|
---|
186 | STDMETHODIMP GuestOSType::COMGETTER(Description)(BSTR *aDescription)
|
---|
187 | {
|
---|
188 | CheckComArgOutPointerValid(aDescription);
|
---|
189 |
|
---|
190 | AutoCaller autoCaller(this);
|
---|
191 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
192 |
|
---|
193 | /* mDescription is constant during life time, no need to lock */
|
---|
194 | mDescription.cloneTo(aDescription);
|
---|
195 |
|
---|
196 | return S_OK;
|
---|
197 | }
|
---|
198 |
|
---|
199 | STDMETHODIMP GuestOSType::COMGETTER(Is64Bit)(BOOL *aIs64Bit)
|
---|
200 | {
|
---|
201 | CheckComArgOutPointerValid(aIs64Bit);
|
---|
202 |
|
---|
203 | AutoCaller autoCaller(this);
|
---|
204 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
205 |
|
---|
206 | /* mIs64Bit is constant during life time, no need to lock */
|
---|
207 | *aIs64Bit = !!(mOSHint & VBOXOSHINT_64BIT);
|
---|
208 |
|
---|
209 | return S_OK;
|
---|
210 | }
|
---|
211 |
|
---|
212 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedIOAPIC)(BOOL *aRecommendedIOAPIC)
|
---|
213 | {
|
---|
214 | CheckComArgOutPointerValid(aRecommendedIOAPIC);
|
---|
215 |
|
---|
216 | AutoCaller autoCaller(this);
|
---|
217 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
218 |
|
---|
219 | /* mRecommendedIOAPIC is constant during life time, no need to lock */
|
---|
220 | *aRecommendedIOAPIC = !!(mOSHint & VBOXOSHINT_IOAPIC);
|
---|
221 |
|
---|
222 | return S_OK;
|
---|
223 | }
|
---|
224 |
|
---|
225 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedVirtEx)(BOOL *aRecommendedVirtEx)
|
---|
226 | {
|
---|
227 | CheckComArgOutPointerValid(aRecommendedVirtEx);
|
---|
228 |
|
---|
229 | AutoCaller autoCaller(this);
|
---|
230 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
231 |
|
---|
232 | /* mRecommendedVirtEx is constant during life time, no need to lock */
|
---|
233 | *aRecommendedVirtEx = !!(mOSHint & VBOXOSHINT_HWVIRTEX);
|
---|
234 |
|
---|
235 | return S_OK;
|
---|
236 | }
|
---|
237 |
|
---|
238 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedRAM)(ULONG *aRAMSize)
|
---|
239 | {
|
---|
240 | CheckComArgOutPointerValid(aRAMSize);
|
---|
241 |
|
---|
242 | AutoCaller autoCaller(this);
|
---|
243 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
244 |
|
---|
245 | /* mRAMSize is constant during life time, no need to lock */
|
---|
246 | *aRAMSize = mRAMSize;
|
---|
247 |
|
---|
248 | return S_OK;
|
---|
249 | }
|
---|
250 |
|
---|
251 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedVRAM)(ULONG *aVRAMSize)
|
---|
252 | {
|
---|
253 | CheckComArgOutPointerValid(aVRAMSize);
|
---|
254 |
|
---|
255 | AutoCaller autoCaller(this);
|
---|
256 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
257 |
|
---|
258 | /* mVRAMSize is constant during life time, no need to lock */
|
---|
259 | *aVRAMSize = mVRAMSize;
|
---|
260 |
|
---|
261 | return S_OK;
|
---|
262 | }
|
---|
263 |
|
---|
264 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHDD)(LONG64 *aHDDSize)
|
---|
265 | {
|
---|
266 | CheckComArgOutPointerValid(aHDDSize);
|
---|
267 |
|
---|
268 | AutoCaller autoCaller(this);
|
---|
269 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
270 |
|
---|
271 | /* mHDDSize is constant during life time, no need to lock */
|
---|
272 | *aHDDSize = mHDDSize;
|
---|
273 |
|
---|
274 | return S_OK;
|
---|
275 | }
|
---|
276 |
|
---|
277 | STDMETHODIMP GuestOSType::COMGETTER(AdapterType)(NetworkAdapterType_T *aNetworkAdapterType)
|
---|
278 | {
|
---|
279 | CheckComArgOutPointerValid(aNetworkAdapterType);
|
---|
280 |
|
---|
281 | AutoCaller autoCaller(this);
|
---|
282 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
283 |
|
---|
284 | /* mNetworkAdapterType is constant during life time, no need to lock */
|
---|
285 | *aNetworkAdapterType = mNetworkAdapterType;
|
---|
286 |
|
---|
287 | return S_OK;
|
---|
288 | }
|
---|
289 |
|
---|
290 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedPae)(BOOL *aRecommendedPae)
|
---|
291 | {
|
---|
292 | CheckComArgOutPointerValid(aRecommendedPae);
|
---|
293 |
|
---|
294 | AutoCaller autoCaller(this);
|
---|
295 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
296 |
|
---|
297 | /* recommended PAE is constant during life time, no need to lock */
|
---|
298 | *aRecommendedPae = !!(mOSHint & VBOXOSHINT_PAE);
|
---|
299 |
|
---|
300 | return S_OK;
|
---|
301 | }
|
---|
302 |
|
---|
303 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedFirmware)(FirmwareType_T *aFirmwareType)
|
---|
304 | {
|
---|
305 | CheckComArgOutPointerValid(aFirmwareType);
|
---|
306 |
|
---|
307 | AutoCaller autoCaller(this);
|
---|
308 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
309 |
|
---|
310 | /* firmware type is constant during life time, no need to lock */
|
---|
311 | if (mOSHint & VBOXOSHINT_EFI)
|
---|
312 | *aFirmwareType = FirmwareType_EFI;
|
---|
313 | else
|
---|
314 | *aFirmwareType = FirmwareType_BIOS;
|
---|
315 |
|
---|
316 | return S_OK;
|
---|
317 | }
|
---|
318 |
|
---|
319 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedDvdStorageController)(StorageControllerType_T * aStorageControllerType)
|
---|
320 | {
|
---|
321 | CheckComArgOutPointerValid(aStorageControllerType);
|
---|
322 |
|
---|
323 | AutoCaller autoCaller(this);
|
---|
324 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
325 |
|
---|
326 | /* storage controller type is constant during life time, no need to lock */
|
---|
327 | *aStorageControllerType = mDvdStorageControllerType;
|
---|
328 |
|
---|
329 | return S_OK;
|
---|
330 | }
|
---|
331 |
|
---|
332 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedDvdStorageBus)(StorageBus_T * aStorageBusType)
|
---|
333 | {
|
---|
334 | CheckComArgOutPointerValid(aStorageBusType);
|
---|
335 |
|
---|
336 | AutoCaller autoCaller(this);
|
---|
337 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
338 |
|
---|
339 | /* storage controller type is constant during life time, no need to lock */
|
---|
340 | *aStorageBusType = mDvdStorageBusType;
|
---|
341 |
|
---|
342 | return S_OK;
|
---|
343 | }
|
---|
344 |
|
---|
345 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHdStorageController)(StorageControllerType_T * aStorageControllerType)
|
---|
346 | {
|
---|
347 | CheckComArgOutPointerValid(aStorageControllerType);
|
---|
348 |
|
---|
349 | AutoCaller autoCaller(this);
|
---|
350 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
351 |
|
---|
352 | /* storage controller type is constant during life time, no need to lock */
|
---|
353 | *aStorageControllerType = mHdStorageControllerType;
|
---|
354 |
|
---|
355 | return S_OK;
|
---|
356 | }
|
---|
357 |
|
---|
358 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHdStorageBus)(StorageBus_T * aStorageBusType)
|
---|
359 | {
|
---|
360 | CheckComArgOutPointerValid(aStorageBusType);
|
---|
361 |
|
---|
362 | AutoCaller autoCaller(this);
|
---|
363 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
364 |
|
---|
365 | /* storage controller type is constant during life time, no need to lock */
|
---|
366 | *aStorageBusType = mHdStorageBusType;
|
---|
367 |
|
---|
368 | return S_OK;
|
---|
369 | }
|
---|
370 |
|
---|
371 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedUsbHid)(BOOL *aRecommendedUsbHid)
|
---|
372 | {
|
---|
373 | CheckComArgOutPointerValid(aRecommendedUsbHid);
|
---|
374 |
|
---|
375 | AutoCaller autoCaller(this);
|
---|
376 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
377 |
|
---|
378 | /* HID type is constant during life time, no need to lock */
|
---|
379 | *aRecommendedUsbHid = !!(mOSHint & VBOXOSHINT_USBHID);
|
---|
380 |
|
---|
381 | return S_OK;
|
---|
382 | }
|
---|
383 |
|
---|
384 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedHpet)(BOOL *aRecommendedHpet)
|
---|
385 | {
|
---|
386 | CheckComArgOutPointerValid(aRecommendedHpet);
|
---|
387 |
|
---|
388 | AutoCaller autoCaller(this);
|
---|
389 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
390 |
|
---|
391 | /* HPET recommendation is constant during life time, no need to lock */
|
---|
392 | *aRecommendedHpet = !!(mOSHint & VBOXOSHINT_HPET);
|
---|
393 |
|
---|
394 | return S_OK;
|
---|
395 | }
|
---|
396 |
|
---|
397 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedUsbTablet)(BOOL *aRecommendedUsbTablet)
|
---|
398 | {
|
---|
399 | CheckComArgOutPointerValid(aRecommendedUsbTablet);
|
---|
400 |
|
---|
401 | AutoCaller autoCaller(this);
|
---|
402 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
403 |
|
---|
404 | /* HID type is constant during life time, no need to lock */
|
---|
405 | *aRecommendedUsbTablet = !!(mOSHint & VBOXOSHINT_USBTABLET);
|
---|
406 |
|
---|
407 | return S_OK;
|
---|
408 | }
|
---|
409 |
|
---|
410 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedRtcUseUtc)(BOOL *aRecommendedRtcUseUtc)
|
---|
411 | {
|
---|
412 | CheckComArgOutPointerValid(aRecommendedRtcUseUtc);
|
---|
413 |
|
---|
414 | AutoCaller autoCaller(this);
|
---|
415 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
416 |
|
---|
417 | /* HID type is constant during life time, no need to lock */
|
---|
418 | *aRecommendedRtcUseUtc = !!(mOSHint & VBOXOSHINT_RTCUTC);
|
---|
419 |
|
---|
420 | return S_OK;
|
---|
421 | }
|
---|
422 |
|
---|
423 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedChipset) (ChipsetType_T *aChipsetType)
|
---|
424 | {
|
---|
425 | CheckComArgOutPointerValid(aChipsetType);
|
---|
426 |
|
---|
427 | AutoCaller autoCaller(this);
|
---|
428 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
429 |
|
---|
430 | /* chipset type is constant during life time, no need to lock */
|
---|
431 | *aChipsetType = mChipsetType;
|
---|
432 |
|
---|
433 | return S_OK;
|
---|
434 | }
|
---|
435 |
|
---|
436 | STDMETHODIMP GuestOSType::COMGETTER(RecommendedAudioController) (AudioControllerType_T *aAudioController)
|
---|
437 | {
|
---|
438 | CheckComArgOutPointerValid(aAudioController);
|
---|
439 |
|
---|
440 | AutoCaller autoCaller(this);
|
---|
441 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
442 |
|
---|
443 | *aAudioController = mAudioControllerType;
|
---|
444 |
|
---|
445 | return S_OK;
|
---|
446 | }
|
---|
447 |
|
---|
448 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|