原 UEFI中DXE階段概總

 

 

------------------------------------------MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c

  1. // Setup the default exception handlers
  2. // Initialize Debug Agent to support source level debug in DXE phase
  3. // Initialize Memory Services
  4. // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
  5. // Start the Image Services.
  6. // Initialize the Global Coherency Domain Services
  7. // Call constructor for all libraries
  8. // Report DXE Core image information to the PE/COFF Extra Action Library
  9. // Install the DXE Services Table into the EFI System Tables's Configuration Table
  10. // Install the HOB List into the EFI System Tables's Configuration Table
  11. // Install Memory Type Information Table into the EFI System Tables's Configuration Table
  12.   // If Loading modules At fixed address feature is enabled, install Load moduels at fixed address Configuration Table so that user could easily to retrieve the top address to load Dxe and PEI Code and Tseg base to load SMM driver.
  13. // Report Status Code here for DXE_ENTRY_POINT once it is available
  14.   // Create the aligned system table pointer structure that is used by external debuggers to locate the system table...  Also, install debug image info configuration table.
  15. // Initialize the Event Services
  16.   // Get persisted vector hand-off info from GUIDeed HOB again due to HobStart may be updated, and install configuration table
  17. // Publish the EFI, Tiano, and Custom Decompress protocols for use by other DXE components
  18.   // Register for the GUIDs of the Architectural Protocols, so the rest of the  EFI Boot Services and EFI Runtime Services tables can be filled in. Also register for the GUIDs of optional protocols.
  19. // Produce Firmware Volume Protocols, one for each FV in the HOB list.
  20. // Produce the Section Extraction Protocol
  21. // Initialize the DXE Dispatcher
  22. // Invoke the DXE Dispatcher
  23. // Display Architectural protocols that were not loaded if this is DEBUG build
  24. // Display any drivers that were not dispatched because dependency expression evaluated to false if this is a debug build
  25. // Assert if the Architectural Protocols are not present.
  26. // Report Status code before transfer control to BDS
  27. // Transfer control to the BDS Architectural Protocol
  28. // BDS should never return

 

  1. //設置默認異常處理程序
  2. //初始化調試代理以支持DXE階段的源級調試
  3. //初始化內存服務
  4. //從EfiRuntimeServicesData中分配EFI系統表和EFI運行時服務表,使用模板初始化EFI系統表和EFI運行時服務表的內容
  5. //啓動映像服務。
  6. //初始化全局一致性域服務
  7. //調用所有庫的構造函數
  8. //將DXE核心映像信息報告給PE/COFF額外動作庫
  9. //將DXE服務表安裝到EFI系統表的配置表中
  10. //將HOB列表安裝到EFI系統表的配置表中
  11. //將內存類型信息表安裝到EFI系統表的配置表中
  12. //如果啓用了固定地址加載模塊功能,則在固定地址配置表中安裝加載模塊,以便用戶能夠輕鬆檢索到要加載Dxe和PEI代碼的頂層地址,以及要加載SMM驅動程序的Tseg base。
  13. // DXE_ENTRY_POINT一旦可用,就在這裏報告狀態代碼
  14. //創建對齊的系統表指針結構,用於外部調試器定位系統表…另外,安裝調試映像信息配置表。
  15. //初始化事件服務
  16. //由於HobStart的原因,再次從GUIDeed HOB獲取持久化的矢量傳遞信息,並安裝配置表
  17. //發佈EFI、Tiano和自定義解壓協議,供其他DXE組件使用
  18. //註冊體系結構協議的guid,以便填充EFI引導服務和EFI運行時服務表的其餘部分。還可以註冊可選協議的guid。
  19. //爲HOB列表中的每個FV生成固件卷協議。
  20. //生成切片提取協議
  21. //初始化DXE調度程序
  22. //調用DXE調度程序
  23. //如果這是調試構建,則顯示未加載的體系結構協議
  24. //如果這是一個調試構建,則顯示由於依賴關係表達式被計算爲false而沒有被分派的驅動程序
  25. //如果不存在體系結構協議,則斷言。
  26. //在將控制轉移到BDS之前報告狀態碼
  27. //將控制轉移到BDS體系結構協議
  28. //北斗不應該再回來

 

------------------------------------MdePkg/Include/Pi/PiDxeCis.h
/// EFI System Table
typedef struct {
  EFI_TABLE_HEADER     Hdr;  ///EFI系統表的表頭。
typedef struct {
  UINT64  Signature; ///一個64位簽名,用於標識下面的表的類型。已經爲EFI系統表、EFI引導服務表和EFI運行時服務表生成了惟一的簽名。         
  UINT32  Revision;  ///本表所符合的EFI規範的修訂。該字段的上16位包含主要修訂值,下16位包含次要修訂值。次要的修訂值被限制在00..99的範圍內。
  UINT32  HeaderSize;///包括EFI_TABLE_HEADER在內的整個表的大小(以字節爲單位)。
  UINT32  CRC32;///整個表的32位CRC。該值的計算方法是將該字段設置爲0,並計算HeaderSize字節的32位CRC。
  UINT32  Reserved; ///保留字段,必須設置爲0。                                                                                                                                                    
} EFI_TABLE_HEADER;
 
  CHAR16               *FirmwareVendor;    ///指向空終止字符串的指針,該字符串標識爲平臺生產系統固件的供應商。
  UINT32               FirmwareRevision;  ///固件供應商指定的值,用於標識平臺系統固件的修訂。
  EFI_HANDLE           ConsoleInHandle;  ///活動控制檯輸入設備的句柄。這個句柄必須支持EFI_SIMPLE_TEXT_INPUT_PROTOCOL和EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL。
  EFI_SIMPLE_TEXT_INPUT_PROTOCOL    *ConIn;  ///指向與ConsoleInHandle關聯的EFI_SIMPLE_TEXT_INPUT_PROTOCOL接口的指針。
  EFI_HANDLE                        ConsoleOutHandle;  ///活動控制檯輸出設備的句柄。
  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut;///指向與ConsoleOutHandle關聯的EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL接口的指針。
  EFI_HANDLE                        StandardErrorHandle;   ///活動標準錯誤控制檯設備的句柄。這個句柄必須支持EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL。
  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *StdErr;///指向與standard derrorhandle關聯的EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL接口的指針。
  EFI_RUNTIME_SERVICES              *RuntimeServices;//指向EFI運行時服務表的指針。
  EFI_BOOT_SERVICES                 *BootServices;///指向EFI引導服務表的指針。
  UINTN                             NumberOfTableEntries;        ///緩衝區configuration表中系統配置表的數量。
  EFI_CONFIGURATION_TABLE           *ConfigurationTable; //指向系統配置表的指針。表中的條目數是NumberOfTableEntries。
} EFI_SYSTEM_TABLE;   


------------------------------------MdePkg/Include/Pi/PiDxeCis.h
typedef struct {
  /// The table header for the DXE Services Table.This header contains the DXE_SERVICES_SIGNATURE and DXE_SERVICES_REVISION values.
  EFI_TABLE_HEADER                Hdr;

  // Global Coherency Domain Services
  EFI_ADD_MEMORY_SPACE            AddMemorySpace;
  EFI_ALLOCATE_MEMORY_SPACE       AllocateMemorySpace;
  EFI_FREE_MEMORY_SPACE           FreeMemorySpace;
  EFI_REMOVE_MEMORY_SPACE         RemoveMemorySpace;
  EFI_GET_MEMORY_SPACE_DESCRIPTOR GetMemorySpaceDescriptor;
  EFI_SET_MEMORY_SPACE_ATTRIBUTES SetMemorySpaceAttributes;
  EFI_GET_MEMORY_SPACE_MAP        GetMemorySpaceMap;
  EFI_ADD_IO_SPACE                AddIoSpace;
  EFI_ALLOCATE_IO_SPACE           AllocateIoSpace;
  EFI_FREE_IO_SPACE               FreeIoSpace;
  EFI_REMOVE_IO_SPACE             RemoveIoSpace;
  EFI_GET_IO_SPACE_DESCRIPTOR     GetIoSpaceDescriptor;
  EFI_GET_IO_SPACE_MAP            GetIoSpaceMap;

  // Dispatcher Services
  EFI_DISPATCH                    Dispatch;                                                                                                                                                   
  EFI_SCHEDULE                    Schedule;
  EFI_TRUST                       Trust;

  // Service to process a single firmware volume found in a capsule
  EFI_PROCESS_FIRMWARE_VOLUME     ProcessFirmwareVolume;

  // Extensions to Global Coherency Domain Services
  EFI_SET_MEMORY_SPACE_CAPABILITIES SetMemorySpaceCapabilities;
} DXE_SERVICES;


------------------MdePkg/Include/Uefi/UefiSpec.h
/// EFI Runtime Services Table.
typedef struct {
  /// The table header for the EFI Runtime Services Table. EFI運行時服務表的表頭。
  EFI_TABLE_HEADER                Hdr;

  // Time Services       時間服務
  EFI_GET_TIME                    GetTime;
  EFI_SET_TIME                    SetTime;
  EFI_GET_WAKEUP_TIME             GetWakeupTime;
  EFI_SET_WAKEUP_TIME             SetWakeupTime;

  // Virtual Memory Services  虛擬內存服務
  EFI_SET_VIRTUAL_ADDRESS_MAP     SetVirtualAddressMap;
  EFI_CONVERT_POINTER             ConvertPointer;

  // Variable Services     變量服務
  EFI_GET_VARIABLE                GetVariable;
  EFI_GET_NEXT_VARIABLE_NAME      GetNextVariableName;
  EFI_SET_VARIABLE                SetVariable;

  // Miscellaneous Services  各種各樣的服務
  EFI_GET_NEXT_HIGH_MONO_COUNT    GetNextHighMonotonicCount;
  EFI_RESET_SYSTEM                ResetSystem;

  // UEFI 2.0 Capsule Services UEFI 2.0服務
  EFI_QUERY_VARIABLE_INFO         QueryVariableInfo;
} EFI_RUNTIME_SERVICES;

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章