devLib2  2.12
devLibPCIStrings.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <epicsAssert.h>
4 #define epicsExportSharedSymbols
5 #include "devLibPCI.h"
6 
7 const char* devPCIDeviceClassToString(int classId)
8 {
9  struct {int classId; const char* name;} classes [] =
10  {
11  { 0x0000, "legacy device" },
12  { 0x0001, "legacy VGA device" },
13 
14  { 0x0100, "SCSI controller" },
15  { 0x0101, "IDE controller" },
16  { 0x0102, "Floppy controller" },
17  { 0x0103, "IPI controller" },
18  { 0x0104, "RAID controller" },
19  { 0x0105, "ATA controller" },
20  { 0x0106, "SATA controller" },
21  { 0x0107, "srial attached SCSI controller" },
22  { 0x0180, "generic mass storage controller" },
23  { 0x01ff, "unknown mass storage controller" },
24 
25  { 0x0200, "Ethernet controller" },
26  { 0x0201, "Token Ring controller" },
27  { 0x0202, "FDDI controller" },
28  { 0x0203, "ATM controller" },
29  { 0x0204, "ISDN controller" },
30  { 0x0205, "WorldFip controller" },
31  { 0x0206, "PCIMG controller" },
32  { 0x0207, "Infiniband controller" },
33  { 0x0280, "generic network controller" },
34  { 0x02ff, "unknown network controller" },
35 
36  { 0x0300, "VGA controller" },
37  { 0x0301, "XGA controller" },
38  { 0x0302, "3D display controller" },
39  { 0x0380, "generic display controller" },
40  { 0x03ff, "unknown display controller" },
41 
42  { 0x0400, "video controller" },
43  { 0x0401, "audio controller" },
44  { 0x0402, "telephony controller" },
45  { 0x0403, "audio controller" },
46  { 0x0480, "generic multimedia controller" },
47  { 0x04ff, "unknown multimedia controller" },
48 
49  { 0x0500, "RAM controller" },
50  { 0x0501, "Flash controller" },
51  { 0x0580, "generic memory controller" },
52  { 0x05ff, "unknown memory controller" },
53 
54  { 0x0600, "PCI host bridge" },
55  { 0x0601, "ISA bridge" },
56  { 0x0602, "EISA bridge" },
57  { 0x0603, "Micro Channel bridge" },
58  { 0x0604, "PCI-to-PCI bridge" },
59  { 0x0605, "PCMCIA bridge" },
60  { 0x0606, "NuBus bridge" },
61  { 0x0607, "Cardbus bridge" },
62  { 0x0608, "RACEway bridge" },
63  { 0x0609, "semi-transparent PCI-to-PCI bridge" },
64  { 0x060a, "Infiniband PCI Host bridge" },
65  { 0x0680, "generic bus bridge" },
66  { 0x06ff, "unknown bus bridge" },
67 
68  { 0x0700, "serial port controller" },
69  { 0x0701, "parallel port controller" },
70  { 0x0702, "multi port serial controller" },
71  { 0x0703, "modem" },
72  { 0x0704, "GPIB controller" },
73  { 0x0705, "SmartCard controller" },
74  { 0x0780, "generic communication controller" },
75  { 0x07ff, "unknown communication controller" },
76 
77  { 0x0800, "PIC controller" },
78  { 0x0801, "DMA controller" },
79  { 0x0802, "timer" },
80  { 0x0803, "real time clock" },
81  { 0x0804, "PCI hot-plug controller" },
82  { 0x0805, "SD host controller" },
83  { 0x0805, "IOMMU controller" },
84  { 0x0880, "generic system peripheral" },
85  { 0x08ff, "unknown system peripheral" },
86 
87  { 0x0900, "keyboard" },
88  { 0x0901, "digitizer pen" },
89  { 0x0902, "scanner" },
90  { 0x0903, "gameport" },
91  { 0x0980, "generic input device" },
92  { 0x09ff, "unknown input device" },
93 
94  { 0x0a00, "docking station" },
95  { 0x0a80, "generic docking station" },
96  { 0x0aff, "unknown docking station" },
97 
98  { 0x0b00, "386 processor" },
99  { 0x0b01, "486 processor" },
100  { 0x0b02, "Pentium processor" },
101  { 0x0b10, "Alpha processor" },
102  { 0x0b20, "PowerPC processor" },
103  { 0x0b30, "MIPS processor" },
104  { 0x0b40, "co-processor" },
105  { 0x0b80, "generic processor" },
106  { 0x0bff, "unknown processor" },
107 
108  { 0x0c00, "FireWire controller" },
109  { 0x0c01, "ACCESS controller" },
110  { 0x0c02, "SSA controller" },
111  { 0x0c03, "USB controller" },
112  { 0x0c04, "Fibre Channel controller" },
113  { 0x0c05, "SMBus controller" },
114  { 0x0c06, "InfiniBand controller" },
115  { 0x0c07, "IPMI SMIC controller" },
116  { 0x0c08, "SERCOS controller" },
117  { 0x0c09, "CANBUS controller" },
118  { 0x0c80, "generic serial bus controller" },
119  { 0x0cff, "unknown serial bus controller" },
120 
121  { 0x0d00, "IRDA controller" },
122  { 0x0d01, "IR controller" },
123  { 0x0d10, "RF controller" },
124  { 0x0d11, "Bluetooth controller" },
125  { 0x0d12, "Broadband controller" },
126  { 0x0d20, "802.1a controller" },
127  { 0x0d21, "802.1b controller" },
128  { 0x0d80, "generic wireless controller" },
129  { 0x0dff, "unknown wireless controller" },
130 
131  { 0x0e00, "I2O controller" },
132  { 0x0e80, "generic intelligent controller" },
133  { 0x0eff, "unknown intelligent controller" },
134 
135  { 0x0f01, "satellite TV controller" },
136  { 0x0f02, "satellite audio controller" },
137  { 0x0f03, "satellite video controller" },
138  { 0x0f04, "satellite data communications controller" },
139  { 0x0f80, "generic satellite communications controller" },
140  { 0x0fff, "unknown satellite communications controller" },
141 
142  { 0x1000, "network and computing encryption device" },
143  { 0x1001, "entertainment encryption device" },
144  { 0x1080, "generic encryption device" },
145  { 0x10ff, "unknown encryption device" },
146 
147  { 0x1100, "DPIO controller" },
148  { 0x1101, "performance counter" },
149  { 0x1110, "communication synchronizer" },
150  { 0x1120, "signal processing management" },
151  { 0x1180, "generic signal processing controller" },
152  { 0x11ff, "unknown signal processing controller" },
153 
154  { 0x1200, "processing accelerator" },
155  { 0x1280, "generic processing accelerator" },
156  { 0x12ff, "unknown processing accelerator" },
157 
158  { 0x1300, "non-essential instrumentation" },
159  { 0x1380, "generic non-essential instrumentation" },
160  { 0x13ff, "unknown non-essential instrumentation" },
161 
162  { 0xffff, "unknown device class" }
163  };
164 
165  unsigned int n = 0;
166  const unsigned int nument = sizeof(classes)/sizeof(classes[0])-1;
167  unsigned int m = nument;
168  unsigned int i;
169 
170  classId >>= 8;
171 
172  /* binary search */
173  while (m>n)
174  {
175  i = (n+m)>>1;
176  assert(i<nument);
177  if (classes[i].classId == classId) return classes[i].name;
178  if (classes[i].classId < classId) n=i+1;
179  if (classes[i].classId > classId) m=i;
180  }
181  if(i<nument-1) {
182  /* unknown device class linear search */
183  classId |= 0xff;
184  assert(i<nument-1);
185  while (classes[++i].classId < classId);
186  return classes[i].name;
187  } else {
188  /* unknown device class */
189  return classes[nument].name;
190  }
191 }
const char * devPCIDeviceClassToString(int classId)
Translate class id to string.