当前位置:网站首页>Create inf module in AMI code

Create inf module in AMI code

2022-07-05 07:51:00 Yang_ Winston

Module Introduce

  • Modularity is UEFI One of the features of , This brings many benefits , For example, it improves reusability 、 Reduce coupling, etc .
  • The module is UEFI The smallest unit of code that can be compiled separately , After compiling successfully, it will generate .efi file .
  • stay AMI Of code in , Create a Module Need to pay attention to inf file 、sdl file 、c The header file of the file contains , Sometimes you need to check dec Document and cif file . If it's in edk2 Based on the development of , Attention is also needed dsc file .

INF file

  • INF The file is the engineering file of the module ,EDKII The parser of will use INF The information in the file is generated AutoGen.c、AutoGen.h and Makefile/GNU Makefile file .
  • Only in INF Only the module source files listed in the file are processed by the compilation system . Other documents , For example, the header file in the package does not need to be in INF The document lists , Because they use [Packages] Extracted by the package listed in section .
  • INF The file contains many Section, yes , we have Section Is a must , yes , we have Section It's optional .

INF The file can contain Section as follows :

  • [Defines] Section
  • [Sources] Section
  • [BuildOptions] Section
  • [Binaries] Section
  • [Includes] Section
  • [Protocols] Section
  • [Ppis] Section
  • [Guids] Section
  • [LibraryClasses] Section
  • [Packages] Section
  • PCD Section
  • [Depex] Section
  • [UserExtensions] Section

[Defines]

Required blocks , be-all INF All files should contain this block . Be careful , these Sections Yes, according to the INF In the order listed in the document , Subsequent assignments of these local symbols will overwrite the previous assignments . Its format is : Name = Value

PEIM Of [Defines] block
Library Of [Defines] block

Defines There are many in the block Element, Some are necessary , Some are optional .

  • INF_VERSION: Required , To specify INF Spec edition . If there are incompatible changes , The tool uses this value to handle parsing of previous versions of the specification .※
  • BASE_NAME: Required , Identify the Module Of component name.※
  • EDK_RELEASE_VERSION: Not required .
  • PI_SPECIFICATION_VERSION: Not required .
  • UEFI_SPECIFICATION_VERSION: Not required , If the module depends UEFI 2.1 Later definitions , This definition is in UEFI
    2.1 There is no , Then this item must be set .
  • FILE_GUID: Required , be-all driver INF All documents need , except library INF file .※
  • MODULE_TYPE: Required , Indicate the type of module , Some common module types will be introduced later .※
  • BUILD_NUMBER: optional .
  • VERSION_STRING: Required , Module version string , This value will be used for FFS Of VERSION Partial generation UCS-2LE Code file , Except in [Binaries] Partially formulated ver or ver_ui file .※
  • MODULE_UNI_FILE: optional ,UCS-2 Type string , The file address is relative to INF File directory .
  • LIBRARY_CLASS:Driver You don't have to specify ,Library Module There must be , You can specify which types of module calls are allowed .※
  • PCD_IS_DRIVER: Not required ,Driver Only, The value is PEI_PCD_DRIVER or DXE_PEI_PCD_DRIVER.
  • ENTRY_POINT: Not required ,Driver Only,driver Name of module entry function .※
  • UNLOAD_IMAGE: Not required ,Driver Only.
  • CONSTRUCTOR: Not required ,Library Only.
  • DESTRUCTOR: Not required ,Library Only.
  • SHADOW: Not required ,SEC、PEIM and PEI_CORE Driver modules Only.
  • PCI_DEVICE_ID: Not required ,UEFI PCI Option ROMs Just ask .
  • PCI_VENDOR_ID: Not required ,UEFI PCI Option ROMs Just ask .
  • PCI_CLASS_CODE: Not required ,UEFI PCI Option ROMs Just ask .
  • PCI_COMPRESS: Not required ,UEFI PCI Option ROMs Just ask .
  • UEFI_HII_RESOURCE_SECTION: Not required ,Driver Only.
  • DEFINE: Not required .
  • SPEC: Not required .
  • CUSTOM_MAKEFILE: Not required .
  • DPX_SOURCE: Not required ,Driver Only.

[Defines] In the block MODULE_TYPE

  • BASE: The developed code is not associated with a specific execution environment , It can run in any execution environment , Often used in libraries (Library) Module writing .
  • SEC:SEC Modules executed in phase , by PEI Stage prepare corresponding data , The resulting service conforms to PI standard .
  • PEI_CORE: from PEI Core Modules executed , accord with PI standard .
  • PEIM:PEI Modules executed in phase .
  • DXE_CORE: from DXE Core Modules executed , accord with PI standard .
  • DXE_DRIVER: from DXE Drive the module used , accord with PI standard . Only in BS Environmental Science ( Start the service environment ) perform , call ExitBootServices() It's recycled .
  • DXE_RUNTIME_DRIVER: Get into RT It can still run in the environment DXE Driver module .
  • DXE_SAL_DRIVER: Only on IPF CPU( itanium CPU) It works .
  • DXE_SMM_DRIVER: System management mode DXE Driver module , The module is loaded into the system management area memory , When you enter the runtime environment, you can still run .
  • UEFI_DRIVER:UEFI Driver module , accord with UEFI standard , It is only effective in the context of starting the service .
  • UEFI_APPLICATION:UEFI Application module , accord with UEFI standard .

Note: Not all module types are listed here , You can check INF standard .

[Sources]

There are several definitions of this block , Such as :[Sources] [Sources.common] [Sources.IA32] [Sources.X64] [Sources.IPF] [Sources.EBC]

[Packages]

There are several definitions of this block , Such as :[Packages] [Packages.common] [Packages.IA32] [Packages.X64] [Packages.IPF] [Packages.EBC]
List the... Used in this module DEC file .

[Protocols]

There are several definitions of this block , Such as :[Protocols] [Protocols.common] [Protocols.IA32] [Protocols.X64] [Protocols.IPF] [Protocols.EBC]
List the... Used in this module Protocol.

[Ppis]

There are several definitions of this block , Such as :[Ppis] [Ppis.common] [Ppis.IA32] [Ppis.X64] [Ppis.IPF] [Ppis.EBC]
List the global... Used in this module PPI.

[Guids]

There are several definitions of this block , Such as :[Guids] [Guids.common] [Guids.IA32] [Guids.X64] [Guids.IPF] [Guids.EBC]
List the... Used in this module GUID.
Guids

[LibraryClasses]

There are several definitions of this block , Such as :[LibraryClasses] [LibraryClasses.common] [LibraryClasses.IA32] [LibraryClasses.X64] [LibraryClasses.IPF] [LibraryClasses.EBC]
List the libraries used in this module .

[Depex]

There are several definitions of this block , Such as :[Depex] [Depex.common] [Depex.IA32] [Depex.X64] [Depex.IPF] [Depex.EBC]
Appoint Depex expression , It is generally used to set the driving sequence .

  • If the module type is SEC、UEFI_APPLICATION、UEFI_DRIVER、PEI_CORE、SMM_CORE perhaps DXE_CORE, Don't list [Depex], And all of library Module will ignore [Depex].
  • If the module type is PEIM、DXE_DRIVER、DXE_RUNTIME、DXE_SAL_DRIVER and DXE_SMM_DRIVER, Need to list [Depex].

SDL file

  • SDL File is AMI Code Peculiar .
  • It will be parsed during compilation SDL file , Generate intermediate data structures passed to the code generator .
  • SDL File is made up of Object
    group Composed of , such as :TOKEN、PATH、ELINK、OUTPUTREGISTER、FFS_FILE、PCD_MAPPING etc. ; May include token.h or token.mak or token.equ file , These files are generated during compilation .( It can be seen as a macro definition )

establish Module It is usually in the parent directory sdl The file defines the following two Object group, these two items. Object group Cooperation can control whether this INF Module Added to the project in .

Module establish

One Module In the file system, a folder contains one or more files , Such as :inf file 、C file 、 The header file , among inf The file is a Module Must have .

Module There are mainly two ways to create , But it's essentially the same , One is to use Veb Tools new come out , This way is veb Tools help us create files , However, this method is not recommended , The other is to use Veb Tools add Into the project, This way is to have existing folders and files , As for whether this folder and file are created manually or copied .

With PEIM Module as an example :

TestPeim.c file

TestPeim.inf file

原网站

版权声明
本文为[Yang_ Winston]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140549119296.html