xref: /pciutils/README.Windows (revision 7dbb846c)
1ee7d8384SMartin MaresSince 2.1.99-test5, pciutils should also be compilable on Windows. Thanks
2ee7d8384SMartin Maresto Alexander Stock for contributing the port.
3c0eece92SMartin Mares
409156b3bSMartin MaresUpdated after version 2.2.6 to compile again, and with MinGW, even (only?)
509156b3bSMartin Marescross-compiling. (Hopefully it works with MSVC too.)
609156b3bSMartin Mares
7b8773677SPali RohárFor simple listing PCI devices in system via win32-cfgmgr32 access method
8b8773677SPali Rohárwhich provides only basic information and emulated config space, there is no
9353f4109SPali Rohárspecial requirement. To list PCI resources on Windows 8 and higher versions,
10353f4109SPali Rohárit is necessary to have architecture-native version (e.g. AMD64 version on
11353f4109SPali RohárAMD64 systems).
12353f4109SPali Rohár
13b8773677SPali RohárFor config space access there are different windows specific access methods:
14b8773677SPali Rohár- win32-kldbg - Kernel Local Debugging Driver kldbgdrv.sys
15b8773677SPali Rohár- win32-sysdbg - NT SysDbg interface
16b8773677SPali Rohár- intel-conf1 - Direct hardware access via Intel configuration mechanism 1
17b8773677SPali Rohár
18b8773677SPali RohárThe default access method is win32-cfgmgr32 and by default it tries to use
19b8773677SPali Rohárone of the above config access access method to provide as much as possible
20b8773677SPali Rohárinformation to application. More details about particular access method and
21b8773677SPali Rohárcaveats are described in the pcilib(8) manual page.
22b8773677SPali Rohár
23*7dbb846cSMartin MaresThe default access method for config space is win32-kldbg. It uses Microsoft's
247bcd087dSPali RohárKernel Local Debugging Driver kldbgdrv.sys. This driver is not part of the
257bcd087dSPali RohárWindows system but is part of the Microsoft WinDbg tool. It is required to
267bcd087dSPali Rohárhave kldbgdrv.sys driver installed in the system32 directory or to have
277bcd087dSPali Rohárwindbg.exe or kd.exe binary in PATH. kldbgdrv.sys driver has some restrictions.
287bcd087dSPali RohárProcess needs to have Debug privilege and Windows system has to be booted with
297bcd087dSPali RohárDebugging option. Debugging option can be enabled by calling (takes effect
307bcd087dSPali Rohárafter next boot): bcdedit /debug on
317bcd087dSPali Rohár
327bcd087dSPali RohárDownload links for WinDbg 6.12.2.633 standalone installer from Microsoft:
337bcd087dSPali Rohárhttps://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools_amd64/dbg_amd64.msi
347bcd087dSPali Rohárhttps://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools/dbg_x86.msi
357bcd087dSPali Rohár
36b8773677SPali RohárTo access config space via intel-conf1 access method on NT-based systems via
37b8773677SPali RohárNT ProcessUserModeIOPL system call, it is required to have SeTcbPrivilege
38b8fbb6f0SPali Rohár(Act as part of the operating system privilege), which can be enabled in User
39b8fbb6f0SPali RohárAccounts settings (take effect after next login). By default this privilege is
40b8fbb6f0SPali Rohárnot enabled for any non-system user. Or alternatively it is required to be in
41b8fbb6f0SPali Rohárlocal Administrators group and on Windows 2000 SP4 or higher systems to have
42b8fbb6f0SPali RohárSeImpersonatePrivilege (Impersonate a client after authentication privilege)
43b8fbb6f0SPali Rohárwhich is by default enabled for all local Administrators accounts. There is no
44353f4109SPali Rohárspecial requirement for DOS-based systems. 64-bit systems do not have to allow
45353f4109SPali Rohárusers to access config space even with SeTcbPrivilege.
46b5847329SMartin Mares
4763435b6eSPali RohárTo compile this port, run following command:
4863435b6eSPali Rohár
4942e6a803SMartin Mares  make CROSS_COMPILE=i586-mingw32msvc- HOST=i586-windows ZLIB=no IDSDIR=""
5063435b6eSPali Rohár
51353f4109SPali RohárTo build 64-bit version, run:
52353f4109SPali Rohár
53353f4109SPali Rohár  make CROSS_COMPILE=x86_64-w64-mingw32- HOST=x86_64-windows ZLIB=no IDSDIR=""
54353f4109SPali Rohár
5563435b6eSPali RohárSometimes compilation may fail due to broken or missing getopt implementation.
5663435b6eSPali RohárIn this case try to compile with additional make option: COMPAT_GETOPT=yes
5763435b6eSPali Rohár
58b8773677SPali RohárBuilding of shared DLL library libpci3.dll is supported too but needs to be
59b8773677SPali Rohármanually enabled by make option: SHARED=yes
60b8773677SPali Rohár
61b8773677SPali RohárThis DLL library libpci3.dll has versioned symbols with stable ordinal numbers
62b8773677SPali Rohárwhich provides backward and forward compatibility. Every symbol in DLL library
63b8773677SPali Rohárhas '@LIBPCI_3.<version>' suffix to achieve it. For linking application to
64b8773677SPali Rohárlibpci3.dll it is possible to generate import library from libpci3.def file.
65b8773677SPali RohárSuch import library will provide import symbol names without versioned suffix
66b8773677SPali Roháras an alias for the latest symbol version, which matches function name in pci.h
67b8773677SPali Rohárheader file. The alias is resolved by the linker at linking time, so the final
68b8773677SPali Rohárapplication binary would always reference only versioned symbol. DLL library
69b8773677SPali Rohárlibpci3.dll does not provide unversioned symbols, so for using GetProcAddress()
70b8773677SPali Roháror dlsym() it is needed to specify full versioned symbol name.
71