Framework Drivers - bluepillstudy - learn the open source of blue pill
Download
Report
Transcript Framework Drivers - bluepillstudy - learn the open source of blue pill
UEFI Drivers
Intel Corporation
Software and Solutions Group
Copyright © 2006-2008 Intel Corporation
Agenda
•
•
•
•
•
®
Driver Introduction
UEFI Protocols
Driver Design Steps
Driver Writer Guidelines
Driver Writer’s Guide Publication
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 2
UEFI Driver Intro
What do UEFI Drivers do?
• UEFI Drivers extend firmware
– Add support for new hardware
– No HW dependence
– No OS dependence
• Portable across platforms
– IA32, IA64, Intel-64, XScale
• Enables rapid development
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 3
UEFI Driver Intro
General Driver Execution (entry)
UEFI Loader
Entry Point
Establish Protocols:
Supported,
Start,
Stop
Exit Driver
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 4
UEFI Driver Intro
General Driver Execution
(Supported)
Protocol
Consumer
Supported
Is Device supported
Testing ID
True:
Status = Supported
False:
Status = Unsupported
Return
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 5
UEFI Driver Intro
What is an UEFI Driver?
• An UEFI Loadable Image
–
–
–
–
Loaded by UEFI loader
May produce protocols
May consume protocols
Typically system driven
• Can be used for
– Supporting specific hardware
– Overriding an existing driver
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 6
UEFI Driver Intro
Driver vs. Application
Driver
Application
Loaded by:
EFI Loader
EFI Loader
Interfaces available:
ALL
ALL
Consume protocols?
YES
YES
Produce protocols?
YES
NO
Typically driven by?
System
User
Typical use
Support HW
Any
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 7
UEFI Driver Intro
UEFI Driver Model
• Supports complex bus hierarchies
– Follows the organization of physical/electrical
architecture of the machine
• Driver Binding Protocol provides flexibility
– Function to match drivers to devices
– Driver version management
– Hot-plug and unload support
• Drivers not tied to FLASH
– Can be loaded from UEFI System Partition
• Extensible
– Able to extend to future bus and device types
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 8
Agenda
•
•
•
•
•
®
Driver Introduction
UEFI Protocols
Driver Design Steps
Driver Writer Guidelines
Driver Writer’s Guide Publication
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 9
What is a protocol?
•
•
•
•
An interface
Must be Produced by a driver
May be Consumed by anyone
A set of related functions and their associated
data
• Examples:
– Device Path, PCI I/O, Disk I/O, GOP, UNDI
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 10
PCI IO Protocol - Example
GUID
#define EFI_PCI_IO_PROTOCOL_GUID \
{0x4cf5b200,0x68b8,0x4ca5,0x9e,0xec,0xb2,0x3e,0x3f,0x50,
0x2,0x9a}
Protocol Interface Structure
typedef struct _EFI_PCI_IO_PROTOCOL {
EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem;
EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo;
EFI_PCI_IO_PROTOCOL_ACCESS Mem;
EFI_PCI_IO_PROTOCOL_ACCESS Io;
EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci;
EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem;
EFI_PCI_IO_PROTOCOL_MAP Map;
EFI_PCI_IO_PROTOCOL_UNMAP Unmap;
EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
EFI_PCI_IO_PROTOCOL_FLUSH Flush;
EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation;
EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes;
EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes;
EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes;
UINT64 RomSize;
VOID *RomImage;
} EFI_PCI_IO_PROTOCOL
®
See § 13.4 UEFI 2.1 Spec.
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 11
Disk IO Protocol - Example
GUID
#define EFI_DISK_IO_PROTOCOL_GUID \
{0xCE345171,0xBA0B,0x11d2,0x8e,0x4F,0x00,0xa0,0x
c9,0x69,0x72,
0x3b}
Revision Number
#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000
Protocol Interface Structure
typedef struct _EFI_DISK_IO_PROTOCOL {
UINT64 Revision;
EFI_DISK_READ ReadDisk;
EFI_DISK_WRITE WriteDisk;
} EFI_DISK_IO_PROTOCOL;
See § 12.6 UEFI 2.1 Spec.
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 12
Device Path Protocol - Example
GUID
#define EFI_DEVICE_PATH_PROTOCOL_GUID \
{0x09576e91,0x6d3f,0x11d2,0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,
0x3b}
Protocol Interface Structure
typedef struct _EFI_DEVICE_PATH_PROTOCOL {
UINT8 Type;
UINT8 SubType;
UINT8 Length[2];
} EFI_DEVICE_PATH_PROTOCOL;
• The device path describes the location of the device
the handle is for
• A UEFI driver may access only a physical device for
which it provides functionality.
See § 9.2 UEFI 2.1 Spec.
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 13
Protocol example
UEFI application
UEFI boot services
Simple File System
Disk I/O driver
Block I/O
Application Consumes I/O protocol
firmware Produces protocol
(exposed through BS)
The Application
has to
determine which
top level handle
to call into
Firmware uses correct lower level protocols
Consumes Extended SCSI Passthrough protocol
SCSI card driver Produces Extended SCSI
Passthrough protocol
SCSI I/O
Extended
SCSI Passthrough
SCSI card driver will talk directly to the SCSI drive
(PCI OpRom driver)
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 14
Protocol vs. C++ class
• An UEFI protocol is logically similar to a C++
class
– With lower memory overhead
• No virtual function table
–
–
–
–
Has private member variables
Has exposed functions
Has private functions
Has a ‘This’ pointer
– Look/feel very different
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 15
Agenda
•
•
•
•
•
®
Driver Introduction
UEFI Protocols
Driver Design Steps
Driver Writer Guidelines
Driver Writer’s Guide Publication
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 16
Design Steps
Driver Design Steps
1.
2.
3.
4.
5.
6.
Determine Driver Type
Identify Consumed I/O Protocols
Identify Produced I/O Protocols
Identify UEFI Driver Model Protocols
Identify Additional Driver Features
Identify Target Platforms
–
–
–
–
®
x86
x64
Itanium Processor Family
EFI Byte Code (EBC)
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 17
Design Steps
What Type of Driver is Being Designed?
UEFI Images
Drivers
Service Drivers
UEFI Driver Model
Initializing Drivers
Root Bridge
Drivers
Device
BusBus Hybrid Device
Drivers Drivers Drivers
Drivers
Drivers
Applications
OS Loaders
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 18
Design Steps
Drivers
Service Drivers
UEFI Driver Model
Device Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Device
Drivers
• Manages a Controller or Peripheral Device
• Start() Does Not Create Any Child Handles
• Start() Produces One or More I/O Protocols
– Installed onto the Device’s Controller Handle
Examples:
PCI Video Adapters
USB Host Controllers
USB Keyboards / USB Mice
PS/2 Keyboards / PS/2 Mice
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 19
Design Steps
Drivers
Service Drivers
UEFI Driver Model
Bus Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Device
Drivers
• Manages and Enumerates a Bus Controller
• Start() Creates One or More Child Handles
• Start() Produces Bus Specific I/O Protocols
– Installed onto the Bus’s Child Handles
Examples:
PCI Network Interface Controllers
Serial UART Controllers
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 20
Design Steps
Drivers
Service Drivers
UEFI Driver Model
Hybrid Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Device
Drivers
• Manages and Enumerates a Bus Controller
• Start() Creates One or More Child Handles
• Start() Produces Bus Specific I/O Protocols
– Installed onto the Bus’s Controller Handle
– Installed onto Bus’s Child Handles
Examples:
PCI SCSI Host Controllers
PCI Fiber Channel Controllers
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 21
Design Steps
Drivers
Service Drivers
UEFI Driver Model
Service Drivers
Initializing Drivers
Root Bridge
Drivers
•
•
•
•
•
•
Bus
Drivers
Hybrid
Drivers
Device
Drivers
Does Not Manage Hardware
Provides Services to other Drivers
Does not support Driver Binding Protocol
Typically installs protocols in driver entry point
Creates One or More Service Handles
Produces Service Specific Protocols
– Installed onto Service Handles
Examples:
UEFI Decompress Protocol
UEFI Byte Code Virtual Machine
Boot Integrity Services (BIS)
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 22
Design Steps
Drivers
Service Drivers
UEFI Driver Model
Initializing Drivers
Initializing Drivers
Root Bridge
Drivers
•
•
•
•
•
Bus
Drivers
Hybrid
Drivers
Device
Drivers
Typically Touches Hardware
Performs One Time Initialization Operations
Does Not Create Any Handles
Does Not Produce Any Protocols
Unloaded When Finished
Examples: None
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 23
Design Steps
Drivers
Service Drivers
UEFI Driver Model
Root Bridge Drivers
Initializing Drivers
Root Bridge
Drivers
•
•
•
•
Bus
Drivers
Hybrid
Drivers
Device
Drivers
Typically Manages Part of Core Chipset
Directly Touches Hardware
Creates One or More Root Bridge Handles
Produces Root Bridge I/O Protocols
– Installed onto new Root Bridge Handles
Examples: PCI Host Bridge
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 24
Design Steps
What I/O Protocols are Consumed?
FLASH
• PCI Adapters
– PCI I/O Protocol
– Device Path Protocol
• USB Peripherals
– USB I/O Protocol
– Device Path Protocol
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 25
Design Steps
What I/O Protocols are
Produced?
FLASH
SCSI
SCSI RAID
Fiber Channel
• SCSI Pass Thru Protocol
and
• Block I/O Protocol
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 26
Design Steps
What I/O Protocols are
Produced?
FLASH
Network
Interface
Controller
(NIC)
• Universal Network Driver Interface (UNDI)
and
• Network Interface Identifier Protocol (NII)
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 27
Design Steps
Responsibilities of Driver Writer
• Driver Image Handle Required Protocols
Driver Image Handle
Publishe
d by the
driver
EFI_LOADED_IMAGE_PROTOCOL
Unload()
EFI_LOADED_IMAGE_PROTOCOL
EFI_DRIVER_BINDING_PROTOCOL
Supported()
Start()
Stop()
Version
Installed
by the
core
Installed
by the
driver
See § 2.5.2 UEFI 2.1 Spec.
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 28
Design Steps
More
Responsibilities of Driver Writer
• Driver Image Handle Optional Protocols
Driver Image Handle
EFI_PLATFORM_TO_DRIVER_
CONFIGURATION_PROTOCOL
Query()
Response()
EFI_DRIVER_DIAGNOSTICS_PROTOCOL
RunDiagnostics()
SupportedLanguages
EFI_COMPONENT_NAME_PROTOCOL
GetDriverName()
GetControllerName()
SupportedLanguages
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 29
Design Steps
Driver Design Checklist
Driver Type
PCI
Video
Device
I/O Protocols Consumed
PCI I/O
I/O Protocols Produced
Driver Binding
Component Name
Driver Configuration
Driver Diagnostics
Unloadable
Exit Boot Services Event
Runtime
Set Virtual Address Map Event
®
PCI
RAID
Hybrid
PCI I/O
PCI
NIC
Bus
PCI I/O
Device Path
Device Path
GOP
SCSI Pass Thru
Block I/O
UNDI, NII
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 30
Design Steps
Running UEFI drivers
• ConnectController()
– Called from Boot Manager or during load
– Precedence rules are applied
•
•
•
•
Context override
Platform override
Bus override
Version number
– Order of which drivers are installed into handle
database is not deterministic
• DisconnectController()
– Must test and implement Stop()
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 31
Agenda
•
•
•
•
•
®
Driver Introduction
UEFI Protocols
Driver Design Steps
Driver Writer Guidelines
Driver Writer’s Guide Publication
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 32
Driver Guidelines
Implement, Test & Debug
• See Backup Slides for Details
– Required for IHVs
– Optional for OEM/ODMs
•
•
•
•
•
•
Test Functions with EFI Shell Commands
Check for Leaks with EFI Shell Commands
Install UEFI Compliant Operating System
Boot UEFI Compliant Operating System
Debug Macros Identify Critical Failures
Use Same Techniques on all CPU Types
– x86, x64, Itanium Processor Family, EBC
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 33
Driver Guidelines
Driver Guidelines
•
•
•
•
Don’t touch hardware in Driver Entry
Keep Supported() small and simple
Move complex I/O into Start() and Stop()
Start() / Stop() mirror each other
–
–
–
–
InstallProtocolInterface()
OpenProtocol()
AllocatePages()
AllocatePool()
UninstallProtocolInterface()
CloseProtocol
FreePages()
FreePool()
• Driver Entry / Unload() mirror each other
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 34
Driver Guidelines
PCI Device Drivers
• Always Call PciIo->Attributes()
– Advertises Dual Address Cycle Capability
– Save and Enable Attributes in Start()
– Disable Attributes in Stop()
• DMA – Bus Master Write Operations
– Must call PciIo->Flush()
• DMA – Setting Up with PciIo->Map()
– Do Not Use Returned DeviceAddress
– Not all chipsets have 1:1 bus/system mappings
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 35
Driver Guidelines
PCI Device Drivers – Start()
Status = PciIo->Attributes(
PciIo,
EfiPciIoAttributeOperationGet,
0,
&ControllerContext->OriginalPciIoAttributes
);
if (EFI_ERROR (Status)) {
// Error Handling
}
Status = PciIo->Attributes(
PciIo,
EfiPciIoAttributeOperationEnable,
(EFI_PCI_IO_ATTRIBUTE_IO |
EFI_PCI_IO_ATTRIBUTE_MEMORY |
EFI_PCI_IO_ATTRIBUTE_BUS_MASTER |
EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE),
0,
NULL
);
if (EFI_ERROR (Status)) {
// Error Handling
}
Save Original and Enable
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 36
Driver Guidelines
PCI Device Drivers – Stop()
Status = PciIo->Attributes(
PciIo,
EfiPciIoAttributeOperationSet,
&ControllerContext->OriginalPciIoAttributes
NULL
);
if (EFI_ERROR (Status)) {
// Error Handling
}
Restore Original
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 37
Driver Guidelines
Preventing Alignment Faults
VOID
ScsiDeviceNodeInit (
IN OUT SCSI_DEVICE_PATH *ScsiDeviceNode,
IN
UINT16
Pun,
IN
UINT16
Lun
)
{
ScsiDeviceNode->Scsi.Header.Type
= MESSAGING_DEVICE_PATH;
ScsiDeviceNode->Scsi.Header.SubType
= MSG_SCSI_DP;
SetDevicePathNodeLength (&ScsiDeviceNode->Scsi.Header,
sizeof(SCSI_DEVICE_PATH));
ScsiDeviceNode->Scsi.Pun
= Pun;
ScsiDeviceNode->Scsi.Lun
= Lun;
}
BAD
ScsiDeviceNode may not be aligned
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 38
Driver Guidelines
Preventing Alignment Faults
VOID
ScsiDeviceNodeInit (
IN OUT SCSI_DEVICE_PATH *ScsiDeviceNode,
IN
UINT16
Pun,
IN
UINT16
Lun
)
{
SCSI_DEVICE_PATH MyDeviceNode;
GOOD
MyDeviceNode.Scsi.Header.Type
= MESSAGING_DEVICE_PATH;
MyDeviceNode.Scsi.Header.SubType
= MSG_SCSI_DP;
SetDevicePathNodeLength (&MyDeviceNode.Scsi.Header,
sizeof(SCSI_DEVICE_PATH));
MyDeviceNode.Scsi.Pun
= Pun;
MyDeviceNode.Scsi.Lun
= Lun;
gBS->CopyMem (ScsiDeviceNode,
&MyDeviceNode,
sizeof(SCSI_DEVICE_PATH));
}
gBS->CopyMem() handles all alignments
MyDeviceNode is aligned
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 39
Driver Guidelines
Use UEFI Driver Library Functions
CHILD_DEVICE
Child;
OK
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (CHILD_DEVICE),
&Child
);
if (EFI_ERROR (Status)) {
return Status;
}
gBS->SetMem (Child, sizeof (CHILD_DEVICE), 0);
CHILD_DEVICE
Child;
GOOD
Child = EfiLibAllocateZeroPool (sizeof (CHILD_DEVICE));
if (Child == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Library Functions Simplify Source Code
Library Functions May Reduce Size
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 40
Driver Guidelines
UEFI Device Paths
• EFI_DRIVER_BINDING.Start()
Child->DevicePath = EfiAppendDevicePathNode (
ControllerDevicePath,
ChildDevicePathNode
);
if (Child->DevicePath == NULL) {
return(EFI_OUT_OF_RESOURCES);
}
• EFI_DRIVER_BINDING.Stop()
gBS->FreePool (Child->DevicePath);
Parent Device Path is Opaque
Not Parsed by Bus Drivers
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 41
Driver Guidelines
Bus Walk Tips
• Use LocateHandleBuffer(Bus I/O Protocol)
– Do not scan PCI configuration space
• Implement support for RemainingDevicePath
– Highly recommended for all bus drivers
• (i.e. SCSI, Fibre Channel, etc.)
– Allows bus driver to bypass full enumeration.
– Reduces boot time
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 42
Driver Guidelines
Component Name Protocol
• Limit Lengths of Names to 40 Unicode Characters
• Include Driver Name and Version Number
• UNDI Driver (Network Interface Controller)
– Typically the Name of the PCI Controller
• MAC Node Produced by an UNDI Driver
– Identify Location of Physical Connector on NIC
• PCI Slots
– Identify Physical Location of PCI Slots in the System
• SCSI / SCSI RAID / Fiber Channel
– Controller - Typically name of the PCI Controller
– Channel - Identify Physical Location of the SCSI Channel
– Disk
- Use Results from INQUIRY Command
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 43
Driver Guidelines
Option ROM Size Reduction
• Use UEFI Compression
• Compile with EFI Byte Code Compiler
–
–
–
–
®
Single Binary for x86, x64 and Itanium
Smaller than Itanium Binaries
Comparable to x86 Binaries
Compresses Well ~ 50%
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 44
Driver Guidelines
1.
2.
3.
4.
5.
6.
How To Improve Portability
Do Not Assume Max Number of Children
Do Not Use Fixed Memory Addresses
Do Not Use Assembly
Do Not Use Floating Point Arithmetic
Some Minor EBC Porting Considerations
Bus Drivers Should Support Producing 1
Child at a time if possible (improves boot
performance)
Driver Guidelines Improve Portability
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 45
Agenda
•
•
•
•
•
®
Driver Introduction
UEFI Protocols
Driver Design Steps
Driver Writer Guidelines
Driver Writer’s Guide Publication
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 46
Driver Writer’s Guide
•
•
•
•
UEFI Driver Writer’s Guide
Captures Practical Experiences
Use as a Recipe Book
Must Read for all UEFI Driver Developers
Living Document
– Content Based on Industry Feedback
– Updated as Techniques are Refined
– Updated as New Technologies are Introduced
Driver Writer’s
Guide for UEFI 2.0
Draft for Review
®
April 28, 2008
Revision 0.96
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 47
Driver Writer’s Guide
General Topics
• Overview of UEFI Concepts
• UEFI Services
– Commonly Used by UEFI Drivers
– Rarely Used by UEFI Drivers
– Should Not Be Used by UEFI Drivers
•
•
•
•
•
®
General Driver Design Guidelines
Classes of UEFI Drivers
Driver Entry Point
Private Context Data Structures
UEFI Driver Model Protocols
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 48
Driver Writer’s Guide
Platform Specific Topics
•
•
•
•
•
•
•
•
®
PCI Driver Guidelines
USB Driver Design Guidelines
SCSI Driver Design Guidelines
Size Optimizations
Speed Optimizations
Itanium Processor Family Considerations
EFI Byte Code Considerations
Building/Testing/Debugging UEFI Drivers
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 49
Driver Writer’s Guide
Benefits of following EFI
Driver Guidelines
• Following EFI Driver Guidelines
–
–
–
–
Improves Portability, Quality, and Interoperability
Reduces Implementation Effort
May Increase Performance
May Reduce FLASH Overhead
UEFI Driver Writer’s Guide Helps
Improve EFI Drivers
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 50
Summary
•
•
•
•
®
Good Designs Save Time and Money
Many Tools Available to Test and Debug
Using Driver Guidelines Improves Portability
Compile in EBC to have one driver image to
support x86, x64 and Itanium.
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 51
Further Information
• http://www.intel.com/technology/EFI
– EFI Web site for information, IDF presentations
and EFI Driver Writer’s Guide
• http://www.uefi.org
– Website for Unified EFI Forum, UEFI
Specifications
• https://www.TianoCore.org
– Website for UEFI open source resources
• EFI Developer Kit (EDK) and (EDK II)
• UEFI Driver Writer’s Guide 2.0
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 52
Q&A
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 53
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 54
• Required Materials for IHVs
• Optional Materials for OEMs
Back up
See Backup Presentation “UEFI-Drivers-Backup Only”
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 55
Network UEFI 2.1
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 56
Network
Protocol Diagram
PXEBC
TFTP
DHCP
UDP
TCP
IP (ICMP, IGMP, ARP)
SNP
UNDI
Red (solid) lines are new network protocol APIs that can be accessed by
multiple applications and drivers at the same time.
Green (broken) lines are existing network protocol APIs that can only be
accessed by one application or driver at a time.
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 57
Network
Internet Protocol (IP)
• One IP instance per SNP instance.
• Can be used by multiple applications and
drivers at the same time.
• Implements a subset of IP (RFC 791).
– No support for IP options in alpha code.
– Minimal support for ICMP
• ping works
• errors can be routed up to applications and drivers
– Just enough to make UDP and TCP layers work
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 58
Network
User Datagram Protocol (UDP)
• One UDP instance per IP instance.
• Can be used by multiple applications and drivers
at the same time.
• Implements all of UDP (RFC 768).
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 59
Network
Transmission Control Protocol
(TCP)
• One TCP instance per IP instance.
• Can be used by multiple applications and drivers at the
same time.
• Implements a subset of TCP (RFC 793).
– No application control of window or segment sizes.
– Minimal data returned for socket status.
– Just enough to make implementing a Berkeley Socket interface
possible.
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 60
Network
Multicast Trivial File Transfer
Protocol (Mtftp)
• One MTFTP instance per UDP/IP instance.
• Can be used by multiple applications and drivers
at the same time.
• Implements all of TFTP (RFC 1350) + Options
(RFCs 2347, 2348, 2349) + Internet-Drafts
covering BIG extensions.
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 61
Network
Dynamic Host Configuration
Protocol (DHCP)
• One DHCP instance per UDP/IP instance.
• Can be used by multiple applications and drivers at the
same time.
• Only provides network configuration information.
– Does not manage network connections.
– If DHCP data changes, application must update network
connection accordingly.
• Implements all of DHCP (RFC 2131 and 2132)
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 62
Current Network Stack Layout
APP
iSCSI
APP
APP
APP
UEFI PXE Base Code
TCP/IP
Stack
PXEBC
MTFTPv4
DHCPv4
Service Binding
Service Binding
Primarily External Interfaces
TCPv4 Service Binding
Primarily Internal Interfaces
SNP
UNDI
IPv4
UDPv4 Service Binding
Service Binding
ARP
Notice the concurrent
usage in new solution set.
SNP is used exclusively by
MNP, and MNP acts as a
multiplex for incoming use
of the SNP.
MNP
Service Binding
Service Binding
SNP
UNDI
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 63
®
UEFI / Framework Training 2008
Copyright © 2006-2008 Intel Corporation
•Other trademarks and brands are the property of their respective owners
Slide 64