VirtualBox

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

Last change on this file since 104780 was 104780, checked in by vboxsync, 12 months ago

Main: Added new API IPlatformProperties::getSupportedVRAMRange() to return the VRAM range of a given graphics controller. bugref:​10693

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