2019-07-17 20:10:29 +00:00
|
|
|
#include <efi.h>
|
|
|
|
#include <efilib.h>
|
|
|
|
|
2019-07-17 20:18:29 +00:00
|
|
|
EFI_SYSTEM_TABLE *gST;
|
|
|
|
EFI_BOOT_SERVICES *gBS;
|
|
|
|
EFI_RUNTIME_SERVICES *gRT;
|
|
|
|
|
2019-07-17 20:10:29 +00:00
|
|
|
// Application entrypoint (must be set to 'efi_main' for gnu-efi crt0 compatibility)
|
|
|
|
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
|
|
|
{
|
|
|
|
UINTN Event;
|
2019-07-17 20:18:29 +00:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_TIME* Time;
|
|
|
|
gST = SystemTable;
|
|
|
|
gBS = gST->BootServices;
|
|
|
|
gRT = gST->RuntimeServices;
|
2019-07-17 20:10:29 +00:00
|
|
|
|
|
|
|
#if defined(_GNU_EFI)
|
|
|
|
InitializeLib(ImageHandle, SystemTable);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In addition to the standard %-based flags, Print() supports the following:
|
|
|
|
* %N Set output attribute to normal
|
|
|
|
* %H Set output attribute to highlight
|
|
|
|
* %E Set output attribute to error
|
|
|
|
* %B Set output attribute to blue color
|
|
|
|
* %V Set output attribute to green color
|
|
|
|
* %r Human readable version of a status code
|
|
|
|
*/
|
|
|
|
Print(L"\n%H*** Sync Bootloading ***%N\n\n");
|
|
|
|
|
2019-07-17 20:18:29 +00:00
|
|
|
Status = gST->ConOut->OutputString(gST->ConOut, L"Hello World\n\r");
|
|
|
|
if (EFI_ERROR(Status))
|
|
|
|
return Status;
|
|
|
|
|
|
|
|
Status = gBS->AllocatePool(EfiBootServicesData,
|
|
|
|
sizeof(EFI_TIME),
|
|
|
|
(VOID**)&Time);
|
|
|
|
|
|
|
|
if (EFI_ERROR(Status))
|
|
|
|
return Status;
|
2019-07-17 20:10:29 +00:00
|
|
|
|
2019-07-17 20:18:29 +00:00
|
|
|
Status = gRT->GetTime(Time, NULL);
|
|
|
|
if (EFI_ERROR(Status))
|
|
|
|
return Status;
|
2019-07-17 20:10:29 +00:00
|
|
|
|
2019-07-17 20:18:29 +00:00
|
|
|
Print(L"%EPress any key to exit.%N\n");
|
2019-07-17 20:10:29 +00:00
|
|
|
SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
|
|
|
|
SystemTable->BootServices->WaitForEvent(1, &SystemTable->ConIn->WaitForKey, &Event);
|
|
|
|
#if defined(_DEBUG)
|
|
|
|
// If running in debug mode, use the EFI shut down call to close QEMU
|
|
|
|
SystemTable->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
|
|
|
|
#endif
|
|
|
|
|
2019-07-17 20:18:29 +00:00
|
|
|
return Status;
|
2019-07-17 20:10:29 +00:00
|
|
|
}
|