]> git.ipfire.org Git - thirdparty/pciutils.git/log
thirdparty/pciutils.git
4 months agolib: Refactor access to x86 I/O ports
Pali Rohár [Sun, 8 Oct 2023 13:10:12 +0000 (15:10 +0200)] 
lib: Refactor access to x86 I/O ports

On all systems except BeOS and Haiku are x86 I/O ports accessed in the
standard way by the x86 in/out instructions.

On more systems there are wrapper functions for x86 in/out instructions but
under different names and sometimes even for same system those names
depends on user version of toolchain/compiler. And also some systems have
same function names but switched order of arguments.

Simplify this code, define own wrapper functions for x86 in/out
instructions in new header file i386-io-access.h and use it for every
platform except BeOS and Haiku.

This change simplifies Windows port, duplicated code between SunOS and
Windows and also tons of redefined port functions in every port.

To not conlict with possible system functions included from some header
file, add intel_ prefix for every function included from the file
lib/i386-io-access.h into lib/i386-ports.c

4 months agoRename aux fields in structs pci_access and pci_dev to backend_data
Martin Mares [Fri, 29 Dec 2023 18:33:21 +0000 (19:33 +0100)] 
Rename aux fields in structs pci_access and pci_dev to backend_data

This hopefully conveys the purpose much better than just "aux".

4 months agoGet rid of workarounds for Linux systems without pread/pwrite
Martin Mares [Fri, 29 Dec 2023 14:23:00 +0000 (15:23 +0100)] 
Get rid of workarounds for Linux systems without pread/pwrite

Many things have changed since we introduced work-arounds for Linux
systems with missing pread/pwrite in 1999 (if you are curious, it was
in commit bc6346df8d89ece4814be7dff951ec1a7d259938).

I believe that it is supported by all reasonably recent Linux systems
now. After all, pread() was already defined by POSIX.1-2001.

This should also fix problems with musl libc mentioned in GitHub
issue #158.

4 months agoConstants for CXL capability should not change
Martin Mares [Fri, 29 Dec 2023 14:16:03 +0000 (15:16 +0100)] 
Constants for CXL capability should not change

When CXL capability decoding was upgraded to revision 2 by commit
c0ccce1b4cd5b42b17f2e8f7bae4031c311677ff, the value of PCI_CXL_DEV_LEN
in lib/header.h has changed.

This is probably not a good idea - programs using libpci can depend
on the exact value of this constant.

Let us revert PCI_CXL_DEV_LEN to the original value for revision 1
and add PCI_CXL_DEV_LEN_REV2 for the next revision.

Also, fixed a bug in the decoder which caused it to read past the
end of the buffer for a capability which is declared as revision 2,
but too short.

4 months agolibpci: ecam: Fix big address range mappings
Pali Rohár [Thu, 18 May 2023 19:36:50 +0000 (21:36 +0200)] 
libpci: ecam: Fix big address range mappings

If more buses span continuous address space then there can be up to the
256 MB long address range which ecam backend tries to map.

Such huge space cannot be mapped on some memory limited systems. And also
it is not needed to map whole 256 MB long address range because ecam
backend cache uses mapping only for one bus. One bus has maximal mapping
size just 32*8*4096 bytes.

So adjust size calculation when mapping ecam bus.

4 months agolibpci: ecam: Deduplicate get_bus_addr() code for calculating bus address
Pali Rohár [Thu, 18 May 2023 19:34:49 +0000 (21:34 +0200)] 
libpci: ecam: Deduplicate get_bus_addr() code for calculating bus address

Move duplicate code block into helper function calculate_bus_addr().

4 months agolibpci: win32-cfgmgr32: Do not use GetWindowsDirectory()
Pali Rohár [Thu, 17 Aug 2023 20:03:19 +0000 (22:03 +0200)] 
libpci: win32-cfgmgr32: Do not use GetWindowsDirectory()

GetWindowsDirectory() function returns HOME user folder if application is
running on the Terminal Server. So this function is not suitable.

Instead of use GetSystemDirectory() which returns path to system32 folder
or GetSystemWindowsDirectory() which returns path to Windows folder (but
this is not available on all Windows versions).

4 months agolibpci: win32-kldbg: Fix driver constructing path
Pali Rohár [Thu, 17 Aug 2023 19:15:02 +0000 (21:15 +0200)] 
libpci: win32-kldbg: Fix driver constructing path

Get*Directory() functions have strange API. When called with zero buffer
they return length of the required buffer for storing path including
nul-term in TCHAR units (which is 1 for ANSI builds and 2 for UNICODE
builds). When called with non-zero buffer which can store full path they
return length of the path without nul-term (again in TCHAR units).

GetWindowsDirectory() function returns HOME user folder if application is
running on the Terminal Server. So this function is not suitable.

Fix calculation of path buffer for UNICODE builds and instead of usage
GetWindowsDirectory() function with concatenating "\\system32" string, use
function GetSystemDirectory() which returns path directly to system32
folder and which works correctly also on Terminal Server (per KB281316).

4 months agolibpci: i386-io-windows.h: Fix memory leak in grant_process_token_dacl_permissions()
Pali Rohár [Wed, 7 Jun 2023 17:53:32 +0000 (19:53 +0200)] 
libpci: i386-io-windows.h: Fix memory leak in grant_process_token_dacl_permissions()

When SetEntriesInAcl() call success then new_dacl allocated by this
function has to be released by LocalFree() call.

4 months agolibpci: i386-io-windows.h: Fix error code in ERROR_PRIVILEGE_NOT_HELD code path
Pali Rohár [Sat, 6 May 2023 16:35:20 +0000 (18:35 +0200)] 
libpci: i386-io-windows.h: Fix error code in ERROR_PRIVILEGE_NOT_HELD code path

4 months agolibpci: win32-cfgmgr32: Fix reg key name in warning message
Pali Rohár [Sun, 11 Jun 2023 11:48:07 +0000 (13:48 +0200)] 
libpci: win32-cfgmgr32: Fix reg key name in warning message

4 months agolibpci: win32-cfgmgr32: Skip parsing uninterested resources very early
Pali Rohár [Wed, 15 Mar 2023 18:12:05 +0000 (19:12 +0100)] 
libpci: win32-cfgmgr32: Skip parsing uninterested resources very early

4 months agolibpci: win32-cfgmgr32: Show type of source in warning message
Pali Rohár [Wed, 15 Mar 2023 18:11:25 +0000 (19:11 +0100)] 
libpci: win32-cfgmgr32: Show type of source in warning message

4 months agoFix memory leak when fill flags has PCI_FILL_PARENT.
nsf.cd [Tue, 14 Nov 2023 10:20:22 +0000 (18:20 +0800)] 
Fix memory leak when fill flags has PCI_FILL_PARENT.

4 months agoCXL: Fix indentation
Martin Mares [Fri, 8 Dec 2023 18:44:16 +0000 (19:44 +0100)] 
CXL: Fix indentation

4 months agoMerge pull request #146 from alexisgrytalms/master
Martin Mareš [Fri, 8 Dec 2023 18:41:49 +0000 (19:41 +0100)] 
Merge pull request #146 from alexisgrytalms/master

CXL: DVSEC fixes and CXLCap3

4 months agoMerge pull request #157 from pali/master
Martin Mareš [Fri, 8 Dec 2023 18:38:28 +0000 (19:38 +0100)] 
Merge pull request #157 from pali/master

Fix compile warnings about unused variables

4 months agolspci: Add PCIe 6.0 data rate (64 GT/s) also to LnkCap2
Ilpo Järvinen [Fri, 8 Dec 2023 10:13:07 +0000 (12:13 +0200)] 
lspci: Add PCIe 6.0 data rate (64 GT/s) also to LnkCap2

While commit 5bdf63b6b1bc ("lspci: Add PCIe 6.0 data rate (64 GT/s)
support") added 64 GT/s support to some registers, LnkCap2 Supported
Link Speeds Vector was not included.

Add PCIe 6.0 data rate bit check also into
cap_express_link2_speed_cap().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
6 months agoSubject: lspci: Display PASID required attribute in Page Status Register.
Ashok Raj [Wed, 18 Oct 2023 21:34:15 +0000 (14:34 -0700)] 
Subject: lspci: Display PASID required attribute in Page Status Register.

Display the PASID required attribute in the Page Request Status Register.
When set, the function expects a PASID on Page Group Response (PRG)
messages when the corresponding page request had a PASID.

Signed-off-by: Ashok Raj <ashok.raj@intel.com>
6 months agosetpci: Fix man page typo
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:36 +0000 (11:08 -0500)] 
setpci: Fix man page typo

"Several ways how to identity a register" doesn't read correctly and
misspells "identify".  Reword as "several ways to identify a register".

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
6 months agolspci: Remove spurious colon (':') from PCIe PTM decoding
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:35 +0000 (11:08 -0500)] 
lspci: Remove spurious colon (':') from PCIe PTM decoding

Remove spurious colon from PTM decoding to match other enabled/disabled
decoding.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
6 months agolspci: Print PCIe Interrupt Message Numbers consistently
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:34 +0000 (11:08 -0500)] 
lspci: Print PCIe Interrupt Message Numbers consistently

Several Capabilities include MSI/MSI-X Interrupt Message Numbers, which
were decoded in various ways:

  - MSI %02x                             PCIe Capability
  - IntMsg %d                            AER Capability
  - INT Msg #%d                          DPC Capability
  - Interrupt Message Number %03x        SR-IOV Capability
  - Interrupt Message Number %03x        DOE Capability

Print them all using the same format:

  + IntMsgNum %d

This better matches the "Interrupt Message Number" terminology used in the
spec, e.g., PCIe r6.0, sec 7.5.3.2.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 months agolspci: Decode PCIe LnkCtl Link Disable as 'LnkDisable'
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:33 +0000 (11:08 -0500)] 
lspci: Decode PCIe LnkCtl Link Disable as 'LnkDisable'

Decode the Link Disable bit as "LnkDisable" (not simply "Disable") to match
the spec terminology (PCIe r6.0, sec 7.5.3.7)

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
6 months agolspci: Decode PCIe DevCtl2 End-to-End TLP Prefix Blocking
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:32 +0000 (11:08 -0500)] 
lspci: Decode PCIe DevCtl2 End-to-End TLP Prefix Blocking

Decode the PCIe DevCtl2 End-to-End TLP Prefix Blocking bit.  The
"EETLPPrefixBlk" format is analogous to the existing "EETLPPrefix" format
used for the corresponding DevCap2 bit.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
6 months agolspci: Decode PCIe DevCtl2 Emergency Power Reduction Request
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:31 +0000 (11:08 -0500)] 
lspci: Decode PCIe DevCtl2 Emergency Power Reduction Request

Decode the PCIe DevCtl2 Emergency Power Reduction Request bit.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
6 months agolspci: Decode PCIe DevCtl2 ID-Based Ordering Enables
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:30 +0000 (11:08 -0500)] 
lspci: Decode PCIe DevCtl2 ID-Based Ordering Enables

Decode the PCIe DevCtl2 ID-Based Ordering Enable bits.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
6 months agolspci: Reorder PCIe DevCtl2 fields to match spec
Bjorn Helgaas [Wed, 18 Oct 2023 16:08:29 +0000 (11:08 -0500)] 
lspci: Reorder PCIe DevCtl2 fields to match spec

Decode the PCIe DevCtl2 fields in the same order they're documented in the
PCIe spec.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 months agoFix compile warnings about unused variables
Pali Rohár [Sun, 10 Sep 2023 16:48:16 +0000 (18:48 +0200)] 
Fix compile warnings about unused variables

sysfs.c: In function 'sysfs_read_vpd':
sysfs.c:569:43: warning: unused parameter 'd' [-Wunused-parameter]
 static int sysfs_read_vpd(struct pci_dev *d, int pos, byte *buf, int len)
                                           ^
sysfs.c:569:50: warning: unused parameter 'pos' [-Wunused-parameter]
 static int sysfs_read_vpd(struct pci_dev *d, int pos, byte *buf, int len)
                                                  ^~~
sysfs.c:569:61: warning: unused parameter 'buf' [-Wunused-parameter]
 static int sysfs_read_vpd(struct pci_dev *d, int pos, byte *buf, int len)
                                                             ^~~
sysfs.c:569:70: warning: unused parameter 'len' [-Wunused-parameter]
 static int sysfs_read_vpd(struct pci_dev *d, int pos, byte *buf, int len)
                                                                      ^~~

8 months agoAdd support for 32.0 GT/s header
Mateusz Nowicki [Fri, 1 Sep 2023 13:41:59 +0000 (15:41 +0200)] 
Add support for 32.0 GT/s header

9 months agoupdate-pciids: Report itself as an user agent, version included
Martin Mares [Sun, 23 Jul 2023 13:44:03 +0000 (15:44 +0200)] 
update-pciids: Report itself as an user agent, version included

Unfortunately, this leads to the User-Agent not containing version
of curl/wget/lynx we used.

9 months agoupdate-pciids: Re-compress pci.ids if needed
Martin Mares [Sat, 22 Jul 2023 21:47:13 +0000 (23:47 +0200)] 
update-pciids: Re-compress pci.ids if needed

Previously, if pciutils were configured with compression of pci.ids,
update-pciids downloaded the gzipped version. Now, it downloads the
most compressed version for which tools are found installed, and
recompresses it to gzip if needed.

9 months agoupdate-pciids: Add support for xz compression
Martin Mares [Sat, 22 Jul 2023 21:36:11 +0000 (23:36 +0200)] 
update-pciids: Add support for xz compression

9 months agoMerge remote-tracking branch 'twilfredo/wilfred/fixup-doe-bits'
Martin Mares [Wed, 19 Jul 2023 19:13:59 +0000 (21:13 +0200)] 
Merge remote-tracking branch 'twilfredo/wilfred/fixup-doe-bits'

9 months agolspci: Use mangled vendor/device ID when examining vendor caps
David Edmondson [Wed, 19 Jul 2023 14:16:41 +0000 (15:16 +0100)] 
lspci: Use mangled vendor/device ID when examining vendor caps

Given that PCI VFs are expected to have a vendor and device ID of
0xffff, when examining vendor capabilities use the mangled vendor and
device IDs (typically copied from the PF) rather than those read from
the VF configuration space.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
9 months agolib: fixup DOE status register bit
Wilfred Mallawa [Tue, 18 Jul 2023 08:50:28 +0000 (18:50 +1000)] 
lib: fixup DOE status register bit

The error bit is specified by the 2nd (zero indexed) bit
in the status register, so the respective bit value is 4 (PCI Base Spec
6.0.1). Let's fix that up.

Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
10 months agoUpdate license comments and added SPDX license identifiers
Martin Mares [Sun, 18 Jun 2023 12:37:33 +0000 (14:37 +0200)] 
Update license comments and added SPDX license identifiers

Previously, the only information about the specific version of GPL
was present in the README and individual source files mentioned only
GPL alone.

Let us update all copyright comments to explicitly say "GPL v2+"
and also include the machine readable SPDX license identifier.

11 months agoCXL3.0: Add DVSEC CXLCtrl3 and missing CXLCtl2
Alexis Gryta [Tue, 6 Jun 2023 06:03:52 +0000 (15:03 +0900)] 
CXL3.0: Add DVSEC CXLCtrl3 and missing CXLCtl2

8.1.3 PCIe DVSEC for CXL Devices

11 months agoCXL: Fix Flex Bus DVSEC cap
Alexis Gryta [Mon, 5 Jun 2023 06:06:08 +0000 (15:06 +0900)] 
CXL: Fix Flex Bus DVSEC cap

12 months agoFix stripping in cross-compiling mode
Martin Mares [Mon, 1 May 2023 13:44:40 +0000 (15:44 +0200)] 
Fix stripping in cross-compiling mode

Fixes 3d7466ef8545d37a4666e185a9f5d65ceb9c8af4.

12 months agoReleased as v3.10.0. v3.10.0
Martin Mares [Mon, 1 May 2023 13:00:27 +0000 (15:00 +0200)] 
Released as v3.10.0.

12 months agoMerge remote-tracking branch 'pali/ls-tree-multidomain'
Martin Mares [Mon, 1 May 2023 12:48:14 +0000 (14:48 +0200)] 
Merge remote-tracking branch 'pali/ls-tree-multidomain'

12 months agolspci: Allow longer name strings
Martin Mares [Mon, 1 May 2023 12:42:11 +0000 (14:42 +0200)] 
lspci: Allow longer name strings

12 months agoMerge pull request #137 from jiladahe1997/master
Martin Mareš [Mon, 1 May 2023 12:39:34 +0000 (14:39 +0200)] 
Merge pull request #137 from jiladahe1997/master

Makefile: change STRIP to '--strip-program' when cross-compile

12 months agoMerge pull request #140 from pali/ls-tree
Martin Mareš [Mon, 1 May 2023 12:39:19 +0000 (14:39 +0200)] 
Merge pull request #140 from pali/ls-tree

lspci: Fix bridge filter support in tree view

12 months agoAdd test case with multidomain Freescale P2020 PCIe hierarchy
Pali Rohár [Sat, 29 Apr 2023 11:52:11 +0000 (13:52 +0200)] 
Add test case with multidomain Freescale P2020 PCIe hierarchy

12 months agols-tree: Print PCI domains in ascending order
Pali Rohár [Sat, 22 Apr 2023 09:48:55 +0000 (11:48 +0200)] 
ls-tree: Print PCI domains in ascending order

12 months agols-tree: Fix parsing devices on multidomain PCI system
Pali Rohár [Sat, 22 Apr 2023 09:47:24 +0000 (11:47 +0200)] 
ls-tree: Fix parsing devices on multidomain PCI system

Represent each domain as domain bridge under the &host_bridge and put root
bus of each domain under the domain bridge.

With this change lspci in tree view does not show zero bus on domain 0 in
the output if this bus does not exist at all. Root bus in PCIe hierarchy
does not have to be zero and on Freescale PowerPC systems it is common.

Also with this change are separate domain showed in the output separately.

12 months agols-tree: Rename struct bridge member next to prev
Pali Rohár [Mon, 17 Apr 2023 23:53:55 +0000 (01:53 +0200)] 
ls-tree: Rename struct bridge member next to prev

It refers to the previous value in linked-list, not to the next.

12 months agols-tree: Do not read Primary Bus Number for PCI Bridges from PCI config space
Pali Rohár [Mon, 17 Apr 2023 22:31:10 +0000 (00:31 +0200)] 
ls-tree: Do not read Primary Bus Number for PCI Bridges from PCI config space

For PCIe devices of PCI Bridge type is Primary Bus Number not used and the
default value is 0. PCIe devices capture their Bus and Device numbers
automatically from PCIe TLP packets.

Instead of Primary Bus Number use Device Number because zero value confuse
tree building algorithm. Existing code already expects that Device Number
of PCI Bridge is already set to Primary Bus Number.

12 months agolspci: Fix bridge filter support in tree view
Pali Rohár [Tue, 11 Apr 2023 20:02:20 +0000 (22:02 +0200)] 
lspci: Fix bridge filter support in tree view

Correctly show whole subtree of PCI-to-PCI bridge in tree view when filter
(-s or -d option) was specified for PCI-to-PCI bridge device itself.

12 months agopci.ids updated to today's snapshot after a big cleanup of the DB
Martin Mares [Mon, 10 Apr 2023 18:09:24 +0000 (20:09 +0200)] 
pci.ids updated to today's snapshot after a big cleanup of the DB

13 months agoMakefile: change STRIP to '--strip-program' when cross-compile
mingrui.ren [Fri, 17 Mar 2023 01:44:34 +0000 (09:44 +0800)] 
Makefile: change STRIP to '--strip-program' when cross-compile

When cross-compile, we should use specific strip instead of default
/usr/bin/strip.

reference:https://man7.org/linux/man-pages/man1/install.1.html

Signed-off-by: mingrui.ren <mingrui.ren@bst.ai>
14 months agoDocumented that pci_(read|write)_block are little-endian
Martin Mares [Sun, 5 Mar 2023 15:25:48 +0000 (16:25 +0100)] 
Documented that pci_(read|write)_block are little-endian

14 months agoParameters: Keep the list sorted and remove duplicates
Martin Mares [Sun, 5 Mar 2023 13:56:52 +0000 (14:56 +0100)] 
Parameters: Keep the list sorted and remove duplicates

When multiple back-ends use the same option (e.g., "devmem.path"),
they tend to define it each. This is not nice, but before we generalize
these options properly, let us at least remove the duplicate definitions.

14 months agolibpci: Add PCIe ECAM access method
Pali Rohár [Sun, 29 Jan 2023 23:39:36 +0000 (00:39 +0100)] 
libpci: Add PCIe ECAM access method

This is a new direct hardware access method via PCIe ECAM (Enhanced
Configuration Access Mechanism). It is available on all PCIe-compliant
hardware. Requires root privileges and access to physical memory.

ECAM mapping can be specified manually via a new ecam.addrs parameter or
can be read from ACPI MCFG table. ACPI MCFG table can be located in the
system or read from x86 BIOS memory.

14 months agoFix bug in previous commit
Martin Mares [Sat, 4 Mar 2023 22:53:00 +0000 (23:53 +0100)] 
Fix bug in previous commit

14 months agowin32-cfgmgr32: Clean up initialization
Martin Mares [Sat, 4 Mar 2023 16:23:06 +0000 (17:23 +0100)] 
win32-cfgmgr32: Clean up initialization

14 months agowin32-cfgmgr32: Improve wording in manual page
Martin Mares [Sat, 4 Mar 2023 16:02:46 +0000 (17:02 +0100)] 
win32-cfgmgr32: Improve wording in manual page

14 months agoMerge remote-tracking branch 'pali/win32-cfgmgr32'
Martin Mares [Sat, 4 Mar 2023 15:58:35 +0000 (16:58 +0100)] 
Merge remote-tracking branch 'pali/win32-cfgmgr32'

14 months agoUse "command -v" instead of "which"
Martin Mares [Sat, 4 Mar 2023 15:33:09 +0000 (16:33 +0100)] 
Use "command -v" instead of "which"

Apparently, people started considering "which" obsolete. I still
consider "which" rather useful and definitely more comfortable to type
than "command -v".

Still, "command -v" should be more portable, so let us use it.
I wonder which of the ancient systems which we are still supporting
will be broken by this change...

14 months agoMerge remote-tracking branch 'pali/windows'
Martin Mares [Sat, 4 Mar 2023 15:28:08 +0000 (16:28 +0100)] 
Merge remote-tracking branch 'pali/windows'

14 months agoMerge remote-tracking branch 'pali/mmio-ports'
Martin Mares [Sat, 4 Mar 2023 15:27:09 +0000 (16:27 +0100)] 
Merge remote-tracking branch 'pali/mmio-ports'

14 months agoFilters: Allow leading "0x" for backward compatibility
Martin Mares [Sat, 4 Mar 2023 15:02:43 +0000 (16:02 +0100)] 
Filters: Allow leading "0x" for backward compatibility

15 months agolibpci: mmio-ports: Fix support for 64-bit non-LLP64 systems
Pali Rohár [Sun, 29 Jan 2023 22:49:06 +0000 (23:49 +0100)] 
libpci: mmio-ports: Fix support for 64-bit non-LLP64 systems

On 64-bit non-LLP64 systems is type long 64-bit. On 32-bit and 64-bit LLP64
systems is type long only 32-bit. But readl() and writel() functions works
with 32-bit PCI word. Fix it for non-LLP64 systems by using type u32.

16 months agolibpci: win32-cfgmgr32: Add support for accessing config space via other backend
Pali Rohár [Fri, 30 Dec 2022 20:21:10 +0000 (21:21 +0100)] 
libpci: win32-cfgmgr32: Add support for accessing config space via other backend

Extend win32-cfgmgr32 backend and add a new option win32.cfgmethod for
specifying other backend for accessing PCI config space. There are more
config space access methods available on Windows and each is working only
sometimes (either requires special privileges or special setup).

So by default try to choose the first working one via order defined in pci
probe_sequence[] array. If none is available then emulate PCI config space
like before this change.

Function pci_init_v35() is extended and renamed to pci_init_internal() to
optionally do not throw errors and allow to specify one access method which
will be skipped in AUTO mode. This is used to prevent choosing win32-cfgmgr32
as config space access method for win32-cfgmgr32.

16 months agoFix versioned symbol aliases when used with link-time optimization
Martin Mares [Wed, 28 Dec 2022 12:48:47 +0000 (13:48 +0100)] 
Fix versioned symbol aliases when used with link-time optimization

17 months agoREADME.Windows: Fix of $HOST
Martin Mares [Mon, 21 Nov 2022 19:21:59 +0000 (20:21 +0100)] 
README.Windows: Fix of $HOST

Suggested by Pali.

17 months agolibpci: windows: Define ERROR_NOT_FOUND
Pali Rohár [Mon, 21 Nov 2022 00:20:30 +0000 (01:20 +0100)] 
libpci: windows: Define ERROR_NOT_FOUND

Fix compile issues with older toolchain which does not define ERROR_NOT_FOUND macro.

17 months agoReleased as 3.9.0 v3.9.0
Martin Mares [Sun, 20 Nov 2022 12:06:14 +0000 (13:06 +0100)] 
Released as 3.9.0

17 months agoUpdated pci.ids to today's snapshot
Martin Mares [Sun, 20 Nov 2022 12:05:15 +0000 (13:05 +0100)] 
Updated pci.ids to today's snapshot

Worked around encoding issues in the database before we fix them
for real.

17 months agolibpci: windows: Handle long paths generated by GetModuleFileName()
Pali Rohár [Fri, 18 Nov 2022 22:40:39 +0000 (23:40 +0100)] 
libpci: windows: Handle long paths generated by GetModuleFileName()

C function fopen() implemented by msvcrt.dll requires special prefix
"\\\\?\\" for paths longer than 260 bytes. Because GetModuleFileName()
returns absolute path, it may be longer than 260 bytes. Add fixup to handle
long paths.

17 months agolibpci: windows: Fix path returned by GetModuleFileName()
Pali Rohár [Fri, 18 Nov 2022 21:57:11 +0000 (22:57 +0100)] 
libpci: windows: Fix path returned by GetModuleFileName()

GetModuleFileName() on Windows 10 has bugs and returns bogus path.
Implement fixups to make path usable for later fopen() call.

17 months agolibpci: djgpp: Allow to specify empty IDSDIR=
Pali Rohár [Fri, 18 Nov 2022 20:57:50 +0000 (21:57 +0100)] 
libpci: djgpp: Allow to specify empty IDSDIR=

Like for windows builds this will cause to load pci.ids file from the same
directory where is stored application binary. Code is same as for Windows,
just djgpp uses global symbol __dos_argv0 instead of _pgmptr.

Tested with following compile command:
  make CROSS_COMPILE=i586-pc-msdosdjgpp- HOST=i586-djgpp ZLIB=no DNS=no IDSDIR=

17 months agolibpci: windows: Fix locating path to pci.ids file for DLL builds
Pali Rohár [Fri, 18 Nov 2022 20:54:53 +0000 (21:54 +0100)] 
libpci: windows: Fix locating path to pci.ids file for DLL builds

When using shared libpci DLL library, it is expected that pci.ids file is
stored in directory where is also libpci DLL library and not in directory
where is application executable.

Based on the build mode and compile options, choose the appropriate
function for retrieving path to the libpci DLL library or application
executable. Also pass correct module argument to GetModuleFileName() call.

17 months agolibpci: windows: Fix usage of GetModuleFileName()
Pali Rohár [Fri, 18 Nov 2022 20:47:04 +0000 (21:47 +0100)] 
libpci: windows: Fix usage of GetModuleFileName()

Module file name can have arbitrary length despite all MS examples say
about MAX_PATH upper limit. This limit does not apply for example when
executable is running from network disk with very long UNC paths or
when using "\\??\\" prefix for specifying executable binary path.

So handle buffer truncatenation by retrying GetModuleFileName() call with
larger buffer.

Fixes loading of pci.ids file when lspci.exe binary is running from network
drive with path longer than 260 bytes.

17 months agolibpci: mmio-ports: Add Extended PCIe Intel Type 1 access method
Pali Rohár [Sun, 2 Jan 2022 19:50:41 +0000 (20:50 +0100)] 
libpci: mmio-ports: Add Extended PCIe Intel Type 1 access method

Extended method allows to access all PCIe registers, including extended
registers starting at 0x100 offset. This method uses 4 reserved buts above
bus bits for PCIe registers. On ARM platforms it is very common for PCIe
controllers. Like standard method, it needs to be properly configured.

17 months agoMerge remote-tracking branch 'pali/intel-conf1-memio'
Martin Mares [Fri, 18 Nov 2022 13:15:08 +0000 (14:15 +0100)] 
Merge remote-tracking branch 'pali/intel-conf1-memio'

17 months agolibpci: mmio-ports: Check for write access to /dev/mem in detect method
Pali Rohár [Sat, 5 Nov 2022 16:51:25 +0000 (17:51 +0100)] 
libpci: mmio-ports: Check for write access to /dev/mem in detect method

17 months agolibpci: mmio-ports: Add configure note messages
Pali Rohár [Sat, 5 Nov 2022 16:36:42 +0000 (17:36 +0100)] 
libpci: mmio-ports: Add configure note messages

17 months agolibpci: mmio-ports: Bypass CPU cache and add barriers for read/write
Pali Rohár [Sat, 5 Nov 2022 16:32:38 +0000 (17:32 +0100)] 
libpci: mmio-ports: Bypass CPU cache and add barriers for read/write

Between accessing address address and data I/O ports it is needed to issue
barriers. Use explicit readl() for barrier and O_DSYNC to bypass CPU cache.

17 months agoDraft ChangeLog for the next release
Martin Mares [Fri, 18 Nov 2022 11:17:02 +0000 (12:17 +0100)] 
Draft ChangeLog for the next release

17 months agopcilib.man: Include information about win32-kldbg
Pali Rohár [Mon, 7 Mar 2022 20:22:40 +0000 (21:22 +0100)] 
pcilib.man: Include information about win32-kldbg

17 months agolibpci: Add new windows kldbgdrv.sys implementation
Pali Rohár [Fri, 4 Mar 2022 00:07:53 +0000 (01:07 +0100)] 
libpci: Add new windows kldbgdrv.sys implementation

Microsoft Kernel Local Debugging Driver (kldbgdrv.sys) allow access for
userspace processes to the PCI config space. It supports access up to
65536 domains and whole 4096 bytes long extended PCIe config space. Driver
is signed by Microsoft and is available for both 32-bit and 64-bit systems.

Driver is not part of Windows system and has to be installed via WinDbg
installation package. Standalone installers for WinDbg 6.12.2.633 version:
https://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools_amd64/dbg_amd64.msi
https://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools/dbg_x86.msi

This kldbgdrv.sys API is used by the !pci command of new WinDbg kernel
debugger for displaying PCI config space.

API of this driver is available only for processes with Debug privilege and
only if system was booted with Debugging option.

17 months agoDisable mmio-ports on platforms where it does not make much sense
Martin Mares [Fri, 18 Nov 2022 11:03:26 +0000 (12:03 +0100)] 
Disable mmio-ports on platforms where it does not make much sense

Feel free to re-enable it if you find it useful.

17 months agoMerge remote-tracking branch 'pali/intel-conf1-memio'
Martin Mares [Fri, 18 Nov 2022 09:46:22 +0000 (10:46 +0100)] 
Merge remote-tracking branch 'pali/intel-conf1-memio'

17 months agoMerge remote-tracking branch 'jphaws/cxl-dvsec-decoded'
Martin Mares [Fri, 18 Nov 2022 08:26:00 +0000 (09:26 +0100)] 
Merge remote-tracking branch 'jphaws/cxl-dvsec-decoded'

17 months agolspci: Add test case for CXL device
Jaxon Haws [Mon, 7 Nov 2022 21:13:18 +0000 (15:13 -0600)] 
lspci: Add test case for CXL device

Add requested config space dump of CXL device for testing

Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
17 months agolspci: Add support for Non-CXL Function Map DVSEC
Jaxon Haws [Mon, 24 Oct 2022 17:51:54 +0000 (12:51 -0500)] 
lspci: Add support for Non-CXL Function Map DVSEC

Add Non-CXL Function Map DVSEC Registers 0-7 decoding according to
DVSEC Revision ID 0.

Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
17 months agolspci: Add support for CXL MLD DVSEC
Jaxon Haws [Wed, 19 Oct 2022 21:29:37 +0000 (16:29 -0500)] 
lspci: Add support for CXL MLD DVSEC

Add MLD DVSEC decoding for CXL device accoring to DVSEC revision ID 0.
Decode Number of Logical Devices Supported.

Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
17 months agolspci: Add support for CXL GPF Port DVSEC
Jaxon Haws [Mon, 17 Oct 2022 21:09:55 +0000 (16:09 -0500)] 
lspci: Add support for CXL GPF Port DVSEC

Add Global Persistent Flush DVSEC decoding for CXL port according to
DVSEC Revision ID 0.
Decode GPF Phase 1 Control and GPF Phase 2 Control.

Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
17 months agolspci: Add support for CXL Flex Bus DVSEC
Jaxon Haws [Mon, 17 Oct 2022 20:44:08 +0000 (15:44 -0500)] 
lspci: Add support for CXL Flex Bus DVSEC

Add DVSEC Flex Bus Port for CXL devices according to DVSEC Revision ID 1,
capability decoding, control decoding, and status decoding.

Signed-off-by: Jaxon Haws <jaxon.haws@amd.com>
17 months agoMerge remote-tracking branch 'pali/i386-io-windows'
Martin Mares [Sun, 13 Nov 2022 16:05:46 +0000 (17:05 +0100)] 
Merge remote-tracking branch 'pali/i386-io-windows'

17 months agoMerge remote-tracking branch 'pali/linux-ioperm'
Martin Mares [Sun, 13 Nov 2022 16:05:19 +0000 (17:05 +0100)] 
Merge remote-tracking branch 'pali/linux-ioperm'

17 months agoMerge remote-tracking branch 'pali/win32-cfgmgr32'
Martin Mares [Sun, 13 Nov 2022 16:04:10 +0000 (17:04 +0100)] 
Merge remote-tracking branch 'pali/win32-cfgmgr32'

17 months agoMerge remote-tracking branch 'pali/i386-ports'
Martin Mares [Sun, 13 Nov 2022 16:03:40 +0000 (17:03 +0100)] 
Merge remote-tracking branch 'pali/i386-ports'

17 months agowindows: Codepage in resource file is 16-bit number
Pali Rohár [Wed, 9 Nov 2022 19:27:23 +0000 (20:27 +0100)] 
windows: Codepage in resource file is 16-bit number

17 months agoi386-ports: Fix intel_io_lock usage
Pali Rohár [Sun, 6 Nov 2022 17:57:39 +0000 (18:57 +0100)] 
i386-ports: Fix intel_io_lock usage

Do not call pci_generic_block_read() and pci_generic_block_write()
functions when io is locked. These functions call back same backend
read/write function which tries to lock and unlock io again.

17 months agolibpci: win32-cfgmgr32: Fix typo
Pali Rohár [Sat, 22 Oct 2022 14:58:21 +0000 (16:58 +0200)] 
libpci: win32-cfgmgr32: Fix typo

17 months agolibpci: win32-cfgmgr32: Fix parsing paths in NT format
Pali Rohár [Mon, 18 Apr 2022 14:53:59 +0000 (16:53 +0200)] 
libpci: win32-cfgmgr32: Fix parsing paths in NT format

NT namespace separator may be single or double backslash.

17 months agoi386-io-linux: Prefer usage of ioperm()
Pali Rohár [Sun, 6 Nov 2022 12:58:55 +0000 (13:58 +0100)] 
i386-io-linux: Prefer usage of ioperm()

Since Linux 2.6.8, it is possible to use ioperm() syscall to gain access
for all I/O ports. Because iopl() syscall before Linux 5.5 allowed
userspace to disable interrupts, prefer usage of ioperm() syscall and ask
for access only for PCI ports.