VirtualBox

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

Last change on this file since 105305 was 104865, checked in by vboxsync, 6 months ago

Main: Use VBOX_SVGA_VRAM_MIN_SIZE / VBOX_SVGA_VRAM_MIN_SIZE_3D for both, VBoxSVGA + VMSVGA, in PlatformProperties::s_getSupportedVRAMRange() + make the maximum value for GraphicsControllerType_QemuRamFB a power of two [build fix]. bugref:​10693

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