VirtualBox

source: vbox/trunk/src/VBox/Main/src-all/PlatformPropertiesImpl.cpp@ 101292

Last change on this file since 101292 was 101287, checked in by vboxsync, 17 months ago

Main: Added IPlatformProperties::supportedGuestOSTypes() getter to return supported guest OS types for a specific platform. The IVirtualBox::guestOSTypes() getter in turn will return all guest OS types for all platforms [fix -- use the right vector initializer]. bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.2 KB
Line 
1/* $Id: PlatformPropertiesImpl.cpp 101287 2023-09-27 09:45:08Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation - Platform properties.
4 */
5
6/*
7 * Copyright (C) 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_PLATFORMPROPERTIES
29#include "PlatformPropertiesImpl.h"
30#include "VirtualBoxImpl.h"
31#include "LoggingNew.h"
32#include "Global.h"
33
34#include <iprt/cpp/utils.h>
35
36#include <VBox/settings.h>
37
38// generated header
39#include "SchemaDefs.h"
40
41
42/*
43 * PlatformProperties implementation.
44 */
45PlatformProperties::PlatformProperties()
46 : mParent(NULL)
47 , mPlatformArchitecture(PlatformArchitecture_None)
48 , mfIsHost(false)
49{
50}
51
52PlatformProperties::~PlatformProperties()
53{
54 uninit();
55}
56
57HRESULT PlatformProperties::FinalConstruct()
58{
59 return BaseFinalConstruct();
60}
61
62void PlatformProperties::FinalRelease()
63{
64 uninit();
65
66 BaseFinalRelease();
67}
68
69/**
70 * Initializes platform properties.
71 *
72 * @returns HRESULT
73 * @param aParent Pointer to IVirtualBox parent object (weak).
74 * @param fIsHost Set to \c true if this instance handles platform properties of the host,
75 * or set to \c false for guests (default).
76 */
77HRESULT PlatformProperties::init(VirtualBox *aParent, bool fIsHost /* = false */)
78{
79 /* Enclose the state transition NotReady->InInit->Ready */
80 AutoInitSpan autoInitSpan(this);
81 AssertReturn(autoInitSpan.isOk(), E_FAIL);
82
83 unconst(mParent) = aParent;
84
85 m = new settings::PlatformProperties;
86
87 unconst(mfIsHost) = fIsHost;
88
89 if (mfIsHost)
90 {
91 /* On Windows, macOS and Solaris hosts, HW virtualization use isn't exclusive
92 * by default so that VT-x or AMD-V can be shared with other
93 * hypervisors without requiring user intervention.
94 * NB: See also PlatformProperties constructor in settings.h
95 */
96#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
97 m->fExclusiveHwVirt = false; /** @todo BUGBUG Applies for MacOS on ARM as well? */
98#else
99 m->fExclusiveHwVirt = true;
100#endif
101 }
102
103 /* Confirm a successful initialization */
104 autoInitSpan.setSucceeded();
105
106 return S_OK;
107}
108
109/**
110 * Sets the platform architecture.
111 *
112 * @returns HRESULT
113 * @param aArchitecture Platform architecture to set.
114 *
115 * @note Usually only called when creating a new machine.
116 */
117HRESULT PlatformProperties::i_setArchitecture(PlatformArchitecture_T aArchitecture)
118{
119 /* sanity */
120 AutoCaller autoCaller(this);
121 AssertComRCReturn(autoCaller.hrc(), autoCaller.hrc());
122
123 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
124
125 mPlatformArchitecture = aArchitecture;
126
127 return S_OK;
128}
129
130/**
131 * Returns the host's platform architecture.
132 *
133 * @returns The host's platform architecture.
134 */
135PlatformArchitecture_T PlatformProperties::s_getHostPlatformArchitecture()
136{
137#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
138 return PlatformArchitecture_x86;
139#elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)
140 return PlatformArchitecture_ARM;
141#else
142# error "Port me!"
143 return PlatformArchitecture_None;
144#endif
145}
146
147void PlatformProperties::uninit()
148{
149 /* Enclose the state transition Ready->InUninit->NotReady */
150 AutoUninitSpan autoUninitSpan(this);
151 if (autoUninitSpan.uninitDone())
152 return;
153
154 if (m)
155 {
156 delete m;
157 m = NULL;
158 }
159}
160
161HRESULT PlatformProperties::getSerialPortCount(ULONG *count)
162{
163 /* no need to lock, this is const */
164 *count = SchemaDefs::SerialPortCount;
165
166 return S_OK;
167}
168
169HRESULT PlatformProperties::getParallelPortCount(ULONG *count)
170{
171 /* no need to lock, this is const */
172 *count = SchemaDefs::ParallelPortCount;
173
174 return S_OK;
175}
176
177HRESULT PlatformProperties::getMaxBootPosition(ULONG *aMaxBootPosition)
178{
179 /* no need to lock, this is const */
180 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
181
182 return S_OK;
183}
184
185HRESULT PlatformProperties::getRawModeSupported(BOOL *aRawModeSupported)
186{
187 *aRawModeSupported = FALSE;
188 return S_OK;
189}
190
191HRESULT PlatformProperties::getExclusiveHwVirt(BOOL *aExclusiveHwVirt)
192{
193 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
194
195 *aExclusiveHwVirt = m->fExclusiveHwVirt;
196
197 /* Makes no sense for guest platform properties, but we return FALSE anyway. */
198 return S_OK;
199}
200
201HRESULT PlatformProperties::setExclusiveHwVirt(BOOL aExclusiveHwVirt)
202{
203 /* Only makes sense when running in VBoxSVC, as this is a pure host setting -- ignored within clients. */
204#ifdef IN_VBOXSVC
205 /* No locking required, as mfIsHost is const. */
206 if (!mfIsHost) /* Ignore setting the attribute if not host properties. */
207 return S_OK;
208
209 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
210 m->fExclusiveHwVirt = !!aExclusiveHwVirt;
211 alock.release();
212
213 // VirtualBox::i_saveSettings() needs vbox write lock
214 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
215 return mParent->i_saveSettings();
216#else /* VBoxC */
217 RT_NOREF(aExclusiveHwVirt);
218 return VBOX_E_NOT_SUPPORTED;
219#endif
220}
221
222/* static */
223ULONG PlatformProperties::s_getMaxNetworkAdapters(ChipsetType_T aChipset)
224{
225 AssertReturn(aChipset != ChipsetType_Null, 0);
226
227 /* no need for locking, no state */
228 switch (aChipset)
229 {
230 case ChipsetType_PIIX3: return 8;
231 case ChipsetType_ICH9: return 36;
232 case ChipsetType_ARMv8Virtual: return 64; /** @todo BUGBUG Put a sane value here. Just a wild guess for now. */
233 case ChipsetType_Null:
234 RT_FALL_THROUGH();
235 default:
236 break;
237 }
238
239 AssertMsgFailedReturn(("Chipset type %#x not handled\n", aChipset), 0);
240}
241
242HRESULT PlatformProperties::getMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *aMaxNetworkAdapters)
243{
244 *aMaxNetworkAdapters = PlatformProperties::s_getMaxNetworkAdapters(aChipset);
245
246 return S_OK;
247}
248
249/* static */
250ULONG PlatformProperties::s_getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType)
251{
252 /* no need for locking, no state */
253 uint32_t cMaxNetworkAdapters = PlatformProperties::s_getMaxNetworkAdapters(aChipset);
254
255 switch (aType)
256 {
257 case NetworkAttachmentType_NAT:
258 case NetworkAttachmentType_Internal:
259 case NetworkAttachmentType_NATNetwork:
260 /* chipset default is OK */
261 break;
262 case NetworkAttachmentType_Bridged:
263 /* Maybe use current host interface count here? */
264 break;
265 case NetworkAttachmentType_HostOnly:
266 cMaxNetworkAdapters = RT_MIN(cMaxNetworkAdapters, 8);
267 break;
268 default:
269 AssertMsgFailed(("Unhandled attachment type %d\n", aType));
270 }
271
272 return cMaxNetworkAdapters;
273}
274
275HRESULT PlatformProperties::getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType,
276 ULONG *aMaxNetworkAdapters)
277{
278 *aMaxNetworkAdapters = PlatformProperties::s_getMaxNetworkAdaptersOfType(aChipset, aType);
279
280 return S_OK;
281}
282
283HRESULT PlatformProperties::getMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
284 ULONG *aMaxDevicesPerPort)
285{
286 /* no need to lock, this is const */
287 switch (aBus)
288 {
289 case StorageBus_SATA:
290 case StorageBus_SCSI:
291 case StorageBus_SAS:
292 case StorageBus_USB:
293 case StorageBus_PCIe:
294 case StorageBus_VirtioSCSI:
295 {
296 /* SATA and both SCSI controllers only support one device per port. */
297 *aMaxDevicesPerPort = 1;
298 break;
299 }
300 case StorageBus_IDE:
301 case StorageBus_Floppy:
302 {
303 /* The IDE and Floppy controllers support 2 devices. One as master
304 * and one as slave (or floppy drive 0 and 1). */
305 *aMaxDevicesPerPort = 2;
306 break;
307 }
308 default:
309 AssertMsgFailed(("Invalid bus type %d\n", aBus));
310 }
311
312 return S_OK;
313}
314
315HRESULT PlatformProperties::getMinPortCountForStorageBus(StorageBus_T aBus,
316 ULONG *aMinPortCount)
317{
318 /* no need to lock, this is const */
319 switch (aBus)
320 {
321 case StorageBus_SATA:
322 case StorageBus_SAS:
323 case StorageBus_PCIe:
324 case StorageBus_VirtioSCSI:
325 {
326 *aMinPortCount = 1;
327 break;
328 }
329 case StorageBus_SCSI:
330 {
331 *aMinPortCount = 16;
332 break;
333 }
334 case StorageBus_IDE:
335 {
336 *aMinPortCount = 2;
337 break;
338 }
339 case StorageBus_Floppy:
340 {
341 *aMinPortCount = 1;
342 break;
343 }
344 case StorageBus_USB:
345 {
346 *aMinPortCount = 8;
347 break;
348 }
349 default:
350 AssertMsgFailed(("Invalid bus type %d\n", aBus));
351 }
352
353 return S_OK;
354}
355
356HRESULT PlatformProperties::getMaxPortCountForStorageBus(StorageBus_T aBus,
357 ULONG *aMaxPortCount)
358{
359 /* no need to lock, this is const */
360 switch (aBus)
361 {
362 case StorageBus_SATA:
363 {
364 *aMaxPortCount = 30;
365 break;
366 }
367 case StorageBus_SCSI:
368 {
369 *aMaxPortCount = 16;
370 break;
371 }
372 case StorageBus_IDE:
373 {
374 *aMaxPortCount = 2;
375 break;
376 }
377 case StorageBus_Floppy:
378 {
379 *aMaxPortCount = 1;
380 break;
381 }
382 case StorageBus_SAS:
383 case StorageBus_PCIe:
384 {
385 *aMaxPortCount = 255;
386 break;
387 }
388 case StorageBus_USB:
389 {
390 *aMaxPortCount = 8;
391 break;
392 }
393 case StorageBus_VirtioSCSI:
394 {
395 *aMaxPortCount = 256;
396 break;
397 }
398 default:
399 AssertMsgFailed(("Invalid bus type %d\n", aBus));
400 }
401
402 return S_OK;
403}
404
405HRESULT PlatformProperties::getMaxInstancesOfStorageBus(ChipsetType_T aChipset,
406 StorageBus_T aBus,
407 ULONG *aMaxInstances)
408{
409 ULONG cCtrs = 0;
410
411 /* no need to lock, this is const */
412 switch (aBus)
413 {
414 case StorageBus_SATA:
415 case StorageBus_SCSI:
416 case StorageBus_SAS:
417 case StorageBus_PCIe:
418 case StorageBus_VirtioSCSI:
419 cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
420 /** @todo r=andy How many we want to define explicitly for ARMv8Virtual? */
421 break;
422 case StorageBus_USB:
423 case StorageBus_IDE:
424 case StorageBus_Floppy:
425 {
426 cCtrs = 1;
427 break;
428 }
429 default:
430 AssertMsgFailed(("Invalid bus type %d\n", aBus));
431 }
432
433 *aMaxInstances = cCtrs;
434
435 return S_OK;
436}
437
438HRESULT PlatformProperties::getDeviceTypesForStorageBus(StorageBus_T aBus,
439 std::vector<DeviceType_T> &aDeviceTypes)
440{
441 aDeviceTypes.resize(0);
442
443 /* no need to lock, this is const */
444 switch (aBus)
445 {
446 case StorageBus_IDE:
447 case StorageBus_SATA:
448 case StorageBus_SCSI:
449 case StorageBus_SAS:
450 case StorageBus_USB:
451 case StorageBus_VirtioSCSI:
452 {
453 aDeviceTypes.resize(2);
454 aDeviceTypes[0] = DeviceType_DVD;
455 aDeviceTypes[1] = DeviceType_HardDisk;
456 break;
457 }
458 case StorageBus_Floppy:
459 {
460 aDeviceTypes.resize(1);
461 aDeviceTypes[0] = DeviceType_Floppy;
462 break;
463 }
464 case StorageBus_PCIe:
465 {
466 aDeviceTypes.resize(1);
467 aDeviceTypes[0] = DeviceType_HardDisk;
468 break;
469 }
470 default:
471 AssertMsgFailed(("Invalid bus type %d\n", aBus));
472 }
473
474 return S_OK;
475}
476
477HRESULT PlatformProperties::getStorageBusForControllerType(StorageControllerType_T aStorageControllerType,
478 StorageBus_T *aStorageBus)
479{
480 /* no need to lock, this is const */
481 switch (aStorageControllerType)
482 {
483 case StorageControllerType_LsiLogic:
484 case StorageControllerType_BusLogic:
485 *aStorageBus = StorageBus_SCSI;
486 break;
487 case StorageControllerType_IntelAhci:
488 *aStorageBus = StorageBus_SATA;
489 break;
490 case StorageControllerType_PIIX3:
491 case StorageControllerType_PIIX4:
492 case StorageControllerType_ICH6:
493 *aStorageBus = StorageBus_IDE;
494 break;
495 case StorageControllerType_I82078:
496 *aStorageBus = StorageBus_Floppy;
497 break;
498 case StorageControllerType_LsiLogicSas:
499 *aStorageBus = StorageBus_SAS;
500 break;
501 case StorageControllerType_USB:
502 *aStorageBus = StorageBus_USB;
503 break;
504 case StorageControllerType_NVMe:
505 *aStorageBus = StorageBus_PCIe;
506 break;
507 case StorageControllerType_VirtioSCSI:
508 *aStorageBus = StorageBus_VirtioSCSI;
509 break;
510 default:
511 return setError(E_FAIL, tr("Invalid storage controller type %d\n"), aStorageBus);
512 }
513
514 return S_OK;
515}
516
517HRESULT PlatformProperties::getStorageControllerTypesForBus(StorageBus_T aStorageBus,
518 std::vector<StorageControllerType_T> &aStorageControllerTypes)
519{
520 aStorageControllerTypes.resize(0);
521
522 /* no need to lock, this is const */
523 switch (aStorageBus)
524 {
525 case StorageBus_IDE:
526 aStorageControllerTypes.resize(3);
527 aStorageControllerTypes[0] = StorageControllerType_PIIX4;
528 aStorageControllerTypes[1] = StorageControllerType_PIIX3;
529 aStorageControllerTypes[2] = StorageControllerType_ICH6;
530 break;
531 case StorageBus_SATA:
532 aStorageControllerTypes.resize(1);
533 aStorageControllerTypes[0] = StorageControllerType_IntelAhci;
534 break;
535 case StorageBus_SCSI:
536 aStorageControllerTypes.resize(2);
537 aStorageControllerTypes[0] = StorageControllerType_LsiLogic;
538 aStorageControllerTypes[1] = StorageControllerType_BusLogic;
539 break;
540 case StorageBus_Floppy:
541 aStorageControllerTypes.resize(1);
542 aStorageControllerTypes[0] = StorageControllerType_I82078;
543 break;
544 case StorageBus_SAS:
545 aStorageControllerTypes.resize(1);
546 aStorageControllerTypes[0] = StorageControllerType_LsiLogicSas;
547 break;
548 case StorageBus_USB:
549 aStorageControllerTypes.resize(1);
550 aStorageControllerTypes[0] = StorageControllerType_USB;
551 break;
552 case StorageBus_PCIe:
553 aStorageControllerTypes.resize(1);
554 aStorageControllerTypes[0] = StorageControllerType_NVMe;
555 break;
556 case StorageBus_VirtioSCSI:
557 aStorageControllerTypes.resize(1);
558 aStorageControllerTypes[0] = StorageControllerType_VirtioSCSI;
559 break;
560 default:
561 return setError(E_FAIL, tr("Invalid storage bus %d\n"), aStorageBus);
562 }
563
564 return S_OK;
565}
566
567HRESULT PlatformProperties::getStorageControllerHotplugCapable(StorageControllerType_T aControllerType,
568 BOOL *aHotplugCapable)
569{
570 switch (aControllerType)
571 {
572 case StorageControllerType_IntelAhci:
573 case StorageControllerType_USB:
574 *aHotplugCapable = true;
575 break;
576 case StorageControllerType_LsiLogic:
577 case StorageControllerType_LsiLogicSas:
578 case StorageControllerType_BusLogic:
579 case StorageControllerType_NVMe:
580 case StorageControllerType_VirtioSCSI:
581 case StorageControllerType_PIIX3:
582 case StorageControllerType_PIIX4:
583 case StorageControllerType_ICH6:
584 case StorageControllerType_I82078:
585 *aHotplugCapable = false;
586 break;
587 default:
588 AssertMsgFailedReturn(("Invalid controller type %d\n", aControllerType), E_FAIL);
589 }
590
591 return S_OK;
592}
593
594HRESULT PlatformProperties::getMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
595 USBControllerType_T aType,
596 ULONG *aMaxInstances)
597{
598 NOREF(aChipset);
599 ULONG cCtrs = 0;
600
601 /* no need to lock, this is const */
602 switch (aType)
603 {
604 case USBControllerType_OHCI:
605 case USBControllerType_EHCI:
606 case USBControllerType_XHCI:
607 {
608 cCtrs = 1;
609 break;
610 }
611 default:
612 AssertMsgFailed(("Invalid bus type %d\n", aType));
613 }
614
615 *aMaxInstances = cCtrs;
616
617 return S_OK;
618}
619
620HRESULT PlatformProperties::getSupportedParavirtProviders(std::vector<ParavirtProvider_T> &aSupportedParavirtProviders)
621{
622 static const ParavirtProvider_T aParavirtProviders[] =
623 {
624 ParavirtProvider_None,
625 ParavirtProvider_Default,
626 ParavirtProvider_Legacy,
627 ParavirtProvider_Minimal,
628 ParavirtProvider_HyperV,
629 ParavirtProvider_KVM,
630 };
631 aSupportedParavirtProviders.assign(aParavirtProviders,
632 aParavirtProviders + RT_ELEMENTS(aParavirtProviders));
633 return S_OK;
634}
635
636HRESULT PlatformProperties::getSupportedFirmwareTypes(std::vector<FirmwareType_T> &aSupportedFirmwareTypes)
637{
638 switch (mPlatformArchitecture)
639 {
640 case PlatformArchitecture_x86:
641 {
642 static const FirmwareType_T aFirmwareTypes[] =
643 {
644 FirmwareType_BIOS,
645 FirmwareType_EFI,
646 FirmwareType_EFI32,
647 FirmwareType_EFI64,
648 FirmwareType_EFIDUAL
649 };
650 aSupportedFirmwareTypes.assign(aFirmwareTypes,
651 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
652 break;
653 }
654
655 case PlatformArchitecture_ARM:
656 {
657 static const FirmwareType_T aFirmwareTypes[] =
658 {
659 FirmwareType_EFI,
660 FirmwareType_EFI32,
661 FirmwareType_EFI64,
662 FirmwareType_EFIDUAL
663 };
664 aSupportedFirmwareTypes.assign(aFirmwareTypes,
665 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
666 break;
667 }
668
669 default:
670 AssertFailedStmt(aSupportedFirmwareTypes.clear());
671 break;
672 }
673
674 return S_OK;
675}
676
677HRESULT PlatformProperties::getSupportedGraphicsControllerTypes(std::vector<GraphicsControllerType_T> &aSupportedGraphicsControllerTypes)
678{
679 switch (mPlatformArchitecture)
680 {
681 case PlatformArchitecture_x86:
682 {
683 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
684 {
685 GraphicsControllerType_Null,
686 GraphicsControllerType_VBoxVGA,
687 GraphicsControllerType_VBoxSVGA
688#ifdef VBOX_WITH_VMSVGA
689 , GraphicsControllerType_VMSVGA
690#endif
691 };
692 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes + 1 /* Don't include _Null */,
693 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
694 break;
695 }
696
697 case PlatformArchitecture_ARM:
698 {
699 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
700 {
701 GraphicsControllerType_Null,
702 GraphicsControllerType_QemuRamFB
703#ifdef VBOX_WITH_VMSVGA
704 , GraphicsControllerType_VMSVGA
705#endif
706 };
707 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes + 1 /* Don't include _Null */,
708 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
709 break;
710 }
711
712 default:
713 AssertFailedStmt(aSupportedGraphicsControllerTypes.clear());
714 break;
715 }
716
717 return S_OK;
718}
719
720HRESULT PlatformProperties::getSupportedGuestOSTypes(std::vector<ComPtr<IGuestOSType>> &aSupportedGuestOSTypes)
721{
722 /* We only have all supported guest OS types as part of VBoxSVC, not in VBoxC itself. */
723#ifdef IN_VBOXSVC
724 std::vector<PlatformArchitecture_T> vecArchitectures(1 /* Size */, mPlatformArchitecture);
725 return mParent->i_getSupportedGuestOSTypes(vecArchitectures, aSupportedGuestOSTypes);
726#else /* VBoxC */
727 RT_NOREF(aSupportedGuestOSTypes);
728 return VBOX_E_NOT_SUPPORTED;
729#endif
730}
731
732HRESULT PlatformProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
733{
734 switch (mPlatformArchitecture)
735 {
736 case PlatformArchitecture_x86:
737 {
738 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
739 {
740 NetworkAdapterType_Null,
741 NetworkAdapterType_Am79C970A,
742 NetworkAdapterType_Am79C973
743#ifdef VBOX_WITH_E1000
744 , NetworkAdapterType_I82540EM
745 , NetworkAdapterType_I82543GC
746 , NetworkAdapterType_I82545EM
747#endif
748#ifdef VBOX_WITH_VIRTIO
749 , NetworkAdapterType_Virtio
750#endif
751 };
752 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes + 1 /* Don't include _Null */,
753 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
754 break;
755 }
756
757 case PlatformArchitecture_ARM:
758 {
759 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
760 {
761 NetworkAdapterType_Null
762#ifdef VBOX_WITH_E1000
763 , NetworkAdapterType_I82540EM
764 , NetworkAdapterType_I82543GC
765 , NetworkAdapterType_I82545EM
766#endif
767#ifdef VBOX_WITH_VIRTIO
768 , NetworkAdapterType_Virtio
769#endif
770 };
771 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes + 1 /* Don't include _Null */,
772 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
773 break;
774 }
775
776 default:
777 AssertFailedStmt(aSupportedNetworkAdapterTypes.clear());
778 break;
779 }
780
781 return S_OK;
782}
783
784HRESULT PlatformProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
785{
786 static const UartType_T aUartTypes[] =
787 {
788 UartType_U16450,
789 UartType_U16550A,
790 UartType_U16750
791 };
792 aSupportedUartTypes.assign(aUartTypes,
793 aUartTypes + RT_ELEMENTS(aUartTypes));
794 return S_OK;
795}
796
797HRESULT PlatformProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
798{
799 static const USBControllerType_T aUSBControllerTypes[] =
800 {
801 USBControllerType_OHCI,
802 USBControllerType_EHCI,
803 USBControllerType_XHCI
804 };
805 aSupportedUSBControllerTypes.assign(aUSBControllerTypes,
806 aUSBControllerTypes + RT_ELEMENTS(aUSBControllerTypes));
807 return S_OK;
808}
809
810HRESULT PlatformProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
811{
812 switch (mPlatformArchitecture)
813 {
814 case PlatformArchitecture_x86:
815 {
816 static const AudioControllerType_T aAudioControllerTypes[] =
817 {
818 AudioControllerType_AC97,
819 AudioControllerType_SB16,
820 AudioControllerType_HDA,
821 };
822 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
823 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
824 break;
825 }
826
827 case PlatformArchitecture_ARM:
828 {
829 /** @todo None yet / needs to be tested first. */
830 aSupportedAudioControllerTypes.clear();
831 break;
832 }
833
834 default:
835 AssertFailedStmt(aSupportedAudioControllerTypes.clear());
836 break;
837 }
838
839
840 return S_OK;
841}
842
843HRESULT PlatformProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
844{
845 switch (mPlatformArchitecture)
846 {
847 case PlatformArchitecture_x86:
848 {
849 static const StorageBus_T aStorageBuses[] =
850 {
851 StorageBus_SATA,
852 StorageBus_IDE,
853 StorageBus_SCSI,
854 StorageBus_Floppy,
855 StorageBus_SAS,
856 StorageBus_USB,
857 StorageBus_PCIe,
858 StorageBus_VirtioSCSI,
859 };
860 aSupportedStorageBuses.assign(aStorageBuses,
861 aStorageBuses + RT_ELEMENTS(aStorageBuses));
862 break;
863 }
864
865 case PlatformArchitecture_ARM:
866 {
867 static const StorageBus_T aStorageBuses[] =
868 {
869 StorageBus_VirtioSCSI
870 };
871 aSupportedStorageBuses.assign(aStorageBuses,
872 aStorageBuses + RT_ELEMENTS(aStorageBuses));
873 break;
874 }
875
876 default:
877 AssertFailedStmt(aSupportedStorageBuses.clear());
878 break;
879 }
880
881 return S_OK;
882}
883
884HRESULT PlatformProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
885{
886 switch (mPlatformArchitecture)
887 {
888 case PlatformArchitecture_x86:
889 {
890 static const StorageControllerType_T aStorageControllerTypes[] =
891 {
892 StorageControllerType_IntelAhci,
893 StorageControllerType_PIIX4,
894 StorageControllerType_PIIX3,
895 StorageControllerType_ICH6,
896 StorageControllerType_LsiLogic,
897 StorageControllerType_BusLogic,
898 StorageControllerType_I82078,
899 StorageControllerType_LsiLogicSas,
900 StorageControllerType_USB,
901 StorageControllerType_NVMe,
902 StorageControllerType_VirtioSCSI
903 };
904 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
905 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
906 break;
907 }
908
909 case PlatformArchitecture_ARM:
910 {
911 static const StorageControllerType_T aStorageControllerTypes[] =
912 {
913 StorageControllerType_VirtioSCSI
914 };
915 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
916 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
917 break;
918 }
919
920 default:
921 AssertFailedStmt(aSupportedStorageControllerTypes.clear());
922 break;
923 }
924
925 return S_OK;
926}
927
928HRESULT PlatformProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
929{
930 switch (mPlatformArchitecture)
931 {
932 case PlatformArchitecture_x86:
933 {
934 static const ChipsetType_T aChipsetTypes[] =
935 {
936 ChipsetType_PIIX3,
937 ChipsetType_ICH9
938 };
939 aSupportedChipsetTypes.assign(aChipsetTypes,
940 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
941 break;
942 }
943
944 case PlatformArchitecture_ARM:
945 {
946 static const ChipsetType_T aChipsetTypes[] =
947 {
948 ChipsetType_ARMv8Virtual
949 };
950 aSupportedChipsetTypes.assign(aChipsetTypes,
951 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
952 break;
953 }
954
955 default:
956 AssertFailedStmt(aSupportedChipsetTypes.clear());
957 break;
958 }
959
960 return S_OK;
961}
962
963HRESULT PlatformProperties::getSupportedIommuTypes(std::vector<IommuType_T> &aSupportedIommuTypes)
964{
965 switch (mPlatformArchitecture)
966 {
967 case PlatformArchitecture_x86:
968 {
969 static const IommuType_T aIommuTypes[] =
970 {
971 IommuType_None,
972 IommuType_Automatic,
973 IommuType_AMD
974 /** @todo Add Intel when it's supported. */
975 };
976 aSupportedIommuTypes.assign(aIommuTypes,
977 aIommuTypes + RT_ELEMENTS(aIommuTypes));
978 break;
979 }
980
981 case PlatformArchitecture_ARM:
982 {
983 static const IommuType_T aIommuTypes[] =
984 {
985 IommuType_None
986 };
987 aSupportedIommuTypes.assign(aIommuTypes,
988 aIommuTypes + RT_ELEMENTS(aIommuTypes));
989 break;
990 }
991
992 default:
993 AssertFailedStmt(aSupportedIommuTypes.clear());
994 break;
995 }
996
997 return S_OK;
998}
999
1000HRESULT PlatformProperties::getSupportedTpmTypes(std::vector<TpmType_T> &aSupportedTpmTypes)
1001{
1002 switch (mPlatformArchitecture)
1003 {
1004 case PlatformArchitecture_x86:
1005 {
1006 static const TpmType_T aTpmTypes[] =
1007 {
1008 TpmType_None,
1009 TpmType_v1_2,
1010 TpmType_v2_0
1011 };
1012 aSupportedTpmTypes.assign(aTpmTypes,
1013 aTpmTypes + RT_ELEMENTS(aTpmTypes));
1014 break;
1015 }
1016
1017 case PlatformArchitecture_ARM:
1018 {
1019 static const TpmType_T aTpmTypes[] =
1020 {
1021 TpmType_None
1022 };
1023 aSupportedTpmTypes.assign(aTpmTypes,
1024 aTpmTypes + RT_ELEMENTS(aTpmTypes));
1025 break;
1026 }
1027
1028 default:
1029 AssertFailedStmt(aSupportedTpmTypes.clear());
1030 break;
1031 }
1032
1033 return S_OK;
1034}
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