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