Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tel : 69589584 同济大学软件学院 UEFI 与固件程序设计.

Similar presentations


Presentation on theme: "Tel : 69589584 同济大学软件学院 UEFI 与固件程序设计."— Presentation transcript:

1 Tel : 69589584 Email:wang.box@163.com 同济大学软件学院 UEFI 与固件程序设计

2 Agenda Overview DXE Core DXE Dispatcher DXE Architectural Protocol DXE Services DXE Drivers

3 Boot Flow Power on Security (SEC) [.. Platform initialization.. ] Pre EFI Initialization (PEI) Driver Execution Environment (DXE) Boot Dev Select (BDS) [.... OS boot.... ] Transient System Load (TSL) Shutdown After Life (AL) Run Time (RT) ? OS-Present App Final OS Environment Final OS Boot Loader OS-Absent App Transient OS Environment Transient OS Boot Loader Boot Manager CPU Init Chipset Init Board Init verify Device, Bus, or Service Driver Exposed Platform Interface Pre Verifier EFI Driver Dispatcher Intrinsic Services security DXE IPLDXE MAIN

4 Why DXE  No DXE –BIOS features coded in proprietary fashion  ODM has to port features from IBV to IBV  Third parties can not provide value added pre OS features –Single source file controls boot flow  With DXE –Works like OS, large group of companies can write drivers –Modular systems enabled  FLASH on a plug in module to support module

5 Properties of DXE Foundation  Depends only on HOB list –State initialization passed in from PEI  No hard coded addresses in DXE –Foundation code can be loaded anywhere  No hardware specifics in DXE Foundation –Access to hardware abstracted by a set of architectural protocols (APs) –APs implemented as drivers –Only DXE Foundation may call APs –APs encapsulate CPU, chipset, board specifics

6 DXE Components  DXE Core – The main DXE executable binary responsible for dispatching drivers and provide basic services.  DXE Driver – code loaded by the core to do various initializations, produce protocols and other services.  DXE Dispatcher – The part of the DXE core that searches for and executes the drivers in the correct order.  DXE Architectural Protocols – Produced by DXE drivers to abstract DXE from hardware.  UEFI System Table – Contains pointers to all the EFI service tables, configuration tables, handle database, and console device.

7 Agenda Overview DXE Core DXE Dispatcher DXE Architectural Protocol DXE Services DXE Drivers

8 DXE Core  No hard coded addresses allowed  Single Binary for each CPU Architecture  Well specified and validated  Written in C. No assembly allowed  Consumes  HOB List  Architectural Protocols  Produces  Dispatcher  EFI Boot Services  EFI Runtime Services

9 DXE Core Block Diagram

10 DXE Core Functional Blocks DXE Core EFI Boot ServicesDXE Services DXE Dispatcher Dependency Expression Evaluator Firmware Volume Driver Firmware Volume Block Driver (Read-Only) (Memory Mapped) Section Extraction Protocol Driver Decompress Driver PE/COFF Loader Flush Instruction Cache SetJump LongJump Switch Stacks Global Coherency Domain Services Dispatcher Services Task Priority Services Memory Services Event and Timer Services Protocol Handler Services Image Services Driver Support Services HOB Parser

11 DXE Core Data Structures System Configuration Table ACPI Table UEFI System Table UEFI Boot Services Table UEFI Runtime Services Table Variable Services Real Time Clock Services Reset Services Status Code Services Virtual Memory Services Task Priority Level Services Memory Services Event and Timer Services Protocol Handler Services Image Services Driver Support Services Global Coherency Domain Services SMBIOS Table … SAL System Table Input Console Active Consoles Output Console Standard Error Console Version Information UEFI Specification Version Firmware Vendor Firmware Revision Handle Database Protocol Interface Boot Services and Structures Only available prior to OS runtime Runtime Services and Structures Available before and during OS runtime DXE Services Table Dispatcher Services DXE Services Table HOB List

12 DXE Main  Responsible for Initializing DXE Core  Consumes HOB List  Builds EFI System Table  Builds EFI Boot Services Table  Builds EFI Runtime Services Table  Builds DXE Services Table  Makes Memory-Only Boot Services Available  Hands off control to the DXE Dispatcher  Requires access to Firmware Volumes  Requires LoadImage(), StartImage(), Exit()  May require decompression service

13 DXE Core Initialization  Initialize EFI Boot Services Table  Global Variable in DXE Core  All services return EFI_NOT_AVAILABLE_YET  Initialize DXE Services Table  Global Variable in DXE Core  All services return EFI_NOT_AVAILABLE_YET  Initialize Memory-Only TPL Services  RaiseTPL(), RestoreTPL()  Initialize Memory Services (Parses HOB List)  AllocatePages(), AllocatePool(), FreePages(), FreePool()  Allocate EFI System Table  Allocated from EfiRuntimeServicesData  Allocate EFI Runtime Service Table  Allocated from EfiRuntimeServicesData  All services return EFI_NOT_AVAILABLE_YET

14 DXE Core Initialization  Initialize GCD Services (Parses HOB List)  Initialize Driver Support Services  Initialize Event Services  Initialize Protocol Services  Initialize Miscellaneous Services  Add HOB List to System Configuration Table  Part of EFI System Table  Provides other component access to HOB List  Initialize Image Services  Creates Image Handle for DXE Core itself

15 DXE Core Initialization  Create event for each Architectural Protocol  Informs DXE Core when AP is installed  Used to complete EFI Boot Services  Used to complete EFI Runtime Services  Initialize Firmware Volume Drivers  Provides file access to FVs discovered by PEI  Initialize File Decompression (Optional)  Hand control to DXE Dispatcher

16 Agenda Overview DXE Core DXE Dispatcher DXE Architectural Protocol DXE Services DXE Drivers

17 Dispatcher Goals  Resolve Execution Ordering Among DXE Drivers  Drivers may be written by different organizations  Different divisions  Different companies  Support Known Business Issues  Emergency patches  “ Control of Destiny ” for  System developer  Add-in card developer  Driver developer  Expansion Hooks for e.g. Security

18 DXE Dispatcher Model  Some of each  A Priori list of drivers to be run first  Defined by system developers  May be null  Generally implemented as pre-load dispatch queue  Requirements based dispatching for the rest  General Concept: Driver provides a list of requirements that must be met before it can be dispatched.  A syntax that gets the ordering to about 90% is ok  EFI primitives exist to do finer granularity ordering

19 Requirements  Protocols are the “ Requirements ”  Represented by their GUIDs  The fundamental primitive is  “ Does this protocol exist? ”  Hits the 90% target  Driver may have to do RequestProtocolNotify for finer granularity  “ List of Requirements ” : Boolean Expressions  Operators: And, Or, Not (&, |, !)  Special operators: Before, After  Run this driver just before or just after that one  Used for patching  Internally, stored in driver header as Postfix (RPN) for quicker processing  Tool support planned

20 DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B C Driver Execution Environment

21 DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B C TRUE Driver Execution Environment

22 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B C TRUE B C CPU_AP AND TIMER_AP FALSE Driver Execution Environment

23 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B C TRUE B C CPU_AP AND TIMER_AP FALSE B 2 CPU Architectural Protocol Driver B Initializes Driver Execution Environment

24 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B C TRUE B C CPU_AP AND TIMER_AP FALSE B 2 CPU Architectural Protocol Driver B Initializes CPU_AP TRUE Driver Execution Environment

25 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B C TRUE B C CPU_AP AND TIMER_AP FALSE B 2 CPU Architectural Protocol CPU_AP TRUE A C CPU_AP AND TIMER_AP FALSE Driver Execution Environment

26 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: CPU_AP Evaluates To: FALSE Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A TRUE CPU_AP AND TIMER_AP FALSE B 2 CPU Architectural Protocol CPU_AP TRUE C CPU_AP AND TIMER_AP FALSE A 3 Timer Architectural Protocol Driver A Initializes Driver Execution Environment

27 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE DispatcherHandle Database Dependency Expression: Evaluates To: Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B 2 CPU Architectural Protocol C A 3 Timer Architectural Protocol Driver A Initializes CPU_AP AND TIMER_AP TRUE Driver Execution Environment

28 ` DXE Foundation Dispatcher Loaded Image Protocol 1 Main Firmware Volume DXE Dispatcher Handle Database Dependency Expression: Evaluates To: Dependent: Scheduled: Initializing: Initialized: Driver B (CPU_AP) Driver A (Timer_AP) Driver C DXE Foundation A B B 2 CPU Architectural Protocol C A 3 Timer Architectural Protocol CPU_AP AND TIMER_AP TRUE C Driver C Initializes Execution Order Determined at Runtime Based on Dependencies Driver Execution Environment

29 Agenda Overview DXE Core DXE Dispatcher DXE Architectural Protocol DXE Services DXE Drivers

30 DXE – Architectural Protocols What are Architectural Protocols?  Low level protocols that support DXE APIs  Provide support for boot services and runtime services  Typically touch hardware  Only called by DXE core (directly)

31 DXE Core

32 DXE – Architectural Protocols  Boot Service APs  CPU – cache, interrupts, reset, timers  Metronome – periodic signals  Timer – event services  Boot Device Selection (BDS)  Watchdog Timer  Security  Runtime Service APs  Runtime – virtual addressing  Real Time Clock  Reset  Variable Services – nonvolatile storage access  Monotonic Counter  Status Code

33 DXE – Architectural Protocols  Some APs have dependencies on others.  Timer requires interrupts (CPU) and IO access  Watchdog timer requires timer and IO access  Reset requires CPU and IO access  Dependencies can be satisfied by using one or more of the following methods to control load order  Dependency grammar to have DXE load in the correct order  RegisterProtocolNotify() to be notified when required AP gets loaded  Apriori list – file in the file system containing list of filename GUIDs

34 DXE – Architectural Protocols Load Order CPU Timer Metronome Realtime Clock PCI I/O Abstraction Reset Watchdog Timer Variable Services Runtime Services BDS DXE CoreFDVP Status Code Security

35 DXE – Architectural Protocols  CPU APs  FlushDataCache()  EnableInterrupt()/DisableInterrupt()/GetInterruptState()  RaiseTPL() and RestoreTPL()  Init()  reset control  RegisterInterruptHandler()  Used by timer initialization  GetTimerValue()  SetMemoryAttributes()

36 DXE – Architectural Protocols  Watchdog Timer  RegisterHandler()  SetTimer()  GetTimer()  Boot Device Select (BDS)  Entry()  to hand off system to OS loader or system utility  Security  FileAuthenticationState()

37 DXE – Architectural Protocols  Real Time Clock APs  RT->GetTime()  RT->SetTime()  RT->GetWakeupTime()  RT->SetWakeupTime()  Reset APs  RT->ResetSystem() – for cold or warm system reset  Status Code  RT->ReportStatusCode()

38 Agenda Overview DXE Core DXE Dispatcher DXE Architectural Protocol DXE Services DXE Drivers

39 DXE Services  Dispatcher Services  Dispatch()  Schedule()  Trust()  Global Coherency Domain Services  Used to manage CPU visible memory resources  Used to manage CPU visible I/O resources

40 DXE GCD Services  GCD Memory Services  AddMemorySpace()  AllocateMemorySpace()  FreeMemorySpace()  RemoveMemorySpace()  GetMemorySpaceDescriptor()  SetMemorySpaceAttributes()  GetMemorySpaceMap()  GCD I/O Services  AddIoSpace()  AllocateIoSpace()  FreeIoSpace()  RemoveIoSpace()  GetIoSpaceDescriptor()  GetIoSpaceMap()

41 Agenda Overview DXE Core DXE Dispatcher DXE Architectural Protocol DXE Services DXE Drivers

42  DXE drivers are DXE Components that  Initialize the platform  Provide the services required to  boot an UEFI-compliant operating system  Or  a set of UEFI-compliant system utilities.  DXE drivers may consume  UEFI Boot Services  UEFI Runtime Services  DXE Services

43 Classification of DXE Drivers  According to Functionality  Early DXE Drivers  DXE Drivers that follow the UEFI Driver Model  According to Life Cycle  Boot service drivers  Runtime drivers

44 Early DXE Drivers  Early DXE Drivers  Basic services  Processor initialization code  Chipset initialization code  Platform initialization code  DXE Architectural Protocols  Not all services are available  Execution order depends on dependency expressions  As much initialization should be deferred to DXE drivers that follow UEFI Driver Model

45 DXE Drivers that Follow the UEFI Driver Model  DXE Drivers that follow the UEFI Driver Model  Do not touch any hardware resources when they initialize  Register a Driver Binding Protocol interface  Ultimately provide software abstraction for console devices and boot devices  Do not need to be concerned with dependency expressions  Selected by BDS


Download ppt "Tel : 69589584 同济大学软件学院 UEFI 与固件程序设计."

Similar presentations


Ads by Google