UEFI-Lessons
UEFI-Lessons copied to clipboard
Lessons to get to know UEFI programming in Linux with the help of EDKII
These series of lessons are intendend to get you started with UEFI programming in Linux with the help of EDKII.
Content
- Lesson 00: Getting started guide for EDKII. Compile OVMF and run it in QEMU
- Lesson 01: Create a simplest app and run it in OVMF
- Lesson 02: Create a simplest package
- Lesson 03: Create
HelloWorldapp with the help of SystemTable services - Lesson 04: Use edk2 libraries to simplify our
HelloWorldapp - Lesson 05: Simplify build command with the help of files in the
Conffolder - Lesson 06: Handle/Protocol databases internals - Part 1: Theory and raw access to an app ImageHandle
- Lesson 07: Handle/Protocol databases internals - Part 2: Raw access to app protocols
- Lesson 08:
HandleProtocolAPI function. Information from theImageHandleprotocols - Lesson 09: Get ImageHandle protocols with the
ProtocolsPerHandleAPI function - Lesson 10:
EFI_STATUStype andEFI_ERRORmacros - Lesson 11: Get EFI memory map information
- Lesson 12:
EFI_SHELL_PARAMETERS_PROTOCOL. Transform our EFI memory map to the Linux kernel style - Lesson 13:
ShellAppMainentry point - Lesson 14: Get all variable names and GUIDs with the
gRT->GetNextVariableNameAPI - Lesson 15: Get and parse boot variables (BootOrder/BootCurrent/BootXXXX) with the
gRT->GetVariableAPI - Lesson 16: Build our own boot option inside OVMF image similar to the UEFI shell app
- Lesson 17: Add
WaitForEventfunction to our boot option app to see its output on booting - Lesson 18: Handle input from user with the
ReadKeyStrokefunction - Lesson 19: Boot option modification with the help of
bcfgcommand - Lesson 20: Intro to Platfrom Configuration Database (PCD). Declare and get simple fixed PCD
- Lesson 21: Override order for PCD variables
- Lesson 22: Feature flag PCD and its comparision to BOOLEAN fixed at build PCD
- Lesson 23: PatchableInModule PCDs and how they can be changed via
GenPatchPcdTable/PatchPcdValueutilities - Lesson 24: Dynamic/DynamicEx PCDs
- Lesson 25: More on PCDs
- Lesson 26: Tables referenced in
EFI_CONFIGURATION_TABLE - Lesson 27: Get SMBIOS information with
dmem/EFI_SMBIOS_PROTOCOL/smbiosview - Lesson 28: Get ACPI tables and save them to files with a help of
EFI_SHELL_PROTOCOL - Lesson 29: Use
EFI_ACPI_SDT_PROTOCOLandShellLibto save a BMP image from the ACPI BGRT table - Lesson 30: Find all PCI root bridges in the system with a help of
LocateHandleBuffer/OpenProtocolfunctions and useEFI_PCI_ROOT_BRIDGE_IO_PROTOCOLto get all PCI functions in the system - Lesson 31: Search
pci.idsdatabase to get PCI Vendor/Device information with a help ofShellLib/PrintLibfunctions - Lesson 32: Show PCI Option ROM images with the help of
EFI_PCI_IO_PROTOCOLprotocol - Lesson 33: Use
EfiRomutility for parsing and creation of PCI Option ROM images - Lesson 34: Create a simple UEFI driver. Use
load/unloadUEFI shell commands to work with a driver image - Lesson 35: Create a simple library and use it in an app
- Lesson 36: Library constructor and destructor.
NULLlibraries - Lesson 37: Investigate ways how to add
acpiviewcommand functionality to your shell - Lesson 38: Create and use your custom protocol.
InstallMultipleProtocolInterfacesandUninstallMultipleProtocolInterfacesfunctions - Lesson 39: Create a driver that adds hot key functionality with a help of
RegisterKeyNotify/UnregisterKeyNotifyfunctions - Lesson 40:
Key####NVRAM variables - Lesson 41:
DEBUGprint statement internals.EFI_D_*log levels and all the PCDs for theDEBUGstatement control. Getting and parsing OVMF boot log - Lesson 42: Debug your drivers/applications and OVMF itself with GDB
- Lesson 43: Intro to the HII. Create an application to display HII database content
- Lesson 44: HII database internals
- Lesson 45: Use
NewPackageListfrom theEFI_HII_DATABASE_PROTOCOLdirectly to publish HII Package list with Strings packages. Part 1: Investigate common aspects of Package List data generation - Lesson 46: Use
NewPackageListfrom theEFI_HII_DATABASE_PROTOCOLdirectly to publish HII Package list with Strings packages. Part 2: String Packages data generation - Lesson 47: Use
NewPackageListfrom theEFI_HII_DATABASE_PROTOCOLdirectly to publish HII Package list with Strings packages. Part 3: Combine everything together. UseNewPackageListandGetStringprotocol functions - Lesson 48: Use
UNIfiles andHiiLibto publish and work with HII String packages - Lesson 49: UNI files declared with the help of
MODULE_UNI_FILE/PACKAGE_UNI_FILE/[UserExtensions.TianoCore."ExtraFiles"] - Lesson 50: Use
UEFI_HII_RESOURCE_SECTIONto publish HII Package list with Strings packages - Lesson 51: Add manual to UEFI application. How
-?andhelpwork in shell.EFI_SHELL_GET_HELP_TEXTfunction from theEFI_SHELL_PROTOCOL - Lesson 52: Add Russian font - Part 1: investigate
EFI_NARROW_GLYPH/EFI_WIDE_GLYPHformat, construct glyph array from the *.woff font file - Lesson 53: Add Russian font - Part 2: construct
EFI_HII_SIMPLE_FONT_PACKAGEand populate it to the HII database - Lesson 54: Use
NewStringandSetStringfunctions from theEFI_HII_STRING_PROTOCOLto add String Package for another language dynamically - Lesson 55: Try to modify
PlatformLangCodesEFI variable and add another language dynamically. Variable protection with a help ofEDKII_VARIABLE_POLICY_PROTOCOL - Lesson 56: How to get module
FILE_GUIDandBASE_NAMEin code. Autoconf variablesgEfiCallerIdGuid/gEdkiiDscPlatformGuid/gEfiCallerBaseName - Lesson 57: Use VFR to create a simple form and display it with a help of
EFI_FORM_BROWSER2_PROTOCOL.SendForm(). IFR data investigation - Lesson 58:
subtitleandtextVFR elements - Lesson 59: Create an application to display HII Forms by package list GUIDs. Convert our simple form application to UEFI driver form
- Lesson 60: Use
gRT->SetVariable()function to create and delete UEFI variables. Investigate variable attributes. Practical uses of thedmpstorecommand - Lesson 61: Use
dmpstorecommand to save/load variables to/from files. Write an application to recalculate CRC32 checksums in thedmpstorevariable dumps - Lesson 62: Structure of the UEFI
Device path. Dynamic and static Device paths. Interation over Device paths - Lesson 63: Create HII Form with a checkbox - Part 1: VFR code for
checkboxelement andefivarstoreelement - Lesson 64: Create HII Form with a checkbox - Part 2: Necessary code for
efivarstoreto work correctly - Lesson 65: More VFR input elements - Part 1:
numeric - Lesson 66: More VFR input elements - Part 2:
string - Lesson 67: More VFR input elements - Part 3:
dateandtime - Lesson 68: More VFR input elements - Part 4:
oneofandorderedlist - Lesson 69: Conditional keywords in VFR:
suppressif/grayoutif/disableif/warningif/nosubmitif/inconsistentif - Lesson 70: Constants and operators in VFR. Basic condition statements with builtins
ideqval/ideqvallist/ideqid/questionref/pushthis - Lesson 71: Basic VFR builtins for strings:
stringref/toupper/tolower/length - Lesson 72: Dynamically add elements to HII forms with a help of a
labelkeyword - Lesson 73: Setting defaults for the VFR questions:
default/defaultstore/resetbuttonkeywords
- Lesson XX: Register protocol installation callbacks with the
EFI_BOOT_SERVICES.RegisterProtocolNotify()andEfiCreateProtocolNotifyEventfunctions - Lesson XX: UEFI Configuration language. Dump current HII Database settings with the
EFI_HII_CONFIG_ROUTING_PROTOCOL.ExportConfig()function - Lesson XX: UEFI Configuration language. Create a function to prettify configuration string data
- Lesson XX: UEFI Configuration language. Extract individual form element configurations with the
EFI_HII_CONFIG_ROUTING_PROTOCOL.ExtractConfig()function - Lesson XX: UEFI Configuration language. Explore
ExtractConfigrequest syntax on custom forms - Lesson XX: UEFI Configuration language. Change form data with the
EFI_HII_CONFIG_ROUTING_PROTOCOL.RouteConfig()function - Lesson XX: UEFI Configuration language. Keyword handler protocol. Get keyword values with the
EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL.GetData()function - Lesson XX: UEFI Configuration language. Keyword handler protocol. Add keywords to you Form elements. Use
EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL.SetData()function to chage data referred by keywords - Lesson XX: Use
HiiSetToDefaultsfunction to set form elements to their default values non-interactively - Lesson XX: Create a driver with
Buffer Storage- Part 1:varstoreelement andEFI_HII_CONFIG_ACCESS_PROTOCOL - Lesson XX: Create a driver with
Buffer Storage- Part 2: Investigate when and howExtractConfig/RouteConfig/Callbackfunctions are called - Lesson XX: Create a driver with
Buffer Storage- Part 3: UseBlockToConfig()/ConfigToBlock()functions to handle configuration requests - Lesson XX: Create a driver with
Buffer Storage- Part 4: MakeExtractConfig()function compatible with UEFI specification - Lesson XX: Investigate when and how the Form Browser calls
EFI_HII_CONFIG_ROUTING_PROTOCOL.Callback()function - Lesson XX: Popup windows in edk2. Creating popups with the
EFI_HII_POPUP_PROTOCOL.CreatePopup()andCreatePopUpfunctions - Lesson XX: Action requests for the Form Browser from the
EFI_HII_CONFIG_ROUTING_PROTOCOL.Callback()function - Lesson XX: The
passwordVFR input element - Part 1: BasicCallback()implementation to handle password element - Lesson XX: The
passwordVFR input element - Part 2: UseEFI_HASH2_PROTOCOLto calculate password string hash
- Lesson XX: Changing hidden BIOS settings. Using
IFRExtractorutility to extract UEFI IFR data into human-readable text - Lesson XX: Decompile UEFI modules with the help of
Ghidrasoftware and theefiSeekplugin
- Lesson XX: Architecture specifier in section names
- Lesson XX: SKU specifier in section names
- Lesson XX: Build tools configuration via
Conf/tools_def.txtfile and[BuildOptions]section usage in INF and DSC files - Lesson XX: Intro to FDF file format. Flash Device Image
[FD]sections: flash chip defines and regions definition. OVMF image FDF file analysis - Lesson XX: Firmware Volume (
FV), FFS, files. Create simple FV withRAWfiles - Lesson XX: File sections - Part 1:
FREEFORMfile andRAWsection type. FV build process (GenSec/GenFfs/GenFvtools) - Lesson XX: File sections - Part 2: Other leaf sections:
USER_INTERFACE/VERSION/FREEFORM_SUBTYPE_GUID/PE32/PIC/COMPATIBILITY16/TE/DISPOSABLE/PEI_DEPEX/DXE_DEPEX - Lesson XX: File sections - Part 3: Encapsulation sections:
COMPRESSION/GUID_DEFINED/FIRMWARE_VOLUME_IMAGE - Lesson XX: File types
- Lesson XX:
A priorifiles.APRIORI PEI/APRIORI DXEsyntax - Lesson XX: Include modules to FDF via INF files.
Rulesections - Lesson XX: Binary modules.
[Binaries]section and[Rule.<...>.BINARY]rules - Lesson XX:
OVMFflash image structure. Working with FD image regions via memory-mapped flash - Lesson XX: Using
EFI_FIRMWARE_VOLUME2_PROTOCOLto read files from FFS - Lesson XX: PCD storage methods:
HiiPCDs ([PcdsDynamicHii]/[PcdsDynamicExHii]) - Lesson XX: PCD storage methods:
VPDPCDs ([PcdsDynamicVpd]/[PcdsDynamicExVpd]) - Lesson XX: How UEFI variables are stored in flash
Learning links
-
Beyond BIOS: Developing with the Unified Extensible Firmware Interface, Third Edition by Vincent Zimmer and Michael Rothman (https://www.amazon.com/Beyond-BIOS-Developing-Extensible-Interface/dp/1501514784)
-
Harnessing the Uefi Shell: Moving The Platform Beyond Dos, Second Edition by Michael Rothman and Vincent Zimmer (https://www.amazon.com/Harnessing-UEFI-Shell-Moving-Platform/dp/1501514806)
-
https://github.com/tianocore-training
https://github.com/Laurie0131
- https://blog.fpmurphy.com/
https://github.com/fpmurphy/UEFI-Utilities-2019
- https://github.com/andreiw/UefiToolsPkg
Check these if you don't afraid of the Chinese language:
- Principles and Programming of UEFI, Dai Zhenghua (https://www.amazon.com/Combat-UEFI-Principles-Programming-Chinese/dp/B07W3GFLRM)
https://github.com/zhenghuadai/uefi-programming
-
http://www.lab-z.com/iof/
-
https://blog.csdn.net/luobing4365
https://gitee.com/luobing4365/uefi-explorer
And for the Russian speakers:
- https://habr.com/ru/users/CodeRush/posts/
Specifications
UEFI specifications (https://uefi.org/specifications):
EDK2 specifications (https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Documentation#specifications):
- Build Specification
- Platform Description (DSC) File Specification
- Package Declaration (DEC) File Format Specification
- Module Information (INF) File Specification
- Flash Description (FDF) File Specification
- Platform Configuration Database Infrastructure Description
- Multi-String .UNI File Format Specification
- VFR Programming Language Specification
- Driver Writer's Guide
- Module Writer's Guide
- EDKII User Manual
Tools
- UEFITool - UEFITool is a cross-platform C++/Qt program for parsing, extracting and modifying UEFI firmware images
- CrScreenshotDxe - UEFI DXE driver to take screenshots from GOP-compatible graphic consoles
- RU.EFI - "Read Universal" - UEFI application to debug UEFI interfaces
- PCD_TABLE_parser - Parser for Platform Configuration Database (PCD) tables created in the EDKII build process