2 * Copyright 2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
12 get_class_info(uint8 pci_class_base_id
, uint8 pci_class_sub_id
, uint8 pci_class_api_id
, char *classInfo
, size_t size
)
14 if (pci_class_base_id
== 0x80)
15 snprintf(classInfo
, size
, " (Other)");
17 PCI_CLASSCODETABLE
*foundItem
= NULL
;
19 for (i
= 0; i
< (int)PCI_CLASSCODETABLE_LEN
; i
++) {
20 if ((pci_class_base_id
== PciClassCodeTable
[i
].BaseClass
)
21 && (pci_class_sub_id
== PciClassCodeTable
[i
].SubClass
)) {
22 foundItem
= &PciClassCodeTable
[i
];
23 if (pci_class_api_id
== PciClassCodeTable
[i
].ProgIf
)
28 if (pci_class_sub_id
!= 0x80)
29 snprintf(classInfo
, size
, "%s (%s%s%s)", foundItem
->BaseDesc
, foundItem
->SubDesc
,
30 (foundItem
->ProgDesc
&& strcmp("", foundItem
->ProgDesc
)) ? ", " : "", foundItem
->ProgDesc
);
32 snprintf(classInfo
, size
, "%s", foundItem
->BaseDesc
);
34 snprintf(classInfo
, size
, "%s (%u:%u:%u)", "(Unknown)",
35 pci_class_base_id
, pci_class_sub_id
, pci_class_api_id
);
40 get_vendor_info(uint16 vendorID
, const char **venShort
, const char **venFull
)
43 for (i
= 0; i
< (int)PCI_VENTABLE_LEN
; i
++) {
44 if (PciVenTable
[i
].VenId
== vendorID
) {
45 if (PciVenTable
[i
].VenShort
&& PciVenTable
[i
].VenFull
46 && 0 == strcmp(PciVenTable
[i
].VenShort
, PciVenTable
[i
].VenFull
)) {
47 *venShort
= PciVenTable
[i
].VenShort
[0] ? PciVenTable
[i
].VenShort
: NULL
;
50 *venShort
= PciVenTable
[i
].VenShort
&& PciVenTable
[i
].VenShort
[0] ? PciVenTable
[i
].VenShort
: NULL
;
51 *venFull
= PciVenTable
[i
].VenFull
&& PciVenTable
[i
].VenFull
[0] ? PciVenTable
[i
].VenFull
: NULL
;
62 get_device_info(uint16 vendorID
, uint16 deviceID
,
63 uint16 subvendorID
, uint16 subsystemID
, const char **devShort
, const char **devFull
)
69 // search for the device
70 for (i
= 0; i
< (int)PCI_DEVTABLE_LEN
; i
++) {
71 if (PciDevTable
[i
].VenId
== vendorID
&& PciDevTable
[i
].DevId
== deviceID
) {
72 *devShort
= PciDevTable
[i
].ChipDesc
&& PciDevTable
[i
].ChipDesc
[0] ? PciDevTable
[i
].ChipDesc
: NULL
;
73 if (PciDevTable
[i
].SubVenId
== 0 || PciDevTable
[i
].SubDevId
== 0)
79 // search for the subsystem eventually
80 for (; i
< (int)PCI_DEVTABLE_LEN
; i
++) {
81 if (PciDevTable
[i
].VenId
!= vendorID
|| PciDevTable
[i
].DevId
!= deviceID
)
83 if (PciDevTable
[i
].SubVenId
== subvendorID
&& PciDevTable
[i
].SubDevId
== subsystemID
) {
84 *devFull
= PciDevTable
[i
].ChipDesc
&& PciDevTable
[i
].ChipDesc
[0] ? PciDevTable
[i
].ChipDesc
: NULL
;