Fixed one bug in EmuVariable module: The macro (GET_PAD_SIZE) is different with GetPadSize(), so in some special case the variable can not be read rightly after it was set.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2059 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
zliu3 2006-12-06 08:16:31 +00:00
parent 027c2ecb3b
commit 09d4dd14e9
1 changed files with 20 additions and 51 deletions

View File

@ -62,37 +62,6 @@ Returns:
return (Count * 2) + 2;
}
UINTN
EFIAPI
GetPadSize (
IN UINTN Value
)
/*++
Routine Description:
This function return the pad size for alignment
Arguments:
Value The value need to align
Returns:
Pad size for value
--*/
{
//
// If alignment is 0 or 1, means no alignment required
//
if (ALIGNMENT == 0 || ALIGNMENT == 1) {
return 0;
}
return ALIGNMENT - (Value % ALIGNMENT);
}
VARIABLE_STORE_STATUS
EFIAPI
GetVariableStoreStatus (
@ -161,7 +130,7 @@ Returns:
//
// Be careful about pad size for alignment
//
return (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (Variable) + Variable->NameSize + GetPadSize (Variable->NameSize));
return (UINT8 *) ((UINTN) GET_VARIABLE_NAME_PTR (Variable) + Variable->NameSize + GET_PAD_SIZE (Variable->NameSize));
}
VARIABLE_HEADER *
@ -413,7 +382,7 @@ Returns:
UINTN VarNameSize;
EFI_STATUS Status;
if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {
if (VariableNameSize == NULL || VendorGuid == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -593,8 +562,8 @@ Returns:
//
VarNameOffset = sizeof (VARIABLE_HEADER);
VarNameSize = ArrayLength (VariableName);
VarDataOffset = VarNameOffset + VarNameSize + GetPadSize (VarNameSize);
VarSize = VarDataOffset + DataSize + GetPadSize (DataSize);
VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);
VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);
if (Attributes & EFI_VARIABLE_NON_VOLATILE) {
if ((UINT32) (VarSize +*NonVolatileOffset) >
@ -846,7 +815,7 @@ Returns:
//
mVariableModuleGlobal = (ESAL_VARIABLE_GLOBAL *) AllocateRuntimePool (
sizeof (ESAL_VARIABLE_GLOBAL)
);
);
if (NULL == mVariableModuleGlobal) {
return EFI_OUT_OF_RESOURCES;
}