==============================
敬请关注:“固件C字营
==============================
UEFI固件一般存储在被称之为“固件仓库”的非易失性存储器中,简称为FD(固件设备),当前主流的存储介质是NorFlash它拥有非易失性、XIP以及可二次编程的特性。
固件设备可以分为物理设备和逻辑设备,一个NorFlash固件设备可以被划分为多个逻辑设备FV(Firmware Volume),同理多个物理固件设备也可以组成更大的逻辑设备,FV是最基本的“固件设备”管理单元,被称之为FFS(Firmware File System)。FV以唯一的GUID来区分,同时它会有不同的类型如FFS2或FFS3,以及对其读写控制的其他的属性。FD组织方式是:Section->Firmware File->FV->FD,下文分别介绍。
Firmware File:用来存储代码或数据,在FV当中它是由GUID来唯一命名,具有文件类型、存储对齐方式、文件大小等属性。UEFI提供了基本的服务来访问Fireware File,在PEI阶段用EFI_PEI_SERVICES->(FfsFindNextFile, FfsFindFileByName、FfsGetFileInfo),在DXE阶段用EFI_FIRMWARE_VOLUME2_PROTOCOL->(ReadFile, ReadSection、WriteFile、GetNextFile), 或EFI_BOOT_SERVICES->LoadImage()。
Firmware File Section:组成Firmware File的最小单元,由2个最基本的属性,一个是类型,另一个是所占用的存储空间大小。UEFI提供了基本的服务来访问Fireware File Section,在PEI阶段用EFI_PEI_SERVICES->FfsFindSectionData,在DXE阶段用EFI_FIRMWARE_VOLUME2_PROTOCOL->ReadSection
FFS PI Firmware File Types:
PI File Type | Value | Mnemonic |
EFI_FV_FILETYPE_RAW | 0x01 | Binary data |
EFI_FV_FILETYPE_FREEFORM | 0x02 | Sectioned data |
EFI_FV_FILETYPE_SECURITY_CORE | 0x03 | Platform core code used during the SEC phase |
EFI_FV_FILETYPE_PEI_CORE | 0x04 | PEI Foundation |
EFI_FV_FILETYPE_DXE_CORE | 0x05 | DXE Foundation |
EFI_FV_FILETYPE_PEIM | 0x06 | PEI module (PEIM) |
EFI_FV_FILETYPE_DRIVER | 0x07 | DXE driver |
EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER | 0x08 | Combined PEIM/DXE driver |
EFI_FV_FILETYPE_APPLICATION | 0x09 | Application |
EFI_FV_FILETYPE_MM | 0x0A | Contains a PE32+ image that will be loaded into MMRAM in MM Traditional Mode. |
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE | 0x0B | Firmware volume image |
EFI_FV_FILETYPE_COMBINED_MM_DXE | 0x0C | Contains PE32+ image that will be dispatched by the DXE Dispatcher and will also be loaded into MMRAM in MM Tradition Mode. |
EFI_FV_FILETYPE_MM_CORE | 0x0D | MM Foundation that support MM Traditional Mode |
EFI_FV_FILETYPE_MM_STANDALONE | 0x0E | Contains a PE32+ image that will be loaded into MMRAM in MM Standalone Mode. |
EFI_FV_FILETYPE_MM_CORE_STANDALONE | 0x0F | MM Foundation that support MM Tradition Mode and MM Standalone Mode |
EFI_FV_FILETYPE_OEM_MIN… EFI_FV_FILETYPE_OEM_MAX | 0xC0-0xDF | OEM File Types |
EFI_FV_FILETYPE_DEBUG_MIN… EFI_FV_FILETYPE_DEBUG_MAX | 0xE0- 0xEF | Debug/Test File Types |
EFI_FV_FILETYPE_FFS_MIN… EFI_FV_FILETYPE_FFS_MAX | 0xF0- 0xFF | Firmware File System Specific File Types |
EFI_FV_FILETYPE_FFS_PAD | 0xF0 | Pad File For FFS |
FFS PI Section Types:
PI Section Type | Value | Mnemonic |
EFI_SECTION_COMPRESSION | 0x01 | Encapsulation section where other sections are compressed |
EFI_SECTION_GUID_DEFINED | 0x02 | Encapsulation section where other sections have format defined by a GUID |
EFI_SECTION_DISPOSABLE | 0x03 | Encapsulation section used during the build process but not required for execution |
EFI_SECTION_PE32 | 0x10 | PE32+ Executable image. |
EFI_SECTION_PIC | 0x11 | Position-Independent Code |
EFI_SECTION_TE | 0x12 | Terse Executable image |
EFI_SECTION_DXE_DEPEX | 0x13 | DXE Dependency Expression |
EFI_SECTION_VERSION | 0x14 | Version, Text and Numeric. |
EFI_SECTION_USER_INTERFACE | 0x15 | User-Friendly name of the driver |
EFI_SECTION_COMPATIBILITY16 | 0x16 | DOS-style 16-bit EXE |
EFI_SECTION_FIRMWARE_VOLUME_IMAGE | 0x17 | PI Firmware Volume image |
EFI_SECTION_FREEFORM_SUBTYPE_GUID | 0x18 | Raw data with GUID in header to define format |
EFI_SECTION_RAW | 0x19 | Raw data |
EFI_SECTION_PEI_DEPEX | 0x1b | PEI Dependency Expression |
EFI_SECTION_MM_DEPEX | 0x1c | Leaf section type for determining the dispatch order for an MM Traditional driver in MM Traditional Mode or MM Standaline driver in MM Standalone Mode |
更多导读,尽情期待!
==============================
敬请猛戳下面链接,关注&转发
敬请关注:“固件C字营”
点击左下角“分享”,快乐更多人
==============================