History log of /freebsd-11-stable/usr.sbin/pciconf/pciconf.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 358362 27-Feb-2020 kib

MFC r358175:
Print out some newly added PCIe extended capabilities and subclasses.


# 331149 18-Mar-2018 eadler

MFC r315190:

Add constants and descriptions for some new PCI class definitions


# 330968 15-Mar-2018 eadler

MFC r327580,r327581:

bits is never null when we call ot. Add an assert to that effect and
remove test for NULL.

Remove dead code (comma is either 0 or 1 for sure, no need to test).
Close /dev/pci when we're done with it.


# 312619 22-Jan-2017 bapt

MFC r311953 (by cem)

pciconf(8): Reallow trailing colon in selectors

Reallow device selectors to have a trailing colon, as documented in the
manual page. This was broken along with some unrelated cleanups in
r295806.

PR: 215979
Reported by: David Boyd <David.Boyd49 at twc.com>
Sponsored by: Dell EMC Isilon


# 308062 28-Oct-2016 mav

MFC r307731: Add names for some DASP devices.


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 295806 19-Feb-2016 se

Fix possible out-of-bounds access detected by Ulrich Spörleins "scan-build".
Some invalid PCI device selectors could cause read access to an initialized
variable next to the array (local loop index variable).

While here, the parser has been made more strict with regard to the syntax
of PCI device selectors as documented in the man-page. E.g. "pci:" used to
be interpreted as "pci0:0".

MFC after: 3 days


# 295769 18-Feb-2016 se

Use __unused instead of casting to void to silence the unused parameter
warning.

Fix the indentation of 2 lines to conform with the style of this file.

Submitted by: jhb


# 295760 18-Feb-2016 se

Make WARNS=6 safe.

Tested with Clang 3.7.1, GCC 4.2.1 and GCC 4.8.5 on amd64.


# 291225 23-Nov-2015 jhb

Add a new -B flag for use with list mode (-l) that lists details about
bridges. Currently this includes information about what resources a
bridge decodes on the upstream side for use by downstream devices including
bus numbers, I/O port resources, and memory resources. Windows and bus
ranges are enumerated for both PCI-PCI bridges and PCI-CardBus bridges.

To simplify the implementation, all enumeration is done by reading the
appropriate config space registers directly rather than querying the
bridge driver in the kernel via new ioctls. This does result in a few
limitations.

First, an unimplemented window in a PCI-PCI bridge cannot be accurately
detected as accurate detection requires writing to the window base
register. That is not safe for pciconf(8). Instead, this assumes that
any window where both the base and limit read as all zeroes is
unimplemented.

Second, the PCI-PCI bridge driver in a tree has a few quirks for
PCI-PCI bridges that use subtractive decoding but do not indicate that
via the progif config register. The list of quirks is duplicated in
pciconf's source.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D4171


# 287522 06-Sep-2015 bapt

Prefer pciids database from ports if present

Given the pciids database on ports is updated more often than the one in base
prefer this version if present, otherwise read the one from base.

MFC after: 1 week
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D3391


# 279466 28-Feb-2015 rstone

Teach pciconf how to dump out SR-IOV capability

Differential Revision: https://reviews.freebsd.org/D1639
Reviewed by: jhb
MFC after: 1 month
Sponsored by: Sandvine Inc.


# 277856 28-Jan-2015 dim

Fix the following clang 3.6.0 warnings in pciconf:

usr.sbin/pciconf/pciconf.c:237:12: error: address of array 'p->pd_name' will
always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
(p->pd_name && *p->pd_name) ? p->pd_name :
~~~^~~~~~~ ~~
usr.sbin/pciconf/pciconf.c:239:12: error: address of array 'p->pd_name' will
always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
(p->pd_name && *p->pd_name) ? (int)p->pd_unit :
~~~^~~~~~~ ~~

The pd_name field of struct pci_conf is an array, so it can never be null.
Remove the unnecessary check.


# 273488 22-Oct-2014 markj

Fix some buglets in the error-handling of getdevice(). In particular, report
an error if the argument to pciconf -a doesn't have a unit number, rather
than triggering an assertion failure.

PR: 194506
Reported by: Anthony Cornehl <accornehl@gmail.com>
Sponsored by: EMC / Isilon Storage Division


# 266468 20-May-2014 mav

Add IOMMU PCI subclass, found on Tyan S8236 motherboard.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 2 weeks


# 260926 20-Jan-2014 jhb

Add support for displaying VPD for PCI devices via pciconf.
- Store the length of each read-only VPD value since not all values are
guaranteed to be ASCII values (though most are).
- Add a new pciio ioctl to fetch VPD for a single PCI device. The values
are returned as a list of variable length records, one for the device
name and each keyword.
- Add a new -V flag to pciconf's list mode which displays VPD data for
each device.

MFC after: 1 week


# 260910 20-Jan-2014 jhb

- Allow PCI devices that are attached to a driver to be identified by their
device name instead of just the selector.
- Accept an optional device argument to -l to restrict the output to only
listing details about a single device. This is mostly useful in
conjunction with other flags like -e or -c to allow a user to query
details about a single device.

MFC after: 1 week


# 246632 10-Feb-2013 neel

Use the entire 64 bits of 'bar.pbi_length' when printing the bar size.

This allows bar sizes greater than or equal to 4GB to be displayed correctly.


# 240739 20-Sep-2012 gavin

The correct generic term for PCIS_STORAGE_NVM is "NVM" not "NVM Express".

Submitted by: jimharris
MFC after: 6 days


# 240699 19-Sep-2012 gavin

Recognise NVM Express devices and pretty-print their name.

MFC after: 1 week


# 236415 01-Jun-2012 jhb

Add a new -e flag to pciconf(8)'s list mode to display PCI error details.
Currently this dumps the status of any error bits in the PCI status register
and PCI-express device status register. It also lists any errors indicated
by version 1 of PCI-express Advanced Error Reporting (AER).

MFC after: 1 week


# 228990 30-Dec-2011 uqs

Spelling fixes for usr.sbin/


# 212329 08-Sep-2010 jhb

Simplify chkattached(). The PCIOCATTACHED ioctl only needs the pi_sel
field populated, it ignores the rest of the 'pci_sel' structure.

MFC after: 1 week


# 188018 02-Feb-2009 jhb

- Add a new ioctl to /dev/pci to fetch details on an individual BAR of a
device. The details include the current value of the BAR (including all
the flag bits and the current base address), its length, and whether or not
it is enabled. Since this operation is not invasive, non-root users are
allowed to use it (unlike manual config register access which requires
root). The intention is that userland apps (such as Xorg) will use this
interface rather than dangerously frobbing the BARs from userland to
obtain this information.
- Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used
with -l will now list all the active BARs for each device.

MFC after: 1 month


# 184936 13-Nov-2008 mav

Add ADMA, SATA and SAS mass storage subclasses.


# 184142 21-Oct-2008 mav

Add HDA multimedia subclass.


# 184140 21-Oct-2008 mav

Add "SD host controller" subclass name.


# 182708 03-Sep-2008 imp

style nit: indent continuation lines correctly, use style(9) style
if() statement.


# 182707 03-Sep-2008 imp

minor style(9) police: sort getopt options alphabetically. The
semi-logical segregation of 'b' and 'h' doesn't seem to make sense and
makes it harder to read.


# 172448 04-Oct-2007 se

Make selector parsing accept the dot "." as an alternative selector
with identical meaning as the colon ":". This is to support a syntax
that is more similar to a PCI device specification in the device hints
file. The selector is not fully compatible with the specification in
the hints file, since entries in that file use a different prefix,
which needs to be added to the getsel() routine, if full support of
that syntax is found to be desirable.

Approved by: re (Ken Smith)


# 172447 04-Oct-2007 se

Restore compatibility with version before introduction of PCI domains.
PCI selectors with 2 or 3 elements behave exactly as before (i.e. the
domain is 0 and in the 2 element case, the function is also 0).
The form with 4 selector elements works as in the previous revision
and provides the PCI domain number as the left-most selector element.

This change allows old scripts (which used the 2 or 3 selector element
formats) to be kept. Without this patch, the 3 element form was parsed
as starting with a domain number (and the function was assumed to be 0),
with this patch, the domain is assumed to be 0 (and the last value is
used as the function number).

The man page is updated to describe the new selector semantics.

Approved by: re (Ken Smith)


# 172394 30-Sep-2007 marius

Make the PCI code aware of PCI domains (aka PCI segments) so we can
support machines having multiple independently numbered PCI domains
and don't support reenumeration without ambiguity amongst the
devices as seen by the OS and represented by PCI location strings.
This includes introducing a function pci_find_dbsf(9) which works
like pci_find_bsf(9) but additionally takes a domain number argument
and limiting pci_find_bsf(9) to only search devices in domain 0 (the
only domain in single-domain systems). Bge(4) and ofw_pcibus(4) are
changed to use pci_find_dbsf(9) instead of pci_find_bsf(9) in order
to no longer report false positives when searching for siblings and
dupe devices in the same domain respectively.
Along with this change the sole host-PCI bridge driver converted to
actually make use of PCI domain support is uninorth(4), the others
continue to use domain 0 only for now and need to be converted as
appropriate later on.
Note that this means that the format of the location strings as used
by pciconf(8) has been changed and that consumers of <sys/pciio.h>
potentially need to be recompiled.

Suggested by: jhb
Reviewed by: grehan, jhb, marcel
Approved by: re (kensmith), jhb (PCI maintainer hat)


# 166435 02-Feb-2007 jhb

- Teach pciconf(8) to list the PCI capabilities supported by each device
via a new -c flag to be used with -l. Some simple parsing code is
present for the following capabilities: Power Management, AGP, VPD,
MSI, PCI-X, HyperTransport, Vendor-specific, EHCI Debug Port, PCI-PCI
bridge subvendor ID, PCI-express, and MSI-X.
- Fix a few warnings in pciconf.c.
- Update some cruft in pciconf(8):
- PCI 2.1 is no longer a revolutionary standard, and subvendor ID's are
fairly common at this point, so reflect that.
- Header type 2 is used for PCI-CardBus bridges.
- Describe the -v option for -l after completing the basic -l description
instead of disrupting the flow in the middle.

Reviewed by: imp (partially)
MFC after: 1 week


# 149225 18-Aug-2005 des

Use larger buffers to read lines from the vendor list.
Trim trailing whitespace and comments before parsing, and skip empty lines.
Skip subvendor / subdevice entries (which start with two tab characters).
Change the scanf() format string to match any amount and type of whitespace
between the device ID and the description text.

MFC after: 3 weeks


# 149223 18-Aug-2005 des

Whitespace cleanup.


# 144156 26-Mar-2005 jmg

add some additional pci classes and sub-classes..

Reviewed by: imp (almost 6 months ago)


# 133271 07-Aug-2004 imp

Revert unintended commit that came in with 3rd clause removal


# 133268 07-Aug-2004 le

Fix syntax error introduced in the last commit.

Additionally, since this file is written in C and not in Perl,
we need 'continue' instead of 'next'.


# 133249 07-Aug-2004 imp

Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived software
(with permission of addtional copyright holders where appropriate)


# 124031 31-Dec-2003 rwatson

Only a read-only file descriptor is required to implement list_devs()
and list_verbose(), so don't open /dev/pci read-write. This allows
pciconf -l[v] to work for non-root users, assuming the securelevel is
0 or -1.

Problem experienced by: William Michael Grim <wgrim@siue.edu>


# 116640 20-Jun-2003 jmg

make pciconf understand it's own output as stated in the manpage.

pciconf -r none8@pci1:12:2: 0x0
now works.

PR: bin/10312
Submitted by: Castor Fu


# 103499 17-Sep-2002 jdp

Use consistent terminology in the usage message, the man page
synopsis, and the man page description ("selector" vs. "sel" and
"addr" vs. "reg").

Fix the usage message and man page synopsis to show that the "value"
argument is not optional.


# 91299 26-Feb-2002 sos

When asked to print bytes (-b option) do that and put 16 on a line.


# 77533 31-May-2001 imp

Support a range of registers to read.
eg pciconf -r pci0:10:0 0:0xff
and keep the output of the old singleton the same.

Reviewed by: audit@, dd

MFC after: 10 days


# 77513 31-May-2001 imp

Minor style(9) tweak: if ( instead of if(.


# 69785 08-Dec-2000 msmith

Update for new location of pcireg.h.


# 69700 07-Dec-2000 msmith

Update to improve handling of verbose PCI vendor/device information.

- Read the database from /usr/share/misc (or wherever else we're pointed)
rather than compiling it in.
- Decode the class/subclass fields if requested.
- Print things in a slightly longer but more readable format.


# 68677 13-Nov-2000 msmith

Add support for decoding the PCI vendor and device ID registers. Add a
database of about 1400 vendors and 2700 devices courtesy of
www.yourvote.com/pci. We still need to add some more, but this is a good
start.


# 54322 08-Dec-1999 ken

[ repository copy of sys/pci/pci_ioctl.h to sys/sys/pciio.h happened in the
background ]

Rename sys/pci/pci_ioctl.h to sys/sys/pciio.h to make it easier for
userland programs to use this interface. Reformat the file, and add a
BSD-style copyright to it.

Add a new man page for pci(4). The PCIOCGETCONF, PCIOCREAD, and PCIOCWRITE
ioctls are documented, but the PCIOCATTACHED ioctl is not documented
because it is not implemented.

Change includes of <pci/pci_ioctl.h> to <sys/pciio.h> or remove them
altogether. In many cases, pci_ioctl.h was unused.

Reviewed by: steve


# 53761 27-Nov-1999 charnier

.Fn -> .Xr
Do not start warn() message with uppercase.


# 50479 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50225 23-Aug-1999 peter

Fix a few problems on the Alpha, and fix -Wall while here.
Before:
isab0@pci0:8:0: class=0x060100 card=0x00000000 chip=0xffffffffc6931080 ...
After:
isab0@pci0:8:0: class=0x060100 card=0x00000000 chip=0xc6931080 ...


# 41103 11-Nov-1998 ken

Modify pciconf(8) so that it will print out PCI devices that have no driver
configured in the kernel. It gives them a device name of "none" and
monotonically incrementing unit numbers. (starting at 0) Before, pciconf
would just skip over unconfigured devices. (unconfigured devices can be
detected because they have a null string for a device name)

Update the man page to reflect the new pciconf output. Unfortunately, this
causes the sample 'pciconf -l' output lines to wrap, but I'm not sure what
to do about that really.

If anyone presents a reasonable case for printing out something other than
"none1" for unconfigured devices, I'm willing to listen.


# 39231 15-Sep-1998 gibbs

Revive PCIConf.

Submitted by: "Kenneth D. Merry" <ken@plutotech.com>


# 30172 06-Oct-1997 charnier

Sync usage string with man page.


# 24428 31-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 21935 21-Jan-1997 se

Add PCI LKM support:New -a option checks whether a driver has been assigned to a device.


# 19817 16-Nov-1996 se

Fix core dump after printing usage message (pointed out by BDE).
Add printing of PCI header type register. (This makes the output
80 columns wide. Ughh. I'm looking for a better way to put the
information on one line ...)


# 19103 22-Oct-1996 se

This commit was generated by cvs2svn to compensate for changes in r19102,
which included commits to RCS files with non-trunk default branches.


# 19102 22-Oct-1996 se

Initial version of the user land code for the PCI config register
access functions. Written by Garrett Wollman and modified by me to
better match my view of the (PCI) world.

Submitted by: wollman