Compile pciutils (lspci, setpci) in Windows x86,在 Windows x86 平台下编译 pciutils (lspci, setpci)

pciutils 是 Linux 下查看 PCI/PCIe 设备的利器。可以用来 dump PCI configuration space,可惜在 Windows 平台下类似功能的工具寥寥无几。在 pcituils 的官网(http://mj.ucw.cz/pciutils.html)说明中提到了可以在 Windows 平台下工作。那下面来介绍 Windows 下编译 pciutils 的经验。遗憾的是在 x86_64/amd64 下没有成功,如果各位有成功的经验希望留言来描述下,谢谢。

  1. 下载 pciutils source code。在 ftp://atrey.karlin.mff.cuni.cz/pub/linux/pci/ 可以下载到最新的版本。
  2. 然后需要找到编译环境,这里推荐使用 mingw 来编译。mingw 也有许多版本,我是用的是 mplayer 项目的压缩包。(http://nchc.dl.sourceforge.net/project/mplayer-win32/MinGW/MinGW%20BE%20gcc%204.2.5/MinGW-full-gcc-4.2.5-Dec-2010.7z
  3. 再者由于 pciutils 原生是在 Linux 下运用的,在 Windows 下需要提供能够访问 kernel space 的接口,pciutils 使用了 WinIO 来实现这个。所以还要去下载 WinIO,地址在这里 http://www.internals.com/utilities/WinIo.zip
  4. 好了解压好三个包后,运行 mingw 下的 msys.bat。看到的命令行就是操作的环境。其中已经包含了所要使用的 gcc 编译器。需要提的是,由于 pciutils 中的 configure 在 Windows 是没办法使用的。所以要使用预先编制好的 config.h 和 config.mk。这两个文件存放在 pciutils 目录的 win32目录中。将他们拷贝到 lib 目录下。
  5. 然后修改 lib/i386-io-windows.h 文件,找到 lib = LoadLibrary("WinIo.dll");(3.17版本中在第39行),将 WinIo.dll 替换成 WinIo32.dll(当然 64 位系统应该替换成 WinIo64.dll)。保存下。将 WinIo 压缩包中 Binaries 目录下的 WinIo 相对应的 dll 和 sys 文件拷贝到 pciutils 的更目录下。
  6. 接下来就开始正式编译工作了。非常简单,进入到 pciutils 的根目录下,打入 make 稍等片刻,lspci 和 setpci 就生成好了。

Windows 下的 lspci 和 setpci 的使用方法完全和 Linux 中一摸一样。使用 -t 查看 tree view,使用 -xxx 来 dump configuration space, 使用 -vvv 查看具体功能描述,这些都不再赘述。呵呵。

 

pciutils-3.1.7-x86 下载:Download


Comments

8 responses to “Compile pciutils (lspci, setpci) in Windows x86,在 Windows x86 平台下编译 pciutils (lspci, setpci)”

  1. Hi

    Can You upload somewhere compiled version of setpci for Windows x86 ?

    I try it for myself but I’m newbie in software development.

    1. Hi TK,

      I have uploaded the binary for pciutils which includes lspci and setpci. You can download from the URL in the article. It’s just for x86 platform. I failed to compile it for amd64…

      http://edwinwang.com/wp-content/uploads/2011/04/pciutils-3.1.7-x86.zip

      I am glad to help you if you have any problem. 😛

      1. Thank You very much !

  2. Jernej S. Avatar
    Jernej S.

    Since WinIo’s license isn’t GPL-compatible, I wrote my own driver for port I/O, and then ported pciutils to use it. Additionally, the 64-bit driver is signed, so it works on 64-bit Windows. Both source and binaries are available at

    http://eternallybored.org/misc/pciutils/

    (this is from git).

    1. Hi Jerney S,

      It looks good. Much appropriate.
      And I found a tool, RW-Everything. It can do almost everything for space RW in Windows. http://rweverything.phpnet.us/index.htm

      Thank you.

  3. Raymond Avatar
    Raymond

    Dear all,
    I have success load the Winio32.dll by compiler MinGW-full-gcc-4.2.5-Dec-2010.7z and test in “Command Prompt” mode.
    But, when change change the
    lib = LoadLibrary(“WinIo32.dll”);
    to
    lib = LoadLibrary(“WinIo64.dll”);

    and test that again. It failed to load WinIo64.dll and display the error message
    “i386-io-windows: Couldn’t find InitializeWinIo function.”
    Is anyone can help me, thanks.

    1. Hi Raymond,
      I failed as well as I mentioned at the beginning of the post. You can try directio provided by Jernej (link). I tested it and it can work in x86_64. And there is an GUI tool, RW, which can help you in Windows. (link)
      Hope this will be helpful for you. 🙂

  4. Thanks or your help !!!!

Leave a Reply to Edwin Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.