| @@ -1,1085 +1,1129 @@ | | | @@ -1,1085 +1,1129 @@ |
1 | /* $NetBSD: pci_subr.c,v 1.224 2020/05/30 10:43:46 jdolecek Exp $ */ | | 1 | /* $NetBSD: pci_subr.c,v 1.225 2021/01/27 05:00:15 thorpej 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.224 2020/05/30 10:43:46 jdolecek Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.225 2021/01/27 05:00:15 thorpej 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 | #include <sys/kmem.h> | | 55 | #include <sys/kmem.h> |
56 | | | 56 | |
57 | #define MALLOC(sz) kmem_alloc(sz, KM_SLEEP) | | 57 | #define MALLOC(sz) kmem_alloc(sz, KM_SLEEP) |
58 | #define FREE(p, sz) kmem_free(p, sz) | | 58 | #define FREE(p, sz) kmem_free(p, sz) |
59 | | | 59 | |
60 | #else | | 60 | #else |
61 | #include <pci.h> | | 61 | #include <pci.h> |
62 | #include <stdarg.h> | | 62 | #include <stdarg.h> |
63 | #include <stdbool.h> | | 63 | #include <stdbool.h> |
64 | #include <stdio.h> | | 64 | #include <stdio.h> |
65 | #include <stdlib.h> | | 65 | #include <stdlib.h> |
66 | #include <string.h> | | 66 | #include <string.h> |
67 | | | 67 | |
68 | #define MALLOC(sz) malloc(sz) | | 68 | #define MALLOC(sz) malloc(sz) |
69 | #define FREE(p, sz) free(p) | | 69 | #define FREE(p, sz) free(p) |
70 | | | 70 | |
71 | #endif | | 71 | #endif |
72 | | | 72 | |
73 | #include <dev/pci/pcireg.h> | | 73 | #include <dev/pci/pcireg.h> |
74 | #ifdef _KERNEL | | 74 | #ifdef _KERNEL |
75 | #include <dev/pci/pcivar.h> | | 75 | #include <dev/pci/pcivar.h> |
76 | #else | | 76 | #else |
77 | #include <dev/pci/pci_verbose.h> | | 77 | #include <dev/pci/pci_verbose.h> |
78 | #include <dev/pci/pcidevs.h> | | 78 | #include <dev/pci/pcidevs.h> |
79 | #include <dev/pci/pcidevs_data.h> | | 79 | #include <dev/pci/pcidevs_data.h> |
80 | #endif | | 80 | #endif |
81 | | | 81 | |
82 | static int pci_conf_find_cap(const pcireg_t *, unsigned int, int *); | | 82 | static int pci_conf_find_cap(const pcireg_t *, unsigned int, int *); |
83 | static int pci_conf_find_extcap(const pcireg_t *, unsigned int, int *); | | 83 | static int pci_conf_find_extcap(const pcireg_t *, unsigned int, int *); |
84 | static void pci_conf_print_pcie_power(uint8_t, unsigned int); | | 84 | static void pci_conf_print_pcie_power(uint8_t, unsigned int); |
85 | #define PCIREG_SHIFTOUT(a, b) ((pcireg_t)__SHIFTOUT((a), (b))) | | 85 | #define PCIREG_SHIFTOUT(a, b) ((pcireg_t)__SHIFTOUT((a), (b))) |
86 | | | 86 | |
| | | 87 | #ifdef _KERNEL |
| | | 88 | /* |
| | | 89 | * Common routines used to match a compatible device by its PCI ID code. |
| | | 90 | */ |
| | | 91 | |
| | | 92 | const struct device_compatible_entry * |
| | | 93 | pci_compatible_lookup_id(pcireg_t const id, |
| | | 94 | const struct device_compatible_entry *dce) |
| | | 95 | { |
| | | 96 | return device_compatible_lookup_id(id, PCI_COMPAT_EOL_VALUE, dce); |
| | | 97 | } |
| | | 98 | |
| | | 99 | const struct device_compatible_entry * |
| | | 100 | pci_compatible_lookup(const struct pci_attach_args * const pa, |
| | | 101 | const struct device_compatible_entry * const dce) |
| | | 102 | { |
| | | 103 | return pci_compatible_lookup_id(pa->pa_id, dce); |
| | | 104 | } |
| | | 105 | |
| | | 106 | const struct device_compatible_entry * |
| | | 107 | pci_compatible_lookup_subsys(const struct pci_attach_args * const pa, |
| | | 108 | const struct device_compatible_entry * const dce) |
| | | 109 | { |
| | | 110 | const pcireg_t subsysid = |
| | | 111 | pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG); |
| | | 112 | |
| | | 113 | return pci_compatible_lookup_id(subsysid, dce); |
| | | 114 | } |
| | | 115 | |
| | | 116 | int |
| | | 117 | pci_compatible_match(const struct pci_attach_args * const pa, |
| | | 118 | const struct device_compatible_entry * const dce) |
| | | 119 | { |
| | | 120 | return pci_compatible_lookup(pa, dce) != NULL; |
| | | 121 | } |
| | | 122 | |
| | | 123 | int |
| | | 124 | pci_compatible_match_subsys(const struct pci_attach_args * const pa, |
| | | 125 | const struct device_compatible_entry * const dce) |
| | | 126 | { |
| | | 127 | return pci_compatible_lookup_subsys(pa, dce) != NULL; |
| | | 128 | } |
| | | 129 | #endif /* _KERNEL */ |
| | | 130 | |
87 | /* | | 131 | /* |
88 | * Descriptions of known PCI classes and subclasses. | | 132 | * Descriptions of known PCI classes and subclasses. |
89 | * | | 133 | * |
90 | * Subclasses are described in the same way as classes, but have a | | 134 | * Subclasses are described in the same way as classes, but have a |
91 | * NULL subclass pointer. | | 135 | * NULL subclass pointer. |
92 | */ | | 136 | */ |
93 | struct pci_class { | | 137 | struct pci_class { |
94 | const char *name; | | 138 | const char *name; |
95 | u_int val; /* as wide as pci_{,sub}class_t */ | | 139 | u_int val; /* as wide as pci_{,sub}class_t */ |
96 | const struct pci_class *subclasses; | | 140 | const struct pci_class *subclasses; |
97 | }; | | 141 | }; |
98 | | | 142 | |
99 | /* | | 143 | /* |
100 | * Class 0x00. | | 144 | * Class 0x00. |
101 | * Before rev. 2.0. | | 145 | * Before rev. 2.0. |
102 | */ | | 146 | */ |
103 | static const struct pci_class pci_subclass_prehistoric[] = { | | 147 | static const struct pci_class pci_subclass_prehistoric[] = { |
104 | { "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC, NULL, }, | | 148 | { "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC, NULL, }, |
105 | { "VGA", PCI_SUBCLASS_PREHISTORIC_VGA, NULL, }, | | 149 | { "VGA", PCI_SUBCLASS_PREHISTORIC_VGA, NULL, }, |
106 | { NULL, 0, NULL, }, | | 150 | { NULL, 0, NULL, }, |
107 | }; | | 151 | }; |
108 | | | 152 | |
109 | /* | | 153 | /* |
110 | * Class 0x01. | | 154 | * Class 0x01. |
111 | * Mass storage controller | | 155 | * Mass storage controller |
112 | */ | | 156 | */ |
113 | | | 157 | |
114 | /* ATA programming interface */ | | 158 | /* ATA programming interface */ |
115 | static const struct pci_class pci_interface_ata[] = { | | 159 | static const struct pci_class pci_interface_ata[] = { |
116 | { "with single DMA", PCI_INTERFACE_ATA_SINGLEDMA, NULL, }, | | 160 | { "with single DMA", PCI_INTERFACE_ATA_SINGLEDMA, NULL, }, |
117 | { "with chained DMA", PCI_INTERFACE_ATA_CHAINEDDMA, NULL, }, | | 161 | { "with chained DMA", PCI_INTERFACE_ATA_CHAINEDDMA, NULL, }, |
118 | { NULL, 0, NULL, }, | | 162 | { NULL, 0, NULL, }, |
119 | }; | | 163 | }; |
120 | | | 164 | |
121 | /* SATA programming interface */ | | 165 | /* SATA programming interface */ |
122 | static const struct pci_class pci_interface_sata[] = { | | 166 | static const struct pci_class pci_interface_sata[] = { |
123 | { "vendor specific", PCI_INTERFACE_SATA_VND, NULL, }, | | 167 | { "vendor specific", PCI_INTERFACE_SATA_VND, NULL, }, |
124 | { "AHCI 1.0", PCI_INTERFACE_SATA_AHCI10, NULL, }, | | 168 | { "AHCI 1.0", PCI_INTERFACE_SATA_AHCI10, NULL, }, |
125 | { "Serial Storage Bus Interface", PCI_INTERFACE_SATA_SSBI, NULL, }, | | 169 | { "Serial Storage Bus Interface", PCI_INTERFACE_SATA_SSBI, NULL, }, |
126 | { NULL, 0, NULL, }, | | 170 | { NULL, 0, NULL, }, |
127 | }; | | 171 | }; |
128 | | | 172 | |
129 | /* Flash programming interface */ | | 173 | /* Flash programming interface */ |
130 | static const struct pci_class pci_interface_nvm[] = { | | 174 | static const struct pci_class pci_interface_nvm[] = { |
131 | { "vendor specific", PCI_INTERFACE_NVM_VND, NULL, }, | | 175 | { "vendor specific", PCI_INTERFACE_NVM_VND, NULL, }, |
132 | { "NVMHCI 1.0", PCI_INTERFACE_NVM_NVMHCI10, NULL, }, | | 176 | { "NVMHCI 1.0", PCI_INTERFACE_NVM_NVMHCI10, NULL, }, |
133 | { "NVMe", PCI_INTERFACE_NVM_NVME, NULL, }, | | 177 | { "NVMe", PCI_INTERFACE_NVM_NVME, NULL, }, |
134 | { NULL, 0, NULL, }, | | 178 | { NULL, 0, NULL, }, |
135 | }; | | 179 | }; |
136 | | | 180 | |
137 | /* Subclasses */ | | 181 | /* Subclasses */ |
138 | static const struct pci_class pci_subclass_mass_storage[] = { | | 182 | static const struct pci_class pci_subclass_mass_storage[] = { |
139 | { "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI, NULL, }, | | 183 | { "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI, NULL, }, |
140 | { "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE, NULL, }, | | 184 | { "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE, NULL, }, |
141 | { "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY, NULL, }, | | 185 | { "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY, NULL, }, |
142 | { "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI, NULL, }, | | 186 | { "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI, NULL, }, |
143 | { "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID, NULL, }, | | 187 | { "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID, NULL, }, |
144 | { "ATA", PCI_SUBCLASS_MASS_STORAGE_ATA, | | 188 | { "ATA", PCI_SUBCLASS_MASS_STORAGE_ATA, |
145 | pci_interface_ata, }, | | 189 | pci_interface_ata, }, |
146 | { "SATA", PCI_SUBCLASS_MASS_STORAGE_SATA, | | 190 | { "SATA", PCI_SUBCLASS_MASS_STORAGE_SATA, |
147 | pci_interface_sata, }, | | 191 | pci_interface_sata, }, |
148 | { "SAS", PCI_SUBCLASS_MASS_STORAGE_SAS, NULL, }, | | 192 | { "SAS", PCI_SUBCLASS_MASS_STORAGE_SAS, NULL, }, |
149 | { "Flash", PCI_SUBCLASS_MASS_STORAGE_NVM, | | 193 | { "Flash", PCI_SUBCLASS_MASS_STORAGE_NVM, |
150 | pci_interface_nvm, }, | | 194 | pci_interface_nvm, }, |
151 | { "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC, NULL, }, | | 195 | { "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC, NULL, }, |
152 | { NULL, 0, NULL, }, | | 196 | { NULL, 0, NULL, }, |
153 | }; | | 197 | }; |
154 | | | 198 | |
155 | /* | | 199 | /* |
156 | * Class 0x02. | | 200 | * Class 0x02. |
157 | * Network controller. | | 201 | * Network controller. |
158 | */ | | 202 | */ |
159 | static const struct pci_class pci_subclass_network[] = { | | 203 | static const struct pci_class pci_subclass_network[] = { |
160 | { "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET, NULL, }, | | 204 | { "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET, NULL, }, |
161 | { "token ring", PCI_SUBCLASS_NETWORK_TOKENRING, NULL, }, | | 205 | { "token ring", PCI_SUBCLASS_NETWORK_TOKENRING, NULL, }, |
162 | { "FDDI", PCI_SUBCLASS_NETWORK_FDDI, NULL, }, | | 206 | { "FDDI", PCI_SUBCLASS_NETWORK_FDDI, NULL, }, |
163 | { "ATM", PCI_SUBCLASS_NETWORK_ATM, NULL, }, | | 207 | { "ATM", PCI_SUBCLASS_NETWORK_ATM, NULL, }, |
164 | { "ISDN", PCI_SUBCLASS_NETWORK_ISDN, NULL, }, | | 208 | { "ISDN", PCI_SUBCLASS_NETWORK_ISDN, NULL, }, |
165 | { "WorldFip", PCI_SUBCLASS_NETWORK_WORLDFIP, NULL, }, | | 209 | { "WorldFip", PCI_SUBCLASS_NETWORK_WORLDFIP, NULL, }, |
166 | { "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP, NULL, }, | | 210 | { "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP, NULL, }, |
167 | { "miscellaneous", PCI_SUBCLASS_NETWORK_MISC, NULL, }, | | 211 | { "miscellaneous", PCI_SUBCLASS_NETWORK_MISC, NULL, }, |
168 | { NULL, 0, NULL, }, | | 212 | { NULL, 0, NULL, }, |
169 | }; | | 213 | }; |
170 | | | 214 | |
171 | /* | | 215 | /* |
172 | * Class 0x03. | | 216 | * Class 0x03. |
173 | * Display controller. | | 217 | * Display controller. |
174 | */ | | 218 | */ |
175 | | | 219 | |
176 | /* VGA programming interface */ | | 220 | /* VGA programming interface */ |
177 | static const struct pci_class pci_interface_vga[] = { | | 221 | static const struct pci_class pci_interface_vga[] = { |
178 | { "", PCI_INTERFACE_VGA_VGA, NULL, }, | | 222 | { "", PCI_INTERFACE_VGA_VGA, NULL, }, |
179 | { "8514-compat", PCI_INTERFACE_VGA_8514, NULL, }, | | 223 | { "8514-compat", PCI_INTERFACE_VGA_8514, NULL, }, |
180 | { NULL, 0, NULL, }, | | 224 | { NULL, 0, NULL, }, |
181 | }; | | 225 | }; |
182 | /* Subclasses */ | | 226 | /* Subclasses */ |
183 | static const struct pci_class pci_subclass_display[] = { | | 227 | static const struct pci_class pci_subclass_display[] = { |
184 | { "VGA", PCI_SUBCLASS_DISPLAY_VGA, pci_interface_vga,}, | | 228 | { "VGA", PCI_SUBCLASS_DISPLAY_VGA, pci_interface_vga,}, |
185 | { "XGA", PCI_SUBCLASS_DISPLAY_XGA, NULL, }, | | 229 | { "XGA", PCI_SUBCLASS_DISPLAY_XGA, NULL, }, |
186 | { "3D", PCI_SUBCLASS_DISPLAY_3D, NULL, }, | | 230 | { "3D", PCI_SUBCLASS_DISPLAY_3D, NULL, }, |
187 | { "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC, NULL, }, | | 231 | { "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC, NULL, }, |
188 | { NULL, 0, NULL, }, | | 232 | { NULL, 0, NULL, }, |
189 | }; | | 233 | }; |
190 | | | 234 | |
191 | /* | | 235 | /* |
192 | * Class 0x04. | | 236 | * Class 0x04. |
193 | * Multimedia device. | | 237 | * Multimedia device. |
194 | */ | | 238 | */ |
195 | static const struct pci_class pci_subclass_multimedia[] = { | | 239 | static const struct pci_class pci_subclass_multimedia[] = { |
196 | { "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO, NULL, }, | | 240 | { "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO, NULL, }, |
197 | { "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO, NULL, }, | | 241 | { "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO, NULL, }, |
198 | { "telephony", PCI_SUBCLASS_MULTIMEDIA_TELEPHONY, NULL,}, | | 242 | { "telephony", PCI_SUBCLASS_MULTIMEDIA_TELEPHONY, NULL,}, |
199 | { "mixed mode", PCI_SUBCLASS_MULTIMEDIA_HDAUDIO, NULL, }, | | 243 | { "mixed mode", PCI_SUBCLASS_MULTIMEDIA_HDAUDIO, NULL, }, |
200 | { "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC, NULL, }, | | 244 | { "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC, NULL, }, |
201 | { NULL, 0, NULL, }, | | 245 | { NULL, 0, NULL, }, |
202 | }; | | 246 | }; |
203 | | | 247 | |
204 | /* | | 248 | /* |
205 | * Class 0x05. | | 249 | * Class 0x05. |
206 | * Memory controller. | | 250 | * Memory controller. |
207 | */ | | 251 | */ |
208 | static const struct pci_class pci_subclass_memory[] = { | | 252 | static const struct pci_class pci_subclass_memory[] = { |
209 | { "RAM", PCI_SUBCLASS_MEMORY_RAM, NULL, }, | | 253 | { "RAM", PCI_SUBCLASS_MEMORY_RAM, NULL, }, |
210 | { "flash", PCI_SUBCLASS_MEMORY_FLASH, NULL, }, | | 254 | { "flash", PCI_SUBCLASS_MEMORY_FLASH, NULL, }, |
211 | { "miscellaneous", PCI_SUBCLASS_MEMORY_MISC, NULL, }, | | 255 | { "miscellaneous", PCI_SUBCLASS_MEMORY_MISC, NULL, }, |
212 | { NULL, 0, NULL, }, | | 256 | { NULL, 0, NULL, }, |
213 | }; | | 257 | }; |
214 | | | 258 | |
215 | /* | | 259 | /* |
216 | * Class 0x06. | | 260 | * Class 0x06. |
217 | * Bridge device. | | 261 | * Bridge device. |
218 | */ | | 262 | */ |
219 | | | 263 | |
220 | /* PCI bridge programming interface */ | | 264 | /* PCI bridge programming interface */ |
221 | static const struct pci_class pci_interface_pcibridge[] = { | | 265 | static const struct pci_class pci_interface_pcibridge[] = { |
222 | { "", PCI_INTERFACE_BRIDGE_PCI_PCI, NULL, }, | | 266 | { "", PCI_INTERFACE_BRIDGE_PCI_PCI, NULL, }, |
223 | { "subtractive decode", PCI_INTERFACE_BRIDGE_PCI_SUBDEC, NULL, }, | | 267 | { "subtractive decode", PCI_INTERFACE_BRIDGE_PCI_SUBDEC, NULL, }, |
224 | { NULL, 0, NULL, }, | | 268 | { NULL, 0, NULL, }, |
225 | }; | | 269 | }; |
226 | | | 270 | |
227 | /* Semi-transparent PCI-to-PCI bridge programming interface */ | | 271 | /* Semi-transparent PCI-to-PCI bridge programming interface */ |
228 | static const struct pci_class pci_interface_stpci[] = { | | 272 | static const struct pci_class pci_interface_stpci[] = { |
229 | { "primary side facing host", PCI_INTERFACE_STPCI_PRIMARY, NULL, }, | | 273 | { "primary side facing host", PCI_INTERFACE_STPCI_PRIMARY, NULL, }, |
230 | { "secondary side facing host", PCI_INTERFACE_STPCI_SECONDARY, NULL, }, | | 274 | { "secondary side facing host", PCI_INTERFACE_STPCI_SECONDARY, NULL, }, |
231 | { NULL, 0, NULL, }, | | 275 | { NULL, 0, NULL, }, |
232 | }; | | 276 | }; |
233 | | | 277 | |
234 | /* Advanced Switching programming interface */ | | 278 | /* Advanced Switching programming interface */ |
235 | static const struct pci_class pci_interface_advsw[] = { | | 279 | static const struct pci_class pci_interface_advsw[] = { |
236 | { "custom interface", PCI_INTERFACE_ADVSW_CUSTOM, NULL, }, | | 280 | { "custom interface", PCI_INTERFACE_ADVSW_CUSTOM, NULL, }, |
237 | { "ASI-SIG", PCI_INTERFACE_ADVSW_ASISIG, NULL, }, | | 281 | { "ASI-SIG", PCI_INTERFACE_ADVSW_ASISIG, NULL, }, |
238 | { NULL, 0, NULL, }, | | 282 | { NULL, 0, NULL, }, |
239 | }; | | 283 | }; |
240 | | | 284 | |
241 | /* Subclasses */ | | 285 | /* Subclasses */ |
242 | static const struct pci_class pci_subclass_bridge[] = { | | 286 | static const struct pci_class pci_subclass_bridge[] = { |
243 | { "host", PCI_SUBCLASS_BRIDGE_HOST, NULL, }, | | 287 | { "host", PCI_SUBCLASS_BRIDGE_HOST, NULL, }, |
244 | { "ISA", PCI_SUBCLASS_BRIDGE_ISA, NULL, }, | | 288 | { "ISA", PCI_SUBCLASS_BRIDGE_ISA, NULL, }, |
245 | { "EISA", PCI_SUBCLASS_BRIDGE_EISA, NULL, }, | | 289 | { "EISA", PCI_SUBCLASS_BRIDGE_EISA, NULL, }, |
246 | { "MicroChannel", PCI_SUBCLASS_BRIDGE_MC, NULL, }, | | 290 | { "MicroChannel", PCI_SUBCLASS_BRIDGE_MC, NULL, }, |
247 | { "PCI", PCI_SUBCLASS_BRIDGE_PCI, | | 291 | { "PCI", PCI_SUBCLASS_BRIDGE_PCI, |
248 | pci_interface_pcibridge, }, | | 292 | pci_interface_pcibridge, }, |
249 | { "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA, NULL, }, | | 293 | { "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA, NULL, }, |
250 | { "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS, NULL, }, | | 294 | { "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS, NULL, }, |
251 | { "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS, NULL, }, | | 295 | { "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS, NULL, }, |
252 | { "RACEway", PCI_SUBCLASS_BRIDGE_RACEWAY, NULL, }, | | 296 | { "RACEway", PCI_SUBCLASS_BRIDGE_RACEWAY, NULL, }, |
253 | { "Semi-transparent PCI", PCI_SUBCLASS_BRIDGE_STPCI, | | 297 | { "Semi-transparent PCI", PCI_SUBCLASS_BRIDGE_STPCI, |
254 | pci_interface_stpci, }, | | 298 | pci_interface_stpci, }, |
255 | { "InfiniBand", PCI_SUBCLASS_BRIDGE_INFINIBAND, NULL, }, | | 299 | { "InfiniBand", PCI_SUBCLASS_BRIDGE_INFINIBAND, NULL, }, |
256 | { "advanced switching", PCI_SUBCLASS_BRIDGE_ADVSW, | | 300 | { "advanced switching", PCI_SUBCLASS_BRIDGE_ADVSW, |
257 | pci_interface_advsw, }, | | 301 | pci_interface_advsw, }, |
258 | { "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC, NULL, }, | | 302 | { "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC, NULL, }, |
259 | { NULL, 0, NULL, }, | | 303 | { NULL, 0, NULL, }, |
260 | }; | | 304 | }; |
261 | | | 305 | |
262 | /* | | 306 | /* |
263 | * Class 0x07. | | 307 | * Class 0x07. |
264 | * Simple communications controller. | | 308 | * Simple communications controller. |
265 | */ | | 309 | */ |
266 | | | 310 | |
267 | /* Serial controller programming interface */ | | 311 | /* Serial controller programming interface */ |
268 | static const struct pci_class pci_interface_serial[] = { | | 312 | static const struct pci_class pci_interface_serial[] = { |
269 | { "generic XT-compat", PCI_INTERFACE_SERIAL_XT, NULL, }, | | 313 | { "generic XT-compat", PCI_INTERFACE_SERIAL_XT, NULL, }, |
270 | { "16450-compat", PCI_INTERFACE_SERIAL_16450, NULL, }, | | 314 | { "16450-compat", PCI_INTERFACE_SERIAL_16450, NULL, }, |
271 | { "16550-compat", PCI_INTERFACE_SERIAL_16550, NULL, }, | | 315 | { "16550-compat", PCI_INTERFACE_SERIAL_16550, NULL, }, |
272 | { "16650-compat", PCI_INTERFACE_SERIAL_16650, NULL, }, | | 316 | { "16650-compat", PCI_INTERFACE_SERIAL_16650, NULL, }, |
273 | { "16750-compat", PCI_INTERFACE_SERIAL_16750, NULL, }, | | 317 | { "16750-compat", PCI_INTERFACE_SERIAL_16750, NULL, }, |
274 | { "16850-compat", PCI_INTERFACE_SERIAL_16850, NULL, }, | | 318 | { "16850-compat", PCI_INTERFACE_SERIAL_16850, NULL, }, |
275 | { "16950-compat", PCI_INTERFACE_SERIAL_16950, NULL, }, | | 319 | { "16950-compat", PCI_INTERFACE_SERIAL_16950, NULL, }, |
276 | { NULL, 0, NULL, }, | | 320 | { NULL, 0, NULL, }, |
277 | }; | | 321 | }; |
278 | | | 322 | |
279 | /* Parallel controller programming interface */ | | 323 | /* Parallel controller programming interface */ |
280 | static const struct pci_class pci_interface_parallel[] = { | | 324 | static const struct pci_class pci_interface_parallel[] = { |
281 | { "", PCI_INTERFACE_PARALLEL, NULL,}, | | 325 | { "", PCI_INTERFACE_PARALLEL, NULL,}, |
282 | { "bi-directional", PCI_INTERFACE_PARALLEL_BIDIRECTIONAL, NULL,}, | | 326 | { "bi-directional", PCI_INTERFACE_PARALLEL_BIDIRECTIONAL, NULL,}, |
283 | { "ECP 1.X-compat", PCI_INTERFACE_PARALLEL_ECP1X, NULL,}, | | 327 | { "ECP 1.X-compat", PCI_INTERFACE_PARALLEL_ECP1X, NULL,}, |
284 | { "IEEE1284 controller", PCI_INTERFACE_PARALLEL_IEEE1284_CNTRL, NULL,}, | | 328 | { "IEEE1284 controller", PCI_INTERFACE_PARALLEL_IEEE1284_CNTRL, NULL,}, |
285 | { "IEEE1284 target", PCI_INTERFACE_PARALLEL_IEEE1284_TGT, NULL,}, | | 329 | { "IEEE1284 target", PCI_INTERFACE_PARALLEL_IEEE1284_TGT, NULL,}, |
286 | { NULL, 0, NULL,}, | | 330 | { NULL, 0, NULL,}, |
287 | }; | | 331 | }; |
288 | | | 332 | |
289 | /* Modem programming interface */ | | 333 | /* Modem programming interface */ |
290 | static const struct pci_class pci_interface_modem[] = { | | 334 | static const struct pci_class pci_interface_modem[] = { |
291 | { "", PCI_INTERFACE_MODEM, NULL,}, | | 335 | { "", PCI_INTERFACE_MODEM, NULL,}, |
292 | { "Hayes&16450-compat", PCI_INTERFACE_MODEM_HAYES16450, NULL,}, | | 336 | { "Hayes&16450-compat", PCI_INTERFACE_MODEM_HAYES16450, NULL,}, |
293 | { "Hayes&16550-compat", PCI_INTERFACE_MODEM_HAYES16550, NULL,}, | | 337 | { "Hayes&16550-compat", PCI_INTERFACE_MODEM_HAYES16550, NULL,}, |
294 | { "Hayes&16650-compat", PCI_INTERFACE_MODEM_HAYES16650, NULL,}, | | 338 | { "Hayes&16650-compat", PCI_INTERFACE_MODEM_HAYES16650, NULL,}, |
295 | { "Hayes&16750-compat", PCI_INTERFACE_MODEM_HAYES16750, NULL,}, | | 339 | { "Hayes&16750-compat", PCI_INTERFACE_MODEM_HAYES16750, NULL,}, |
296 | { NULL, 0, NULL,}, | | 340 | { NULL, 0, NULL,}, |
297 | }; | | 341 | }; |
298 | | | 342 | |
299 | /* Subclasses */ | | 343 | /* Subclasses */ |
300 | static const struct pci_class pci_subclass_communications[] = { | | 344 | static const struct pci_class pci_subclass_communications[] = { |
301 | { "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL, | | 345 | { "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL, |
302 | pci_interface_serial, }, | | 346 | pci_interface_serial, }, |
303 | { "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL, | | 347 | { "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL, |
304 | pci_interface_parallel, }, | | 348 | pci_interface_parallel, }, |
305 | { "multi-port serial", PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL, NULL,}, | | 349 | { "multi-port serial", PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL, NULL,}, |
306 | { "modem", PCI_SUBCLASS_COMMUNICATIONS_MODEM, | | 350 | { "modem", PCI_SUBCLASS_COMMUNICATIONS_MODEM, |
307 | pci_interface_modem, }, | | 351 | pci_interface_modem, }, |
308 | { "GPIB", PCI_SUBCLASS_COMMUNICATIONS_GPIB, NULL,}, | | 352 | { "GPIB", PCI_SUBCLASS_COMMUNICATIONS_GPIB, NULL,}, |
309 | { "smartcard", PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD, NULL,}, | | 353 | { "smartcard", PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD, NULL,}, |
310 | { "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC, NULL,}, | | 354 | { "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC, NULL,}, |
311 | { NULL, 0, NULL,}, | | 355 | { NULL, 0, NULL,}, |
312 | }; | | 356 | }; |
313 | | | 357 | |
314 | /* | | 358 | /* |
315 | * Class 0x08. | | 359 | * Class 0x08. |
316 | * Base system peripheral. | | 360 | * Base system peripheral. |
317 | */ | | 361 | */ |
318 | | | 362 | |
319 | /* PIC programming interface */ | | 363 | /* PIC programming interface */ |
320 | static const struct pci_class pci_interface_pic[] = { | | 364 | static const struct pci_class pci_interface_pic[] = { |
321 | { "generic 8259", PCI_INTERFACE_PIC_8259, NULL, }, | | 365 | { "generic 8259", PCI_INTERFACE_PIC_8259, NULL, }, |
322 | { "ISA PIC", PCI_INTERFACE_PIC_ISA, NULL, }, | | 366 | { "ISA PIC", PCI_INTERFACE_PIC_ISA, NULL, }, |
323 | { "EISA PIC", PCI_INTERFACE_PIC_EISA, NULL, }, | | 367 | { "EISA PIC", PCI_INTERFACE_PIC_EISA, NULL, }, |
324 | { "IO APIC", PCI_INTERFACE_PIC_IOAPIC, NULL, }, | | 368 | { "IO APIC", PCI_INTERFACE_PIC_IOAPIC, NULL, }, |
325 | { "IO(x) APIC", PCI_INTERFACE_PIC_IOXAPIC, NULL, }, | | 369 | { "IO(x) APIC", PCI_INTERFACE_PIC_IOXAPIC, NULL, }, |
326 | { NULL, 0, NULL, }, | | 370 | { NULL, 0, NULL, }, |
327 | }; | | 371 | }; |
328 | | | 372 | |
329 | /* DMA programming interface */ | | 373 | /* DMA programming interface */ |
330 | static const struct pci_class pci_interface_dma[] = { | | 374 | static const struct pci_class pci_interface_dma[] = { |
331 | { "generic 8237", PCI_INTERFACE_DMA_8237, NULL, }, | | 375 | { "generic 8237", PCI_INTERFACE_DMA_8237, NULL, }, |
332 | { "ISA", PCI_INTERFACE_DMA_ISA, NULL, }, | | 376 | { "ISA", PCI_INTERFACE_DMA_ISA, NULL, }, |
333 | { "EISA", PCI_INTERFACE_DMA_EISA, NULL, }, | | 377 | { "EISA", PCI_INTERFACE_DMA_EISA, NULL, }, |
334 | { NULL, 0, NULL, }, | | 378 | { NULL, 0, NULL, }, |
335 | }; | | 379 | }; |
336 | | | 380 | |
337 | /* Timer programming interface */ | | 381 | /* Timer programming interface */ |
338 | static const struct pci_class pci_interface_tmr[] = { | | 382 | static const struct pci_class pci_interface_tmr[] = { |
339 | { "generic 8254", PCI_INTERFACE_TIMER_8254, NULL, }, | | 383 | { "generic 8254", PCI_INTERFACE_TIMER_8254, NULL, }, |
340 | { "ISA", PCI_INTERFACE_TIMER_ISA, NULL, }, | | 384 | { "ISA", PCI_INTERFACE_TIMER_ISA, NULL, }, |
341 | { "EISA", PCI_INTERFACE_TIMER_EISA, NULL, }, | | 385 | { "EISA", PCI_INTERFACE_TIMER_EISA, NULL, }, |
342 | { "HPET", PCI_INTERFACE_TIMER_HPET, NULL, }, | | 386 | { "HPET", PCI_INTERFACE_TIMER_HPET, NULL, }, |
343 | { NULL, 0, NULL, }, | | 387 | { NULL, 0, NULL, }, |
344 | }; | | 388 | }; |
345 | | | 389 | |
346 | /* RTC programming interface */ | | 390 | /* RTC programming interface */ |
347 | static const struct pci_class pci_interface_rtc[] = { | | 391 | static const struct pci_class pci_interface_rtc[] = { |
348 | { "generic", PCI_INTERFACE_RTC_GENERIC, NULL, }, | | 392 | { "generic", PCI_INTERFACE_RTC_GENERIC, NULL, }, |
349 | { "ISA", PCI_INTERFACE_RTC_ISA, NULL, }, | | 393 | { "ISA", PCI_INTERFACE_RTC_ISA, NULL, }, |
350 | { NULL, 0, NULL, }, | | 394 | { NULL, 0, NULL, }, |
351 | }; | | 395 | }; |
352 | | | 396 | |
353 | /* Subclasses */ | | 397 | /* Subclasses */ |
354 | static const struct pci_class pci_subclass_system[] = { | | 398 | static const struct pci_class pci_subclass_system[] = { |
355 | { "interrupt", PCI_SUBCLASS_SYSTEM_PIC, pci_interface_pic,}, | | 399 | { "interrupt", PCI_SUBCLASS_SYSTEM_PIC, pci_interface_pic,}, |
356 | { "DMA", PCI_SUBCLASS_SYSTEM_DMA, pci_interface_dma,}, | | 400 | { "DMA", PCI_SUBCLASS_SYSTEM_DMA, pci_interface_dma,}, |
357 | { "timer", PCI_SUBCLASS_SYSTEM_TIMER, pci_interface_tmr,}, | | 401 | { "timer", PCI_SUBCLASS_SYSTEM_TIMER, pci_interface_tmr,}, |
358 | { "RTC", PCI_SUBCLASS_SYSTEM_RTC, pci_interface_rtc,}, | | 402 | { "RTC", PCI_SUBCLASS_SYSTEM_RTC, pci_interface_rtc,}, |
359 | { "PCI Hot-Plug", PCI_SUBCLASS_SYSTEM_PCIHOTPLUG, NULL, }, | | 403 | { "PCI Hot-Plug", PCI_SUBCLASS_SYSTEM_PCIHOTPLUG, NULL, }, |
360 | { "SD Host Controller", PCI_SUBCLASS_SYSTEM_SDHC, NULL, }, | | 404 | { "SD Host Controller", PCI_SUBCLASS_SYSTEM_SDHC, NULL, }, |
361 | { "IOMMU", PCI_SUBCLASS_SYSTEM_IOMMU, NULL, }, | | 405 | { "IOMMU", PCI_SUBCLASS_SYSTEM_IOMMU, NULL, }, |
362 | { "Root Complex Event Collector", PCI_SUBCLASS_SYSTEM_RCEC, NULL, }, | | 406 | { "Root Complex Event Collector", PCI_SUBCLASS_SYSTEM_RCEC, NULL, }, |
363 | { "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC, NULL, }, | | 407 | { "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC, NULL, }, |
364 | { NULL, 0, NULL, }, | | 408 | { NULL, 0, NULL, }, |
365 | }; | | 409 | }; |
366 | | | 410 | |
367 | /* | | 411 | /* |
368 | * Class 0x09. | | 412 | * Class 0x09. |
369 | * Input device. | | 413 | * Input device. |
370 | */ | | 414 | */ |
371 | | | 415 | |
372 | /* Gameport programming interface */ | | 416 | /* Gameport programming interface */ |
373 | static const struct pci_class pci_interface_game[] = { | | 417 | static const struct pci_class pci_interface_game[] = { |
374 | { "generic", PCI_INTERFACE_GAMEPORT_GENERIC, NULL, }, | | 418 | { "generic", PCI_INTERFACE_GAMEPORT_GENERIC, NULL, }, |
375 | { "legacy", PCI_INTERFACE_GAMEPORT_LEGACY, NULL, }, | | 419 | { "legacy", PCI_INTERFACE_GAMEPORT_LEGACY, NULL, }, |
376 | { NULL, 0, NULL, }, | | 420 | { NULL, 0, NULL, }, |
377 | }; | | 421 | }; |
378 | | | 422 | |
379 | /* Subclasses */ | | 423 | /* Subclasses */ |
380 | static const struct pci_class pci_subclass_input[] = { | | 424 | static const struct pci_class pci_subclass_input[] = { |
381 | { "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD, NULL, }, | | 425 | { "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD, NULL, }, |
382 | { "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER, NULL, }, | | 426 | { "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER, NULL, }, |
383 | { "mouse", PCI_SUBCLASS_INPUT_MOUSE, NULL, }, | | 427 | { "mouse", PCI_SUBCLASS_INPUT_MOUSE, NULL, }, |
384 | { "scanner", PCI_SUBCLASS_INPUT_SCANNER, NULL, }, | | 428 | { "scanner", PCI_SUBCLASS_INPUT_SCANNER, NULL, }, |
385 | { "game port", PCI_SUBCLASS_INPUT_GAMEPORT, | | 429 | { "game port", PCI_SUBCLASS_INPUT_GAMEPORT, |
386 | pci_interface_game, }, | | 430 | pci_interface_game, }, |
387 | { "miscellaneous", PCI_SUBCLASS_INPUT_MISC, NULL, }, | | 431 | { "miscellaneous", PCI_SUBCLASS_INPUT_MISC, NULL, }, |
388 | { NULL, 0, NULL, }, | | 432 | { NULL, 0, NULL, }, |
389 | }; | | 433 | }; |
390 | | | 434 | |
391 | /* | | 435 | /* |
392 | * Class 0x0a. | | 436 | * Class 0x0a. |
393 | * Docking station. | | 437 | * Docking station. |
394 | */ | | 438 | */ |
395 | static const struct pci_class pci_subclass_dock[] = { | | 439 | static const struct pci_class pci_subclass_dock[] = { |
396 | { "generic", PCI_SUBCLASS_DOCK_GENERIC, NULL, }, | | 440 | { "generic", PCI_SUBCLASS_DOCK_GENERIC, NULL, }, |
397 | { "miscellaneous", PCI_SUBCLASS_DOCK_MISC, NULL, }, | | 441 | { "miscellaneous", PCI_SUBCLASS_DOCK_MISC, NULL, }, |
398 | { NULL, 0, NULL, }, | | 442 | { NULL, 0, NULL, }, |
399 | }; | | 443 | }; |
400 | | | 444 | |
401 | /* | | 445 | /* |
402 | * Class 0x0b. | | 446 | * Class 0x0b. |
403 | * Processor. | | 447 | * Processor. |
404 | */ | | 448 | */ |
405 | static const struct pci_class pci_subclass_processor[] = { | | 449 | static const struct pci_class pci_subclass_processor[] = { |
406 | { "386", PCI_SUBCLASS_PROCESSOR_386, NULL, }, | | 450 | { "386", PCI_SUBCLASS_PROCESSOR_386, NULL, }, |
407 | { "486", PCI_SUBCLASS_PROCESSOR_486, NULL, }, | | 451 | { "486", PCI_SUBCLASS_PROCESSOR_486, NULL, }, |
408 | { "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM, NULL, }, | | 452 | { "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM, NULL, }, |
409 | { "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA, NULL, }, | | 453 | { "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA, NULL, }, |
410 | { "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC, NULL, }, | | 454 | { "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC, NULL, }, |
411 | { "MIPS", PCI_SUBCLASS_PROCESSOR_MIPS, NULL, }, | | 455 | { "MIPS", PCI_SUBCLASS_PROCESSOR_MIPS, NULL, }, |
412 | { "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC, NULL, }, | | 456 | { "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC, NULL, }, |
413 | { "miscellaneous", PCI_SUBCLASS_PROCESSOR_MISC, NULL, }, | | 457 | { "miscellaneous", PCI_SUBCLASS_PROCESSOR_MISC, NULL, }, |
414 | { NULL, 0, NULL, }, | | 458 | { NULL, 0, NULL, }, |
415 | }; | | 459 | }; |
416 | | | 460 | |
417 | /* | | 461 | /* |
418 | * Class 0x0c. | | 462 | * Class 0x0c. |
419 | * Serial bus controller. | | 463 | * Serial bus controller. |
420 | */ | | 464 | */ |
421 | | | 465 | |
422 | /* IEEE1394 programming interface */ | | 466 | /* IEEE1394 programming interface */ |
423 | static const struct pci_class pci_interface_ieee1394[] = { | | 467 | static const struct pci_class pci_interface_ieee1394[] = { |
424 | { "Firewire", PCI_INTERFACE_IEEE1394_FIREWIRE, NULL,}, | | 468 | { "Firewire", PCI_INTERFACE_IEEE1394_FIREWIRE, NULL,}, |
425 | { "OpenHCI", PCI_INTERFACE_IEEE1394_OPENHCI, NULL,}, | | 469 | { "OpenHCI", PCI_INTERFACE_IEEE1394_OPENHCI, NULL,}, |
426 | { NULL, 0, NULL,}, | | 470 | { NULL, 0, NULL,}, |
427 | }; | | 471 | }; |
428 | | | 472 | |
429 | /* USB programming interface */ | | 473 | /* USB programming interface */ |
430 | static const struct pci_class pci_interface_usb[] = { | | 474 | static const struct pci_class pci_interface_usb[] = { |
431 | { "UHCI", PCI_INTERFACE_USB_UHCI, NULL, }, | | 475 | { "UHCI", PCI_INTERFACE_USB_UHCI, NULL, }, |
432 | { "OHCI", PCI_INTERFACE_USB_OHCI, NULL, }, | | 476 | { "OHCI", PCI_INTERFACE_USB_OHCI, NULL, }, |
433 | { "EHCI", PCI_INTERFACE_USB_EHCI, NULL, }, | | 477 | { "EHCI", PCI_INTERFACE_USB_EHCI, NULL, }, |
434 | { "xHCI", PCI_INTERFACE_USB_XHCI, NULL, }, | | 478 | { "xHCI", PCI_INTERFACE_USB_XHCI, NULL, }, |
435 | { "other HC", PCI_INTERFACE_USB_OTHERHC, NULL, }, | | 479 | { "other HC", PCI_INTERFACE_USB_OTHERHC, NULL, }, |
436 | { "device", PCI_INTERFACE_USB_DEVICE, NULL, }, | | 480 | { "device", PCI_INTERFACE_USB_DEVICE, NULL, }, |
437 | { NULL, 0, NULL, }, | | 481 | { NULL, 0, NULL, }, |
438 | }; | | 482 | }; |
439 | | | 483 | |
440 | /* IPMI programming interface */ | | 484 | /* IPMI programming interface */ |
441 | static const struct pci_class pci_interface_ipmi[] = { | | 485 | static const struct pci_class pci_interface_ipmi[] = { |
442 | { "SMIC", PCI_INTERFACE_IPMI_SMIC, NULL, }, | | 486 | { "SMIC", PCI_INTERFACE_IPMI_SMIC, NULL, }, |
443 | { "keyboard", PCI_INTERFACE_IPMI_KBD, NULL, }, | | 487 | { "keyboard", PCI_INTERFACE_IPMI_KBD, NULL, }, |
444 | { "block transfer", PCI_INTERFACE_IPMI_BLOCKXFER, NULL, }, | | 488 | { "block transfer", PCI_INTERFACE_IPMI_BLOCKXFER, NULL, }, |
445 | { NULL, 0, NULL, }, | | 489 | { NULL, 0, NULL, }, |
446 | }; | | 490 | }; |
447 | | | 491 | |
448 | /* Subclasses */ | | 492 | /* Subclasses */ |
449 | static const struct pci_class pci_subclass_serialbus[] = { | | 493 | static const struct pci_class pci_subclass_serialbus[] = { |
450 | { "IEEE1394", PCI_SUBCLASS_SERIALBUS_FIREWIRE, | | 494 | { "IEEE1394", PCI_SUBCLASS_SERIALBUS_FIREWIRE, |
451 | pci_interface_ieee1394, }, | | 495 | pci_interface_ieee1394, }, |
452 | { "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS, NULL, }, | | 496 | { "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS, NULL, }, |
453 | { "SSA", PCI_SUBCLASS_SERIALBUS_SSA, NULL, }, | | 497 | { "SSA", PCI_SUBCLASS_SERIALBUS_SSA, NULL, }, |
454 | { "USB", PCI_SUBCLASS_SERIALBUS_USB, | | 498 | { "USB", PCI_SUBCLASS_SERIALBUS_USB, |
455 | pci_interface_usb, }, | | 499 | pci_interface_usb, }, |
456 | /* XXX Fiber Channel/_FIBRECHANNEL */ | | 500 | /* XXX Fiber Channel/_FIBRECHANNEL */ |
457 | { "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER, NULL, }, | | 501 | { "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER, NULL, }, |
458 | { "SMBus", PCI_SUBCLASS_SERIALBUS_SMBUS, NULL, }, | | 502 | { "SMBus", PCI_SUBCLASS_SERIALBUS_SMBUS, NULL, }, |
459 | { "InfiniBand", PCI_SUBCLASS_SERIALBUS_INFINIBAND, NULL,}, | | 503 | { "InfiniBand", PCI_SUBCLASS_SERIALBUS_INFINIBAND, NULL,}, |
460 | { "IPMI", PCI_SUBCLASS_SERIALBUS_IPMI, | | 504 | { "IPMI", PCI_SUBCLASS_SERIALBUS_IPMI, |
461 | pci_interface_ipmi, }, | | 505 | pci_interface_ipmi, }, |
462 | { "SERCOS", PCI_SUBCLASS_SERIALBUS_SERCOS, NULL, }, | | 506 | { "SERCOS", PCI_SUBCLASS_SERIALBUS_SERCOS, NULL, }, |
463 | { "CANbus", PCI_SUBCLASS_SERIALBUS_CANBUS, NULL, }, | | 507 | { "CANbus", PCI_SUBCLASS_SERIALBUS_CANBUS, NULL, }, |
464 | { "miscellaneous", PCI_SUBCLASS_SERIALBUS_MISC, NULL, }, | | 508 | { "miscellaneous", PCI_SUBCLASS_SERIALBUS_MISC, NULL, }, |
465 | { NULL, 0, NULL, }, | | 509 | { NULL, 0, NULL, }, |
466 | }; | | 510 | }; |
467 | | | 511 | |
468 | /* | | 512 | /* |
469 | * Class 0x0d. | | 513 | * Class 0x0d. |
470 | * Wireless Controller. | | 514 | * Wireless Controller. |
471 | */ | | 515 | */ |
472 | static const struct pci_class pci_subclass_wireless[] = { | | 516 | static const struct pci_class pci_subclass_wireless[] = { |
473 | { "IrDA", PCI_SUBCLASS_WIRELESS_IRDA, NULL, }, | | 517 | { "IrDA", PCI_SUBCLASS_WIRELESS_IRDA, NULL, }, |
474 | { "Consumer IR",/*XXX*/ PCI_SUBCLASS_WIRELESS_CONSUMERIR, NULL, }, | | 518 | { "Consumer IR",/*XXX*/ PCI_SUBCLASS_WIRELESS_CONSUMERIR, NULL, }, |
475 | { "RF", PCI_SUBCLASS_WIRELESS_RF, NULL, }, | | 519 | { "RF", PCI_SUBCLASS_WIRELESS_RF, NULL, }, |
476 | { "bluetooth", PCI_SUBCLASS_WIRELESS_BLUETOOTH, NULL, }, | | 520 | { "bluetooth", PCI_SUBCLASS_WIRELESS_BLUETOOTH, NULL, }, |
477 | { "broadband", PCI_SUBCLASS_WIRELESS_BROADBAND, NULL, }, | | 521 | { "broadband", PCI_SUBCLASS_WIRELESS_BROADBAND, NULL, }, |
478 | { "802.11a (5 GHz)", PCI_SUBCLASS_WIRELESS_802_11A, NULL, }, | | 522 | { "802.11a (5 GHz)", PCI_SUBCLASS_WIRELESS_802_11A, NULL, }, |
479 | { "802.11b (2.4 GHz)", PCI_SUBCLASS_WIRELESS_802_11B, NULL, }, | | 523 | { "802.11b (2.4 GHz)", PCI_SUBCLASS_WIRELESS_802_11B, NULL, }, |
480 | { "miscellaneous", PCI_SUBCLASS_WIRELESS_MISC, NULL, }, | | 524 | { "miscellaneous", PCI_SUBCLASS_WIRELESS_MISC, NULL, }, |
481 | { NULL, 0, NULL, }, | | 525 | { NULL, 0, NULL, }, |
482 | }; | | 526 | }; |
483 | | | 527 | |
484 | /* | | 528 | /* |
485 | * Class 0x0e. | | 529 | * Class 0x0e. |
486 | * Intelligent IO controller. | | 530 | * Intelligent IO controller. |
487 | */ | | 531 | */ |
488 | | | 532 | |
489 | /* Intelligent IO programming interface */ | | 533 | /* Intelligent IO programming interface */ |
490 | static const struct pci_class pci_interface_i2o[] = { | | 534 | static const struct pci_class pci_interface_i2o[] = { |
491 | { "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40, NULL, }, | | 535 | { "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40, NULL, }, |
492 | { NULL, 0, NULL, }, | | 536 | { NULL, 0, NULL, }, |
493 | }; | | 537 | }; |
494 | | | 538 | |
495 | /* Subclasses */ | | 539 | /* Subclasses */ |
496 | static const struct pci_class pci_subclass_i2o[] = { | | 540 | static const struct pci_class pci_subclass_i2o[] = { |
497 | { "standard", PCI_SUBCLASS_I2O_STANDARD, pci_interface_i2o,}, | | 541 | { "standard", PCI_SUBCLASS_I2O_STANDARD, pci_interface_i2o,}, |
498 | { "miscellaneous", PCI_SUBCLASS_I2O_MISC, NULL, }, | | 542 | { "miscellaneous", PCI_SUBCLASS_I2O_MISC, NULL, }, |
499 | { NULL, 0, NULL, }, | | 543 | { NULL, 0, NULL, }, |
500 | }; | | 544 | }; |
501 | | | 545 | |
502 | /* | | 546 | /* |
503 | * Class 0x0f. | | 547 | * Class 0x0f. |
504 | * Satellite communication controller. | | 548 | * Satellite communication controller. |
505 | */ | | 549 | */ |
506 | static const struct pci_class pci_subclass_satcom[] = { | | 550 | static const struct pci_class pci_subclass_satcom[] = { |
507 | { "TV", PCI_SUBCLASS_SATCOM_TV, NULL, }, | | 551 | { "TV", PCI_SUBCLASS_SATCOM_TV, NULL, }, |
508 | { "audio", PCI_SUBCLASS_SATCOM_AUDIO, NULL, }, | | 552 | { "audio", PCI_SUBCLASS_SATCOM_AUDIO, NULL, }, |
509 | { "voice", PCI_SUBCLASS_SATCOM_VOICE, NULL, }, | | 553 | { "voice", PCI_SUBCLASS_SATCOM_VOICE, NULL, }, |
510 | { "data", PCI_SUBCLASS_SATCOM_DATA, NULL, }, | | 554 | { "data", PCI_SUBCLASS_SATCOM_DATA, NULL, }, |
511 | { "miscellaneous", PCI_SUBCLASS_SATCOM_MISC, NULL, }, | | 555 | { "miscellaneous", PCI_SUBCLASS_SATCOM_MISC, NULL, }, |
512 | { NULL, 0, NULL, }, | | 556 | { NULL, 0, NULL, }, |
513 | }; | | 557 | }; |
514 | | | 558 | |
515 | /* | | 559 | /* |
516 | * Class 0x10. | | 560 | * Class 0x10. |
517 | * Encryption/Decryption controller. | | 561 | * Encryption/Decryption controller. |
518 | */ | | 562 | */ |
519 | static const struct pci_class pci_subclass_crypto[] = { | | 563 | static const struct pci_class pci_subclass_crypto[] = { |
520 | { "network/computing", PCI_SUBCLASS_CRYPTO_NETCOMP, NULL, }, | | 564 | { "network/computing", PCI_SUBCLASS_CRYPTO_NETCOMP, NULL, }, |
521 | { "entertainment", PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,}, | | 565 | { "entertainment", PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,}, |
522 | { "miscellaneous", PCI_SUBCLASS_CRYPTO_MISC, NULL, }, | | 566 | { "miscellaneous", PCI_SUBCLASS_CRYPTO_MISC, NULL, }, |
523 | { NULL, 0, NULL, }, | | 567 | { NULL, 0, NULL, }, |
524 | }; | | 568 | }; |
525 | | | 569 | |
526 | /* | | 570 | /* |
527 | * Class 0x11. | | 571 | * Class 0x11. |
528 | * Data aquuisition and signal processing controller. | | 572 | * Data aquuisition and signal processing controller. |
529 | */ | | 573 | */ |
530 | static const struct pci_class pci_subclass_dasp[] = { | | 574 | static const struct pci_class pci_subclass_dasp[] = { |
531 | { "DPIO", PCI_SUBCLASS_DASP_DPIO, NULL, }, | | 575 | { "DPIO", PCI_SUBCLASS_DASP_DPIO, NULL, }, |
532 | { "performance counters", PCI_SUBCLASS_DASP_TIMEFREQ, NULL, }, | | 576 | { "performance counters", PCI_SUBCLASS_DASP_TIMEFREQ, NULL, }, |
533 | { "synchronization", PCI_SUBCLASS_DASP_SYNC, NULL, }, | | 577 | { "synchronization", PCI_SUBCLASS_DASP_SYNC, NULL, }, |
534 | { "management", PCI_SUBCLASS_DASP_MGMT, NULL, }, | | 578 | { "management", PCI_SUBCLASS_DASP_MGMT, NULL, }, |
535 | { "miscellaneous", PCI_SUBCLASS_DASP_MISC, NULL, }, | | 579 | { "miscellaneous", PCI_SUBCLASS_DASP_MISC, NULL, }, |
536 | { NULL, 0, NULL, }, | | 580 | { NULL, 0, NULL, }, |
537 | }; | | 581 | }; |
538 | | | 582 | |
539 | /* List of classes */ | | 583 | /* List of classes */ |
540 | static const struct pci_class pci_classes[] = { | | 584 | static const struct pci_class pci_classes[] = { |
541 | { "prehistoric", PCI_CLASS_PREHISTORIC, | | 585 | { "prehistoric", PCI_CLASS_PREHISTORIC, |
542 | pci_subclass_prehistoric, }, | | 586 | pci_subclass_prehistoric, }, |
543 | { "mass storage", PCI_CLASS_MASS_STORAGE, | | 587 | { "mass storage", PCI_CLASS_MASS_STORAGE, |
544 | pci_subclass_mass_storage, }, | | 588 | pci_subclass_mass_storage, }, |
545 | { "network", PCI_CLASS_NETWORK, | | 589 | { "network", PCI_CLASS_NETWORK, |
546 | pci_subclass_network, }, | | 590 | pci_subclass_network, }, |
547 | { "display", PCI_CLASS_DISPLAY, | | 591 | { "display", PCI_CLASS_DISPLAY, |
548 | pci_subclass_display, }, | | 592 | pci_subclass_display, }, |
549 | { "multimedia", PCI_CLASS_MULTIMEDIA, | | 593 | { "multimedia", PCI_CLASS_MULTIMEDIA, |
550 | pci_subclass_multimedia, }, | | 594 | pci_subclass_multimedia, }, |
551 | { "memory", PCI_CLASS_MEMORY, | | 595 | { "memory", PCI_CLASS_MEMORY, |
552 | pci_subclass_memory, }, | | 596 | pci_subclass_memory, }, |
553 | { "bridge", PCI_CLASS_BRIDGE, | | 597 | { "bridge", PCI_CLASS_BRIDGE, |
554 | pci_subclass_bridge, }, | | 598 | pci_subclass_bridge, }, |
555 | { "communications", PCI_CLASS_COMMUNICATIONS, | | 599 | { "communications", PCI_CLASS_COMMUNICATIONS, |
556 | pci_subclass_communications, }, | | 600 | pci_subclass_communications, }, |
557 | { "system", PCI_CLASS_SYSTEM, | | 601 | { "system", PCI_CLASS_SYSTEM, |
558 | pci_subclass_system, }, | | 602 | pci_subclass_system, }, |
559 | { "input", PCI_CLASS_INPUT, | | 603 | { "input", PCI_CLASS_INPUT, |
560 | pci_subclass_input, }, | | 604 | pci_subclass_input, }, |
561 | { "dock", PCI_CLASS_DOCK, | | 605 | { "dock", PCI_CLASS_DOCK, |
562 | pci_subclass_dock, }, | | 606 | pci_subclass_dock, }, |
563 | { "processor", PCI_CLASS_PROCESSOR, | | 607 | { "processor", PCI_CLASS_PROCESSOR, |
564 | pci_subclass_processor, }, | | 608 | pci_subclass_processor, }, |
565 | { "serial bus", PCI_CLASS_SERIALBUS, | | 609 | { "serial bus", PCI_CLASS_SERIALBUS, |
566 | pci_subclass_serialbus, }, | | 610 | pci_subclass_serialbus, }, |
567 | { "wireless", PCI_CLASS_WIRELESS, | | 611 | { "wireless", PCI_CLASS_WIRELESS, |
568 | pci_subclass_wireless, }, | | 612 | pci_subclass_wireless, }, |
569 | { "I2O", PCI_CLASS_I2O, | | 613 | { "I2O", PCI_CLASS_I2O, |
570 | pci_subclass_i2o, }, | | 614 | pci_subclass_i2o, }, |
571 | { "satellite comm", PCI_CLASS_SATCOM, | | 615 | { "satellite comm", PCI_CLASS_SATCOM, |
572 | pci_subclass_satcom, }, | | 616 | pci_subclass_satcom, }, |
573 | { "crypto", PCI_CLASS_CRYPTO, | | 617 | { "crypto", PCI_CLASS_CRYPTO, |
574 | pci_subclass_crypto, }, | | 618 | pci_subclass_crypto, }, |
575 | { "DASP", PCI_CLASS_DASP, | | 619 | { "DASP", PCI_CLASS_DASP, |
576 | pci_subclass_dasp, }, | | 620 | pci_subclass_dasp, }, |
577 | { "processing accelerators", PCI_CLASS_ACCEL, | | 621 | { "processing accelerators", PCI_CLASS_ACCEL, |
578 | NULL, }, | | 622 | NULL, }, |
579 | { "non-essential instrumentation", PCI_CLASS_INSTRUMENT, | | 623 | { "non-essential instrumentation", PCI_CLASS_INSTRUMENT, |
580 | NULL, }, | | 624 | NULL, }, |
581 | { "undefined", PCI_CLASS_UNDEFINED, | | 625 | { "undefined", PCI_CLASS_UNDEFINED, |
582 | NULL, }, | | 626 | NULL, }, |
583 | { NULL, 0, | | 627 | { NULL, 0, |
584 | NULL, }, | | 628 | NULL, }, |
585 | }; | | 629 | }; |
586 | | | 630 | |
587 | DEV_VERBOSE_DEFINE(pci); | | 631 | DEV_VERBOSE_DEFINE(pci); |
588 | | | 632 | |
589 | /* | | 633 | /* |
590 | * Append a formatted string to dest without writing more than len | | 634 | * Append a formatted string to dest without writing more than len |
591 | * characters (including the trailing NUL character). dest and len | | 635 | * characters (including the trailing NUL character). dest and len |
592 | * are updated for use in subsequent calls to snappendf(). | | 636 | * are updated for use in subsequent calls to snappendf(). |
593 | * | | 637 | * |
594 | * Returns 0 on success, a negative value if vnsprintf() fails, or | | 638 | * Returns 0 on success, a negative value if vnsprintf() fails, or |
595 | * a positive value if the dest buffer would have overflowed. | | 639 | * a positive value if the dest buffer would have overflowed. |
596 | */ | | 640 | */ |
597 | | | 641 | |
598 | static int __printflike(3, 4) | | 642 | static int __printflike(3, 4) |
599 | snappendf(char **dest, size_t *len, const char * restrict fmt, ...) | | 643 | snappendf(char **dest, size_t *len, const char * restrict fmt, ...) |
600 | { | | 644 | { |
601 | va_list ap; | | 645 | va_list ap; |
602 | int count; | | 646 | int count; |
603 | | | 647 | |
604 | va_start(ap, fmt); | | 648 | va_start(ap, fmt); |
605 | count = vsnprintf(*dest, *len, fmt, ap); | | 649 | count = vsnprintf(*dest, *len, fmt, ap); |
606 | va_end(ap); | | 650 | va_end(ap); |
607 | | | 651 | |
608 | /* Let vsnprintf() errors bubble up to caller */ | | 652 | /* Let vsnprintf() errors bubble up to caller */ |
609 | if (count < 0 || *len == 0) | | 653 | if (count < 0 || *len == 0) |
610 | return count; | | 654 | return count; |
611 | | | 655 | |
612 | /* Handle overflow */ | | 656 | /* Handle overflow */ |
613 | if ((size_t)count >= *len) { | | 657 | if ((size_t)count >= *len) { |
614 | *dest += *len - 1; | | 658 | *dest += *len - 1; |
615 | *len = 1; | | 659 | *len = 1; |
616 | return 1; | | 660 | return 1; |
617 | } | | 661 | } |
618 | | | 662 | |
619 | /* Update dest & len to point at trailing NUL */ | | 663 | /* Update dest & len to point at trailing NUL */ |
620 | *dest += count; | | 664 | *dest += count; |
621 | *len -= count; | | 665 | *len -= count; |
622 | | | 666 | |
623 | return 0; | | 667 | return 0; |
624 | } | | 668 | } |
625 | | | 669 | |
626 | void | | 670 | void |
627 | pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp, | | 671 | pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp, |
628 | size_t l) | | 672 | size_t l) |
629 | { | | 673 | { |
630 | pci_class_t class; | | 674 | pci_class_t class; |
631 | pci_subclass_t subclass; | | 675 | pci_subclass_t subclass; |
632 | pci_interface_t interface; | | 676 | pci_interface_t interface; |
633 | pci_revision_t revision; | | 677 | pci_revision_t revision; |
634 | char vendor[PCI_VENDORSTR_LEN], product[PCI_PRODUCTSTR_LEN]; | | 678 | char vendor[PCI_VENDORSTR_LEN], product[PCI_PRODUCTSTR_LEN]; |
635 | const struct pci_class *classp, *subclassp, *interfacep; | | 679 | const struct pci_class *classp, *subclassp, *interfacep; |
636 | | | 680 | |
637 | class = PCI_CLASS(class_reg); | | 681 | class = PCI_CLASS(class_reg); |
638 | subclass = PCI_SUBCLASS(class_reg); | | 682 | subclass = PCI_SUBCLASS(class_reg); |
639 | interface = PCI_INTERFACE(class_reg); | | 683 | interface = PCI_INTERFACE(class_reg); |
640 | revision = PCI_REVISION(class_reg); | | 684 | revision = PCI_REVISION(class_reg); |
641 | | | 685 | |
642 | pci_findvendor(vendor, sizeof(vendor), PCI_VENDOR(id_reg)); | | 686 | pci_findvendor(vendor, sizeof(vendor), PCI_VENDOR(id_reg)); |
643 | pci_findproduct(product, sizeof(product), PCI_VENDOR(id_reg), | | 687 | pci_findproduct(product, sizeof(product), PCI_VENDOR(id_reg), |
644 | PCI_PRODUCT(id_reg)); | | 688 | PCI_PRODUCT(id_reg)); |
645 | | | 689 | |
646 | classp = pci_classes; | | 690 | classp = pci_classes; |
647 | while (classp->name != NULL) { | | 691 | while (classp->name != NULL) { |
648 | if (class == classp->val) | | 692 | if (class == classp->val) |
649 | break; | | 693 | break; |
650 | classp++; | | 694 | classp++; |
651 | } | | 695 | } |
652 | | | 696 | |
653 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; | | 697 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; |
654 | while (subclassp && subclassp->name != NULL) { | | 698 | while (subclassp && subclassp->name != NULL) { |
655 | if (subclass == subclassp->val) | | 699 | if (subclass == subclassp->val) |
656 | break; | | 700 | break; |
657 | subclassp++; | | 701 | subclassp++; |
658 | } | | 702 | } |
659 | | | 703 | |
660 | interfacep = (subclassp && subclassp->name != NULL) ? | | 704 | interfacep = (subclassp && subclassp->name != NULL) ? |
661 | subclassp->subclasses : NULL; | | 705 | subclassp->subclasses : NULL; |
662 | while (interfacep && interfacep->name != NULL) { | | 706 | while (interfacep && interfacep->name != NULL) { |
663 | if (interface == interfacep->val) | | 707 | if (interface == interfacep->val) |
664 | break; | | 708 | break; |
665 | interfacep++; | | 709 | interfacep++; |
666 | } | | 710 | } |
667 | | | 711 | |
668 | (void)snappendf(&cp, &l, "%s %s", vendor, product); | | 712 | (void)snappendf(&cp, &l, "%s %s", vendor, product); |
669 | if (showclass) { | | 713 | if (showclass) { |
670 | (void)snappendf(&cp, &l, " ("); | | 714 | (void)snappendf(&cp, &l, " ("); |
671 | if (classp->name == NULL) | | 715 | if (classp->name == NULL) |
672 | (void)snappendf(&cp, &l, | | 716 | (void)snappendf(&cp, &l, |
673 | "class 0x%02x, subclass 0x%02x", | | 717 | "class 0x%02x, subclass 0x%02x", |
674 | class, subclass); | | 718 | class, subclass); |
675 | else { | | 719 | else { |
676 | if (subclassp == NULL || subclassp->name == NULL) | | 720 | if (subclassp == NULL || subclassp->name == NULL) |
677 | (void)snappendf(&cp, &l, | | 721 | (void)snappendf(&cp, &l, |
678 | "%s, subclass 0x%02x", | | 722 | "%s, subclass 0x%02x", |
679 | classp->name, subclass); | | 723 | classp->name, subclass); |
680 | else | | 724 | else |
681 | (void)snappendf(&cp, &l, "%s %s", | | 725 | (void)snappendf(&cp, &l, "%s %s", |
682 | subclassp->name, classp->name); | | 726 | subclassp->name, classp->name); |
683 | } | | 727 | } |
684 | if ((interfacep == NULL) || (interfacep->name == NULL)) { | | 728 | if ((interfacep == NULL) || (interfacep->name == NULL)) { |
685 | if (interface != 0) | | 729 | if (interface != 0) |
686 | (void)snappendf(&cp, &l, ", interface 0x%02x", | | 730 | (void)snappendf(&cp, &l, ", interface 0x%02x", |
687 | interface); | | 731 | interface); |
688 | } else if (strncmp(interfacep->name, "", 1) != 0) | | 732 | } else if (strncmp(interfacep->name, "", 1) != 0) |
689 | (void)snappendf(&cp, &l, ", %s", interfacep->name); | | 733 | (void)snappendf(&cp, &l, ", %s", interfacep->name); |
690 | if (revision != 0) | | 734 | if (revision != 0) |
691 | (void)snappendf(&cp, &l, ", revision 0x%02x", revision); | | 735 | (void)snappendf(&cp, &l, ", revision 0x%02x", revision); |
692 | (void)snappendf(&cp, &l, ")"); | | 736 | (void)snappendf(&cp, &l, ")"); |
693 | } | | 737 | } |
694 | } | | 738 | } |
695 | | | 739 | |
696 | #ifdef _KERNEL | | 740 | #ifdef _KERNEL |
697 | void | | 741 | void |
698 | pci_aprint_devinfo_fancy(const struct pci_attach_args *pa, const char *naive, | | 742 | pci_aprint_devinfo_fancy(const struct pci_attach_args *pa, const char *naive, |
699 | const char *known, int addrev) | | 743 | const char *known, int addrev) |
700 | { | | 744 | { |
701 | char devinfo[256]; | | 745 | char devinfo[256]; |
702 | | | 746 | |
703 | if (known) { | | 747 | if (known) { |
704 | aprint_normal(": %s", known); | | 748 | aprint_normal(": %s", known); |
705 | if (addrev) | | 749 | if (addrev) |
706 | aprint_normal(" (rev. 0x%02x)", | | 750 | aprint_normal(" (rev. 0x%02x)", |
707 | PCI_REVISION(pa->pa_class)); | | 751 | PCI_REVISION(pa->pa_class)); |
708 | aprint_normal("\n"); | | 752 | aprint_normal("\n"); |
709 | } else { | | 753 | } else { |
710 | pci_devinfo(pa->pa_id, pa->pa_class, 0, | | 754 | pci_devinfo(pa->pa_id, pa->pa_class, 0, |
711 | devinfo, sizeof(devinfo)); | | 755 | devinfo, sizeof(devinfo)); |
712 | aprint_normal(": %s (rev. 0x%02x)\n", devinfo, | | 756 | aprint_normal(": %s (rev. 0x%02x)\n", devinfo, |
713 | PCI_REVISION(pa->pa_class)); | | 757 | PCI_REVISION(pa->pa_class)); |
714 | } | | 758 | } |
715 | if (naive) | | 759 | if (naive) |
716 | aprint_naive(": %s\n", naive); | | 760 | aprint_naive(": %s\n", naive); |
717 | else | | 761 | else |
718 | aprint_naive("\n"); | | 762 | aprint_naive("\n"); |
719 | } | | 763 | } |
720 | #endif | | 764 | #endif |
721 | | | 765 | |
722 | /* | | 766 | /* |
723 | * Print out most of the PCI configuration registers. Typically used | | 767 | * Print out most of the PCI configuration registers. Typically used |
724 | * in a device attach routine like this: | | 768 | * in a device attach routine like this: |
725 | * | | 769 | * |
726 | * #ifdef MYDEV_DEBUG | | 770 | * #ifdef MYDEV_DEBUG |
727 | * printf("%s: ", device_xname(sc->sc_dev)); | | 771 | * printf("%s: ", device_xname(sc->sc_dev)); |
728 | * pci_conf_print(pa->pa_pc, pa->pa_tag, NULL); | | 772 | * pci_conf_print(pa->pa_pc, pa->pa_tag, NULL); |
729 | * #endif | | 773 | * #endif |
730 | */ | | 774 | */ |
731 | | | 775 | |
732 | #define i2o(i) ((i) * 4) | | 776 | #define i2o(i) ((i) * 4) |
733 | #define o2i(o) ((o) / 4) | | 777 | #define o2i(o) ((o) / 4) |
734 | #define onoff2(str, rval, bit, onstr, offstr) \ | | 778 | #define onoff2(str, rval, bit, onstr, offstr) \ |
735 | /*CONSTCOND*/ \ | | 779 | /*CONSTCOND*/ \ |
736 | printf(" %s: %s\n", (str), ((rval) & (bit)) ? onstr : offstr); | | 780 | printf(" %s: %s\n", (str), ((rval) & (bit)) ? onstr : offstr); |
737 | #define onoff(str, rval, bit) onoff2(str, rval, bit, "on", "off") | | 781 | #define onoff(str, rval, bit) onoff2(str, rval, bit, "on", "off") |
738 | | | 782 | |
739 | static void | | 783 | static void |
740 | pci_conf_print_common( | | 784 | pci_conf_print_common( |
741 | #ifdef _KERNEL | | 785 | #ifdef _KERNEL |
742 | pci_chipset_tag_t pc, pcitag_t tag, | | 786 | pci_chipset_tag_t pc, pcitag_t tag, |
743 | #endif | | 787 | #endif |
744 | const pcireg_t *regs) | | 788 | const pcireg_t *regs) |
745 | { | | 789 | { |
746 | pci_class_t class; | | 790 | pci_class_t class; |
747 | pci_subclass_t subclass; | | 791 | pci_subclass_t subclass; |
748 | pci_interface_t interface; | | 792 | pci_interface_t interface; |
749 | pci_revision_t revision; | | 793 | pci_revision_t revision; |
750 | char vendor[PCI_VENDORSTR_LEN], product[PCI_PRODUCTSTR_LEN]; | | 794 | char vendor[PCI_VENDORSTR_LEN], product[PCI_PRODUCTSTR_LEN]; |
751 | const struct pci_class *classp, *subclassp, *interfacep; | | 795 | const struct pci_class *classp, *subclassp, *interfacep; |
752 | const char *name; | | 796 | const char *name; |
753 | pcireg_t rval; | | 797 | pcireg_t rval; |
754 | unsigned int num; | | 798 | unsigned int num; |
755 | | | 799 | |
756 | rval = regs[o2i(PCI_CLASS_REG)]; | | 800 | rval = regs[o2i(PCI_CLASS_REG)]; |
757 | class = PCI_CLASS(rval); | | 801 | class = PCI_CLASS(rval); |
758 | subclass = PCI_SUBCLASS(rval); | | 802 | subclass = PCI_SUBCLASS(rval); |
759 | interface = PCI_INTERFACE(rval); | | 803 | interface = PCI_INTERFACE(rval); |
760 | revision = PCI_REVISION(rval); | | 804 | revision = PCI_REVISION(rval); |
761 | | | 805 | |
762 | rval = regs[o2i(PCI_ID_REG)]; | | 806 | rval = regs[o2i(PCI_ID_REG)]; |
763 | name = pci_findvendor(vendor, sizeof(vendor), PCI_VENDOR(rval)); | | 807 | name = pci_findvendor(vendor, sizeof(vendor), PCI_VENDOR(rval)); |
764 | if (name) | | 808 | if (name) |
765 | printf(" Vendor Name: %s (0x%04x)\n", name, | | 809 | printf(" Vendor Name: %s (0x%04x)\n", name, |
766 | PCI_VENDOR(rval)); | | 810 | PCI_VENDOR(rval)); |
767 | else | | 811 | else |
768 | printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval)); | | 812 | printf(" Vendor ID: 0x%04x\n", PCI_VENDOR(rval)); |
769 | name = pci_findproduct(product, sizeof(product), PCI_VENDOR(rval), | | 813 | name = pci_findproduct(product, sizeof(product), PCI_VENDOR(rval), |
770 | PCI_PRODUCT(rval)); | | 814 | PCI_PRODUCT(rval)); |
771 | if (name) | | 815 | if (name) |
772 | printf(" Device Name: %s (0x%04x)\n", name, | | 816 | printf(" Device Name: %s (0x%04x)\n", name, |
773 | PCI_PRODUCT(rval)); | | 817 | PCI_PRODUCT(rval)); |
774 | else | | 818 | else |
775 | printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval)); | | 819 | printf(" Device ID: 0x%04x\n", PCI_PRODUCT(rval)); |
776 | | | 820 | |
777 | rval = regs[o2i(PCI_COMMAND_STATUS_REG)]; | | 821 | rval = regs[o2i(PCI_COMMAND_STATUS_REG)]; |
778 | | | 822 | |
779 | printf(" Command register: 0x%04x\n", rval & 0xffff); | | 823 | printf(" Command register: 0x%04x\n", rval & 0xffff); |
780 | onoff("I/O space accesses", rval, PCI_COMMAND_IO_ENABLE); | | 824 | onoff("I/O space accesses", rval, PCI_COMMAND_IO_ENABLE); |
781 | onoff("Memory space accesses", rval, PCI_COMMAND_MEM_ENABLE); | | 825 | onoff("Memory space accesses", rval, PCI_COMMAND_MEM_ENABLE); |
782 | onoff("Bus mastering", rval, PCI_COMMAND_MASTER_ENABLE); | | 826 | onoff("Bus mastering", rval, PCI_COMMAND_MASTER_ENABLE); |
783 | onoff("Special cycles", rval, PCI_COMMAND_SPECIAL_ENABLE); | | 827 | onoff("Special cycles", rval, PCI_COMMAND_SPECIAL_ENABLE); |
784 | onoff("MWI transactions", rval, PCI_COMMAND_INVALIDATE_ENABLE); | | 828 | onoff("MWI transactions", rval, PCI_COMMAND_INVALIDATE_ENABLE); |
785 | onoff("Palette snooping", rval, PCI_COMMAND_PALETTE_ENABLE); | | 829 | onoff("Palette snooping", rval, PCI_COMMAND_PALETTE_ENABLE); |
786 | onoff("Parity error checking", rval, PCI_COMMAND_PARITY_ENABLE); | | 830 | onoff("Parity error checking", rval, PCI_COMMAND_PARITY_ENABLE); |
787 | onoff("Address/data stepping", rval, PCI_COMMAND_STEPPING_ENABLE); | | 831 | onoff("Address/data stepping", rval, PCI_COMMAND_STEPPING_ENABLE); |
788 | onoff("System error (SERR)", rval, PCI_COMMAND_SERR_ENABLE); | | 832 | onoff("System error (SERR)", rval, PCI_COMMAND_SERR_ENABLE); |
789 | onoff("Fast back-to-back transactions", rval, | | 833 | onoff("Fast back-to-back transactions", rval, |
790 | PCI_COMMAND_BACKTOBACK_ENABLE); | | 834 | PCI_COMMAND_BACKTOBACK_ENABLE); |
791 | onoff("Interrupt disable", rval, PCI_COMMAND_INTERRUPT_DISABLE); | | 835 | onoff("Interrupt disable", rval, PCI_COMMAND_INTERRUPT_DISABLE); |
792 | | | 836 | |
793 | printf(" Status register: 0x%04x\n", (rval >> 16) & 0xffff); | | 837 | printf(" Status register: 0x%04x\n", (rval >> 16) & 0xffff); |
794 | onoff("Immediate Readiness", rval, PCI_STATUS_IMMD_READNESS); | | 838 | onoff("Immediate Readiness", rval, PCI_STATUS_IMMD_READNESS); |
795 | onoff2("Interrupt status", rval, PCI_STATUS_INT_STATUS, "active", | | 839 | onoff2("Interrupt status", rval, PCI_STATUS_INT_STATUS, "active", |
796 | "inactive"); | | 840 | "inactive"); |
797 | onoff("Capability List support", rval, PCI_STATUS_CAPLIST_SUPPORT); | | 841 | onoff("Capability List support", rval, PCI_STATUS_CAPLIST_SUPPORT); |
798 | onoff("66 MHz capable", rval, PCI_STATUS_66MHZ_SUPPORT); | | 842 | onoff("66 MHz capable", rval, PCI_STATUS_66MHZ_SUPPORT); |
799 | onoff("User Definable Features (UDF) support", rval, | | 843 | onoff("User Definable Features (UDF) support", rval, |
800 | PCI_STATUS_UDF_SUPPORT); | | 844 | PCI_STATUS_UDF_SUPPORT); |
801 | onoff("Fast back-to-back capable", rval, | | 845 | onoff("Fast back-to-back capable", rval, |
802 | PCI_STATUS_BACKTOBACK_SUPPORT); | | 846 | PCI_STATUS_BACKTOBACK_SUPPORT); |
803 | onoff("Data parity error detected", rval, PCI_STATUS_PARITY_ERROR); | | 847 | onoff("Data parity error detected", rval, PCI_STATUS_PARITY_ERROR); |
804 | | | 848 | |
805 | printf(" DEVSEL timing: "); | | 849 | printf(" DEVSEL timing: "); |
806 | switch (rval & PCI_STATUS_DEVSEL_MASK) { | | 850 | switch (rval & PCI_STATUS_DEVSEL_MASK) { |
807 | case PCI_STATUS_DEVSEL_FAST: | | 851 | case PCI_STATUS_DEVSEL_FAST: |
808 | printf("fast"); | | 852 | printf("fast"); |
809 | break; | | 853 | break; |
810 | case PCI_STATUS_DEVSEL_MEDIUM: | | 854 | case PCI_STATUS_DEVSEL_MEDIUM: |
811 | printf("medium"); | | 855 | printf("medium"); |
812 | break; | | 856 | break; |
813 | case PCI_STATUS_DEVSEL_SLOW: | | 857 | case PCI_STATUS_DEVSEL_SLOW: |
814 | printf("slow"); | | 858 | printf("slow"); |
815 | break; | | 859 | break; |
816 | default: | | 860 | default: |
817 | printf("unknown/reserved"); /* XXX */ | | 861 | printf("unknown/reserved"); /* XXX */ |
818 | break; | | 862 | break; |
819 | } | | 863 | } |
820 | printf(" (0x%x)\n", PCIREG_SHIFTOUT(rval, PCI_STATUS_DEVSEL_MASK)); | | 864 | printf(" (0x%x)\n", PCIREG_SHIFTOUT(rval, PCI_STATUS_DEVSEL_MASK)); |
821 | | | 865 | |
822 | onoff("Slave signaled Target Abort", rval, | | 866 | onoff("Slave signaled Target Abort", rval, |
823 | PCI_STATUS_TARGET_TARGET_ABORT); | | 867 | PCI_STATUS_TARGET_TARGET_ABORT); |
824 | onoff("Master received Target Abort", rval, | | 868 | onoff("Master received Target Abort", rval, |
825 | PCI_STATUS_MASTER_TARGET_ABORT); | | 869 | PCI_STATUS_MASTER_TARGET_ABORT); |
826 | onoff("Master received Master Abort", rval, PCI_STATUS_MASTER_ABORT); | | 870 | onoff("Master received Master Abort", rval, PCI_STATUS_MASTER_ABORT); |
827 | onoff("Asserted System Error (SERR)", rval, PCI_STATUS_SPECIAL_ERROR); | | 871 | onoff("Asserted System Error (SERR)", rval, PCI_STATUS_SPECIAL_ERROR); |
828 | onoff("Parity error detected", rval, PCI_STATUS_PARITY_DETECT); | | 872 | onoff("Parity error detected", rval, PCI_STATUS_PARITY_DETECT); |
829 | | | 873 | |
830 | rval = regs[o2i(PCI_CLASS_REG)]; | | 874 | rval = regs[o2i(PCI_CLASS_REG)]; |
831 | for (classp = pci_classes; classp->name != NULL; classp++) { | | 875 | for (classp = pci_classes; classp->name != NULL; classp++) { |
832 | if (class == classp->val) | | 876 | if (class == classp->val) |
833 | break; | | 877 | break; |
834 | } | | 878 | } |
835 | | | 879 | |
836 | /* | | 880 | /* |
837 | * ECN: Change Root Complex Event Collector Class Code | | 881 | * ECN: Change Root Complex Event Collector Class Code |
838 | * Old RCEC has subclass 0x06. It's the same as IOMMU. Read the type | | 882 | * Old RCEC has subclass 0x06. It's the same as IOMMU. Read the type |
839 | * in PCIe extend capability to know whether it's RCEC or IOMMU. | | 883 | * in PCIe extend capability to know whether it's RCEC or IOMMU. |
840 | */ | | 884 | */ |
841 | if ((class == PCI_CLASS_SYSTEM) | | 885 | if ((class == PCI_CLASS_SYSTEM) |
842 | && (subclass == PCI_SUBCLASS_SYSTEM_IOMMU)) { | | 886 | && (subclass == PCI_SUBCLASS_SYSTEM_IOMMU)) { |
843 | int pcie_capoff; | | 887 | int pcie_capoff; |
844 | pcireg_t reg; | | 888 | pcireg_t reg; |
845 | | | 889 | |
846 | if (pci_conf_find_cap(regs, PCI_CAP_PCIEXPRESS, &pcie_capoff)) { | | 890 | if (pci_conf_find_cap(regs, PCI_CAP_PCIEXPRESS, &pcie_capoff)) { |
847 | reg = regs[o2i(pcie_capoff + PCIE_XCAP)]; | | 891 | reg = regs[o2i(pcie_capoff + PCIE_XCAP)]; |
848 | if (PCIE_XCAP_TYPE(reg) == PCIE_XCAP_TYPE_ROOT_EVNTC) | | 892 | if (PCIE_XCAP_TYPE(reg) == PCIE_XCAP_TYPE_ROOT_EVNTC) |
849 | subclass = PCI_SUBCLASS_SYSTEM_RCEC; | | 893 | subclass = PCI_SUBCLASS_SYSTEM_RCEC; |
850 | } | | 894 | } |
851 | } | | 895 | } |
852 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; | | 896 | subclassp = (classp->name != NULL) ? classp->subclasses : NULL; |
853 | while (subclassp && subclassp->name != NULL) { | | 897 | while (subclassp && subclassp->name != NULL) { |
854 | if (subclass == subclassp->val) | | 898 | if (subclass == subclassp->val) |
855 | break; | | 899 | break; |
856 | subclassp++; | | 900 | subclassp++; |
857 | } | | 901 | } |
858 | | | 902 | |
859 | interfacep = (subclassp && subclassp->name != NULL) ? | | 903 | interfacep = (subclassp && subclassp->name != NULL) ? |
860 | subclassp->subclasses : NULL; | | 904 | subclassp->subclasses : NULL; |
861 | while (interfacep && interfacep->name != NULL) { | | 905 | while (interfacep && interfacep->name != NULL) { |
862 | if (interface == interfacep->val) | | 906 | if (interface == interfacep->val) |
863 | break; | | 907 | break; |
864 | interfacep++; | | 908 | interfacep++; |
865 | } | | 909 | } |
866 | | | 910 | |
867 | if (classp->name != NULL) | | 911 | if (classp->name != NULL) |
868 | printf(" Class Name: %s (0x%02x)\n", classp->name, class); | | 912 | printf(" Class Name: %s (0x%02x)\n", classp->name, class); |
869 | else | | 913 | else |
870 | printf(" Class ID: 0x%02x\n", class); | | 914 | printf(" Class ID: 0x%02x\n", class); |
871 | if (subclassp != NULL && subclassp->name != NULL) | | 915 | if (subclassp != NULL && subclassp->name != NULL) |
872 | printf(" Subclass Name: %s (0x%02x)\n", | | 916 | printf(" Subclass Name: %s (0x%02x)\n", |
873 | subclassp->name, PCI_SUBCLASS(rval)); | | 917 | subclassp->name, PCI_SUBCLASS(rval)); |
874 | else | | 918 | else |
875 | printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval)); | | 919 | printf(" Subclass ID: 0x%02x\n", PCI_SUBCLASS(rval)); |
876 | if ((interfacep != NULL) && (interfacep->name != NULL) | | 920 | if ((interfacep != NULL) && (interfacep->name != NULL) |
877 | && (strncmp(interfacep->name, "", 1) != 0)) | | 921 | && (strncmp(interfacep->name, "", 1) != 0)) |
878 | printf(" Interface Name: %s (0x%02x)\n", | | 922 | printf(" Interface Name: %s (0x%02x)\n", |
879 | interfacep->name, interface); | | 923 | interfacep->name, interface); |
880 | else | | 924 | else |
881 | printf(" Interface: 0x%02x\n", interface); | | 925 | printf(" Interface: 0x%02x\n", interface); |
882 | printf(" Revision ID: 0x%02x\n", revision); | | 926 | printf(" Revision ID: 0x%02x\n", revision); |
883 | | | 927 | |
884 | rval = regs[o2i(PCI_BHLC_REG)]; | | 928 | rval = regs[o2i(PCI_BHLC_REG)]; |
885 | printf(" BIST: 0x%02x\n", PCI_BIST(rval)); | | 929 | printf(" BIST: 0x%02x\n", PCI_BIST(rval)); |
886 | printf(" Header Type: 0x%02x%s (0x%02x)\n", PCI_HDRTYPE_TYPE(rval), | | 930 | printf(" Header Type: 0x%02x%s (0x%02x)\n", PCI_HDRTYPE_TYPE(rval), |
887 | PCI_HDRTYPE_MULTIFN(rval) ? "+multifunction" : "", | | 931 | PCI_HDRTYPE_MULTIFN(rval) ? "+multifunction" : "", |
888 | PCI_HDRTYPE(rval)); | | 932 | PCI_HDRTYPE(rval)); |
889 | printf(" Latency Timer: 0x%02x\n", PCI_LATTIMER(rval)); | | 933 | printf(" Latency Timer: 0x%02x\n", PCI_LATTIMER(rval)); |
890 | num = PCI_CACHELINE(rval); | | 934 | num = PCI_CACHELINE(rval); |
891 | printf(" Cache Line Size: %ubytes (0x%02x)\n", num * 4, num); | | 935 | printf(" Cache Line Size: %ubytes (0x%02x)\n", num * 4, num); |
892 | } | | 936 | } |
893 | | | 937 | |
894 | static int | | 938 | static int |
895 | pci_conf_print_bar( | | 939 | pci_conf_print_bar( |
896 | #ifdef _KERNEL | | 940 | #ifdef _KERNEL |
897 | pci_chipset_tag_t pc, pcitag_t tag, | | 941 | pci_chipset_tag_t pc, pcitag_t tag, |
898 | #endif | | 942 | #endif |
899 | const pcireg_t *regs, int reg, const char *name) | | 943 | const pcireg_t *regs, int reg, const char *name) |
900 | { | | 944 | { |
901 | int width; | | 945 | int width; |
902 | pcireg_t rval, rval64h; | | 946 | pcireg_t rval, rval64h; |
903 | bool ioen, memen; | | 947 | bool ioen, memen; |
904 | #ifdef _KERNEL | | 948 | #ifdef _KERNEL |
905 | pcireg_t mask, mask64h = 0; | | 949 | pcireg_t mask, mask64h = 0; |
906 | #endif | | 950 | #endif |
907 | | | 951 | |
908 | rval = regs[o2i(PCI_COMMAND_STATUS_REG)]; | | 952 | rval = regs[o2i(PCI_COMMAND_STATUS_REG)]; |
909 | ioen = rval & PCI_COMMAND_IO_ENABLE; | | 953 | ioen = rval & PCI_COMMAND_IO_ENABLE; |
910 | memen = rval & PCI_COMMAND_MEM_ENABLE; | | 954 | memen = rval & PCI_COMMAND_MEM_ENABLE; |
911 | | | 955 | |
912 | width = 4; | | 956 | width = 4; |
913 | /* | | 957 | /* |
914 | * Section 6.2.5.1, `Address Maps', tells us that: | | 958 | * Section 6.2.5.1, `Address Maps', tells us that: |
915 | * | | 959 | * |
916 | * 1) The builtin software should have already mapped the | | 960 | * 1) The builtin software should have already mapped the |
917 | * device in a reasonable way. | | 961 | * device in a reasonable way. |
918 | * | | 962 | * |
919 | * 2) A device which wants 2^n bytes of memory will hardwire | | 963 | * 2) A device which wants 2^n bytes of memory will hardwire |
920 | * the bottom n bits of the address to 0. As recommended, | | 964 | * the bottom n bits of the address to 0. As recommended, |
921 | * we write all 1s and see what we get back. | | 965 | * we write all 1s and see what we get back. |
922 | */ | | 966 | */ |
923 | | | 967 | |
924 | rval = regs[o2i(reg)]; | | 968 | rval = regs[o2i(reg)]; |
925 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && | | 969 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && |
926 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { | | 970 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { |
927 | rval64h = regs[o2i(reg + 4)]; | | 971 | rval64h = regs[o2i(reg + 4)]; |
928 | width = 8; | | 972 | width = 8; |
929 | } else | | 973 | } else |
930 | rval64h = 0; | | 974 | rval64h = 0; |
931 | | | 975 | |
932 | #ifdef _KERNEL | | 976 | #ifdef _KERNEL |
933 | if (rval != 0 && memen) { | | 977 | if (rval != 0 && memen) { |
934 | int s; | | 978 | int s; |
935 | | | 979 | |
936 | /* | | 980 | /* |
937 | * The following sequence seems to make some devices | | 981 | * The following sequence seems to make some devices |
938 | * (e.g. host bus bridges, which don't normally | | 982 | * (e.g. host bus bridges, which don't normally |
939 | * have their space mapped) very unhappy, to | | 983 | * have their space mapped) very unhappy, to |
940 | * the point of crashing the system. | | 984 | * the point of crashing the system. |
941 | * | | 985 | * |
942 | * Therefore, if the mapping register is zero to | | 986 | * Therefore, if the mapping register is zero to |
943 | * start out with, don't bother trying. | | 987 | * start out with, don't bother trying. |
944 | */ | | 988 | */ |
945 | s = splhigh(); | | 989 | s = splhigh(); |
946 | pci_conf_write(pc, tag, reg, 0xffffffff); | | 990 | pci_conf_write(pc, tag, reg, 0xffffffff); |
947 | mask = pci_conf_read(pc, tag, reg); | | 991 | mask = pci_conf_read(pc, tag, reg); |
948 | pci_conf_write(pc, tag, reg, rval); | | 992 | pci_conf_write(pc, tag, reg, rval); |
949 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && | | 993 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM && |
950 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { | | 994 | PCI_MAPREG_MEM_TYPE(rval) == PCI_MAPREG_MEM_TYPE_64BIT) { |
951 | pci_conf_write(pc, tag, reg + 4, 0xffffffff); | | 995 | pci_conf_write(pc, tag, reg + 4, 0xffffffff); |
952 | mask64h = pci_conf_read(pc, tag, reg + 4); | | 996 | mask64h = pci_conf_read(pc, tag, reg + 4); |
953 | pci_conf_write(pc, tag, reg + 4, rval64h); | | 997 | pci_conf_write(pc, tag, reg + 4, rval64h); |
954 | } | | 998 | } |
955 | splx(s); | | 999 | splx(s); |
956 | } else | | 1000 | } else |
957 | mask = mask64h = 0; | | 1001 | mask = mask64h = 0; |
958 | #endif /* _KERNEL */ | | 1002 | #endif /* _KERNEL */ |
959 | | | 1003 | |
960 | printf(" Base address register at 0x%02x", reg); | | 1004 | printf(" Base address register at 0x%02x", reg); |
961 | if (name) | | 1005 | if (name) |
962 | printf(" (%s)", name); | | 1006 | printf(" (%s)", name); |
963 | printf("\n "); | | 1007 | printf("\n "); |
964 | if (rval == 0) { | | 1008 | if (rval == 0) { |
965 | printf("not implemented\n"); | | 1009 | printf("not implemented\n"); |
966 | return width; | | 1010 | return width; |
967 | } | | 1011 | } |
968 | printf("type: "); | | 1012 | printf("type: "); |
969 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM) { | | 1013 | if (PCI_MAPREG_TYPE(rval) == PCI_MAPREG_TYPE_MEM) { |
970 | const char *type, *prefetch; | | 1014 | const char *type, *prefetch; |
971 | | | 1015 | |
972 | switch (PCI_MAPREG_MEM_TYPE(rval)) { | | 1016 | switch (PCI_MAPREG_MEM_TYPE(rval)) { |
973 | case PCI_MAPREG_MEM_TYPE_32BIT: | | 1017 | case PCI_MAPREG_MEM_TYPE_32BIT: |
974 | type = "32-bit"; | | 1018 | type = "32-bit"; |
975 | break; | | 1019 | break; |
976 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: | | 1020 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: |
977 | type = "32-bit-1M"; | | 1021 | type = "32-bit-1M"; |
978 | break; | | 1022 | break; |
979 | case PCI_MAPREG_MEM_TYPE_64BIT: | | 1023 | case PCI_MAPREG_MEM_TYPE_64BIT: |
980 | type = "64-bit"; | | 1024 | type = "64-bit"; |
981 | break; | | 1025 | break; |
982 | default: | | 1026 | default: |
983 | type = "unknown (XXX)"; | | 1027 | type = "unknown (XXX)"; |
984 | break; | | 1028 | break; |
985 | } | | 1029 | } |
986 | if (PCI_MAPREG_MEM_PREFETCHABLE(rval)) | | 1030 | if (PCI_MAPREG_MEM_PREFETCHABLE(rval)) |
987 | prefetch = ""; | | 1031 | prefetch = ""; |
988 | else | | 1032 | else |
989 | prefetch = "non"; | | 1033 | prefetch = "non"; |
990 | printf("%s %sprefetchable memory\n", type, prefetch); | | 1034 | printf("%s %sprefetchable memory\n", type, prefetch); |
991 | switch (PCI_MAPREG_MEM_TYPE(rval)) { | | 1035 | switch (PCI_MAPREG_MEM_TYPE(rval)) { |
992 | case PCI_MAPREG_MEM_TYPE_64BIT: | | 1036 | case PCI_MAPREG_MEM_TYPE_64BIT: |
993 | printf(" base: 0x%016llx", | | 1037 | printf(" base: 0x%016llx", |
994 | PCI_MAPREG_MEM64_ADDR( | | 1038 | PCI_MAPREG_MEM64_ADDR( |
995 | ((((long long) rval64h) << 32) | rval))); | | 1039 | ((((long long) rval64h) << 32) | rval))); |
996 | if (!memen) | | 1040 | if (!memen) |
997 | printf(", disabled"); | | 1041 | printf(", disabled"); |
998 | printf("\n"); | | 1042 | printf("\n"); |
999 | #ifdef _KERNEL | | 1043 | #ifdef _KERNEL |
1000 | printf(" size: 0x%016llx\n", | | 1044 | printf(" size: 0x%016llx\n", |
1001 | PCI_MAPREG_MEM64_SIZE( | | 1045 | PCI_MAPREG_MEM64_SIZE( |
1002 | ((((long long) mask64h) << 32) | mask))); | | 1046 | ((((long long) mask64h) << 32) | mask))); |
1003 | #endif | | 1047 | #endif |
1004 | break; | | 1048 | break; |
1005 | case PCI_MAPREG_MEM_TYPE_32BIT: | | 1049 | case PCI_MAPREG_MEM_TYPE_32BIT: |
1006 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: | | 1050 | case PCI_MAPREG_MEM_TYPE_32BIT_1M: |
1007 | default: | | 1051 | default: |
1008 | printf(" base: 0x%08x", | | 1052 | printf(" base: 0x%08x", |
1009 | PCI_MAPREG_MEM_ADDR(rval)); | | 1053 | PCI_MAPREG_MEM_ADDR(rval)); |
1010 | if (!memen) | | 1054 | if (!memen) |
1011 | printf(", disabled"); | | 1055 | printf(", disabled"); |
1012 | printf("\n"); | | 1056 | printf("\n"); |
1013 | #ifdef _KERNEL | | 1057 | #ifdef _KERNEL |
1014 | printf(" size: 0x%08x\n", | | 1058 | printf(" size: 0x%08x\n", |
1015 | PCI_MAPREG_MEM_SIZE(mask)); | | 1059 | PCI_MAPREG_MEM_SIZE(mask)); |
1016 | #endif | | 1060 | #endif |
1017 | break; | | 1061 | break; |
1018 | } | | 1062 | } |
1019 | } else { | | 1063 | } else { |
1020 | #ifdef _KERNEL | | 1064 | #ifdef _KERNEL |
1021 | if (ioen) | | 1065 | if (ioen) |
1022 | printf("%d-bit ", mask & ~0x0000ffff ? 32 : 16); | | 1066 | printf("%d-bit ", mask & ~0x0000ffff ? 32 : 16); |
1023 | #endif | | 1067 | #endif |
1024 | printf("I/O\n"); | | 1068 | printf("I/O\n"); |
1025 | printf(" base: 0x%08x", PCI_MAPREG_IO_ADDR(rval)); | | 1069 | printf(" base: 0x%08x", PCI_MAPREG_IO_ADDR(rval)); |
1026 | if (!ioen) | | 1070 | if (!ioen) |
1027 | printf(", disabled"); | | 1071 | printf(", disabled"); |
1028 | printf("\n"); | | 1072 | printf("\n"); |
1029 | #ifdef _KERNEL | | 1073 | #ifdef _KERNEL |
1030 | printf(" size: 0x%08x\n", PCI_MAPREG_IO_SIZE(mask)); | | 1074 | printf(" size: 0x%08x\n", PCI_MAPREG_IO_SIZE(mask)); |
1031 | #endif | | 1075 | #endif |
1032 | } | | 1076 | } |
1033 | | | 1077 | |
1034 | return width; | | 1078 | return width; |
1035 | } | | 1079 | } |
1036 | | | 1080 | |
1037 | static void | | 1081 | static void |
1038 | pci_conf_print_regs(const pcireg_t *regs, int first, int pastlast) | | 1082 | pci_conf_print_regs(const pcireg_t *regs, int first, int pastlast) |
1039 | { | | 1083 | { |
1040 | int off, needaddr, neednl; | | 1084 | int off, needaddr, neednl; |
1041 | | | 1085 | |
1042 | needaddr = 1; | | 1086 | needaddr = 1; |
1043 | neednl = 0; | | 1087 | neednl = 0; |
1044 | for (off = first; off < pastlast; off += 4) { | | 1088 | for (off = first; off < pastlast; off += 4) { |
1045 | if ((off % 16) == 0 || needaddr) { | | 1089 | if ((off % 16) == 0 || needaddr) { |
1046 | printf(" 0x%02x:", off); | | 1090 | printf(" 0x%02x:", off); |
1047 | needaddr = 0; | | 1091 | needaddr = 0; |
1048 | } | | 1092 | } |
1049 | printf(" 0x%08x", regs[o2i(off)]); | | 1093 | printf(" 0x%08x", regs[o2i(off)]); |
1050 | neednl = 1; | | 1094 | neednl = 1; |
1051 | if ((off % 16) == 12) { | | 1095 | if ((off % 16) == 12) { |
1052 | printf("\n"); | | 1096 | printf("\n"); |
1053 | neednl = 0; | | 1097 | neednl = 0; |
1054 | } | | 1098 | } |
1055 | } | | 1099 | } |
1056 | if (neednl) | | 1100 | if (neednl) |
1057 | printf("\n"); | | 1101 | printf("\n"); |
1058 | } | | 1102 | } |
1059 | | | 1103 | |
1060 | static const char * | | 1104 | static const char * |
1061 | pci_conf_print_agp_calcycle(uint8_t cal) | | 1105 | pci_conf_print_agp_calcycle(uint8_t cal) |
1062 | { | | 1106 | { |
1063 | | | 1107 | |
1064 | switch (cal) { | | 1108 | switch (cal) { |
1065 | case 0x0: | | 1109 | case 0x0: |
1066 | return "4ms"; | | 1110 | return "4ms"; |
1067 | case 0x1: | | 1111 | case 0x1: |
1068 | return "16ms"; | | 1112 | return "16ms"; |
1069 | case 0x2: | | 1113 | case 0x2: |
1070 | return "64ms"; | | 1114 | return "64ms"; |
1071 | case 0x3: | | 1115 | case 0x3: |
1072 | return "256ms"; | | 1116 | return "256ms"; |
1073 | case 0x7: | | 1117 | case 0x7: |
1074 | return "Calibration Cycle Not Needed"; | | 1118 | return "Calibration Cycle Not Needed"; |
1075 | default: | | 1119 | default: |
1076 | return "(reserved)"; | | 1120 | return "(reserved)"; |
1077 | } | | 1121 | } |
1078 | } | | 1122 | } |
1079 | | | 1123 | |
1080 | static void | | 1124 | static void |
1081 | pci_conf_print_agp_datarate(pcireg_t reg, bool isagp3) | | 1125 | pci_conf_print_agp_datarate(pcireg_t reg, bool isagp3) |
1082 | { | | 1126 | { |
1083 | if (isagp3) { | | 1127 | if (isagp3) { |
1084 | /* AGP 3.0 */ | | 1128 | /* AGP 3.0 */ |
1085 | if (reg & AGP_MODE_V3_RATE_4x) | | 1129 | if (reg & AGP_MODE_V3_RATE_4x) |