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