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

Function GetNvramVariable

rEFIt_UEFI/Platform/Nvram.cpp:98–137  ·  view source on GitHub ↗

Reads and returns value of NVRAM variable. */

Source from the content-addressed store, hash-verified

96
97/** Reads and returns value of NVRAM variable. */
98VOID *GetNvramVariable(
99 IN CONST CHAR16 *VariableName,
100 IN EFI_GUID *VendorGuid,
101 OUT UINT32 *Attributes OPTIONAL,
102 OUT UINTN *DataSize OPTIONAL)
103{
104 EFI_STATUS Status;
105 VOID *Data = NULL;
106 //
107 // Pass in a zero size buffer to find the required buffer size.
108 //
109 UINTN IntDataSize = 0;
110
111 Status = gRT->GetVariable (VariableName, VendorGuid, Attributes, &IntDataSize, NULL);
112 if (IntDataSize == 0) {
113 return NULL;
114 }
115
116 if (Status == EFI_BUFFER_TOO_SMALL) {
117 //
118 // Allocate the buffer to return
119 //
120 Data = (__typeof__(Data))AllocateZeroPool(IntDataSize + 1);
121 if (Data != NULL) {
122 //
123 // Read variable into the allocated buffer.
124 //
125 Status = gRT->GetVariable (VariableName, VendorGuid, Attributes, &IntDataSize, Data);
126 if (EFI_ERROR(Status)) {
127 FreePool(Data);
128 IntDataSize = 0;
129 Data = NULL;
130 }
131 }
132 }
133 if (DataSize != NULL) {
134 *DataSize = IntDataSize;
135 }
136 return Data;
137}
138
139/** Reads and returns value of NVRAM variable. */
140XString8 GetNvramVariableAsXString8(

Callers 12

SetVariablesFromNvramFunction · 0.85
GetBootOrderFunction · 0.85
GetBootOptionFunction · 0.85
GetStoredOutputFunction · 0.85
SetVariablesForOSXFunction · 0.85
SetNvramVariableFunction · 0.85
AddNvramVariableFunction · 0.85
GetSmcKeysFunction · 0.85
SetBootCurrentFunction · 0.85
InitThemeFunction · 0.85
GetDefaultSettingsFunction · 0.85

Calls 2

AllocateZeroPoolFunction · 0.50
FreePoolFunction · 0.50

Tested by

no test coverage detected