主页 > 其他  > 

UEFISpec学习笔记---9-Protocols—EFILoadedImage

UEFISpec学习笔记---9-Protocols—EFILoadedImage

本节定义EFI_LOADED_IMAGE_PROTOCOL和 EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL。这些协议分别描述了已加载到内存中的映像,并指定了PE/COFF映像通过EFI引导服务LoadImage()加载 时使用的设备路径。这些描述包括 load image 的源、映像在内存中的当前位置、为image分配的内存类型、 以及在调用image时传递给image的参数。

9.1 EFI Loaded Image Protocol

被 image handle 使用,用于获取加载的 Image 的信息。

/// /// Can be used on any image handle to obtain information about the loaded image. /// typedef struct { UINT32 Revision; ///< Defines the revision of the EFI_LOADED_IMAGE_PROTOCOL structure. ///< All future revisions will be backward compatible to the current revision. EFI_HANDLE ParentHandle; ///< Parent image's image handle. NULL if the image is loaded directly from ///< the firmware's boot manager. EFI_SYSTEM_TABLE *SystemTable; ///< the image's EFI system table pointer. // // Source location of image // EFI_HANDLE DeviceHandle; ///< The device handle that the EFI Image was loaded from. EFI_DEVICE_PATH_PROTOCOL *FilePath; ///< A pointer to the file path portion specific to DeviceHandle ///< that the EFI Image was loaded from. VOID *Reserved; ///< Reserved. DO NOT USE. // // Images load options // UINT32 LoadOptionsSize; ///< The size in bytes of LoadOptions. VOID *LoadOptions; ///< A pointer to the image's binary load options. // // Location of where image was loaded // VOID *ImageBase; ///< The base address at which the image was loaded. UINT64 ImageSize; ///< The size in bytes of the loaded image. EFI_MEMORY_TYPE ImageCodeType; ///< The memory type that the code sections were loaded as. EFI_MEMORY_TYPE ImageDataType; ///< The memory type that the data sections were loaded as. EFI_IMAGE_UNLOAD Unload; } EFI_LOADED_IMAGE_PROTOCOL;

这个EFI_LOADED_IMAGE_PROTOCOL 是在需要加载 Image 的 driver 来 install,拿 SMM driver 来举例:

在 SMM driver entry 里面会来填充对应 image 的相关信息,包括 image 的地址。

9.2 EFI Loaded Image Device Path Protocol

安装后,Loaded Image Device Path Protocol 指定通过EFI引导服务LoadImage()加载 PE/COFF映像时使用的设备路径。Loaded Image Device Path Protocol 使用与第 10 章中定义的Device Path Protocol 相同的协议接口结构,只有 GUIID 不同。

Loaded Image Device Path Protocol 必须安装到EFI引导服务loadimage()加载的PE/COFF映像的映像句柄上。

在 Boot service-->loadimage 加载 image 之前需要将这个 device patch 复制到Boot service-->loadimage;

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;
标签:

UEFISpec学习笔记---9-Protocols—EFILoadedImage由讯客互联其他栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“UEFISpec学习笔记---9-Protocols—EFILoadedImage