You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <hc...@us...> - 2010-05-27 08:48:35
|
Revision: 236 http://efidevkit.svn.sourceforge.net/efidevkit/?rev=236&view=rev Author: hchen30 Date: 2010-05-27 08:48:27 +0000 (Thu, 27 May 2010) Log Message: ----------- Trackers :7 Trackers included: ---------------------------------------------------------------------------------------------------------- ID | Title | Priority | Resolver ---------------------------------------------------------------------------------------------------------- #1304 | Correction in UefiSetupBrowser IfrParse.c for handling ordered list options | High | xdu2 #1305 | GetString() buffer overflow | Medium | xdu2 #1306 | [VfrCompiler] Set correct MinValue/MaxValue for OneOf | Low | xdu2 #1307 | How could HII app prevent user entering date/time that are already lapsed | Medium | #1308 | Bug in ATA LowestAlignedLba Computation | High | jgong5 #1310 | [HII] Bug in HII Database - HiiGetLanguages() | High | #1311 | [PXE] Siaddr in DHCPv4 header should be prior to Option 54 when determine | Low | | the next server address. | | Modified Paths: -------------- trunk/Edk/Foundation/Efi/Protocol/HiiString/HiiString.h trunk/Edk/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Apps/Load.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Apps/Ver.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Apps/pci.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Shell.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Shell_Full.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/Load.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/Touch.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/Ver.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/pci.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Shell.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Shell_Full.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Apps/Load.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Apps/Ver.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Apps/pci.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Shell.efi trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Shell_Full.efi trunk/Edk/Sample/Bus/Pci/IdeBus/Dxe/ata.c trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcDhcp.c trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcImpl.c trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/Database.c trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/HiiDatabase.h trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/String.c trunk/Edk/Sample/Universal/UserInterface/UefiSetupBrowser/Dxe/DriverSample/DriverSample.c trunk/Edk/Sample/Universal/UserInterface/UefiSetupBrowser/Dxe/IfrParse.c trunk/Edk/Sample/Universal/UserInterface/UefiSetupBrowser/Dxe/ProcessOptions.c trunk/Edk/Sample/Version.env Modified: trunk/Edk/Foundation/Efi/Protocol/HiiString/HiiString.h =================================================================== --- trunk/Edk/Foundation/Efi/Protocol/HiiString/HiiString.h 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Foundation/Efi/Protocol/HiiString/HiiString.h 2010-05-27 08:48:27 UTC (rev 236) @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2010, Intel Corporation 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 @@ -54,6 +54,8 @@ Routine Description: This function adds the string String to the group of strings owned by PackageList, with the specified font information StringFontInfo and returns a new string id. + The new string identifier is guaranteed to be unique within the package list. + That new string identifier is reserved for all languages in the package list. Arguments: This - A pointer to the EFI_HII_STRING_PROTOCOL instance. Modified: trunk/Edk/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c =================================================================== --- trunk/Edk/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c 2010-05-27 08:48:27 UTC (rev 236) @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007 - 2010, Intel Corporation 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 @@ -552,19 +552,36 @@ Languages = GetSupportedLanguages (PackageList); + if (StringId == NULL) { + return EFI_INVALID_PARAMETER; + } + *StringId = 0; + LangStrings = Languages; while (*LangStrings != 0) { GetNextLanguage (&LangStrings, Lang); - Status = gIfrLibHiiString->NewString ( - gIfrLibHiiString, - PackageList, - StringId, - Lang, - NULL, - String, - NULL - ); + if (*StringId == 0) { + Status = gIfrLibHiiString->NewString ( + gIfrLibHiiString, + PackageList, + StringId, + Lang, + NULL, + String, + NULL + ); + } else { + Status = gIfrLibHiiString->SetString ( + gIfrLibHiiString, + PackageList, + *StringId, + Lang, + String, + NULL + ); + } + if (EFI_ERROR (Status)) { break; } Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Apps/Load.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Apps/Ver.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Apps/pci.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Shell.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ia32/Shell_Full.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/Load.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/Touch.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/Ver.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Apps/pci.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Shell.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/ipf/Shell_Full.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Apps/Load.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Apps/Ver.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Apps/pci.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Shell.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Other/Maintained/Application/UefiShell/bin/x64/Shell_Full.efi =================================================================== (Binary files differ) Modified: trunk/Edk/Sample/Bus/Pci/IdeBus/Dxe/ata.c =================================================================== --- trunk/Edk/Sample/Bus/Pci/IdeBus/Dxe/ata.c 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Bus/Pci/IdeBus/Dxe/ata.c 2010-05-27 08:48:27 UTC (rev 236) @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2010, Intel Corporation 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 @@ -2309,7 +2309,8 @@ // if ((AtaIdentifyData->alignment_logic_in_phy_blocks & 0xc000) == 0x4000) { IdeDev->BlkIo.Media->LowestAlignedLba = - (EFI_LBA) (AtaIdentifyData->alignment_logic_in_phy_blocks & 0x3fff); + (EFI_LBA) ((IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock - (AtaIdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) % + IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock); } } // Modified: trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h =================================================================== --- trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h 2010-05-27 08:48:27 UTC (rev 236) @@ -1,5 +1,5 @@ /*++ - Copyright (c) 2004 - 2008, Intel Corporation + Copyright (c) 2004 - 2010, Intel Corporation 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 @@ -369,48 +369,159 @@ } }; -static CIfrQuestionHeader *gCurrentQuestion = NULL; - /* * The definition of CIfrMinMaxStepData */ class CIfrMinMaxStepData { private: MINMAXSTEP_DATA *mMinMaxStepData; + BOOLEAN ValueIsSet; + BOOLEAN IsNumeric; public: - CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr) : mMinMaxStepData (DataAddr) { + CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr, BOOLEAN NumericOpcode=FALSE) : mMinMaxStepData (DataAddr) { mMinMaxStepData->u64.MinValue = 0; mMinMaxStepData->u64.MaxValue = 0; mMinMaxStepData->u64.Step = 0; + ValueIsSet = FALSE; + IsNumeric = NumericOpcode; } VOID SetMinMaxStepData (IN UINT64 MinValue, IN UINT64 MaxValue, IN UINT64 Step) { - mMinMaxStepData->u64.MinValue = MinValue; - mMinMaxStepData->u64.MaxValue = MaxValue; - mMinMaxStepData->u64.Step = Step; + if (!ValueIsSet) { + mMinMaxStepData->u64.MinValue = MinValue; + mMinMaxStepData->u64.MaxValue = MaxValue; + ValueIsSet = TRUE; + } else { + if (MinValue < mMinMaxStepData->u64.MinValue) { + mMinMaxStepData->u64.MinValue = MinValue; + } + if (MaxValue > mMinMaxStepData->u64.MaxValue) { + mMinMaxStepData->u64.MaxValue = MaxValue; + } + } + mMinMaxStepData->u64.Step = Step; } VOID SetMinMaxStepData (IN UINT32 MinValue, IN UINT32 MaxValue, IN UINT32 Step) { - mMinMaxStepData->u32.MinValue = MinValue; - mMinMaxStepData->u32.MaxValue = MaxValue; - mMinMaxStepData->u32.Step = Step; + if (!ValueIsSet) { + mMinMaxStepData->u32.MinValue = MinValue; + mMinMaxStepData->u32.MaxValue = MaxValue; + ValueIsSet = TRUE; + } else { + if (MinValue < mMinMaxStepData->u32.MinValue) { + mMinMaxStepData->u32.MinValue = MinValue; + } + if (MaxValue > mMinMaxStepData->u32.MaxValue) { + mMinMaxStepData->u32.MaxValue = MaxValue; + } + } + mMinMaxStepData->u32.Step = Step; } VOID SetMinMaxStepData (IN UINT16 MinValue, IN UINT16 MaxValue, IN UINT16 Step) { - mMinMaxStepData->u16.MinValue = MinValue; - mMinMaxStepData->u16.MaxValue = MaxValue; - mMinMaxStepData->u16.Step = Step; + if (!ValueIsSet) { + mMinMaxStepData->u16.MinValue = MinValue; + mMinMaxStepData->u16.MaxValue = MaxValue; + ValueIsSet = TRUE; + } else { + if (MinValue < mMinMaxStepData->u16.MinValue) { + mMinMaxStepData->u16.MinValue = MinValue; + } + if (MaxValue > mMinMaxStepData->u16.MaxValue) { + mMinMaxStepData->u16.MaxValue = MaxValue; + } + } + mMinMaxStepData->u16.Step = Step; } VOID SetMinMaxStepData (IN UINT8 MinValue, IN UINT8 MaxValue, IN UINT8 Step) { - mMinMaxStepData->u8.MinValue = MinValue; - mMinMaxStepData->u8.MaxValue = MaxValue; - mMinMaxStepData->u8.Step = Step; + if (!ValueIsSet) { + mMinMaxStepData->u8.MinValue = MinValue; + mMinMaxStepData->u8.MaxValue = MaxValue; + ValueIsSet = TRUE; + } else { + if (MinValue < mMinMaxStepData->u8.MinValue) { + mMinMaxStepData->u8.MinValue = MinValue; + } + if (MaxValue > mMinMaxStepData->u8.MaxValue) { + mMinMaxStepData->u8.MaxValue = MaxValue; + } + } + mMinMaxStepData->u8.Step = Step; } + UINT64 GetMinData (UINT8 VarType) { + UINT64 MinValue = 0; + switch (VarType) { + case EFI_IFR_TYPE_NUM_SIZE_64: + MinValue = mMinMaxStepData->u64.MinValue; + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + MinValue = (UINT64) mMinMaxStepData->u32.MinValue; + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + MinValue = (UINT64) mMinMaxStepData->u16.MinValue; + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + MinValue = (UINT64) mMinMaxStepData->u8.MinValue; + break; + default: + break; + } + return MinValue; + } + + UINT64 GetMaxData (UINT8 VarType) { + UINT64 MaxValue = 0; + switch (VarType) { + case EFI_IFR_TYPE_NUM_SIZE_64: + MaxValue = mMinMaxStepData->u64.MaxValue; + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + MaxValue = (UINT64) mMinMaxStepData->u32.MaxValue; + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + MaxValue = (UINT64) mMinMaxStepData->u16.MaxValue; + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + MaxValue = (UINT64) mMinMaxStepData->u8.MaxValue; + break; + default: + break; + } + return MaxValue; + } + + UINT64 GetStepData (UINT8 VarType) { + UINT64 MaxValue = 0; + switch (VarType) { + case EFI_IFR_TYPE_NUM_SIZE_64: + MaxValue = mMinMaxStepData->u64.Step; + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + MaxValue = (UINT64) mMinMaxStepData->u32.Step; + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + MaxValue = (UINT64) mMinMaxStepData->u16.Step; + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + MaxValue = (UINT64) mMinMaxStepData->u8.Step; + break; + default: + break; + } + return MaxValue; + } + + BOOLEAN IsNumericOpcode () { + return IsNumeric; + } }; +static CIfrQuestionHeader *gCurrentQuestion = NULL; +static CIfrMinMaxStepData *gCurrentMinMaxData = NULL; + /* * The definition of all of the UEFI IFR Objects */ @@ -946,13 +1057,15 @@ CIfrNumeric () : CIfrObj (EFI_IFR_NUMERIC_OP, (CHAR8 **)&mNumeric), CIfrOpHeader (EFI_IFR_NUMERIC_OP, &mNumeric->Header), CIfrQuestionHeader (&mNumeric->Question), - CIfrMinMaxStepData (&mNumeric->data) { + CIfrMinMaxStepData (&mNumeric->data, TRUE) { mNumeric->Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC; - gCurrentQuestion = this; + gCurrentQuestion = this; + gCurrentMinMaxData = this; } ~CIfrNumeric () { - gCurrentQuestion = NULL; + gCurrentQuestion = NULL; + gCurrentMinMaxData = NULL; } EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) { @@ -982,11 +1095,13 @@ CIfrQuestionHeader (&mOneOf->Question), CIfrMinMaxStepData (&mOneOf->data) { mOneOf->Flags = 0; - gCurrentQuestion = this; + gCurrentQuestion = this; + gCurrentMinMaxData = this; } ~CIfrOneOf () { - gCurrentQuestion = NULL; + gCurrentQuestion = NULL; + gCurrentMinMaxData = NULL; } EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) { Modified: trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g =================================================================== --- trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g 2010-05-27 08:48:27 UTC (rev 236) @@ -1,5 +1,5 @@ /*++ -Copyright (c) 2004 - 2009, Intel Corporation +Copyright (c) 2004 - 2010, Intel Corporation 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 @@ -975,25 +975,35 @@ D:Default << DObj.SetLineNo(D->getLine()); >> ( ( - vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); { CIfrEnd EndObj1; EndObj1.SetLineNo(0); } >> - | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," - << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >> + vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >> + | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," << + if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) { + //check default value is valid for Numeric Opcode + if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue."); + } + } + DObj.SetType (_GET_CURRQEST_DATATYPE()); + DObj.SetValue(Val); + >> ) { DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >> } << - _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine()); - _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine()); - if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) { - _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd ( - DefaultId, - _GET_CURRQEST_VARTINFO(), - VarStoreName, - _GET_CURRQEST_DATATYPE (), - Val), D); - } - >> + _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine()); + _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine()); + if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) { + _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd ( + DefaultId, + _GET_CURRQEST_VARTINFO(), + VarStoreName, + _GET_CURRQEST_DATATYPE (), + Val), + D->getLine() + ); + } + >> ) ; @@ -1525,9 +1535,25 @@ << UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE; UINT8 HFlags = 0; + EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID; >> numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )* - << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >> + << + //check data type flag + VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId); + if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) { + if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) { + _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type"); + } + } else { + // update data type for name/value store + UINT32 DataTypeSize; + _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE; + mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); + _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize; + } + _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); + >> ; numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] : @@ -1559,11 +1585,27 @@ vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] : << - UINT8 LFlags = _GET_CURRQEST_DATATYPE(); + UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE; UINT8 HFlags = 0; + EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID; >> numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )* - << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >> + << + //check data type flag + VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId); + if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) { + if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) { + _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type"); + } + } else { + // update data type for Name/Value store + UINT32 DataTypeSize; + _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE; + mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize); + _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize; + } + _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); + >> ; vfrStatementStringType : @@ -1676,7 +1718,7 @@ ( vfrQuestionHeader[TObj, QUESTION_TIME] "," { F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," } - vfrStatementDefault + vfrStatementQuestionOptionList ) | ( @@ -1919,7 +1961,31 @@ >> L:Option << OOOObj.SetLineNo(L->getLine()); >> Text "=" "STRING_TOKEN" "\(" S:Number "\)" "," << OOOObj.SetOption (_STOSID(S->getText())); >> - Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] "," << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >> + Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] "," + << + if (gCurrentMinMaxData != NULL) { + //set min/max value for oneof opcode + UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE()); + switch (_GET_CURRQEST_DATATYPE()) { + case EFI_IFR_TYPE_NUM_SIZE_64: + gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step); + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step); + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step); + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step); + break; + default: + break; + } + } + OOOObj.SetType (_GET_CURRQEST_DATATYPE()); + OOOObj.SetValue (Val); + >> F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()] << if (OOOObj.GetFlags () & 0x10) { @@ -2664,6 +2730,7 @@ VOID _PCATCH (IN EFI_VFR_RETURN_CODE); VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr); VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32); + VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN INT8 *); VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32); @@ -2850,6 +2917,16 @@ } VOID +EfiVfrParser::_PCATCH ( + IN EFI_VFR_RETURN_CODE ReturnCode, + IN UINT32 LineNum, + IN INT8 *ErrorMsg + ) +{ + mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg); +} + +VOID EfiVfrParser::syn ( ANTLRAbstractToken *Tok, ANTLRChar *Egroup, Modified: trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp =================================================================== --- trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp 2010-05-27 08:48:27 UTC (rev 236) @@ -1,5 +1,5 @@ /*++ -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2010, Intel Corporation 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 @@ -1115,6 +1115,38 @@ EFI_VFR_RETURN_CODE CVfrVarDataTypeDB::GetDataTypeSize ( + IN UINT8 DataType, + OUT UINT32 *Size + ) +{ + SVfrDataType *pDataType = NULL; + + if (Size == NULL) { + return VFR_RETURN_FATAL_ERROR; + } + + *Size = 0; + DataType = DataType & 0x0F; + + // + // For user defined data type, the size can't be got by this function. + // + if (DataType == EFI_IFR_TYPE_OTHER) { + return VFR_RETURN_SUCCESS; + } + + for (pDataType = mDataTypeList; pDataType != NULL; pDataType = pDataType->mNext) { + if (DataType == pDataType->mType) { + *Size = pDataType->mTotalSize; + return VFR_RETURN_SUCCESS; + } + } + + return VFR_RETURN_UNDEFINED; +} + +EFI_VFR_RETURN_CODE +CVfrVarDataTypeDB::GetDataTypeSize ( IN INT8 *TypeName, OUT UINT32 *Size ) @@ -1689,6 +1721,44 @@ return VFR_RETURN_UNDEFINED; } +EFI_VFR_VARSTORE_TYPE +CVfrDataStorage::GetVarStoreType ( + IN EFI_VARSTORE_ID VarStoreId + ) +{ + SVfrVarStorageNode *pNode; + EFI_VFR_VARSTORE_TYPE VarStoreType; + + VarStoreType = EFI_VFR_VARSTORE_INVALID; + + if (VarStoreId == EFI_VARSTORE_ID_INVALID) { + return VarStoreType; + } + + for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) { + if (pNode->mVarStoreId == VarStoreId) { + VarStoreType = pNode->mVarStoreType; + return VarStoreType; + } + } + + for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) { + if (pNode->mVarStoreId == VarStoreId) { + VarStoreType = pNode->mVarStoreType; + return VarStoreType; + } + } + + for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) { + if (pNode->mVarStoreId == VarStoreId) { + VarStoreType = pNode->mVarStoreType; + return VarStoreType; + } + } + + return VarStoreType; +} + EFI_VFR_RETURN_CODE CVfrDataStorage::GetVarStoreName ( IN EFI_VARSTORE_ID VarStoreId, Modified: trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h =================================================================== --- trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h 2010-05-27 08:48:27 UTC (rev 236) @@ -1,5 +1,5 @@ /*++ -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2010, Intel Corporation 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 @@ -192,6 +192,7 @@ EFI_VFR_RETURN_CODE GetDataType (IN INT8 *, OUT SVfrDataType **); EFI_VFR_RETURN_CODE GetDataTypeSize (IN INT8 *, OUT UINT32 *); + EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *); EFI_VFR_RETURN_CODE GetDataFieldInfo (IN INT8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &); EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT INT8 ***, OUT UINT32 *); @@ -289,6 +290,7 @@ EFI_VFR_RETURN_CODE GetVarStoreId (IN INT8 *, OUT EFI_VARSTORE_ID *); EFI_VFR_RETURN_CODE GetVarStoreType (IN INT8 *, OUT EFI_VFR_VARSTORE_TYPE &); + EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID); EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT INT8 **); EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN INT8 *, OUT INT8 **); Modified: trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcDhcp.c =================================================================== --- trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcDhcp.c 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcDhcp.c 2010-05-27 08:48:27 UTC (rev 236) @@ -322,25 +322,21 @@ Offer = &Private->Dhcp4Offers[Index].Packet.Offer; // - // use option 54, if zero, use siaddr in header + // Use siaddr in header, or use option 54 if siaddr is zero. // NetZeroMem (&ServerIp, sizeof(EFI_IP_ADDRESS)); - if (Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID] != NULL) { + NetCopyMem ( + &ServerIp.Addr[0], + &Offer->Dhcp4.Header.ServerAddr, + sizeof (EFI_IPv4_ADDRESS) + ); + if (ServerIp.Addr[0] == 0) { NetCopyMem ( &ServerIp.Addr[0], Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data, sizeof (EFI_IPv4_ADDRESS) ); - } else { - NetCopyMem ( - &ServerIp.Addr[0], - &Offer->Dhcp4.Header.ServerAddr, - sizeof (EFI_IPv4_ADDRESS) - ); } - if (ServerIp.Addr[0] == 0) { - return FALSE; - } CachedPacket = &Private->ProxyOffer; Reply = &CachedPacket->Packet.Offer; Modified: trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcImpl.c =================================================================== --- trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcImpl.c 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Universal/Network/UefiPxeBc/Dxe/PxeBcImpl.c 2010-05-27 08:48:27 UTC (rev 236) @@ -1725,24 +1725,20 @@ } // - // use option 54, if zero, use siaddr in header + // Use siaddr in header, or use option 54 if siaddr is zero. // - if (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID] != NULL) { + NetCopyMem ( + &Private->ServerIp, + &Packet->Packet.Offer.Dhcp4.Header.ServerAddr, + sizeof (EFI_IPv4_ADDRESS) + ); + if (Private->ServerIp.Addr[0] == 0) { NetCopyMem ( &Private->ServerIp, Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data, sizeof (EFI_IPv4_ADDRESS) ); - } else { - NetCopyMem ( - &Private->ServerIp, - &Packet->Packet.Offer.Dhcp4.Header.ServerAddr, - sizeof (EFI_IPv4_ADDRESS) - ); } - if (Private->ServerIp.Addr[0] == 0) { - return EFI_DEVICE_ERROR; - } ASSERT (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL); Modified: trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/Database.c =================================================================== --- trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/Database.c 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/Database.c 2010-05-27 08:48:27 UTC (rev 236) @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2010, Intel Corporation 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 @@ -878,7 +878,7 @@ // // Collect all font block info // - Status = FindStringBlock (Private, StringPackage, (EFI_STRING_ID) (-1), NULL, NULL, NULL, NULL); + Status = FindStringBlock (Private, StringPackage, (EFI_STRING_ID) (-1), NULL, NULL, NULL, &StringPackage->MaxStringId); if (EFI_ERROR (Status)) { return Status; } @@ -903,6 +903,88 @@ return Status; } +EFI_STATUS +AdjustStringPackage ( + IN OUT HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList +) +/*++ + + Routine Description: + Adjust all string packages in a single package list to have the same max string ID. + + Arguments: + PackageList - Pointer to a package list which will be inserted to. + + Returns: + EFI_SUCCESS - Adjust all string packages successfully. + others - Can't adjust string packges. + +--*/ +{ + EFI_LIST_ENTRY *Link; + HII_STRING_PACKAGE_INSTANCE *StringPackage; + UINT32 Skip2BlockSize; + UINT32 OldBlockSize; + UINT8 *StringBlock; + UINT8 *BlockPtr; + EFI_STRING_ID MaxStringId; + UINT16 SkipCount; + + MaxStringId = 0; + for (Link = PackageList->StringPkgHdr.ForwardLink; + Link != &PackageList->StringPkgHdr; + Link = Link->ForwardLink + ) { + StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE); + if (MaxStringId < StringPackage->MaxStringId) { + MaxStringId = StringPackage->MaxStringId; + } + } + + for (Link = PackageList->StringPkgHdr.ForwardLink; + Link != &PackageList->StringPkgHdr; + Link = Link->ForwardLink + ) { + StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE); + if (StringPackage->MaxStringId < MaxStringId) { + OldBlockSize = StringPackage->StringPkgHdr->Header.Length - StringPackage->StringPkgHdr->HdrSize; + // + // Create SKIP2 EFI_HII_SIBT_SKIP2_BLOCKs to reserve the missing string IDs. + // + SkipCount = (UINT16) (MaxStringId - StringPackage->MaxStringId); + Skip2BlockSize = (UINT32) sizeof (EFI_HII_SIBT_SKIP2_BLOCK); + + StringBlock = (UINT8 *) EfiLibAllocateZeroPool (OldBlockSize + Skip2BlockSize); + if (StringBlock == NULL) { + return EFI_OUT_OF_RESOURCES; + } + // + // Copy original string blocks, except the EFI_HII_SIBT_END. + // + EfiCopyMem (StringBlock, StringPackage->StringBlock, OldBlockSize - sizeof (EFI_HII_SIBT_END_BLOCK)); + // + // Create SKIP2 EFI_HII_SIBT_SKIP2_BLOCK blocks + // + BlockPtr = StringBlock + OldBlockSize - sizeof (EFI_HII_SIBT_END_BLOCK); + *BlockPtr = EFI_HII_SIBT_SKIP2; + EfiCopyMem (BlockPtr + 1, &SkipCount, sizeof (UINT16)); + BlockPtr += sizeof (EFI_HII_SIBT_SKIP2_BLOCK); + + // + // Append a EFI_HII_SIBT_END block to the end. + // + *BlockPtr = EFI_HII_SIBT_END; + gBS->FreePool (StringPackage->StringBlock); + StringPackage->StringBlock = StringBlock; + StringPackage->StringPkgHdr->Header.Length += Skip2BlockSize; + PackageList->PackageListHdr.PackageLength += Skip2BlockSize; + StringPackage->MaxStringId = MaxStringId; + } + } + + return EFI_SUCCESS; +} + STATIC EFI_STATUS ExportStringPackages ( @@ -2367,6 +2449,13 @@ EFI_HII_PACKAGE_HEADER *PackageHdrPtr; EFI_HII_PACKAGE_HEADER PackageHeader; UINT32 OldPackageListLen; + BOOLEAN StringPkgIsAdd; + + // + // Initialize Variables + // + StringPkgIsAdd = FALSE; + FontPackage = NULL; // // Process the package list header @@ -2460,6 +2549,7 @@ (UINT8) (PackageHeader.Type), DatabaseRecord->Handle ); + StringPkgIsAdd = TRUE; break; case EFI_HII_PACKAGE_FONTS: Status = InsertFontPackage ( @@ -2538,6 +2628,13 @@ EfiCopyMem (&PackageHeader, PackageHdrPtr, sizeof (EFI_HII_PACKAGE_HEADER)); } + // + // Adjust String Package to make sure all string packages have the same max string ID. + // + if (!EFI_ERROR (Status) && StringPkgIsAdd) { + Status = AdjustStringPackage (DatabaseRecord->PackageList); + } + return Status; } Modified: trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/HiiDatabase.h =================================================================== --- trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/HiiDatabase.h 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/HiiDatabase.h 2010-05-27 08:48:27 UTC (rev 236) @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2010, Intel Corporation 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 @@ -92,6 +92,7 @@ EFI_LIST_ENTRY StringEntry; EFI_LIST_ENTRY FontInfoList; // local font info list UINT8 FontId; + EFI_STRING_ID MaxStringId; // record StringId } HII_STRING_PACKAGE_INSTANCE; // @@ -413,7 +414,8 @@ Parse all string blocks to find a String block specified by StringId. If StringId = (EFI_STRING_ID) (-1), find out all EFI_HII_SIBT_FONT blocks - within this string package and backup its information. + within this string package and backup its information. If LastStringId is + specified, the string id of last string block will also be output. If StringId = 0, output the string id of last string block (EFI_HII_SIBT_END). @@ -426,7 +428,7 @@ StringBlockAddr - Output the block address of found string block. StringTextOffset - Offset, relative to the found block address, of the string text information. - LastStringId - Output the last string id when StringId = 0. + LastStringId - Output the last string id when StringId = 0 or StringId = -1. Returns: EFI_SUCCESS - The string text and font is retrieved successfully. Modified: trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/String.c =================================================================== --- trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/String.c 2009-12-22 02:51:31 UTC (rev 235) +++ trunk/Edk/Sample/Universal/UserInterface/UefiHiiDataBase/Dxe/String.c 2010-05-27 08:48:27 UTC (rev 236) @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2010, Intel Corporation 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 @@ -254,29 +254,29 @@ /*++ Routine Description: - Parse all string blocks to find a String block specified by StringId. + Parse all string blocks to find a String block specified by StringId. + If StringId = (EFI_STRING_ID) (-1), find out all EFI_HII_SIBT_FONT blocks + within this string package and backup its information. If LastStringId is + specified, the string id of last string block will also be output. + If StringId = 0, output the string id of last string block (EFI_HII_SIBT_STRING). - If StringId = (EFI_STRING_ID) (-1), find out all EFI_HII_SIBT_FONT blocks - within this string package and backup its information. - - If StringId = 0, output the string id of last string block (EFI_HII_SIBT_END). - + Arguments: Private - Hii database private structure. StringPackage - Hii string package instance. - StringId - The string\xA1\xAFs id, which is unique within PackageList. + StringId - The string\xA1\xAFs id, which is unique within PackageList. BlockType - Output the block type of found string block. StringBlockAddr - Output the block address of found string block. StringTextOffset - Offset, relative to the found block address, of the string text information. - LastStringId - Output the last string id when StringId = 0. + LastStringId - Output the last string id when StringId = 0 or StringId = -1. Returns: EFI_SUCCESS - The string text and font is retrieved successfully. EFI_NOT_FOUND - The specified text or font info can not be found out. - EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task. + EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task. ---*/ +--*/ { UINT8 *BlockHdr; EFI_STRING_ID CurrentStringId; @@ -306,8 +306,15 @@ if (StringId != (EFI_STRING_ID) (-1) && StringId != 0) { ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL); + if (StringId > StringPackage->MaxStringId) { + return EFI_NOT_FOUND; + } } else { ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE); + if (StringId == 0 && LastStringId != NULL) { + *LastStringId = StringPackage->MaxStringId; + return EFI_SUCCESS; + } } EfiZeroMem (&Zero, sizeof (CHAR16)); @@ -559,15 +566,14 @@ } + // + // Get last string ID + // if (StringId == (EFI_STRING_ID) (-1)) { + *LastStringId = CurrentStringId - 1; return EFI_SUCCESS; } - if (StringId == 0 && LastStringId != NULL) { - *LastStringId = CurrentStringId; - return EFI_SUCCESS; - } - return EFI_NOT_FOUND; } @@ -578,7 +584,7 @@ IN HII_STRING_PACKAGE_INSTANCE *StringPackage, IN EFI_STRING_ID StringId, OUT EFI_STRING String, - IN OUT UINTN *StringSize, + IN OUT UINTN *StringSize, OPTIONAL OUT EFI_FONT_INFO **StringFontInfo OPTIONAL ) /*++ @@ -610,7 +616,7 @@ EFI_STATUS Status; UINT8 FontId; - ASSERT (StringPackage != NULL && StringSize != NULL); + ASSERT (StringPackage != NULL); ASSERT (Private != NULL && Private->Signature == HII_DATABASE_PRIVATE_DATA_SIGNATURE); // @@ -629,6 +635,13 @@ return Status; } + if (StringSize == NULL) { + // + // String text is not requested + // + return EFI_SUCCESS; + } + // // Get the string text. // @@ -923,6 +936,8 @@ Routine Description: This function adds the string String to the group of strings owned by PackageList, with the specified font information StringFontInfo and returns a new string id. + The new string identifier is guaranteed to be unique within the package list. + That new string identifier is reserved for all languages in the package list. Arguments: This - A pointer to the EFI_HII_STRING_PROTOCOL instance. @@ -948,7 +963,6 @@ { EFI_STATUS Status; EFI_LIST_ENTRY *Link; - BOOLEAN Matched; HII_DATABASE_PRIVATE_DATA *Private; HII_DATABASE_RECORD *DatabaseRecord; HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageListNode; @@ -964,6 +978,11 @@ EFI_HII_SIBT_EXT2_BLOCK Ext2; HII_FONT_INFO *LocalFont; HII_GLOBAL_FONT_INFO *GlobalFont; + EFI_STRING_ID NewStringId; + EFI_STRING_ID NextStringId; + EFI_STRING_ID Index; + HII_STRING_PACKAGE_INSTANCE *MatchStringPackage; + BOOLEAN NewStringPackageCreated; if (This == NULL || String == NULL || StringId == NULL || Language == NULL || PackageList == NULL) { return EFI_INVALID_PARAMETER; @@ -1000,36 +1019,112 @@ return EFI_NOT_FOUND; } - // - // Try to get the matching string package. Create a new string package when failed. - // + Status = EFI_SUCCESS; + NewStringPackageCreated = FALSE; + NewStringId = 0; + NextStringId = 0; StringPackage = NULL; - Matched = FALSE; + MatchStringPackage = NULL; for (Link = PackageListNode->StringPkgHdr.ForwardLink; Link != &PackageListNode->StringPkgHdr; Link = Link->ForwardLink ) { StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE); + // + // Create a string block and corresponding font block if exists, then append them + // to the end of the string package. + // + Status = FindStringBlock ( + Private, + StringPackage, + 0, + NULL, + NULL, + NULL, + &NextStringId + ); + if (EFI_ERROR (Status)) { + goto Done; + } + // + // Make sure that new StringId is same in all String Packages for the different language. + // + if (NewStringId != 0 && NewStringId != NextStringId) { + ASSERT (FALSE); + Status = EFI_INVALID_PARAMETER; + goto Done; + } + NewStringId = NextStringId; + // + // Get the matched string package with language. + // if (EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) { - Matched = TRUE; - break; + MatchStringPackage = StringPackage; + } else { + OldBlockSize = StringPackage->StringPkgHdr->Header.Length - StringPackage->StringPkgHdr->HdrSize; + // + // Create a blank EFI_HII_SIBT_STRING_UCS2_BLOCK to reserve new string ID. + // + Ucs2BlockSize = (UINT32) sizeof (EFI_HII_SIBT_STRING_UCS2_BLOCK); + + StringBlock = (UINT8 *) EfiLibAllocateZeroPool (OldBlockSize + Ucs2BlockSize); + if (StringBlock == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto Done; + } + // + // Copy original string blocks, except the EFI_HII_SIBT_END. + // + EfiCopyMem (StringBlock, StringPackage->StringBlock, OldBlockSize - sizeof (EFI_HII_SIBT_END_BLOCK)); + // + // Create a blank EFI_HII_SIBT_STRING_UCS2 block + // + BlockPtr = StringBlock + OldBlockSize - sizeof (EFI_HII_SIBT_END_BLOCK); + *BlockPtr = EFI_HII_SIBT_STRING_UCS2; + BlockPtr += sizeof (EFI_HII_SIBT_STRING_UCS2_BLOCK); + + // + // Append a EFI_HII_SIBT_END block to the end. + // + *BlockPtr = EFI_HII_SIBT_END; + gBS->FreePool (StringPackage->StringBlock); + StringPackage->StringBlock = StringBlock; + StringPackage->StringPkgHdr->Header.Length += Ucs2BlockSize; + PackageListNode->PackageListHdr.PackageLength += Ucs2BlockSize; } - } + } + if (NewStringId == 0) { + // + // No string package is found. + // Create new string package. StringId 1 is reserved for Language Name string. + // + *StringId = 2; + } else { + // + // Set new StringId + // + *StringId = NewStringId + 1; + } - if (!Matched) { + if (MatchStringPackage != NULL) { + StringPackage = MatchStringPackage; + } else { // // LanguageName is required to create a new string package. // if (LanguageName == NULL) { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + goto Done; } StringPackage = EfiLibAllocateZeroPool (sizeof (HII_STRING_PACKAGE_INSTANCE)); if (StringPackage == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } StringPackage->Signature = HII_STRING_PACKAGE_SIGNATURE; + StringPackage->MaxStringId = *StringId; StringPackage->FontId = 0; InitializeListHead (&StringPackage->FontInfoList); @@ -1040,12 +1135,13 @@ StringPackage->StringPkgHdr = EfiLibAllocateZeroPool (HeaderSize); if (StringPackage->StringPkgHdr == NULL) { EfiLibSafeFreePool (StringPackage); - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } StringPackage->StringPkgHdr->Header.Type = EFI_HII_PACKAGE_STRINGS; StringPackage->StringPkgHdr->HdrSize = HeaderSize; StringPackage->StringPkgHdr->StringInfoOffset = HeaderSize; - EfiCopyMem (StringPackage->StringPkgHdr->LanguageWindow, mLanguageWindow, 16 * sizeof (CHAR16));; + EfiCopyMem (StringPackage->StringPkgHdr->LanguageWindow, mLanguageWindow, 16 * sizeof (CHAR16)); StringPackage->StringPkgHdr->LanguageName = 1; EfiAsciiStrCpy (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language); @@ -1054,14 +1150,15 @@ // printable language full name and EFI_HII_SIBT_END_BLOCK. // Ucs2BlockSize = (UINT32) (EfiStrSize ((CHAR16 *) LanguageName) + - sizeof (EFI_HII_SIBT_STRING_UCS2_BLOCK) - sizeof (CHAR16)); + (*StringId - 1) * sizeof (EFI_HII_SIBT_STRING_UCS2_BLOCK) - sizeof (CHAR16)); BlockSize = Ucs2BlockSize + sizeof (EFI_HII_SIBT_END_BLOCK); StringPackage->StringBlock = (UINT8 *) EfiLibAllocateZeroPool (BlockSize); if (StringPackage->StringBlock == NULL) { EfiLibSafeFreePool (StringPackage->StringPkgHdr); EfiLibSafeFreePool (StringPackage); - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } // @@ -1072,7 +1169,10 @@ BlockPtr += sizeof (EFI_HII_STRING_BLOCK); EfiCopyMem (BlockPtr, (EFI_STRING) LanguageName, EfiStrSize ((EFI_STRING) LanguageName)); BlockPtr += EfiStrSize ((EFI_STRING) LanguageName); - + for (Index = 2; Index <= *StringId - 1; Index ++) { + *BlockPtr = EFI_HII_SIBT_STRING_UCS2; + BlockPtr += sizeof (EFI_HII_SIBT_STRING_UCS2_BLOCK); + } // // Insert the end block // @@ -1084,24 +1184,8 @@ StringPackage->StringPkgHdr->Header.Length = HeaderSize + BlockSize; PackageListNode->PackageListHdr.PackageLength += StringPackage->StringPkgHdr->Header.Length; InsertTailList (&PackageListNode->StringPkgHdr, &StringPackage->StringEntry); + NewStringPackageCreated = TRUE; } - - // - // Create a string block and corresponding font block if exists, then append them - // to the end of the string package. - // - Status = FindStringBlock ( - Private, - StringPackage, - 0, - NULL, - NULL, - NULL, - StringId - ); - if (EFI_ERROR (Status)) { - return Status; - } OldBlockSize = StringPackage->StringPkgHdr->Header.Length - StringPackage->StringPkgHdr->HdrSize; @@ -1115,7 +1199,8 @@ StringBlock = (UINT8 *) EfiLibAllocateZeroPool (OldBlockSize + Ucs2BlockSize); if (StringBlock == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } // // Copy original string blocks, except the EFI_HII_SIBT_END. @@ -1154,7 +1239,8 @@ // StringBlock = (UINT8 *) EfiLibAllocateZeroPool (OldBlockSize + Ucs2FontBlockSize); if (StringBlock == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } // // Copy original string blocks, except the EFI_HII_SIBT_END. @@ -1190,7 +1276,8 @@ sizeof (EFI_HII_SIBT_FONT_BLOCK) - sizeof (CHAR16)); StringBlock = (UINT8 *) EfiLibAllocateZeroPool (OldBlockSize + FontBlockSize + Ucs2FontBlockSize); if (StringBlock == NULL) { - return EFI_OUT_OF_RESOURCES; + Status = EFI_OUT_OF_RESOURCES; + goto Done; } // // Copy original string blocks, except the EFI_HII_SIBT_END. @@ -1220,7 +1307,7 @@ &((EFI_FONT_INFO *) StringFontInfo)->FontName, EfiStrSize (((EFI_FONT_INFO *) StringFontInfo)->FontName) ); - + BlockPtr += EfiStrSize (((EFI_FONT_INFO *) StringFontInfo)->FontName); // // Create a EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK // @@ -1248,20 +1335,42 @@ } } - // - // Trigger any registered notification function - // - if (!Matched) { - return InvokeRegisteredFunction ( - Private, - EFI_HII_DATABASE_NOTIFY_NEW_PACK, - (VOID *) StringPackage, - EFI_HII_PACKAGE_STRINGS, - PackageList - ); +Done: + if (!EFI_ERROR (Status) && NewStringPackageCreated) { + // + // Trigger any registered notification function for new string package + // + Status = InvokeRegisteredFunction ( + Private, + EFI_HII_DATABASE_NOTIFY_NEW_PACK, + (VOID *) StringPackage, + EFI_HII_PACKAGE_STRINGS, + PackageList + ); } - return EFI_SUCCESS; + if (!EFI_ERROR (Status)) { + // + // Update MaxString Id to new StringId + // + for (Link = PackageListNode->StringPkgHdr.ForwardLink; + Link != &PackageListNode->StringPkgHdr; + Link = Link->ForwardLink + ) { + StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE); + StringPackage->MaxStringId = *StringId; + } + } else if (NewStringPackageCreated) { + // + // Free the allocated new string Package when new string can't be added. + // + RemoveEntryList (&StringPackage->StringEntry); + gBS->FreePool (StringPac... [truncated message content] |