| @@ -1,1119 +1,1120 @@ | | | @@ -1,1119 +1,1120 @@ |
1 | /* $NetBSD: pci_subr.c,v 1.92 2012/04/24 09:53:41 drochner Exp $ */ | | 1 | /* $NetBSD: pci_subr.c,v 1.93 2012/09/23 01:10:10 chs Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997 Zubin D. Dittia. All rights reserved. | | 4 | * Copyright (c) 1997 Zubin D. Dittia. All rights reserved. |
5 | * Copyright (c) 1995, 1996, 1998, 2000 | | 5 | * Copyright (c) 1995, 1996, 1998, 2000 |
6 | * Christopher G. Demetriou. All rights reserved. | | 6 | * Christopher G. Demetriou. All rights reserved. |
7 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. | | 7 | * Copyright (c) 1994 Charles M. Hannum. All rights reserved. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
15 | * notice, this list of conditions and the following disclaimer in the | | 15 | * notice, this list of conditions and the following disclaimer in the |
16 | * documentation and/or other materials provided with the distribution. | | 16 | * documentation and/or other materials provided with the distribution. |
17 | * 3. All advertising materials mentioning features or use of this software | | 17 | * 3. All advertising materials mentioning features or use of this software |
18 | * must display the following acknowledgement: | | 18 | * must display the following acknowledgement: |
19 | * This product includes software developed by Charles M. Hannum. | | 19 | * This product includes software developed by Charles M. Hannum. |
20 | * 4. The name of the author may not be used to endorse or promote products | | 20 | * 4. The name of the author may not be used to endorse or promote products |
21 | * derived from this software without specific prior written permission. | | 21 | * derived from this software without specific prior written permission. |
22 | * | | 22 | * |
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | /* | | 35 | /* |
36 | * PCI autoconfiguration support functions. | | 36 | * PCI autoconfiguration support functions. |
37 | * | | 37 | * |
38 | * Note: This file is also built into a userland library (libpci). | | 38 | * Note: This file is also built into a userland library (libpci). |
39 | * Pay attention to this when you make modifications. | | 39 | * Pay attention to this when you make modifications. |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | #include <sys/cdefs.h> | | 42 | #include <sys/cdefs.h> |
43 | __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.92 2012/04/24 09:53:41 drochner Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.93 2012/09/23 01:10:10 chs Exp $"); |
44 | | | 44 | |
45 | #ifdef _KERNEL_OPT | | 45 | #ifdef _KERNEL_OPT |
46 | #include "opt_pci.h" | | 46 | #include "opt_pci.h" |
47 | #endif | | 47 | #endif |
48 | | | 48 | |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | | | 50 | |
51 | #ifdef _KERNEL | | 51 | #ifdef _KERNEL |
52 | #include <sys/systm.h> | | 52 | #include <sys/systm.h> |
53 | #include <sys/intr.h> | | 53 | #include <sys/intr.h> |
54 | #include <sys/module.h> | | 54 | #include <sys/module.h> |
55 | #else | | 55 | #else |
56 | #include <pci.h> | | 56 | #include <pci.h> |
57 | #include <stdbool.h> | | 57 | #include <stdbool.h> |
58 | #include <stdio.h> | | 58 | #include <stdio.h> |
59 | #endif | | 59 | #endif |
60 | | | 60 | |
61 | #include <dev/pci/pcireg.h> | | 61 | #include <dev/pci/pcireg.h> |
62 | #ifdef _KERNEL | | 62 | #ifdef _KERNEL |
63 | #include <dev/pci/pcivar.h> | | 63 | #include <dev/pci/pcivar.h> |
64 | #endif | | 64 | #endif |
65 | | | 65 | |
66 | /* | | 66 | /* |
67 | * Descriptions of known PCI classes and subclasses. | | 67 | * Descriptions of known PCI classes and subclasses. |
68 | * | | 68 | * |
69 | * Subclasses are described in the same way as classes, but have a | | 69 | * Subclasses are described in the same way as classes, but have a |
70 | * NULL subclass pointer. | | 70 | * NULL subclass pointer. |
71 | */ | | 71 | */ |
72 | struct pci_class { | | 72 | struct pci_class { |
73 | const char *name; | | 73 | const char *name; |
74 | u_int val; /* as wide as pci_{,sub}class_t */ | | 74 | u_int val; /* as wide as pci_{,sub}class_t */ |
75 | const struct pci_class *subclasses; | | 75 | const struct pci_class *subclasses; |
76 | }; | | 76 | }; |
77 | | | 77 | |
78 | static const struct pci_class pci_subclass_prehistoric[] = { | | 78 | static const struct pci_class pci_subclass_prehistoric[] = { |
79 | { "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC, NULL, }, | | 79 | { "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC, NULL, }, |
80 | { "VGA", PCI_SUBCLASS_PREHISTORIC_VGA, NULL, }, | | 80 | { "VGA", PCI_SUBCLASS_PREHISTORIC_VGA, NULL, }, |
81 | { NULL, 0, NULL, }, | | 81 | { NULL, 0, NULL, }, |
82 | }; | | 82 | }; |
83 | | | 83 | |
84 | static const struct pci_class pci_subclass_mass_storage[] = { | | 84 | static const struct pci_class pci_subclass_mass_storage[] = { |
85 | { "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI, NULL, }, | | 85 | { "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI, NULL, }, |
86 | { "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE, NULL, }, | | 86 | { "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE, NULL, }, |
87 | { "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY, NULL, }, | | 87 | { "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY, NULL, }, |
88 | { "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI, NULL, }, | | 88 | { "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI, NULL, }, |
89 | { "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID, NULL, }, | | 89 | { "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID, NULL, }, |
90 | { "ATA", PCI_SUBCLASS_MASS_STORAGE_ATA, NULL, }, | | 90 | { "ATA", PCI_SUBCLASS_MASS_STORAGE_ATA, NULL, }, |
91 | { "SATA", PCI_SUBCLASS_MASS_STORAGE_SATA, NULL, }, | | 91 | { "SATA", PCI_SUBCLASS_MASS_STORAGE_SATA, NULL, }, |
92 | { "SAS", PCI_SUBCLASS_MASS_STORAGE_SAS, NULL, }, | | 92 | { "SAS", PCI_SUBCLASS_MASS_STORAGE_SAS, NULL, }, |
93 | { "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC, NULL, }, | | 93 | { "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC, NULL, }, |
94 | { NULL, 0, NULL, }, | | 94 | { NULL, 0, NULL, }, |
95 | }; | | 95 | }; |
96 | | | 96 | |
97 | static const struct pci_class pci_subclass_network[] = { | | 97 | static const struct pci_class pci_subclass_network[] = { |
98 | { "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET, NULL, }, | | 98 | { "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET, NULL, }, |
99 | { "token ring", PCI_SUBCLASS_NETWORK_TOKENRING, NULL, }, | | 99 | { "token ring", PCI_SUBCLASS_NETWORK_TOKENRING, NULL, }, |
100 | { "FDDI", PCI_SUBCLASS_NETWORK_FDDI, NULL, }, | | 100 | { "FDDI", PCI_SUBCLASS_NETWORK_FDDI, NULL, }, |
101 | { "ATM", PCI_SUBCLASS_NETWORK_ATM, NULL, }, | | 101 | { "ATM", PCI_SUBCLASS_NETWORK_ATM, NULL, }, |
102 | { "ISDN", PCI_SUBCLASS_NETWORK_ISDN, NULL, }, | | 102 | { "ISDN", PCI_SUBCLASS_NETWORK_ISDN, NULL, }, |
103 | { "WorldFip", PCI_SUBCLASS_NETWORK_WORLDFIP, NULL, }, | | 103 | { "WorldFip", PCI_SUBCLASS_NETWORK_WORLDFIP, NULL, }, |
104 | { "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP, NULL, }, | | 104 | { "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP, NULL, }, |
105 | { "miscellaneous", PCI_SUBCLASS_NETWORK_MISC, NULL, }, | | 105 | { "miscellaneous", PCI_SUBCLASS_NETWORK_MISC, NULL, }, |
106 | { NULL, 0, NULL, }, | | 106 | { NULL, 0, NULL, }, |
107 | }; | | 107 | }; |
108 | | | 108 | |
109 | static const struct pci_class pci_subclass_display[] = { | | 109 | static const struct pci_class pci_subclass_display[] = { |
110 | { "VGA", PCI_SUBCLASS_DISPLAY_VGA, NULL, }, | | 110 | { "VGA", PCI_SUBCLASS_DISPLAY_VGA, NULL, }, |
111 | { "XGA", PCI_SUBCLASS_DISPLAY_XGA, NULL, }, | | 111 | { "XGA", PCI_SUBCLASS_DISPLAY_XGA, NULL, }, |
112 | { "3D", PCI_SUBCLASS_DISPLAY_3D, NULL, }, | | 112 | { "3D", PCI_SUBCLASS_DISPLAY_3D, NULL, }, |
113 | { "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC, NULL, }, | | 113 | { "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC, NULL, }, |
114 | { NULL, 0, NULL, }, | | 114 | { NULL, 0, NULL, }, |
115 | }; | | 115 | }; |
116 | | | 116 | |
117 | static const struct pci_class pci_subclass_multimedia[] = { | | 117 | static const struct pci_class pci_subclass_multimedia[] = { |
118 | { "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO, NULL, }, | | 118 | { "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO, NULL, }, |
119 | { "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO, NULL, }, | | 119 | { "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO, NULL, }, |
120 | { "telephony", PCI_SUBCLASS_MULTIMEDIA_TELEPHONY, NULL,}, | | 120 | { "telephony", PCI_SUBCLASS_MULTIMEDIA_TELEPHONY, NULL,}, |
| | | 121 | { "HD audio", PCI_SUBCLASS_MULTIMEDIA_HDAUDIO, NULL, }, |
121 | { "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC, NULL, }, | | 122 | { "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC, NULL, }, |
122 | { NULL, 0, NULL, }, | | 123 | { NULL, 0, NULL, }, |
123 | }; | | 124 | }; |
124 | | | 125 | |
125 | static const struct pci_class pci_subclass_memory[] = { | | 126 | static const struct pci_class pci_subclass_memory[] = { |
126 | { "RAM", PCI_SUBCLASS_MEMORY_RAM, NULL, }, | | 127 | { "RAM", PCI_SUBCLASS_MEMORY_RAM, NULL, }, |
127 | { "flash", PCI_SUBCLASS_MEMORY_FLASH, NULL, }, | | 128 | { "flash", PCI_SUBCLASS_MEMORY_FLASH, NULL, }, |
128 | { "miscellaneous", PCI_SUBCLASS_MEMORY_MISC, NULL, }, | | 129 | { "miscellaneous", PCI_SUBCLASS_MEMORY_MISC, NULL, }, |
129 | { NULL, 0, NULL, }, | | 130 | { NULL, 0, NULL, }, |
130 | }; | | 131 | }; |
131 | | | 132 | |
132 | static const struct pci_class pci_subclass_bridge[] = { | | 133 | static const struct pci_class pci_subclass_bridge[] = { |
133 | { "host", PCI_SUBCLASS_BRIDGE_HOST, NULL, }, | | 134 | { "host", PCI_SUBCLASS_BRIDGE_HOST, NULL, }, |
134 | { "ISA", PCI_SUBCLASS_BRIDGE_ISA, NULL, }, | | 135 | { "ISA", PCI_SUBCLASS_BRIDGE_ISA, NULL, }, |
135 | { "EISA", PCI_SUBCLASS_BRIDGE_EISA, NULL, }, | | 136 | { "EISA", PCI_SUBCLASS_BRIDGE_EISA, NULL, }, |
136 | { "MicroChannel", PCI_SUBCLASS_BRIDGE_MC, NULL, }, | | 137 | { "MicroChannel", PCI_SUBCLASS_BRIDGE_MC, NULL, }, |
137 | { "PCI", PCI_SUBCLASS_BRIDGE_PCI, NULL, }, | | 138 | { "PCI", PCI_SUBCLASS_BRIDGE_PCI, NULL, }, |
138 | { "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA, NULL, }, | | 139 | { "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA, NULL, }, |
139 | { "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS, NULL, }, | | 140 | { "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS, NULL, }, |
140 | { "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS, NULL, }, | | 141 | { "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS, NULL, }, |
141 | { "RACEway", PCI_SUBCLASS_BRIDGE_RACEWAY, NULL, }, | | 142 | { "RACEway", PCI_SUBCLASS_BRIDGE_RACEWAY, NULL, }, |
142 | { "Semi-transparent PCI", PCI_SUBCLASS_BRIDGE_STPCI, NULL, }, | | 143 | { "Semi-transparent PCI", PCI_SUBCLASS_BRIDGE_STPCI, NULL, }, |
143 | { "InfiniBand", PCI_SUBCLASS_BRIDGE_INFINIBAND, NULL, }, | | 144 | { "InfiniBand", PCI_SUBCLASS_BRIDGE_INFINIBAND, NULL, }, |
144 | { "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC, NULL, }, | | 145 | { "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC, NULL, }, |
145 | { NULL, 0, NULL, }, | | 146 | { NULL, 0, NULL, }, |
146 | }; | | 147 | }; |
147 | | | 148 | |
148 | static const struct pci_class pci_subclass_communications[] = { | | 149 | static const struct pci_class pci_subclass_communications[] = { |
149 | { "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL, NULL, }, | | 150 | { "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL, NULL, }, |
150 | { "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL, NULL, }, | | 151 | { "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL, NULL, }, |
151 | { "multi-port serial", PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL, NULL, }, | | 152 | { "multi-port serial", PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL, NULL, }, |
152 | { "modem", PCI_SUBCLASS_COMMUNICATIONS_MODEM, NULL, }, | | 153 | { "modem", PCI_SUBCLASS_COMMUNICATIONS_MODEM, NULL, }, |
153 | { "GPIB", PCI_SUBCLASS_COMMUNICATIONS_GPIB, NULL, }, | | 154 | { "GPIB", PCI_SUBCLASS_COMMUNICATIONS_GPIB, NULL, }, |
154 | { "smartcard", PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD, NULL, }, | | 155 | { "smartcard", PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD, NULL, }, |
155 | { "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC, NULL, }, | | 156 | { "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC, NULL, }, |
156 | { NULL, 0, NULL, }, | | 157 | { NULL, 0, NULL, }, |
157 | }; | | 158 | }; |
158 | | | 159 | |
159 | static const struct pci_class pci_subclass_system[] = { | | 160 | static const struct pci_class pci_subclass_system[] = { |
160 | { "interrupt", PCI_SUBCLASS_SYSTEM_PIC, NULL, }, | | 161 | { "interrupt", PCI_SUBCLASS_SYSTEM_PIC, NULL, }, |
161 | { "8237 DMA", PCI_SUBCLASS_SYSTEM_DMA, NULL, }, | | 162 | { "8237 DMA", PCI_SUBCLASS_SYSTEM_DMA, NULL, }, |
162 | { "8254 timer", PCI_SUBCLASS_SYSTEM_TIMER, NULL, }, | | 163 | { "8254 timer", PCI_SUBCLASS_SYSTEM_TIMER, NULL, }, |
163 | { "RTC", PCI_SUBCLASS_SYSTEM_RTC, NULL, }, | | 164 | { "RTC", PCI_SUBCLASS_SYSTEM_RTC, NULL, }, |
164 | { "PCI Hot-Plug", PCI_SUBCLASS_SYSTEM_PCIHOTPLUG, NULL, }, | | 165 | { "PCI Hot-Plug", PCI_SUBCLASS_SYSTEM_PCIHOTPLUG, NULL, }, |
165 | { "SD Host Controller", PCI_SUBCLASS_SYSTEM_SDHC, NULL, }, | | 166 | { "SD Host Controller", PCI_SUBCLASS_SYSTEM_SDHC, NULL, }, |
166 | { "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC, NULL, }, | | 167 | { "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC, NULL, }, |
167 | { NULL, 0, NULL, }, | | 168 | { NULL, 0, NULL, }, |
168 | }; | | 169 | }; |
169 | | | 170 | |
170 | static const struct pci_class pci_subclass_input[] = { | | 171 | static const struct pci_class pci_subclass_input[] = { |
171 | { "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD, NULL, }, | | 172 | { "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD, NULL, }, |
172 | { "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER, NULL, }, | | 173 | { "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER, NULL, }, |
173 | { "mouse", PCI_SUBCLASS_INPUT_MOUSE, NULL, }, | | 174 | { "mouse", PCI_SUBCLASS_INPUT_MOUSE, NULL, }, |
174 | { "scanner", PCI_SUBCLASS_INPUT_SCANNER, NULL, }, | | 175 | { "scanner", PCI_SUBCLASS_INPUT_SCANNER, NULL, }, |
175 | { "game port", PCI_SUBCLASS_INPUT_GAMEPORT, NULL, }, | | 176 | { "game port", PCI_SUBCLASS_INPUT_GAMEPORT, NULL, }, |
176 | { "miscellaneous", PCI_SUBCLASS_INPUT_MISC, NULL, }, | | 177 | { "miscellaneous", PCI_SUBCLASS_INPUT_MISC, NULL, }, |
177 | { NULL, 0, NULL, }, | | 178 | { NULL, 0, NULL, }, |
178 | }; | | 179 | }; |
179 | | | 180 | |
180 | static const struct pci_class pci_subclass_dock[] = { | | 181 | static const struct pci_class pci_subclass_dock[] = { |
181 | { "generic", PCI_SUBCLASS_DOCK_GENERIC, NULL, }, | | 182 | { "generic", PCI_SUBCLASS_DOCK_GENERIC, NULL, }, |
182 | { "miscellaneous", PCI_SUBCLASS_DOCK_MISC, NULL, }, | | 183 | { "miscellaneous", PCI_SUBCLASS_DOCK_MISC, NULL, }, |
183 | { NULL, 0, NULL, }, | | 184 | { NULL, 0, NULL, }, |
184 | }; | | 185 | }; |
185 | | | 186 | |
186 | static const struct pci_class pci_subclass_processor[] = { | | 187 | static const struct pci_class pci_subclass_processor[] = { |
187 | { "386", PCI_SUBCLASS_PROCESSOR_386, NULL, }, | | 188 | { "386", PCI_SUBCLASS_PROCESSOR_386, NULL, }, |
188 | { "486", PCI_SUBCLASS_PROCESSOR_486, NULL, }, | | 189 | { "486", PCI_SUBCLASS_PROCESSOR_486, NULL, }, |
189 | { "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM, NULL, }, | | 190 | { "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM, NULL, }, |
190 | { "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA, NULL, }, | | 191 | { "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA, NULL, }, |
191 | { "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC, NULL, }, | | 192 | { "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC, NULL, }, |
192 | { "MIPS", PCI_SUBCLASS_PROCESSOR_MIPS, NULL, }, | | 193 | { "MIPS", PCI_SUBCLASS_PROCESSOR_MIPS, NULL, }, |
193 | { "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC, NULL, }, | | 194 | { "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC, NULL, }, |
194 | { NULL, 0, NULL, }, | | 195 | { NULL, 0, NULL, }, |
195 | }; | | 196 | }; |
196 | | | 197 | |
197 | static const struct pci_class pci_subclass_serialbus[] = { | | 198 | static const struct pci_class pci_subclass_serialbus[] = { |
198 | { "Firewire", PCI_SUBCLASS_SERIALBUS_FIREWIRE, NULL, }, | | 199 | { "Firewire", PCI_SUBCLASS_SERIALBUS_FIREWIRE, NULL, }, |
199 | { "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS, NULL, }, | | 200 | { "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS, NULL, }, |
200 | { "SSA", PCI_SUBCLASS_SERIALBUS_SSA, NULL, }, | | 201 | { "SSA", PCI_SUBCLASS_SERIALBUS_SSA, NULL, }, |
201 | { "USB", PCI_SUBCLASS_SERIALBUS_USB, NULL, }, | | 202 | { "USB", PCI_SUBCLASS_SERIALBUS_USB, NULL, }, |
202 | /* XXX Fiber Channel/_FIBRECHANNEL */ | | 203 | /* XXX Fiber Channel/_FIBRECHANNEL */ |
203 | { "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER, NULL, }, | | 204 | { "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER, NULL, }, |
204 | { "SMBus", PCI_SUBCLASS_SERIALBUS_SMBUS, NULL, }, | | 205 | { "SMBus", PCI_SUBCLASS_SERIALBUS_SMBUS, NULL, }, |
205 | { "InfiniBand", PCI_SUBCLASS_SERIALBUS_INFINIBAND, NULL,}, | | 206 | { "InfiniBand", PCI_SUBCLASS_SERIALBUS_INFINIBAND, NULL,}, |
206 | { "IPMI", PCI_SUBCLASS_SERIALBUS_IPMI, NULL, }, | | 207 | { "IPMI", PCI_SUBCLASS_SERIALBUS_IPMI, NULL, }, |
207 | { "SERCOS", PCI_SUBCLASS_SERIALBUS_SERCOS, NULL, }, | | 208 | { "SERCOS", PCI_SUBCLASS_SERIALBUS_SERCOS, NULL, }, |
208 | { "CANbus", PCI_SUBCLASS_SERIALBUS_CANBUS, NULL, }, | | 209 | { "CANbus", PCI_SUBCLASS_SERIALBUS_CANBUS, NULL, }, |
209 | { NULL, 0, NULL, }, | | 210 | { NULL, 0, NULL, }, |
210 | }; | | 211 | }; |
211 | | | 212 | |
212 | static const struct pci_class pci_subclass_wireless[] = { | | 213 | static const struct pci_class pci_subclass_wireless[] = { |
213 | { "IrDA", PCI_SUBCLASS_WIRELESS_IRDA, NULL, }, | | 214 | { "IrDA", PCI_SUBCLASS_WIRELESS_IRDA, NULL, }, |
214 | { "Consumer IR", PCI_SUBCLASS_WIRELESS_CONSUMERIR, NULL, }, | | 215 | { "Consumer IR", PCI_SUBCLASS_WIRELESS_CONSUMERIR, NULL, }, |
215 | { "RF", PCI_SUBCLASS_WIRELESS_RF, NULL, }, | | 216 | { "RF", PCI_SUBCLASS_WIRELESS_RF, NULL, }, |
216 | { "bluetooth", PCI_SUBCLASS_WIRELESS_BLUETOOTH, NULL, }, | | 217 | { "bluetooth", PCI_SUBCLASS_WIRELESS_BLUETOOTH, NULL, }, |
217 | { "broadband", PCI_SUBCLASS_WIRELESS_BROADBAND, NULL, }, | | 218 | { "broadband", PCI_SUBCLASS_WIRELESS_BROADBAND, NULL, }, |
218 | { "802.11a (5 GHz)", PCI_SUBCLASS_WIRELESS_802_11A, NULL, }, | | 219 | { "802.11a (5 GHz)", PCI_SUBCLASS_WIRELESS_802_11A, NULL, }, |
219 | { "802.11b (2.4 GHz)", PCI_SUBCLASS_WIRELESS_802_11B, NULL, }, | | 220 | { "802.11b (2.4 GHz)", PCI_SUBCLASS_WIRELESS_802_11B, NULL, }, |
220 | { "miscellaneous", PCI_SUBCLASS_WIRELESS_MISC, NULL, }, | | 221 | { "miscellaneous", PCI_SUBCLASS_WIRELESS_MISC, NULL, }, |
221 | { NULL, 0, NULL, }, | | 222 | { NULL, 0, NULL, }, |
222 | }; | | 223 | }; |
223 | | | 224 | |
224 | static const struct pci_class pci_subclass_i2o[] = { | | 225 | static const struct pci_class pci_subclass_i2o[] = { |
225 | { "standard", PCI_SUBCLASS_I2O_STANDARD, NULL, }, | | 226 | { "standard", PCI_SUBCLASS_I2O_STANDARD, NULL, }, |
226 | { NULL, 0, NULL, }, | | 227 | { NULL, 0, NULL, }, |
227 | }; | | 228 | }; |
228 | | | 229 | |
229 | static const struct pci_class pci_subclass_satcom[] = { | | 230 | static const struct pci_class pci_subclass_satcom[] = { |
230 | { "TV", PCI_SUBCLASS_SATCOM_TV, NULL, }, | | 231 | { "TV", PCI_SUBCLASS_SATCOM_TV, NULL, }, |
231 | { "audio", PCI_SUBCLASS_SATCOM_AUDIO, NULL, }, | | 232 | { "audio", PCI_SUBCLASS_SATCOM_AUDIO, NULL, }, |
232 | { "voice", PCI_SUBCLASS_SATCOM_VOICE, NULL, }, | | 233 | { "voice", PCI_SUBCLASS_SATCOM_VOICE, NULL, }, |
233 | { "data", PCI_SUBCLASS_SATCOM_DATA, NULL, }, | | 234 | { "data", PCI_SUBCLASS_SATCOM_DATA, NULL, }, |
234 | { NULL, 0, NULL, }, | | 235 | { NULL, 0, NULL, }, |
235 | }; | | 236 | }; |
236 | | | 237 | |
237 | static const struct pci_class pci_subclass_crypto[] = { | | 238 | static const struct pci_class pci_subclass_crypto[] = { |
238 | { "network/computing", PCI_SUBCLASS_CRYPTO_NETCOMP, NULL, }, | | 239 | { "network/computing", PCI_SUBCLASS_CRYPTO_NETCOMP, NULL, }, |
239 | { "entertainment", PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,}, | | 240 | { "entertainment", PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,}, |
240 | { "miscellaneous", PCI_SUBCLASS_CRYPTO_MISC, NULL, }, | | 241 | { "miscellaneous", PCI_SUBCLASS_CRYPTO_MISC, NULL, }, |
241 | { NULL, 0, NULL, }, | | 242 | { NULL, 0, NULL, }, |
242 | }; | | 243 | }; |
243 | | | 244 | |
244 | static const struct pci_class pci_subclass_dasp[] = { | | 245 | static const struct pci_class pci_subclass_dasp[] = { |
245 | { "DPIO", PCI_SUBCLASS_DASP_DPIO, NULL, }, | | 246 | { "DPIO", PCI_SUBCLASS_DASP_DPIO, NULL, }, |
246 | { "Time and Frequency", PCI_SUBCLASS_DASP_TIMEFREQ, NULL, }, | | 247 | { "Time and Frequency", PCI_SUBCLASS_DASP_TIMEFREQ, NULL, }, |
247 | { "synchronization", PCI_SUBCLASS_DASP_SYNC, NULL, }, | | 248 | { "synchronization", PCI_SUBCLASS_DASP_SYNC, NULL, }, |
248 | { "management", PCI_SUBCLASS_DASP_MGMT, NULL, }, | | 249 | { "management", PCI_SUBCLASS_DASP_MGMT, NULL, }, |
249 | { "miscellaneous", PCI_SUBCLASS_DASP_MISC, NULL, }, | | 250 | { "miscellaneous", PCI_SUBCLASS_DASP_MISC, NULL, }, |
250 | { NULL, 0, NULL, }, | | 251 | { NULL, 0, NULL, }, |
251 | }; | | 252 | }; |
252 | | | 253 | |
253 | static const struct pci_class pci_class[] = { | | 254 | static const struct pci_class pci_class[] = { |
254 | { "prehistoric", PCI_CLASS_PREHISTORIC, | | 255 | { "prehistoric", PCI_CLASS_PREHISTORIC, |
255 | pci_subclass_prehistoric, }, | | 256 | pci_subclass_prehistoric, }, |
256 | { "mass storage", PCI_CLASS_MASS_STORAGE, | | 257 | { "mass storage", PCI_CLASS_MASS_STORAGE, |
257 | pci_subclass_mass_storage, }, | | 258 | pci_subclass_mass_storage, }, |
258 | { "network", PCI_CLASS_NETWORK, | | 259 | { "network", PCI_CLASS_NETWORK, |
259 | pci_subclass_network, }, | | 260 | pci_subclass_network, }, |
260 | { "display", PCI_CLASS_DISPLAY, | | 261 | { "display", PCI_CLASS_DISPLAY, |
261 | pci_subclass_display, }, | | 262 | pci_subclass_display, }, |
262 | { "multimedia", PCI_CLASS_MULTIMEDIA, | | 263 | { "multimedia", PCI_CLASS_MULTIMEDIA, |
263 | pci_subclass_multimedia, }, | | 264 | pci_subclass_multimedia, }, |
264 | { "memory", PCI_CLASS_MEMORY, | | 265 | { "memory", PCI_CLASS_MEMORY, |
265 | pci_subclass_memory, }, | | 266 | pci_subclass_memory, }, |
266 | { "bridge", PCI_CLASS_BRIDGE, | | 267 | { "bridge", PCI_CLASS_BRIDGE, |
267 | pci_subclass_bridge, }, | | 268 | pci_subclass_bridge, }, |
268 | { "communications", PCI_CLASS_COMMUNICATIONS, | | 269 | { "communications", PCI_CLASS_COMMUNICATIONS, |
269 | pci_subclass_communications, }, | | 270 | pci_subclass_communications, }, |
270 | { "system", PCI_CLASS_SYSTEM, | | 271 | { "system", PCI_CLASS_SYSTEM, |
271 | pci_subclass_system, }, | | 272 | pci_subclass_system, }, |
272 | { "input", PCI_CLASS_INPUT, | | 273 | { "input", PCI_CLASS_INPUT, |
273 | pci_subclass_input, }, | | 274 | pci_subclass_input, }, |
274 | { "dock", PCI_CLASS_DOCK, | | 275 | { "dock", PCI_CLASS_DOCK, |
275 | pci_subclass_dock, }, | | 276 | pci_subclass_dock, }, |
276 | { "processor", PCI_CLASS_PROCESSOR, | | 277 | { "processor", PCI_CLASS_PROCESSOR, |
277 | pci_subclass_processor, }, | | 278 | pci_subclass_processor, }, |
278 | { "serial bus", PCI_CLASS_SERIALBUS, | | 279 | { "serial bus", PCI_CLASS_SERIALBUS, |
279 | pci_subclass_serialbus, }, | | 280 | pci_subclass_serialbus, }, |
280 | { "wireless", PCI_CLASS_WIRELESS, | | 281 | { "wireless", PCI_CLASS_WIRELESS, |
281 | pci_subclass_wireless, }, | | 282 | pci_subclass_wireless, }, |
282 | { "I2O", PCI_CLASS_I2O, | | 283 | { "I2O", PCI_CLASS_I2O, |
283 | pci_subclass_i2o, }, | | 284 | pci_subclass_i2o, }, |
284 | { "satellite comm", PCI_CLASS_SATCOM, | | 285 | { "satellite comm", PCI_CLASS_SATCOM, |
285 | pci_subclass_satcom, }, | | 286 | pci_subclass_satcom, }, |
286 | { "crypto", PCI_CLASS_CRYPTO, | | 287 | { "crypto", PCI_CLASS_CRYPTO, |
287 | pci_subclass_crypto, }, | | 288 | pci_subclass_crypto, }, |
288 | { "DASP", PCI_CLASS_DASP, | | 289 | { "DASP", PCI_CLASS_DASP, |
289 | pci_subclass_dasp, }, | | 290 | pci_subclass_dasp, }, |
290 | { "undefined", PCI_CLASS_UNDEFINED, | | 291 | { "undefined", PCI_CLASS_UNDEFINED, |
291 | NULL, }, | | 292 | NULL, }, |
292 | { NULL, 0, | | 293 | { NULL, 0, |
293 | NULL, }, | | 294 | NULL, }, |
294 | }; | | 295 | }; |
295 | | | 296 | |
296 | void pci_load_verbose(void); | | 297 | void pci_load_verbose(void); |
297 | | | 298 | |
298 | #if defined(_KERNEL) | | 299 | #if defined(_KERNEL) |
299 | /* | | 300 | /* |
300 | * In kernel, these routines are provided and linked via the | | 301 | * In kernel, these routines are provided and linked via the |
301 | * pciverbose module. | | 302 | * pciverbose module. |
302 | */ | | 303 | */ |
303 | const char *pci_findvendor_stub(pcireg_t); | | 304 | const char *pci_findvendor_stub(pcireg_t); |
304 | const char *pci_findproduct_stub(pcireg_t); | | 305 | const char *pci_findproduct_stub(pcireg_t); |
305 | | | 306 | |
306 | const char *(*pci_findvendor)(pcireg_t) = pci_findvendor_stub; | | 307 | const char *(*pci_findvendor)(pcireg_t) = pci_findvendor_stub; |
307 | const char *(*pci_findproduct)(pcireg_t) = pci_findproduct_stub; | | 308 | const char *(*pci_findproduct)(pcireg_t) = pci_findproduct_stub; |
308 | const char *pci_unmatched = ""; | | 309 | const char *pci_unmatched = ""; |
309 | #else | | 310 | #else |
310 | /* | | 311 | /* |
311 | * For userland we just set the vectors here. | | 312 | * For userland we just set the vectors here. |
312 | */ | | 313 | */ |
313 | const char *(*pci_findvendor)(pcireg_t id_reg) = pci_findvendor_real; | | 314 | const char *(*pci_findvendor)(pcireg_t id_reg) = pci_findvendor_real; |
314 | const char *(*pci_findproduct)(pcireg_t id_reg) = pci_findproduct_real; | | 315 | const char *(*pci_findproduct)(pcireg_t id_reg) = pci_findproduct_real; |
315 | const char *pci_unmatched = "unmatched "; | | 316 | const char *pci_unmatched = "unmatched "; |
316 | #endif | | 317 | #endif |
317 | | | 318 | |
318 | int pciverbose_loaded = 0; | | 319 | int pciverbose_loaded = 0; |
319 | | | 320 | |
320 | #if defined(_KERNEL) | | 321 | #if defined(_KERNEL) |
321 | /* | | 322 | /* |
322 | * Routine to load the pciverbose kernel module as needed | | 323 | * Routine to load the pciverbose kernel module as needed |
323 | */ | | 324 | */ |
324 | void pci_load_verbose(void) | | 325 | void pci_load_verbose(void) |
325 | { | | 326 | { |
326 | if (pciverbose_loaded == 0) | | 327 | if (pciverbose_loaded == 0) |
327 | module_autoload("pciverbose", MODULE_CLASS_MISC); | | 328 | module_autoload("pciverbose", MODULE_CLASS_MISC); |
328 | } | | 329 | } |
329 | | | 330 | |
330 | const char *pci_findvendor_stub(pcireg_t id_reg) | | 331 | const char *pci_findvendor_stub(pcireg_t id_reg) |
331 | { | | 332 | { |
332 | pci_load_verbose(); | | 333 | pci_load_verbose(); |
333 | if (pciverbose_loaded) | | 334 | if (pciverbose_loaded) |
334 | return pci_findvendor(id_reg); | | 335 | return pci_findvendor(id_reg); |
335 | else | | 336 | else |
336 | return NULL; | | 337 | return NULL; |
337 | } | | 338 | } |
338 | | | 339 | |
339 | const char *pci_findproduct_stub(pcireg_t id_reg) | | 340 | const char *pci_findproduct_stub(pcireg_t id_reg) |
340 | { | | 341 | { |
341 | pci_load_verbose(); | | 342 | pci_load_verbose(); |
342 | if (pciverbose_loaded) | | 343 | if (pciverbose_loaded) |
343 | return pci_findproduct(id_reg); | | 344 | return pci_findproduct(id_reg); |
344 | else | | 345 | else |
345 | return NULL; | | 346 | return NULL; |
346 | } | | 347 | } |
347 | #endif | | 348 | #endif |
348 | | | 349 | |
349 | void | | 350 | void |
350 | pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp, | | 351 | pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp, |
351 | size_t l) | | 352 | size_t l) |
352 | { | | 353 | { |
353 | pci_vendor_id_t vendor; | | 354 | pci_vendor_id_t vendor; |
354 | pci_product_id_t product; | | 355 | pci_product_id_t product; |
355 | pci_class_t class; | | 356 | pci_class_t class; |
356 | pci_subclass_t subclass; | | 357 | pci_subclass_t subclass; |
357 | pci_interface_t interface; | | 358 | pci_interface_t interface; |
358 | pci_revision_t revision; | | 359 | pci_revision_t revision; |
359 | const char *unmatched = pci_unmatched; | | 360 | const char *unmatched = pci_unmatched; |
360 | const char *vendor_namep, *product_namep; | | 361 | const char *vendor_namep, *product_namep; |
361 | const struct pci_class *classp, *subclassp; | | 362 | const struct pci_class *classp, *subclassp; |
362 | char *ep; | | 363 | char *ep; |
363 | | | 364 | |
364 | ep = cp + l; | | 365 | ep = cp + l; |
365 | | | 366 | |
366 | vendor = PCI_VENDOR(id_reg); | | 367 | vendor = PCI_VENDOR(id_reg); |
367 | product = PCI_PRODUCT(id_reg); | | 368 | product = PCI_PRODUCT(id_reg); |
368 | | | 369 | |
369 | class = PCI_CLASS(class_reg); | | 370 | class = PCI_CLASS(class_reg); |
370 | subclass = PCI_SUBCLASS(class_reg); | | 371 | subclass = PCI_SUBCLASS(class_reg); |
371 | interface = PCI_INTERFACE(class_reg); | | 372 | interface = PCI_INTERFACE(class_reg); |
372 | revision = PCI_REVISION(class_reg); | | 373 | revision = PCI_REVISION(class_reg); |
373 | | | 374 | |
374 | vendor_namep = pci_findvendor(id_reg); | | 375 | vendor_namep = pci_findvendor(id_reg); |
375 | product_namep = pci_findproduct(id_reg); | | 376 | product_namep = pci_findproduct(id_reg); |
376 | | | 377 | |
377 | classp = pci_class; | | 378 | classp = pci_class; |
378 | while (classp->name != NULL) { | | 379 | while (classp->name != NULL) { |
379 | if (class == classp->val) | | 380 | if (class == classp->val) |
380 | break; | | 381 | break; |
381 | classp++; | | 382 | classp++; |
382 | } | | 383 | } |
383 | | | 384 | |
384 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; | | 385 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; |
385 | while (subclassp && subclassp->name != NULL) { | | 386 | while (subclassp && subclassp->name != NULL) { |
386 | if (subclass == subclassp->val) | | 387 | if (subclass == subclassp->val) |
387 | break; | | 388 | break; |
388 | subclassp++; | | 389 | subclassp++; |
389 | } | | 390 | } |
390 | | | 391 | |
391 | if (vendor_namep == NULL) | | 392 | if (vendor_namep == NULL) |
392 | cp += snprintf(cp, ep - cp, "%svendor 0x%04x product 0x%04x", | | 393 | cp += snprintf(cp, ep - cp, "%svendor 0x%04x product 0x%04x", |
393 | unmatched, vendor, product); | | 394 | unmatched, vendor, product); |
394 | else if (product_namep != NULL) | | 395 | else if (product_namep != NULL) |
395 | cp += snprintf(cp, ep - cp, "%s %s", vendor_namep, | | 396 | cp += snprintf(cp, ep - cp, "%s %s", vendor_namep, |
396 | product_namep); | | 397 | product_namep); |
397 | else | | 398 | else |
398 | cp += snprintf(cp, ep - cp, "%s product 0x%04x", | | 399 | cp += snprintf(cp, ep - cp, "%s product 0x%04x", |
399 | vendor_namep, product); | | 400 | vendor_namep, product); |
400 | if (showclass) { | | 401 | if (showclass) { |
401 | cp += snprintf(cp, ep - cp, " ("); | | 402 | cp += snprintf(cp, ep - cp, " ("); |
402 | if (classp->name == NULL) | | 403 | if (classp->name == NULL) |
403 | cp += snprintf(cp, ep - cp, | | 404 | cp += snprintf(cp, ep - cp, |
404 | "class 0x%02x, subclass 0x%02x", class, subclass); | | 405 | "class 0x%02x, subclass 0x%02x", class, subclass); |
405 | else { | | 406 | else { |
406 | if (subclassp == NULL || subclassp->name == NULL) | | 407 | if (subclassp == NULL || subclassp->name == NULL) |
407 | cp += snprintf(cp, ep - cp, | | 408 | cp += snprintf(cp, ep - cp, |
408 | "%s, subclass 0x%02x", | | 409 | "%s, subclass 0x%02x", |
409 | classp->name, subclass); | | 410 | classp->name, subclass); |
410 | else | | 411 | else |
411 | cp += snprintf(cp, ep - cp, "%s %s", | | 412 | cp += snprintf(cp, ep - cp, "%s %s", |
412 | subclassp->name, classp->name); | | 413 | subclassp->name, classp->name); |
413 | } | | 414 | } |
414 | if (interface != 0) | | 415 | if (interface != 0) |
415 | cp += snprintf(cp, ep - cp, ", interface 0x%02x", | | 416 | cp += snprintf(cp, ep - cp, ", interface 0x%02x", |
416 | interface); | | 417 | interface); |
417 | if (revision != 0) | | 418 | if (revision != 0) |
418 | cp += snprintf(cp, ep - cp, ", revision 0x%02x", | | 419 | cp += snprintf(cp, ep - cp, ", revision 0x%02x", |
419 | revision); | | 420 | revision); |
420 | cp += snprintf(cp, ep - cp, ")"); | | 421 | cp += snprintf(cp, ep - cp, ")"); |
421 | } | | 422 | } |
422 | } | | 423 | } |
423 | | | 424 | |
424 | #ifdef _KERNEL | | 425 | #ifdef _KERNEL |
425 | void | | 426 | void |
426 | pci_aprint_devinfo_fancy(const struct pci_attach_args *pa, const char *naive, | | 427 | pci_aprint_devinfo_fancy(const struct pci_attach_args *pa, const char *naive, |
427 | const char *known, int addrev) | | 428 | const char *known, int addrev) |
428 | { | | 429 | { |
429 | char devinfo[256]; | | 430 | char devinfo[256]; |
430 | | | 431 | |
431 | if (known) { | | 432 | if (known) { |
432 | aprint_normal(": %s", known); | | 433 | aprint_normal(": %s", known); |
433 | if (addrev) | | 434 | if (addrev) |
434 | aprint_normal(" (rev. 0x%02x)", | | 435 | aprint_normal(" (rev. 0x%02x)", |
435 | PCI_REVISION(pa->pa_class)); | | 436 | PCI_REVISION(pa->pa_class)); |
436 | aprint_normal("\n"); | | 437 | aprint_normal("\n"); |
437 | } else { | | 438 | } else { |
438 | pci_devinfo(pa->pa_id, pa->pa_class, 0, | | 439 | pci_devinfo(pa->pa_id, pa->pa_class, 0, |
439 | devinfo, sizeof(devinfo)); | | 440 | devinfo, sizeof(devinfo)); |
440 | aprint_normal(": %s (rev. 0x%02x)\n", devinfo, | | 441 | aprint_normal(": %s (rev. 0x%02x)\n", devinfo, |
441 | PCI_REVISION(pa->pa_class)); | | 442 | PCI_REVISION(pa->pa_class)); |
442 | } | | 443 | } |
443 | if (naive) | | 444 | if (naive) |
444 | aprint_naive(": %s\n", naive); | | 445 | aprint_naive(": %s\n", naive); |
445 | else | | 446 | else |
446 | aprint_naive("\n"); | | 447 | aprint_naive("\n"); |
447 | } | | 448 | } |
448 | #endif | | 449 | #endif |
449 | | | 450 | |
450 | /* | | 451 | /* |
451 | * Print out most of the PCI configuration registers. Typically used | | 452 | * Print out most of the PCI configuration registers. Typically used |
452 | * in a device attach routine like this: | | 453 | * in a device attach routine like this: |
453 | * | | 454 | * |
454 | * #ifdef MYDEV_DEBUG | | 455 | * #ifdef MYDEV_DEBUG |
455 | * printf("%s: ", device_xname(&sc->sc_dev)); | | 456 | * printf("%s: ", device_xname(&sc->sc_dev)); |
456 | * pci_conf_print(pa->pa_pc, pa->pa_tag, NULL); | | 457 | * pci_conf_print(pa->pa_pc, pa->pa_tag, NULL); |
457 | * #endif | | 458 | * #endif |
458 | */ | | 459 | */ |
459 | | | 460 | |
460 | #define i2o(i) ((i) * 4) | | 461 | #define i2o(i) ((i) * 4) |
461 | #define o2i(o) ((o) / 4) | | 462 | #define o2i(o) ((o) / 4) |
462 | #define onoff2(str, bit, onstr, offstr) \ | | 463 | #define onoff2(str, bit, onstr, offstr) \ |
463 | printf(" %s: %s\n", (str), (rval & (bit)) ? onstr : offstr); | | 464 | printf(" %s: %s\n", (str), (rval & (bit)) ? onstr : offstr); |
464 | #define onoff(str, bit) onoff2(str, bit, "on", "off") | | 465 | #define onoff(str, bit) onoff2(str, bit, "on", "off") |
465 | | | 466 | |
466 | static void | | 467 | static void |
467 | pci_conf_print_common( | | 468 | pci_conf_print_common( |
468 | #ifdef _KERNEL | | 469 | #ifdef _KERNEL |
469 | pci_chipset_tag_t pc, pcitag_t tag, | | 470 | pci_chipset_tag_t pc, pcitag_t tag, |
470 | #endif | | 471 | #endif |
471 | const pcireg_t *regs) | | 472 | const pcireg_t *regs) |
472 | { | | 473 | { |
473 | const char *name; | | 474 | const char *name; |
474 | const struct pci_class *classp, *subclassp; | | 475 | const struct pci_class *classp, *subclassp; |
475 | pcireg_t rval; | | 476 | pcireg_t rval; |
476 | | | 477 | |
477 | rval = regs[o2i(PCI_ID_REG)]; | | 478 | rval = regs[o2i(PCI_ID_REG)]; |
478 | name = pci_findvendor(rval); | | 479 | name = pci_findvendor(rval); |
479 | if (name) | | 480 | if (name) |
480 | printf(" Vendor Name: %s (0x%04x)\n", name, | | 481 | printf(" Vendor Name: %s (0x%04x)\n", name, |
481 | PCI_VENDOR(rval)); | | 482 | PCI_VENDOR(rval)); |
482 | else | | 483 | else |
483 | printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval)); | | 484 | printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval)); |
484 | name = pci_findproduct(rval); | | 485 | name = pci_findproduct(rval); |
485 | if (name) | | 486 | if (name) |
486 | printf(" Device Name: %s (0x%04x)\n", name, | | 487 | printf(" Device Name: %s (0x%04x)\n", name, |
487 | PCI_PRODUCT(rval)); | | 488 | PCI_PRODUCT(rval)); |
488 | else | | 489 | else |
489 | printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval)); | | 490 | printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval)); |
490 | | | 491 | |
491 | rval = regs[o2i(PCI_COMMAND_STATUS_REG)]; | | 492 | rval = regs[o2i(PCI_COMMAND_STATUS_REG)]; |
492 | | | 493 | |
493 | printf(" Command register: 0x%04x\n", rval & 0xffff); | | 494 | printf(" Command register: 0x%04x\n", rval & 0xffff); |
494 | onoff("I/O space accesses", PCI_COMMAND_IO_ENABLE); | | 495 | onoff("I/O space accesses", PCI_COMMAND_IO_ENABLE); |
495 | onoff("Memory space accesses", PCI_COMMAND_MEM_ENABLE); | | 496 | onoff("Memory space accesses", PCI_COMMAND_MEM_ENABLE); |
496 | onoff("Bus mastering", PCI_COMMAND_MASTER_ENABLE); | | 497 | onoff("Bus mastering", PCI_COMMAND_MASTER_ENABLE); |
497 | onoff("Special cycles", PCI_COMMAND_SPECIAL_ENABLE); | | 498 | onoff("Special cycles", PCI_COMMAND_SPECIAL_ENABLE); |
498 | onoff("MWI transactions", PCI_COMMAND_INVALIDATE_ENABLE); | | 499 | onoff("MWI transactions", PCI_COMMAND_INVALIDATE_ENABLE); |
499 | onoff("Palette snooping", PCI_COMMAND_PALETTE_ENABLE); | | 500 | onoff("Palette snooping", PCI_COMMAND_PALETTE_ENABLE); |
500 | onoff("Parity error checking", PCI_COMMAND_PARITY_ENABLE); | | 501 | onoff("Parity error checking", PCI_COMMAND_PARITY_ENABLE); |
501 | onoff("Address/data stepping", PCI_COMMAND_STEPPING_ENABLE); | | 502 | onoff("Address/data stepping", PCI_COMMAND_STEPPING_ENABLE); |
502 | onoff("System error (SERR)", PCI_COMMAND_SERR_ENABLE); | | 503 | onoff("System error (SERR)", PCI_COMMAND_SERR_ENABLE); |
503 | onoff("Fast back-to-back transactions", PCI_COMMAND_BACKTOBACK_ENABLE); | | 504 | onoff("Fast back-to-back transactions", PCI_COMMAND_BACKTOBACK_ENABLE); |
504 | onoff("Interrupt disable", PCI_COMMAND_INTERRUPT_DISABLE); | | 505 | onoff("Interrupt disable", PCI_COMMAND_INTERRUPT_DISABLE); |
505 | | | 506 | |
506 | printf(" Status register: 0x%04x\n", (rval >> 16) & 0xffff); | | 507 | printf(" Status register: 0x%04x\n", (rval >> 16) & 0xffff); |
507 | onoff2("Interrupt status", PCI_STATUS_INT_STATUS, "active", "inactive"); | | 508 | onoff2("Interrupt status", PCI_STATUS_INT_STATUS, "active", "inactive"); |
508 | onoff("Capability List support", PCI_STATUS_CAPLIST_SUPPORT); | | 509 | onoff("Capability List support", PCI_STATUS_CAPLIST_SUPPORT); |
509 | onoff("66 MHz capable", PCI_STATUS_66MHZ_SUPPORT); | | 510 | onoff("66 MHz capable", PCI_STATUS_66MHZ_SUPPORT); |
510 | onoff("User Definable Features (UDF) support", PCI_STATUS_UDF_SUPPORT); | | 511 | onoff("User Definable Features (UDF) support", PCI_STATUS_UDF_SUPPORT); |
511 | onoff("Fast back-to-back capable", PCI_STATUS_BACKTOBACK_SUPPORT); | | 512 | onoff("Fast back-to-back capable", PCI_STATUS_BACKTOBACK_SUPPORT); |
512 | onoff("Data parity error detected", PCI_STATUS_PARITY_ERROR); | | 513 | onoff("Data parity error detected", PCI_STATUS_PARITY_ERROR); |
513 | | | 514 | |
514 | printf(" DEVSEL timing: "); | | 515 | printf(" DEVSEL timing: "); |
515 | switch (rval & PCI_STATUS_DEVSEL_MASK) { | | 516 | switch (rval & PCI_STATUS_DEVSEL_MASK) { |
516 | case PCI_STATUS_DEVSEL_FAST: | | 517 | case PCI_STATUS_DEVSEL_FAST: |
517 | printf("fast"); | | 518 | printf("fast"); |
518 | break; | | 519 | break; |
519 | case PCI_STATUS_DEVSEL_MEDIUM: | | 520 | case PCI_STATUS_DEVSEL_MEDIUM: |
520 | printf("medium"); | | 521 | printf("medium"); |
521 | break; | | 522 | break; |
522 | case PCI_STATUS_DEVSEL_SLOW: | | 523 | case PCI_STATUS_DEVSEL_SLOW: |
523 | printf("slow"); | | 524 | printf("slow"); |
524 | break; | | 525 | break; |
525 | default: | | 526 | default: |
526 | printf("unknown/reserved"); /* XXX */ | | 527 | printf("unknown/reserved"); /* XXX */ |
527 | break; | | 528 | break; |
528 | } | | 529 | } |
529 | printf(" (0x%x)\n", (rval & PCI_STATUS_DEVSEL_MASK) >> 25); | | 530 | printf(" (0x%x)\n", (rval & PCI_STATUS_DEVSEL_MASK) >> 25); |
530 | | | 531 | |
531 | onoff("Slave signaled Target Abort", PCI_STATUS_TARGET_TARGET_ABORT); | | 532 | onoff("Slave signaled Target Abort", PCI_STATUS_TARGET_TARGET_ABORT); |
532 | onoff("Master received Target Abort", PCI_STATUS_MASTER_TARGET_ABORT); | | 533 | onoff("Master received Target Abort", PCI_STATUS_MASTER_TARGET_ABORT); |
533 | onoff("Master received Master Abort", PCI_STATUS_MASTER_ABORT); | | 534 | onoff("Master received Master Abort", PCI_STATUS_MASTER_ABORT); |
534 | onoff("Asserted System Error (SERR)", PCI_STATUS_SPECIAL_ERROR); | | 535 | onoff("Asserted System Error (SERR)", PCI_STATUS_SPECIAL_ERROR); |
535 | onoff("Parity error detected", PCI_STATUS_PARITY_DETECT); | | 536 | onoff("Parity error detected", PCI_STATUS_PARITY_DETECT); |
536 | | | 537 | |
537 | rval = regs[o2i(PCI_CLASS_REG)]; | | 538 | rval = regs[o2i(PCI_CLASS_REG)]; |
538 | for (classp = pci_class; classp->name != NULL; classp++) { | | 539 | for (classp = pci_class; classp->name != NULL; classp++) { |
539 | if (PCI_CLASS(rval) == classp->val) | | 540 | if (PCI_CLASS(rval) == classp->val) |
540 | break; | | 541 | break; |
541 | } | | 542 | } |
542 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; | | 543 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; |
543 | while (subclassp && subclassp->name != NULL) { | | 544 | while (subclassp && subclassp->name != NULL) { |
544 | if (PCI_SUBCLASS(rval) == subclassp->val) | | 545 | if (PCI_SUBCLASS(rval) == subclassp->val) |
545 | break; | | 546 | break; |
546 | subclassp++; | | 547 | subclassp++; |
547 | } | | 548 | } |
548 | if (classp->name != NULL) { | | 549 | if (classp->name != NULL) { |
549 | printf(" Class Name: %s (0x%02x)\n", classp->name, | | 550 | printf(" Class Name: %s (0x%02x)\n", classp->name, |
550 | PCI_CLASS(rval)); | | 551 | PCI_CLASS(rval)); |
551 | if (subclassp != NULL && subclassp->name != NULL) | | 552 | if (subclassp != NULL && subclassp->name != NULL) |
552 | printf(" Subclass Name: %s (0x%02x)\n", | | 553 | printf(" Subclass Name: %s (0x%02x)\n", |
553 | subclassp->name, PCI_SUBCLASS(rval)); | | 554 | subclassp->name, PCI_SUBCLASS(rval)); |
554 | else | | 555 | else |
555 | printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval)); | | 556 | printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval)); |
556 | } else { | | 557 | } else { |
557 | printf(" Class ID: 0x%02x\n", PCI_CLASS(rval)); | | 558 | printf(" Class ID: 0x%02x\n", PCI_CLASS(rval)); |
558 | printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval)); | | 559 | printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval)); |
559 | } | | 560 | } |
560 | printf(" Interface: 0x%02x\n", PCI_INTERFACE(rval)); | | 561 | printf(" Interface: 0x%02x\n", PCI_INTERFACE(rval)); |
561 | printf(" Revision ID: 0x%02x\n", PCI_REVISION(rval)); | | 562 | printf(" Revision ID: 0x%02x\n", PCI_REVISION(rval)); |
562 | | | 563 | |
563 | rval = regs[o2i(PCI_BHLC_REG)]; | | 564 | rval = regs[o2i(PCI_BHLC_REG)]; |
564 | printf(" BIST: 0x%02x\n", PCI_BIST(rval)); | | 565 | printf(" BIST: 0x%02x\n", PCI_BIST(rval)); |
565 | printf(" Header Type: 0x%02x%s (0x%02x)\n", PCI_HDRTYPE_TYPE(rval), | | 566 | printf(" Header Type: 0x%02x%s (0x%02x)\n", PCI_HDRTYPE_TYPE(rval), |
566 | PCI_HDRTYPE_MULTIFN(rval) ? "+multifunction" : "", | | 567 | PCI_HDRTYPE_MULTIFN(rval) ? "+multifunction" : "", |
567 | PCI_HDRTYPE(rval)); | | 568 | PCI_HDRTYPE(rval)); |
568 | printf(" Latency Timer: 0x%02x\n", PCI_LATTIMER(rval)); | | 569 | printf(" Latency Timer: 0x%02x\n", PCI_LATTIMER(rval)); |
569 | printf(" Cache Line Size: 0x%02x\n", PCI_CACHELINE(rval)); | | 570 | printf(" Cache Line Size: 0x%02x\n", PCI_CACHELINE(rval)); |
570 | } | | 571 | } |
571 | | | 572 | |
572 | static int | | 573 | static int |
573 | pci_conf_print_bar( | | 574 | pci_conf_print_bar( |
574 | #ifdef _KERNEL | | 575 | #ifdef _KERNEL |
575 | pci_chipset_tag_t pc, pcitag_t tag, | | 576 | pci_chipset_tag_t pc, pcitag_t tag, |
576 | #endif | | 577 | #endif |
577 | const pcireg_t *regs, int reg, const char *name | | 578 | const pcireg_t *regs, int reg, const char *name |
578 | #ifdef _KERNEL | | 579 | #ifdef _KERNEL |
579 | , int sizebar | | 580 | , int sizebar |
580 | #endif | | 581 | #endif |
581 | ) | | 582 | ) |
582 | { | | 583 | { |
583 | int width; | | 584 | int width; |
584 | pcireg_t rval, rval64h; | | 585 | pcireg_t rval, rval64h; |
585 | #ifdef _KERNEL | | 586 | #ifdef _KERNEL |
586 | int s; | | 587 | int s; |
587 | pcireg_t mask, mask64h; | | 588 | pcireg_t mask, mask64h; |
588 | #endif | | 589 | #endif |
589 | | | 590 | |
590 | width = 4; | | 591 | width = 4; |
591 | | | 592 | |
592 | /* | | 593 | /* |
593 | * Section 6.2.5.1, `Address Maps', tells us that: | | 594 | * Section 6.2.5.1, `Address Maps', tells us that: |
594 | * | | 595 | * |
595 | * 1) The builtin software should have already mapped the | | 596 | * 1) The builtin software should have already mapped the |
596 | * device in a reasonable way. | | 597 | * device in a reasonable way. |
597 | * | | 598 | * |
598 | * 2) A device which wants 2^n bytes of memory will hardwire | | 599 | * 2) A device which wants 2^n bytes of memory will hardwire |
599 | * the bottom n bits of the address to 0. As recommended, | | 600 | * the bottom n bits of the address to 0. As recommended, |
600 | * we write all 1s and see what we get back. | | 601 | * we write all 1s and see what we get back. |
601 | */ | | 602 | */ |
602 | | | 603 | |
603 | rval = regs[o2i(reg)]; | | 604 | rval = regs[o2i(reg)]; |
604 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && | | 605 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && |
605 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { | | 606 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { |
606 | rval64h = regs[o2i(reg + 4)]; | | 607 | rval64h = regs[o2i(reg + 4)]; |
607 | width = 8; | | 608 | width = 8; |
608 | } else | | 609 | } else |
609 | rval64h = 0; | | 610 | rval64h = 0; |
610 | | | 611 | |
611 | #ifdef _KERNEL | | 612 | #ifdef _KERNEL |
612 | /* XXX don't size unknown memory type? */ | | 613 | /* XXX don't size unknown memory type? */ |
613 | if (rval != 0 && sizebar) { | | 614 | if (rval != 0 && sizebar) { |
614 | /* | | 615 | /* |
615 | * The following sequence seems to make some devices | | 616 | * The following sequence seems to make some devices |
616 | * (e.g. host bus bridges, which don't normally | | 617 | * (e.g. host bus bridges, which don't normally |
617 | * have their space mapped) very unhappy, to | | 618 | * have their space mapped) very unhappy, to |
618 | * the point of crashing the system. | | 619 | * the point of crashing the system. |
619 | * | | 620 | * |
620 | * Therefore, if the mapping register is zero to | | 621 | * Therefore, if the mapping register is zero to |
621 | * start out with, don't bother trying. | | 622 | * start out with, don't bother trying. |
622 | */ | | 623 | */ |
623 | s = splhigh(); | | 624 | s = splhigh(); |
624 | pci_conf_write(pc, tag, reg, 0xffffffff); | | 625 | pci_conf_write(pc, tag, reg, 0xffffffff); |
625 | mask = pci_conf_read(pc, tag, reg); | | 626 | mask = pci_conf_read(pc, tag, reg); |
626 | pci_conf_write(pc, tag, reg, rval); | | 627 | pci_conf_write(pc, tag, reg, rval); |
627 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && | | 628 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && |
628 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { | | 629 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { |
629 | pci_conf_write(pc, tag, reg + 4, 0xffffffff); | | 630 | pci_conf_write(pc, tag, reg + 4, 0xffffffff); |
630 | mask64h = pci_conf_read(pc, tag, reg + 4); | | 631 | mask64h = pci_conf_read(pc, tag, reg + 4); |
631 | pci_conf_write(pc, tag, reg + 4, rval64h); | | 632 | pci_conf_write(pc, tag, reg + 4, rval64h); |
632 | } else | | 633 | } else |
633 | mask64h = 0; | | 634 | mask64h = 0; |
634 | splx(s); | | 635 | splx(s); |
635 | } else | | 636 | } else |
636 | mask = mask64h = 0; | | 637 | mask = mask64h = 0; |
637 | #endif /* _KERNEL */ | | 638 | #endif /* _KERNEL */ |
638 | | | 639 | |
639 | printf(" Base address register at 0x%02x", reg); | | 640 | printf(" Base address register at 0x%02x", reg); |
640 | if (name) | | 641 | if (name) |
641 | printf(" (%s)", name); | | 642 | printf(" (%s)", name); |
642 | printf("\n "); | | 643 | printf("\n "); |
643 | if (rval == 0) { | | 644 | if (rval == 0) { |
644 | printf("not implemented(?)\n"); | | 645 | printf("not implemented(?)\n"); |
645 | return width; | | 646 | return width; |
646 | } | | 647 | } |
647 | printf("type: "); | | 648 | printf("type: "); |
648 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM) { | | 649 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM) { |
649 | const char *type, *prefetch; | | 650 | const char *type, *prefetch; |
650 | | | 651 | |
651 | switch (PCI_MAPREG_MEM_TYPE(rval)) { | | 652 | switch (PCI_MAPREG_MEM_TYPE(rval)) { |
652 | case PCI_MAPREG_MEM_TYPE_32BIT: | | 653 | case PCI_MAPREG_MEM_TYPE_32BIT: |
653 | type = "32-bit"; | | 654 | type = "32-bit"; |
654 | break; | | 655 | break; |
655 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: | | 656 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: |
656 | type = "32-bit-1M"; | | 657 | type = "32-bit-1M"; |
657 | break; | | 658 | break; |
658 | case PCI_MAPREG_MEM_TYPE_64BIT: | | 659 | case PCI_MAPREG_MEM_TYPE_64BIT: |
659 | type = "64-bit"; | | 660 | type = "64-bit"; |
660 | break; | | 661 | break; |
661 | default: | | 662 | default: |
662 | type = "unknown (XXX)"; | | 663 | type = "unknown (XXX)"; |
663 | break; | | 664 | break; |
664 | } | | 665 | } |
665 | if (PCI_MAPREG_MEM_PREFETCHABLE(rval)) | | 666 | if (PCI_MAPREG_MEM_PREFETCHABLE(rval)) |
666 | prefetch = ""; | | 667 | prefetch = ""; |
667 | else | | 668 | else |
668 | prefetch = "non"; | | 669 | prefetch = "non"; |
669 | printf("%s %sprefetchable memory\n", type, prefetch); | | 670 | printf("%s %sprefetchable memory\n", type, prefetch); |
670 | switch (PCI_MAPREG_MEM_TYPE(rval)) { | | 671 | switch (PCI_MAPREG_MEM_TYPE(rval)) { |
671 | case PCI_MAPREG_MEM_TYPE_64BIT: | | 672 | case PCI_MAPREG_MEM_TYPE_64BIT: |
672 | printf(" base: 0x%016llx, ", | | 673 | printf(" base: 0x%016llx, ", |
673 | PCI_MAPREG_MEM64_ADDR( | | 674 | PCI_MAPREG_MEM64_ADDR( |
674 | ((((long long) rval64h) << 32) | rval))); | | 675 | ((((long long) rval64h) << 32) | rval))); |
675 | #ifdef _KERNEL | | 676 | #ifdef _KERNEL |
676 | if (sizebar) | | 677 | if (sizebar) |
677 | printf("size: 0x%016llx", | | 678 | printf("size: 0x%016llx", |
678 | PCI_MAPREG_MEM64_SIZE( | | 679 | PCI_MAPREG_MEM64_SIZE( |
679 | ((((long long) mask64h) << 32) | mask))); | | 680 | ((((long long) mask64h) << 32) | mask))); |
680 | else | | 681 | else |
681 | #endif /* _KERNEL */ | | 682 | #endif /* _KERNEL */ |
682 | printf("not sized"); | | 683 | printf("not sized"); |
683 | printf("\n"); | | 684 | printf("\n"); |
684 | break; | | 685 | break; |
685 | case PCI_MAPREG_MEM_TYPE_32BIT: | | 686 | case PCI_MAPREG_MEM_TYPE_32BIT: |
686 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: | | 687 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: |
687 | default: | | 688 | default: |
688 | printf(" base: 0x%08x, ", | | 689 | printf(" base: 0x%08x, ", |
689 | PCI_MAPREG_MEM_ADDR(rval)); | | 690 | PCI_MAPREG_MEM_ADDR(rval)); |
690 | #ifdef _KERNEL | | 691 | #ifdef _KERNEL |
691 | if (sizebar) | | 692 | if (sizebar) |
692 | printf("size: 0x%08x", | | 693 | printf("size: 0x%08x", |
693 | PCI_MAPREG_MEM_SIZE(mask)); | | 694 | PCI_MAPREG_MEM_SIZE(mask)); |
694 | else | | 695 | else |
695 | #endif /* _KERNEL */ | | 696 | #endif /* _KERNEL */ |
696 | printf("not sized"); | | 697 | printf("not sized"); |
697 | printf("\n"); | | 698 | printf("\n"); |
698 | break; | | 699 | break; |
699 | } | | 700 | } |
700 | } else { | | 701 | } else { |
701 | #ifdef _KERNEL | | 702 | #ifdef _KERNEL |
702 | if (sizebar) | | 703 | if (sizebar) |
703 | printf("%d-bit ", mask & ~0x0000ffff ? 32 : 16); | | 704 | printf("%d-bit ", mask & ~0x0000ffff ? 32 : 16); |
704 | #endif /* _KERNEL */ | | 705 | #endif /* _KERNEL */ |
705 | printf("i/o\n"); | | 706 | printf("i/o\n"); |
706 | printf(" base: 0x%08x, ", PCI_MAPREG_IO_ADDR(rval)); | | 707 | printf(" base: 0x%08x, ", PCI_MAPREG_IO_ADDR(rval)); |
707 | #ifdef _KERNEL | | 708 | #ifdef _KERNEL |
708 | if (sizebar) | | 709 | if (sizebar) |
709 | printf("size: 0x%08x", PCI_MAPREG_IO_SIZE(mask)); | | 710 | printf("size: 0x%08x", PCI_MAPREG_IO_SIZE(mask)); |
710 | else | | 711 | else |
711 | #endif /* _KERNEL */ | | 712 | #endif /* _KERNEL */ |
712 | printf("not sized"); | | 713 | printf("not sized"); |
713 | printf("\n"); | | 714 | printf("\n"); |
714 | } | | 715 | } |
715 | | | 716 | |
716 | return width; | | 717 | return width; |
717 | } | | 718 | } |
718 | | | 719 | |
719 | static void | | 720 | static void |
720 | pci_conf_print_regs(const pcireg_t *regs, int first, int pastlast) | | 721 | pci_conf_print_regs(const pcireg_t *regs, int first, int pastlast) |
721 | { | | 722 | { |
722 | int off, needaddr, neednl; | | 723 | int off, needaddr, neednl; |
723 | | | 724 | |
724 | needaddr = 1; | | 725 | needaddr = 1; |
725 | neednl = 0; | | 726 | neednl = 0; |
726 | for (off = first; off < pastlast; off += 4) { | | 727 | for (off = first; off < pastlast; off += 4) { |
727 | if ((off % 16) == 0 || needaddr) { | | 728 | if ((off % 16) == 0 || needaddr) { |
728 | printf(" 0x%02x:", off); | | 729 | printf(" 0x%02x:", off); |
729 | needaddr = 0; | | 730 | needaddr = 0; |
730 | } | | 731 | } |
731 | printf(" 0x%08x", regs[o2i(off)]); | | 732 | printf(" 0x%08x", regs[o2i(off)]); |
732 | neednl = 1; | | 733 | neednl = 1; |
733 | if ((off % 16) == 12) { | | 734 | if ((off % 16) == 12) { |
734 | printf("\n"); | | 735 | printf("\n"); |
735 | neednl = 0; | | 736 | neednl = 0; |
736 | } | | 737 | } |
737 | } | | 738 | } |
738 | if (neednl) | | 739 | if (neednl) |
739 | printf("\n"); | | 740 | printf("\n"); |
740 | } | | 741 | } |
741 | | | 742 | |
742 | static void | | 743 | static void |
743 | pci_conf_print_type0( | | 744 | pci_conf_print_type0( |
744 | #ifdef _KERNEL | | 745 | #ifdef _KERNEL |
745 | pci_chipset_tag_t pc, pcitag_t tag, | | 746 | pci_chipset_tag_t pc, pcitag_t tag, |
746 | #endif | | 747 | #endif |
747 | const pcireg_t *regs | | 748 | const pcireg_t *regs |
748 | #ifdef _KERNEL | | 749 | #ifdef _KERNEL |
749 | , int sizebars | | 750 | , int sizebars |
750 | #endif | | 751 | #endif |
751 | ) | | 752 | ) |
752 | { | | 753 | { |
753 | int off, width; | | 754 | int off, width; |
754 | pcireg_t rval; | | 755 | pcireg_t rval; |
755 | | | 756 | |
756 | for (off = PCI_MAPREG_START; off < PCI_MAPREG_END; off += width) { | | 757 | for (off = PCI_MAPREG_START; off < PCI_MAPREG_END; off += width) { |
757 | #ifdef _KERNEL | | 758 | #ifdef _KERNEL |
758 | width = pci_conf_print_bar(pc, tag, regs, off, NULL, sizebars); | | 759 | width = pci_conf_print_bar(pc, tag, regs, off, NULL, sizebars); |
759 | #else | | 760 | #else |
760 | width = pci_conf_print_bar(regs, off, NULL); | | 761 | width = pci_conf_print_bar(regs, off, NULL); |
761 | #endif | | 762 | #endif |
762 | } | | 763 | } |
763 | | | 764 | |
764 | printf(" Cardbus CIS Pointer: 0x%08x\n", regs[o2i(0x28)]); | | 765 | printf(" Cardbus CIS Pointer: 0x%08x\n", regs[o2i(0x28)]); |
765 | | | 766 | |
766 | rval = regs[o2i(PCI_SUBSYS_ID_REG)]; | | 767 | rval = regs[o2i(PCI_SUBSYS_ID_REG)]; |
767 | printf(" Subsystem vendor ID: 0x%04x\n", PCI_VENDOR(rval)); | | 768 | printf(" Subsystem vendor ID: 0x%04x\n", PCI_VENDOR(rval)); |
768 | printf(" Subsystem ID: 0x%04x\n", PCI_PRODUCT(rval)); | | 769 | printf(" Subsystem ID: 0x%04x\n", PCI_PRODUCT(rval)); |
769 | | | 770 | |
770 | /* XXX */ | | 771 | /* XXX */ |
771 | printf(" Expansion ROM Base Address: 0x%08x\n", regs[o2i(0x30)]); | | 772 | printf(" Expansion ROM Base Address: 0x%08x\n", regs[o2i(0x30)]); |
772 | | | 773 | |
773 | if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT) | | 774 | if (regs[o2i(PCI_COMMAND_STATUS_REG)] & PCI_STATUS_CAPLIST_SUPPORT) |
774 | printf(" Capability list pointer: 0x%02x\n", | | 775 | printf(" Capability list pointer: 0x%02x\n", |
775 | PCI_CAPLIST_PTR(regs[o2i(PCI_CAPLISTPTR_REG)])); | | 776 | PCI_CAPLIST_PTR(regs[o2i(PCI_CAPLISTPTR_REG)])); |
776 | else | | 777 | else |
777 | printf(" Reserved @ 0x34: 0x%08x\n", regs[o2i(0x34)]); | | 778 | printf(" Reserved @ 0x34: 0x%08x\n", regs[o2i(0x34)]); |
778 | | | 779 | |
779 | printf(" Reserved @ 0x38: 0x%08x\n", regs[o2i(0x38)]); | | 780 | printf(" Reserved @ 0x38: 0x%08x\n", regs[o2i(0x38)]); |
780 | | | 781 | |
781 | rval = regs[o2i(PCI_INTERRUPT_REG)]; | | 782 | rval = regs[o2i(PCI_INTERRUPT_REG)]; |
782 | printf(" Maximum Latency: 0x%02x\n", (rval >> 24) & 0xff); | | 783 | printf(" Maximum Latency: 0x%02x\n", (rval >> 24) & 0xff); |
783 | printf(" Minimum Grant: 0x%02x\n", (rval >> 16) & 0xff); | | 784 | printf(" Minimum Grant: 0x%02x\n", (rval >> 16) & 0xff); |
784 | printf(" Interrupt pin: 0x%02x ", PCI_INTERRUPT_PIN(rval)); | | 785 | printf(" Interrupt pin: 0x%02x ", PCI_INTERRUPT_PIN(rval)); |
785 | switch (PCI_INTERRUPT_PIN(rval)) { | | 786 | switch (PCI_INTERRUPT_PIN(rval)) { |
786 | case PCI_INTERRUPT_PIN_NONE: | | 787 | case PCI_INTERRUPT_PIN_NONE: |
787 | printf("(none)"); | | 788 | printf("(none)"); |
788 | break; | | 789 | break; |
789 | case PCI_INTERRUPT_PIN_A: | | 790 | case PCI_INTERRUPT_PIN_A: |
790 | printf("(pin A)"); | | 791 | printf("(pin A)"); |
791 | break; | | 792 | break; |
792 | case PCI_INTERRUPT_PIN_B: | | 793 | case PCI_INTERRUPT_PIN_B: |
793 | printf("(pin B)"); | | 794 | printf("(pin B)"); |
794 | break; | | 795 | break; |
795 | case PCI_INTERRUPT_PIN_C: | | 796 | case PCI_INTERRUPT_PIN_C: |
796 | printf("(pin C)"); | | 797 | printf("(pin C)"); |
797 | break; | | 798 | break; |
798 | case PCI_INTERRUPT_PIN_D: | | 799 | case PCI_INTERRUPT_PIN_D: |
799 | printf("(pin D)"); | | 800 | printf("(pin D)"); |
800 | break; | | 801 | break; |
801 | default: | | 802 | default: |
802 | printf("(? ? ?)"); | | 803 | printf("(? ? ?)"); |
803 | break; | | 804 | break; |
804 | } | | 805 | } |
805 | printf("\n"); | | 806 | printf("\n"); |
806 | printf(" Interrupt line: 0x%02x\n", PCI_INTERRUPT_LINE(rval)); | | 807 | printf(" Interrupt line: 0x%02x\n", PCI_INTERRUPT_LINE(rval)); |
807 | } | | 808 | } |
808 | | | 809 | |
809 | static void | | 810 | static void |
810 | pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff) | | 811 | pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff) |
811 | { | | 812 | { |
812 | bool check_slot = false; | | 813 | bool check_slot = false; |
813 | static const char * const linkspeeds[] = {"2.5", "5.0", "8.0"}; | | 814 | static const char * const linkspeeds[] = {"2.5", "5.0", "8.0"}; |
814 | | | 815 | |
815 | printf("\n PCI Express Capabilities Register\n"); | | 816 | printf("\n PCI Express Capabilities Register\n"); |
816 | printf(" Capability version: %x\n", | | 817 | printf(" Capability version: %x\n", |
817 | (unsigned int)((regs[o2i(capoff)] & 0x000f0000) >> 16)); | | 818 | (unsigned int)((regs[o2i(capoff)] & 0x000f0000) >> 16)); |
818 | printf(" Device type: "); | | 819 | printf(" Device type: "); |
819 | switch ((regs[o2i(capoff)] & 0x00f00000) >> 20) { | | 820 | switch ((regs[o2i(capoff)] & 0x00f00000) >> 20) { |
820 | case 0x0: | | 821 | case 0x0: |
821 | printf("PCI Express Endpoint device\n"); | | 822 | printf("PCI Express Endpoint device\n"); |
822 | break; | | 823 | break; |
823 | case 0x1: | | 824 | case 0x1: |
824 | printf("Legacy PCI Express Endpoint device\n"); | | 825 | printf("Legacy PCI Express Endpoint device\n"); |
825 | break; | | 826 | break; |
826 | case 0x4: | | 827 | case 0x4: |
827 | printf("Root Port of PCI Express Root Complex\n"); | | 828 | printf("Root Port of PCI Express Root Complex\n"); |
828 | check_slot = true; | | 829 | check_slot = true; |
829 | break; | | 830 | break; |
830 | case 0x5: | | 831 | case 0x5: |
831 | printf("Upstream Port of PCI Express Switch\n"); | | 832 | printf("Upstream Port of PCI Express Switch\n"); |
832 | break; | | 833 | break; |
833 | case 0x6: | | 834 | case 0x6: |
834 | printf("Downstream Port of PCI Express Switch\n"); | | 835 | printf("Downstream Port of PCI Express Switch\n"); |
835 | check_slot = true; | | 836 | check_slot = true; |
836 | break; | | 837 | break; |
837 | case 0x7: | | 838 | case 0x7: |
838 | printf("PCI Express to PCI/PCI-X Bridge\n"); | | 839 | printf("PCI Express to PCI/PCI-X Bridge\n"); |
839 | break; | | 840 | break; |
840 | case 0x8: | | 841 | case 0x8: |
841 | printf("PCI/PCI-X to PCI Express Bridge\n"); | | 842 | printf("PCI/PCI-X to PCI Express Bridge\n"); |
842 | break; | | 843 | break; |
843 | default: | | 844 | default: |
844 | printf("unknown\n"); | | 845 | printf("unknown\n"); |
845 | break; | | 846 | break; |
846 | } | | 847 | } |
847 | if (check_slot && (regs[o2i(capoff)] & 0x01000000) != 0) | | 848 | if (check_slot && (regs[o2i(capoff)] & 0x01000000) != 0) |
848 | printf(" Slot implemented\n"); | | 849 | printf(" Slot implemented\n"); |
849 | printf(" Interrupt Message Number: %x\n", | | 850 | printf(" Interrupt Message Number: %x\n", |
850 | (unsigned int)((regs[o2i(capoff)] & 0x4e000000) >> 27)); | | 851 | (unsigned int)((regs[o2i(capoff)] & 0x4e000000) >> 27)); |
851 | printf(" Link Capabilities Register: 0x%08x\n", | | 852 | printf(" Link Capabilities Register: 0x%08x\n", |
852 | regs[o2i(capoff + 0x0c)]); | | 853 | regs[o2i(capoff + 0x0c)]); |
853 | printf(" Maximum Link Speed: "); | | 854 | printf(" Maximum Link Speed: "); |
854 | if ((regs[o2i(capoff + 0x0c)] & 0x000f) < 1 || | | 855 | if ((regs[o2i(capoff + 0x0c)] & 0x000f) < 1 || |
855 | (regs[o2i(capoff + 0x0c)] & 0x000f) > 3) { | | 856 | (regs[o2i(capoff + 0x0c)] & 0x000f) > 3) { |
856 | printf("unknown %u value\n", | | 857 | printf("unknown %u value\n", |
857 | (regs[o2i(capoff + 0x0c)] & 0x000f)); | | 858 | (regs[o2i(capoff + 0x0c)] & 0x000f)); |
858 | } else { | | 859 | } else { |
859 | printf("%sGb/s\n", linkspeeds[(regs[o2i(capoff + 0x0c)] & 0x000f) - 1]); | | 860 | printf("%sGb/s\n", linkspeeds[(regs[o2i(capoff + 0x0c)] & 0x000f) - 1]); |
860 | } | | 861 | } |
861 | printf(" Maximum Link Width: x%u lanes\n", | | 862 | printf(" Maximum Link Width: x%u lanes\n", |
862 | (regs[o2i(capoff + 0x0c)] & 0x03f0) >> 4); | | 863 | (regs[o2i(capoff + 0x0c)] & 0x03f0) >> 4); |
863 | printf(" Port Number: %u\n", regs[o2i(capoff + 0x0c)] >> 24); | | 864 | printf(" Port Number: %u\n", regs[o2i(capoff + 0x0c)] >> 24); |
864 | printf(" Link Status Register: 0x%04x\n", | | 865 | printf(" Link Status Register: 0x%04x\n", |
865 | regs[o2i(capoff + 0x10)] >> 16); | | 866 | regs[o2i(capoff + 0x10)] >> 16); |
866 | printf(" Negotiated Link Speed: "); | | 867 | printf(" Negotiated Link Speed: "); |
867 | if (((regs[o2i(capoff + 0x10)] >> 16) & 0x000f) < 1 || | | 868 | if (((regs[o2i(capoff + 0x10)] >> 16) & 0x000f) < 1 || |
868 | ((regs[o2i(capoff + 0x10)] >> 16) & 0x000f) > 3) { | | 869 | ((regs[o2i(capoff + 0x10)] >> 16) & 0x000f) > 3) { |
869 | printf("unknown %u value\n", | | 870 | printf("unknown %u value\n", |
870 | (regs[o2i(capoff + 0x10)] >> 16) & 0x000f); | | 871 | (regs[o2i(capoff + 0x10)] >> 16) & 0x000f); |
871 | } else { | | 872 | } else { |
872 | printf("%sGb/s\n", linkspeeds[((regs[o2i(capoff + 0x10)] >> 16) & 0x000f) - 1]); | | 873 | printf("%sGb/s\n", linkspeeds[((regs[o2i(capoff + 0x10)] >> 16) & 0x000f) - 1]); |
873 | } | | 874 | } |
874 | printf(" Negotiated Link Width: x%u lanes\n", | | 875 | printf(" Negotiated Link Width: x%u lanes\n", |
875 | (regs[o2i(capoff + 0x10)] >> 20) & 0x003f); | | 876 | (regs[o2i(capoff + 0x10)] >> 20) & 0x003f); |
876 | if ((regs[o2i(capoff + 0x18)] & 0x07ff) != 0) { | | 877 | if ((regs[o2i(capoff + 0x18)] & 0x07ff) != 0) { |
877 | printf(" Slot Control Register:\n"); | | 878 | printf(" Slot Control Register:\n"); |
878 | if ((regs[o2i(capoff + 0x18)] & 0x0001) != 0) | | 879 | if ((regs[o2i(capoff + 0x18)] & 0x0001) != 0) |
879 | printf(" Attention Button Pressed Enabled\n"); | | 880 | printf(" Attention Button Pressed Enabled\n"); |
880 | if ((regs[o2i(capoff + 0x18)] & 0x0002) != 0) | | 881 | if ((regs[o2i(capoff + 0x18)] & 0x0002) != 0) |
881 | printf(" Power Fault Detected Enabled\n"); | | 882 | printf(" Power Fault Detected Enabled\n"); |
882 | if ((regs[o2i(capoff + 0x18)] & 0x0004) != 0) | | 883 | if ((regs[o2i(capoff + 0x18)] & 0x0004) != 0) |
883 | printf(" MRL Sensor Changed Enabled\n"); | | 884 | printf(" MRL Sensor Changed Enabled\n"); |
884 | if ((regs[o2i(capoff + 0x18)] & 0x0008) != 0) | | 885 | if ((regs[o2i(capoff + 0x18)] & 0x0008) != 0) |
885 | printf(" Presense Detected Changed Enabled\n"); | | 886 | printf(" Presense Detected Changed Enabled\n"); |
886 | if ((regs[o2i(capoff + 0x18)] & 0x0010) != 0) | | 887 | if ((regs[o2i(capoff + 0x18)] & 0x0010) != 0) |
887 | printf(" Command Completed Interrupt Enabled\n"); | | 888 | printf(" Command Completed Interrupt Enabled\n"); |
888 | if ((regs[o2i(capoff + 0x18)] & 0x0020) != 0) | | 889 | if ((regs[o2i(capoff + 0x18)] & 0x0020) != 0) |
889 | printf(" Hot-Plug Interrupt Enabled\n"); | | 890 | printf(" Hot-Plug Interrupt Enabled\n"); |
890 | printf(" Attention Indicator Control: "); | | 891 | printf(" Attention Indicator Control: "); |
891 | switch ((regs[o2i(capoff + 0x18)] & 0x00c0) >> 6) { | | 892 | switch ((regs[o2i(capoff + 0x18)] & 0x00c0) >> 6) { |
892 | case 0x0: | | 893 | case 0x0: |
893 | printf("reserved\n"); | | 894 | printf("reserved\n"); |
894 | break; | | 895 | break; |
895 | case 0x1: | | 896 | case 0x1: |
896 | printf("on\n"); | | 897 | printf("on\n"); |
897 | break; | | 898 | break; |
898 | case 0x2: | | 899 | case 0x2: |
899 | printf("blink\n"); | | 900 | printf("blink\n"); |
900 | break; | | 901 | break; |
901 | case 0x3: | | 902 | case 0x3: |
902 | printf("off\n"); | | 903 | printf("off\n"); |
903 | break; | | 904 | break; |
904 | } | | 905 | } |
905 | printf(" Power Indicator Control: "); | | 906 | printf(" Power Indicator Control: "); |
906 | switch ((regs[o2i(capoff + 0x18)] & 0x0300) >> 8) { | | 907 | switch ((regs[o2i(capoff + 0x18)] & 0x0300) >> 8) { |
907 | case 0x0: | | 908 | case 0x0: |
908 | printf("reserved\n"); | | 909 | printf("reserved\n"); |
909 | break; | | 910 | break; |
910 | case 0x1: | | 911 | case 0x1: |
911 | printf("on\n"); | | 912 | printf("on\n"); |
912 | break; | | 913 | break; |
913 | case 0x2: | | 914 | case 0x2: |
914 | printf("blink\n"); | | 915 | printf("blink\n"); |
915 | break; | | 916 | break; |
916 | case 0x3: | | 917 | case 0x3: |
917 | printf("off\n"); | | 918 | printf("off\n"); |
918 | break; | | 919 | break; |
919 | } | | 920 | } |
920 | printf(" Power Controller Control: "); | | 921 | printf(" Power Controller Control: "); |
921 | if ((regs[o2i(capoff + 0x18)] & 0x0400) != 0) | | 922 | if ((regs[o2i(capoff + 0x18)] & 0x0400) != 0) |
922 | printf("off\n"); | | 923 | printf("off\n"); |
923 | else | | 924 | else |
924 | printf("on\n"); | | 925 | printf("on\n"); |
925 | } | | 926 | } |
926 | } | | 927 | } |
927 | | | 928 | |
928 | static const char * | | 929 | static const char * |
929 | pci_conf_print_pcipm_cap_aux(uint16_t caps) | | 930 | pci_conf_print_pcipm_cap_aux(uint16_t caps) |
930 | { | | 931 | { |
931 | switch ((caps >> 6) & 7) { | | 932 | switch ((caps >> 6) & 7) { |
932 | case 0: return "self-powered"; | | 933 | case 0: return "self-powered"; |
933 | case 1: return "55 mA"; | | 934 | case 1: return "55 mA"; |
934 | case 2: return "100 mA"; | | 935 | case 2: return "100 mA"; |
935 | case 3: return "160 mA"; | | 936 | case 3: return "160 mA"; |
936 | case 4: return "220 mA"; | | 937 | case 4: return "220 mA"; |
937 | case 5: return "270 mA"; | | 938 | case 5: return "270 mA"; |
938 | case 6: return "320 mA"; | | 939 | case 6: return "320 mA"; |
939 | case 7: | | 940 | case 7: |
940 | default: return "375 mA"; | | 941 | default: return "375 mA"; |
941 | } | | 942 | } |
942 | } | | 943 | } |
943 | | | 944 | |
944 | static const char * | | 945 | static const char * |
945 | pci_conf_print_pcipm_cap_pmrev(uint8_t val) | | 946 | pci_conf_print_pcipm_cap_pmrev(uint8_t val) |
946 | { | | 947 | { |
947 | static const char unk[] = "unknown"; | | 948 | static const char unk[] = "unknown"; |
948 | static const char *pmrev[8] = { | | 949 | static const char *pmrev[8] = { |
949 | unk, "1.0", "1.1", "1.2", unk, unk, unk, unk | | 950 | unk, "1.0", "1.1", "1.2", unk, unk, unk, unk |
950 | }; | | 951 | }; |
951 | if (val > 7) | | 952 | if (val > 7) |
952 | return unk; | | 953 | return unk; |
953 | return pmrev[val]; | | 954 | return pmrev[val]; |
954 | } | | 955 | } |
955 | | | 956 | |
956 | static void | | 957 | static void |
957 | pci_conf_print_pcipm_cap(const pcireg_t *regs, int capoff) | | 958 | pci_conf_print_pcipm_cap(const pcireg_t *regs, int capoff) |
958 | { | | 959 | { |
959 | uint16_t caps, pmcsr; | | 960 | uint16_t caps, pmcsr; |
960 | | | 961 | |
961 | caps = regs[o2i(capoff)] >> 16; | | 962 | caps = regs[o2i(capoff)] >> 16; |
962 | pmcsr = regs[o2i(capoff + 0x04)] & 0xffff; | | 963 | pmcsr = regs[o2i(capoff + 0x04)] & 0xffff; |
963 | | | 964 | |
964 | printf("\n PCI Power Management Capabilities Register\n"); | | 965 | printf("\n PCI Power Management Capabilities Register\n"); |
965 | | | 966 | |
966 | printf(" Capabilities register: 0x%04x\n", caps); | | 967 | printf(" Capabilities register: 0x%04x\n", caps); |
967 | printf(" Version: %s\n", | | 968 | printf(" Version: %s\n", |
968 | pci_conf_print_pcipm_cap_pmrev(caps & 0x3)); | | 969 | pci_conf_print_pcipm_cap_pmrev(caps & 0x3)); |
969 | printf(" PME# clock: %s\n", caps & 0x4 ? "on" : "off"); | | 970 | printf(" PME# clock: %s\n", caps & 0x4 ? "on" : "off"); |
970 | printf(" Device specific initialization: %s\n", | | 971 | printf(" Device specific initialization: %s\n", |
971 | caps & 0x20 ? "on" : "off"); | | 972 | caps & 0x20 ? "on" : "off"); |
972 | printf(" 3.3V auxiliary current: %s\n", | | 973 | printf(" 3.3V auxiliary current: %s\n", |
973 | pci_conf_print_pcipm_cap_aux(caps)); | | 974 | pci_conf_print_pcipm_cap_aux(caps)); |
974 | printf(" D1 power management state support: %s\n", | | 975 | printf(" D1 power management state support: %s\n", |
975 | (caps >> 9) & 1 ? "on" : "off"); | | 976 | (caps >> 9) & 1 ? "on" : "off"); |
976 | printf(" D2 power management state support: %s\n", | | 977 | printf(" D2 power management state support: %s\n", |
977 | (caps >> 10) & 1 ? "on" : "off"); | | 978 | (caps >> 10) & 1 ? "on" : "off"); |
978 | printf(" PME# support: 0x%02x\n", caps >> 11); | | 979 | printf(" PME# support: 0x%02x\n", caps >> 11); |
979 | | | 980 | |
980 | printf(" Control/status register: 0x%04x\n", pmcsr); | | 981 | printf(" Control/status register: 0x%04x\n", pmcsr); |
981 | printf(" Power state: D%d\n", pmcsr & 3); | | 982 | printf(" Power state: D%d\n", pmcsr & 3); |
982 | printf(" PCI Express reserved: %s\n", | | 983 | printf(" PCI Express reserved: %s\n", |
983 | (pmcsr >> 2) & 1 ? "on" : "off"); | | 984 | (pmcsr >> 2) & 1 ? "on" : "off"); |
984 | printf(" No soft reset: %s\n", (pmcsr >> 3) & 1 ? "on" : "off"); | | 985 | printf(" No soft reset: %s\n", (pmcsr >> 3) & 1 ? "on" : "off"); |
985 | printf(" PME# assertion %sabled\n", | | 986 | printf(" PME# assertion %sabled\n", |
986 | (pmcsr >> 8) & 1 ? "en" : "dis"); | | 987 | (pmcsr >> 8) & 1 ? "en" : "dis"); |
987 | printf(" PME# status: %s\n", (pmcsr >> 15) ? "on" : "off"); | | 988 | printf(" PME# status: %s\n", (pmcsr >> 15) ? "on" : "off"); |
988 | } | | 989 | } |
989 | | | 990 | |
990 | static void | | 991 | static void |
991 | pci_conf_print_msi_cap(const pcireg_t *regs, int capoff) | | 992 | pci_conf_print_msi_cap(const pcireg_t *regs, int capoff) |
992 | { | | 993 | { |
993 | uint32_t ctl, mmc, mme; | | 994 | uint32_t ctl, mmc, mme; |
994 | | | 995 | |
995 | regs += o2i(capoff); | | 996 | regs += o2i(capoff); |
996 | ctl = *regs++; | | 997 | ctl = *regs++; |
997 | mmc = __SHIFTOUT(ctl, PCI_MSI_CTL_MMC_MASK); | | 998 | mmc = __SHIFTOUT(ctl, PCI_MSI_CTL_MMC_MASK); |
998 | mme = __SHIFTOUT(ctl, PCI_MSI_CTL_MME_MASK); | | 999 | mme = __SHIFTOUT(ctl, PCI_MSI_CTL_MME_MASK); |
999 | | | 1000 | |
1000 | printf("\n PCI Message Signaled Interrupt\n"); | | 1001 | printf("\n PCI Message Signaled Interrupt\n"); |
1001 | | | 1002 | |
1002 | printf(" Message Control register: 0x%04x\n", ctl >> 16); | | 1003 | printf(" Message Control register: 0x%04x\n", ctl >> 16); |
1003 | printf(" MSI Enabled: %s\n", | | 1004 | printf(" MSI Enabled: %s\n", |
1004 | ctl & PCI_MSI_CTL_MSI_ENABLE ? "yes" : "no"); | | 1005 | ctl & PCI_MSI_CTL_MSI_ENABLE ? "yes" : "no"); |
1005 | printf(" Multiple Message Capable: %s (%d vector%s)\n", | | 1006 | printf(" Multiple Message Capable: %s (%d vector%s)\n", |
1006 | mmc > 0 ? "yes" : "no", 1 << mmc, mmc > 0 ? "s" : ""); | | 1007 | mmc > 0 ? "yes" : "no", 1 << mmc, mmc > 0 ? "s" : ""); |
1007 | printf(" Multiple Message Enabled: %s (%d vector%s)\n", | | 1008 | printf(" Multiple Message Enabled: %s (%d vector%s)\n", |
1008 | mme > 0 ? "on" : "off", 1 << mme, mme > 0 ? "s" : ""); | | 1009 | mme > 0 ? "on" : "off", 1 << mme, mme > 0 ? "s" : ""); |
1009 | printf(" 64 Bit Address Capable: %s\n", | | 1010 | printf(" 64 Bit Address Capable: %s\n", |
1010 | ctl & PCI_MSI_CTL_64BIT_ADDR ? "yes" : "no"); | | 1011 | ctl & PCI_MSI_CTL_64BIT_ADDR ? "yes" : "no"); |
1011 | printf(" Per-Vector Masking Capable: %s\n", | | 1012 | printf(" Per-Vector Masking Capable: %s\n", |
1012 | ctl & PCI_MSI_CTL_PERVEC_MASK ? "yes" : "no"); | | 1013 | ctl & PCI_MSI_CTL_PERVEC_MASK ? "yes" : "no"); |
1013 | printf(" Message Address %sregister: 0x%08x\n", | | 1014 | printf(" Message Address %sregister: 0x%08x\n", |
1014 | ctl & PCI_MSI_CTL_64BIT_ADDR ? "(lower) " : "", *regs++); | | 1015 | ctl & PCI_MSI_CTL_64BIT_ADDR ? "(lower) " : "", *regs++); |
1015 | if (ctl & PCI_MSI_CTL_64BIT_ADDR) { | | 1016 | if (ctl & PCI_MSI_CTL_64BIT_ADDR) { |
1016 | printf(" Message Address %sregister: 0x%08x\n", | | 1017 | printf(" Message Address %sregister: 0x%08x\n", |
1017 | "(upper) ", *regs++); | | 1018 | "(upper) ", *regs++); |
1018 | } | | 1019 | } |
1019 | printf(" Message Data register: 0x%08x\n", *regs++); | | 1020 | printf(" Message Data register: 0x%08x\n", *regs++); |
1020 | if (ctl & PCI_MSI_CTL_PERVEC_MASK) { | | 1021 | if (ctl & PCI_MSI_CTL_PERVEC_MASK) { |
1021 | printf(" Vector Mask register: 0x%08x\n", *regs++); | | 1022 | printf(" Vector Mask register: 0x%08x\n", *regs++); |
1022 | printf(" Vector Pending register: 0x%08x\n", *regs++); | | 1023 | printf(" Vector Pending register: 0x%08x\n", *regs++); |
1023 | } | | 1024 | } |
1024 | } | | 1025 | } |
1025 | static void | | 1026 | static void |
1026 | pci_conf_print_caplist( | | 1027 | pci_conf_print_caplist( |
1027 | #ifdef _KERNEL | | 1028 | #ifdef _KERNEL |
1028 | pci_chipset_tag_t pc, pcitag_t tag, | | 1029 | pci_chipset_tag_t pc, pcitag_t tag, |
1029 | #endif | | 1030 | #endif |
1030 | const pcireg_t *regs, int capoff) | | 1031 | const pcireg_t *regs, int capoff) |
1031 | { | | 1032 | { |
1032 | int off; | | 1033 | int off; |
1033 | pcireg_t rval; | | 1034 | pcireg_t rval; |
1034 | int pcie_off = -1, pcipm_off = -1, msi_off = -1; | | 1035 | int pcie_off = -1, pcipm_off = -1, msi_off = -1; |
1035 | | | 1036 | |
1036 | for (off = PCI_CAPLIST_PTR(regs[o2i(capoff)]); | | 1037 | for (off = PCI_CAPLIST_PTR(regs[o2i(capoff)]); |
1037 | off != 0; | | 1038 | off != 0; |
1038 | off = PCI_CAPLIST_NEXT(regs[o2i(off)])) { | | 1039 | off = PCI_CAPLIST_NEXT(regs[o2i(off)])) { |
1039 | rval = regs[o2i(off)]; | | 1040 | rval = regs[o2i(off)]; |
1040 | printf(" Capability register at 0x%02x\n", off); | | 1041 | printf(" Capability register at 0x%02x\n", off); |
1041 | | | 1042 | |
1042 | printf(" type: 0x%02x (", PCI_CAPLIST_CAP(rval)); | | 1043 | printf(" type: 0x%02x (", PCI_CAPLIST_CAP(rval)); |
1043 | switch (PCI_CAPLIST_CAP(rval)) { | | 1044 | switch (PCI_CAPLIST_CAP(rval)) { |
1044 | case PCI_CAP_RESERVED0: | | 1045 | case PCI_CAP_RESERVED0: |
1045 | printf("reserved"); | | 1046 | printf("reserved"); |
1046 | break; | | 1047 | break; |
1047 | case PCI_CAP_PWRMGMT: | | 1048 | case PCI_CAP_PWRMGMT: |
1048 | printf("Power Management, rev. %s", | | 1049 | printf("Power Management, rev. %s", |
1049 | pci_conf_print_pcipm_cap_pmrev((rval >> 0) & 0x07)); | | 1050 | pci_conf_print_pcipm_cap_pmrev((rval >> 0) & 0x07)); |
1050 | pcipm_off = off; | | 1051 | pcipm_off = off; |
1051 | break; | | 1052 | break; |
1052 | case PCI_CAP_AGP: | | 1053 | case PCI_CAP_AGP: |
1053 | printf("AGP, rev. %d.%d", | | 1054 | printf("AGP, rev. %d.%d", |
1054 | PCI_CAP_AGP_MAJOR(rval), | | 1055 | PCI_CAP_AGP_MAJOR(rval), |
1055 | PCI_CAP_AGP_MINOR(rval)); | | 1056 | PCI_CAP_AGP_MINOR(rval)); |
1056 | break; | | 1057 | break; |
1057 | case PCI_CAP_VPD: | | 1058 | case PCI_CAP_VPD: |
1058 | printf("VPD"); | | 1059 | printf("VPD"); |
1059 | break; | | 1060 | break; |
1060 | case PCI_CAP_SLOTID: | | 1061 | case PCI_CAP_SLOTID: |
1061 | printf("SlotID"); | | 1062 | printf("SlotID"); |
1062 | break; | | 1063 | break; |
1063 | case PCI_CAP_MSI: | | 1064 | case PCI_CAP_MSI: |
1064 | printf("MSI"); | | 1065 | printf("MSI"); |
1065 | msi_off = off; | | 1066 | msi_off = off; |
1066 | break; | | 1067 | break; |
1067 | case PCI_CAP_CPCI_HOTSWAP: | | 1068 | case PCI_CAP_CPCI_HOTSWAP: |
1068 | printf("CompactPCI Hot-swapping"); | | 1069 | printf("CompactPCI Hot-swapping"); |
1069 | break; | | 1070 | break; |
1070 | case PCI_CAP_PCIX: | | 1071 | case PCI_CAP_PCIX: |
1071 | printf("PCI-X"); | | 1072 | printf("PCI-X"); |
1072 | break; | | 1073 | break; |
1073 | case PCI_CAP_LDT: | | 1074 | case PCI_CAP_LDT: |
1074 | printf("LDT"); | | 1075 | printf("LDT"); |
1075 | break; | | 1076 | break; |
1076 | case PCI_CAP_VENDSPEC: | | 1077 | case PCI_CAP_VENDSPEC: |
1077 | printf("Vendor-specific"); | | 1078 | printf("Vendor-specific"); |
1078 | break; | | 1079 | break; |
1079 | case PCI_CAP_DEBUGPORT: | | 1080 | case PCI_CAP_DEBUGPORT: |
1080 | printf("Debug Port"); | | 1081 | printf("Debug Port"); |
1081 | break; | | 1082 | break; |
1082 | case PCI_CAP_CPCI_RSRCCTL: | | 1083 | case PCI_CAP_CPCI_RSRCCTL: |
1083 | printf("CompactPCI Resource Control"); | | 1084 | printf("CompactPCI Resource Control"); |
1084 | break; | | 1085 | break; |
1085 | case PCI_CAP_HOTPLUG: | | 1086 | case PCI_CAP_HOTPLUG: |
1086 | printf("Hot-Plug"); | | 1087 | printf("Hot-Plug"); |
1087 | break; | | 1088 | break; |
1088 | case PCI_CAP_AGP8: | | 1089 | case PCI_CAP_AGP8: |
1089 | printf("AGP 8x"); | | 1090 | printf("AGP 8x"); |
1090 | break; | | 1091 | break; |
1091 | case PCI_CAP_SECURE: | | 1092 | case PCI_CAP_SECURE: |
1092 | printf("Secure Device"); | | 1093 | printf("Secure Device"); |
1093 | break; | | 1094 | break; |
1094 | case PCI_CAP_PCIEXPRESS: | | 1095 | case PCI_CAP_PCIEXPRESS: |
1095 | printf("PCI Express"); | | 1096 | printf("PCI Express"); |
1096 | pcie_off = off; | | 1097 | pcie_off = off; |
1097 | break; | | 1098 | break; |
1098 | case PCI_CAP_MSIX: | | 1099 | case PCI_CAP_MSIX: |
1099 | printf("MSI-X"); | | 1100 | printf("MSI-X"); |
1100 | break; | | 1101 | break; |
1101 | case PCI_CAP_SATA: | | 1102 | case PCI_CAP_SATA: |
1102 | printf("SATA"); | | 1103 | printf("SATA"); |
1103 | break; | | 1104 | break; |
1104 | case PCI_CAP_PCIAF: | | 1105 | case PCI_CAP_PCIAF: |
1105 | printf("Advanced Features"); | | 1106 | printf("Advanced Features"); |
1106 | break; | | 1107 | break; |
1107 | default: | | 1108 | default: |
1108 | printf("unknown"); | | 1109 | printf("unknown"); |
1109 | } | | 1110 | } |
1110 | printf(")\n"); | | 1111 | printf(")\n"); |
1111 | } | | 1112 | } |
1112 | if (msi_off != -1) | | 1113 | if (msi_off != -1) |
1113 | pci_conf_print_msi_cap(regs, msi_off); | | 1114 | pci_conf_print_msi_cap(regs, msi_off); |
1114 | if (pcipm_off != -1) | | 1115 | if (pcipm_off != -1) |
1115 | pci_conf_print_pcipm_cap(regs, pcipm_off); | | 1116 | pci_conf_print_pcipm_cap(regs, pcipm_off); |
1116 | if (pcie_off != -1) | | 1117 | if (pcie_off != -1) |
1117 | pci_conf_print_pcie_cap(regs, pcie_off); | | 1118 | pci_conf_print_pcie_cap(regs, pcie_off); |
1118 | } | | 1119 | } |
1119 | | | 1120 | |