mirror of https://github.com/acidanthera/audk.git
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:
parent
027c2ecb3b
commit
09d4dd14e9
|
@ -1,16 +1,16 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2006, Intel Corporation
|
Copyright (c) 2006, Intel Corporation
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
Module Name:
|
||||||
|
|
||||||
EmuVariable.c
|
EmuVariable.c
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
@ -62,37 +62,6 @@ Returns:
|
||||||
return (Count * 2) + 2;
|
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
|
VARIABLE_STORE_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
GetVariableStoreStatus (
|
GetVariableStoreStatus (
|
||||||
|
@ -161,7 +130,7 @@ Returns:
|
||||||
//
|
//
|
||||||
// Be careful about pad size for alignment
|
// 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 *
|
VARIABLE_HEADER *
|
||||||
|
@ -413,7 +382,7 @@ Returns:
|
||||||
UINTN VarNameSize;
|
UINTN VarNameSize;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {
|
if (VariableNameSize == NULL || VendorGuid == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,8 +562,8 @@ Returns:
|
||||||
//
|
//
|
||||||
VarNameOffset = sizeof (VARIABLE_HEADER);
|
VarNameOffset = sizeof (VARIABLE_HEADER);
|
||||||
VarNameSize = ArrayLength (VariableName);
|
VarNameSize = ArrayLength (VariableName);
|
||||||
VarDataOffset = VarNameOffset + VarNameSize + GetPadSize (VarNameSize);
|
VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);
|
||||||
VarSize = VarDataOffset + DataSize + GetPadSize (DataSize);
|
VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);
|
||||||
|
|
||||||
if (Attributes & EFI_VARIABLE_NON_VOLATILE) {
|
if (Attributes & EFI_VARIABLE_NON_VOLATILE) {
|
||||||
if ((UINT32) (VarSize +*NonVolatileOffset) >
|
if ((UINT32) (VarSize +*NonVolatileOffset) >
|
||||||
|
@ -675,11 +644,11 @@ Routine Description:
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
Attributes Attributes bitmask to specify the type of variables
|
Attributes Attributes bitmask to specify the type of variables
|
||||||
on which to return information.
|
on which to return information.
|
||||||
MaximumVariableStorageSize Pointer to the maximum size of the storage space available
|
MaximumVariableStorageSize Pointer to the maximum size of the storage space available
|
||||||
for the EFI variables associated with the attributes specified.
|
for the EFI variables associated with the attributes specified.
|
||||||
RemainingVariableStorageSize Pointer to the remaining size of the storage space available
|
RemainingVariableStorageSize Pointer to the remaining size of the storage space available
|
||||||
for the EFI variables associated with the attributes specified.
|
for the EFI variables associated with the attributes specified.
|
||||||
MaximumVariableSize Pointer to the maximum size of the individual EFI variables
|
MaximumVariableSize Pointer to the maximum size of the individual EFI variables
|
||||||
associated with the attributes specified.
|
associated with the attributes specified.
|
||||||
|
@ -699,7 +668,7 @@ Returns:
|
||||||
VARIABLE_HEADER *NextVariable;
|
VARIABLE_HEADER *NextVariable;
|
||||||
UINT64 VariableSize;
|
UINT64 VariableSize;
|
||||||
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
VARIABLE_STORE_HEADER *VariableStoreHeader;
|
||||||
|
|
||||||
if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL) {
|
if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
@ -725,7 +694,7 @@ Returns:
|
||||||
//
|
//
|
||||||
// Query is Volatile related.
|
// Query is Volatile related.
|
||||||
//
|
//
|
||||||
VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase);
|
VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Query is Non-Volatile related.
|
// Query is Non-Volatile related.
|
||||||
|
@ -734,14 +703,14 @@ Returns:
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize
|
// Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize
|
||||||
// with the storage size (excluding the storage header size)
|
// with the storage size (excluding the storage header size)
|
||||||
//
|
//
|
||||||
*MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
|
*MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
|
||||||
*RemainingVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
|
*RemainingVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Let *MaximumVariableSize be MAX_VARIABLE_SIZE
|
// Let *MaximumVariableSize be MAX_VARIABLE_SIZE
|
||||||
//
|
//
|
||||||
*MaximumVariableSize = MAX_VARIABLE_SIZE;
|
*MaximumVariableSize = MAX_VARIABLE_SIZE;
|
||||||
|
|
||||||
|
@ -846,7 +815,7 @@ Returns:
|
||||||
//
|
//
|
||||||
mVariableModuleGlobal = (ESAL_VARIABLE_GLOBAL *) AllocateRuntimePool (
|
mVariableModuleGlobal = (ESAL_VARIABLE_GLOBAL *) AllocateRuntimePool (
|
||||||
sizeof (ESAL_VARIABLE_GLOBAL)
|
sizeof (ESAL_VARIABLE_GLOBAL)
|
||||||
);
|
);
|
||||||
if (NULL == mVariableModuleGlobal) {
|
if (NULL == mVariableModuleGlobal) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue