- FD(Firmware Device):一個實際的Device,能用來存放Firmware(EX:HDD)
- FV(Firmware Volume):一個Logically的partition(EX:C:\ D:\)
- FF(Firmware File):每個File需要有一個GUID儲存在FV中
- Section:FFS允許每個File裡分成不同的Section(有很多不同類型的Section)
Design
Constraints
- Boot Vector:指向一個Fixed Address 的Firmware Device(EX:FD0)
- Alignment:Data 放置在File中的一個特定位置
- Easy Access:File必需要simple enoough在PEI Phase的時後被located以及read,不需要被雜的計算或是複雜的Data Structure
- Rare Writes:在EFI,最常做write動作的會是在power on或是runtime的時後,並會專注在Variable上
- Flash Headaches:可以看下圖,主要是在講現在Internal Fragmentation 沒有被完全使用,會造成使用上沒有效率。
- Bank Switching:在Flash裡面的資料不會永遠呈現線性,會在不同的區塊間進行儲存,但對應到一塊System Address Space(EX:像Memory Mapping的時後,會有這種狀況發生)
- Fault Tolerance:在FV0中如果少了任何一個file,都會使得system 死掉,因此File Level falut tolerance是不被滿足的,但是Volume-level fault tolerance是必需的。有兩種algorithm能夠達到 Fault Tolerance update
- Dual Image Update
- Top Swap Update
- to File or not To File:要在同一個FD 中Support EFI Variables使它當作一個file system不需要在Firmware Volume中包含Variable Storage
File Type
- Freeform:內部有包含section的file
- Raw:只是一團的binary data
Section Type
- Common Encapsulation Section Type
- Compression Section:裡面能compress包住的Section,在compression header有說明如何找到對應的protocol去Uncompress content.
- GUIDed section:指定一個section的protocol
- Common Leaf Section Type
- 可以被支援並執行的mats(PE32+ image、PIC Image等等)
- Version 和 File name section
- Firmware Volume Image
How the Dispatcher use Volumes , Files and Sections
DXE Dispatcher最主要的任務是find 和dispatch drivers。
PEI Phase會提供HOB給 DXE Foundation ,當DXE Initialize 完之後會透過HOB找到Volume(這在之後會說明到)。
任一個FV在system中是被表示成一個protocol。
DXE Dispatcher 會用 Firmware Volume Protocol找到 Volume 中型態為DXE Driver的file ,當找到後,會讀取Dependency expression section以排列driver order。
當確定要dispatch這隻Driver後,它會read PE/COFF Image Section以利後面的執行。
執行的流程如下圖所示
Internal Format
Basic Format:告訢system如何access其它的file system(Framework File System Format ,FFS)
// // FFS File State Bits. // #define EFI_FILE_HEADER_CONSTRUCTION 0x01 #define EFI_FILE_HEADER_VALID 0x02 #define EFI_FILE_DATA_VALID 0x04 #define EFI_FILE_MARKED_FOR_UPDATE 0x08 #define EFI_FILE_DELETED 0x10 #define EFI_FILE_HEADER_INVALID 0x20 #define EFI_FILE_ALL_STATE_BITS (EFI_FILE_HEADER_CONSTRUCTION | \ EFI_FILE_HEADER_VALID | \ EFI_FILE_DATA_VALID | \ EFI_FILE_MARKED_FOR_UPDATE | \ EFI_FILE_DELETED | \ EFI_FILE_HEADER_INVALID \ ) // // Each file begins with the header that describe the // contents and state of the files. // typedef struct { EFI_GUID Name; EFI_FFS_INTEGRITY_CHECK IntegrityCheck; EFI_FV_FILETYPE Type; EFI_FFS_FILE_ATTRIBUTES Attributes; UINT8 Size[3]; EFI_FFS_FILE_STATE State; } EFI_FFS_FILE_HEADER;
Managing FV
File 在Voluem中會從lowest Address開始分配,當一個File被delete的時後,並不是真的erase掉,而是設定bit,讓它暫時看不見
Below The File System
Variables
EFI Variables 取名會帶著GUID 和 Unicode name
這篇有提到一些有關Variable的資訊
Capsules
是一個機制,讓OS提供data讓下次pre-boot的時後使用(通常用來update Firmware)。
裡面包含了許多的Header以及FV。
留言
張貼留言