zl程序教程

您现在的位置是:首页 >  其他

当前栏目

定制dmi信息的具体流程及相关知识

流程 信息 相关 知识 具体 定制
2023-09-14 09:09:19 时间

客户最近有一个需求,定制dmi信息。如果不定制信息会导致更新BIOS后,在新的固件下无法使用快捷键(如:Fn+F5,Fn+F6等等)以及电池图标。

要求修改内容:DMI信息 type3 为LapTop,type11为L39UPro。

乍看一头雾水,什么意思?DMI的信息type3是什么,11又是什么?具体应该改什么地方?

带着这一连串的问号,先来进行“科普”,从最基础的概念讲起。

BIOS里面的DMI信息是什么?它有什么用处?

DMI (Desktop Management Interface, DMI)桌面管理接口,就是帮助收集电脑系统信息的管理系统,用来让系统保存自身及外围设备相关数据。 DMI充当了管理工具和系统层之间接口的角色,通过DMI可以在操作系统级查询到包括 CPU、内存、I/O扩展槽等在内的系统配置信息(不用进入BIOS)。它建立了标准的可管理系统更加方便了电脑厂商和用户对系统的了解。DMI通常将上述信息存储在BIOS中一个4KB大小的DMI数据区中,这一数据区通常被称为MIFD(Management Information Format Database)。这个数据库包括了所有有关电脑系统和配件的信息。通过DMI,用户可以获取序列号、电脑厂商、串口信息以及其它系统配件信息。DMI信息的收集必须在严格遵照SMBIOS规范的前提下进行。SMBIOS和DMI是由行业指导机构Desktop Management Task Force (DMTF)起草的开放性的技术标准,其中,DMI设计适用于任何的平台和操作系统,是由行业指导机构(Desktop Management Task Force[DMTF])起草的开放性技术标准。SMBIOS(System Management BIOS)是主板或系统制造者以标准格式显示产品管理信息所需遵循的统一规范。

 

Dmidecode的作用

dmidecode的作用是将DMI数据库中的信息解码,以可读的文本方式显示。由于DMI信息可以人为修改,因此里面的信息不一定是系统准确的信息。

dmidecode命令用法详解 不带选项执行 dmidecode 通常会输出所有的硬件信息。Dmidecode 有个很有用的选项 -t,可以按指定类型输出相关信息,假如要获得处理器方面的信息,则可以执行:

dmidecode -t processor

如果想知道dmidecode具体的使用方法,则可以执行:

(sudo) dmidecode -h

输出: Usage: dmidecode [OPTIONS] Options are:

-d, --dev-mem FILE Read memory from device FILE (default: /dev/mem) 从设备文件读信息,输出内容与不加参数标准输出相同

-h, --help Display this help text and exit 显示帮助信息

-q, --quiet Less verbose output 显示更少的简化信息

-s, --string KEYWORD Only display the value of the given DMI string 只显示指定DMI字符串的信息

-t, --type TYPE Only display the entries of given type 只显示指定条目的信息

-H, --handle HANDLE Only display the entry of given handle

u, --dump Do not decode the entries 显示未解码的原始条目内容 --dump-bin FILE Dump the DMI data to a binary file --from-dump FILE Read the DMI data from a binary file

--no-sysfs Do not attempt to read DMI data from sysfs files

--oem-string N Only display the value of the given OEM string

-V, --version Display the version and exit 显示版本信息

dmidecode参数string及type列表 (1)Valid string keywords are:-s

bios-vendor

bios-version

bios-release-date

system-manufacturer

system-product-name

system-version

system-serial-number

system-uuid baseboard-manufacturer

baseboard-product-name

baseboard-version

baseboard-serial-number

baseboard-asset-tag

chassis-manufacturer

chassis-type

chassis-version

chassis-serial-number

chassis-asset-tag

processor-family

processor-manufacturer

processor-version

processor-frequency

(2)Valid type keywords are:-t

bios

system

baseboard

chassis

processor

memory

Cache

connector

slot

(3)type全部编码列表 //示例dmidecode -t 4 通过man dmidecode 查看

0 BIOS

1 System

2 Baseboard

3 Chassis

4 Processor

5 Memory Controller

6 Memory Module

7 Cache

8 Port Connector

9 System Slots

10 On Board Devices

11 OEM Strings

12 System Configuration Options

13 BIOS Language

14 Group Associations

15 System Event Log

16 Physical Memory Array

17 Memory Device 18 32-bit Memory Error

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

32 System Boot

33 64-bit Memory Error

34 Management Device

35 Management Device Component

36 Management Device Threshold Data

37 Memory Channel

38 IPMI Device

39 Power Supply

40 Additional Information

41 Onboard Devices Extended Information

42 Management Controller Host Interface

 

(4)string和type对应关系 Keyword Types

bios 0, 13 

system 1, 12, 15, 23, 32

baseboard 2, 10, 41

chassis 3

processor 4

memory 5, 6, 16, 17

cache 7

connector 8

slot 9

命令用法示例

查看服务器型号:dmidecode | grep 'Product Name'

查看主板的序列号:dmidecode | grep 'Serial Number'

查看系统序列号:dmidecode -s system-serial-number

查看内存信息:dmidecode -t memory

查看OEM信息:dmidecode -t 11

查看厂商产品:dmidecode -t 1

 

经过以上的“科普”,你应该能有一些思路了吧?其实客户要求的很简单,将type 3 设置为"LapTop",type 11设置为"L39UPro"。根据上边的说明,type 3对应Chassis(机箱风扇),type 11对应OEM Strings。也就是说要将Chassis的值设置为"LapTop",将OEM Strings的值设置为"L39UPro"。

那么接下来的问题来了,在哪里进行设置?怎么设置?

看似很复杂的问题,其实很简单。

对于前一个问题,在内核源码路径的drivers/platform/mips/loong-xxx.c中进行设置。mips/文件夹下的代码为各个厂商提供的ec文件,就在这个文件中进行设置(添加或修改)如果这个文件不存在则需要由厂家进行提供。对于后一个问题,其实只需要在ec文件中的static const struct dmi_system_id loongson_device_table[]结构体数组中添加一项:

{
        .ident = "THTF L39UPro",
        .matches = {
            DMI_MATCH(DMI_OEM_STRING, "L39UPro"),
            DMI_MATCH(DMI_CHASSIS_TYPE, "9"),
        },
        .callback = dmi_check_cb,
        .driver_data = &quirk_ea_ls7a_laptop,
},

其中.matches中的2项必须严格按照客户发来的值填写,.ident的值可以自行定义,但为了规范最好还是由厂家给出定义。

这里有个问题,DMI_CHASSIS_TYPE传的值并不是客户要求的"LapTop",而是"9",这是为什么?实际上这里有一个字符串与索引值(字符串形式)的转换。"9"转为索引值9,再转换为"LapTop"。

这样,作了以上修改后,就可以编译内核,结合固件进行验证了。