VirtualBox

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

Last change on this file since 101381 was 101215, checked in by vboxsync, 9 months ago

Main: Separated (renamed) the internal generic OS hint bits from the x86-specific ones. bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.9 KB
Line 
1/* $Id: GuestOSTypeImpl.cpp 101215 2023-09-21 08:53:19Z 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(mOSVariant) = ostype.variant;
103 unconst(mID) = ostype.id;
104 unconst(mDescription) = ostype.description;
105 unconst(mOSType) = ostype.osType;
106 unconst(mOSHint) = ostype.osHint;
107 unconst(mRAMSize) = ostype.recommendedRAM;
108 unconst(mCPUCount) = ostype.recommendedCPUCount;
109 unconst(mHDDSize) = ostype.recommendedHDD;
110 unconst(mGraphicsControllerType) = ostype.graphicsControllerType;
111 unconst(mVRAMSize) = ostype.recommendedVRAM;
112 unconst(mNetworkAdapterType) = ostype.networkAdapterType;
113 unconst(mNumSerialEnabled) = ostype.numSerialEnabled;
114 unconst(mDVDStorageControllerType) = ostype.dvdStorageControllerType;
115 unconst(mDVDStorageBusType) = ostype.dvdStorageBusType;
116 unconst(mHDStorageControllerType) = ostype.hdStorageControllerType;
117 unconst(mHDStorageBusType) = ostype.hdStorageBusType;
118 unconst(mChipsetType) = ostype.chipsetType;
119 unconst(mIommuType) = ostype.iommuType;
120 unconst(mAudioControllerType) = ostype.audioControllerType;
121 unconst(mAudioCodecType) = ostype.audioCodecType;
122
123 /* Confirm a successful initialization when it's the case */
124 autoInitSpan.setSucceeded();
125
126 return S_OK;
127}
128
129/**
130 * Uninitializes the instance and sets the ready flag to FALSE.
131 * Called either from FinalRelease() or by the parent when it gets destroyed.
132 */
133void GuestOSType::uninit()
134{
135 /* Enclose the state transition Ready->InUninit->NotReady */
136 AutoUninitSpan autoUninitSpan(this);
137 if (autoUninitSpan.uninitDone())
138 return;
139}
140
141// IGuestOSType properties
142/////////////////////////////////////////////////////////////////////////////
143
144HRESULT GuestOSType::getFamilyId(com::Utf8Str &aFamilyId)
145{
146 /* mFamilyID is constant during life time, no need to lock */
147 aFamilyId = mFamilyID;
148 return S_OK;
149}
150
151
152HRESULT GuestOSType::getFamilyDescription(com::Utf8Str &aFamilyDescription)
153{
154 /* mFamilyDescription is constant during life time, no need to lock */
155 aFamilyDescription = mFamilyDescription;
156
157 return S_OK;
158}
159
160
161HRESULT GuestOSType::getVariant(com::Utf8Str &aVariant)
162{
163 /* mOSVariant is constant during life time, no need to lock */
164 aVariant = mOSVariant;
165
166 return S_OK;
167}
168
169
170HRESULT GuestOSType::getId(com::Utf8Str &aId)
171{
172 /* mID is constant during life time, no need to lock */
173 aId = mID;
174
175 return S_OK;
176}
177
178
179HRESULT GuestOSType::getDescription(com::Utf8Str &aDescription)
180{
181 /* mDescription is constant during life time, no need to lock */
182 aDescription = mDescription;
183
184 return S_OK;
185}
186
187HRESULT GuestOSType::getIs64Bit(BOOL *aIs64Bit)
188{
189 /* mIs64Bit is constant during life time, no need to lock */
190 *aIs64Bit = !!(mOSHint & VBOXOSHINT_64BIT);
191
192 return S_OK;
193}
194
195PlatformArchitecture_T GuestOSType::i_platformArchitecture() const
196{
197 /* mOSType constant during life time, no need to lock */
198 VBOXOSTYPE const osTypePlatformArchitectureMasked = VBOXOSTYPE(mOSType & VBOXOSTYPE_ArchitectureMask);
199 if ( osTypePlatformArchitectureMasked == VBOXOSTYPE_x86
200 || osTypePlatformArchitectureMasked == VBOXOSTYPE_x64)
201 return PlatformArchitecture_x86;
202 else if ( osTypePlatformArchitectureMasked == VBOXOSTYPE_arm32
203 || osTypePlatformArchitectureMasked == VBOXOSTYPE_arm64)
204 return PlatformArchitecture_ARM;
205
206 /* Will happen when called before being properly initialized(). */
207 return PlatformArchitecture_None;
208}
209
210HRESULT GuestOSType::getPlatformArchitecture(PlatformArchitecture_T *aPlatformArchitecture)
211{
212 *aPlatformArchitecture = i_platformArchitecture();
213 return S_OK;
214}
215
216HRESULT GuestOSType::getRecommendedIOAPIC(BOOL *aRecommendedIOAPIC)
217{
218 /* mRecommendedIOAPIC is constant during life time, no need to lock */
219 *aRecommendedIOAPIC = !!(mOSHint & VBOXOSHINT_X86_IOAPIC);
220
221 return S_OK;
222}
223
224
225HRESULT GuestOSType::getRecommendedVirtEx(BOOL *aRecommendedVirtEx)
226{
227 /* mRecommendedVirtEx is constant during life time, no need to lock */
228 *aRecommendedVirtEx = !!(mOSHint & VBOXOSHINT_X86_HWVIRTEX);
229
230 return S_OK;
231}
232
233
234HRESULT GuestOSType::getRecommendedRAM(ULONG *aRAMSize)
235{
236 /* mRAMSize is constant during life time, no need to lock */
237 *aRAMSize = mRAMSize;
238
239 return S_OK;
240}
241
242
243HRESULT GuestOSType::getRecommendedGraphicsController(GraphicsControllerType_T *aRecommendedGraphicsController)
244{
245 /* mGraphicsController is constant during life time, no need to lock */
246 *aRecommendedGraphicsController = mGraphicsControllerType;
247
248 return S_OK;
249}
250
251
252HRESULT GuestOSType::getRecommendedVRAM(ULONG *aVRAMSize)
253{
254 /* mVRAMSize is constant during life time, no need to lock */
255 *aVRAMSize = mVRAMSize;
256
257 return S_OK;
258}
259
260
261HRESULT GuestOSType::getRecommended2DVideoAcceleration(BOOL *aRecommended2DVideoAcceleration)
262{
263 /* Constant during life time, no need to lock */
264 *aRecommended2DVideoAcceleration = !!(mOSHint & VBOXOSHINT_ACCEL2D);
265
266 return S_OK;
267}
268
269
270HRESULT GuestOSType::getRecommended3DAcceleration(BOOL *aRecommended3DAcceleration)
271{
272 /* Constant during life time, no need to lock */
273 *aRecommended3DAcceleration = !!(mOSHint & VBOXOSHINT_ACCEL3D);
274
275 return S_OK;
276}
277
278
279HRESULT GuestOSType::getRecommendedHDD(LONG64 *aHDDSize)
280{
281 /* mHDDSize is constant during life time, no need to lock */
282 *aHDDSize = (LONG64)mHDDSize;
283
284 return S_OK;
285}
286
287
288HRESULT GuestOSType::getAdapterType(NetworkAdapterType_T *aNetworkAdapterType)
289{
290 /* mNetworkAdapterType is constant during life time, no need to lock */
291 *aNetworkAdapterType = mNetworkAdapterType;
292
293 return S_OK;
294}
295
296HRESULT GuestOSType::getRecommendedPAE(BOOL *aRecommendedPAE)
297{
298 /* recommended PAE is constant during life time, no need to lock */
299 *aRecommendedPAE = !!(mOSHint & VBOXOSHINT_X86_PAE);
300
301 return S_OK;
302}
303
304
305HRESULT GuestOSType::getRecommendedFirmware(FirmwareType_T *aFirmwareType)
306{
307 /* firmware type is constant during life time, no need to lock */
308 if (mOSHint & VBOXOSHINT_EFI)
309 *aFirmwareType = FirmwareType_EFI;
310 else
311 *aFirmwareType = FirmwareType_BIOS;
312
313 return S_OK;
314}
315
316
317HRESULT GuestOSType::getRecommendedDVDStorageController(StorageControllerType_T *aStorageControllerType)
318{
319 /* storage controller type is constant during life time, no need to lock */
320 *aStorageControllerType = mDVDStorageControllerType;
321
322 return S_OK;
323}
324
325
326HRESULT GuestOSType::getRecommendedDVDStorageBus(StorageBus_T *aStorageBusType)
327{
328 /* storage controller type is constant during life time, no need to lock */
329 *aStorageBusType = mDVDStorageBusType;
330
331 return S_OK;
332}
333
334
335HRESULT GuestOSType::getRecommendedHDStorageController(StorageControllerType_T *aStorageControllerType)
336{
337 /* storage controller type is constant during life time, no need to lock */
338 *aStorageControllerType = mHDStorageControllerType;
339
340 return S_OK;
341}
342
343
344HRESULT GuestOSType::getRecommendedHDStorageBus(StorageBus_T *aStorageBusType)
345{
346 /* storage controller type is constant during life time, no need to lock */
347 *aStorageBusType = mHDStorageBusType;
348
349 return S_OK;
350}
351
352
353HRESULT GuestOSType::getRecommendedUSBHID(BOOL *aRecommendedUSBHID)
354{
355 /* HID type is constant during life time, no need to lock */
356 *aRecommendedUSBHID = !!(mOSHint & VBOXOSHINT_USBHID);
357
358 return S_OK;
359}
360
361
362HRESULT GuestOSType::getRecommendedHPET(BOOL *aRecommendedHPET)
363{
364 /* HPET recommendation is constant during life time, no need to lock */
365 *aRecommendedHPET = !!(mOSHint & VBOXOSHINT_X86_HPET);
366
367 return S_OK;
368}
369
370
371HRESULT GuestOSType::getRecommendedUSBTablet(BOOL *aRecommendedUSBTablet)
372{
373 /* HID type is constant during life time, no need to lock */
374 *aRecommendedUSBTablet = !!(mOSHint & VBOXOSHINT_USBTABLET);
375
376 return S_OK;
377}
378
379
380HRESULT GuestOSType::getRecommendedRTCUseUTC(BOOL *aRecommendedRTCUseUTC)
381{
382 /* Value is constant during life time, no need to lock */
383 *aRecommendedRTCUseUTC = !!(mOSHint & VBOXOSHINT_RTCUTC);
384
385 return S_OK;
386}
387
388
389HRESULT GuestOSType::getRecommendedChipset(ChipsetType_T *aChipsetType)
390{
391 /* chipset type is constant during life time, no need to lock */
392 *aChipsetType = mChipsetType;
393
394 return S_OK;
395}
396
397
398HRESULT GuestOSType::getRecommendedIommuType(IommuType_T *aIommuType)
399{
400 /* IOMMU type is constant during life time, no need to lock */
401 *aIommuType = mIommuType;
402
403 return S_OK;
404}
405
406
407HRESULT GuestOSType::getRecommendedAudioController(AudioControllerType_T *aAudioController)
408{
409 *aAudioController = mAudioControllerType;
410
411 return S_OK;
412}
413
414
415HRESULT GuestOSType::getRecommendedAudioCodec(AudioCodecType_T *aAudioCodec)
416{
417 *aAudioCodec = mAudioCodecType;
418
419 return S_OK;
420}
421
422
423HRESULT GuestOSType::getRecommendedFloppy(BOOL *aRecommendedFloppy)
424{
425 /* Value is constant during life time, no need to lock */
426 *aRecommendedFloppy = !!(mOSHint & VBOXOSHINT_FLOPPY);
427
428 return S_OK;
429}
430
431
432HRESULT GuestOSType::getRecommendedUSB(BOOL *aRecommendedUSB)
433{
434 /* Value is constant during life time, no need to lock */
435 *aRecommendedUSB = !(mOSHint & VBOXOSHINT_NOUSB);
436
437 return S_OK;
438}
439
440HRESULT GuestOSType::getRecommendedUSB3(BOOL *aRecommendedUSB3)
441{
442 /* Value is constant during life time, no need to lock */
443 *aRecommendedUSB3 = !!(mOSHint & VBOXOSHINT_USB3);
444
445 return S_OK;
446}
447
448HRESULT GuestOSType::getRecommendedTFReset(BOOL *aRecommendedTFReset)
449{
450 /* recommended triple fault behavior is constant during life time, no need to lock */
451 *aRecommendedTFReset = !!(mOSHint & VBOXOSHINT_TFRESET);
452
453 return S_OK;
454}
455
456HRESULT GuestOSType::getRecommendedX2APIC(BOOL *aRecommendedX2APIC)
457{
458 /* mRecommendedX2APIC is constant during life time, no need to lock */
459 *aRecommendedX2APIC = !!(mOSHint & VBOXOSHINT_X86_X2APIC);
460
461 return S_OK;
462}
463
464HRESULT GuestOSType::getRecommendedCPUCount(ULONG *aRecommendedCPUCount)
465{
466 /* mCPUCount is constant during life time, no need to lock */
467 *aRecommendedCPUCount = mCPUCount;
468
469 return S_OK;
470}
471
472HRESULT GuestOSType::getRecommendedTpmType(TpmType_T *aRecommendedTpmType)
473{
474 /* Value is constant during life time, no need to lock */
475 if (mOSHint & VBOXOSHINT_TPM2)
476 *aRecommendedTpmType = TpmType_v2_0;
477 else if (mOSHint & VBOXOSHINT_TPM)
478 *aRecommendedTpmType = TpmType_v1_2;
479 else
480 *aRecommendedTpmType = TpmType_None;
481
482 return S_OK;
483}
484
485HRESULT GuestOSType::getRecommendedSecureBoot(BOOL *aRecommendedSecureBoot)
486{
487 /* Value is constant during life time, no need to lock */
488 *aRecommendedSecureBoot = !!(mOSHint & VBOXOSHINT_EFI_SECUREBOOT);
489
490 return S_OK;
491}
492
493HRESULT GuestOSType::getRecommendedWDDMGraphics(BOOL *aRecommendedWDDMGraphics)
494{
495 /* Value is constant during life time, no need to lock */
496 *aRecommendedWDDMGraphics = !!(mOSHint & VBOXOSHINT_WDDM_GRAPHICS);
497
498 return S_OK;
499}
500
501/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use