[UEFI] use of the Guid --- BIOS as well as the use of summary Lib function

--- --- restore content begins

  BIOS development has long been the traditional compilation includes abandoned, UEFI as the current mainstream standard defines a set of interfaces, are widely used. Before being GUID and some information about the use of some functions and cross-Lib Pkg frustrating not to call, every change must build the code several times, in order to build too. Taking advantage of a Bug this time, using the GUID for cross Pkg Lib and do the next summary.     

/ * GUID * /

  As the name suggests --globally unique identifier, a globally unique identifier. GUID is a binary data 128bit = 16Byte composition, this data is generally generated by a dedicated generator GUID (Do not own scribbles oh), and each GUID generated is substantially not repeated. BIOS GUID used a lot of places, most of the global variables as well as Protocol and so need to locate or install by GUID. Today to introduce GUID by Solutions 1. Before 2. format usage. (Background problem: a program InsydeMoudlePkg in Moudle1 is to be set Variable1, a program Moudle2 in going to read Variable1)

  (See before, please mastery of basic concepts such as UEFI-Pkg Moudle and dec / inf / dsc document consists of two)

 1. Format - Similarly, we start from the final demand, the step by step.

  Final demand: a necessary function Password.c, the variable EncryptedHashData saved , and mounted below the gInspurUserPassWordFlagGuid (below left).

  • Step1:   Check Password.c in which Pkg in the following figure from right,

           

  • Step2: After determining InsydeMoudlPkg, find the Pkg Dec document and add definition to go gInspurUserPassWordFlagGuid (added to dec purpose is to be able to directly call the GUID in other Pkg, in order not to give the future of their digging, this the recommended procedure must be done, because at the same Pkg across Mould call or GUID GUID across Pkg calls are extremely common)

         

  •  Step3: After adding Dec, you can use the GUID in each Mouldle in the Pkg. Password.c belongs GenericUtilityLib this mouldle, also the first step first gInspurUserPassWordFlagGuid added to the INF described in the document moudle.

        

 

 

  •  Step4: After inf added, .c file under the Moudle which can use the Guild, compiled at compile becomes a .c file when compiling parsing INF file and the definition of gInspurUserPassWordFlagGuid, then at all in the Mouldle. c documents can be declared using extern way, the statement GUID and use it directly. Below, we are using this time in Password.c in SetVaribale GUID, then you can declare the GUID directly at the beginning of the file extern.

           

 

 

   Carding At this point, we should have a general grasp of the use GUID format, are summarized as follows:

  1.1 dec defined in the GUID, one is to let all moudle this Pkg can see the GUID and direct calls, and the second is to provide a declaration interface across Pkg when using the GUID. Other Pkg To use the program only need to add the GUID GUID DEC documents and statements in the document to INF

  1.2 INF document indicates that the GUID GUID is added to this Moudle visible and available to all programs

 2. Usage

  As a globally unique identifier GUID, the GUID UEFI then in the end is how to use it? Often said that a certain variable or a Protocol mount a GUID below is what does that mean? 

 /*以gRT->GetVariable()函数为例*/
1
typedef 2 EFI_RUNTIMESERVICE 3 EFI_STATUS 4 (EFIAPI *EFI_GET_VARIABLE) ( 5 IN CHAR16 *VariableName, 6 IN EFI_GUID * VendorGuid, 7 OUT UINT32 *Attributes OPTIONAL, 8 IN OUT UINTN *DataSize, 9 OUT VOID *Data 10 );
  • gRT-> GetVariable () function to obtain the following entities, is obtained using the landlord Insyde code, Insyde noted here that this should be done to modify the package in order to obtain a larger InsydeMoudlePkg, the landlord to function according to this entity, spent a lot of time, it is it should not be. In this prompt does not appear, do not use DEBUG () function to locate, this module should be defined is too DebugLib NULL, so I added DEBUG () after. The final method is the use of CMOS, only to find this function. Find a function entity, then we go for the next code, to see how in the end is the index GUID, and find the mount was variable data obtained from the GUID.

       

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/szhb-5251/p/11609483.html