1 | /* $Id: PlatformPropertiesImpl.cpp 101057 2023-09-07 17:12:48Z 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.alldomusa.eu.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 | */
|
---|
45 | PlatformProperties::PlatformProperties()
|
---|
46 | : mParent(NULL)
|
---|
47 | , mPlatformArchitecture(PlatformArchitecture_None)
|
---|
48 | , mfIsHost(false)
|
---|
49 | {
|
---|
50 | }
|
---|
51 |
|
---|
52 | PlatformProperties::~PlatformProperties()
|
---|
53 | {
|
---|
54 | uninit();
|
---|
55 | }
|
---|
56 |
|
---|
57 | HRESULT PlatformProperties::FinalConstruct()
|
---|
58 | {
|
---|
59 | return BaseFinalConstruct();
|
---|
60 | }
|
---|
61 |
|
---|
62 | void 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 | */
|
---|
77 | HRESULT 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 | */
|
---|
117 | HRESULT 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 | */
|
---|
135 | PlatformArchitecture_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 |
|
---|
147 | void 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 |
|
---|
161 | HRESULT PlatformProperties::getSerialPortCount(ULONG *count)
|
---|
162 | {
|
---|
163 | /* no need to lock, this is const */
|
---|
164 | *count = SchemaDefs::SerialPortCount;
|
---|
165 |
|
---|
166 | return S_OK;
|
---|
167 | }
|
---|
168 |
|
---|
169 | HRESULT PlatformProperties::getParallelPortCount(ULONG *count)
|
---|
170 | {
|
---|
171 | /* no need to lock, this is const */
|
---|
172 | *count = SchemaDefs::ParallelPortCount;
|
---|
173 |
|
---|
174 | return S_OK;
|
---|
175 | }
|
---|
176 |
|
---|
177 | HRESULT PlatformProperties::getMaxBootPosition(ULONG *aMaxBootPosition)
|
---|
178 | {
|
---|
179 | /* no need to lock, this is const */
|
---|
180 | *aMaxBootPosition = SchemaDefs::MaxBootPosition;
|
---|
181 |
|
---|
182 | return S_OK;
|
---|
183 | }
|
---|
184 |
|
---|
185 | HRESULT PlatformProperties::getRawModeSupported(BOOL *aRawModeSupported)
|
---|
186 | {
|
---|
187 | *aRawModeSupported = FALSE;
|
---|
188 | return S_OK;
|
---|
189 | }
|
---|
190 |
|
---|
191 | HRESULT 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 |
|
---|
201 | HRESULT 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 */
|
---|
223 | ULONG 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 |
|
---|
242 | HRESULT PlatformProperties::getMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *aMaxNetworkAdapters)
|
---|
243 | {
|
---|
244 | *aMaxNetworkAdapters = PlatformProperties::s_getMaxNetworkAdapters(aChipset);
|
---|
245 |
|
---|
246 | return S_OK;
|
---|
247 | }
|
---|
248 |
|
---|
249 | /* static */
|
---|
250 | ULONG 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 |
|
---|
275 | HRESULT 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 |
|
---|
283 | HRESULT 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 |
|
---|
315 | HRESULT 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 |
|
---|
356 | HRESULT 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 |
|
---|
405 | HRESULT PlatformProperties::getMaxInstancesOfStorageBus(ChipsetType_T aChipset,
|
---|
406 | StorageBus_T aBus,
|
---|
407 | ULONG *aMaxInstances)
|
---|
408 | {
|
---|
409 | ULONG cCtrs = 0;
|
---|
410 |
|
---|
411 | /* no need to lock, this is const */
|
---|
412 | switch (aBus)
|
---|
413 | {
|
---|
414 | case StorageBus_SATA:
|
---|
415 | case StorageBus_SCSI:
|
---|
416 | case StorageBus_SAS:
|
---|
417 | case StorageBus_PCIe:
|
---|
418 | case StorageBus_VirtioSCSI:
|
---|
419 | cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
|
---|
420 | 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 |
|
---|
437 | HRESULT 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 |
|
---|
476 | HRESULT 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 |
|
---|
516 | HRESULT 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 |
|
---|
566 | HRESULT 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 |
|
---|
593 | HRESULT 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 |
|
---|
619 | HRESULT 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 |
|
---|
635 | HRESULT PlatformProperties::getSupportedFirmwareTypes(std::vector<FirmwareType_T> &aSupportedFirmwareTypes)
|
---|
636 | {
|
---|
637 | static const FirmwareType_T aFirmwareTypes[] =
|
---|
638 | {
|
---|
639 | FirmwareType_BIOS,
|
---|
640 | FirmwareType_EFI,
|
---|
641 | FirmwareType_EFI32,
|
---|
642 | FirmwareType_EFI64,
|
---|
643 | FirmwareType_EFIDUAL,
|
---|
644 | };
|
---|
645 | aSupportedFirmwareTypes.assign(aFirmwareTypes,
|
---|
646 | aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
|
---|
647 | return S_OK;
|
---|
648 | }
|
---|
649 |
|
---|
650 | HRESULT PlatformProperties::getSupportedGraphicsControllerTypes(std::vector<GraphicsControllerType_T> &aSupportedGraphicsControllerTypes)
|
---|
651 | {
|
---|
652 | static const GraphicsControllerType_T aGraphicsControllerTypes[] =
|
---|
653 | {
|
---|
654 | GraphicsControllerType_VBoxVGA,
|
---|
655 | GraphicsControllerType_VMSVGA,
|
---|
656 | GraphicsControllerType_VBoxSVGA,
|
---|
657 | GraphicsControllerType_Null,
|
---|
658 | };
|
---|
659 | aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes,
|
---|
660 | aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
|
---|
661 | return S_OK;
|
---|
662 | }
|
---|
663 |
|
---|
664 | HRESULT PlatformProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
|
---|
665 | {
|
---|
666 | static const NetworkAdapterType_T aNetworkAdapterTypes[] =
|
---|
667 | {
|
---|
668 | NetworkAdapterType_Am79C970A,
|
---|
669 | NetworkAdapterType_Am79C973,
|
---|
670 | NetworkAdapterType_I82540EM,
|
---|
671 | NetworkAdapterType_I82543GC,
|
---|
672 | NetworkAdapterType_I82545EM,
|
---|
673 | NetworkAdapterType_Virtio,
|
---|
674 | };
|
---|
675 | aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes,
|
---|
676 | aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
|
---|
677 | return S_OK;
|
---|
678 | }
|
---|
679 |
|
---|
680 | HRESULT PlatformProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
|
---|
681 | {
|
---|
682 | static const UartType_T aUartTypes[] =
|
---|
683 | {
|
---|
684 | UartType_U16450,
|
---|
685 | UartType_U16550A,
|
---|
686 | UartType_U16750,
|
---|
687 | };
|
---|
688 | aSupportedUartTypes.assign(aUartTypes,
|
---|
689 | aUartTypes + RT_ELEMENTS(aUartTypes));
|
---|
690 | return S_OK;
|
---|
691 | }
|
---|
692 |
|
---|
693 | HRESULT PlatformProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
|
---|
694 | {
|
---|
695 | static const USBControllerType_T aUSBControllerTypes[] =
|
---|
696 | {
|
---|
697 | USBControllerType_OHCI,
|
---|
698 | USBControllerType_EHCI,
|
---|
699 | USBControllerType_XHCI,
|
---|
700 | };
|
---|
701 | aSupportedUSBControllerTypes.assign(aUSBControllerTypes,
|
---|
702 | aUSBControllerTypes + RT_ELEMENTS(aUSBControllerTypes));
|
---|
703 | return S_OK;
|
---|
704 | }
|
---|
705 |
|
---|
706 | HRESULT PlatformProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
|
---|
707 | {
|
---|
708 | static const AudioControllerType_T aAudioControllerTypes[] =
|
---|
709 | {
|
---|
710 | AudioControllerType_AC97,
|
---|
711 | AudioControllerType_SB16,
|
---|
712 | AudioControllerType_HDA,
|
---|
713 | };
|
---|
714 | aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
|
---|
715 | aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
|
---|
716 | return S_OK;
|
---|
717 | }
|
---|
718 |
|
---|
719 | HRESULT PlatformProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
|
---|
720 | {
|
---|
721 | static const StorageBus_T aStorageBuses[] =
|
---|
722 | {
|
---|
723 | StorageBus_SATA,
|
---|
724 | StorageBus_IDE,
|
---|
725 | StorageBus_SCSI,
|
---|
726 | StorageBus_Floppy,
|
---|
727 | StorageBus_SAS,
|
---|
728 | StorageBus_USB,
|
---|
729 | StorageBus_PCIe,
|
---|
730 | StorageBus_VirtioSCSI,
|
---|
731 | };
|
---|
732 | aSupportedStorageBuses.assign(aStorageBuses,
|
---|
733 | aStorageBuses + RT_ELEMENTS(aStorageBuses));
|
---|
734 | return S_OK;
|
---|
735 | }
|
---|
736 |
|
---|
737 | HRESULT PlatformProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
|
---|
738 | {
|
---|
739 | static const StorageControllerType_T aStorageControllerTypes[] =
|
---|
740 | {
|
---|
741 | StorageControllerType_IntelAhci,
|
---|
742 | StorageControllerType_PIIX4,
|
---|
743 | StorageControllerType_PIIX3,
|
---|
744 | StorageControllerType_ICH6,
|
---|
745 | StorageControllerType_LsiLogic,
|
---|
746 | StorageControllerType_BusLogic,
|
---|
747 | StorageControllerType_I82078,
|
---|
748 | StorageControllerType_LsiLogicSas,
|
---|
749 | StorageControllerType_USB,
|
---|
750 | StorageControllerType_NVMe,
|
---|
751 | StorageControllerType_VirtioSCSI,
|
---|
752 | };
|
---|
753 | aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
|
---|
754 | aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
|
---|
755 | return S_OK;
|
---|
756 | }
|
---|
757 |
|
---|
758 | HRESULT PlatformProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
|
---|
759 | {
|
---|
760 | static const ChipsetType_T aChipsetTypes[] =
|
---|
761 | {
|
---|
762 | ChipsetType_PIIX3,
|
---|
763 | ChipsetType_ICH9,
|
---|
764 | };
|
---|
765 | aSupportedChipsetTypes.assign(aChipsetTypes,
|
---|
766 | aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
|
---|
767 | return S_OK;
|
---|
768 | }
|
---|
769 |
|
---|
770 | HRESULT PlatformProperties::getSupportedIommuTypes(std::vector<IommuType_T> &aSupportedIommuTypes)
|
---|
771 | {
|
---|
772 | static const IommuType_T aIommuTypes[] =
|
---|
773 | {
|
---|
774 | IommuType_None,
|
---|
775 | IommuType_Automatic,
|
---|
776 | IommuType_AMD,
|
---|
777 | /** @todo Add Intel when it's supported. */
|
---|
778 | };
|
---|
779 | aSupportedIommuTypes.assign(aIommuTypes,
|
---|
780 | aIommuTypes + RT_ELEMENTS(aIommuTypes));
|
---|
781 | return S_OK;
|
---|
782 | }
|
---|
783 |
|
---|
784 | HRESULT PlatformProperties::getSupportedTpmTypes(std::vector<TpmType_T> &aSupportedTpmTypes)
|
---|
785 | {
|
---|
786 | static const TpmType_T aTpmTypes[] =
|
---|
787 | {
|
---|
788 | TpmType_None,
|
---|
789 | TpmType_v1_2,
|
---|
790 | TpmType_v2_0
|
---|
791 | };
|
---|
792 | aSupportedTpmTypes.assign(aTpmTypes,
|
---|
793 | aTpmTypes + RT_ELEMENTS(aTpmTypes));
|
---|
794 | return S_OK;
|
---|
795 | }
|
---|