前言:
SMBIOS和DMI它定義了可用於以標准化方式訪問硬件和系統 BIOS 公開的信息的數據結構。 SMBIOS 經常與DMI混淆 ,但它本質上是原始 DMI 規范的演變。這就是 Linux dmidecode實用程序名稱的來源。 |
SMBIOS標准
smbios(System Management BIOS 簡寫為SMBIOS) 是主板或系統制造者以標准格式顯示產品管理信息所需遵循的統一規范 SMBIOS是由行業指導機構Desktop Management Task Force (DMTF)起草的開放性的技術標准; SMBIOS(System Management BIOS)是由BIOS/UEFI在初始化系統的時候收集的關於系統信息的一組結構化的表,並且存放在內存中, 提供給操作系統使用。
https://www.dmtf.org/standards/smbios
linux內核實現:
http://sourceforge.net/projects/smbios/
DMI標准
官網: https://www.dmtf.org/standards/dmi/ DMI 生成一個標准框架,用於管理和跟蹤台式電腦、筆記本電腦或服務器中的組件。DMI 是第一個桌面管理標准。
DMI 和SMBIOS的區別
DMI 將系統數據(包括系統管理 BIOS (SMBIOS) 數據)公開給管理軟件,但兩種規范獨立運行。
DMI 通常與 SMBIOS 混淆,SMBIOS 在其第一次修訂時實際上稱為 DMIBIOS
來自: https://en.wikipedia.org/wiki/Desktop_Management_Interface
查看 DMI和 SMBIOS 信息的 都可以用這個查看用 dmidecode工具查看
dmidecode程序,它可以訪問硬件公開的 SMBIOS/DMI 信息。該實用程序可以公開有關機器上硬件和 BIOS 軟件的大量信息。
內核啟動時,從日志可以看到類似:
[root@aozhejin /proc]#dmesg | grep SMBIOS [ 0.000000] SMBIOS 2.4 present.
我們查看dmi信息(在 sysfs文件系統中,DMI 信息位於/sys/class/dmi/id
)
[root@aozhejin /proc]#ls /sys/class/dmi/id bios_date board_asset_tag board_vendor chassis_serial chassis_version product_name product_version uevent bios_vendor board_name board_version chassis_type modalias product_serial subsystem bios_version board_serial chassis_asset_tag chassis_vendor power product_uuid sys_vendor
另外獲取dmi 標准下的硬件信息.
[root@aozhejin /proc]#ll /sys/devices/virtual/dmi/id/ total 0 -r--r--r-- 1 root root 4096 Apr 27 2022 bios_date -r--r--r-- 1 root root 4096 Apr 27 2022 bios_vendor -r--r--r-- 1 root root 4096 Apr 27 2022 bios_version -r--r--r-- 1 root root 4096 Mar 15 13:40 board_asset_tag -r--r--r-- 1 root root 4096 Mar 15 13:40 board_name -r-------- 1 root root 4096 Mar 15 13:40 board_serial -r--r--r-- 1 root root 4096 Mar 15 13:40 board_vendor -r--r--r-- 1 root root 4096 Mar 15 13:40 board_version -r--r--r-- 1 root root 4096 Mar 15 13:40 chassis_asset_tag -r-------- 1 root root 4096 Mar 15 13:40 chassis_serial -r--r--r-- 1 root root 4096 Mar 15 13:40 chassis_type -r--r--r-- 1 root root 4096 Mar 15 13:40 chassis_vendor -r--r--r-- 1 root root 4096 Mar 15 13:40 chassis_version -r--r--r-- 1 root root 4096 Apr 21 2022 modalias drwxr-xr-x 2 root root 0 Mar 15 13:40 power -r--r--r-- 1 root root 4096 Apr 27 2022 product_name -r-------- 1 root root 4096 Apr 27 2022 product_serial -r-------- 1 root root 4096 Apr 27 2022 product_uuid -r--r--r-- 1 root root 4096 Apr 27 2022 product_version lrwxrwxrwx 1 root root 0 Apr 27 2022 subsystem -> ../../../../class/dmi -r--r--r-- 1 root root 4096 Apr 21 2022 sys_vendor -rw-r--r-- 1 root root 4096 Apr 21 2022 uevent 獲取硬件基礎信息,比如生產廠商、系統、機箱等
一、從 SMBIOS 2.3 版本開始,兼容 SMBIOS 的實現必須包含以下 10 個數據表結構
SMBIOS 規范定義了以下 DMI 類型:
類型 | 信息 |
0 | BIOS |
1 | 系統 |
2 | 底板 |
3 | 機殼 |
4 | 處理器 |
5 | 內存控制器 |
6 | 內存模塊 |
7 | 緩存 |
8 | 端口連接器 |
9 | 系統插槽 |
10 | 車載設備 |
11 | OEM 琴弦 |
12 | 系統配置選項 |
13 | BIOS語言 |
14 | 團體協會 |
15 | 系統事件日志 |
16 | 物理內存陣列 |
17 | 記憶裝置 |
18 | 32 位內存錯誤 |
19 | 內存陣列映射地址 |
20 | 存儲設備映射地址 |
21 | 內置指點設備 |
22 | 便攜式電池 |
23 | 系統重置 |
24 | 硬件安全 |
25 | 系統電源控制 |
26 | 電壓探頭 |
27 | 冷卻裝置 |
28 | 溫度探頭 |
29 | 電流探頭 |
30 | 帶外遠程訪問 |
31 | 啟動完整性服務 |
32 | 系統啟動 |
33 | 64 位內存錯誤 |
34 | 管理設備 |
35 | 管理設備組件 |
36 | 管理設備閾值數據 |
37 | 內存通道 |
38 | IPMI 設備 |
39 | 電源 |
40 | 附加信息 |
41 | 板載設備擴展信息 |
42 | 管理控制器主機接口 |
此外,類型 126 用於禁用條目,類型 127 是表尾標記。類型 128 到 255 用於 OEM 特定數據。 默認情況下, dmidecode會顯示這些條目,但只有在供應商為它們提供文檔或代碼時,它才能解碼它們。
可以使用關鍵字代替帶有 --type的類型數字。每個關鍵字都相當於一個類型數字列表:
關鍵詞 | 類型 |
BIOS | 0, 13 |
系統 | 1, 12, 15, 23, 32 |
底板 | 2, 10, 41 |
機殼 | 3個 |
處理器 | 4個 |
記憶 | 5, 6, 16, 17 |
緩存 | 7 |
連接器 | 8個 |
二、SMBIOS 規范2.6定義的type如下。
TYPE 0->BIOS 信息, TYPE 1->系統信息
TYPE 2->基板(模塊)信息 TYPE 3->系統外圍或底架 TYPE 4->處理器信息 TYPE 5->存儲控制器信息(Obsolete),TYPE 6->存儲模塊信息(Obseolete) TYPE 7->緩存信息 TYPE 8->端口連接器信息 TYPE 9->系統插槽 TYPE 10->板載系統信息 TYPE 11->OEM字符串
TYPE 12->系統配置信息.............................
這里我看下 TYPE 1(系統信息)
位置 名稱 長度 描述
00h TYPE 號 1BYTE 結構的TYPE 號,此處是1
01h 長度 1BYTE 格式區域總長度,2.0 版為08h ,2.1-2.3.4 版為19h ,從2.4 版開始為1Bh 02h 句柄 2BYTE 指向本結構的句柄 04h 電腦制造商 1BYTE 一般為01h ,表示在字符串區域中的編號 05h 產品名稱 1BYTE 在字符串區域中的編號 06h 版本號 1BYTE 在字符串區域中的編號 07h 序列號 1BYTE 在字符串區域中的編號 09h UUID 16BYTE 通用唯一標識符 18h 喚醒類型 BYTE 用來標識導致系統開電啟動的事件 19h SKU 號 BYTE 在字符串區域中的編號,SKU 號通常為產品ID 或采購訂單號 1Ah 產品家族 1BYTE 在字符串區域中的編號
三 、SMBIOS 規范 2.7.1 中定義了如下的結構類型:
type Description 0 BIOS Information 1 System Information 2 Baseboard (or Module) Information 3 System Enclosure or Chassis 4 Processor Information 5 Memory Controller Information (Obsolete) 6 Memory Module Information (Obsolete) 7 Cache Information 8 Port Connector Information 9 System Slots 10 On Board Devices Information 11 OEM Strings 12 System Configuration Options 13 BIOS Language Information 14 Group Associations 15 System Event Log 16 Physical Memory Array 17 Memory Device 18 32-Bit Memory Error Information 19 Memory Array Mapped Address 20 Memory Device Mapped Address 21 Built-in Pointing Device 22 Portable Battery 23 System Reset 24 Hardware Security 25 System Power Controls 26 Voltage Probe 27 Cooling Device 28 Temperature Probe 29 Electrical Current Probe 30 Out-of-Band Remote Access 31 Boot Integrity Services (BIS) Entry Point 32 System Boot Information 33 64-Bit Memory Error Information 34 Management Device 35 Management Device Component 36 Management Device Threshold Data 37 Memory Channel 38 IPMI Device Information 39 System Power Supply 40 Additional Information 41 Onboard Devices Extended Information 42 Management Controller host Interface 126 Inactive 127 End-of-Table 128-255 Available for system- and OEM- specific informatio
四、在Linux中,可以通過dmidecode命令查看,不同類型的 SMBIOS子表 通過type數值來區分
語法 dmidecode -t type_num(在系統里面查看smbios表的信息)
查詢方法:
[root@ht8 devices]#dmidecode
[root@ht8 devices]#dmidecode -t 0
[root@ht8 devices]# dmidecode -t system
1) type=0代表bios
[root@ht8 devices]# dmidecode -t 0 //0代表bios # dmidecode 3.2 Getting SMBIOS data from sysfs. SMBIOS 2.4 present. Handle 0x0000, DMI type 0, 24 bytes BIOS Information Vendor: Phoenix Technologies LTD Version: 6.00 Release Date: 09/21/2015 Address: 0xE99E0 Runtime Size: 91680 bytes ROM Size: 64 kB Characteristics: ISA is supported PCI is supported PC Card (PCMCIA) is supported PNP is supported APM is supported BIOS is upgradeable BIOS shadowing is allowed ESCD support is available Boot from CD is supported Selectable boot is supported EDD is supported Print screen service is supported (int 5h) 8042 keyboard services are supported (int 9h) Serial services are supported (int 14h) Printer services are supported (int 17h) CGA/mono video services are supported (int 10h) ACPI is supported Smart battery is supported BIOS boot specification is supported Function key-initiated network boot is supported Targeted content distribution is supported BIOS Revision: 4.6 Firmware Revision: 0.0
2) type=9代表系統插槽
[root@ht8 devices]# dmidecode -t 9 # dmidecode 3.2 Getting SMBIOS data from sysfs. SMBIOS 2.4 present. ......
五、他們從哪里讀取信息的
[root@aozhejin /sys/firmware/dmi/tables]#ll total 0 -r-------- 1 root root 27170 Mar 15 15:21 DMI -r-------- 1 root root 31 Mar 15 15:21 smbios_entry_point 上面這兩個文件: [root@aozhejin /proc]#file /sys/firmware/dmi/tables/DMI /sys/firmware/dmi/tables/DMI: data #這是一個二進制屬性的文件 [root@aozhejin /proc]#cat /sys/firmware/dmi/tables/smbios_entry_point _SM_
我們來看看官方對/sys/firmware/dmi/tables/ 這個的解釋
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-dmi-tables
固件提供 DMI 數據結構作為打包列表被 SMBIOS 表入口點引用的數據。 SMBIOS 入口點包含一般信息,如 SMBIOS 版本、DMI 表大小等結構、內容和 SMBIOS 入口點的大小取決於 SMBIOS 版本。 SMBIOS 入口點 和 DMI 結構的格式可以在 SMBIOS 規范中閱讀。 dmi/tables 提供原始(raw)的SMBIOS 入口點和 DMI 表 通過 sysfs文件來作為實用程序的替代方案(例如: ),讀取來自/dev/mem。 原始 SMBIOS 入口點和 DMI表是呈現為二進制屬性, 可通過以下方式訪問: /sys/firmware/dmi/tables/smbios_entry_point /sys/firmware/dmi/tables/DMI 使用這兩個可以得到完整的DMI信息表。
參考資料:
https://www.dmtf.org/zh-hans
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0.pdf smbios規范下載
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.5.0.pdf
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0WIP50.pdf Work in Progress Documents
https://www.dmtf.org/sites/default/files/standards/documents/DSP0130.pdf Historical Documents
https://opensource.apple.com/source/AppleSMBIOS/AppleSMBIOS-22/SMBIOS.h.auto.html 蘋果公司關於smbios實現
https://www.dmtf.org/standards/dmi
https://www.dmtf.org/sites/default/files/standards/documents/DSP0005.pdf DMI規范
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/firmware/dmi-id.c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/firmware/dmi_scan.c
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf SMBIO規范
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-dmi-tables
https://linuxcommandlibrary.com/man/dmidecode