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

Function FindFreeBootNum

rEFIt_UEFI/Platform/BootOptions.cpp:713–735  ·  view source on GitHub ↗

Returns BootNum: XXXX of first unoccupied BootXXXX var slot. */

Source from the content-addressed store, hash-verified

711
712/** Returns BootNum: XXXX of first unoccupied BootXXXX var slot. */
713EFI_STATUS
714FindFreeBootNum (
715 OUT UINT16 *BootNum
716 )
717{
718 EFI_STATUS Status;
719 UINTN Index;
720 CHAR16 VarName[16];
721 UINTN VarSize;
722
723
724 for (Index = 0; Index <= 0xFFFF; Index++) {
725 snwprintf(VarName, sizeof(VarName), "Boot%04llX", Index);
726 VarSize = 0;
727 Status = gRT->GetVariable (VarName, &gEfiGlobalVariableGuid, NULL, &VarSize, NULL);
728 if (Status == EFI_NOT_FOUND) {
729 *BootNum = (UINT16)Index;
730 return EFI_SUCCESS;
731 }
732 }
733
734 return EFI_NOT_FOUND;
735}
736
737
738/** Searches BootXXXX vars for entry that points to given FileDeviceHandle/FileName

Callers 1

AddBootOptionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected