1 | /* $Id: BusAssignmentManager.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox bus slots assignment manager
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2024 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 | #ifndef MAIN_INCLUDED_BusAssignmentManager_h
|
---|
29 | #define MAIN_INCLUDED_BusAssignmentManager_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "VBox/types.h"
|
---|
35 | #include "VBox/pci.h"
|
---|
36 | #include "VirtualBoxBase.h"
|
---|
37 | #include <vector>
|
---|
38 |
|
---|
39 | class BusAssignmentManager
|
---|
40 | {
|
---|
41 | private:
|
---|
42 | struct State;
|
---|
43 | State *pState;
|
---|
44 |
|
---|
45 | BusAssignmentManager();
|
---|
46 | virtual ~BusAssignmentManager();
|
---|
47 |
|
---|
48 | HRESULT assignPCIDeviceImpl(const char *pszDevName, PCFGMNODE pCfg, PCIBusAddress& GuestAddress,
|
---|
49 | PCIBusAddress HostAddress, bool fGuestAddressRequired = false);
|
---|
50 |
|
---|
51 | public:
|
---|
52 | struct PCIDeviceInfo
|
---|
53 | {
|
---|
54 | com::Utf8Str strDeviceName;
|
---|
55 | PCIBusAddress guestAddress;
|
---|
56 | PCIBusAddress hostAddress;
|
---|
57 | };
|
---|
58 |
|
---|
59 | static BusAssignmentManager *createInstance(PCVMMR3VTABLE pVMM, ChipsetType_T chipsetType, IommuType_T iommuType);
|
---|
60 | virtual void AddRef();
|
---|
61 | virtual void Release();
|
---|
62 |
|
---|
63 | virtual HRESULT assignHostPCIDevice(const char *pszDevName, PCFGMNODE pCfg, PCIBusAddress HostAddress,
|
---|
64 | PCIBusAddress& GuestAddress, bool fAddressRequired = false)
|
---|
65 | {
|
---|
66 | return assignPCIDeviceImpl(pszDevName, pCfg, GuestAddress, HostAddress, fAddressRequired);
|
---|
67 | }
|
---|
68 |
|
---|
69 | virtual HRESULT assignPCIDevice(const char *pszDevName, PCFGMNODE pCfg, PCIBusAddress& Address, bool fAddressRequired = false)
|
---|
70 | {
|
---|
71 | PCIBusAddress HostAddress;
|
---|
72 | return assignPCIDeviceImpl(pszDevName, pCfg, Address, HostAddress, fAddressRequired);
|
---|
73 | }
|
---|
74 |
|
---|
75 | virtual HRESULT assignPCIDevice(const char *pszDevName, PCFGMNODE pCfg)
|
---|
76 | {
|
---|
77 | PCIBusAddress GuestAddress;
|
---|
78 | PCIBusAddress HostAddress;
|
---|
79 | return assignPCIDeviceImpl(pszDevName, pCfg, GuestAddress, HostAddress, false);
|
---|
80 | }
|
---|
81 | virtual bool findPCIAddress(const char *pszDevName, int iInstance, PCIBusAddress& Address);
|
---|
82 | virtual bool hasPCIDevice(const char *pszDevName, int iInstance)
|
---|
83 | {
|
---|
84 | PCIBusAddress Address;
|
---|
85 | return findPCIAddress(pszDevName, iInstance, Address);
|
---|
86 | }
|
---|
87 | virtual void listAttachedPCIDevices(std::vector<PCIDeviceInfo> &aAttached);
|
---|
88 | };
|
---|
89 |
|
---|
90 | #endif /* !MAIN_INCLUDED_BusAssignmentManager_h */
|
---|