diff --git a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c index 8954a5fd8e..cb56f66078 100644 --- a/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c +++ b/MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c @@ -214,14 +214,14 @@ FindVariable ( while ((Variable[Index] != NULL) && (Variable[Index] <= GetEndPointer (VariableStoreHeader[Index]))) { if (Variable[Index]->StartId == VARIABLE_DATA && Variable[Index]->State == VAR_ADDED) { - if (!(EfiAtRuntime () && !(Variable[Index]->Attributes & EFI_VARIABLE_RUNTIME_ACCESS))) { + if (!(EfiAtRuntime () && (Variable[Index]->Attributes & EFI_VARIABLE_RUNTIME_ACCESS == 0))) { if (VariableName[0] == 0) { PtrTrack->CurrPtr = Variable[Index]; PtrTrack->Volatile = (BOOLEAN) Index; return EFI_SUCCESS; } else { if (CompareGuid (VendorGuid, &Variable[Index]->VendorGuid)) { - if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize)) { + if (CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable[Index]), Variable[Index]->NameSize) == 0) { PtrTrack->CurrPtr = Variable[Index]; PtrTrack->Volatile = (BOOLEAN) Index; return EFI_SUCCESS; @@ -389,7 +389,7 @@ GetNextVariableName ( // Variable is found // if (Variable.CurrPtr->StartId == VARIABLE_DATA && Variable.CurrPtr->State == VAR_ADDED) { - if (!(EfiAtRuntime () && !(Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS))) { + if (!(EfiAtRuntime () && (Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS == 0))) { VarNameSize = Variable.CurrPtr->NameSize; if (VarNameSize <= *VariableNameSize) { CopyMem ( @@ -527,7 +527,7 @@ SetVariable ( // // Only variable have NV attribute can be updated/deleted in Runtime // - if (!(Variable.CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE)) { + if ((Variable.CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } @@ -548,7 +548,7 @@ SetVariable ( // then return to the caller immediately. // if (Variable.CurrPtr->DataSize == DataSize && - !CompareMem (Data, GetVariableDataPtr (Variable.CurrPtr), DataSize) + CompareMem (Data, GetVariableDataPtr (Variable.CurrPtr), DataSize) == 0 ) { Status = EFI_SUCCESS; goto Done; diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 6d3967947d..8fbcf129fa 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -38,14 +38,6 @@ VARIABLE_CACHE_ENTRY mVariableCache[] = { VARIABLE_INFO_ENTRY *gVariableInfo = NULL; -EFI_STATUS -FtwVariableSpace ( - IN EFI_PHYSICAL_ADDRESS VariableBaseAddress, - IN UINT8 *Buffer, - IN UINTN BufferSize - ); - - /** Acquires lock only at boot time. Simply returns at runtime. @@ -929,7 +921,7 @@ FindVariable ( if (Variable[Index]->State == VAR_ADDED || Variable[Index]->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED) ) { - if (!EfiAtRuntime () || (Variable[Index]->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) { + if (!EfiAtRuntime () || (Variable[Index]->Attributes & EFI_VARIABLE_RUNTIME_ACCESS != 0)) { if (VariableName[0] == 0) { if (Variable[Index]->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) { InDeletedVariable = Variable[Index]; @@ -947,7 +939,7 @@ FindVariable ( Point = (VOID *) GetVariableNamePtr (Variable[Index]); ASSERT (NameSizeOfVariable (Variable[Index]) != 0); - if (!CompareMem (VariableName, Point, NameSizeOfVariable (Variable[Index]))) { + if (CompareMem (VariableName, Point, NameSizeOfVariable (Variable[Index])) == 0) { if (Variable[Index]->State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) { InDeletedVariable = Variable[Index]; InDeletedStorageIndex = Index; @@ -1136,7 +1128,7 @@ RuntimeServiceGetNextVariableName ( // Variable is found // if (IsValidVariableHeader (Variable.CurrPtr) && Variable.CurrPtr->State == VAR_ADDED) { - if (!(EfiAtRuntime () && !(Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS))) { + if ((EfiAtRuntime () && ((Variable.CurrPtr->Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0)) == 0) { VarNameSize = NameSizeOfVariable (Variable.CurrPtr); ASSERT (VarNameSize != 0); @@ -1294,7 +1286,7 @@ RuntimeServiceSetVariable ( // // Only variable have NV attribute can be updated/deleted in Runtime // - if (!(Variable.CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE)) { + if ((Variable.CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) { Status = EFI_INVALID_PARAMETER; goto Done; } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h index c508d8bade..ec35a7dfcf 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h @@ -70,4 +70,28 @@ typedef struct { VOID *Data; } VARIABLE_CACHE_ENTRY; +/** + Writes a buffer to variable storage space, in the working block. + + This function writes a buffer to variable storage space into firmware + volume block device. The destination is specified by parameter + VariableBase. Fault Tolerant Write protocol is used for writing. + + @param VariableBase Base address of variable to write + @param Buffer Point to the data buffer + @param BufferSize The number of bytes of the data Buffer + + @retval EFI_SUCCESS The function completed successfully + @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol + @retval EFI_ABORTED The function could not complete successfully + +**/ +EFI_STATUS +FtwVariableSpace ( + IN EFI_PHYSICAL_ADDRESS VariableBase, + IN UINT8 *Buffer, + IN UINTN BufferSize + ); + + #endif