xref: /aosp_15_r20/external/pciutils/README.Windows (revision c2e0c6b56a71da9abe8df5c8348fb3eb5c2c9251)
1*c2e0c6b5SAndroid Build Coastguard WorkerSince 2.1.99-test5, pciutils should also be compilable on Windows. Thanks
2*c2e0c6b5SAndroid Build Coastguard Workerto Alexander Stock for contributing the port.
3*c2e0c6b5SAndroid Build Coastguard Worker
4*c2e0c6b5SAndroid Build Coastguard WorkerUpdated after version 2.2.6 to compile again, and with MinGW, even (only?)
5*c2e0c6b5SAndroid Build Coastguard Workercross-compiling. (Hopefully it works with MSVC too.)
6*c2e0c6b5SAndroid Build Coastguard Worker
7*c2e0c6b5SAndroid Build Coastguard WorkerFor simple listing PCI devices in system via win32-cfgmgr32 access method
8*c2e0c6b5SAndroid Build Coastguard Workerwhich provides only basic information and emulated config space, there is no
9*c2e0c6b5SAndroid Build Coastguard Workerspecial requirement. To list PCI resources on Windows 8 and higher versions,
10*c2e0c6b5SAndroid Build Coastguard Workerit is necessary to have architecture-native version (e.g. AMD64 version on
11*c2e0c6b5SAndroid Build Coastguard WorkerAMD64 systems).
12*c2e0c6b5SAndroid Build Coastguard Worker
13*c2e0c6b5SAndroid Build Coastguard WorkerFor config space access there are different windows specific access methods:
14*c2e0c6b5SAndroid Build Coastguard Worker- win32-kldbg - Kernel Local Debugging Driver kldbgdrv.sys
15*c2e0c6b5SAndroid Build Coastguard Worker- win32-sysdbg - NT SysDbg interface
16*c2e0c6b5SAndroid Build Coastguard Worker- intel-conf1 - Direct hardware access via Intel configuration mechanism 1
17*c2e0c6b5SAndroid Build Coastguard Worker
18*c2e0c6b5SAndroid Build Coastguard WorkerThe default access method is win32-cfgmgr32 and by default it tries to use
19*c2e0c6b5SAndroid Build Coastguard Workerone of the above config access access method to provide as much as possible
20*c2e0c6b5SAndroid Build Coastguard Workerinformation to application. More details about particular access method and
21*c2e0c6b5SAndroid Build Coastguard Workercaveats are described in the pcilib(8) manual page.
22*c2e0c6b5SAndroid Build Coastguard Worker
23*c2e0c6b5SAndroid Build Coastguard WorkerThe default access method for config space is win32-kldbg. It uses Microsoft's
24*c2e0c6b5SAndroid Build Coastguard WorkerKernel Local Debugging Driver kldbgdrv.sys. This driver is not part of the
25*c2e0c6b5SAndroid Build Coastguard WorkerWindows system but is part of the Microsoft WinDbg tool. It is required to
26*c2e0c6b5SAndroid Build Coastguard Workerhave kldbgdrv.sys driver installed in the system32 directory or to have
27*c2e0c6b5SAndroid Build Coastguard Workerwindbg.exe or kd.exe binary in PATH. kldbgdrv.sys driver has some restrictions.
28*c2e0c6b5SAndroid Build Coastguard WorkerProcess needs to have Debug privilege and Windows system has to be booted with
29*c2e0c6b5SAndroid Build Coastguard WorkerDebugging option. Debugging option can be enabled by calling (takes effect
30*c2e0c6b5SAndroid Build Coastguard Workerafter next boot): bcdedit /debug on
31*c2e0c6b5SAndroid Build Coastguard Worker
32*c2e0c6b5SAndroid Build Coastguard WorkerDownload links for WinDbg 6.12.2.633 standalone installer from Microsoft:
33*c2e0c6b5SAndroid Build Coastguard Workerhttps://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools_amd64/dbg_amd64.msi
34*c2e0c6b5SAndroid Build Coastguard Workerhttps://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/setup/WinSDKDebuggingTools/dbg_x86.msi
35*c2e0c6b5SAndroid Build Coastguard Worker
36*c2e0c6b5SAndroid Build Coastguard WorkerTo access config space via intel-conf1 access method on NT-based systems via
37*c2e0c6b5SAndroid Build Coastguard WorkerNT ProcessUserModeIOPL system call, it is required to have SeTcbPrivilege
38*c2e0c6b5SAndroid Build Coastguard Worker(Act as part of the operating system privilege), which can be enabled in User
39*c2e0c6b5SAndroid Build Coastguard WorkerAccounts settings (take effect after next login). By default this privilege is
40*c2e0c6b5SAndroid Build Coastguard Workernot enabled for any non-system user. Or alternatively it is required to be in
41*c2e0c6b5SAndroid Build Coastguard Workerlocal Administrators group and on Windows 2000 SP4 or higher systems to have
42*c2e0c6b5SAndroid Build Coastguard WorkerSeImpersonatePrivilege (Impersonate a client after authentication privilege)
43*c2e0c6b5SAndroid Build Coastguard Workerwhich is by default enabled for all local Administrators accounts. There is no
44*c2e0c6b5SAndroid Build Coastguard Workerspecial requirement for DOS-based systems. 64-bit systems do not have to allow
45*c2e0c6b5SAndroid Build Coastguard Workerusers to access config space even with SeTcbPrivilege.
46*c2e0c6b5SAndroid Build Coastguard Worker
47*c2e0c6b5SAndroid Build Coastguard WorkerTo compile this port, run following command:
48*c2e0c6b5SAndroid Build Coastguard Worker
49*c2e0c6b5SAndroid Build Coastguard Worker  make CROSS_COMPILE=i586-mingw32msvc- HOST=i586-windows ZLIB=no IDSDIR=""
50*c2e0c6b5SAndroid Build Coastguard Worker
51*c2e0c6b5SAndroid Build Coastguard WorkerTo build 64-bit version, run:
52*c2e0c6b5SAndroid Build Coastguard Worker
53*c2e0c6b5SAndroid Build Coastguard Worker  make CROSS_COMPILE=x86_64-w64-mingw32- HOST=x86_64-windows ZLIB=no IDSDIR=""
54*c2e0c6b5SAndroid Build Coastguard Worker
55*c2e0c6b5SAndroid Build Coastguard WorkerSometimes compilation may fail due to broken or missing getopt implementation.
56*c2e0c6b5SAndroid Build Coastguard WorkerIn this case try to compile with additional make option: COMPAT_GETOPT=yes
57*c2e0c6b5SAndroid Build Coastguard Worker
58*c2e0c6b5SAndroid Build Coastguard WorkerBuilding of shared DLL library libpci3.dll is supported too but needs to be
59*c2e0c6b5SAndroid Build Coastguard Workermanually enabled by make option: SHARED=yes
60*c2e0c6b5SAndroid Build Coastguard Worker
61*c2e0c6b5SAndroid Build Coastguard WorkerThis DLL library libpci3.dll has versioned symbols with stable ordinal numbers
62*c2e0c6b5SAndroid Build Coastguard Workerwhich provides backward and forward compatibility. Every symbol in DLL library
63*c2e0c6b5SAndroid Build Coastguard Workerhas '@LIBPCI_3.<version>' suffix to achieve it. For linking application to
64*c2e0c6b5SAndroid Build Coastguard Workerlibpci3.dll it is possible to generate import library from libpci3.def file.
65*c2e0c6b5SAndroid Build Coastguard WorkerSuch import library will provide import symbol names without versioned suffix
66*c2e0c6b5SAndroid Build Coastguard Workeras an alias for the latest symbol version, which matches function name in pci.h
67*c2e0c6b5SAndroid Build Coastguard Workerheader file. The alias is resolved by the linker at linking time, so the final
68*c2e0c6b5SAndroid Build Coastguard Workerapplication binary would always reference only versioned symbol. DLL library
69*c2e0c6b5SAndroid Build Coastguard Workerlibpci3.dll does not provide unversioned symbols, so for using GetProcAddress()
70*c2e0c6b5SAndroid Build Coastguard Workeror dlsym() it is needed to specify full versioned symbol name.
71