lspci命令詳解

說明:
lspci 是一個用來顯示系統中所有PCI總線設備或連接到該總線上的所有設備的工具。

參數:

-v
使得 lspci 以冗餘模式顯示所有設備的詳細信息。
-vv
使得 lspci 以過冗餘模式顯示更詳細的信息 (事實上是 PCI 設備能給出的所有東西)。這些數據的確切意義沒有在此手冊頁中解釋,如果你想知道更多,請參照 /usr/include/linux/pci.h 或者 PCI 規範。
-n
以數字形式顯示 PCI 生產廠商和設備號,而不是在 PCI ID 數據庫中查找它們。
-x
以十六進制顯示 PCI 配置空間 (configuration space) 的前64個字節映像 (標準頭部信息)。此參數對調試驅動和 lspci 本身很有用。
-xxx
以十六進制顯示所有 PCI 配置空間的映像。此選項只有 root 可用,並且很多 PCI 設備在你試圖讀取配置空間的未定義部分時會崩潰 (此操作可能不違反PCI標準,但是它至少非常愚蠢)。
-b
以總線爲中心進行查看。顯示所有 IRQ 號和記憶體地址,就像 PCI 總線上的卡看到的一樣,而不是核心看到的內容。
-t
以樹形方式顯示包含所有總線、橋、設備和它們的連接的圖表。
-s [[<bus>]:][<slot>][.[<func>]]
僅顯示指定總線、插槽上的設備或設備上的功能塊信息。設備地址的任何部分都可以忽略,或以「*」代替 (意味著所有值)。所有數字都是十六進制。例如:「0:」指的是在0號總線上的所有設備;「0」指的是在任意總線上0號設備的所有功能塊;「0.3」選擇 了所有總線上0號設備的第三個功能塊;「.4」則是隻列出每一設備上的第四個功能塊。
-d [<vendor>]:[<device>]
只顯示指定生產廠商和設備 ID 的設備。 這兩個 ID 都以十六進制表示,可以忽略或者以「*」代替 (意味著所有值)。
-i <file>
使用 <file> 作爲 PCI ID 數據庫而不是使用預設的 /usr/share/hwdata/pci.ids
-p <dir>
使用 <dir> 作爲包含 PCI 總線信息的目錄而不是使用預設的目錄 /proc/bus/pci
-m
以機器可讀的方式轉儲 PCI 設備數據 (支持兩種模式:普通和冗餘),便於稿本解析。
-M
使用總線映射模式,這種模式對總線進行全面地掃描以查明總線上的所有設備,包括配置錯誤的橋之後的設備。請注意,此操作只應在調試時使 用,並可能造成系統崩潰 (只在設備有錯誤的時候,但是不幸的是它們存在),此命令只有 root 可以使用。同時,在不直接接觸硬體的 PCI 訪問模式中使用 -M 參數沒有意義,因爲顯示的結果 (排除 lspci 中的 bug 的影響) 與普通的列表模式相同。
--version
顯示 lspci 的版本。這個選項應當單獨使用。

PCILIB 選項 PCILIB OPTIONS
PCI 工具使用 PCILIB (一種可移植的庫,提供平臺獨立的函數來訪問 PCI 配置空間)來和PCI卡交互。下面的選項用來控制庫參數,特別是所用訪問模式的指定。預設情況下,PCILIB 使用第一種可用的訪問模式,不會顯示任何調試信息。每一個開關選項都列出了一組它所支持的硬件/軟軟件列表。
-P <dir>
使用 linux 2.1 風格的配置,直接訪問目錄 <dir> 而非 /proc/bus/pci 目錄。(只能在linux 2.1或以上版本中使用)
-H1
通過 Intel 架構 1 來實現直接硬體訪問。(只能用於 i386 及其相容機)
-H2
通過Intel 架構2來實現直接硬體訪問。警告:此模式只能尋址任何總線上的前16個設備,並且在很多情況下相當不可靠。(只能用於 i386 及其相容機)
-S
使用 PCI 系統調用訪問。(只能用於 Alpha  Ultra-Sparc 上的 Linux)
-F <file>
從所給的包含 lspci -x命令輸出的檔案中獲取相關信息。這在分析使用者提交的錯誤報告時很有用,因爲你可以用任何方式來顯示硬體配置信息而無需爲了獲取更多信息打擾使用者。(可用於所有系統)
-G
增加庫的調試等級。(可用於所有系統)

 
實例:
實例1:不必加上任何選項,就能夠顯示出目前的硬件配備

# lspci
00:00.0 Host bridge: Intel Corporation 3200/3210 Chipset DRAM Controller  //主板芯片
00:19.0 Ethernet controller: Intel Corporation 82566DM-2 Gigabit Network Connection (rev 02)
00:1a.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 (rev 02)
00:1a.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 (rev 02)
00:1a.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 (rev 02)  //USB控制器
00:1c.0 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 1 (rev 02)  //接口插槽
00:1c.4 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 5 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 92)
00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 4 port SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
00:1f.5 IDE interface: Intel Corporation 82801I (ICH9 Family) 2 port SATA IDE Controller (rev 02)
02:00.0 VGA compatible controller: Matrox Graphics, Inc. MGA G200e [Pilot] ServerEngines (SEP1) (rev 02)  //顯卡
03:02.0 Ethernet controller: Intel Corporation 82541GI Gigabit Ethernet Controller (rev 05)  //網卡

 
實例2:查看一般詳細信息

# lspci -v
00:00.0 Host bridge: Intel Corporation 3200/3210 Chipset DRAM Controller
        Subsystem: Intel Corporation Unknown device 34d0
        Flags: bus master, fast devsel, latency 0
        Capabilities: [e0] Vendor Specific Information

00:19.0 Ethernet controller: Intel Corporation 82566DM-2 Gigabit Network Connection (rev 02)
        Subsystem: Intel Corporation Unknown device 34d0
        Flags: bus master, fast devsel, latency 0, IRQ 50
        Memory at e1a00000 (32-bit, non-prefetchable) [size=128K]
        Memory at e1a20000 (32-bit, non-prefetchable) [size=4K]
        I/O ports at 20e0 [size=32]
        Capabilities: [c8] Power Management version 2
        Capabilities: [d0] Message Signalled Interrupts: 64bit+ Queue=0/0 Enable+
        Capabilities: [e0] #13 [0306]

 
實例3:查看網卡詳細信息

# lspci -s 03:02.0 -vv  //-s後面接的是每個設備的總線、插槽與相關函數功能
03:02.0 Ethernet controller: Intel Corporation 82541GI Gigabit Ethernet Controller (rev 05)
        Subsystem: Intel Corporation Unknown device 34d0
        Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV+ VGASnoop- ParErr+ Stepping- SERR+ FastB2B-
        Status: Cap+ 66MHz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <tabort- <mabort- >SERR- <perr-
        Latency: 32 (63750ns min), Cache Line Size: 64 bytes
        Interrupt: pin A routed to IRQ 209
        Region 0: Memory at e1920000 (32-bit, non-prefetchable) [size=128K]
        Region 1: Memory at e1900000 (32-bit, non-prefetchable) [size=128K]
        Region 2: I/O ports at 1000 [size=64]
        Expansion ROM at fffe0000 [disabled] [size=128K]
        Capabilities: [dc] Power Management version 2
                Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
                Status: D0 PME-Enable- DSel=0 DScale=1 PME-
        Capabilities: [e4] PCI-X non-bridge device
                Command: DPERE- ERO+ RBC=512 OST=1
                Status: Dev=00:00.0 64bit- 133MHz- SCD- USC- DC=simple DMMRBC=2048 DMOST=1 DMCRS=8 RSCEM- 266MHz- 533MHz-

 
附錄:
附錄1:爲了能使用這個命令所有功能,你需要有 linux 2.1.82 或以上版本,支持 /proc/bus/pci 接口的核心。在舊版本核心中,PCI工具必須使用只有root才能執行的直接硬體訪問,而且總是出現競爭狀況以及其他問題。
如果你要報告 PCI 設備驅動中,或者是 lspci 自身的 bugs,請在報告中包含 “lspci -vvx” 的輸出。

附錄2:CentOS bash: lspci: command not found解決方法
大多使用/sbin/lspci即可,我發現我的系統中/sbin下也沒有。使用yum install lspci顯示沒有這個包。

# yum whatprovides */lspci
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.grandcloud.cn
 * extras: mirrors.163.com
 * updates: mirrors.grandcloud.cn
base/filelists                                                                                                                                  | 3.6 MB     00:16
extras/filelists_db                                                                                                                             | 241 kB     00:00
updates/filelists_db                                                                                                                            | 2.4 MB     00:19
pciutils-3.1.7-5.el5.x86_64 : PCI bus related utilities  //這裏顯示的pciutils-3.1.7-5.el5.x86_64
Repo        : base
Matched from:
Filename    : /sbin/lspci

pciutils-3.1.7-3.el5.x86_64 : PCI bus related utilities.
Repo        : installed
Matched from:
Filename    : /sbin/lspci

因此只需要yum install pciutils即可

附錄3.lspci用到的文件
/usr/share/hwdata/pci.ids:所有已知 PCI ID 的清單 (廠商,設備名,類,子類)
/proc/bus/pci:linux 2.1.82 之後版本核心提供的 PCI 總線配置空間的接口。包含每個總線 (per-bus) 的子目錄以及每個設備卡 (per-card) 的配置空間檔案,還有一個 devices 檔案,包含所有PCI設備的列表


發佈了9 篇原創文章 · 獲贊 45 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章