UEFI实战HII之涉及数据结构

Posted jiangwei0512

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UEFI实战HII之涉及数据结构相关的知识,希望对你有一定的参考价值。

EFI_HII_PACKAGE_HEADER

HII中的资源有不同的类型,由Package表示,有如下的值:

  • Font Package
  • Simplified Font Package
  • String Package
  • Image Package
  • Device Path Package
  • keyboard Layout Package
  • GUID Package
  • Forms Package
  • Animation Pacakge

Packge有一个通用的头部结构体:

///
/// The header found at the start of each package.
///
typedef struct 
  UINT32  Length:24;
  UINT32  Type:8;
  // UINT8  Data[...];
 EFI_HII_PACKAGE_HEADER;

它是一个不定结构体,头部包含长度和类型,后者有如下的值,与前面提到的Package类型大致一致:

//
// Value of HII package type
//
#define EFI_HII_PACKAGE_TYPE_ALL             0x00
#define EFI_HII_PACKAGE_TYPE_GUID            0x01
#define EFI_HII_PACKAGE_FORMS                0x02
#define EFI_HII_PACKAGE_STRINGS              0x04
#define EFI_HII_PACKAGE_FONTS                0x05
#define EFI_HII_PACKAGE_IMAGES               0x06
#define EFI_HII_PACKAGE_SIMPLE_FONTS         0x07
#define EFI_HII_PACKAGE_DEVICE_PATH          0x08
#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT      0x09
#define EFI_HII_PACKAGE_ANIMATIONS           0x0A
#define EFI_HII_PACKAGE_END                  0xDF
#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN    0xE0
#define EFI_HII_PACKAGE_TYPE_SYSTEM_END      0xFF

其中包含的宏还有些不同真正的Package类型,而是有特定的用处:

EFI_HII_PACKAGE_TYPE_ALL:伪Package,用于导出Package列表时使用,具体可以参考ExportPackageList()

EFI_HII_PACKAGE_END:用于标识Package列表尾部;

EFI_HII_PACKAGE_TYPE_SYSTEM_BEGINEFI_HII_PACKAGE_TYPE_SYSTEM_END:保留项。

EFI_HII_PACKAGE_LIST_HEADER

一系列Package组成的Package列表包含一个头部,其结构如下:

///
/// The header found at the start of each package list.
///
typedef struct 
  EFI_GUID               PackageListGuid;
  UINT32                 PackageLength;
 EFI_HII_PACKAGE_LIST_HEADER;

各类Package的头部

这些结构体都可以在MdePkg\\Include\\Uefi\\UefiInternalFormRepresentation.h中找到,且每种Package都有关联的其它结构体或者枚举等类型,这里不列出。

Simplified Font Package:

///
/// A simplified font package consists of a font header
/// followed by a series of glyph structures.
///
typedef struct _EFI_HII_SIMPLE_FONT_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER Header;
  UINT16                 NumberOfNarrowGlyphs;
  UINT16                 NumberOfWideGlyphs;
  // EFI_NARROW_GLYPH       NarrowGlyphs[];
  // EFI_WIDE_GLYPH         WideGlyphs[];
 EFI_HII_SIMPLE_FONT_PACKAGE_HDR;

Font Package:

///
/// The fixed header consists of a standard record header,
/// then the character values in this section, the flags
/// (including the encoding method) and the offsets of the glyph
/// information, the glyph bitmaps and the character map.
///
typedef struct _EFI_HII_FONT_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER Header;
  UINT32                 HdrSize;
  UINT32                 GlyphBlockOffset;
  EFI_HII_GLYPH_INFO     Cell;
  EFI_HII_FONT_STYLE     FontStyle;
  CHAR16                 FontFamily[1];
 EFI_HII_FONT_PACKAGE_HDR;

Device Path Package:

///
/// The device path package is used to carry a device path
/// associated with the package list.
///
typedef struct _EFI_HII_DEVICE_PATH_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER   Header;
  // EFI_DEVICE_PATH_PROTOCOL DevicePath[];
 EFI_HII_DEVICE_PATH_PACKAGE_HDR;

GUID Package:

///
/// The GUID package is used to carry data where the format is defined by a GUID.
///
typedef struct _EFI_HII_GUID_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER  Header;
  EFI_GUID                Guid;
  // Data per GUID definition may follow
 EFI_HII_GUID_PACKAGE_HDR;

String Package:

///
/// The fixed header consists of a standard record header and then the string identifiers
/// contained in this section and the offsets of the string and language information.
///
typedef struct _EFI_HII_STRING_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER  Header;
  UINT32                  HdrSize;
  UINT32                  StringInfoOffset;
  CHAR16                  LanguageWindow[16];
  EFI_STRING_ID           LanguageName;
  CHAR8                   Language[1];
 EFI_HII_STRING_PACKAGE_HDR;

Image Package:

typedef struct _EFI_HII_IMAGE_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER  Header;
  UINT32                  ImageInfoOffset;
  UINT32                  PaletteInfoOffset;
 EFI_HII_IMAGE_PACKAGE_HDR;

Forms Package:

///
/// The Form package is used to carry form-based encoding data.
///
typedef struct _EFI_HII_FORM_PACKAGE_HDR 
  EFI_HII_PACKAGE_HEADER       Header;
  // EFI_IFR_OP_HEADER         OpCodeHeader;
  // More op-codes follow
 EFI_HII_FORM_PACKAGE_HDR;

Keyboard Package:

typedef struct 
  EFI_HII_PACKAGE_HEADER  Header;
  UINT16                  LayoutCount;
  // EFI_HII_KEYBOARD_LAYOUT Layout[];
 EFI_HII_KEYBOARD_PACKAGE_HDR;

Animations Package:

///
/// HII animation package header.
///
typedef struct _EFI_HII_ANIMATION_PACKAGE_HDR 
  ///
  /// Standard package header, where Header.Type = EFI_HII_PACKAGE_ANIMATIONS.
  ///
  EFI_HII_PACKAGE_HEADER  Header;
  ///
  /// Offset, relative to this header, of the animation information. If
  /// this is zero, then there are no animation sequences in the package.
  ///
  UINT32                  AnimationInfoOffset;
 EFI_HII_ANIMATION_PACKAGE_HDR;

头部之后的内容不同的类型有不同的值,后续介绍到具体类型时再详细说明。

以上是关于UEFI实战HII之涉及数据结构的主要内容,如果未能解决你的问题,请参考以下文章

UEFI实战HII之涉及模块

UEFI实战HII之涉及模块

UEFI实战HII之涉及Protocols

UEFI实战HII之涉及Protocols

UEFI实战HII之vfr文件

UEFI实战HII之vfr文件