/** @file\r
Help functions used by PCD DXE driver.\r
\r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
EFI_STATUS Status;\r
UINT32 LocalTokenNumber;\r
UINT32 Offset;\r
- UINT16 StringTableIdx; \r
+ STRING_HEAD StringTableIdx; \r
BOOLEAN IsPeiDb;\r
\r
//\r
// If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of \r
// string array in string table.\r
//\r
- StringTableIdx = *(UINT16*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset); \r
+ StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset); \r
VaraiableDefaultBuffer = (VOID *) (StringTable + StringTableIdx); \r
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);\r
if (Status == EFI_SUCCESS) {\r
//\r
GetPtrTypeSize (TmpTokenNumber, &GetSize);\r
}\r
+ //\r
+ // If the operation is successful, we copy the data\r
+ // to the default value buffer in the PCD Database.\r
+ // So that we can free the Data allocated in GetHiiVariable.\r
+ //\r
CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);\r
FreePool (Data);\r
}\r
//\r
GetPtrTypeSize (TmpTokenNumber, &GetSize);\r
}\r
+ //\r
+ // If the operation is successful, we copy the data\r
+ // to the default value buffer in the PCD Database.\r
+ // So that we can free the Data allocated in GetHiiVariable.\r
+ //\r
CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize);\r
FreePool (Data);\r
}\r
- //\r
- // If the operation is successful, we copy the data\r
- // to the default value buffer in the PCD Database.\r
- // So that we can free the Data allocated in GetHiiVariable.\r
- //\r
- //\r
- // If the operation is not successful, \r
- // Return 1) either the default value specified by Platform Integrator \r
- // 2) Or the value Set by a PCD set operation.\r
- //\r
RetPtr = (VOID *) VaraiableDefaultBuffer;\r
}\r
break;\r
\r
case PCD_TYPE_STRING:\r
- StringTableIdx = *(UINT16*)((UINT8 *) PcdDb + Offset);\r
+ StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + Offset);\r
RetPtr = (VOID *) (StringTable + StringTableIdx);\r
break;\r
\r
ASSERT (Status == EFI_SUCCESS);\r
*VariableData = Buffer;\r
*VariableSize = Size;\r
+ } else {\r
+ //\r
+ // Use Default Data only when variable is not found. \r
+ // For other error status, correct data can't be got, and trig ASSERT().\r
+ //\r
+ ASSERT (Status == EFI_NOT_FOUND);\r
}\r
\r
return Status;\r
ASSERT (TokenNumber + 1 < PCD_TOTAL_TOKEN_NUMBER + 1);\r
\r
if (PtrType) {\r
- if (*Size > DxePcdGetSize (TokenNumber + 1)) {\r
+ //\r
+ // Get MaxSize first, then check new size with max buffer size.\r
+ //\r
+ GetPtrTypeSize (TokenNumber, &MaxSize);\r
+ if (*Size > MaxSize) {\r
+ *Size = MaxSize;\r
return EFI_INVALID_PARAMETER;\r
}\r
} else {\r
\r
case PCD_TYPE_STRING:\r
if (SetPtrTypeSize (TmpTokenNumber, Size)) {\r
- CopyMem (StringTable + *((UINT16 *)InternalData), Data, *Size);\r
+ CopyMem (StringTable + *((STRING_HEAD *)InternalData), Data, *Size);\r
Status = EFI_SUCCESS;\r
} else {\r
Status = EFI_INVALID_PARAMETER;\r
if (EFI_NOT_FOUND == Status) {\r
if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {\r
CopyMem (\r
- StringTable + *(UINT16 *)(PcdDb + VariableHead->DefaultValueOffset),\r
+ StringTable + *(STRING_HEAD *)(PcdDb + VariableHead->DefaultValueOffset),\r
Data,\r
*Size\r
);\r