UEFI BIOS之Device Path(设备路径)

小记:BIOS为什么能识别插入的USB,SATA HDD,M.2 Drive,网卡,显卡等设备?如果同时插入多个不同的设备,如何区分每个设备的路径?(主要参考UEFI SPEC V2.6 第9章 Protocols — Device Path Protocol)

目录

1.What is the Device Path ?/设备路径是什么?

2.EFI Device Path Protocol,GUID & Protocol Interface Structure

3.Device Path Nodes

3.1Generic Device Path Structures

3.2End of Hardware Device Path node

4.Six major types of Device Path nodes

4.1Hardware Device Path

1>PCI Device Path

4.2ACPI Device Path

4.3Messaging Device Path

1>USB Device Paths

2>SATA Device Path

4.4Media Device Path 

4.5.BIOS Boot Specification Device Path

5.实例分析​

其他内容可以参考UEFI SPEC:Device Path Generation Rules,Device Path Utilities Protocol,EFI Device Path Display Format...英文意思更准确,中文只是为了方便理解

1.What is the Device Path ?/ 设备路径是什么?

A device path is constructed and used by the firmware to convey the location of important devices, such as the boot device and console, consistent with the software-visible topology of the system.

A Device Path is used to define the programmatic path to a device. The primary purpose of a Device Path is to allow an application, such as an OS loader, to determine the physical device that the interfaces are abstracting.

A Device Path is designed to make maximum leverage of the ACPI name space.

The Device Path was designed so that the OS loader and the operating system could tell which devices the platform firmware was using as boot devices.

BIOS通过设备路径来构建和传递设备的位置,如启动设备和输入输出设备,以达到与系统的软件可见的拓扑结构一致。

设备路径用于定义设备的路径。设备路径的主要目的是允许应用程序(如操作系统加载程序)确定接口的物理设备。

设备路径旨在最大限度地利用ACPI名称空间。

设备路径的设计使操作系统加载程序和操作系统能够判断平台固件(BIOS)正在使用哪些设备作为引导设备。

2.EFI Device Path Protocol,GUID & Protocol Interface Structure

The executing UEFI Image may use the device path to match its own device drivers to the particular device. Note that the executing UEFI OS loader and UEFI application images must access all physical devices via Boot Services device handles until EFI_BOOT_SERVICES.ExitBootServices() is successfully called. A UEFI driver may access only a physical device for which it provides functionality.

正在执行的UEFI Image可以使用设备路径将其自己的设备驱动程序与特定设备相匹配。请注意,执行UEFI操作系统加载程序和UEFI应用程序Image必须通过Boot Services device handles访问所有物理设备,直到ExitBootServices()被成功调用。UEFI驱动程序只能访问其提供功能的物理设备。

3.Device Path Nodes

A Device Path is a series of generic Device Path nodes. The first Device Path node starts at byte offset zero of the Device Path. The next Device Path node starts at the end of the previous Device Path node. Therefore all nodes are byte-packed data structures that may appear on any byte boundary. All code references to device path notes must assume all fields are unaligned. Since every Device Path node contains a length field in a known place, it is possible to traverse Device Path nodes that are of an unknown type. There is no limit to the number, type, or sequence of nodes in a Device Path.

3.1Generic Device Path Structures

3.2End of Hardware Device Path node

Depending on the Sub-Type, this Device Path node is used to indicate the end of the Device Path instance or Device Path structure.This type of node has two sub-types (see Table 42):

1>End This Instance of a Device Path (sub-type 0x01).

2>End Entire Device Path (sub-type 0xFF).

4.Six major types of Device Path nodes

There are six major types of Device Path nodes:

1》Hardware Device Path.

2》ACPI Device Path.

3》Messaging Device Path.

4》Media Device Path. 

5》BIOS Boot Specification Device Path.

6》End of Hardware Device Path.

4.1Hardware Device Path

1>PCI Device Path

The Device Path for PCI defines the path to the PCI configuration space address for a PCI device. There is one PCI Device Path entry for each device and function number that defines the path from the root PCI bus to the device.

4.2ACPI Device Path

This Device Path contains ACPI Device IDs that represent a device’s Plug and Play Hardware ID and its corresponding unique persistent ID. The ACPI IDs are stored in the ACPI _HID, _CID, and _UID device identification objects that are associated with a device.

4.3Messaging Device Path

1>USB Device Paths

2>SATA Device Path

4.4Media Device Path 

4.5BIOS Boot Specification Device Path

以上每个分类都有很多子类,太多了有的不常用,具体有需求再找UEFI SPEC就可以了。

5.实例分析

分析:

1>02 01 0C 00 D0 41 03 0A 00 00 00 00:Type 2 – ACPI Device Path,Sub-Type 1 ACPI Device Path,Length – 0x0C, _HID –D0 41 03 0A, _UID – 00 00 00 00

2>01 01 06 00 00 14:Type 1 – Hardware Device Path,Sub-Type 1 – PCI,Length – 0x06,PCI Function Number – 0,PCI Device Number  – 0x14

3>03 05 06 00 13 00:Type 3 – Messaging Device Path,Sub-Type 5 – USB,Length – 0x06, USB Parent Port Number –0x13,USB Interface Number– 0x00

4>03 05 06 00 02 00:Type 3 – Messaging Device Path,Sub-Type 5 – USB,Length – 0x06, USB Parent Port Number –0x02,USB Interface Number– 0x00

5>7F FF 04 00:Type 0x7F – End of Hardware Device Path,Sub-Type –0xFF,End Entire Device Path,Length – 0x04

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值