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