Why does ExitBootServices() fails if I don't alllocate
Posted: Tue Jun 09, 2015 9:51 am
Hi,
I decided to play a bit with UEFI but I got stuck. When I attempt to call ExitBootServices() I got the EFI_INVALID_PARAMETER even though I don't allocate memory. Despite reading the spec I cannot figure out what might be wrong.
The error persists even if I simplify the code:
What am I missing from specification?
I decided to play a bit with UEFI but I got stuck. When I attempt to call ExitBootServices() I got the EFI_INVALID_PARAMETER even though I don't allocate memory. Despite reading the spec I cannot figure out what might be wrong.
The error persists even if I simplify the code:
Code: Select all
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_STATUS Status;
UINTN DescriptorsSize;
EFI_MEMORY_DESCRIPTOR Descriptors[64];
UINTN MapKey;
UINTN DescriptorSize;
UINT32 DescriptorVersion;
ST = SystemTable;
DescriptorsSize = sizeof(Descriptors);
Status = ST->BootServices->GetMemoryMap(&DescriptorsSize, Descriptors, &MapKey, &DescriptorSize, &DescriptorVersion);
if (EFI_ERROR(Status))
return Status;
Status = ST->ConOut->OutputString(ST->ConOut, L"ABOUT TO EXIT\n\r");
if (EFI_ERROR(Status))
return Status;
Status = ST->BootServices->ExitBootServices(ImageHandle, MapKey);
if (EFI_ERROR(Status)) {
Status = ST->ConOut->OutputString(ST->ConOut, L"FAILED\n\r");
Status = ST->ConIn->Reset(ST->ConIn, FALSE);
while ((Status = ST->ConIn->ReadKeyStroke(ST->ConIn, &Key)) == EFI_NOT_READY) ;
}
return Status;
}