Use
Useof
of multilayer
multilayer modularity
modularitymeans
means
UEFI
/
Framework
Special
more
morescenarios
scenariosjust
justwork
workTopicSlide 2
UEFI Drivers
Extensible
Able to extend to future bus and device types
UEFI / Framework Special Topic
Slide 3
UEFI Drivers
x86
x64
Itanium Processor Family
EFI Byte Code (EBC)
UEFI / Framework Special Topic
Slide 5
UEFI Drivers
CPU
North
Bridge
CPU
PCI BUS
IBA-PCI
Bridge
PCI-IBA
Bridge
USB BUS
USB
KBD
VGA
PCI-ISA
Bridge
Mouse
Removable
Media
(floppy)
ISA BUS
SCSI
PCI BUS
Hard
Drive
Hard
Drive
Hard
Drive
Hard
Drive
UEFI Drivers
Initializing Drivers
Root Bridge
Drivers
Device
BusBus Hybrid Device
Drivers Drivers Drivers
Drivers
Drivers
Applications
OS Loaders
UEFI / Framework Special Topic
Slide 7
Device Driver
Consumes Bus I/O Abstraction(s)
Initializes Device Controller
Produces Device Abstraction(s)
Block I/O Protocol
Simple Text Output Protocol
Simple Network Protocol
UEFI Drivers
Drivers
Service Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Device Drivers
Device
Drivers
Bus Driver
Optional
EFI_BUS_SPECIFIC_DRIVER_
OVERRIDE_PROTOCO
UEFI Drivers
Drivers
Service Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Bus Drivers
Device
Drivers
UEFI Drivers
Drivers
Service Drivers
Hybrid Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Device
Drivers
UEFI Drivers
Drivers
Service Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Service Drivers
Device
Drivers
Examples:
UEFI Decompress Protocol
UEFI Byte Code Virtual Machine
Boot Integrity Services (BIS)
UEFI / Framework Special Topic
Slide 13
Driver Initialization
EFI Driver Handoff State
Not Allowed to Touch Hardware Resources
Installs Driver Binding on Driver Image Handle
Created by LoadImage()
Installed by LoadImage()
Installed in Driver Initialization
Implemented by Driver Writer
Registers
RegistersDriver
Driverfor
forLater
LaterUse
Use
UEFI / Framework Special Topic
Slide 14
UEFI Drivers
Drivers
Service Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Initializing Drivers
Device
Drivers
UEFI Drivers
Drivers
Service Drivers
Initializing Drivers
Root Bridge
Drivers
Bus
Drivers
Hybrid
Drivers
Device
Drivers
UEFI Drivers
FLASH
PCI Adapters
PCI I/O Protocol
Device Path Protocol
USB Peripherals
USB I/O Protocol
Device Path Protocol
UEFI Drivers
FLASH
SCSI
SCSI RAID
Fiber Channel
UEFI Drivers
FLASH
Network
Interface
Controller
(NIC)
UEFI Drivers
Installed
by the
core
Installed
by the
driver
UEFI Drivers
More
Responsibilities of Driver Writer
UEFI Drivers
Driver Type
PCI
Video
PCI
RAID
PCI
NIC
Device
Hybrid
Bus
Bus
PCI I/O
PCI
PCII/O
I/O
PCI I/O
Device Path
Device
DevicePath
Path
UGA Draw
UGA I/O
UNDI,
UNDI,NII
NII
Driver Binding
Component Name
Driver Configuration
Driver Diagnostics
Unloadable
Runtime
Set
SetVirtual
VirtualAddress
AddressMap
MapEvent
Event
UEFI Drivers
Context override
Platform override
Bus override
Version number
DisconnectController()
Must test and implement Stop()
UEFI / Framework Special Topic
Slide 23
UEFI Drivers
Driver Guidelines
Driver Guidelines
InstallProtocolInterface() UninstallProtocolInterface()
OpenProtocol() CloseProtocol
AllocatePages() FreePages()
AllocatePool()
FreePool()
Driver Guidelines
Driver Guidelines
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
}
Driver Guidelines
Status = PciIo->Attributes(
PciIo,
EfiPciIoAttributeOperationSet,
&ControllerContext->OriginalPciIoAttributes
NULL
);
if (EFI_ERROR (Status)) {
// Error Handling
}
Restore Original
Driver Guidelines
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
Driver Guidelines
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));
}
Driver Guidelines
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
Driver Guidelines
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);
Driver Guidelines
Driver Guidelines
PCI Slots
Identify Physical Location of PCI Slots in the System
Driver Guidelines
Driver Guidelines
1.
2.
3.
4.
5.
6.
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
EFI
EFI Driver
Driver Writers
WritersGuide
GuideHelps
Helps
Improve
ImproveEFI
EFI Drivers
Drivers
UEFI / Framework Special Topic
Slide 40
Summary