EDK II UEFI Driver Writer's Guide
Search…
⌃K
EDK II UEFI Driver Writer's Guide
Search…
⌃K
Introduction
Tables
Figures
Examples
Acknowledgements
1 Introduction
2 UEFI Driver Implementation Checklist
3 Foundation
4 General Driver Design Guidelines
5 UEFI Services
6 UEFI Driver Categories
7 Driver Entry Point
8 Private Context Data Structures
9 Driver Binding Protocol
10 UEFI Service Binding Protocol
11 UEFI Driver and Controller Names
12 UEFI Driver Configuration
13 UEFI Driver Diagnostics
14 Driver Health Protocol
15 Driver Family Override Protocol
16 Driver Supported EFI Version Protocol
17 Bus-Specific Driver Override Protocol
18 PCI Driver Design Guidelines
19 USB Driver Design Guidelines
20 SCSI Driver Design Guidelines
21 ATA Driver Design Guidelines
22 Text Console Driver Design Guidelines
23 Graphics Driver Design Guidelines
24 Mass Storage Driver Design Guidelines
25 Network Driver Design Guidelines
26 User Credential Driver Design Guidelines
27 Load File Driver Design Guidelines
28 IPF Platform Porting Considerations
29 EFI Byte Code Porting Considerations
30 Building UEFI Drivers
31 Testing and Debugging UEFI Drivers
32 Distributing UEFI Drivers
Appendix A EDK II File Templates
Appendix B EDK II Sample Drivers
Appendix C Glossary
Powered By
GitBook
Examples
​
Example 1-EFI_GUID data structure in EDK II
​
​
Example 2-Protocol structure in EDK II
​
​
Example 3-Device Path Header
​
​
Example 4-PCI Device Path
​
​
Example 5-Device Path Examples
​
​
Example 6-ConnectController() UEFI Boot Service
​
​
Example 7-Stronger type checking
​
​
Example 8-Assignment operation warnings
​
​
Example 9-Comparison operation warnings
​
​
Example 10-Examples of casting pointers
​
​
Example 11-Negative number example
​
​
Example 12-Casting OUT function parameters
​
​
Example 13-Array subscripts example
​
​
Example 14-Incorrect and correct piecemeal structure allocation
​
​
Example 15-CopyMem() and SetMem() Speed Optimizations
​
​
Example 16-Allocate and free pool using UEFI Boot Services Table
​
​
Example 17-Allocate and free pool using MemoryAllocationLib
​
​
Example 18-Allocate and clear pool using MemoryAllocationLib
​
​
Example 19-Allocate and initialize pool using MemoryAllocationLib
​
​
Example 20-Allocate and free pages using UEFI Boot Services Table
​
​
Example 21-Allocate and free pages using MemoryAllocationLib
​
​
Example 22-Allocate and free aligned pages using MemoryAllocationLib
​
​
Example 23-Allocate and clear a buffer using UEFI Boot Services
​
​
Example 24-Allocate and clear a buffer using BaseMemoryLib
​
​
Example 25-Allocate and clear a buffer using BaseMemoryLib
​
​
Example 26-Allocate and copy buffer
​
​
Example 27-Allocate and clear a buffer using BaseMemoryLib
​
​
Example 28-Install protocols in UEFI Driver entry point.
​
​
Example 29-Install protocols in UEFI Driver entry point using UefiLib.
​
​
Example 30-Uninstall protocols in UEFI Driver Unload() function.
​
​
Example 31-Add child handle to handle database
​
​
Example 32-Remove child handle from handle database.
​
​
Example 33-Add tag GUID to a controller handle.
​
​
Example 34-Remove tag GUID from a controller handle.
​
​
Example 35-Retrieve all handles in handle database
​
​
Example 36-Retrieve all Block I/O Protocols in handle database
​
​
Example 37-Locate first Decompress Protocol in handle database
​
​
Example 38-OpenProtocol() function prototype
​
​
Example 39-OpenProtocol() TEST_PROTOCOL
​
​
Example 40-OpenProtocol() GET_PROTOCOL
​
​
Example 41-OpenProtocol() EFI_OPEN_PROTOCOL_BY_DRIVER
​
​
Example 42-OpenProtocol() EFI_OPEN_PROTOCOL_BY_DRIVER |
​
​
Example 43-OpenProtocol()
​
​
Example 44-Count child handles using OpenProtocolInformation()
​
​
Example 45-Using TPL Services for a Global Lock
​
​
Example 46-Using UEFI Library for a Global Lock
​
​
Example 47-Create and close a wait event
​
​
Example 48-Create and Close an Exit Boot Services Event
​
​
Example 49-Create and Close an Exit Boot Services Event Group
​
​
Example 50-Create and Signal an Event Group
​
​
Example 51-Signal a key press event
​
​
Example 52-Wait for one-shot timer event to be signaled
​
​
Example 53-Create periodic timer event
​
​
Example 54-Create one-shot timer event
​
​
Example 55-Cancel and close one-shot timer event
​
​
Example 56-Fixed delay stall
​
​
Example 57-Poll for completion status using stalls
​
​
Example 58-Recursive connect in response to a hot-add operation
​
​
Example 59-Recursive disconnect in response to a hot-remove operation
​
​
Example 60-Disconnect a UEFI Driver from all handles
​
​
Example 61-Reinstall Block I/O Protocol for media change
​
​
Example 62-Reinstall Device Path Protocol for Serial I/O attributes change
​
​
Example 63-Locate Device Path
​
​
Example 64-Load and Start a UEFI Application from a PCI Option ROM
​
​
Example 65-Write configuration structure to a UEFI variable
​
​
Example 66-Read configuration structure from a UEFI variable
​
​
Example 67-Use UefiLib to read configuration structure from a UEFI variable
​
​
Example 68-Collect information about the UEFI variable store
​
​
Example 69-Get time and date
​
​
Example 70-Get real time clock capabilities
​
​
Example 71-Calculate and update 32-bit CRC in UEFI System Table
​
​
Example 72-Calculate and 32-bit CRC for a structure
​
​
Example 73-Verify 32-bit CRC in UEFI System Table
​
​
Example 74-Create a Set Virtual Address Map event
​
​
Example 75-Convert a global pointer from physical to virtual
​
​
Example 76-Using UefiRuntimeLib to convert a pointer
​
​
Example 77-Using UefiRuntimeLib to convert a function pointer
​
​
Example 78-Using UefiRuntimeLib to convert a linked list
​
​
Example 79-Add or update a configuration table entry
​
​
Example 80-Add or update a configuration table entry
​
​
Example 81-Wait for key press or timer event
​
​
Example 82-Retrieve 64-bit monotonic counter value.
​
​
Example 83-Print all UEFI variable store contents
​
​
Example 84-ResetSystem
​
​
Example 85-Exit from a UEFI Driver
​
​
Example 87-UEFI Driver INF File
​
​
Example 88-EDK II UefiLib driver initialization functions
​
​
Example 89-Single Driver Binding Protocol
​
​
Example 90-Single Driver Binding Protocol with optional features
​
​
Example 91-Multiple Driver Binding Protocols
​
​
Example 92-Driver Heath Protocol Feature
​
​
Example 93-Driver Family Override Protocol Feature
​
​
Example 94-Driver Supported EFI Version Protocol Feature
​
​
Example 95-HII Packages feature
​
​
Example 96-UEFI Driver INF File with HII Packages feature
​
​
Example 97-HII Config Access Protocol Feature
​
​
Example 98-Add the Unload feature
​
​
Example 99-UEFI Driver INF File with Unload feature
​
​
Example 100-UEFI Driver Model Unload Feature
​
​
Example 101-Adding the Exit Boot Services feature
​
​
Example 102-Add the Unload and Exit Boot Services event features
​
​
Example 103-Initializing driver entry point
​
​
Example 104-Service driver entry point using image handle
​
​
Example 105-Service driver entry point creating new handle
​
​
Example 106-Single PCI root bridge driver entry point
​
​
Example 107-Multiple PCI root bridge driver entry point
​
​
Example 108-UEFI Runtime Driver entry point
​
​
Example 109-UEFI Runtime Driver INF File
​
​
Example 110-UEFI Runtime Driver entry point with Unload feature
​
​
Example 111-Containing record macro definitions
​
​
Example 112-Containing record macro definitions
​
​
Example 113-Simple private context data structure
​
​
Example 114-Complex private context data structure
​
​
Example 115-Allocation of a private context data structure
​
​
Example 116-Library allocation of private context data structure
​
​
Example 117-Disk I/O allocation of private context data structure
​
​
Example 118-Free a private context data structure
​
​
Example 119-Disk I/O free of a private context data structure
​
​
Example 120-Retrieving the Disk I/O private context data structure
​
​
Example 121-Retrieving the disk I/O private context data structure in Stop()
​
​
Example 122-Driver Binding Protocol
​
​
Example 123-Driver Binding Protocol declaration
​
​
Example 124-Service Binding Protocol
​
​
Example 125-Service Binding Protocol for Service Driver
​
​
Example 126-Component Name Protocol
​
​
Example 127-Component Name 2 Protocol
​
​
Example 128-Driver Diagnostics Protocol declaration
​
​
Example 129-GetDriverName() for Device, Bus, or Hybrid Driver
​
​
Example 130-GetControllerName () Service
​
​
Example 131-GetControllerName() for a Device Driver
​
​
Example 132-Controller names in private context data structure
​
​
Example 133-Adding a controller name to a dynamic controller name table
​
​
Example 134-Freeing a dynamic controller name table
​
​
Example 135-Device driver with dynamic controller names
​
​
Example 136-GetControllerName() for a Bus Driver or Hybrid Driver
​
​
Example 137-Example of a Unicode string file
​
​
Example 138-Example of a Unicode string file
​
​
Example 139-ExtractConfig() Function
​
​
Example 140-RouteConfig() Function
​
​
Example 141-Callback function
​
​
Example 142-Unicode string file with support for multiple languages
​
​
Example 143-Sample VFR file, simplified
​
​
Example 144-Driver Diagnostics Protocol
​
​
Example 145-Driver Diagnostics 2 Protocol
​
​
Example 146-Driver Diagnostics Protocol declaration
​
​
Example 147-RunDiagnostics() Service
​
​
Example 148-RunDiagnostics() for a Device Driver
​
​
Example 149-RunDiagnostics() for a Bus Driver or Hybrid Driver
​
​
Example 150-Driver Health Protocol
​
​
Example 151-Install Driver Health Protocol
​
​
Example 152-GetHealthStatus() Function of the Driver Health Protocol
​
​
Example 153-GetHealthStatus() for a Device Driver
​
​
Example 154-GetHealthStatus() for a Bus Driver or Hybrid Driver
​
​
Example 155-Repair() Function for a Device Driver
​
​
Example 156-Repair() for a Bus Driver or Hybrid Driver
​
​
Example 157-Driver Family Override Protocol
​
​
Example 158-Install Driver Family Override Protocol
​
​
Example 159-GetVersion() Function of the Driver Family Override Protocol
​
​
Example 160-Driver Support EFI Version Protocol
​
​
Example 161-Driver Supported EFI Version Protocol Feature
​
​
Example 162-Bus Specific Driver Override Protocol
​
​
Example 163-Private Context Data Structure with a Bus Specific Driver Override Protocol
​
​
Example 164-Private Context Data Structure Initialization
​
​
Example 165-Install Bus Specific Driver Override Protocol
​
​
Example 166-Uninstall Bus Specific Driver Override Protocol
​
​
Example 167-GetDriver() Function of a Bus Specific Driver Override Protocol
​
​
Example 168-Adding Driver Image Handles
​
​
Example 169-Supported() Reading partial PCI Configuration Header
​
​
Example 170-Supported() Reading entire PCI Configuration Header
​
​
Example 171-Start() for a 64-bit DMA-capable PCI controller
​
​
Example 172-Restore PCI Attributes in Stop()
​
​
Example 173-Completing a memory write transaction
​
​
Example 174-Accessing ISA resources on a PCI controller
​
​
Example 175-Locate PCI handles with matching bus number
​
​
Example 176-Map() Function
​
​
Example 177-Completing a bus master write operation
​
​
Example 178-Bus master read operation
​
​
Example 179-Bus master write operation
​
​
Example 180-Allocate bus master common buffer
​
​
Example 181-Free bus master common buffer
​
​
Example 182-PCI I/O 8-bit fill with a loop
​
​
Example 183-PCI I/O 32-bit fill with a loop
​
​
Example 184-PCI I/O 8-bit fill without a loop
​
​
Example 185-PCI I/O 32-bit fill without a loop
​
​
Example 186-PCI I/O FIFO using a loop
​
​
Example 187-PCI I/O FIFO without a loop
​
​
Example 188-Scroll frame buffer using a loop
​
​
Example 189-Scroll frame buffer without a loop
​
​
Example 190-Read PCI configuration using a loop
​
​
Example 191-Read PCI configuration 32 bits at a time
​
​
Example 192-Read PCI configuration 32 bits at a time
​
​
Example 193-Write 1MB Frame Buffer using a loop
​
​
Example 194-Write 1MB Frame Buffer with no loop
​
​
Example 195-Using Mem.Read() and Stall() to poll for 1 second
​
​
Example 196-Using PollIo() to poll for 1 second
​
​
Example 197-EfiRom Utility Help
​
​
Example 198-EfiRom Utility Dump Feature
​
​
Example 199-UEFI Driver INF File for PCI Option ROM
​
​
Example 200-Specify name of FDF file from a DSC file
​
​
Example 201-Using an FDF file to Generate PCI Option ROM images
​
​
Example 202-USB 2 Host Controller Protocol
​
​
Example 203-USB I/O Protocol
​
​
Example 204-Supported() service for USB host controller driver
​
​
Example 205-Disable USB Legacy Support
​
​
Example 206-Supported() for a USB device driver
​
​
Example 207-USB mass storage driver private context data structure
​
​
Example 208-USB Mouse Private Context Data Structure
​
​
Example 209-Setup asynchronous interrupt transfer for USB mouse driver
​
​
Example 210-Completing an asynchronous interrupt transfer
​
​
Example 211-Retrieving pointer movement
​
​
Example 212-Extended SCSI Pass Thru Protocol
​
​
Example 213-SCSI Pass Thru Mode Structure for Single Channel Adapter
​
​
Example 214-SCSI Pass Thru Mode Structure for Multi-Channel Adapter
​
​
Example 215-SCSI Pass Thru Mode Structures for RAID SCSI adapter
​
​
Example 216-Building Device Path for ATAPI Device
​
​
Example 217-Non-Blocking Extended SCSI Pass Thru
​
​
Example 218-Blocking and non-blocking modes
​
​
Example 219-Supported() for a SCSI device driver
​
​
Example 220-ATA Pass Thru Protocol
​
​
Example 221-ATA Pass Thru Mode Structure
​
​
Example 222-SCSI Pass Thru Mode Structures for RAID SCSI adapter
​
​
Example 223-Simple Text Input Protocol
​
​
Example 224-Simple Text Input Ex Protocol
​
​
Example 225-Simple Text Output Protocol
​
​
Example 226-Light reset of terminal driver
​
​
Example 227-Full reset of terminal driver
​
​
Example 228-Query current Simple Text Output Mode
​
​
Example 229-Query all Simple Text Output Modes
​
​
Example 230-Simple Text Output Protocol
​
​
Example 231-Graphics Output Protocol
​
​
Example 232-Graphics Output Protocol Blt() Service
​
​
Example 233-EDID Discovered Protocol
​
​
Example 234-EDID Active Protocol
​
​
Example 235-DID Override Protocol
​
​
Example 236-Block I/O Protocol
​
​
Example 237-Block I/O 2 Protocol
​
​
Example 238-Storage Security Command Protocol
​
​
Example 239-Network Interface Identifier Protocol
​
​
Example 240-Simple Network Protocol
​
​
Example 241-User Credential Protocol
​
​
Example 242-Load File Protocol
​
​
Example 243-Pointer-cast alignment fault
​
​
Example 244-Corrected pointer-cast alignment fault
​
​
Example 245-Packed structure alignment fault
​
​
Example 246-Corrected packed structure alignment fault
​
​
Example 247-UEFI device path node alignment fault
​
​
Example 248-Corrected UEFI device path node alignment fault
​
​
Example 249-Accessing a 64-bit BAR in a PCI configuration header
​
​
Example 250-Size of data types with EBC
​
​
Example 251-Global Variable Initialization that fails for EBC
​
​
Example 252-Global Variable Initialization that works for EBC
​
​
Example 253-Case statements that fail for EBC
​
​
Example 254-Case statements that work for EBC
​
​
Example 255-EDK II Package Directory
​
​
Example 256-EDK II Package DEC File
​
​
Example 257-EDK II Package DSC File
​
​
Example 258-UEFI Driver Directory
​
​
Example 259-UEFI Driver INF File
​
​
Example 260-UEFI Driver C Source File
​
​
Example 261-Disk I/O UEFI Driver Source Files
​
​
Example 262-EBC driver with instruction set architecture-specific files
​
​
Example 263-EDK II Package DSC File
​
​
Example 264-Build Output Directory
​
​
Example 265-EDK II Package DSC File with Optimizations Disabled
​
​
Example 266-EDK II Package DSC File with Build Options
​
​
Example 268-EDK II Package DSC File with Build Options
​
​
Example 269-UEFI Driver Entry Point with POST_CODE() Macros
​
​
Example 270-Enable POST_CODE() macros from DSC file
​
​
Example A-1-UEFI Driver INF file template
​
​
Example A-2-UEFI Runtime Driver INF file template
​
​
Example A-3-UEFI Driver include file template
​
​
Example A-4-UEFI Driver implementation template
​
​
Example A-5-UEFI Driver protocol implementation template
​
​
Example A-6-Component Name Protocol implementation template
​
​
Example A-7-Driver Configuration Protocol implementation template
​
​
Example A-8-Driver Health Protocol implementation template
​
​
Example A-9-Driver Health Protocol implementation template
​
​
Example A-10-Driver Family Override Protocol implementation template
​
​
Example A-11-Bus Specific Driver Override Protocol implementation template
​
​
Example A-12-Driver Diagnostics Protocols implementation template
​
​
Example A-13-USB 2 Host Controller Protocol implementation template
​
​
Example A-14-Extended SCSI Pass Thru Protocol implementation template
​
​
Example A-15-ATA Pass Thru Protocol implementation template
​
​
Example A-16-Simple Text Input Protocols implementation template
​
​
Example A-17-Simple Text Output Protocol implementation template
​
​
Example A-18-Serial I/O Protocol implementation template
​
​
Example A-19-Graphics Output Protocol implementation template
​
​
Example A-20-Block I/O, Block I/O 2, and
​
​
Example A-21-Network Interface Identifier Protocol implementation template
​
​
Example A-22-Simple Network Protocol implementation template
​
​
Example A-23-User Credential Protocol implementation template
​
​
Example A-24-Load File Protocol implementation template
​
​
Example A-25-EDID Override Protocol implementation template
​
​
Example A-26-Add protocol to an EDK II package
​