---?image=assets/images/gitpitch-audience.jpg
@title[UEFI_Driver_Pres]
This slide deck has moved to:
https://gitpitch.com/tianocore-training/UEFI_Driver_pres/master#/
tianocore.org Note: PITCHME.md for UEFI / EDK II Training UEFI Driver Model and Driver Wizard Pres
Copyright (c) 2020, Intel Corporation. All rights reserved.
Redistribution and use in source (original document form) and 'compiled' forms (converted to PDF, epub, HTML and other formats) with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code (original document form) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified.
-
Redistributions in compiled form (transformed to other DTDs, converted to PDF, epub, HTML and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS DOCUMENTATION IS PROVIDED BY TIANOCORE PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TIANOCORE PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@title[Lesson Objective]
- @fa[certificate gp-bullet-green] What is the UEFI Driver Model
- @fa[certificate gp-bullet-cyan] Details on Driver Binding Protocol
- @fa[certificate gp-bullet-yellow] Example of UEFI Driver
---?image=assets/images/binary-strings-black2.jpg
@title[UEFI Driver Model]
---?image=/assets/images/slides/Slide10.JPG @title[UEFI Drivers - Location]
UEFI Drivers - Location
Note:
- UEFI Drivers depend on:
- the EFI system table
- Boot services
- runtime services
---?image=/assets/images/slides/Slide5_1.JPG @title[What are UEFI Drivers ?]
@size[1.1em](What are UEFI Drivers ? )
@snap[south-east span-15 fragment ]
New UEFI Driver
![Newblock](/assets/images/newBlock.png)@snapend
@snap[north-west span-60 fragment ]
- UEFI Drivers extend firmware
- Portable across platforms
- Enables rapid development
- Produce Protocols
@snap[south-west span-70 fragment]
@box[bg-purple-pp text-white rounded my-box-pad2 ](
UEFI driver is chained into a link lst of
@color[yellow](Drivers Managing Devices)
@snapend
Note: So what do UEFI Drivers do? More than anything UEFI drivers extend the firmware. They add support for new hardware without any Hardware or OS dependence. – What that means is -- The UEFI driver does not need a specific piece of hardware, a UEFI Driver will allow new hardware to exist and will manage this new hardware but does not depend on any other hardware or OS manager. In other words, a UEFI driver is chained into a link list of drivers and devices Drivers can be Portable across platform architectures IA32, X64 Enables rapid development – Enable reuse and through the driver protocols enable rapid development
UEFI and PI Drivers produce protocols. – that can be used by anything else in the UEFI System
@title[Defining a UEFI Driver?]
Defining a UEFI Driver?
@snap[north-west span-60 fragment]
@box[bg-purple-pp text-white rounded my-box-pad2 ](
UEFI Loadable Image
@snapend
@snap[north-east span-65 fragment]
May produce/consume protocols
@snapend
@snap[north-west span-70 fragment]
@box[bg-royal text-white rounded my-box-pad2 ](
Supports complex bus hierarchies
@snapend
@snap[north-east span-90 fragment]
Driver Binding Protocol matches drivers to devices, adds version management
@snapend
@snap[north-west span-100 fragment]
Supports specific hardware, can be unloaded or override an existing driver
@snapend
Note:
- An UEFI Loadable Image
- May produce or consume protocols
- Protocols are UEFI interfaces
- Supports complex bus hierarchies
- Driver Binding Protocol matches drivers to devices & adds version management
- Supports specific hardware, can be unloaded or override an existing driver
---?image=/assets/images/slides/Slide12_1.JPG @title[UEFI Drivers - Location II]
UEFI Drivers - Location
Note:
- UEFI Drivers extend firmware … add support for new hardware with no operating system or platform dependence
- Portable across platforms … compile the same code across multiple architectures (IA32, x64, EFI Byte Code, Intel Itanium, …)
---?image=/assets/images/slides/Slide14.JPG
@title[UEFI Drivers Vs. Applications]
UEFI Drivers Vs. Applications
Note:
Simlar to the Applications loading slide
+++?image=/assets/images/slides/Slide15.JPG
@title[UEFI Drivers Vs. Applications 02]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide16.JPG
@title[UEFI Drivers Vs. Applications 03]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide17.JPG
@title[UEFI Drivers Vs. Applications 04]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide18.JPG
@title[UEFI Drivers Vs. Applications 05]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide19.JPG
@title[UEFI Drivers Vs. Applications 06]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide20.JPG
@title[UEFI Drivers Vs. Applications 07]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide21.JPG
@title[UEFI Drivers Vs. Applications 08]
UEFI Drivers Vs. Applications
Note:
+++?image=/assets/images/slides/Slide22.JPG
@title[UEFI Drivers Vs. Applications 09]
UEFI Drivers Vs. Applications
Note:
---?image=/assets/images/slides/Slide25.JPG
@title[Drivers Produce Protocols]
Drivers Produce Protocols
Note:
-
What are the differences between a driver and an Application?
-
Both have EFI_SYSTEM_TABLE and can then access the Handle Database
-
UEFI drivers contains functions specific to one or more protocol implementations, and registers them with the InstallProtocolInterface() Boot Service
-
System firmware returns the Protocol Interface for the protocol that is then used to invoke the protocol specific service.
-
The UEFI Driver keeps private, device specific context with the protocol interfaces.
-
Examples:
-
Device Path, PCI I/O, Disk I/O, GOP, UNDI
-
See § 2.4 UEFI 2.x Spec.
-
+++?image=/assets/images/slides/Slide26.JPG
@title[Drivers Produce Protocols 02]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide27.JPG
@title[Drivers Produce Protocols 03]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide28.JPG
@title[Drivers Produce Protocols 04]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide29.JPG
@title[Drivers Produce Protocols 05]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide30.JPG
@title[Drivers Produce Protocols 06]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide31.JPG
@title[Drivers Produce Protocols 07]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide32.JPG
@title[Drivers Produce Protocols 08]
Drivers Produce Protocols
Note:
+++?image=/assets/images/slides/Slide33.JPG
@title[Drivers Produce Protocols 09]
Drivers Produce Protocols
Note:
@title[UEFI Driver Binding Protocol]
UEFI Driver Binding Protocol
@snap[north-west span-20 fragment]
@fa[star gp-bullet-cyan]
@snapend@snap[north-east span-85 fragment]
@color[yellow](Supported())
Determines if a driver supports a controller
@snap[north-west span-20 fragment]
@fa[star gp-bullet-ltgreen]
@snapend@snap[north-east span-85 fragment]
@color[yellow](Start())
Starts a driver on a controller & Installs Protocols
@snap[north-west span-20 fragment]
@fa[star gp-bullet-gold]
@snapend@snap[north-east span-85 fragment]
@color[yellow](Stop())
Stops a driver from managing a controller
Note:
- Supported ()
- Start()
- Stop()
Supported() - Checks if a driver supports a controller Check should not change hardware state of controller Minimize execution time, move complex I/O to Start() May be called for controller that is already managed Child is optionally specified
Start() - Starts a driver on a controller Can create ALL child handles or ONE child handle A driver is not required to support starting ONE child handle. It may always create ALL child handles.
Stop() - Stops a driver from managing a controller Destroys all specified child handles If no children are specified, controller is stopped immediately Stopping a bus controller requires two calls
@title[Supported - PCI Controller Device Handle]
Supported - PCI Controller Device Handle
@snap[north-west span-50]PCI Controller Device Handle |
`EFI_DEVICE_PATH_PROTOCOL` |
`EFI_PCI_IO_PROTOCOL` |
@snapend
@snap[west span-50 fragment]
Tasks:
- 1. @color[yellow](Opens) PCI_IO Protocol
- 2. Checks
- 3. @color[yellow](Closes) PCI_IO Protocol
- 4. Returns: Supported or Not
Supported
@snap[north-east span-50 fragment]
Inputs:
- “This”
- Controller to manage
- Remaining Device Path
@snap[east span-50 fragment]
`Supported()`
- Checks to see if a driver supports a controller
- Check should not change hardware state of controller
- Minimize execution time, move complex I/O to Start()
- May be called for controller that is already managed
- Child is optionally specified
@snapend
Note:
@title[Start - PCI Controller Device Handle]
Start - PCI Controller Device Handle
@snap[north-east span-50 fragment]
Inputs:
- “This”
- Controller to manage
- Remaining Device Path
@snap[east span-50 fragment]
`Start()`
- @color[yellow](Opens) PCI I/O Protocol
- Starts a driver on a controller
- Can create ALL child handles or ONE child handle (i.e. Call Install Library)
@snapend
@snap[north-west span-50]
PCI Controller Device Handle |
`EFI_DEVICE_PATH_PROTOCOL` |
`EFI_PCI_IO_PROTOCOL` |
`EFI_BLOCK_IO_PROTOCOL` |
@snapend
Note:
@title[Stop - PCI Controller Device Handle]
Stop - PCI Controller Device Handle
@snap[north-west span-50]
PCI Controller Device Handle |
`EFI_DEVICE_PATH_PROTOCOL` |
`EFI_PCI_IO_PROTOCOL` |
`EFI_BLOCK_IO_PROTOCOL` |
@snapend
@snap[north-east span-50 fragment]
Inputs:
- “This”
- Controller to manage
- Remaining Device Path
@snap[east span-50 fragment]
`Stop()`
- @color[yellow](Closes) PCI I/O Protocol
- Destroys all specified child handles (i.e. Call Uninstall)
- If no children specified, controller is stopped
- Stopping a bus controller requires 2 calls
- One call to stop the children. A second call to stop the bus controller itself
@snapend
Note:
+++
@title[Stop - PCI Controller Device Handle 02]
Stop - PCI Controller Device Handle
@snap[north-west span-50]
PCI Controller Device Handle |
`EFI_DEVICE_PATH_PROTOCOL` |
`EFI_PCI_IO_PROTOCOL` |
@snapend
@snap[north-east span-50 ]
Inputs:
- “This”
- Controller to manage
- Remaining Device Path
@snap[east span-50 ]
`Stop()`
- @color[yellow](Closes) PCI I/O Protocol
- Destroys all specified child handles (i.e. Call Uninstall)
- If no children specified, controller is stopped
- Stopping a bus controller requires 2 calls
- One call to stop the children. A second call to stop the bus controller itself
@snapend
Note:
---?image=assets/images/binary-strings-black2.jpg
@title[UEFI Driver Example Section ]
Exam details of the UEFI Driver - ScsiDiskDxe
---?image=/assets/images/slides/Slide48.JPG
@title[Example: UEFI Driver - ScsiDiskDxe]
Example: UEFI Driver - ScsiDiskDxe
@fa[github gp-bullet-black] edk2/MdeModulePkg/Bus/Scsi/ScsiDiskDxe
Note:
+++?image=/assets/images/slides/Slide49.JPG
@title[Example: UEFI Driver - ScsiDiskDxe 02 -1]
Example: UEFI Driver - ScsiDiskDxe
@fa[github gp-bullet-black] edk2/MdeModulePkg/Bus/Scsi/ScsiDiskDxe
Note:
- Entry point, Global Protocols – see the BY_START and TO_START usages in the protocols
+++ @title[Example: UEFI Driver - ScsiDiskDxe 02 -2]
Example: UEFI Driver - ScsiDiskDxe
```php [Defines] INF_VERSION = 0x00010005 BASE_NAME = ScsiDisk MODULE_UNI_FILE = ScsiDisk.uni FILE_GUID = 0A66E322-3740-4cce-AD62-BD172CECCA35 MODULE_TYPE = UEFI_DRIVER VERSION_STRING = 1.0
ENTRY_POINT = InitializeScsiDisk
[Sources] ComponentName.c ScsiDisk.c ScsiDisk.h
[Packages] MdePkg/MdePkg.dec
[LibraryClasses] UefiBootServicesTableLib UefiScsiLib BaseMemoryLib MemoryAllocationLib UefiLib UefiDriverEntryPoint DebugLib DevicePathLib
[Protocols] gEfiDiskInfoProtocolGuid ## BY_START gEfiBlockIoProtocolGuid ## BY_START gEfiBlockIo2ProtocolGuid ## BY_START gEfiEraseBlockProtocolGuid ## BY_START gEfiScsiIoProtocolGuid ## TO_START gEfiScsiPassThruProtocolGuid ## TO_START gEfiExtScsiPassThruProtocolGuid ## TO_START
[Guids] gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_PRODUCES ## UNDEFINED gEfiDiskInfoIdeInterfaceGuid ## SOMETIMES_PRODUCES ## UNDEFINED gEfiDiskInfoAhciInterfaceGuid ## SOMETIMES_PRODUCES ## UNDEFINED gEfiDiskInfoUfsInterfaceGuid ## SOMETIMES_PRODUCES ## UNDEFINED
[UserExtensions.TianoCore."ExtraFiles"] ScsiDiskExtra.uni
@[8-9](Entry point function)
Note:
---?image=/assets/images/slides/Slide50.JPG
@title[Example: UEFI Driver - ScsiDiskDxe 03 -1]
<p align="right"><span class="gold" ><b>Example: UEFI Driver - ScsiDiskDxe</b></span></p>
<br>
@fa[github gp-bullet-black]<span style="font-size:0.7em"> <a href="https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Bus/Scsi/ScsiDiskDxe">edk2/MdeModulePkg/Bus/Scsi/ScsiDiskDxe</a></span><br>
Note:
- Driver’s Private Data Structure declaration – Data structures for managing a SCSI disk device
+++?code=sample/ScsiDiskDxe/ScsiDisk.h&lang=c++&title=Example: ScsiDisk.h
@[55-99]( UEFI Driver's Private Data Structure declaration)
Note:
---?image=/assets/images/slides/Slide51.JPG
@title[Example: UEFI Driver - ScsiDiskDxe 04 -1]
<p align="right"><span class="gold" ><b>Example: UEFI Driver - ScsiDiskDxe</b></span></p>
<br>
@fa[github gp-bullet-black]<span style="font-size:0.7em"> <a href="https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Bus/Scsi/ScsiDiskDxe">edk2/MdeModulePkg/Bus/Scsi/ScsiDiskDxe</a></span><br>
Note:
- Driver’s Private Data Structure declaration – Data structures for managing a SCSI disk device
+++?code=sample/ScsiDiskDxe/ScsiDisk.c&lang=c++&title=Example: ScsiDisk.c
@[16-33](Module Data Structures for Binding Protocol and SCSI Dick Info Protocol - Produced)
@[89-113]( Entry point, notice only Install of Binding and Component Name Protocol)
@[134-174]( The Supported Function, Only Checks and returns Supported or Unsupported)
@[196-204](Start Function Entry)
@[318-337](Start calls Install function to create handles for Multiple Protocols)
@[394-402](Stop Function Entry)
@[439-459](Stop Calls Un-install function matching the Start's Install)
Note:
- See the Start makes a call : Status = gBS->InstallMultipleProtocolInterfaces Line 320
---
@title[Summary]
<BR>
### <p align="center"><span class="gold" >Summary </span></p><br>
<ul style="list-style-type:none">
<li>@fa[certificate gp-bullet-green]<span style="font-size:0.9em"> What is the UEFI Driver Model</span> </li><br>
<li>@fa[certificate gp-bullet-cyan]<span style="font-size:0.9em"> Details on Driver Binding Protocol</span></li><br>
<li>@fa[certificate gp-bullet-yellow]<span style="font-size:0.9em"> Example of UEFI Driver</span> </li>
</ul>
---?image=assets/images/gitpitch-audience.jpg
@title[Questions]
<br>
![Questions](/assets/images/questions.JPG)
---?image=assets/images/gitpitch-audience.jpg
@title[Logo Slide]
<br><br><br>
![Logo Slide](/assets/images/TianocoreLogo.png =10x)
---
@title[Acknowledgements]
#### <p align="center"><span class="gold" >Acknowledgements</span></p>
```c++
/**
Redistribution and use in source (original document form) and 'compiled' forms (converted
to PDF, epub, HTML and other formats) with or without modification, are permitted provided
that the following conditions are met:
Redistributions of source code (original document form) must retain the above copyright
notice, this list of conditions and the following disclaimer as the first lines of this
file unmodified.
Redistributions in compiled form (transformed to other DTDs, converted to PDF, epub, HTML
and other formats) must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials provided with the
distribution.
THIS DOCUMENTATION IS PROVIDED BY TIANOCORE PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TIANOCORE PROJECT BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
Copyright (c) 2020, Intel Corporation. All rights reserved.
**/