pci_subr.c revision 1.22 1 1.22 thorpej /* $NetBSD: pci_subr.c,v 1.22 1998/04/14 21:24:50 thorpej Exp $ */
2 1.3 cgd
3 1.1 mycroft /*
4 1.22 thorpej * Copyright (c) 1997 Zubin D. Dittia. All rights reserved.
5 1.13 cgd * Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
6 1.1 mycroft * Copyright (c) 1994 Charles Hannum. All rights reserved.
7 1.1 mycroft *
8 1.1 mycroft * Redistribution and use in source and binary forms, with or without
9 1.1 mycroft * modification, are permitted provided that the following conditions
10 1.1 mycroft * are met:
11 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
12 1.1 mycroft * notice, this list of conditions and the following disclaimer.
13 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
15 1.1 mycroft * documentation and/or other materials provided with the distribution.
16 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
17 1.1 mycroft * must display the following acknowledgement:
18 1.1 mycroft * This product includes software developed by Charles Hannum.
19 1.1 mycroft * 4. The name of the author may not be used to endorse or promote products
20 1.1 mycroft * derived from this software without specific prior written permission.
21 1.1 mycroft *
22 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 mycroft */
33 1.1 mycroft
34 1.1 mycroft /*
35 1.10 cgd * PCI autoconfiguration support functions.
36 1.1 mycroft */
37 1.21 enami
38 1.21 enami #include "opt_pciverbose.h"
39 1.1 mycroft
40 1.1 mycroft #include <sys/param.h>
41 1.10 cgd #include <sys/systm.h>
42 1.1 mycroft #include <sys/device.h>
43 1.1 mycroft
44 1.10 cgd #include <dev/pci/pcireg.h>
45 1.7 cgd #include <dev/pci/pcivar.h>
46 1.10 cgd #ifdef PCIVERBOSE
47 1.10 cgd #include <dev/pci/pcidevs.h>
48 1.10 cgd #endif
49 1.10 cgd
50 1.10 cgd /*
51 1.10 cgd * Descriptions of known PCI classes and subclasses.
52 1.10 cgd *
53 1.10 cgd * Subclasses are described in the same way as classes, but have a
54 1.10 cgd * NULL subclass pointer.
55 1.10 cgd */
56 1.10 cgd struct pci_class {
57 1.10 cgd char *name;
58 1.10 cgd int val; /* as wide as pci_{,sub}class_t */
59 1.10 cgd struct pci_class *subclasses;
60 1.10 cgd };
61 1.10 cgd
62 1.10 cgd struct pci_class pci_subclass_prehistoric[] = {
63 1.10 cgd { "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC, },
64 1.10 cgd { "VGA", PCI_SUBCLASS_PREHISTORIC_VGA, },
65 1.10 cgd { 0 }
66 1.10 cgd };
67 1.10 cgd
68 1.10 cgd struct pci_class pci_subclass_mass_storage[] = {
69 1.10 cgd { "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI, },
70 1.10 cgd { "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE, },
71 1.10 cgd { "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY, },
72 1.10 cgd { "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI, },
73 1.20 cgd { "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID, },
74 1.10 cgd { "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC, },
75 1.10 cgd { 0 },
76 1.10 cgd };
77 1.10 cgd
78 1.10 cgd struct pci_class pci_subclass_network[] = {
79 1.10 cgd { "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET, },
80 1.10 cgd { "token ring", PCI_SUBCLASS_NETWORK_TOKENRING, },
81 1.10 cgd { "FDDI", PCI_SUBCLASS_NETWORK_FDDI, },
82 1.20 cgd { "ATM", PCI_SUBCLASS_NETWORK_ATM, },
83 1.10 cgd { "miscellaneous", PCI_SUBCLASS_NETWORK_MISC, },
84 1.10 cgd { 0 },
85 1.10 cgd };
86 1.10 cgd
87 1.10 cgd struct pci_class pci_subclass_display[] = {
88 1.10 cgd { "VGA", PCI_SUBCLASS_DISPLAY_VGA, },
89 1.10 cgd { "XGA", PCI_SUBCLASS_DISPLAY_XGA, },
90 1.10 cgd { "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC, },
91 1.10 cgd { 0 },
92 1.10 cgd };
93 1.10 cgd
94 1.10 cgd struct pci_class pci_subclass_multimedia[] = {
95 1.10 cgd { "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO, },
96 1.10 cgd { "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO, },
97 1.10 cgd { "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC, },
98 1.10 cgd { 0 },
99 1.10 cgd };
100 1.10 cgd
101 1.10 cgd struct pci_class pci_subclass_memory[] = {
102 1.10 cgd { "RAM", PCI_SUBCLASS_MEMORY_RAM, },
103 1.10 cgd { "flash", PCI_SUBCLASS_MEMORY_FLASH, },
104 1.10 cgd { "miscellaneous", PCI_SUBCLASS_MEMORY_MISC, },
105 1.10 cgd { 0 },
106 1.10 cgd };
107 1.10 cgd
108 1.10 cgd struct pci_class pci_subclass_bridge[] = {
109 1.10 cgd { "host", PCI_SUBCLASS_BRIDGE_HOST, },
110 1.10 cgd { "ISA", PCI_SUBCLASS_BRIDGE_ISA, },
111 1.10 cgd { "EISA", PCI_SUBCLASS_BRIDGE_EISA, },
112 1.10 cgd { "MicroChannel", PCI_SUBCLASS_BRIDGE_MC, },
113 1.10 cgd { "PCI", PCI_SUBCLASS_BRIDGE_PCI, },
114 1.10 cgd { "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA, },
115 1.20 cgd { "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS, },
116 1.20 cgd { "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS, },
117 1.10 cgd { "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC, },
118 1.10 cgd { 0 },
119 1.10 cgd };
120 1.10 cgd
121 1.20 cgd struct pci_class pci_subclass_communications[] = {
122 1.20 cgd { "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL, },
123 1.20 cgd { "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL, },
124 1.20 cgd { "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC, },
125 1.20 cgd { 0 },
126 1.20 cgd };
127 1.20 cgd
128 1.20 cgd struct pci_class pci_subclass_system[] = {
129 1.20 cgd { "8259 PIC", PCI_SUBCLASS_SYSTEM_PIC, },
130 1.20 cgd { "8237 DMA", PCI_SUBCLASS_SYSTEM_DMA, },
131 1.20 cgd { "8254 timer", PCI_SUBCLASS_SYSTEM_TIMER, },
132 1.20 cgd { "RTC", PCI_SUBCLASS_SYSTEM_RTC, },
133 1.20 cgd { "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC, },
134 1.20 cgd { 0 },
135 1.20 cgd };
136 1.20 cgd
137 1.20 cgd struct pci_class pci_subclass_input[] = {
138 1.20 cgd { "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD, },
139 1.20 cgd { "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER, },
140 1.20 cgd { "mouse", PCI_SUBCLASS_INPUT_MOUSE, },
141 1.20 cgd { "miscellaneous", PCI_SUBCLASS_INPUT_MISC, },
142 1.20 cgd { 0 },
143 1.20 cgd };
144 1.20 cgd
145 1.20 cgd struct pci_class pci_subclass_dock[] = {
146 1.20 cgd { "generic", PCI_SUBCLASS_DOCK_GENERIC, },
147 1.20 cgd { "miscellaneous", PCI_SUBCLASS_DOCK_MISC, },
148 1.20 cgd { 0 },
149 1.20 cgd };
150 1.20 cgd
151 1.20 cgd struct pci_class pci_subclass_processor[] = {
152 1.20 cgd { "386", PCI_SUBCLASS_PROCESSOR_386, },
153 1.20 cgd { "486", PCI_SUBCLASS_PROCESSOR_486, },
154 1.20 cgd { "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM, },
155 1.20 cgd { "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA, },
156 1.20 cgd { "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC, },
157 1.20 cgd { "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC, },
158 1.20 cgd { 0 },
159 1.20 cgd };
160 1.20 cgd
161 1.20 cgd struct pci_class pci_subclass_serialbus[] = {
162 1.20 cgd { "Firewire", PCI_SUBCLASS_SERIALBUS_FIREWIRE, },
163 1.20 cgd { "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS, },
164 1.20 cgd { "SSA", PCI_SUBCLASS_SERIALBUS_SSA, },
165 1.20 cgd { "USB", PCI_SUBCLASS_SERIALBUS_USB, },
166 1.20 cgd { "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER, },
167 1.20 cgd { 0 },
168 1.20 cgd };
169 1.20 cgd
170 1.10 cgd struct pci_class pci_class[] = {
171 1.10 cgd { "prehistoric", PCI_CLASS_PREHISTORIC,
172 1.10 cgd pci_subclass_prehistoric, },
173 1.10 cgd { "mass storage", PCI_CLASS_MASS_STORAGE,
174 1.10 cgd pci_subclass_mass_storage, },
175 1.10 cgd { "network", PCI_CLASS_NETWORK,
176 1.10 cgd pci_subclass_network, },
177 1.10 cgd { "display", PCI_CLASS_DISPLAY,
178 1.11 cgd pci_subclass_display, },
179 1.10 cgd { "multimedia", PCI_CLASS_MULTIMEDIA,
180 1.10 cgd pci_subclass_multimedia, },
181 1.10 cgd { "memory", PCI_CLASS_MEMORY,
182 1.10 cgd pci_subclass_memory, },
183 1.10 cgd { "bridge", PCI_CLASS_BRIDGE,
184 1.10 cgd pci_subclass_bridge, },
185 1.20 cgd { "communications", PCI_CLASS_COMMUNICATIONS,
186 1.20 cgd pci_subclass_communications, },
187 1.20 cgd { "system", PCI_CLASS_SYSTEM,
188 1.20 cgd pci_subclass_system, },
189 1.20 cgd { "input", PCI_CLASS_INPUT,
190 1.20 cgd pci_subclass_input, },
191 1.20 cgd { "dock", PCI_CLASS_DOCK,
192 1.20 cgd pci_subclass_dock, },
193 1.20 cgd { "processor", PCI_CLASS_PROCESSOR,
194 1.20 cgd pci_subclass_processor, },
195 1.20 cgd { "serial bus", PCI_CLASS_SERIALBUS,
196 1.20 cgd pci_subclass_serialbus, },
197 1.10 cgd { "undefined", PCI_CLASS_UNDEFINED,
198 1.10 cgd 0, },
199 1.10 cgd { 0 },
200 1.10 cgd };
201 1.10 cgd
202 1.10 cgd #ifdef PCIVERBOSE
203 1.10 cgd /*
204 1.10 cgd * Descriptions of of known vendors and devices ("products").
205 1.10 cgd */
206 1.10 cgd struct pci_knowndev {
207 1.10 cgd pci_vendor_id_t vendor;
208 1.10 cgd pci_product_id_t product;
209 1.10 cgd int flags;
210 1.10 cgd char *vendorname, *productname;
211 1.10 cgd };
212 1.13 cgd #define PCI_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
213 1.10 cgd
214 1.10 cgd #include <dev/pci/pcidevs_data.h>
215 1.10 cgd #endif /* PCIVERBOSE */
216 1.10 cgd
217 1.10 cgd void
218 1.13 cgd pci_devinfo(id_reg, class_reg, showclass, cp)
219 1.10 cgd pcireg_t id_reg, class_reg;
220 1.13 cgd int showclass;
221 1.10 cgd char *cp;
222 1.10 cgd {
223 1.10 cgd pci_vendor_id_t vendor;
224 1.10 cgd pci_product_id_t product;
225 1.10 cgd pci_class_t class;
226 1.10 cgd pci_subclass_t subclass;
227 1.10 cgd pci_interface_t interface;
228 1.10 cgd pci_revision_t revision;
229 1.10 cgd char *vendor_namep, *product_namep;
230 1.10 cgd struct pci_class *classp, *subclassp;
231 1.10 cgd #ifdef PCIVERBOSE
232 1.10 cgd struct pci_knowndev *kdp;
233 1.16 cgd const char *unmatched = "unknown ";
234 1.15 cgd #else
235 1.16 cgd const char *unmatched = "";
236 1.10 cgd #endif
237 1.10 cgd
238 1.10 cgd vendor = PCI_VENDOR(id_reg);
239 1.10 cgd product = PCI_PRODUCT(id_reg);
240 1.10 cgd
241 1.10 cgd class = PCI_CLASS(class_reg);
242 1.10 cgd subclass = PCI_SUBCLASS(class_reg);
243 1.10 cgd interface = PCI_INTERFACE(class_reg);
244 1.10 cgd revision = PCI_REVISION(class_reg);
245 1.10 cgd
246 1.10 cgd #ifdef PCIVERBOSE
247 1.10 cgd kdp = pci_knowndevs;
248 1.10 cgd while (kdp->vendorname != NULL) { /* all have vendor name */
249 1.10 cgd if (kdp->vendor == vendor && (kdp->product == product ||
250 1.10 cgd (kdp->flags & PCI_KNOWNDEV_NOPROD) != 0))
251 1.10 cgd break;
252 1.10 cgd kdp++;
253 1.10 cgd }
254 1.13 cgd if (kdp->vendorname == NULL)
255 1.10 cgd vendor_namep = product_namep = NULL;
256 1.13 cgd else {
257 1.10 cgd vendor_namep = kdp->vendorname;
258 1.10 cgd product_namep = (kdp->flags & PCI_KNOWNDEV_NOPROD) == 0 ?
259 1.10 cgd kdp->productname : NULL;
260 1.10 cgd }
261 1.10 cgd #else /* PCIVERBOSE */
262 1.10 cgd vendor_namep = product_namep = NULL;
263 1.10 cgd #endif /* PCIVERBOSE */
264 1.10 cgd
265 1.10 cgd classp = pci_class;
266 1.10 cgd while (classp->name != NULL) {
267 1.10 cgd if (class == classp->val)
268 1.10 cgd break;
269 1.10 cgd classp++;
270 1.10 cgd }
271 1.10 cgd
272 1.10 cgd subclassp = (classp->name != NULL) ? classp->subclasses : NULL;
273 1.10 cgd while (subclassp && subclassp->name != NULL) {
274 1.10 cgd if (subclass == subclassp->val)
275 1.10 cgd break;
276 1.10 cgd subclassp++;
277 1.10 cgd }
278 1.10 cgd
279 1.10 cgd if (vendor_namep == NULL)
280 1.19 christos cp += sprintf(cp, "%svendor 0x%04x product 0x%04x",
281 1.15 cgd unmatched, vendor, product);
282 1.10 cgd else if (product_namep != NULL)
283 1.19 christos cp += sprintf(cp, "%s %s", vendor_namep, product_namep);
284 1.10 cgd else
285 1.20 cgd cp += sprintf(cp, "%s product 0x%04x",
286 1.10 cgd vendor_namep, product);
287 1.13 cgd if (showclass) {
288 1.19 christos cp += sprintf(cp, " (");
289 1.13 cgd if (classp->name == NULL)
290 1.20 cgd cp += sprintf(cp, "class 0x%02x, subclass 0x%02x",
291 1.13 cgd class, subclass);
292 1.13 cgd else {
293 1.13 cgd if (subclassp == NULL || subclassp->name == NULL)
294 1.20 cgd cp += sprintf(cp,
295 1.20 cgd "%s subclass 0x%02x",
296 1.20 cgd classp->name, subclass);
297 1.13 cgd else
298 1.20 cgd cp += sprintf(cp, "%s %s",
299 1.20 cgd subclassp->name, classp->name);
300 1.13 cgd }
301 1.20 cgd if (interface != 0)
302 1.20 cgd cp += sprintf(cp, ", interface 0x%02x", interface);
303 1.20 cgd if (revision != 0)
304 1.20 cgd cp += sprintf(cp, ", revision 0x%02x", revision);
305 1.20 cgd cp += sprintf(cp, ")");
306 1.13 cgd }
307 1.22 thorpej }
308 1.22 thorpej
309 1.22 thorpej /*
310 1.22 thorpej * Print out most of the PCI configuration registers. Typically used
311 1.22 thorpej * in a device attach routine like this:
312 1.22 thorpej *
313 1.22 thorpej * #ifdef MYDEV_DEBUG
314 1.22 thorpej * printf("%s: ", sc->sc_dev.dv_xname);
315 1.22 thorpej * pci_conf_print(pa->pa_pc, pa->pa_tag);
316 1.22 thorpej * #endif
317 1.22 thorpej */
318 1.22 thorpej void
319 1.22 thorpej pci_conf_print(pc, tag)
320 1.22 thorpej pci_chipset_tag_t pc;
321 1.22 thorpej pcitag_t tag;
322 1.22 thorpej {
323 1.22 thorpej pcireg_t rval;
324 1.22 thorpej int reg;
325 1.22 thorpej #ifdef PCIVERBOSE
326 1.22 thorpej struct pci_knowndev *kdp;
327 1.22 thorpej #endif
328 1.22 thorpej struct pci_class *classp, *subclassp;
329 1.22 thorpej static const char on_str[] = "ON", off_str[] = "OFF";
330 1.22 thorpej
331 1.22 thorpej printf("PCI configuration registers:\n");
332 1.22 thorpej
333 1.22 thorpej rval = pci_conf_read(pc, tag, PCI_ID_REG);
334 1.22 thorpej
335 1.22 thorpej #ifndef PCIVERBOSE
336 1.22 thorpej printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval));
337 1.22 thorpej printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval));
338 1.22 thorpej #else
339 1.22 thorpej for (kdp = pci_knowndevs; kdp->vendorname != NULL; kdp++) {
340 1.22 thorpej if (kdp->vendor == PCI_VENDOR(rval) &&
341 1.22 thorpej (kdp->product == PCI_PRODUCT(rval) ||
342 1.22 thorpej (kdp->flags & PCI_KNOWNDEV_NOPROD) != 0)) {
343 1.22 thorpej break;
344 1.22 thorpej }
345 1.22 thorpej }
346 1.22 thorpej if (kdp->vendorname != NULL)
347 1.22 thorpej printf(" Vendor Name: %s\n", kdp->vendorname);
348 1.22 thorpej else
349 1.22 thorpej printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval));
350 1.22 thorpej
351 1.22 thorpej if (kdp->productname != NULL && (kdp->flags & PCI_KNOWNDEV_NOPROD) == 0)
352 1.22 thorpej printf(" Device Name: %s\n", kdp->productname);
353 1.22 thorpej else
354 1.22 thorpej printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval));
355 1.22 thorpej #endif /* PCIVERBOSE */
356 1.22 thorpej
357 1.22 thorpej #define onoff(reg) ((rval & (reg)) ? on_str : off_str)
358 1.22 thorpej
359 1.22 thorpej rval = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
360 1.22 thorpej
361 1.22 thorpej #ifndef PCIVERBOSE
362 1.22 thorpej printf(" Command/Status Register: 0x%08x\n", rval);
363 1.22 thorpej #else
364 1.22 thorpej printf(" Command Register:\n");
365 1.22 thorpej printf(" I/O space accesses %s\n", onoff(PCI_COMMAND_IO_ENABLE));
366 1.22 thorpej printf(" Mem space accesses %s\n", onoff(PCI_COMMAND_MEM_ENABLE));
367 1.22 thorpej printf(" Bus mastering %s\n", onoff(PCI_COMMAND_MASTER_ENABLE));
368 1.22 thorpej printf(" Special cycles %s\n", onoff(PCI_COMMAND_SPECIAL_ENABLE));
369 1.22 thorpej printf(" MWI transactions %s\n",
370 1.22 thorpej onoff(PCI_COMMAND_INVALIDATE_ENABLE));
371 1.22 thorpej printf(" Palette snooping %s\n", onoff(PCI_COMMAND_PALETTE_ENABLE));
372 1.22 thorpej printf(" Parity error checking %s\n",
373 1.22 thorpej onoff(PCI_COMMAND_PARITY_ENABLE));
374 1.22 thorpej printf(" Address/Data stepping %s\n",
375 1.22 thorpej onoff(PCI_COMMAND_STEPPING_ENABLE));
376 1.22 thorpej printf(" System Error (SERR) %s\n", onoff(PCI_COMMAND_SERR_ENABLE));
377 1.22 thorpej printf(" Fast back-to-back transactions %s\n",
378 1.22 thorpej onoff(PCI_COMMAND_BACKTOBACK_ENABLE));
379 1.22 thorpej printf(" Status Register:\n");
380 1.22 thorpej printf(" 66 MHz capable %s\n", onoff(PCI_STATUS_66MHZ_SUPPORT));
381 1.22 thorpej printf(" User Definable Features (UDF) support %s\n",
382 1.22 thorpej onoff(PCI_STATUS_UDF_SUPPORT));
383 1.22 thorpej printf(" Fast back-to-back capable %s\n",
384 1.22 thorpej onoff(PCI_STATUS_BACKTOBACK_SUPPORT));
385 1.22 thorpej printf(" Data parity error detected %s\n",
386 1.22 thorpej onoff(PCI_STATUS_PARITY_ERROR));
387 1.22 thorpej
388 1.22 thorpej printf(" DEVSEL timing ");
389 1.22 thorpej switch (rval & PCI_STATUS_DEVSEL_MASK) {
390 1.22 thorpej case PCI_STATUS_DEVSEL_FAST:
391 1.22 thorpej printf("fast");
392 1.22 thorpej break;
393 1.22 thorpej case PCI_STATUS_DEVSEL_MEDIUM:
394 1.22 thorpej printf("medium");
395 1.22 thorpej break;
396 1.22 thorpej case PCI_STATUS_DEVSEL_SLOW:
397 1.22 thorpej printf("slow");
398 1.22 thorpej break;
399 1.22 thorpej }
400 1.22 thorpej printf("\n");
401 1.22 thorpej
402 1.22 thorpej printf(" Slave signaled Target Abort %s\n",
403 1.22 thorpej onoff(PCI_STATUS_TARGET_TARGET_ABORT));
404 1.22 thorpej printf(" Master received Target Abort %s\n",
405 1.22 thorpej onoff(PCI_STATUS_MASTER_TARGET_ABORT));
406 1.22 thorpej printf(" Master received Master Abort %s\n",
407 1.22 thorpej onoff(PCI_STATUS_MASTER_ABORT));
408 1.22 thorpej printf(" Asserted System Error (SERR) %s\n",
409 1.22 thorpej onoff(PCI_STATUS_SPECIAL_ERROR));
410 1.22 thorpej printf(" Parity error detected %s\n",
411 1.22 thorpej onoff(PCI_STATUS_PARITY_DETECT));
412 1.22 thorpej #endif /* PCIVERBOSE */
413 1.22 thorpej
414 1.22 thorpej rval = pci_conf_read(pc, tag, PCI_CLASS_REG);
415 1.22 thorpej
416 1.22 thorpej for (classp = pci_class; classp->name != NULL; classp++) {
417 1.22 thorpej if (PCI_CLASS(rval) == classp->val)
418 1.22 thorpej break;
419 1.22 thorpej }
420 1.22 thorpej subclassp = (classp->name != NULL) ? classp->subclasses : NULL;
421 1.22 thorpej while (subclassp && subclassp->name != NULL) {
422 1.22 thorpej if (PCI_SUBCLASS(rval) == subclassp->val)
423 1.22 thorpej break;
424 1.22 thorpej subclassp++;
425 1.22 thorpej }
426 1.22 thorpej if (classp->name != NULL) {
427 1.22 thorpej printf(" Class Name: %s\n", classp->name);
428 1.22 thorpej if (subclassp != NULL && subclassp->name != NULL)
429 1.22 thorpej printf(" Subclass Name: %s\n", subclassp->name);
430 1.22 thorpej else
431 1.22 thorpej printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval));
432 1.22 thorpej } else {
433 1.22 thorpej printf(" Class ID: 0x%02x\n", PCI_CLASS(rval));
434 1.22 thorpej printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval));
435 1.22 thorpej }
436 1.22 thorpej printf(" Interface: 0x%02x\n", PCI_INTERFACE(rval));
437 1.22 thorpej printf(" Revision ID: 0x%02x\n", PCI_REVISION(rval));
438 1.22 thorpej
439 1.22 thorpej rval = pci_conf_read(pc, tag, PCI_BHLC_REG);
440 1.22 thorpej
441 1.22 thorpej printf(" BIST: 0x%02x\n", PCI_BIST(rval));
442 1.22 thorpej printf(" Header Type: 0x%02x\n", PCI_HDRTYPE(rval));
443 1.22 thorpej printf(" Latency Timer: 0x%02x\n", PCI_LATTIMER(rval));
444 1.22 thorpej printf(" Cache Line Size: 0x%02x\n", PCI_CACHELINE(rval));
445 1.22 thorpej
446 1.22 thorpej for (reg = PCI_MAPREG_START; reg < PCI_MAPREG_END; reg += 4) {
447 1.22 thorpej rval = pci_conf_read(pc, tag, reg);
448 1.22 thorpej printf(" Mapping register 0x%02x\n", reg);
449 1.22 thorpej if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM) {
450 1.22 thorpej printf(" Base Address: 0x%08x, size 0x%08x, "
451 1.22 thorpej "type = mem", PCI_MAPREG_MEM_ADDR(rval),
452 1.22 thorpej PCI_MAPREG_MEM_SIZE(rval));
453 1.22 thorpej switch (PCI_MAPREG_MEM_TYPE(rval)) {
454 1.22 thorpej case PCI_MAPREG_MEM_TYPE_32BIT:
455 1.22 thorpej printf(", 32-bit");
456 1.22 thorpej break;
457 1.22 thorpej case PCI_MAPREG_MEM_TYPE_32BIT_1M:
458 1.22 thorpej printf(", 32-bit-1M");
459 1.22 thorpej break;
460 1.22 thorpej case PCI_MAPREG_MEM_TYPE_64BIT:
461 1.22 thorpej printf(", 64-bit");
462 1.22 thorpej break;
463 1.22 thorpej }
464 1.22 thorpej if (PCI_MAPREG_MEM_CACHEABLE(rval))
465 1.22 thorpej printf(", cacheable");
466 1.22 thorpej else
467 1.22 thorpej printf(", not cacheable");
468 1.22 thorpej printf("\n");
469 1.22 thorpej } else {
470 1.22 thorpej printf(" Base Address: 0x%08x, size 0x%08x, "
471 1.22 thorpej "type = i/o\n", PCI_MAPREG_IO_ADDR(rval),
472 1.22 thorpej PCI_MAPREG_IO_SIZE(rval));
473 1.22 thorpej }
474 1.22 thorpej }
475 1.22 thorpej
476 1.22 thorpej rval = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
477 1.22 thorpej
478 1.22 thorpej printf(" Maximum Latency: 0x%08x\n", (rval >> 24) & 0xff);
479 1.22 thorpej printf(" Minimum Grant: 0x%08x\n", (rval >> 16) & 0xff);
480 1.22 thorpej printf(" Interrupt pin: 0x%08x", PCI_INTERRUPT_PIN(rval));
481 1.22 thorpej switch (PCI_INTERRUPT_PIN(rval)) {
482 1.22 thorpej case PCI_INTERRUPT_PIN_NONE:
483 1.22 thorpej printf(" (none)");
484 1.22 thorpej break;
485 1.22 thorpej case PCI_INTERRUPT_PIN_A:
486 1.22 thorpej printf(" (pin A)");
487 1.22 thorpej break;
488 1.22 thorpej case PCI_INTERRUPT_PIN_B:
489 1.22 thorpej printf(" (pin B)");
490 1.22 thorpej break;
491 1.22 thorpej case PCI_INTERRUPT_PIN_C:
492 1.22 thorpej printf(" (pin C)");
493 1.22 thorpej break;
494 1.22 thorpej case PCI_INTERRUPT_PIN_D:
495 1.22 thorpej printf(" (pin D)");
496 1.22 thorpej break;
497 1.22 thorpej }
498 1.22 thorpej printf("\n");
499 1.22 thorpej printf(" Interrupt line: 0x%08x\n", PCI_INTERRUPT_LINE(rval));
500 1.1 mycroft }
501