VirtualBox

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

Last change on this file since 101137 was 101133, checked in by vboxsync, 18 months ago

Main: Also guard GraphicsControllerType_VMSVGA in platform properties and don't include _Null the returned arrays (FE/Qt does not have translation for those anyway). bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.6 KB
Line 
1/* $Id: PlatformPropertiesImpl.cpp 101133 2023-09-15 16:22:59Z 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#ifdef VBOX_WITH_VMSVGA
703 , GraphicsControllerType_VMSVGA
704#endif
705 };
706 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes + 1 /* Don't include _Null */,
707 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
708 break;
709 }
710
711 default:
712 AssertFailedStmt(aSupportedGraphicsControllerTypes.clear());
713 break;
714 }
715
716 return S_OK;
717}
718
719HRESULT PlatformProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
720{
721 switch (mPlatformArchitecture)
722 {
723 case PlatformArchitecture_x86:
724 {
725 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
726 {
727 NetworkAdapterType_Null,
728 NetworkAdapterType_Am79C970A,
729 NetworkAdapterType_Am79C973
730#ifdef VBOX_WITH_E1000
731 , NetworkAdapterType_I82540EM
732 , NetworkAdapterType_I82543GC
733 , NetworkAdapterType_I82545EM
734#endif
735#ifdef VBOX_WITH_VIRTIO
736 , NetworkAdapterType_Virtio
737#endif
738 };
739 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes + 1 /* Don't include _Null */,
740 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
741 break;
742 }
743
744 case PlatformArchitecture_ARM:
745 {
746 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
747 {
748 NetworkAdapterType_Null
749#ifdef VBOX_WITH_E1000
750 , NetworkAdapterType_I82540EM
751 , NetworkAdapterType_I82543GC
752 , NetworkAdapterType_I82545EM
753#endif
754#ifdef VBOX_WITH_VIRTIO
755 , NetworkAdapterType_Virtio
756#endif
757 };
758 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes + 1 /* Don't include _Null */,
759 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
760 break;
761 }
762
763 default:
764 AssertFailedStmt(aSupportedNetworkAdapterTypes.clear());
765 break;
766 }
767
768 return S_OK;
769}
770
771HRESULT PlatformProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
772{
773 static const UartType_T aUartTypes[] =
774 {
775 UartType_U16450,
776 UartType_U16550A,
777 UartType_U16750
778 };
779 aSupportedUartTypes.assign(aUartTypes,
780 aUartTypes + RT_ELEMENTS(aUartTypes));
781 return S_OK;
782}
783
784HRESULT PlatformProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
785{
786 static const USBControllerType_T aUSBControllerTypes[] =
787 {
788 USBControllerType_OHCI,
789 USBControllerType_EHCI,
790 USBControllerType_XHCI
791 };
792 aSupportedUSBControllerTypes.assign(aUSBControllerTypes,
793 aUSBControllerTypes + RT_ELEMENTS(aUSBControllerTypes));
794 return S_OK;
795}
796
797HRESULT PlatformProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
798{
799 switch (mPlatformArchitecture)
800 {
801 case PlatformArchitecture_x86:
802 {
803 static const AudioControllerType_T aAudioControllerTypes[] =
804 {
805 AudioControllerType_AC97,
806 AudioControllerType_SB16,
807 AudioControllerType_HDA,
808 };
809 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
810 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
811 break;
812 }
813
814 case PlatformArchitecture_ARM:
815 {
816 /** @todo None yet / needs to be tested first. */
817 aSupportedAudioControllerTypes.clear();
818 break;
819 }
820
821 default:
822 AssertFailedStmt(aSupportedAudioControllerTypes.clear());
823 break;
824 }
825
826
827 return S_OK;
828}
829
830HRESULT PlatformProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
831{
832 switch (mPlatformArchitecture)
833 {
834 case PlatformArchitecture_x86:
835 {
836 static const StorageBus_T aStorageBuses[] =
837 {
838 StorageBus_SATA,
839 StorageBus_IDE,
840 StorageBus_SCSI,
841 StorageBus_Floppy,
842 StorageBus_SAS,
843 StorageBus_USB,
844 StorageBus_PCIe,
845 StorageBus_VirtioSCSI,
846 };
847 aSupportedStorageBuses.assign(aStorageBuses,
848 aStorageBuses + RT_ELEMENTS(aStorageBuses));
849 break;
850 }
851
852 case PlatformArchitecture_ARM:
853 {
854 static const StorageBus_T aStorageBuses[] =
855 {
856 StorageBus_VirtioSCSI
857 };
858 aSupportedStorageBuses.assign(aStorageBuses,
859 aStorageBuses + RT_ELEMENTS(aStorageBuses));
860 break;
861 }
862
863 default:
864 AssertFailedStmt(aSupportedStorageBuses.clear());
865 break;
866 }
867
868 return S_OK;
869}
870
871HRESULT PlatformProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
872{
873 switch (mPlatformArchitecture)
874 {
875 case PlatformArchitecture_x86:
876 {
877 static const StorageControllerType_T aStorageControllerTypes[] =
878 {
879 StorageControllerType_IntelAhci,
880 StorageControllerType_PIIX4,
881 StorageControllerType_PIIX3,
882 StorageControllerType_ICH6,
883 StorageControllerType_LsiLogic,
884 StorageControllerType_BusLogic,
885 StorageControllerType_I82078,
886 StorageControllerType_LsiLogicSas,
887 StorageControllerType_USB,
888 StorageControllerType_NVMe,
889 StorageControllerType_VirtioSCSI
890 };
891 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
892 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
893 break;
894 }
895
896 case PlatformArchitecture_ARM:
897 {
898 static const StorageControllerType_T aStorageControllerTypes[] =
899 {
900 StorageControllerType_VirtioSCSI
901 };
902 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
903 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
904 break;
905 }
906
907 default:
908 AssertFailedStmt(aSupportedStorageControllerTypes.clear());
909 break;
910 }
911
912 return S_OK;
913}
914
915HRESULT PlatformProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
916{
917 switch (mPlatformArchitecture)
918 {
919 case PlatformArchitecture_x86:
920 {
921 static const ChipsetType_T aChipsetTypes[] =
922 {
923 ChipsetType_PIIX3,
924 ChipsetType_ICH9
925 };
926 aSupportedChipsetTypes.assign(aChipsetTypes,
927 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
928 break;
929 }
930
931 case PlatformArchitecture_ARM:
932 {
933 static const ChipsetType_T aChipsetTypes[] =
934 {
935 ChipsetType_ARMv8Virtual
936 };
937 aSupportedChipsetTypes.assign(aChipsetTypes,
938 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
939 break;
940 }
941
942 default:
943 AssertFailedStmt(aSupportedChipsetTypes.clear());
944 break;
945 }
946
947 return S_OK;
948}
949
950HRESULT PlatformProperties::getSupportedIommuTypes(std::vector<IommuType_T> &aSupportedIommuTypes)
951{
952 switch (mPlatformArchitecture)
953 {
954 case PlatformArchitecture_x86:
955 {
956 static const IommuType_T aIommuTypes[] =
957 {
958 IommuType_None,
959 IommuType_Automatic,
960 IommuType_AMD
961 /** @todo Add Intel when it's supported. */
962 };
963 aSupportedIommuTypes.assign(aIommuTypes,
964 aIommuTypes + RT_ELEMENTS(aIommuTypes));
965 break;
966 }
967
968 case PlatformArchitecture_ARM:
969 {
970 static const IommuType_T aIommuTypes[] =
971 {
972 IommuType_None
973 };
974 aSupportedIommuTypes.assign(aIommuTypes,
975 aIommuTypes + RT_ELEMENTS(aIommuTypes));
976 break;
977 }
978
979 default:
980 AssertFailedStmt(aSupportedIommuTypes.clear());
981 break;
982 }
983
984 return S_OK;
985}
986
987HRESULT PlatformProperties::getSupportedTpmTypes(std::vector<TpmType_T> &aSupportedTpmTypes)
988{
989 switch (mPlatformArchitecture)
990 {
991 case PlatformArchitecture_x86:
992 {
993 static const TpmType_T aTpmTypes[] =
994 {
995 TpmType_None,
996 TpmType_v1_2,
997 TpmType_v2_0
998 };
999 aSupportedTpmTypes.assign(aTpmTypes,
1000 aTpmTypes + RT_ELEMENTS(aTpmTypes));
1001 break;
1002 }
1003
1004 case PlatformArchitecture_ARM:
1005 {
1006 static const TpmType_T aTpmTypes[] =
1007 {
1008 TpmType_None
1009 };
1010 aSupportedTpmTypes.assign(aTpmTypes,
1011 aTpmTypes + RT_ELEMENTS(aTpmTypes));
1012 break;
1013 }
1014
1015 default:
1016 AssertFailedStmt(aSupportedTpmTypes.clear());
1017 break;
1018 }
1019
1020 return S_OK;
1021}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette