2 * Copyright 2008-2009 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
10 #include "DevicePCI.h"
17 #undef B_TRANSLATION_CONTEXT
18 #define B_TRANSLATION_CONTEXT "DevicePCI"
21 #include "dm_wrapper.h"
23 #include "pci-utils.h"
27 DevicePCI::DevicePCI(Device
* parent
)
35 fSubsystemVendorId(0),
41 DevicePCI::~DevicePCI()
46 BString
ToHex(uint16 num
)
49 ss
.flags(std::ios::hex
| std::ios::showbase
);
51 return BString(ss
.str().c_str());
56 DevicePCI::InitFromAttributes()
58 // Process the attributes
59 fClassBaseId
= atoi(fAttributeMap
[B_DEVICE_TYPE
].String());
60 fClassSubId
= atoi(fAttributeMap
[B_DEVICE_SUB_TYPE
].String());
61 fClassApiId
= atoi(fAttributeMap
[B_DEVICE_INTERFACE
].String());
62 fVendorId
= atoi(fAttributeMap
[B_DEVICE_VENDOR_ID
].String());
63 fDeviceId
= atoi(fAttributeMap
[B_DEVICE_ID
].String());
65 // Looks better in Hex, so rewrite
66 fAttributeMap
[B_DEVICE_TYPE
] = ToHex(fClassBaseId
);
67 fAttributeMap
[B_DEVICE_SUB_TYPE
] = ToHex(fClassSubId
);
68 fAttributeMap
[B_DEVICE_INTERFACE
] = ToHex(fClassApiId
);
69 fAttributeMap
[B_DEVICE_VENDOR_ID
] = ToHex(fVendorId
);
70 fAttributeMap
[B_DEVICE_ID
] = ToHex(fDeviceId
);
74 get_class_info(fClassBaseId
, fClassSubId
, fClassApiId
, classInfo
,
77 // Fetch ManufacturerName
78 BString ManufacturerName
;
81 get_vendor_info(fVendorId
, &venShort
, &venFull
);
82 if (!venShort
&& !venFull
) {
83 ManufacturerName
<< B_TRANSLATE("Unknown");
84 } else if (venShort
&& venFull
) {
85 ManufacturerName
<< venFull
<< "(" << venShort
<< ")";
87 ManufacturerName
<< (venShort
? venShort
: venFull
);
94 get_device_info(fVendorId
, fDeviceId
, fSubsystemVendorId
, fSubSystemId
,
96 if (!devShort
&& !devFull
) {
97 DeviceName
<< B_TRANSLATE("Unknown");
98 } else if (devShort
&& devFull
) {
99 DeviceName
<< devFull
<< "(" << devShort
<< ")";
101 DeviceName
<< (devShort
? devShort
: devFull
);
104 SetAttribute(B_TRANSLATE("Device name"), DeviceName
);
105 SetAttribute(B_TRANSLATE("Manufacturer"), ManufacturerName
);
106 SetAttribute(B_TRANSLATE("Driver used"), B_TRANSLATE("Not implemented"));
107 SetAttribute(B_TRANSLATE("Device paths"), B_TRANSLATE("Not implemented"));
108 SetAttribute(B_TRANSLATE("Class info"), classInfo
);
109 fCategory
= (Category
)fClassBaseId
;
111 outlineName
<< ManufacturerName
<< " " << DeviceName
;
112 SetText(outlineName
.String());
117 DevicePCI::GetBusAttributes()
119 Attributes attributes
;
120 attributes
.push_back(GetAttribute(B_DEVICE_TYPE
));
121 attributes
.push_back(GetAttribute(B_DEVICE_SUB_TYPE
));
122 attributes
.push_back(GetAttribute(B_DEVICE_INTERFACE
));
123 attributes
.push_back(GetAttribute(B_DEVICE_VENDOR_ID
));
124 attributes
.push_back(GetAttribute(B_DEVICE_ID
));
130 DevicePCI::GetBusStrings()
132 BString
str("Class Info:\t\t\t\t: %classInfo%");
133 str
.ReplaceFirst("%classInfo%", fAttributeMap
["Class Info"]);
139 DevicePCI::GetBusTabName()
141 return B_TRANSLATE("PCI Information");