X-Git-Url: https://code.delx.au/refind/blobdiff_plain/b8b1a02cc8cd3519503b2731af83231bdeed689c..463d49c9646ad30a500cc9a6305676b790871945:/refind/lib.c diff --git a/refind/lib.c b/refind/lib.c index b4dc2ec..0570265 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -265,6 +265,43 @@ static EFI_STATUS FinishInitRefitLib(VOID) return EFI_SUCCESS; } +// +// EFI variable read and write functions +// + +// From gummiboot: Retrieve a raw EFI variable. +// Returns EFI status +EFI_STATUS EfivarGetRaw(EFI_GUID *vendor, CHAR16 *name, CHAR8 **buffer, UINTN *size) { + CHAR8 *buf; + UINTN l; + EFI_STATUS err; + + l = sizeof(CHAR16 *) * EFI_MAXIMUM_VARIABLE_SIZE; + buf = AllocatePool(l); + if (!buf) + return EFI_OUT_OF_RESOURCES; + + err = refit_call5_wrapper(RT->GetVariable, name, vendor, NULL, &l, buf); + if (EFI_ERROR(err) == EFI_SUCCESS) { + *buffer = buf; + if (size) + *size = l; + } else + MyFreePool(buf); + return err; +} // EFI_STATUS EfivarGetRaw() + +// From gummiboot: Set an EFI variable +EFI_STATUS EfivarSetRaw(EFI_GUID *vendor, CHAR16 *name, CHAR8 *buf, UINTN size, BOOLEAN persistent) { + UINT32 flags; + + flags = EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS; + if (persistent) + flags |= EFI_VARIABLE_NON_VOLATILE; + + return refit_call5_wrapper(RT->SetVariable, name, vendor, flags, size, buf); +} // EFI_STATUS EfivarSetRaw() + // // list functions // @@ -2025,11 +2062,12 @@ BOOLEAN IsGuid(CHAR16 *UnknownString) { for (i = 0; i < Length; i++) { a = UnknownString[i]; - if (((i == 8) || (i == 13) || (i == 18) || (i == 23)) && (a != '-')) { - retval = FALSE; + if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) { + if (a != '-') + retval = FALSE; } else if (((a < 'a') || (a > 'f')) && ((a < 'A') || (a > 'F')) && ((a < '0') && (a > '9'))) { retval = FALSE; - } // if/else + } // if/else if } // for return retval; } // BOOLEAN IsGuid()