4.2 Write UEFI Application Entry Point

Developers must focus on specifying the entry point of UEFI application in the [Defines] section of INF file.

Its prototype is list below:

EFI_STATUS
EFIAPI
UefiMain (

IN EFI_HANDLE ImageHandle,

IN EFI_SYSTEM_TABLE*SystemTable

);

As can be seen, there are two parameters for UEFI application entry point,

ImageHandle and SystemTable. ImageHandle refers to the image handle of the UEFI application. SystemTable is the pointer to the EFI System Table.

The following is a full UEFI_APPLICATION example located at

$WORKSPACE\MdeModulePkg\Application\HelloWorld. It shows how to print a "UEFI Hello World!" string to console.


Note: This application uses several pcds to demonstrate the usage of PCD. Readers can obtain the default value of these pcds from the


$WORKSPACE\MdeModulePkg\MdeModulePkg.dec file.

EFI_STATUS
EFIAPI
UefiMain (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  UINT32  Index;
  Index = 0;
  //
  // Three PCD type (FeatureFlag, UINT32 and String) are used as the
  // sample.
  //
  if (FeaturePcdGet (PcdHelloWorldPrintEnable)) {
    for (Index = 0;
         Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
      //
      // Use UefiLib Print API to print string to UEFI console
      //
      Print ((CHAR16 *)PcdGetPtr (PcdHelloWorldPrintString));
    }
  }
  return EFI_SUCCESS;
}

results matching ""

    No results matching ""