MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / GetVariable2

Function GetVariable2

MdePkg/Library/UefiLib/UefiLib.c:1415–1469  ·  view source on GitHub ↗

Returns the status whether get the variable success. The function retrieves variable through the UEFI Runtime Service GetVariable(). The returned buffer is allocated using AllocatePool(). The caller is responsible for freeing this buffer with FreePool(). If Name is NULL, then ASSERT(). If Guid is NULL, then ASSERT(). If Value is NULL, then ASSERT(). @param[in] Name

Source from the content-addressed store, hash-verified

1413
1414**/
1415EFI_STATUS
1416EFIAPI
1417GetVariable2 (
1418 IN CONST CHAR16 *Name,
1419 IN CONST EFI_GUID *Guid,
1420 OUT VOID **Value,
1421 OUT UINTN *Size OPTIONAL
1422 )
1423{
1424 EFI_STATUS Status;
1425 UINTN BufferSize;
1426
1427 ASSERT (Name != NULL && Guid != NULL && Value != NULL);
1428 if (!Name || !Guid || !Value) {
1429 return EFI_NOT_FOUND;
1430 }
1431
1432 //
1433 // Try to get the variable size.
1434 //
1435 BufferSize = 0;
1436 *Value = NULL;
1437 if (Size != NULL) {
1438 *Size = 0;
1439 }
1440
1441 Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
1442 if (Status != EFI_BUFFER_TOO_SMALL) {
1443 return Status;
1444 }
1445
1446 //
1447 // Allocate buffer to get the variable.
1448 //
1449 *Value = AllocatePool (BufferSize);
1450 ASSERT (*Value != NULL);
1451 if (*Value == NULL) {
1452 return EFI_OUT_OF_RESOURCES;
1453 }
1454
1455 //
1456 // Get the variable data.
1457 //
1458 Status = gRT->GetVariable ((CHAR16 *) Name, (EFI_GUID *) Guid, NULL, &BufferSize, *Value);
1459 if (EFI_ERROR(Status)) {
1460 FreePool(*Value);
1461 *Value = NULL;
1462 }
1463
1464 if (Size != NULL) {
1465 *Size = BufferSize;
1466 }
1467
1468 return Status;
1469}
1470
1471/** Return the attributes of the variable.
1472

Callers 15

GetEfiGlobalVariable2Function · 0.85
IsOsxHibernatedFunction · 0.85
PrepareHibernationFunction · 0.85
GetEarlyUserSettingsFunction · 0.85
MOStartImageFunction · 0.85
MOStartImageFunction · 0.85
MOStartImageFunction · 0.85
EfiShellGetAliasFunction · 0.85
DpGetNameFromHandleFunction · 0.85

Calls 2

AllocatePoolFunction · 0.50
FreePoolFunction · 0.50

Tested by

no test coverage detected