UEFI(2):PPI和HOB列表(PEI->DXE)
前置步调:[*]准备UEFI实验环境教程:搭建edk2编译环境
[*]UEFI官方技术参考手册
HOB(Hand-Off Block)是一个通用的布局体类型:MdePkg/Include/Pi/PiHob.h
///
/// Describes the format and size of the data inside the HOB.
/// All HOBs must contain this generic HOB header.
///
typedef struct {
///
/// Identifies the HOB data structure type.
///
UINT16 HobType;
///
/// The length in bytes of the HOB.
///
UINT16 HobLength;
///
/// This field must always be set to zero.
///
UINT32 Reserved;
} EFI_HOB_GENERIC_HEADER;
EFI_HOB_GENERIC_HEADER是所有HOB布局的通用头部,它包罗了HOB的类型、长度以及指向下一个HOB的指针
除了通用头部,具体的HOB数据布局根据HobType的差别会有差别的定义
EFI_HOB_HANDOFF_INFO_TABLE
用于描述HOB列表的起始信息,通常是第一个HOB,用于传递PEI到DXE的过渡信息:MdePkg/Include/Pi/PiHob.h
///
/// Contains general state information used by the HOB producer phase.
/// This HOB must be the first one in the HOB list.
///
typedef struct {
///
/// The HOB generic header. Header.HobType = EFI_HOB_TYPE_HANDOFF.
///
EFI_HOB_GENERIC_HEADER Header;
///
/// The version number pertaining to the PHIT HOB definition.
/// This value is four bytes in length to provide an 8-byte aligned entry
/// when it is combined with the 4-byte BootMode.
///
UINT32 Version;
///
/// The system boot mode as determined during the HOB producer phase.
///
EFI_BOOT_MODE BootMode;
///
/// The highest address location of memory that is allocated for use by the HOB producer
/// phase. This address must be 4-KB aligned to meet page restrictions of UEFI.
///
EFI_PHYSICAL_ADDRESS EfiMemoryTop;
///
/// The lowest address location of memory that is allocated for use by the HOB producer phase.
///
EFI_PHYSICAL_ADDRESS EfiMemoryBottom;
///
/// The highest address location of free memory that is currently available
/// for use by the HOB producer phase.
///
EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop;
///
/// The lowest address location of free memory that is available for use by the HOB producer phase.
///
EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom;
///
/// The end of the HOB list.
///
EFI_PHYSICAL_ADDRESS EfiEndOfHobList;
} EFI_HOB_HANDOFF_INFO_TABLE;
EFI_HOB_MEMORY_ALLOCATION
描述内存分配环境的HOB,用于报告已分配的内存范围:MdePkg/Include/Pi/PiHob.h
///
/// Describes all memory ranges used during the HOB producer
/// phase that exist outside the HOB list. This HOB type
/// describes how memory is used, not the physical attributes of memory.
///
typedef struct {
///
/// The HOB generic header. Header.HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION.
///
EFI_HOB_GENERIC_HEADER Header;
///
/// An instance of the EFI_HOB_MEMORY_ALLOCATION_HEADER that describes the
/// various attributes of the logical memory allocation.
///
EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor;
//
// Additional data pertaining to the "Name" Guid memory
// may go here.
//
} EFI_HOB_MEMORY_ALLOCATION;
EFI_HOB_GUID_TYPE
这是一个通用的HOB类型,用于存储自定义数据。它由GUID标识并携带特定数据
///
/// Allows writers of executable content in the HOB producer phase to
/// maintain and manage HOBs with specific GUID.
///
typedef struct {
///
/// The HOB generic header. Header.HobType = EFI_HOB_TYPE_GUID_EXTENSION.
///
EFI_HOB_GENERIC_HEADER Header;
///
/// A GUID that defines the contents of this HOB.
///
EFI_GUID Name;
//
// Guid specific data goes here
//
} EFI_HOB_GUID_TYPE;
每个HOB元素通过EFI_HOB_GENERIC_HEADER中的HobLength字段举行计算,找到下一个HOB的位置,停止HOB为EFI_HOB_TYPE_END_OF_HOB_LIST类型
//
// HobType of EFI_HOB_GENERIC_HEADER.
//
#define EFI_HOB_TYPE_HANDOFF 0x0001
#define EFI_HOB_TYPE_MEMORY_ALLOCATION 0x0002
#define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR0x0003
#define EFI_HOB_TYPE_GUID_EXTENSION 0x0004
#define EFI_HOB_TYPE_FV 0x0005
#define EFI_HOB_TYPE_CPU 0x0006
#define EFI_HOB_TYPE_MEMORY_POOL 0x0007
#define EFI_HOB_TYPE_FV2 0x0009
#define EFI_HOB_TYPE_LOAD_PEIM_UNUSED 0x000A
#define EFI_HOB_TYPE_UEFI_CAPSULE 0x000B
#define EFI_HOB_TYPE_FV3 0x000C
#define EFI_HOB_TYPE_UNUSED 0xFFFE
#define EFI_HOB_TYPE_END_OF_HOB_LIST 0xFFFF
在MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c中有一段代码:
/**
Main entry point to DXE Core.
@paramHobStart Pointer to the beginning of the HOB List from PEI.
@return This function should never return.
**/
VOID
EFIAPI
DxeMain (
INVOID*HobStart // 由PEI阶段传递的HOB(Handoff Block)列表开始地址
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS MemoryBaseAddress;
UINT64 MemoryLength;
PE_COFF_LOADER_IMAGE_CONTEXTImageContext;
UINTN Index;
EFI_HOB_GUID_TYPE *GuidHob;
EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
EFI_VECTOR_HANDOFF_INFO *VectorInfo;
VOID *EntryPoint;
//
// Setup the default exception handlers
//
VectorInfoList = NULL;
GuidHob = GetNextGuidHob (&gEfiVectorHandoffInfoPpiGuid, HobStart);
//
}
此处的gEfiVectorHandoffInfoPpiGuid位置:MdePkg/MdePkg.dec
## Include/Ppi/VectorHandoffInfo.h
gEfiVectorHandoffInfoPpiGuid = { 0x3cd652b4, 0x6d33, 0x4dce, { 0x89, 0xdb, 0x83, 0xdf, 0x97, 0x66, 0xfc, 0xca }}
由此可知,gEfiVectorHandoffInfoPpiGuid为PPI GUID,PPI接口头文件路径:Include/Ppi/VectorHandoffInfo.h
在MdePkg/Include/Ppi/VectorHandoffInfo.h举行访问该PPI GUID
extern EFI_GUIDgEfiVectorHandoffInfoPpiGuid;
在其中检察该PPI接口:MdePkg/Include/Ppi/VectorHandoffInfo.h
///
/// EFI_VECTOR_HANDOFF_INFO entries that describes the interrupt and/or
/// exception vectors in use in the PEI Phase.
///
typedef struct {
//
// The interrupt or exception vector that is in use and must be preserved.
//
UINT32 VectorNumber;
//
// A bitmask that describes the attributes of the interrupt or exception vector.
//
UINT32 Attribute;
//
// The GUID identifies the party who created the entry. For the
// EFI_VECTOR_HANDOFF_DO_NOT_HOOK case, this establishes the single owner.
//
EFI_GUID Owner;
} EFI_VECTOR_HANDOFF_INFO;
///
/// Provides a description of the interrupt and/or exception vectors that
/// were established in the SEC Phase and need to persist into PEI and DXE.
///
typedef struct _EFI_PEI_VECTOR_HANDOFF_INFO_PPI {
//
// Pointer to an array of interrupt and /or exception vectors.
//
EFI_VECTOR_HANDOFF_INFO *Info;
} EFI_PEI_VECTOR_HANDOFF_INFO_PPI;
EFI_PEI_VECTOR_HANDOFF_INFO_PPI的作用为:将向量表信息从PEI阶段传递到DXE阶段,用于在差别固件阶段之间传递与中断向量干系的信息
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]