diff options
author | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-16 09:12:20 +0000 |
---|---|---|
committer | klu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-03-16 09:12:20 +0000 |
commit | bb60dd97af4e377073e2c6700830897405f232bd (patch) | |
tree | 7253e49b0ea0dad95c693eafd33d7295ed816f9e | |
parent | 7af45bf1f0b989e932cd36d6ab729d9878bbc982 (diff) | |
download | edk2-platforms-bb60dd97af4e377073e2c6700830897405f232bd.tar.xz |
Fix the issue that the variable Unicode string may be not aligned on 16-bit boundary in flash (it dependent on ALIGNMENT macro in EdkModulePkg\Universal\Variable\Pei\x64\VarMachine.h). The unalignment Unicode string will lead assert of StrCmp, StrCopy, StrLen function in Mde library.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2482 6f19259b-4bc3-4df7-8a09-765794883524
8 files changed, 30 insertions, 90 deletions
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c index accf5d799c..acc4121879 100644 --- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c +++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.c @@ -58,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
@@ -269,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;
@@ -529,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.
@@ -590,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);
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.msa b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.msa index 7acd1ba819..1fbf8da410 100644 --- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.msa +++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariable.msa @@ -43,6 +43,9 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Variable.h</Filename>
diff --git a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariableIpf.msa b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariableIpf.msa index 9264ffacda..e0f66f981f 100644 --- a/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariableIpf.msa +++ b/EdkModulePkg/Universal/EmuVariable/RuntimeDxe/EmuVariableIpf.msa @@ -46,6 +46,9 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Variable.h</Filename>
diff --git a/EdkModulePkg/Universal/Variable/Pei/Variable.c b/EdkModulePkg/Universal/Variable/Pei/Variable.c index e2f3c4bddd..33772f8513 100644 --- a/EdkModulePkg/Universal/Variable/Pei/Variable.c +++ b/EdkModulePkg/Universal/Variable/Pei/Variable.c @@ -1,6 +1,6 @@ /*++
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2007 Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials
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
@@ -209,7 +209,7 @@ Returns: (((INT32 *) VendorGuid)[2] == ((INT32 *) &Variable->VendorGuid)[2]) &&
(((INT32 *) VendorGuid)[3] == ((INT32 *) &Variable->VendorGuid)[3])
) {
- if (!StrCmp (VariableName, GET_VARIABLE_NAME_PTR (Variable))) {
+ if (!CompareMem (VariableName, GET_VARIABLE_NAME_PTR (Variable), Variable->NameSize)) {
PtrTrack->CurrPtr = Variable;
return EFI_SUCCESS;
}
diff --git a/EdkModulePkg/Universal/Variable/Pei/Variable.msa b/EdkModulePkg/Universal/Variable/Pei/Variable.msa index 6bb518a1db..a1a3c93f55 100644 --- a/EdkModulePkg/Universal/Variable/Pei/Variable.msa +++ b/EdkModulePkg/Universal/Variable/Pei/Variable.msa @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>PeiVariable</ModuleName>
@@ -8,11 +8,11 @@ <Abstract>Component description file for PeiVariable module.</Abstract>
<Description>Framework PEIM to provide the Variable functionality.</Description>
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation</Copyright>
- <License>All rights reserved. This program and the accompanying materials
- 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
- http://opensource.org/licenses/bsd-license.php
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ <License>All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
@@ -37,6 +37,9 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PcdLib</Keyword>
</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseMemoryLib</Keyword>
+ </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Variable.h</Filename>
@@ -67,7 +70,7 @@ <PcdEntry PcdItemType="DYNAMIC">
<C_Name>PcdFlashNvStorageVariableBase</C_Name>
<TokenSpaceGuidCName>gEfiGenericPlatformTokenSpaceGuid</TokenSpaceGuidCName>
- <HelpText>The driver gets the Variable store base address from this PCD. This base address point to
+ <HelpText>The driver gets the Variable store base address from this PCD. This base address point to an EFI_FIRMWARE_VOLUMN_HEADER struct.</HelpText>
</PcdEntry>
</PcdCoded>
diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c index da711ebe48..a3992f7ebd 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -60,43 +60,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
BOOLEAN
EFIAPI
IsValidVariableHeader (
@@ -600,7 +563,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;
@@ -876,7 +839,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.
@@ -985,7 +948,7 @@ Returns: //
NextVariable->Reserved = 0;
VarNameOffset = sizeof (VARIABLE_HEADER);
- VarNameSize = ArrayLength (VariableName);
+ VarNameSize = StrSize (VariableName);
CopyMem (
(UINT8 *) ((UINTN) NextVariable + VarNameOffset),
VariableName,
diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa index 227d8a1344..d1e6f3bb93 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.msa @@ -49,6 +49,9 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Variable.h</Filename>
diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa b/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa index cbc60df38e..11ca3086ba 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/VariableIpf.msa @@ -52,6 +52,9 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">
+ <Keyword>BaseLib</Keyword>
+ </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>Variable.h</Filename>
|