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

Function ResetNativeNvram

rEFIt_UEFI/Platform/Nvram.cpp:333–424  ·  view source on GitHub ↗

Reset Native NVRAM by vit9696, reworked and implemented by Sherlocks

Source from the content-addressed store, hash-verified

331
332// Reset Native NVRAM by vit9696, reworked and implemented by Sherlocks
333EFI_STATUS
334ResetNativeNvram ()
335{
336 EFI_STATUS Status = EFI_NOT_FOUND;
337 EFI_GUID Guid;
338 CHAR16 *Name;
339 UINTN NameSize;
340 UINTN NewNameSize;
341 BOOLEAN Restart = TRUE;
342 UINTN VolumeIndex;
343 REFIT_VOLUME *Volume;
344 EFI_FILE_HANDLE FileHandle;
345
346 //DbgHeader("ResetNativeNvram: cleanup NVRAM variables");
347
348 NameSize = sizeof (CHAR16);
349 Name = (__typeof__(Name))AllocateZeroPool(NameSize);
350 if (Name == NULL) {
351 return Status;
352 }
353
354 while (TRUE) {
355 if (Restart) {
356 ZeroMem (&Guid, sizeof(Guid));
357 ZeroMem (Name, sizeof(Name));
358 Restart = FALSE;
359 }
360
361 NewNameSize = NameSize;
362 Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
363 if (Status == EFI_BUFFER_TOO_SMALL) {
364 Name = (__typeof__(Name))ReallocatePool (NameSize, NewNameSize, Name);
365 if (Name == NULL) {
366 return Status;
367 }
368
369 Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
370 NameSize = NewNameSize;
371 }
372
373 if (EFI_ERROR(Status)) {
374 break;
375 }
376
377 if (!EFI_ERROR(Status)) {
378 if (IsDeletableVariable (Name, &Guid)) {
379 //DBG("Deleting %s:%ls...", strguid(&Guid), Name);
380 Status = DeleteNvramVariable(Name, &Guid);
381 if (!EFI_ERROR(Status)) {
382 //DBG("OK\n");
383 Restart = TRUE;
384 } else {
385 //DBG("FAIL (%s)\n", efiStrError(Status));
386 break;
387 }
388 }
389 }
390 }

Callers 1

ResetNvramFunction · 0.85

Calls 11

DeleteNvramVariableFunction · 0.85
StriStrFunction · 0.85
DeleteFileFunction · 0.85
IsDeletableVariableFunction · 0.70
AllocateZeroPoolFunction · 0.50
ZeroMemFunction · 0.50
ReallocatePoolFunction · 0.50
FreePoolFunction · 0.50
sizeMethod · 0.45
OpenMethod · 0.45
wc_strMethod · 0.45

Tested by

no test coverage detected