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