VirtualBox

source: vbox/trunk/src/VBox/Main/include/BusAssignmentManager.h@ 34772

最後變更 在這個檔案從34772是 34331,由 vboxsync 提交於 14 年 前

PCI: more 4.0 interfaces

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.1 KB
 
1/* $Id: BusAssignmentManager.h 34331 2010-11-24 16:24:17Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox bus slots assignment manager
6 */
7
8/*
9 * Copyright (C) 2010 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.alldomusa.eu.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19#ifndef __BusAssignmentManager_h
20#define __BusAssignmentManager_h
21
22#include "VBox/types.h"
23#include "VirtualBoxBase.h"
24
25struct PciBusAddress
26{
27 int iBus;
28 int iDevice;
29 int iFn;
30
31 PciBusAddress()
32 {
33 clear();
34 }
35
36 PciBusAddress(int bus, int device, int fn)
37 : iBus(bus), iDevice(device), iFn(fn)
38 {
39 }
40
41 PciBusAddress& clear()
42 {
43 iBus = iDevice = iFn = -1;
44 return *this;
45 }
46
47 bool operator<(const PciBusAddress &a) const
48 {
49 if (iBus < a.iBus)
50 return true;
51
52 if (iBus > a.iBus)
53 return false;
54
55 if (iDevice < a.iDevice)
56 return true;
57
58 if (iDevice > a.iDevice)
59 return false;
60
61 if (iFn < a.iFn)
62 return true;
63
64 if (iFn > a.iFn)
65 return false;
66
67 return false;
68 }
69
70 bool operator==(const PciBusAddress &a) const
71 {
72 return (iBus == a.iBus)
73 && (iDevice == a.iDevice)
74 && (iFn == a.iFn);
75 }
76
77 bool operator!=(const PciBusAddress &a) const
78 {
79 return (iBus != a.iBus)
80 || (iDevice != a.iDevice)
81 || (iFn != a.iFn);
82 }
83
84 bool valid() const
85 {
86 return (iBus != -1) && (iDevice != -1) && (iFn != -1);
87 }
88
89 LONG asLong() const
90 {
91 Assert(valid());
92 return (iBus << 8) | (iDevice << 3) | iFn;
93 }
94
95 void fromLong(LONG value)
96 {
97 iBus = (value >> 8) & 0xff;
98 iDevice = (value & 0xff) >> 3;
99 iFn = (value & 7);
100 }
101};
102
103class BusAssignmentManager
104{
105private:
106 struct State;
107 State* pState;
108
109 BusAssignmentManager();
110 virtual ~BusAssignmentManager();
111
112public:
113 static BusAssignmentManager* createInstance(ChipsetType_T chipsetType);
114 virtual void AddRef();
115 virtual void Release();
116
117 virtual HRESULT assignPciDevice(const char* pszDevName, PCFGMNODE pCfg, PciBusAddress& Address, bool fAddressRequired = false);
118 virtual HRESULT assignPciDevice(const char* pszDevName, PCFGMNODE pCfg)
119 {
120 PciBusAddress Address;
121 return assignPciDevice(pszDevName, pCfg, Address, false);
122 }
123 virtual bool findPciAddress(const char* pszDevName, int iInstance, PciBusAddress& Address);
124 virtual bool hasPciDevice(const char* pszDevName, int iInstance)
125 {
126 PciBusAddress Address;
127 return findPciAddress(pszDevName, iInstance, Address);
128 }
129 virtual void listAttachedPciDevices(ComSafeArrayOut(IPciDeviceAttachment*, aAttached));
130};
131
132#endif // __BusAssignmentManager_h
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette