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:
1
EFI_STATUS
2
EFIAPI
3
UefiMain (
Copied!
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.
1
EFI_STATUS
2
EFIAPI
3
UefiMain (
4
IN EFI_HANDLE ImageHandle,
5
IN EFI_SYSTEM_TABLE *SystemTable
6
)
7
{
8
UINT32 Index;
9
Index = 0;
10
//
11
// Three PCD type (FeatureFlag, UINT32 and String) are used as the
12
// sample.
13
//
14
if (FeaturePcdGet (PcdHelloWorldPrintEnable)) {
15
for (Index = 0;
16
Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
17
//
18
// Use UefiLib Print API to print string to UEFI console
19
//
20
Print ((CHAR16 *)PcdGetPtr (PcdHelloWorldPrintString));
21
}
22
}
23
return EFI_SUCCESS;
24
}
Copied!
Last modified 1yr ago
Copy link