bloggerads

2015年6月19日 星期五

UEFI : PEI Phase Code Trace

$ PEI (Pre Efi Initialization)的概述:

● Small, tight startup code
• Startup with transitory memory store for call-stack (I.e., cache)       
• XIP from ROM
● Core locates, validates, and dispatches PEIMs

● Publishes own protocol and call-abstraction with PPI
• Silicon/platform abstractions
● Primary goals
• Discover boot mode       
• Launch modules that initialize main memory       
• Discovery & launch DXE core- Convey platform info into DXE

2015年6月16日 星期二

UEFI : SEC Phase Code Trace

UEFI 架構只有SEC這個phase因為是machine dependent而且cache/memory尚未初始化,所以剛開始是組合語言寫的,最主要就是做以下這幾件事:
  1. 切32位元(或64位元)flat mode
  2. Cache As Ram (在Flat32.asm中jump到CacheAsRam函數的位址)
  3. 找BFV(Boot Firmware Volume), BFV指的是存放PEI Foundation/PEIMs的FV
  4. 找到以C寫的SEC phase entry point
  5. 跳到以C code寫的SEC point (SecStartup),最後Transfer the control to the PEI core
VOID
EFIAPI
SecStartup (
  IN UINT32    SizeOfRam,
  IN UINT32    TempRamBase,
  IN VOID      *BootFirmwareVolume
  )
{
   ...
}


從上電的reset vector, trace Code如下:

進入點為 UefiCpuPkg\ResetVector\Vtf0\Ia16\ResetVectorVtf0.asm


;; Reset Vector
;
; This is where the processor will begin execution
;
    nop
    nop
    jmp     short EarlyBspInitReal16