UEFI Device Path

阅读数:224 评论数:0

跳转到新版页面

分类

OS

正文

总的来说,Device Path主要描述的是设备或总线或legacy启动项。

Device Path  Protocol

Device Path Protocol在UEFI下的通用结构体如下:

/**
  This protocol can be used on any device handle to obtain generic path/location 
  information concerning the physical device or logical device. If the handle does 
  not logically map to a physical device, the handle may not necessarily support 
  the device path protocol. The device path describes the location of the device 
  the handle is for. The size of the Device Path can be determined from the structures 
  that make up the Device Path.
**/
typedef struct {
  UINT8 Type;       ///< 0x01 Hardware Device Path.
                    ///< 0x02 ACPI Device Path.
                    ///< 0x03 Messaging Device Path.
                    ///< 0x04 Media Device Path.
                    ///< 0x05 BIOS Boot Specification Device Path.
                    ///< 0x7F End of Hardware Device Path.
                    
  UINT8 SubType;    ///< Varies by Type
                    ///< 0xFF End Entire Device Path, or
                    ///< 0x01 End This Instance of a Device Path and start a new
                    ///< Device Path.
                    
  UINT8 Length[2];  ///< Specific Device Path data. Type and Sub-Type define
                    ///< type of data. Size of data is included in Length.
                    
} EFI_DEVICE_PATH_PROTOCOL;

它是一个可变结构体,因为有不同种类的Device Path,它们的大小各不相同。

1、一个Device Path 可能由多个Device Path组成,子Device Path称为Device Path Node

2、每个Device Path都由End of Hardware Device Path结尾

3、End of Hardware Device Path由两种类型,一种是End of This Instance of a Device Path(SubType是0x01),用在Device Path Node的最后,另一种是End Entire Device Path(Sub-Type是0xFF),后者用在整个Device Path的最后。

在UEFI中有指定的函数来判断这两种End of Hardware Device Path

BOOLEAN
EFIAPI
IsDevicePathEnd (
  IN CONST VOID  *Node
  )
{
  ASSERT (Node != NULL);
  return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);
}
 
BOOLEAN
EFIAPI
IsDevicePathEndInstance (
  IN CONST VOID  *Node
  )
{
  ASSERT (Node != NULL);
  return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);
}

不同类型的Device Path

1、Hardware Device Path

描述了与一个设备关联的系统资源,比如共享内存,MMIO,IO等。具体的子类型可以参考UEFI SPEC。

2、ACPI Device Path

包含了ACPI设备ID和其它的一些内容,有_HID、_CID、_UID等ID和_ADR等其它信息。

3、Messaging Device Path

总线和协议

4、Media Device Path

表示了能够作为启动项的设备

5、BIOS Boot Specification Device Path

与前一种Media Device Path类似,不同的是它表示的是Legacy BIOS启动项设备。

Device Path操作接口

UEFI SPEC提供了一个工具接口来操作Device Path:

///
/// This protocol is used to creates and manipulates device paths and device nodes.
/// 
typedef struct {
  EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
  EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH      DuplicateDevicePath;
  EFI_DEVICE_PATH_UTILS_APPEND_PATH          AppendDevicePath;
  EFI_DEVICE_PATH_UTILS_APPEND_NODE          AppendDeviceNode;
  EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE      AppendDevicePathInstance;
  EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE    GetNextDevicePathInstance;
  EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE    IsDevicePathMultiInstance;
  EFI_DEVICE_PATH_UTILS_CREATE_NODE          CreateDeviceNode;
} EFI_DEVICE_PATH_UTILITIES_PROTOCOL;

 




相关推荐

legacy BIOS在1975年由IBM提出,现在一般使用legacy表示。 1、主要作用: (1)加电自检程序,开机时对硬件检测

遵从PI标准,分为7个阶段 SEC-&gt;PEI-&gt;DXE-&gt;BDS-&gt;TSL-&gt;RT-&gt;AL 即 安全验证-》EFI前

EDKII是一套Intel对UEFI规范实现的开源代码,可以在这个网站或github(https://gith

BIOS BIOS用于计算机硬件自检、CMOS设置、引导操作系统启动、提供硬件I/O、硬件中断等4项主要功能,因此