1.\" Copyright (c) 1997 2.\" Stefan Esser <se@FreeBSD.org>. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.Dd March 10, 2026 27.Dt PCICONF 8 28.Os 29.Sh NAME 30.Nm pciconf 31.Nd diagnostic utility for the PCI bus 32.Sh SYNOPSIS 33.Nm 34.Fl l Oo Fl BbceVv Oc Op Ar device 35.Nm 36.Fl t Oo Fl v Oc 37.Nm 38.Fl a Ar device 39.Nm 40.Fl r Oo Fl b | h Oc Ar device addr Ns Op : Ns Ar addr2 41.Nm 42.Fl w Oo Fl b | h Oc Ar device addr value 43.Nm 44.Fl D Oo Fl b | h | x Oc Ar device bar Op Ar start Op Ns Ar count 45.Sh DESCRIPTION 46The 47.Nm 48utility provides a command line interface to functionality provided by the 49.Xr pci 4 50.Xr ioctl 2 51interface. 52As such, some of the functions are only available to users with write 53access to 54.Pa /dev/pci , 55normally only the super-user. 56.Pp 57A 58.Ar device 59can be identified either by a device name if the device is 60attached to a driver or by a selector. 61Selectors identify a PCI device by its address in PCI config space and 62can take one of the following forms: 63.Pp 64.Bl -bullet -offset indent -compact 65.It 66.Li pci Ns Va domain Ns \&: Ns Va bus Ns \&: Ns Va device Ns \&: \ 67Ns Va function Ns 68.It 69.Li pci Ns Va bus Ns \&: Ns Va device Ns \&: Ns Va function Ns 70.It 71.Li pci Ns Va bus Ns \&: Ns Va device Ns 72.El 73.Pp 74In the case of an abridged form, omitted selector components are assumed to be 0. 75An optional leading device name followed by @ and an optional final colon 76will be ignored; this is so that the first column in the output of 77.Nm 78.Fl l 79can be used without modification. 80All numbers are base 10. 81.Ss List Mode 82With the 83.Fl l 84option, 85.Nm 86lists PCI devices in the following format: 87.Bd -literal 88foo0@pci0:0:4:0: class=0x010000 rev=0x01 hdr=0x00 vendor=0x1000 device=0x000f \ 89subvendor=0x0000 subdevice=0x0000 90bar0@pci0:0:5:0: class=0x000100 rev=0x00 hdr=0x00 vendor=0x88c1 device=0x5333 \ 91subvendor=0x0000 subdevice=0x0000 92none0@pci0:0:6:0: class=0x020000 rev=0x00 hdr=0x00 vendor=0x10ec device=0x8029 \ 93subvendor=0x0000 subdevice=0x0000 94.Ed 95.Pp 96The first column gives the 97driver name, unit number, and selector. 98If there is no driver attached to the 99.Tn PCI 100device in question, the driver name will be 101.Dq none . 102Unit numbers for detached devices start at zero and are incremented for 103each detached device that is encountered. 104The selector 105is in a form which may directly be used for the other forms of the command. 106The second column is the class code, with the class byte printed as two 107hex digits, followed by the sub-class and the interface bytes. 108The third column prints the device's revision. 109The fourth column describes the header type. 110.Pp 111Currently assigned header types include 0 for standard devices, 1121 for 113.Tn PCI 114to 115.Tn PCI 116bridges, and 2 for 117.Tn PCI 118to 119.Tn CardBus 120bridges. 121If the most significant bit 122of the header type register is set for 123function 0 of a 124.Tn PCI 125device, it is a 126.Em multi-function 127device, which contains several (similar or independent) functions on 128one chip. 129.Pp 130The sixth and seventh columns contain the vendor ID and the device ID of the 131device. 132The eigth and ninth columns contain subvendor and subdevice IDs, introduced 133in revision 2.1 of the 134.Tn PCI 135standard. 136Note that they will be 0 for older cards. 137.Pp 138Adding a second 139.Fl l 140option causes output to be in a compact columnar format, suitable for 14180 column output: 142.Bd -literal 143drv selector class rev hdr vendor device subven subdev 144foo0@pci0:0:4:0: 010000 01 00 1000 000f 0000 0000 145bar0@pci0:0:5:0: 000100 00 00 88c1 5333 0000 0000 146none0@pci0:0:6:0: 020000 00 00 10ec 8029 0000 0000 147.Ed 148.Pp 149All fields retain the same definition as with the non-compact form. 150.Pp 151If the 152.Fl B 153option is supplied, 154.Nm 155will list additional information for 156.Tn PCI 157to 158.Tn PCI 159and 160.Tn PCI 161to 162.Tn CardBus 163bridges, 164specifically the resource ranges decoded by the bridge for use by devices 165behind the bridge. 166Each bridge lists a range of bus numbers handled by the bridge and its 167downstream devices. 168Memory and I/O port decoding windows are enumerated via a line in the 169following format: 170.Bd -literal 171 window[1c] = type I/O Port, range 16, addr 0x5000-0x8fff, enabled 172.Ed 173.Pp 174The first value after the 175.Dq Li window 176prefix in the square brackets is the offset of the decoding window in 177config space in hexadecimal. 178The type of a window is one of 179.Dq Memory , 180.Dq Prefetchable Memory , 181or 182.Dq I/O Port . 183The range indicates the binary log of the maximum address the window decodes. 184The address field indicates the start and end addresses of the decoded range. 185Finally, the last flag indicates if the window is enabled or disabled. 186.Pp 187If the 188.Fl b 189option is supplied, 190.Nm 191will list any base address registers 192.Pq BARs 193that are assigned resources for each device. 194Each BAR will be enumerated via a line in the following format: 195.Bd -literal 196 bar [10] = type Memory, range 32, base 0xda060000, size 131072, enabled 197.Ed 198.Pp 199The first value after the 200.Dq Li bar 201prefix in the square brackets is the offset of the BAR in config space in 202hexadecimal. 203The type of a BAR is one of 204.Dq Memory , 205.Dq Prefetchable Memory , 206or 207.Dq I/O Port . 208The range indicates the binary log of the maximum address the BAR decodes. 209The base and size indicate the start and length of the BAR's address window, 210respectively. 211Finally, the last flag indicates if the BAR is enabled or disabled. 212.Pp 213If the 214.Fl c 215option is supplied, 216.Nm 217will list any capabilities supported by each device. 218A second invocation of 219.Fl c 220will print additional data for certain capabilities. 221Each capability is enumerated via a line in the following format: 222.Bd -literal 223 cap 10[40] = PCI-Express 1 root port 224.Ed 225.Pp 226The first value after the 227.Dq Li cap 228prefix is the capability ID in hexadecimal. 229The second value in the square brackets is the offset of the capability 230in config space in hexadecimal. 231The format of the text after the equals sign is capability-specific. 232.Pp 233Each extended capability is enumerated via a line in a similar format: 234.Bd -literal 235ecap 0002[100] = VC 1 max VC0 236.Ed 237.Pp 238The first value after the 239.Dq Li ecap 240prefix is the extended capability ID in hexadecimal. 241The second value in the square brackets is the offset of the extended 242capability in config space in hexadecimal. 243The format of the text after the equals sign is capability-specific. 244.Pp 245If the 246.Fl e 247option is supplied, 248.Nm 249will list any errors reported for this device in standard PCI error registers. 250Errors are checked for in the PCI status register, 251the PCI-express device status register, 252and the Advanced Error Reporting status registers. 253.Pp 254If the 255.Fl v 256option is supplied, 257.Nm 258will attempt to load the vendor/device information database, and print 259vendor, device, class and subclass identification strings for each device. 260.Pp 261If the 262.Fl V 263option is supplied, 264.Nm 265will list any vital product data 266.Pq VPD 267provided by each device. 268Each VPD keyword is enumerated via a line in the following format: 269.Bd -literal 270 VPD ro PN = '110114640C0 ' 271.Ed 272.Pp 273The first string after the 274.Dq Li VPD 275prefix indicates if the keyword is read-only 276.Dq ro 277or read-write 278.Dq rw . 279The second string provides the keyword name. 280The text after the equals sign lists the value of the keyword which is 281usually an ASCII string. 282.Pp 283If the optional 284.Ar device 285argument is given with the 286.Fl l 287flag, 288.Nm 289will only list details about a single device instead of all devices. 290.Ss Tree Mode 291With the 292.Fl t 293flag, 294.Nm 295lists PCI devices in a tree prefixing each device with indentation text showing 296the sibling and parent/child relationships. 297If the device has an attached driver, the device is identified by the driver 298name and unit number; 299otherwise, the device is identified by a PCI selector. 300.Pp 301Top-level entries in the tree identify top-level PCI buses. 302Each bus is named as a partial PCI selector: 303.Li pci Ns Va domain Ns \&: Ns Va bus Ns . 304.Pp 305If the 306.Fl v 307flag is specified, 308the device name or PCI selector is followed by the device's vendor and device 309strings from the vendor/device information database. 310If an identification string is not found in the database, 311the ID register values are output instead. 312.Ss Device Information Modes 313With the 314.Fl a 315flag, 316.Nm 317determines whether any driver has been assigned to the device 318identified by 319.Ar selector . 320An exit status of zero indicates that the device has a driver; 321non-zero indicates that it does not. 322.Pp 323The 324.Fl r 325option reads a configuration space register at byte offset 326.Ar addr 327of device 328.Ar selector 329and prints out its value in hexadecimal. 330The optional second address 331.Ar addr2 332specifies a range to read. 333The 334.Fl w 335option writes the 336.Ar value 337into a configuration space register at byte offset 338.Ar addr 339of device 340.Ar selector . 341.Pp 342The 343.Fl D 344option request a dump of the specified BAR. 345Dump is performed to the standard output, raw register values 346are written. 347Use 348.Xr hexdump 1 349to convert them to human-readable dump, 350or redirect into a file to save the snapshot of the device state. 351Optionally, the 352.Ar start 353and 354.Ar count 355of the registers dumped can be specified, in multiple of the operation width, 356see next paragraph. 357.Pp 358For read, write, and dump operations, the flags 359.Fl b , 360.Fl h , 361and 362.Fl x 363select the width of the operation; 364.Fl b 365indicates a byte operation, and 366.Fl h 367indicates a halfword (two-byte) operation. 368.Fl x 369indicates a quadword (four-byte) operation. 370The default is to read or 371write a longword (four bytes). 372The quadword mode is only valid for BAR dump. 373.Sh ENVIRONMENT 374PCI vendor and device information is read from 375.Pa /usr/local/share/pciids/pci.ids . 376If that file is not present, it is read from 377.Pa /usr/share/misc/pci_vendors . 378This path can be overridden by setting the environment variable 379.Ev PCICONF_VENDOR_DATABASE . 380.Sh SEE ALSO 381.Xr ioctl 2 , 382.\" .Xr pci 4 , 383.Xr devinfo 8 , 384.Xr kldload 8 385.Sh HISTORY 386The 387.Nm 388utility appeared first in 389.Fx 2.2 . 390The 391.Fl a 392option was added for 393.Tn PCI 394KLD support in 395.Fx 3.0 . 396.Sh AUTHORS 397.An -nosplit 398The 399.Nm 400utility was written by 401.An Stefan Esser 402and 403.An Garrett Wollman . 404.Sh BUGS 405The 406.Fl b 407and 408.Fl h 409options are implemented in 410.Nm , 411but not in the underlying 412.Xr ioctl 2 . 413.Pp 414It might be useful to give non-root users access to the 415.Fl a 416and 417.Fl r 418options. 419But only root will be able to execute a 420.Nm kldload 421to provide the device with a driver KLD, and reading of configuration space 422registers may cause a failure in badly designed 423.Tn PCI 424chips. 425.Pp 426There is currently no way to specify the caching mode for the mapping 427established by the 428.Fl D 429option, 430.Nm 431always uses uncached access. 432This is fine for control register BARs. 433