Changeset 36630 in vbox for trunk/include/VBox
- Timestamp:
- Apr 8, 2011 6:41:51 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 71093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pci.h
r36562 r36630 1018 1018 1019 1019 #if defined(__cplusplus) && defined(IN_RING3) 1020 /** 1021 * Document me. 1020 /* For RTStrPrintf(). */ 1021 #include <iprt/string.h> 1022 1023 /** 1024 * Class representing PCI address. PCI device consist of 1025 * bus, device and function numbers. Generally device PCI 1026 * address could be changed during runtime, but only by 1027 * an OS PCI driver. 1022 1028 * 1023 1029 * @remarks C++ classes (structs included) are not generally accepted in … … 1028 1034 struct PciBusAddress 1029 1035 { 1030 /** @todo r=bird: Add 'm', or 'm_' to data members. This is general1031 * practice in most of the source tree. */1032 int iBus;1033 int iDevice;1034 int iFn;1036 /** @todo: think if we'll need domain, which is higher 1037 * word of the address. */ 1038 int miBus; 1039 int miDevice; 1040 int miFn; 1035 1041 1036 1042 PciBusAddress() … … 1039 1045 } 1040 1046 1041 PciBusAddress(int bus, int device, int fn)1042 { 1043 init( bus, device, fn);1047 PciBusAddress(int iBus, int iDevice, int iFn) 1048 { 1049 init(iBus, iDevice, iFn); 1044 1050 } 1045 1051 1046 1052 PciBusAddress& clear() 1047 1053 { 1048 iBus = iDevice =iFn = -1;1054 miBus = miDevice = miFn = -1; 1049 1055 return *this; 1050 1056 } 1051 1057 1052 void init(int bus, int device, int fn)1053 { 1054 iBus = bus;1055 iDevice = device;1056 iFn = fn;1058 void init(int iBus, int iDevice, int iFn) 1059 { 1060 miBus = iBus; 1061 miDevice = iDevice; 1062 miFn = iFn; 1057 1063 } 1058 1064 1059 1065 void init(const PciBusAddress &a) 1060 1066 { 1061 iBus = a.iBus;1062 iDevice = a.iDevice;1063 iFn = a.iFn;1067 miBus = a.miBus; 1068 miDevice = a.miDevice; 1069 miFn = a.miFn; 1064 1070 } 1065 1071 1066 1072 bool operator<(const PciBusAddress &a) const 1067 1073 { 1068 if ( iBus < a.iBus)1074 if (miBus < a.miBus) 1069 1075 return true; 1070 1076 1071 if ( iBus > a.iBus)1077 if (miBus > a.miBus) 1072 1078 return false; 1073 1079 1074 if ( iDevice < a.iDevice)1080 if (miDevice < a.miDevice) 1075 1081 return true; 1076 1082 1077 if ( iDevice > a.iDevice)1083 if (miDevice > a.miDevice) 1078 1084 return false; 1079 1085 1080 if ( iFn < a.iFn)1086 if (miFn < a.miFn) 1081 1087 return true; 1082 1088 1083 if ( iFn > a.iFn)1089 if (miFn > a.miFn) 1084 1090 return false; 1085 1091 … … 1089 1095 bool operator==(const PciBusAddress &a) const 1090 1096 { 1091 return ( iBus == a.iBus)1092 && ( iDevice == a.iDevice)1093 && ( iFn == a.iFn);1097 return (miBus == a.miBus) 1098 && (miDevice == a.miDevice) 1099 && (miFn == a.miFn); 1094 1100 } 1095 1101 1096 1102 bool operator!=(const PciBusAddress &a) const 1097 1103 { 1098 return ( iBus != a.iBus)1099 || ( iDevice != a.iDevice)1100 || ( iFn != a.iFn);1104 return (miBus != a.miBus) 1105 || (miDevice != a.miDevice) 1106 || (miFn != a.miFn); 1101 1107 } 1102 1108 1103 1109 bool valid() const 1104 1110 { 1105 return (iBus != -1) && (iDevice != -1) && (iFn != -1); 1111 return (miBus != -1) 1112 && (miDevice != -1) 1113 && (miFn != -1); 1106 1114 } 1107 1115 … … 1109 1117 { 1110 1118 Assert(valid()); 1111 return ( iBus << 8) | (iDevice << 3) |iFn;1119 return (miBus << 8) | (miDevice << 3) | miFn; 1112 1120 } 1113 1121 1114 1122 PciBusAddress& fromLong(int32_t value) 1115 1123 { 1116 iBus = (value >> 8) & 0xff;1117 iDevice = (value & 0xff) >> 3;1118 iFn = (value & 7);1124 miBus = (value >> 8) & 0xff; 1125 miDevice = (value & 0xff) >> 3; 1126 miFn = (value & 7); 1119 1127 return *this; 1128 } 1129 1130 /** Create string representation of this PCI address. */ 1131 bool format(char* szBuf, int32_t cBufSize) 1132 { 1133 if (cBufSize < (/* bus */ 2 + /* : */ 1 + /* device */ 2 + /* . */ 1 + /* function*/ 1 + /* \0 */1)) 1134 return false; 1135 1136 if (valid()) 1137 RTStrPrintf(szBuf, cBufSize, "%02x:%02x.%01x", miBus, miDevice, miFn); 1138 else 1139 RTStrPrintf(szBuf, cBufSize, "%s", "<bad>"); 1140 1141 return true; 1120 1142 } 1121 1143 };
Note:
See TracChangeset
for help on using the changeset viewer.