VirtualBox

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

Last change on this file since 98351 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

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