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