VirtualBox

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

Last change on this file was 102113, checked in by vboxsync, 6 months ago

Main: Added IPlatformProperties::getSupportedBootDevices(), so that API clients know which boot devices actually are supported for a particular platform. This also returns the supported boot devices in the default order (was hardcoded in FE/Qt). bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 32.3 KB
Line 
1/* $Id: PlatformPropertiesImpl.cpp 102113 2023-11-15 16:23:52Z 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 || aChipset == ChipsetType_ARMv8Virtual ? 8 : 1;
420 break;
421 case StorageBus_USB:
422 case StorageBus_IDE:
423 case StorageBus_Floppy:
424 {
425 cCtrs = 1;
426 break;
427 }
428 default:
429 AssertMsgFailed(("Invalid bus type %d\n", aBus));
430 }
431
432 *aMaxInstances = cCtrs;
433
434 return S_OK;
435}
436
437HRESULT PlatformProperties::getDeviceTypesForStorageBus(StorageBus_T aBus,
438 std::vector<DeviceType_T> &aDeviceTypes)
439{
440 aDeviceTypes.resize(0);
441
442 /* no need to lock, this is const */
443 switch (aBus)
444 {
445 case StorageBus_IDE:
446 case StorageBus_SATA:
447 case StorageBus_SCSI:
448 case StorageBus_SAS:
449 case StorageBus_USB:
450 case StorageBus_VirtioSCSI:
451 {
452 aDeviceTypes.resize(2);
453 aDeviceTypes[0] = DeviceType_DVD;
454 aDeviceTypes[1] = DeviceType_HardDisk;
455 break;
456 }
457 case StorageBus_Floppy:
458 {
459 aDeviceTypes.resize(1);
460 aDeviceTypes[0] = DeviceType_Floppy;
461 break;
462 }
463 case StorageBus_PCIe:
464 {
465 aDeviceTypes.resize(1);
466 aDeviceTypes[0] = DeviceType_HardDisk;
467 break;
468 }
469 default:
470 AssertMsgFailed(("Invalid bus type %d\n", aBus));
471 }
472
473 return S_OK;
474}
475
476HRESULT PlatformProperties::getStorageBusForControllerType(StorageControllerType_T aStorageControllerType,
477 StorageBus_T *aStorageBus)
478{
479 /* no need to lock, this is const */
480 switch (aStorageControllerType)
481 {
482 case StorageControllerType_LsiLogic:
483 case StorageControllerType_BusLogic:
484 *aStorageBus = StorageBus_SCSI;
485 break;
486 case StorageControllerType_IntelAhci:
487 *aStorageBus = StorageBus_SATA;
488 break;
489 case StorageControllerType_PIIX3:
490 case StorageControllerType_PIIX4:
491 case StorageControllerType_ICH6:
492 *aStorageBus = StorageBus_IDE;
493 break;
494 case StorageControllerType_I82078:
495 *aStorageBus = StorageBus_Floppy;
496 break;
497 case StorageControllerType_LsiLogicSas:
498 *aStorageBus = StorageBus_SAS;
499 break;
500 case StorageControllerType_USB:
501 *aStorageBus = StorageBus_USB;
502 break;
503 case StorageControllerType_NVMe:
504 *aStorageBus = StorageBus_PCIe;
505 break;
506 case StorageControllerType_VirtioSCSI:
507 *aStorageBus = StorageBus_VirtioSCSI;
508 break;
509 default:
510 return setError(E_FAIL, tr("Invalid storage controller type %d\n"), aStorageBus);
511 }
512
513 return S_OK;
514}
515
516HRESULT PlatformProperties::getStorageControllerTypesForBus(StorageBus_T aStorageBus,
517 std::vector<StorageControllerType_T> &aStorageControllerTypes)
518{
519 aStorageControllerTypes.resize(0);
520
521 /* no need to lock, this is const */
522 switch (aStorageBus)
523 {
524 case StorageBus_IDE:
525 aStorageControllerTypes.resize(3);
526 aStorageControllerTypes[0] = StorageControllerType_PIIX4;
527 aStorageControllerTypes[1] = StorageControllerType_PIIX3;
528 aStorageControllerTypes[2] = StorageControllerType_ICH6;
529 break;
530 case StorageBus_SATA:
531 aStorageControllerTypes.resize(1);
532 aStorageControllerTypes[0] = StorageControllerType_IntelAhci;
533 break;
534 case StorageBus_SCSI:
535 aStorageControllerTypes.resize(2);
536 aStorageControllerTypes[0] = StorageControllerType_LsiLogic;
537 aStorageControllerTypes[1] = StorageControllerType_BusLogic;
538 break;
539 case StorageBus_Floppy:
540 aStorageControllerTypes.resize(1);
541 aStorageControllerTypes[0] = StorageControllerType_I82078;
542 break;
543 case StorageBus_SAS:
544 aStorageControllerTypes.resize(1);
545 aStorageControllerTypes[0] = StorageControllerType_LsiLogicSas;
546 break;
547 case StorageBus_USB:
548 aStorageControllerTypes.resize(1);
549 aStorageControllerTypes[0] = StorageControllerType_USB;
550 break;
551 case StorageBus_PCIe:
552 aStorageControllerTypes.resize(1);
553 aStorageControllerTypes[0] = StorageControllerType_NVMe;
554 break;
555 case StorageBus_VirtioSCSI:
556 aStorageControllerTypes.resize(1);
557 aStorageControllerTypes[0] = StorageControllerType_VirtioSCSI;
558 break;
559 default:
560 return setError(E_FAIL, tr("Invalid storage bus %d\n"), aStorageBus);
561 }
562
563 return S_OK;
564}
565
566HRESULT PlatformProperties::getStorageControllerHotplugCapable(StorageControllerType_T aControllerType,
567 BOOL *aHotplugCapable)
568{
569 switch (aControllerType)
570 {
571 case StorageControllerType_IntelAhci:
572 case StorageControllerType_USB:
573 *aHotplugCapable = true;
574 break;
575 case StorageControllerType_LsiLogic:
576 case StorageControllerType_LsiLogicSas:
577 case StorageControllerType_BusLogic:
578 case StorageControllerType_NVMe:
579 case StorageControllerType_VirtioSCSI:
580 case StorageControllerType_PIIX3:
581 case StorageControllerType_PIIX4:
582 case StorageControllerType_ICH6:
583 case StorageControllerType_I82078:
584 *aHotplugCapable = false;
585 break;
586 default:
587 AssertMsgFailedReturn(("Invalid controller type %d\n", aControllerType), E_FAIL);
588 }
589
590 return S_OK;
591}
592
593HRESULT PlatformProperties::getMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
594 USBControllerType_T aType,
595 ULONG *aMaxInstances)
596{
597 NOREF(aChipset);
598 ULONG cCtrs = 0;
599
600 /* no need to lock, this is const */
601 switch (aType)
602 {
603 case USBControllerType_OHCI:
604 case USBControllerType_EHCI:
605 case USBControllerType_XHCI:
606 {
607 cCtrs = 1;
608 break;
609 }
610 default:
611 AssertMsgFailed(("Invalid bus type %d\n", aType));
612 }
613
614 *aMaxInstances = cCtrs;
615
616 return S_OK;
617}
618
619HRESULT PlatformProperties::getSupportedParavirtProviders(std::vector<ParavirtProvider_T> &aSupportedParavirtProviders)
620{
621 static const ParavirtProvider_T aParavirtProviders[] =
622 {
623 ParavirtProvider_None,
624 ParavirtProvider_Default,
625 ParavirtProvider_Legacy,
626 ParavirtProvider_Minimal,
627 ParavirtProvider_HyperV,
628 ParavirtProvider_KVM,
629 };
630 aSupportedParavirtProviders.assign(aParavirtProviders,
631 aParavirtProviders + RT_ELEMENTS(aParavirtProviders));
632 return S_OK;
633}
634
635HRESULT PlatformProperties::getSupportedFirmwareTypes(std::vector<FirmwareType_T> &aSupportedFirmwareTypes)
636{
637 switch (mPlatformArchitecture)
638 {
639 case PlatformArchitecture_x86:
640 {
641 static const FirmwareType_T aFirmwareTypes[] =
642 {
643 FirmwareType_BIOS,
644 FirmwareType_EFI,
645 FirmwareType_EFI32,
646 FirmwareType_EFI64,
647 FirmwareType_EFIDUAL
648 };
649 aSupportedFirmwareTypes.assign(aFirmwareTypes,
650 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
651 break;
652 }
653
654 case PlatformArchitecture_ARM:
655 {
656 static const FirmwareType_T aFirmwareTypes[] =
657 {
658 FirmwareType_EFI,
659 FirmwareType_EFI32,
660 FirmwareType_EFI64,
661 FirmwareType_EFIDUAL
662 };
663 aSupportedFirmwareTypes.assign(aFirmwareTypes,
664 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
665 break;
666 }
667
668 default:
669 AssertFailedStmt(aSupportedFirmwareTypes.clear());
670 break;
671 }
672
673 return S_OK;
674}
675
676HRESULT PlatformProperties::getSupportedGraphicsControllerTypes(std::vector<GraphicsControllerType_T> &aSupportedGraphicsControllerTypes)
677{
678 switch (mPlatformArchitecture)
679 {
680 case PlatformArchitecture_x86:
681 {
682 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
683 {
684 GraphicsControllerType_Null,
685 GraphicsControllerType_VBoxVGA,
686 GraphicsControllerType_VBoxSVGA
687#ifdef VBOX_WITH_VMSVGA
688 , GraphicsControllerType_VMSVGA
689#endif
690 };
691 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes + 1 /* Don't include _Null */,
692 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
693 break;
694 }
695
696 case PlatformArchitecture_ARM:
697 {
698 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
699 {
700 GraphicsControllerType_Null,
701 GraphicsControllerType_QemuRamFB
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::getSupportedGuestOSTypes(std::vector<ComPtr<IGuestOSType> > &aSupportedGuestOSTypes)
720{
721 /* We only have all supported guest OS types as part of VBoxSVC, not in VBoxC itself. */
722#ifdef IN_VBOXSVC
723 std::vector<PlatformArchitecture_T> vecArchitectures(1 /* Size */, mPlatformArchitecture);
724 return mParent->i_getSupportedGuestOSTypes(vecArchitectures, aSupportedGuestOSTypes);
725#else /* VBoxC */
726 RT_NOREF(aSupportedGuestOSTypes);
727 return VBOX_E_NOT_SUPPORTED;
728#endif
729}
730
731HRESULT PlatformProperties::getSupportedNetAdpPromiscModePols(std::vector<NetworkAdapterPromiscModePolicy_T> &aSupportedNetworkAdapterPromiscModePolicies)
732{
733 static const NetworkAdapterPromiscModePolicy_T aNetworkAdapterPromiscModePolicies[] =
734 {
735 NetworkAdapterPromiscModePolicy_Deny,
736 NetworkAdapterPromiscModePolicy_AllowNetwork,
737 NetworkAdapterPromiscModePolicy_AllowAll
738 };
739
740 aSupportedNetworkAdapterPromiscModePolicies.assign(aNetworkAdapterPromiscModePolicies,
741 aNetworkAdapterPromiscModePolicies + RT_ELEMENTS(aNetworkAdapterPromiscModePolicies));
742 return S_OK;
743}
744
745HRESULT PlatformProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
746{
747 switch (mPlatformArchitecture)
748 {
749 case PlatformArchitecture_x86:
750 {
751 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
752 {
753 NetworkAdapterType_Null,
754 NetworkAdapterType_Am79C970A,
755 NetworkAdapterType_Am79C973
756#ifdef VBOX_WITH_E1000
757 , NetworkAdapterType_I82540EM
758 , NetworkAdapterType_I82543GC
759 , NetworkAdapterType_I82545EM
760#endif
761#ifdef VBOX_WITH_VIRTIO
762 , NetworkAdapterType_Virtio
763#endif
764 };
765 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes + 1 /* Don't include _Null */,
766 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
767 break;
768 }
769
770 case PlatformArchitecture_ARM:
771 {
772 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
773 {
774 NetworkAdapterType_Null
775#ifdef VBOX_WITH_E1000
776 , NetworkAdapterType_I82540EM
777 , NetworkAdapterType_I82543GC
778 , NetworkAdapterType_I82545EM
779#endif
780#ifdef VBOX_WITH_VIRTIO
781 , NetworkAdapterType_Virtio
782#endif
783 };
784 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes + 1 /* Don't include _Null */,
785 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
786 break;
787 }
788
789 default:
790 AssertFailedStmt(aSupportedNetworkAdapterTypes.clear());
791 break;
792 }
793
794 return S_OK;
795}
796
797HRESULT PlatformProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
798{
799 static const UartType_T aUartTypes[] =
800 {
801 UartType_U16450,
802 UartType_U16550A,
803 UartType_U16750
804 };
805 aSupportedUartTypes.assign(aUartTypes,
806 aUartTypes + RT_ELEMENTS(aUartTypes));
807 return S_OK;
808}
809
810HRESULT PlatformProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
811{
812 static const USBControllerType_T aUSBControllerTypes[] =
813 {
814 USBControllerType_OHCI,
815 USBControllerType_EHCI,
816 USBControllerType_XHCI
817 };
818 aSupportedUSBControllerTypes.assign(aUSBControllerTypes,
819 aUSBControllerTypes + RT_ELEMENTS(aUSBControllerTypes));
820 return S_OK;
821}
822
823HRESULT PlatformProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
824{
825 switch (mPlatformArchitecture)
826 {
827 case PlatformArchitecture_x86:
828 {
829 static const AudioControllerType_T aAudioControllerTypes[] =
830 {
831 AudioControllerType_AC97,
832 AudioControllerType_SB16,
833 AudioControllerType_HDA,
834 };
835 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
836 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
837 break;
838 }
839
840 case PlatformArchitecture_ARM:
841 {
842 static const AudioControllerType_T aAudioControllerTypes[] =
843 {
844 AudioControllerType_AC97,
845 AudioControllerType_HDA,
846 };
847 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
848 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
849 break;
850 }
851
852 default:
853 AssertFailedStmt(aSupportedAudioControllerTypes.clear());
854 break;
855 }
856
857
858 return S_OK;
859}
860
861HRESULT PlatformProperties::getSupportedBootDevices(std::vector<DeviceType_T> &aSupportedBootDevices)
862{
863 /* Note: This function returns the supported boot devices for the given architecture,
864 in the default order, to keep it simple for the caller. */
865
866 switch (mPlatformArchitecture)
867 {
868 case PlatformArchitecture_x86:
869 {
870 static const DeviceType_T aBootDevices[] =
871 {
872 DeviceType_Floppy,
873 DeviceType_DVD,
874 DeviceType_HardDisk,
875 DeviceType_Network
876 };
877 aSupportedBootDevices.assign(aBootDevices,
878 aBootDevices + RT_ELEMENTS(aBootDevices));
879 break;
880 }
881
882 case PlatformArchitecture_ARM:
883 {
884 static const DeviceType_T aBootDevices[] =
885 {
886 DeviceType_DVD,
887 DeviceType_HardDisk
888 /** @todo BUGBUG We need to test network booting via PXE on ARM first! */
889 };
890 aSupportedBootDevices.assign(aBootDevices,
891 aBootDevices + RT_ELEMENTS(aBootDevices));
892 break;
893 }
894
895 default:
896 AssertFailedStmt(aSupportedBootDevices.clear());
897 break;
898 }
899
900 return S_OK;
901}
902
903HRESULT PlatformProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
904{
905 switch (mPlatformArchitecture)
906 {
907 case PlatformArchitecture_x86:
908 {
909 static const StorageBus_T aStorageBuses[] =
910 {
911 StorageBus_SATA,
912 StorageBus_IDE,
913 StorageBus_SCSI,
914 StorageBus_Floppy,
915 StorageBus_SAS,
916 StorageBus_USB,
917 StorageBus_PCIe,
918 StorageBus_VirtioSCSI,
919 };
920 aSupportedStorageBuses.assign(aStorageBuses,
921 aStorageBuses + RT_ELEMENTS(aStorageBuses));
922 break;
923 }
924
925 case PlatformArchitecture_ARM:
926 {
927 static const StorageBus_T aStorageBuses[] =
928 {
929 StorageBus_VirtioSCSI
930 };
931 aSupportedStorageBuses.assign(aStorageBuses,
932 aStorageBuses + RT_ELEMENTS(aStorageBuses));
933 break;
934 }
935
936 default:
937 AssertFailedStmt(aSupportedStorageBuses.clear());
938 break;
939 }
940
941 return S_OK;
942}
943
944HRESULT PlatformProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
945{
946 switch (mPlatformArchitecture)
947 {
948 case PlatformArchitecture_x86:
949 {
950 static const StorageControllerType_T aStorageControllerTypes[] =
951 {
952 StorageControllerType_IntelAhci,
953 StorageControllerType_PIIX4,
954 StorageControllerType_PIIX3,
955 StorageControllerType_ICH6,
956 StorageControllerType_LsiLogic,
957 StorageControllerType_BusLogic,
958 StorageControllerType_I82078,
959 StorageControllerType_LsiLogicSas,
960 StorageControllerType_USB,
961 StorageControllerType_NVMe,
962 StorageControllerType_VirtioSCSI
963 };
964 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
965 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
966 break;
967 }
968
969 case PlatformArchitecture_ARM:
970 {
971 static const StorageControllerType_T aStorageControllerTypes[] =
972 {
973 StorageControllerType_VirtioSCSI
974 };
975 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
976 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
977 break;
978 }
979
980 default:
981 AssertFailedStmt(aSupportedStorageControllerTypes.clear());
982 break;
983 }
984
985 return S_OK;
986}
987
988HRESULT PlatformProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
989{
990 switch (mPlatformArchitecture)
991 {
992 case PlatformArchitecture_x86:
993 {
994 static const ChipsetType_T aChipsetTypes[] =
995 {
996 ChipsetType_PIIX3,
997 ChipsetType_ICH9
998 };
999 aSupportedChipsetTypes.assign(aChipsetTypes,
1000 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
1001 break;
1002 }
1003
1004 case PlatformArchitecture_ARM:
1005 {
1006 static const ChipsetType_T aChipsetTypes[] =
1007 {
1008 ChipsetType_ARMv8Virtual
1009 };
1010 aSupportedChipsetTypes.assign(aChipsetTypes,
1011 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
1012 break;
1013 }
1014
1015 default:
1016 AssertFailedStmt(aSupportedChipsetTypes.clear());
1017 break;
1018 }
1019
1020 return S_OK;
1021}
1022
1023HRESULT PlatformProperties::getSupportedIommuTypes(std::vector<IommuType_T> &aSupportedIommuTypes)
1024{
1025 switch (mPlatformArchitecture)
1026 {
1027 case PlatformArchitecture_x86:
1028 {
1029 static const IommuType_T aIommuTypes[] =
1030 {
1031 IommuType_None,
1032 IommuType_Automatic,
1033 IommuType_AMD
1034 /** @todo Add Intel when it's supported. */
1035 };
1036 aSupportedIommuTypes.assign(aIommuTypes,
1037 aIommuTypes + RT_ELEMENTS(aIommuTypes));
1038 break;
1039 }
1040
1041 case PlatformArchitecture_ARM:
1042 {
1043 static const IommuType_T aIommuTypes[] =
1044 {
1045 IommuType_None
1046 };
1047 aSupportedIommuTypes.assign(aIommuTypes,
1048 aIommuTypes + RT_ELEMENTS(aIommuTypes));
1049 break;
1050 }
1051
1052 default:
1053 AssertFailedStmt(aSupportedIommuTypes.clear());
1054 break;
1055 }
1056
1057 return S_OK;
1058}
1059
1060HRESULT PlatformProperties::getSupportedTpmTypes(std::vector<TpmType_T> &aSupportedTpmTypes)
1061{
1062 switch (mPlatformArchitecture)
1063 {
1064 case PlatformArchitecture_x86:
1065 {
1066 static const TpmType_T aTpmTypes[] =
1067 {
1068 TpmType_None,
1069 TpmType_v1_2,
1070 TpmType_v2_0
1071 };
1072 aSupportedTpmTypes.assign(aTpmTypes,
1073 aTpmTypes + RT_ELEMENTS(aTpmTypes));
1074 break;
1075 }
1076
1077 case PlatformArchitecture_ARM:
1078 {
1079 static const TpmType_T aTpmTypes[] =
1080 {
1081 TpmType_None
1082 };
1083 aSupportedTpmTypes.assign(aTpmTypes,
1084 aTpmTypes + RT_ELEMENTS(aTpmTypes));
1085 break;
1086 }
1087
1088 default:
1089 AssertFailedStmt(aSupportedTpmTypes.clear());
1090 break;
1091 }
1092
1093 return S_OK;
1094}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use