UEFI Framework - 8 [ DXE Basics-Foundation, Dispatching, and Drivers ]

DXE 由下面這三個compoment組成

  1. DXE Foundation
  2. DXE Dispatcher
  3. DXE Drivers 
DXE Phase 是 system 實作最多 Initial 的時後

PEI Phase會initial Permanent Memory,所以DXE code 可以被 load跟executed
在PEI Phase最後面會傳HOB 給 DXE,HOB是一個Data Structure 
DXE 跟 BDS phase 會一起工作去完成console跟booting OS


DXE Foundation



PEI 跟DXE之間的溝通

  1. DXE Foundation 只有 depends on HOB 在initial state的時後,其它都不會影響
  2. DXE Foundation(ex.PEI Phase的Service等等) 
  3. DXE Foundation不會包含Hard-coded address。因為這個原因,DXE Foundation可以在任何Physical Address中被load
  4. DXE Foundation不會包含任何的processor-specific or chipset-specific or platform-spfcific的資訊,
  5. DXE Foudation 和 DXE Drivers 透過 Achitecture Protocols 和 Motherboard 溝通( 就是Hardware)
  6. DXE Foundation 會產生EFI System table (裡面有Runtime Service 、Boot Service等等 忘記的可以看下圖)


  7. 會維護Handle Database,每個Handle由GUID命名


    Hand-Off Block (HOB)List

  1. 裡面包含了boot mode、Processor's instruction set和Firmware Device的Memory Description
  2. 裡面最重要的是描述System Memory 和Firmware Volume的HOB
  3. FV 包含了DXE Driver,DXE Dispatcher負責將這些在FV中的DXE Driver 做 load 和執行的動作


///
/// Value of version  in EFI_HOB_HANDOFF_INFO_TABLE.
/// 
#define EFI_HOB_HANDOFF_TABLE_VERSION 0x0009

///
/// 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;


PHIT (Phase HandOff Information Table)


DXE Foundation Architectural Protocols


  1. DXE Foundation 使用 DXE Architectural Protocol產生 Boot Service Table 和 Runtime Service Table。
  2. DXE Driver從FV load 出來並產生DXE Architectural Protocol。
  3. DXE Foundation 必需要有足夠的Service去load跟執行DXE Driver。
  4. HOB List裡面會描述System Momory的總數以及最少一個FV。
  5. System會保證在這個時後只會跑在單核並diable interrupt的flat Physical Mode。
  6. FV要pass給DXE Dispatcher必需要有read-only的FFS driver才能去search DXE Driver。
  7. 當有DXE Driver被找到並需要被執行的時後,會透過PE/COFF loader去load and invoke DXE Driver。
  8. EFI Boot Service 和DXE Service Table會在進入runtime phase時被free掉
  9. EFI System Table和EFI Runtime Service Table被分配在EFI Runtime Service Memory並會持續存在到OS Runtime Phase
  10. Runtime Architectural Protocol 會提供Service讓Runtime Service從Physical mode 到 Virtual Mode。

DXE Service Table

  1. GCD (Global Coherency Domain Service):管理 I/O Resource、Memory-mapped I/O Resource和System Memory Resource。可以參考/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
  2. DXE Dispatcher Service:管理被DXE Dispatcher Dispatch的DXE Driver

DXE Dispatcher Flow

  1. DXE Foundation Initial完,將控制權交給 DXE Dispatcher
  2. DXE Dispatcher從HOB List中找FV裡面的Driver
  3. 在過程中可能會有另外的FV被找到
  4. 透過priori file對新的FV進行Search (priori file有固定的name包含了DXE Driver List並且會第一個被執行到)
  5. 當DXE Driver都被load和執行後會開始跑Dependency expressions
  6. Dependency expression裡有weakly的執行順序
  7. 在DXE Driver被執行前,需要被 Security Architectural Protocol 授權
  8. 執行已經被授權的Driver
  9. 接著控制權會轉移給BDS  Architectural Protocol
  10. BDS  Architectural Protocol會建立Console Device並boot 進OS
  11. 如果 BDS  Architectural Protocol無法開始Console Device或OS,會退回DXE Dispatcher




Dependency Grammer

  1. Dispatcher可以直接看Driver的Dependency Section
  2. Dependency Section包含了Section Header,寫法需符合Dependency grammer,也就是要有opcodes和operands
  3. 裡面包含了ordering

留言

張貼留言