Skip to content

Latest commit

 

History

History
2047 lines (1555 loc) · 83.3 KB

PITCHME.md

File metadata and controls

2047 lines (1555 loc) · 83.3 KB

---?image=assets/images/gitpitch-audience.jpg @title[EDK II Modules]




UEFI & EDK II Training

EDK II Modules: Libs, Drivers & Apps


tianocore.org Note: PITCHME.md for UEFI / EDK II Training EDK II Modules: Libs, Drivers & Apps 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:

  1. 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.

  2. 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]

<p align="center"Lesson Objective



@fa[certificate gp-bullet-green]  What is a EDK II Module
@fa[certificate gp-bullet-cyan]  Use EDK II libraries to write UEFI apps/drivers
@fa[certificate gp-bullet-yellow]  How to Define a UEFI application
@fa[certificate gp-bullet-magenta]  Differences between UEFI App / Drivers INF file

---?image=assets/images/binary-strings-black2.jpg @title[Modules Overview Section]




     EDK II Modules Overview

        What are EDK II Modules

---?image=/assets/images/slides/Slide4.JPG @title[Modules]

Modules

@css[text-white fragment]( Smallest separate object compiled in EDK II)


@css[text-yellow fragment](@color[yellow](Compiles to)
@color[yellow](.EFI File)
)

@snap[east span-35] @css[ text-white fragment](UEFI/DXE Driver
@coloryellow
@color[orange](UEFI App.)
or
@color#00ffff
) @snapend

@snap[south span-90 fragment] @box[bg-purple-pp-trans text-white rounded](Modules:   Building Blocks of EDK II) @snapend

Note:

So the first thing we have in trying to break EDK II down is Modules:

  • A module is the smallest separate object compiled in the EDK II. A module is a single resultant .EFI file.

  • Module examples:

  • A UEFI/DXE driver

  • A PEIM

  • A UEFI application

  • A Library

  • All of these could be a module. A modules could be one entity


@title[Module Types]

Module Types

@snap[north span-60 fragment]


@box[bg-purple-pp text-white ](Most Used Module Types) @snapend

@snap[north-west span-100 fragment]






@color[#00b0f0](PEI_CORE)                  @color[yellow](UEFI_APPLICATION)                @color[orange](DXE_CORE)

@color[orange](BASE)                             @color[#00b0f0](DXE_RUNTIME_DRIVER)        

@color[#87E2A9](PEIM)                             @color[yellow](UEFI_DRIVER)                         @color[#87E2A9](DXE_DRIVER)

@snapend

@snap[south span-100 fragment]

syntax:
<ModuleTypes>  ::=  <ModuleType> [<Space> <ModuleType>]

@snapend

@snap[north-west span-90 fragment]










                                    
@color[red](⤑)

@snapend

Note:

  • BASE
  • SEC
  • PEI_CORE
  • PEIM
  • DXE_CORE
  • DXE_DRIVER
  • DXE_RUNTIME_DRIVER
  • DXE_SAL_DRIVER
  • DXE_SMM_DRIVER
  • UEFI_DRIVER
  • UEFI_APPLICATION
  • BASE LIBRARY
  • SECURITY_CORE
  • PEI_CORE
  • COMBINED_PEIM_DRIVER
  • PIC_PEIM
  • RELOCATABLE_PEIM
  • BS_DRIVER
  • RT_DRIVER
  • SAL_RT_DRIVER
  • APPLICATION

There are many Module types. This also determines how the module code is compiled and how libraries are associated with each module.

the syntax is: as shown on the slide

First we will show the UEFI_APPLICATION type of module since it is the simplest and can be somewhat independent from the underlining hardware.


@title[Module Source - minimum files]

Module Source Contents - minimum files

MODULE_TYPE

Example Source files

UEFI_APPLICATION

@color[yellow](Foo.c, Foo.inf )

UEFI_DRIVER

@color[yellow](FooDriver.c, FooDriver.h, FooDriver.vfr,
FooDriver.uni, FooDriver.inf
)

DXE_DRIVER

@color[yellow](FooDxe.c, FooDxe.h, FooDxe.inf)

DXE, UEFI or PEIM Library

@color[yellow](FooLib.c, FooLib.h, FooLib.inf )   ( w/ LIBRARY_CLASS= )

@snap[south-west span-100] @box[bg-brick-trans text-white rounded fragment ](Complexity - Greater number of source files) @box[bg-lt-orange-trans text-white rounded fragment ](.INF file - One file is required per module) @box[bg-gold2-trans text-white rounded fragment ](.EFI file - Sources compiled to a single .EFI file) @snapend

Note:

Example of the naming and number of files associated with the modules types

  • the number of files is based on the Complexity of the UEFI / DXE driver and or UEFI application
  • There is a requirement that a module must have at least 1 .INF file
  • The resulting compilation will be a .EFI file

---?image=assets/images/binary-strings-black2.jpg @title[EDK II Library Modules Section]




     EDK II Library Modules

        


@title[Library Class ]

Library Class

Syntax: ``` [LibraryClasses.common] |

DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf


@snap[west span-20]
@box[bg-royal text-white rounded fragment ](<span style="font-size:01.20em" ><b>Name</b></span>)
@snapend

@snap[west span-25 fragment]
<p align="right"><span style="font-size:02.50em" >@color[yellow](<b>&vert;</b>)</span></p>
@snapend

@snap[midpoint span-40 fragment]
@box[bg-purple-pp text-white rounded  ](<span style="font-size:01.20em" ><b>Implementation<sup>1</sup></b></span>)
@snapend

@snap[midpoint span-40 fragment]
@box[bg-green2 text-white rounded  ](<span style="font-size:01.20em" ><b>Implementation<sup>2</sup></b></span>)
@snapend

@snap[midpoint span-40 fragment]
@box[bg-brick text-white rounded  ](<span style="font-size:01.20em" ><b>Implementation<sup>3</sup></b></span>)
@snapend


@snap[south span-80 ]
@box[bg-green text-white rounded fragment ](<span style="font-size:01.20em" ><b>Consistent set of interfaces</b></span>)
<br>
<br>
<br>
@snapend

@snap[south span-100 ]
@box[bg-purple-pp text-white rounded fragment ](<span style="font-size:01.20em" ><b>Does not describe implementation of the interfaces</b></span>)
@snapend



Note:

#### Syntax for the .dsc file when mapping Libraries to modules

- [LibraryClasses.common]
-   <LibraryClassName>|<LibraryInstancePathToInf/Name.inf>
-   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

It has a library class name, a pipe symbol and then a library instance, which is identified by the path to the INF, then the INF itself. 

So for example, the “DebugLib”, class is identified by the MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
The library instance, BaseDebugLibNull, has all the required interfaces for debug Lib.  And that’s the one that will be linked against the modules in this example.


- Consistent set of interfaces 
#### First, a basic library class definition: <br>
A library class is a set of interfaces; it does not have any implementation information

It is identified by one GUID. And usually contains
- some macros, 
- sometimes global variables, 
- some functions uniquely

 Each library class has one GUID, and there is a mapping of a library class to library instance. 
For example there may be three library instances for a given function and one library class that they would all represent. In this example, the DSC file is going to map library class to a library instance.


- Does not describe implementation of the interfaces
- The implementation is decided at the platform level
- DSC file maps class to instance

- library class

- At the top of the slide there is an example of [libraryclasses.common] for a DSC file.


---
@title[NULL Library Class]
<p align="right"><span class="gold" ><b>"NULL" Library Class</b></span></p>
<br>
<br>
<br>
<br>
<span style="font-size:0.85em">@color[yellow](<b>Syntax:</b>)</span>
```xml
    Pkg/MyModule/MyModule.inf {
    	 <LibraryClasses>
      	NULL|Pkg/Library/LibName/LibName.inf
      	NULL|Pkg/Library/LibName2/LibName2.inf
  	}


@color[yellow](UEFI Shell example:)

    ShellPkg/Application/Shell/Shell.inf {
     <LibraryClasses>
       NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
	  . . .
    }      

@snap[north-west span-40]


@box[bg-royal text-white rounded fragment ](Constructors) @snapend

@snap[north-east span-40]


@box[bg-lt-orange text-white rounded fragment ](Special Cases) @snapend

@snap[north span-65]





@box[bg-navy text-white rounded fragment ](NOT   "...LibNull"   instance) @snapend

@snap[south-east span-40] @box[bg-purple-pp text-white rounded my-box-pad fragment ](

Open Source Example
DxeCrc32GuidedSectionExtractLib
ShellPkg as used with Profiles
 

)
@snapend

Note:

  • Not a named library
  • Not related to LibNull instances (DebugLibNull)
  • May not produce any interfaces
  • Does all work in constructors
  • Can be linked more than once
  • Used for special cases
  • DXE Core and DXE IPL section file interpreters
  • ShellPkg uses the NULL named library with its profiles, thus when compiling a version of the UEFI Shell application, all that is needed is to include the interface as shown in the example on this slide.

@title[Locating library classes]

Locating Library Classes

@snap[north-west span-100]

@box[bg-royal text-white rounded my-box-pad fragment](

                       Library based upon
       1. Industry specifications (UEFI, PCI, USB, etc.)
             @color[yellow](MdePkg/MdeModulePkg)
       2. Intel’s framework1 specs
             @color[yellow](IntelFrameworkPkg/IntelFrameworkModulePkg)
 

) @box[bg-brick text-white rounded my-box-pad fragment](Use the package help files (.CHM) to find a library or function
Example: MdePkg.chm
)
@box[bg-green text-white rounded fragment]( Search WorkSpace (.INF) "LIBRARY_CLASS" ) @snapend

@snap[south-west span-50] 1Intel® Platform Innovation Framework for UEFI @snapend

Note:

How do you find library classes?
The simple answer is ”you have to know what the library class is based on.”

  • For example, if it is based on industry standards like the UEFI, PI, SMBIOS, ACPI, etc…you are probably going to find it in the MDE package or maybe in the MDE module package.

---?image=/assets/images/slides/Slide11_1.JPG @title[Library Instance Hierarch]

Library Instance Hierarchy

@snap[north-west span-30]

@color[yellow](Form)
a hierarchy similar to UEFI drivers

@snapend

@snap[north-east span-30]

@color[yellow](Link)
your module to another

@snapend

@snap[north span-100]



@css[text-white fragment](

DebugLib

) @css[text-white fragment](

DebugLibSerialPort
(Instance)

) @css[text-white fragment](


SerialPort (Class)

) @css[text-white fragment](


MdePkg (Specs)

) @css[text-white fragment](



@color[red](Build error):Instance of Library class [Foo...Lib] is not found...
Consumed by module [My Module.inf]

)

@snapend

Note:

  • when the error Build : error 4000 : Instance of Library class [Foo…Lib] is not found in [WorkSpace/some module Lib.inf] consumed by module [WorkSpace/My Module.inf]

  • Library Instances (NOT Library Classes) form a hierarchy similar to UEFI drivers Some Library Instances will link your module to another Library DebugLib (Class)

  • DebugLibSerialPort (Instance)

  • SerialPort (Class)

  • Etc…

The build process handles this, as long as a Library Instance is listed somewhere in the module hierarchy in the .DSC file

Library instances, not library classes, form a hierarchy very similar to the way drivers work. One library instance you link to may link another library class without your awareness:

For example, If you linked the debug Lib and then someone doing the platform decides that they will use the debug Lib serial port for your debug Lib class, That debug serial port instance links against the serial Port library class which now links its own library instance.

Now the build will handle this all in the background. When it looks in your INF file it is going to see debug Lib, and when you look at the debug serial port it’s going to see serial port.

As long as there is at least one of each library instance in the workspace and in DSC file, it will be built behind the scenes. You won’t even realize that there is more than one dependency under your module, and behind the scenes is doing this for everything. Another NOTE: Most libraries are dependent on another library the same way that .c and .h files are dependent upon some other .c and .h files..


@title[Commonly Used Base Library Classes]

Commonly Used Base Library Classes

@snap[north-west span-100 fragment]

BaseLib   DebugLib
     UefiLib
 UefiApplicationEntryPoint

@snapend

@snap[north-east span-100 fragment]

@color[yellow](UefiDriverEntryPoint)
UefiBootServicesTableLib  
@color[yellow](DxeCoreEntryPoint)  
DevicePathLib  IoLib
  PrintLib  @color[yellow](PeimEntryPoint)
 UefiScsiLib @color[#87E2A9](BaseMemoryLib)

@snapend

@snap[north-west span-100 fragment]




CpuLib  UefiUsbLib PciLib
@color[#87E2A9](MemoryAllocationLib)
 @color[yellow](PeiCoreEntryPoint)
   UefiRuntimeLib     @color[#87E2A9](SmmMemLib)

@snapend

@snap[north-west span-100 fragment]








 @color[#00b0f0](DxeSerivesLib)   @color[yellow](SynchronizationLib) PciExpressLib
DxePcdLib      @color[#00b0f0](UefiRuntimeServicesTableLib)
   PciSegmentLibLib  @color[yellow](PeiServicesLib)
  PeiPcdLib  DxeHobLib   @color[#87E2A9](UefiFileHandleLib)

@snapend

@snap[south span-90] @box[bg-purple-pp text-white rounded my-box-pad fragment ](

@coloryellow   Many Libraries in the EDK II code
 

) @snapend

Note: Key point is that this soon becomes an Eye chart of many - MANY Many Libraries in the EDK II code

---?image=/assets/images/slides/Slide48.JPG @title[MdePkg Library Doc. Location ]

MdePkg Library .CHM file Location

tianocore.org UDK2018 Documentation on

@fa[github gp-bullet-gold]  Latest UDK Release


@fa[github gp-bullet-gold]  UDK2018

---?image=/assets/images/slides/Slide51.JPG

@title[Library Navigation Demonstration]

Library Navigation Demonstration

Note:

  • Install a CHM Viewer for Ubuntu
bash$ sudo aptitude install kchmviewer

chm file unlock – right click –properties –check unblock

+++?image=/assets/images/slides/Slide42.JPG

@title[Library Navigation Demonstration video]

Library Navigation Demonstration

![video](https://www.youtube.com/embed/s8Zw1w1iQS4) Note:
  • Install a CHM Viewer for Ubuntu
bash$ sudo aptitude install kchmviewer

chm file unlock – right click –properties –check unblock

---?image=assets/images/binary-strings-black2.jpg @title[EDK II UEFI Applications Section]




     EDK II UEFI Applications

        

---?image=/assets/images/slides/Slide54.JPG @title[Defining a UEFI Application]

Defining a UEFI Application

Characteristics of a UEFI Loadable Image

@ul[no-bullet] - @fa[certificate gp-bullet-white]  Loaded by UEFI loader, just like drivers - @fa[certificate gp-bullet-white]  Does not register protocols - @fa[certificate gp-bullet-white]  Consumes protocols - @fa[certificate gp-bullet-white]  Typically exits when completed (user driven ) - @fa[certificate gp-bullet-white]  Same set of interfaces as drivers available @ulend

Note: @fa[certificate gp-bullet-green]  What is a EDK II Module

UEFI Applications are just like UEFI drivers, they are loadable images.

Their difference lies in that they typically do not register protocols like a driver does. They typically consume protocols to do a user driven task.

The same set of UEFI or firmware interfaces are available to applications that drivers have. Thus they are useful for driver prototyping since they can be quickly loaded from the UEFI shell to test the usage of an interface and help you in driver development.

  • What do UEFI Applications do?
  • Extend firmware abstractly
  • Without hardware or OS dependence
  • Portable across platforms
  • IA32, IA64, Intel-64, XScale, Apple*, NT32 emulator, OVMF emulator
  • Enable rapid application development

---?image=/assets/images/slides/Slide56_1.JPG @title[Defining a UEFI Application -Usages]

Defining a UEFI Application

UEFI Loadable Image Usages

@ul[no-bullet] - @fa[certificate gp-bullet-white]  Diagnostics: Platform / Factory - @fa[certificate gp-bullet-white]  Utilities - @fa[certificate gp-bullet-white]  Driver Prototyping - @fa[certificate gp-bullet-white]  “Platform” Applications - @fa[certificate gp-bullet-white]  Portable Across Platforms (IA32, X64, ARM, Itanium, etc.) @ulend

Note: Their usages include factory testing, platform diagnostics (no OS required), and other various pre-boot applications you can think of where the need to do some operation without an OS would be useful.

---?image=/assets/images/slides/Slide58.JPG

@title[Executing Applications]

Executing Applications

Note:

What are the Application Execution steps?

Applications written to the UEFI specification are loaded by the Boot Manager or by other UEFI applications. For Example, the shell is an application .

To load an application the firmware allocates enough memory to hold the image, copies the sections within the application to the allocated memory, and applies the relocation fix-ups needed. Once this is done, the allocated memory is set to be the proper type for code and data for the image. Control is then transferred to the application’s entry point. When the application returns from its entry point, or when it calls the Boot Service Exit(), the application is unloaded from memory and control is returned to the UEFI component that loaded the application.

+++?image=/assets/images/slides/Slide59.JPG

@title[Executing Applications 02]

Executing Applications

Note:

What are the Application Execution steps?

Applications written to the UEFI specification are loaded by the Boot Manager or by other UEFI applications. For Example, the shell is an application .

To load an application the firmware allocates enough memory to hold the image, copies the sections within the application to the allocated memory, and applies the relocation fix-ups needed. Once this is done, the allocated memory is set to be the proper type for code and data for the image. Control is then transferred to the application’s entry point. When the application returns from its entry point, or when it calls the Boot Service Exit(), the application is unloaded from memory and control is returned to the UEFI component that loaded the application.

+++?image=/assets/images/slides/Slide60.JPG

@title[Executing Applications 03]

Executing Applications

Note:

What are the Application Execution steps?

Applications written to the UEFI specification are loaded by the Boot Manager or by other UEFI applications. For Example, the shell is an application .

To load an application the firmware allocates enough memory to hold the image, copies the sections within the application to the allocated memory, and applies the relocation fix-ups needed. Once this is done, the allocated memory is set to be the proper type for code and data for the image. Control is then transferred to the application’s entry point. When the application returns from its entry point, or when it calls the Boot Service Exit(), the application is unloaded from memory and control is returned to the UEFI component that loaded the application.

+++?image=/assets/images/slides/Slide61.JPG

@title[Executing Applications 04]

Executing Applications

Note:

What are the Application Execution steps?

Applications written to the UEFI specification are loaded by the Boot Manager or by other UEFI applications. For Example, the shell is an application .

To load an application the firmware allocates enough memory to hold the image, copies the sections within the application to the allocated memory, and applies the relocation fix-ups needed. Once this is done, the allocated memory is set to be the proper type for code and data for the image. Control is then transferred to the application’s entry point. When the application returns from its entry point, or when it calls the Boot Service Exit(), the application is unloaded from memory and control is returned to the UEFI component that loaded the application.

+++?image=/assets/images/slides/Slide62.JPG

@title[Executing Applications 05]

Executing Applications

Note:

What are the Application Execution steps?

Applications written to the UEFI specification are loaded by the Boot Manager or by other UEFI applications. For Example, the shell is an application .

To load an application the firmware allocates enough memory to hold the image, copies the sections within the application to the allocated memory, and applies the relocation fix-ups needed. Once this is done, the allocated memory is set to be the proper type for code and data for the image. Control is then transferred to the application’s entry point. When the application returns from its entry point, or when it calls the Boot Service Exit(), the application is unloaded from memory and control is returned to the UEFI component that loaded the application.

---?image=/assets/images/slides/Slide65.JPG

@title[Executing OS Load App]

Executing Applications

Note:

Same as the UEFI application except will not return to the UEFI Loader and the OS will take over

+++?image=/assets/images/slides/Slide66.JPG

@title[Executing OS Load App 02]

Executing Applications

Note:

Same as the UEFI application except will not return to the UEFI Loader and the OS will take over

+++?image=/assets/images/slides/Slide67.JPG

@title[Executing OS Load App 03]

Executing Applications

Note:

Same as the UEFI application except will not return to the UEFI Loader and the OS will take over

+++?image=/assets/images/slides/Slide68.JPG

@title[Executing OS Load App 04]

Executing Applications

Note:

Same as the UEFI application except will not return to the UEFI Loader and the OS will take over

+++?image=/assets/images/slides/Slide69.JPG

@title[Executing OS Load App 05]

Executing Applications

Note:

Same as the UEFI application except will not return to the UEFI Loader and the OS will take over

+++?image=/assets/images/slides/Slide70.JPG

@title[Executing OS Load App 06]

Executing Applications

Note:

Same as the UEFI application except will not return to the UEFI Loader and the OS will take over


@title[Driver vs. Application]

Driver Vs. Application

Driver

Application

Loaded by:

UEFI Loader

UEFI Loader

Interface available:

All

All

Consume protocols?

YES

YES

Produce protocols?

YES

NO

Typically Driven by?

System

User

Typically use?

Support Hardware

Any

+++

@title[Driver vs. Application]

Driver Vs. Application

Driver

Application

Loaded by:

UEFI Loader

UEFI Loader

Interface available:

All

All

Consume protocols?

YES

YES

Produce protocols?

YES

NO

Typically Driven by?

System

User

Typically use?

Support Hardware

Any

Note:

---?image=assets/images/binary-strings-black2.jpg @title[Writing EDK II Applications Section]




     EDK II UEFI Applications

        How to Write a EDK II UEFI Application


@title[Application Files Placement]

Application Files Placement

@css[text-white fragment](@fa[certificate gp-bullet-ltgreen]  Application source code can go anywhere in the EDK II
         workspace including PACKAGES_PATH
)

@css[text-white fragment](@fa[certificate gp-bullet-cyan]  All code and include files go under a single directory containing
          an INF
)

@css[text-white fragment](@fa[certificate gp-bullet-yellow]  EDK II Sample Applications can be found here:
            edk2/MdeModulePkg/Application   )

@css[text-white fragment](@fa[certificate gp-bullet-gold]  Typically, modules reside within a package: )

@box[bg-grey-05 text-white rounded my-box-pad fragment](

       /MyWorkSpace   
           /edk2/MyPkg   
               /Application   
                   /MyApp   
 

)

@snap[south-east span-55 fragment] MyAppdir
@snapend

Note:

Same as slide

---?image=/assets/images/slides/Slide35_1.JPG @title[Module .INF File]

Module .INF File


Syntax

    INFfile ::= [<Header>]
          <Defines>
          [<BuildOptions>]
          [<Sources>]
          [<Binaries>]
          [<Guids>]
          [<Protocols>]
          [<Ppis>]
          [<Packages>]
          [<LibraryClasses>]
          [<Pcds>]
          [<UserExtensions>]
          [<Depex>]

Note:

Update to define all Sources (.c, .h, .uni) , libraries, Packages, Guids, PCDs be used by the Module

See EDK II INF File Specification for more details and examples

1 Depex only used with specific Module types


@title[Application INF Files -DEFINES]

Application INF Files [DEFINES]

Field

Description

INF_VERSION

1.25* - Version of the INF spec.

BASE_NAME

What’s the name of the application

FILE_GUID

Create a GUID for your module

MODULE_UNI_FILE

Meta-data - localization for Description, Abstract

VERSION_STRING

Version number

ENTRY_POINT

Name of the entry function to call

MODULE_TYPE

UEFI_APPLICATION

@snap[south-west span-100] *EDK II Specifications: https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Specifications @snapend

Note:

  • There are other optional fields
  • Check the Extended INF Specification

defines

  • INF_VERSION 1.25* - Version of the INF spec.
  • BASE_NAME What’s the name of the application
  • FILE_GUID Create a GUID for your module guidgen.com
  • MODULE_UNI_FILE Meta-data - localization for Description & Abstract
  • VERSION_STRING Version number
  • ENTRY_POINT Name of the function to call ie MyMainEntryPoint();
  • MODULE_TYPE UEFI_APPLICATION

@title[Sample INF file]

Sample INF file

[Defines]
  INF_VERSION                    = 0x00010005
  BASE_NAME                      = MyApplication
  MODULE_UNI_FILE                = MyFile.uni
  FILE_GUID                      = 215cdcfb-1cfc-47e0-9c02-47048c21d20d
  MODULE_TYPE                    = UEFI_APPLICATION
  VERSION_STRING                 = 1.0
  ENTRY_POINT                    = UefiMain

[Sources]
  MyFile.c

[Packages]
  MdePkg/MdePkg.dec
  
[LibraryClasses]
  UefiApplicationEntryPoint
    
[Guids]

[Ppis]

[Protocols]

Note:

+++

@title[Sample INF file]

Sample INF file

[Defines]
  INF_VERSION                    = 0x00010005
  BASE_NAME                      = MyApplication
  MODULE_UNI_FILE                = MyFile.uni
  FILE_GUID                      = 215cdcfb-1cfc-47e0-9c02-47048c21d20d
  MODULE_TYPE                    = UEFI_APPLICATION
  VERSION_STRING                 = 1.0
  ENTRY_POINT                    = UefiMain

[Sources]
  MyFile.c

[Packages]
  MdePkg/MdePkg.dec
  
[LibraryClasses]
  UefiApplicationEntryPoint
    
[Guids]

[Ppis]

[Protocols]

@[1-8](Defines for this .INF file; BASE_NAME results in this name.efi file) @[4-4](OPTIONAL: UNI Text file for localization of descriptions and abstract MyFile.uni) @[5-5](Always get a new quid .i.e http://guidgen.com) @[7-7](User defined string syntax is number dot number) @[8-8](The main entry point of the module in one of the .c files in list of sources) @[10-11]( Source: .c, .h, .uni, .vfr, any files needed for the compiler/linker/lib etc) @[13-17](Package dependencies and Libraries this module will include in its final binary image)

Note:

  • INF_VERSION see spec
  • BASE_NAME BASE_NAME results in this name.efi file
  • MODULE_UNI_FILE OPTIONAL: UNI Text file for localization of descriptions and abstract MyFile.uni
  • FILE_GUID Always get a new quid
  • MODULE_TYPE UEFI_APPLICATION or driver or PEIM or DXE
  • VERSION_STRING User defined string number dot number
  • ENTRY_POINT The main entry point of the module in one of the .c files in list of sources

---?image=/assets/images/slides/Slide88.JPG @title[Building an Application]

Building an Application



Platform .DSC references .INF
  • Runs:
  •    “Build” for the entire platform
  •         OR
  •    “Build” in the application’s directory

Note:

  • Put the INF file in the components section withinin DSC file
  • Platform references .INF file
  • Provides context for the application to build within
  • You can build an app without building the entire platform
  • The DSC for the platform must reference the INF
  • Run “build” for the entire platform
  • Run “build” in the application’s directory
  • Will build any required files (libs, etc…)

@title[Sample Application "C" File]

Sample Application "C" File



```C #include #include

EFI_STATUS EFIAPI UefiMain ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { return EFI_SUCCESS; }



Note:
This sample application does not do anything, it is just a reference.


+++
<!-- .slide: data-background-transition="none" -->
<!-- .slide: data-transition="none" -->
@title[Sample Application "C" File]
<p align="right"><span class="gold" ><b>Sample Application "C" File</b></span></p>
<br>
<br>
```C
#include <Uefi.h>
#include <Library/UefiApplicationEntryPoint.h>


EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  return EFI_SUCCESS;
}

@[7]( The function name is the same as in the .inf file "ENTRY_POINT" define) @[8-9](Parameters passed to EVERY UEFI entry point: Handle to "itself" AKA "this", EFI_SYSTEM_TABLE, a pointer to Everything in the system) @[12]( This function does not really do anything but return "success", EFI_SUCCESS = 0)

Note: This sample application does not do anything, it is just a reference.

---?image=/assets/images/slides/Slide91.JPG @title[UEFI Application Vs. EADK Application]

UEFI Application Vs. EADK Application



  • EDK II Application Development Kit includes the Standard C Libraries in UEFI Shell Applications

  • Off the shelf “C” application Converted to UEFI application

Note:

  • EDK II Application Development Kit includes the Standard C Libraries in UEFI Shell Applications
  • Off the shelf “C” application Converted to UEFI application

@title[Sample INF file using EDK II EADK ]

Sample INF file using EDK II EADK

[Defines]
  INF_VERSION                    = 0x00010005
  BASE_NAME                      = MyApplication
  MODULE_UNI_FILE                = MyFile.uni
  FILE_GUID                      = 215cdcfb-1cfc-47e0-9c09-47048c21d20d
  MODULE_TYPE                    = UEFI_APPLICATION
  VERSION_STRING                 = 1.0
  ENTRY_POINT                    = ShellCEntryLib

[Sources]
  MyFile.c

[Packages]
  StdLib/StdLib.dec
  ShellPkg/ShellPkg.dec
  MdePkg/MdePkg.dec
  
[LibraryClasses]
  LibC
  LibStdio
    
[Guids]

[Ppis]

[Protocols]

Note:

Differences:

  • ENTRY_POINT = ShellCEntryLib

  • [Packages]

    • StdLib/StdLib.dec
    • ShellPkg/ShellPkg.dec
  • [LibraryClasses]

    • LibC
    • LibStdio

+++

@title[Sample INF file using EDK II EADK ]

Sample INF file using EDK II EADK

[Defines]
  INF_VERSION                    = 0x00010005
  BASE_NAME                      = MyApplication
  MODULE_UNI_FILE                = MyFile.uni
  FILE_GUID                      = 215cdcfb-1cfc-47e0-9c09-47048c21d20d
  MODULE_TYPE                    = UEFI_APPLICATION
  VERSION_STRING                 = 1.0
  ENTRY_POINT                    = ShellCEntryLib

[Sources]
  MyFile.c

[Packages]
  StdLib/StdLib.dec
  ShellPkg/ShellPkg.dec
  MdePkg/MdePkg.dec
  
[LibraryClasses]
  LibC
  LibStdio
    
[Guids]

[Ppis]

[Protocols]

@[8]( Entry point is a library in the shell to get parameters from the command line) @[13-15]( Packages included for standard "C" lib and Shell Lib) @[18-21]( Library classes for ANSI "C" and Standard IO "stdio.h")

Note:

Differences:

  • ENTRY_POINT = ShellCEntryLib

  • [Packages]

    • StdLib/StdLib.dec
    • ShellPkg/ShellPkg.dec
  • [LibraryClasses]

    • LibC
    • LibStdio

@title[Sample "C" file using EDK II EADK ]

Sample "C" file using EDK II EADK


This sample looks a lot like actual “C” source.
#include <stdio.h>


  int
  Main (
    IN int Argc,
    IN char **Argv
    )
  {
    return 0;
  }

Note:

simple "C" looks like a normal "C" file


@title[Driver File Placement]

Driver File Placement

@css[text-white fragment](@fa[certificate gp-bullet-ltgreen]  Driver source code can go anywhere in the EDK II
         workspace
)

@css[text-white fragment](@fa[certificate gp-bullet-cyan]  All code and include files go under a single directory containing
          an INF
)

@css[text-white fragment](@fa[certificate gp-bullet-yellow]  Good example of UEFI Drivers can be found here:
            /MdeModulePkg/Bus/ScsiDiskDxe   )

@css[text-white fragment](@fa[certificate gp-bullet-gold]  Typically, Driver modules reside within a package: )

@box[bg-grey-05 text-white rounded my-box-pad fragment](

       /MyWorkSpace   
           /edk2/MyPkg   
               /Include   
               /MyDriver   
 

)

@snap[south-east span-55 fragment]
MyDriverdir

Note: Same as slide


Driver INF Files: [DEFINES]

Field

Description

INF_VERSION

1.25* - Version of the INF spec.

BASE_NAME

What’s the name of the driver

FILE_GUID

Create a GUID for your module

MODULE_UNI_FILE

Meta-data - localization for Description, Abstract

VERSION_STRING

Version number

ENTRY_POINT

Name of the entry function to call

MODULE_TYPE

UEFI_DRIVER, DXE_DRIVER, PEIM, etc...

@snap[south-west span-100] *EDK II Specifications: https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Specifications @snapend

Note:

  • There are other optional fields
  • Check the Extended INF Specification
  • Notice the differences between Application and driver is only the MODULE_TYPE - so simply change the module type and it becomes a driver.

defines

  • INF_VERSION 1.25* - Version of the INF spec.
  • BASE_NAME What’s the name of the DRIVER
  • FILE_GUID Create a GUID for your module
  • MODULE_UNI_FILE Meta-data - localization for Description & Abstract
  • VERSION_STRING Version number
  • ENTRY_POINT Name of the function to call
  • MODULE_TYPE UEFI_DRIVER, DXE_DRIVER, PEIM, or others

---?image=/assets/images/slides/Slide47_1.JPG @title[Changes for a UEFI Driver Module]

Changes for a UEFI Driver Module

@css[text-white fragment](Applications can be converted to a driver )

@css[text-white fragment](@coloryellow . . . It remains in memory after it runs ) @snap[north-east span-15 fragment]

uefi_logo @snapend
@css[text-white fragment](

UEFI Driver Module requirements:
  •  Driver Binding Protocol
  •  Component Name2 Protocol (recommended)

)


@css[text-white fragment](DXE/PEIM/other Driver requirements )

Note:

An Application can be converted to UEFI Drier by simply changing the MODULE_TYPE to UEFI_DRIVER

(But) . . . It remains in memory after it runs

It is better to also add the UEFI Driver Binding Protocol and / or Component Name Protocol (others maybe needed for whatever the job is for the driver that is being created)

Other requirements maybe on DXE and/or PEIM and/or other types of UEFI Drivers i.e. a serial UEFI driver may require the Serial IO protocol


@title[Sample INF Driver file]

Sample Driver INF file

[Defines]
  INF_VERSION                    = 0x00010005
  BASE_NAME                      = MyDriver
  FILE_GUID                      = 215cdcfb-1cfc-47e0-9c02-92d05021d20d
  MODULE_TYPE                    = UEFI_DRIVER
  VERSION_STRING                 = 1.0
  ENTRY_POINT                    = UefiMain

[Sources]
  MyFile.c

[Packages]
  MdePkg/MdePkg.dec
  
[LibraryClasses]
  UefiDriverEntryPoint
    
[Guids]

[Ppis]

[Protocols]

@[4](Always get a new GUID - http://www.guidgen.com ) @[5](UEFI_DRIVER instead of Application) @[15-16](Library for Driver instead of Application)

Note:

---?image=/assets/images/slides/Slide49_1.JPG @title[INF Usage fields – DIST files ]

INF Usage fields – DIST files

@color[yellow](Optional)    UEFI Spec - Package Distribution

Usage field used by the Build tools for creating the .Dist file for binary modules

  • [GUID]
  • [PCD]
  • [PROTOCOL]
  • [PPIS]

1 Usage Block   - "##" After the entry
n Usage Blocks - "##" Precede the entry



@color[yellow](  Usage Key Word)

  • ## UNDEFINED
  • ## CONSUMES
  • ## SOMETIMES_CONSUMES
  • ## PRODUCES
  • ## SOMETIMES_PRODUCES
  • ## TO_START
  • ## BY_START
  • ## NOTIFY
@snap[south-east span-40]

@color[yellow](}) UEFI Protocol  






 


@snapend

Note:

Usage field used by the Build tools for creating the .Dist file for binary modules can be used in applications that parse the .DIST files.

  • Example: PCDs of type "Patch-able"

  • CONSUMES

    • This module does not install the protocol, but needs to locate a protocol. Not valid if the Notify attribute is true.
  • PRODUCES

    • This module will install this protocol. Not valid if the Notify attribute is true.
  • SOMETIMES_CONSUMES

    • This module does not install the protocol, but may need to locate a protocol under certain conditions, (such as if it is present.) If the Notify attribute is set, then the module will use the protocol, named by GUID, via a registry protocol notify mechanism.
  • SOMETIMES_PRODUCES

    • This module will install this protocol under certain conditions. Not valid if the Notify attribute is true.
  • TO_START

    • The protocol is consumed by a Driver Binding protocol Start function. Thus the protocol is used as part of the UEFI driver model. Not valid if the Notify attribute is true.
  • BY_START

    • The protocol is produced by a Driver Binding protocol Start function. Thus the protocol is used as part of the UEFI driver model. Not valid if the Notify attribute is true.
  • NOTIFY

    • This specifies whether this is a Protocol or ProtocolNotify. If set, then the module will use this protocol, named by GUID, via a registry protocol notify mechanism.
  • UNDEFINED

    • Typically, this entry will be used when tools creating/installing UEFI Distribution Packages encounter a missing or misspelled usage. UNDEFINED is also valid when the Protocol is not used as a Protocol and the GUID value of the Protocol is used for something else.

@title[INF File Usage Block examples]

INF File Usage Block examples


[Guids]
  ## SOMETIMES_PRODUCES ## Variable:L"ConInDev"
  ## SOMETIMES_CONSUMES ## Variable:L"ConInDev"
  ## SOMETIMES_PRODUCES ## Variable:L"ConOutDev"
  ## SOMETIMES_CONSUMES ## Variable:L"ConOutDev"
  ## SOMETIMES_PRODUCES ## Variable:L"ErrOutDev"
  ## SOMETIMES_CONSUMES ## Variable:L"ErrOutDev"
  gEfiGlobalVariableGuid
  gEfiVTUTF8Guid                                ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
  gEfiVT100Guid                                 ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
  gEfiVT100PlusGuid                             ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
  gEfiPcAnsiGuid                                ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
  gEfiTtyTermGuid                               ## SOMETIMES_CONSUMES ## GUID # used with a Vendor-Defined Messaging Device Path
  gEdkiiStatusCodeDataTypeVariableGuid          ## SOMETIMES_CONSUMES ## GUID

@[1-8](The Usage Block text comes before the gEfiGlobalVariableGuid GUID) @[9-14](The Usage Block text comes after the referenced GUIDs)

Example: TerminalDxe.inf

Note:

  • CONSUMES
    • This module does not install the protocol, but needs to locate a protocol. Not valid if the Notify attribute is true.
  • PRODUCES
    • This module will install this protocol. Not valid if the Notify attribute is true.
  • SOMETIMES_CONSUMES
    • This module does not install the protocol, but may need to locate a protocol under certain conditions, (such as if it is present.) If the Notify attribute is set, then the module will use the protocol, named by GUID, via a registry protocol notify mechanism.
  • SOMETIMES_PRODUCES
    • This module will install this protocol under certain conditions. Not valid if the Notify attribute is true.
  • TO_START
    • The protocol is consumed by a Driver Binding protocol Start function. Thus the protocol is used as part of the UEFI driver model. Not valid if the Notify attribute is true.
  • BY_START
    • The protocol is produced by a Driver Binding protocol Start function. Thus the protocol is used as part of the UEFI driver model. Not valid if the Notify attribute is true.
  • NOTIFY
    • This specifies whether this is a Protocol or ProtocolNotify. If set, then the module will use this protocol, named by GUID, via a registry protocol notify mechanism.
  • UNDEFINED
    • Typically, this entry will be used when tools creating/installing UEFI Distribution Packages encounter a missing or misspelled usage. UNDEFINED is also valid when the Protocol is not used as a Protocol and the GUID value of the Protocol is used for something else.

+++ @title[INF File Usage Block examples]

INF File Usage Block examples


[Protocols]
  gEfiSerialIoProtocolGuid                      ## TO_START
  ## BY_START
  ## TO_START
  gEfiDevicePathProtocolGuid
  gEfiSimpleTextInProtocolGuid                  ## BY_START
  gEfiSimpleTextInputExProtocolGuid             ## BY_START
  gEfiSimpleTextOutProtocolGuid                 ## BY_START

[Pcd]
  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType           ## SOMETIMES_CONSUMES
  gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable    ## CONSUMES

@[3-5](The Usage Block text comes before the gEfiDevicePathProtocolGuid protocol GUID) @[7-12](The Usage Block text comes after the referenced protocol GUIDs and PCDs)

Example: TerminalDxe.inf

Note:

  • CONSUMES
    • This module does not install the protocol, but needs to locate a protocol. Not valid if the Notify attribute is true.
  • PRODUCES
    • This module will install this protocol. Not valid if the Notify attribute is true.
  • SOMETIMES_CONSUMES
    • This module does not install the protocol, but may need to locate a protocol under certain conditions, (such as if it is present.) If the Notify attribute is set, then the module will use the protocol, named by GUID, via a registry protocol notify mechanism.
  • SOMETIMES_PRODUCES
    • This module will install this protocol under certain conditions. Not valid if the Notify attribute is true.
  • TO_START
    • The protocol is consumed by a Driver Binding protocol Start function. Thus the protocol is used as part of the UEFI driver model. Not valid if the Notify attribute is true.
  • BY_START
    • The protocol is produced by a Driver Binding protocol Start function. Thus the protocol is used as part of the UEFI driver model. Not valid if the Notify attribute is true.
  • NOTIFY
    • This specifies whether this is a Protocol or ProtocolNotify. If set, then the module will use this protocol, named by GUID, via a registry protocol notify mechanism.
  • UNDEFINED
    • Typically, this entry will be used when tools creating/installing UEFI Distribution Packages encounter a missing or misspelled usage. UNDEFINED is also valid when the Protocol is not used as a Protocol and the GUID value of the Protocol is used for something else.

---?image=/assets/images/slides/Slide112_1.JPG @title[UEFI Driver Example - Disk I/O]

UEFI Driver Example - Disk I/O


@fa[github gp-bullet-black]  https://github.com/tianocore/edk2 /Disk/DiskIoDxe

Note:

  • PCI Platform DXE
  • Under workspace directory
  • Under the Platform Package

@title[UEFI Driver Example - Disk I/O]

UEFI Driver Example - Disk I/O

@fa[github gp-bullet-gold]  https://github.com/tianocore/edk2 /Disk/DiskIoDxe - entry point

@snap[north-west span-50 ]


"C" file

EFI_STATUS
EFIAPI
InitializeDiskIo (
  IN EFI_HANDLE           ImageHandle,
  IN EFI_SYSTEM_TABLE     *SystemTable
)
  // . . .
  Status = EfiLibInstallDriverBindingComponentName2 (
             ImageHandle,
             SystemTable,
             &gDiskIoDriverBinding,
             ImageHandle,
             &gDiskIoComponentName,
             &gDiskIoComponentName2
             );
  ASSERT_EFI_ERROR (Status);
  return Status;
}
@[3](Entry point for this UEFI Driver) @[8-11](Install -Supported, Start and Stop for the UEFI Driver binding protocol) @[3-17](The UEFI Driver Only does the Install then EXITs)

@snapend

@snap[north-east span-48 ]


INF file

[Defines]
 . . .
  ENTRY_POINT  = InitializeDiskIo

@snapend

Note:


@title[UEFI Driver Example - Disk I/O 02]

UEFI Driver Example - Disk I/O

@fa[github gp-bullet-gold]  https://github.com/tianocore/edk2 /Disk/DiskIoDxe - Supported

@snap[north-west span-50 ]


"C" file

EFI_STATUS
EFIAPI
DiskIoDriverBindingSupported (
  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
  IN EFI_HANDLE                   ControllerHandle,
  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
  )
{
  Status = gBS->OpenProtocol (
	ControllerHandle,
      &gEfiBlockIoProtocolGuid,
      (VOID **) &BlockIo,
	  This->DriverBindingHandle,
	  ControllerHandle,
	  EFI_OPEN_PROTOCOL_BY_DRIVER
	);
	

@[3](Entry point for Supported) @[11]( Using the global gEfiBlockIoProtocolGuid protocol to determine if this device controller handle is a Block I/O device)

@snapend

@snap[north-east span-48 ]


INF file

[Protocols]
  . . .
  gEfiBlockIoProtocolGuid  ## TO_START

@snapend

Note:

Using the global gEfiBlockIoProtocolGuid protocol to determine if this device controller handle is a Block I/O device


@title[UEFI Driver Example - Disk I/O 03]

UEFI Driver Example - Disk I/O

@fa[github gp-bullet-gold]  https://github.com/tianocore/edk2 /Disk/DiskIoDxe - Start

@snap[north-west span-50 ]


"C" file

EFI_STATUS
EFIAPI
 DiskIoDriverBindingStart (
  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
  IN EFI_HANDLE                   ControllerHandle,
  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
  )
{

  if (Instance->BlockIo2 != NULL) {
    Status = gBS->InstallMultipleProtocolInterfaces (
	&ControllerHandle,
	&gEfiDiskIoProtocolGuid,  &Instance->DiskIo,
	&gEfiDiskIo2ProtocolGuid, &Instance->DiskIo2,
	NULL	
	);
	

@[3](Entry point for Start function) @[13-14]( Using the global gEfiDiskIoProtocolGuid and gEfiDiskIo2ProtocolGuid protocols to INSTALL handles to) @snapend

@snap[north-east span-48 ]


INF file

[Protocols]
  . . .
  gEfiDiskIoProtocolGuid   ## BY_START
  gEfiDiskIo2ProtocolGuid  ## BY_START

@snapend

Note:

---?image=/assets/images/slides/Slide117_1.JPG @title[DXE Driver Example - PlatformInfoDxe]

DXE Driver Example - PlatformInfoDxe


@fa[github gp-bullet-black]  https://github.com/tianocore/edk2-platforms/ PlatformInfoDxe

Note:

  • PCI Platform DXE
  • Under workspace directory
  • Under the Platform Package

@title[DXE Example .INF File - PlatformInfoDxe]

DXE Driver Example - PlatformInfoDxe

@fa[github gp-bullet-gold]  https://github.com/tianocore/edk2-platforms/ PlatformInfoDxe

@snap[north-west span-50 ]


"C" file

#include “PlatformInfoDxe.h“
// • • •
EFI_STATUS
EFIAPI
PlatformInfoInit (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
/*++
{
// • • •
  return Status;
}

@snapend

@snap[north-east span-48 ]


INF file

[Defines]
 . . .
  MODULE_TYPE     = DXE_DRIVER
  VERSION_STRING  = 1.0
  ENTRY_POINT     = PlatformInfoInit
 . . .

[Depex]
  gEfiVariableArchProtocolGuid AND 
    gEfiVariableWriteArchProtocolGuid

@snapend

@snap[south-west span-100 ] Notice the MODULE TYPE, C function Entry point and the [Depex] differences in the INF file


@snapend

Note:

MODULE_TYPE = DXE_DRIVER

Depex section is part of the Dxe driver INF file

---?image=/assets/images/slides/Slide121_1.JPG @title[PEI Driver (PEIM) Example - CpuIoPei]

PEI Driver (PEIM) Example - CpuIoPei


@fa[github gp-bullet-black]  https://github.com/tianocore/edk2/ UefiCpuPkg/CpuIoPei

Note:

  • PCI Platform DXE
  • Under workspace directory
  • Under the Platform Package

@title[PEI Driver (PEIM) Example - CpuIoPei]

PEI Driver (PEIM) Example - CpuIoPei

@fa[github gp-bullet-gold]  https://github.com/tianocore/edk2/ UefiCpuPkg/CpuIoPei @snap[north-west span-50 ]


"C" file

#include “CpuIoPei.h“
 //• • •
EFI_STATUS
EFIAPI
CpuIoInitialize (
  IN EFI_PEI_FILE_HANDLE     FileHandle,
  IN CONST EFI_PEI_SERVICES  **PeiServices
  )
{
  EFI_STATUS  Status;
 //• • •
  return EFI_SUCCESS;
}

@[5](Entry point for this Dxe Driver) @[6-7]("FileHandle" - Instead of the ImageHandle & NO EFI_SYSTEM_TABLE - Not yet defined)

@snapend

@snap[north-east span-48 ]


INF file

``` [Defines] . . . MODULE_TYPE = PEIM VERSION_STRING = 1.0 ENTRY_POINT = CpuIoInitialize . . .

[Depex] TRUE

@snapend

Note:

- INF file Module type PEIM

- "FileHandle" - Instead of the ImageHandle & 
- NO EFI_SYSTEM_TABLE - because it is Not yet defined so pointer to the PEI Services is uses similar to EFI System table

---  
@title[Summary]
<BR>
### <p align="center"><span class="gold"   >Summary </span></p><br>
<br>
 @fa[certificate gp-bullet-green]<span style="font-size:0.9em">&nbsp;&nbsp;What is a EDK II Module</span><br>
 @fa[certificate gp-bullet-cyan]<span style="font-size:0.9em">&nbsp;&nbsp;Use EDK II libraries to write UEFI apps/drivers</span><br>
 @fa[certificate gp-bullet-yellow]<span style="font-size:0.9em">&nbsp;&nbsp;How to Define a UEFI application</span> <br>
 @fa[certificate gp-bullet-magenta]<span style="font-size:0.9em">&nbsp;&nbsp;Differences between UEFI App / Drivers INF file</span><br>

 

---?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.
**/