X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FUniversal%2FEmuVariable%2FRuntimeDxe%2FEmuVariable.c;h=8695b7526a699d734d8faa8dfbec9b0632861744;hp=d39ecd2ce07bac010d13938e3430ebad911acf12;hb=6dcb94c713b1373cc78117b7713e654889802114;hpb=6ed71dcc327e0b52e262192bd737a40fc16ea526 diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c index d39ecd2ce0..8695b7526a 100644 --- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c +++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c @@ -31,6 +31,7 @@ ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal; // when EfiAcquireLock in UefiLib can handle the // the call in UEFI Runtimer driver in RT phase. // +STATIC VOID AcquireLockOnlyAtBootTime ( IN EFI_LOCK *Lock @@ -46,6 +47,7 @@ AcquireLockOnlyAtBootTime ( // when EfiAcquireLock in UefiLib can handle the // the call in UEFI Runtimer driver in RT phase. // +STATIC VOID ReleaseLockOnlyAtBootTime ( IN EFI_LOCK *Lock @@ -56,44 +58,6 @@ ReleaseLockOnlyAtBootTime ( } } - -STATIC -UINT32 -EFIAPI -ArrayLength ( - IN CHAR16 *String - ) -/*++ - -Routine Description: - - Determine the length of null terminated char16 array. - -Arguments: - - String Null-terminated CHAR16 array pointer. - -Returns: - - UINT32 Number of bytes in the string, including the double NULL at the end; - ---*/ -{ - UINT32 Count; - - if (NULL == String) { - return 0; - } - - Count = 0; - - while (0 != String[Count]) { - Count++; - } - - return (Count * 2) + 2; -} - STATIC UINT8 * EFIAPI @@ -267,7 +231,7 @@ Returns: return EFI_SUCCESS; } else { if (CompareGuid (VendorGuid, &Variable[Index]->VendorGuid)) { - if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), ArrayLength (VariableName))) { + if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize)) { PtrTrack->CurrPtr = Variable[Index]; PtrTrack->Volatile = (BOOLEAN) Index; return EFI_SUCCESS; @@ -527,7 +491,7 @@ Returns: // Status = EFI_WRITE_PROTECTED; goto Done; - } else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) { + } else if (sizeof (VARIABLE_HEADER) + (StrSize (VariableName) + DataSize) > MAX_VARIABLE_SIZE) { // // The size of the VariableName, including the Unicode Null in bytes plus // the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes. @@ -588,7 +552,7 @@ Returns: // Create a new variable and copy the data. // VarNameOffset = sizeof (VARIABLE_HEADER); - VarNameSize = ArrayLength (VariableName); + VarNameSize = StrSize (VariableName); VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize); VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize); @@ -862,7 +826,7 @@ Returns: return EFI_OUT_OF_RESOURCES; } - EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_CALLBACK); + EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, EFI_TPL_NOTIFY); // // Intialize volatile variable store