VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/GuestOSTypeImpl.cpp@ 73768

Last change on this file since 73768 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.7 KB
Line 
1/* $Id: GuestOSTypeImpl.cpp 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 *
4 * VirtualBox COM class implementation
5 */
6
7/*
8 * Copyright (C) 2006-2017 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#include "GuestOSTypeImpl.h"
20#include "AutoCaller.h"
21#include "Logging.h"
22#include <iprt/cpp/utils.h>
23
24// constructor / destructor
25/////////////////////////////////////////////////////////////////////////////
26
27GuestOSType::GuestOSType()
28 : mOSType(VBOXOSTYPE_Unknown)
29 , mOSHint(VBOXOSHINT_NONE)
30 , mRAMSize(0), mVRAMSize(0)
31 , mHDDSize(0), mMonitorCount(0)
32 , mNetworkAdapterType(NetworkAdapterType_Am79C973)
33 , mNumSerialEnabled(0)
34 , mDVDStorageControllerType(StorageControllerType_PIIX3)
35 , mDVDStorageBusType(StorageBus_IDE)
36 , mHDStorageControllerType(StorageControllerType_PIIX3)
37 , mHDStorageBusType(StorageBus_IDE)
38 , mChipsetType(ChipsetType_PIIX3)
39 , mAudioControllerType(AudioControllerType_AC97)
40 , mAudioCodecType(AudioCodecType_STAC9700)
41{
42}
43
44GuestOSType::~GuestOSType()
45{
46}
47
48HRESULT GuestOSType::FinalConstruct()
49{
50 return BaseFinalConstruct();
51}
52
53void GuestOSType::FinalRelease()
54{
55 uninit();
56
57 BaseFinalRelease();
58}
59
60// public initializer/uninitializer for internal purposes only
61/////////////////////////////////////////////////////////////////////////////
62
63/**
64 * Initializes the guest OS type object.
65 *
66 * @returns COM result indicator
67 * @param ostype containing the following parts:
68 * @a aFamilyId os family short name string
69 * @a aFamilyDescription os family name string
70 * @a aId os short name string
71 * @a aDescription os name string
72 * @a aOSType global OS type ID
73 * @a aOSHint os configuration hint
74 * @a aRAMSize recommended RAM size in megabytes
75 * @a aVRAMSize recommended video memory size in megabytes
76 * @a aHDDSize recommended HDD size in bytes
77 */
78HRESULT GuestOSType::init(const Global::OSType &ostype)
79{
80 ComAssertRet(ostype.familyId && ostype.familyDescription && ostype.id && ostype.description, E_INVALIDARG);
81
82 /* Enclose the state transition NotReady->InInit->Ready */
83 AutoInitSpan autoInitSpan(this);
84 AssertReturn(autoInitSpan.isOk(), E_FAIL);
85
86 unconst(mFamilyID) = ostype.familyId;
87 unconst(mFamilyDescription) = ostype.familyDescription;
88 unconst(mID) = ostype.id;
89 unconst(mDescription) = ostype.description;
90 unconst(mOSType) = ostype.osType;
91 unconst(mOSHint) = ostype.osHint;
92 unconst(mRAMSize) = ostype.recommendedRAM;
93 unconst(mVRAMSize) = ostype.recommendedVRAM;
94 unconst(mHDDSize) = ostype.recommendedHDD;
95 unconst(mNetworkAdapterType) = ostype.networkAdapterType;
96 unconst(mNumSerialEnabled) = ostype.numSerialEnabled;
97 unconst(mDVDStorageControllerType) = ostype.dvdStorageControllerType;
98 unconst(mDVDStorageBusType) = ostype.dvdStorageBusType;
99 unconst(mHDStorageControllerType) = ostype.hdStorageControllerType;
100 unconst(mHDStorageBusType) = ostype.hdStorageBusType;
101 unconst(mChipsetType) = ostype.chipsetType;
102 unconst(mAudioControllerType) = ostype.audioControllerType;
103 unconst(mAudioCodecType) = ostype.audioCodecType;
104
105 /* Confirm a successful initialization when it's the case */
106 autoInitSpan.setSucceeded();
107
108 return S_OK;
109}
110
111/**
112 * Uninitializes the instance and sets the ready flag to FALSE.
113 * Called either from FinalRelease() or by the parent when it gets destroyed.
114 */
115void GuestOSType::uninit()
116{
117 /* Enclose the state transition Ready->InUninit->NotReady */
118 AutoUninitSpan autoUninitSpan(this);
119 if (autoUninitSpan.uninitDone())
120 return;
121}
122
123// IGuestOSType properties
124/////////////////////////////////////////////////////////////////////////////
125
126HRESULT GuestOSType::getFamilyId(com::Utf8Str &aFamilyId)
127{
128 /* mFamilyID is constant during life time, no need to lock */
129 aFamilyId = mFamilyID;
130 return S_OK;
131}
132
133
134HRESULT GuestOSType::getFamilyDescription(com::Utf8Str &aFamilyDescription)
135{
136 /* mFamilyDescription is constant during life time, no need to lock */
137 aFamilyDescription = mFamilyDescription;
138
139 return S_OK;
140}
141
142
143HRESULT GuestOSType::getId(com::Utf8Str &aId)
144{
145 /* mID is constant during life time, no need to lock */
146 aId = mID;
147
148 return S_OK;
149}
150
151
152HRESULT GuestOSType::getDescription(com::Utf8Str &aDescription)
153{
154 /* mDescription is constant during life time, no need to lock */
155 aDescription = mDescription;
156
157 return S_OK;
158}
159
160HRESULT GuestOSType::getIs64Bit(BOOL *aIs64Bit)
161{
162 /* mIs64Bit is constant during life time, no need to lock */
163 *aIs64Bit = !!(mOSHint & VBOXOSHINT_64BIT);
164
165 return S_OK;
166}
167
168HRESULT GuestOSType::getRecommendedIOAPIC(BOOL *aRecommendedIOAPIC)
169{
170 /* mRecommendedIOAPIC is constant during life time, no need to lock */
171 *aRecommendedIOAPIC = !!(mOSHint & VBOXOSHINT_IOAPIC);
172
173 return S_OK;
174}
175
176
177HRESULT GuestOSType::getRecommendedVirtEx(BOOL *aRecommendedVirtEx)
178{
179 /* mRecommendedVirtEx is constant during life time, no need to lock */
180 *aRecommendedVirtEx = !!(mOSHint & VBOXOSHINT_HWVIRTEX);
181
182 return S_OK;
183}
184
185
186HRESULT GuestOSType::getRecommendedRAM(ULONG *aRAMSize)
187{
188 /* mRAMSize is constant during life time, no need to lock */
189 *aRAMSize = mRAMSize;
190
191 return S_OK;
192}
193
194
195HRESULT GuestOSType::getRecommendedVRAM(ULONG *aVRAMSize)
196{
197 /* mVRAMSize is constant during life time, no need to lock */
198 *aVRAMSize = mVRAMSize;
199
200 return S_OK;
201}
202
203
204HRESULT GuestOSType::getRecommended2DVideoAcceleration(BOOL *aRecommended2DVideoAcceleration)
205{
206 /* Constant during life time, no need to lock */
207 *aRecommended2DVideoAcceleration = !!(mOSHint & VBOXOSHINT_ACCEL2D);
208
209 return S_OK;
210}
211
212
213HRESULT GuestOSType::getRecommended3DAcceleration(BOOL *aRecommended3DAcceleration)
214{
215 /* Constant during life time, no need to lock */
216 *aRecommended3DAcceleration = !!(mOSHint & VBOXOSHINT_ACCEL3D);
217
218 return S_OK;
219}
220
221
222HRESULT GuestOSType::getRecommendedHDD(LONG64 *aHDDSize)
223{
224 /* mHDDSize is constant during life time, no need to lock */
225 *aHDDSize = mHDDSize;
226
227 return S_OK;
228}
229
230
231HRESULT GuestOSType::getAdapterType(NetworkAdapterType_T *aNetworkAdapterType)
232{
233 /* mNetworkAdapterType is constant during life time, no need to lock */
234 *aNetworkAdapterType = mNetworkAdapterType;
235
236 return S_OK;
237}
238
239HRESULT GuestOSType::getRecommendedPAE(BOOL *aRecommendedPAE)
240{
241 /* recommended PAE is constant during life time, no need to lock */
242 *aRecommendedPAE = !!(mOSHint & VBOXOSHINT_PAE);
243
244 return S_OK;
245}
246
247
248HRESULT GuestOSType::getRecommendedFirmware(FirmwareType_T *aFirmwareType)
249{
250 /* firmware type is constant during life time, no need to lock */
251 if (mOSHint & VBOXOSHINT_EFI)
252 *aFirmwareType = FirmwareType_EFI;
253 else
254 *aFirmwareType = FirmwareType_BIOS;
255
256 return S_OK;
257}
258
259
260HRESULT GuestOSType::getRecommendedDVDStorageController(StorageControllerType_T *aStorageControllerType)
261{
262 /* storage controller type is constant during life time, no need to lock */
263 *aStorageControllerType = mDVDStorageControllerType;
264
265 return S_OK;
266}
267
268
269HRESULT GuestOSType::getRecommendedDVDStorageBus(StorageBus_T *aStorageBusType)
270{
271 /* storage controller type is constant during life time, no need to lock */
272 *aStorageBusType = mDVDStorageBusType;
273
274 return S_OK;
275}
276
277
278HRESULT GuestOSType::getRecommendedHDStorageController(StorageControllerType_T *aStorageControllerType)
279{
280 /* storage controller type is constant during life time, no need to lock */
281 *aStorageControllerType = mHDStorageControllerType;
282
283 return S_OK;
284}
285
286
287HRESULT GuestOSType::getRecommendedHDStorageBus(StorageBus_T *aStorageBusType)
288{
289 /* storage controller type is constant during life time, no need to lock */
290 *aStorageBusType = mHDStorageBusType;
291
292 return S_OK;
293}
294
295
296HRESULT GuestOSType::getRecommendedUSBHID(BOOL *aRecommendedUSBHID)
297{
298 /* HID type is constant during life time, no need to lock */
299 *aRecommendedUSBHID = !!(mOSHint & VBOXOSHINT_USBHID);
300
301 return S_OK;
302}
303
304
305HRESULT GuestOSType::getRecommendedHPET(BOOL *aRecommendedHPET)
306{
307 /* HPET recommendation is constant during life time, no need to lock */
308 *aRecommendedHPET = !!(mOSHint & VBOXOSHINT_HPET);
309
310 return S_OK;
311}
312
313
314HRESULT GuestOSType::getRecommendedUSBTablet(BOOL *aRecommendedUSBTablet)
315{
316 /* HID type is constant during life time, no need to lock */
317 *aRecommendedUSBTablet = !!(mOSHint & VBOXOSHINT_USBTABLET);
318
319 return S_OK;
320}
321
322
323HRESULT GuestOSType::getRecommendedRTCUseUTC(BOOL *aRecommendedRTCUseUTC)
324{
325 /* Value is constant during life time, no need to lock */
326 *aRecommendedRTCUseUTC = !!(mOSHint & VBOXOSHINT_RTCUTC);
327
328 return S_OK;
329}
330
331
332HRESULT GuestOSType::getRecommendedChipset(ChipsetType_T *aChipsetType)
333{
334 /* chipset type is constant during life time, no need to lock */
335 *aChipsetType = mChipsetType;
336
337 return S_OK;
338}
339
340
341HRESULT GuestOSType::getRecommendedAudioController(AudioControllerType_T *aAudioController)
342{
343 *aAudioController = mAudioControllerType;
344
345 return S_OK;
346}
347
348
349HRESULT GuestOSType::getRecommendedAudioCodec(AudioCodecType_T *aAudioCodec)
350{
351 *aAudioCodec = mAudioCodecType;
352
353 return S_OK;
354}
355
356
357HRESULT GuestOSType::getRecommendedFloppy(BOOL *aRecommendedFloppy)
358{
359 /* Value is constant during life time, no need to lock */
360 *aRecommendedFloppy = !!(mOSHint & VBOXOSHINT_FLOPPY);
361
362 return S_OK;
363}
364
365
366HRESULT GuestOSType::getRecommendedUSB(BOOL *aRecommendedUSB)
367{
368 /* Value is constant during life time, no need to lock */
369 *aRecommendedUSB = !(mOSHint & VBOXOSHINT_NOUSB);
370
371 return S_OK;
372}
373
374HRESULT GuestOSType::getRecommendedUSB3(BOOL *aRecommendedUSB3)
375{
376 /* Value is constant during life time, no need to lock */
377 *aRecommendedUSB3 = !!(mOSHint & VBOXOSHINT_USB3);
378
379 return S_OK;
380}
381
382HRESULT GuestOSType::getRecommendedTFReset(BOOL *aRecommendedTFReset)
383{
384 /* recommended triple fault behavior is constant during life time, no need to lock */
385 *aRecommendedTFReset = !!(mOSHint & VBOXOSHINT_TFRESET);
386
387 return S_OK;
388}
389
390HRESULT GuestOSType::getRecommendedX2APIC(BOOL *aRecommendedX2APIC)
391{
392 /* mRecommendedX2APIC is constant during life time, no need to lock */
393 *aRecommendedX2APIC = !!(mOSHint & VBOXOSHINT_X2APIC);
394
395 return S_OK;
396}
397
398
399/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use