]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Nov 2010 01:54:49 +0000 (01:54 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 26 Nov 2010 01:54:49 +0000 (01:54 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524

183 files changed:
EdkCompatibilityPkg/EDK_Snapshot.txt [deleted file]
EdkCompatibilityPkg/EdkCompatibilityPkg.dec
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.S
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.c
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.S
EdkCompatibilityPkg/Foundation/Cpu/Pentium/CpuIA32Lib/X64/Cpu.asm
EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
EdkCompatibilityPkg/Foundation/Efi/Include/EfiError.h
EdkCompatibilityPkg/Foundation/Efi/Include/EfiHii.h
EdkCompatibilityPkg/Foundation/Efi/Include/EfiImage.h
EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/BlockIo/BlockIo.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/EfiProtocolLib.inf
EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiFont/HiiFont.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiImage/HiiImage.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiString/HiiString.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/Ip4/Ip4.h
EdkCompatibilityPkg/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
EdkCompatibilityPkg/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
EdkCompatibilityPkg/Foundation/Framework/Include/EfiCapsule.h
EdkCompatibilityPkg/Foundation/Framework/Include/EfiPciCfg.h
EdkCompatibilityPkg/Foundation/Framework/Include/PeiApi.h
EdkCompatibilityPkg/Foundation/Framework/Include/TianoSpecDevicePath.h
EdkCompatibilityPkg/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
EdkCompatibilityPkg/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h
EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h [new file with mode: 0644]
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
EdkCompatibilityPkg/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
EdkCompatibilityPkg/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
EdkCompatibilityPkg/Foundation/Guid/AcpiDescription/AcpiDescription.h
EdkCompatibilityPkg/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
EdkCompatibilityPkg/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
EdkCompatibilityPkg/Foundation/Include/EfiSpec.h
EdkCompatibilityPkg/Foundation/Include/EfiTpm.h
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Smbios.h
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/Tpm12.h
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/pci23.h
EdkCompatibilityPkg/Foundation/Include/IndustryStandard/scsi.h
EdkCompatibilityPkg/Foundation/Include/Tiano.h
EdkCompatibilityPkg/Foundation/Include/TianoHii.h
EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.h
EdkCompatibilityPkg/Foundation/Protocol/NicIp4Config/NicIp4Config.h
EdkCompatibilityPkg/Foundation/Protocol/TcgService/TcgService.h
EdkCompatibilityPkg/Sample/CommonTools.env
EdkCompatibilityPkg/Sample/Platform/Common.dsc
EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
EdkCompatibilityPkg/Sample/Tools/Source/Makefile
EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile [new file with mode: 0644]
EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
EdkCompatibilityPkg/Sample/Version.env

diff --git a/EdkCompatibilityPkg/EDK_Snapshot.txt b/EdkCompatibilityPkg/EDK_Snapshot.txt
deleted file mode 100644 (file)
index efc15da..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Notes:\r
-  This EDK Compatibility Package is based on the EDK 1.03 release found at http://edk.tianocore.org.\r
-  It is compatibile with EDK 1.01 with the following exception:\r
-\r
-\r
-13:49 2008-1-24\r
-\r
-  This Edk Compatibility Package is updated to the EDK 1.04 release found at http://edk.tianocore.org.\r
-  \r
-  
\ No newline at end of file
index bda1bcd7b7a434b4d8f7b1ee2ab905cee6a0c314..6240bfde57aad556e15ddfda7e25b20e332d23ad 100644 (file)
@@ -3,7 +3,7 @@
 # in UEFI 2.0 + Framework 0.9x mode. This package also provides Thunk modules that enable Framework 0.9x modules to work with UEFI2.3/PI1.2 EDK II Cores.\r
 # EdkCompatibilityPkg is based on the EDK 1.01 release, found at http://edk.tianocore.org. This package only \r
 # contains the header files and libraries found in the original EDK. EdkCompatibilityPkg code is ANSI C compliant, so the modules can be built with GCC tool-chains. \r
-# This package also incorporates bug fixes released in EDK 1.04.\r
+# This package also incorporates bug fixes released in EDK 1.06.\r
 # \r
 # Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
 #\r
index 35cb4957c487bef5052bd478009ee6f75ffb9b80..acc2b2e9c9dee70963e198ee0207b977ae0e2567 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-#Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+#Copyright (c) 2006 - 2010, 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
@@ -157,7 +157,7 @@ L2:
 #  VOID\r
 #  )\r
 ASM_PFX(EfiEnableCache):\r
-    invd\r
+    wbinvd\r
     movl  %cr0, %eax\r
     andl  $0x9fffffff, %eax\r
     movl  %eax, %cr0\r
index 38d3c49744ee4038c5a4079e06e4bd9d1862c104..878be4d80a0accfb632318c824fd9c4865a43655 100644 (file)
@@ -1,6 +1,6 @@
 ;/*++\r
 ;\r
-;Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+;Copyright (c) 2006 - 2010, 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
@@ -140,7 +140,7 @@ EfiDisableCache  ENDP
 ;  VOID\r
 ;  )\r
 EfiEnableCache PROC C PUBLIC\r
-    invd\r
+    wbinvd\r
     mov   eax, cr0\r
     and   eax, 09fffffffh         \r
     mov   cr0, eax\r
index 6572bbd8f5699e2e532e324f3bd4445114b1afcc..b4dc7e0b226881dfa3f319133894d531a3e66d1b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -118,7 +118,7 @@ VOID
 EfiEnableCache (VOID)\r
 {\r
   __asm {\r
-    invd\r
+    wbinvd\r
     mov   eax, cr0\r
     and   eax, 09fffffffh         \r
     mov   cr0, eax\r
index 380ff936a11c7923576f23b6291efa499f61c654..38c663e1314403f4b9d2f40744307fe908260e44 100644 (file)
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------\r
 #*\r
-#*   Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r
+#*   Copyright (c) 2008 - 2010, 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
@@ -151,7 +151,7 @@ ASM_PFX(EfiDisableCache):
 #   );\r
 #------------------------------------------------------------------------------\r
 ASM_PFX(EfiEnableCache):\r
-      invd   \r
+      wbinvd   \r
       mov    %cr0,%rax\r
       and    $0xffffffff9fffffff,%rax\r
       mov    %rax,%cr0\r
index ab4daedfdcfa63cbb58e0a274dd87244757d939f..adb0fa73f32c13f5a73dbb5d81df636acefcc403 100644 (file)
@@ -2,7 +2,7 @@ TITLE   Cpu.asm: Assembly code for the x64 resources
 \r
 ;------------------------------------------------------------------------------\r
 ;*\r
-;*   Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
+;*   Copyright (c) 2005 - 2010, 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
@@ -150,7 +150,7 @@ EfiDisableCache ENDP
 ;   );\r
 ;------------------------------------------------------------------------------\r
 EfiEnableCache PROC    PUBLIC\r
-    invd\r
+    wbinvd\r
     mov   rax, cr0\r
     and   rax, 09fffffffh         \r
     mov   cr0, rax\r
index ea54c4bc0f419b131604c044f21d4379c3bc0f0b..4bde7d26109a8180aebf1bc3ab3af529c2662364 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
  \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -214,7 +214,6 @@ typedef struct {
   UINT8                           DeviceProtocol;\r
 } USB_CLASS_DEVICE_PATH;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
 #define MSG_USB_WWID_DP           0x10\r
 typedef struct {\r
   EFI_DEVICE_PATH_PROTOCOL        Header;\r
@@ -231,7 +230,6 @@ typedef struct {
   EFI_DEVICE_PATH_PROTOCOL        Header;\r
   UINT8                           Lun;\r
 } DEVICE_LOGICAL_UNIT_DEVICE_PATH;\r
-#endif\r
 \r
 #define MSG_SATA_DP               0x12\r
 typedef struct {\r
@@ -330,8 +328,6 @@ typedef struct {
   UINT32                          FlowControlMap;\r
 } UART_FLOW_CONTROL_DEVICE_PATH;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-\r
 #define DEVICE_PATH_MESSAGING_SAS \\r
     { 0xd487ddb4, 0x008b, 0x11d9, {0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d} }\r
 \r
@@ -345,8 +341,6 @@ typedef struct {
   UINT16                          RelativeTargetPort;\r
 } SAS_DEVICE_PATH;\r
 \r
-#endif\r
-\r
 #define MSG_ISCSI_DP              0x13\r
 typedef struct {\r
   EFI_DEVICE_PATH_PROTOCOL        Header;\r
@@ -428,8 +422,6 @@ typedef struct {
   EFI_GUID                        Protocol;\r
 } MEDIA_PROTOCOL_DEVICE_PATH;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
-\r
 #define MEDIA_FV_DP  0x07\r
 typedef struct {\r
   EFI_DEVICE_PATH_PROTOCOL  Header;\r
@@ -449,7 +441,6 @@ typedef struct {
   UINT64                    StartingOffset;\r
   UINT64                    EndingOffset;\r
 } MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH;\r
-#endif\r
 \r
 //\r
 // BBS Device Path\r
@@ -509,10 +500,8 @@ typedef union {
   F1394_DEVICE_PATH                    F1394;\r
   USB_DEVICE_PATH                      Usb;\r
   USB_CLASS_DEVICE_PATH                UsbClass;\r
-  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
   USB_WWID_DEVICE_PATH                 UsbWwid;\r
   DEVICE_LOGICAL_UNIT_DEVICE_PATH      LogicUnit;\r
-  #endif\r
   I2O_DEVICE_PATH                      I2O;\r
   MAC_ADDR_DEVICE_PATH                 MacAddr;\r
   IPv4_DEVICE_PATH                     Ipv4;\r
@@ -520,9 +509,7 @@ typedef union {
   INFINIBAND_DEVICE_PATH               InfiniBand;\r
   UART_DEVICE_PATH                     Uart;\r
   UART_FLOW_CONTROL_DEVICE_PATH        UartFlowControl;\r
-  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
   SAS_DEVICE_PATH                      Sas;\r
-  #endif\r
   ISCSI_DEVICE_PATH                    Iscsi;\r
   HARDDRIVE_DEVICE_PATH                HardDrive;\r
   CDROM_DEVICE_PATH                    CD;\r
@@ -530,12 +517,10 @@ typedef union {
   FILEPATH_DEVICE_PATH                 FilePath;\r
   MEDIA_PROTOCOL_DEVICE_PATH           MediaProtocol;\r
 \r
-  #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
   MEDIA_FW_VOL_DEVICE_PATH             PiwgFirmwareVolume;\r
   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH    PiwgFirmwareFile;\r
   MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH\r
                                        Offset;\r
-  #endif\r
 \r
   BBS_BBS_DEVICE_PATH                  Bbs;\r
 } EFI_DEV_PATH;\r
@@ -563,10 +548,8 @@ typedef union {
   F1394_DEVICE_PATH                    *F1394;\r
   USB_DEVICE_PATH                      *Usb;\r
   USB_CLASS_DEVICE_PATH                *UsbClass;\r
-  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
   USB_WWID_DEVICE_PATH                 *UsbWwid;\r
   DEVICE_LOGICAL_UNIT_DEVICE_PATH      *LogicUnit;\r
-  #endif\r
   I2O_DEVICE_PATH                      *I2O;\r
   MAC_ADDR_DEVICE_PATH                 *MacAddr;\r
   IPv4_DEVICE_PATH                     *Ipv4;\r
@@ -575,9 +558,7 @@ typedef union {
   UART_DEVICE_PATH                     *Uart;\r
   UART_FLOW_CONTROL_DEVICE_PATH        *UartFlowControl;\r
 \r
-  #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
   SAS_DEVICE_PATH                      *Sas;\r
-  #endif\r
   ISCSI_DEVICE_PATH                    *Iscsi;\r
 \r
   HARDDRIVE_DEVICE_PATH                *HardDrive;\r
@@ -586,10 +567,10 @@ typedef union {
   FILEPATH_DEVICE_PATH                 *FilePath;\r
   MEDIA_PROTOCOL_DEVICE_PATH           *MediaProtocol;\r
 \r
-  #if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
   MEDIA_FW_VOL_DEVICE_PATH             *PiwgFirmwareVolume;\r
   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH    *PiwgFirmwareFile;\r
-  #endif\r
+  MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH\r
+                                       *Offset;\r
 \r
   BBS_BBS_DEVICE_PATH                  *Bbs;\r
   UINT8                                *Raw;\r
index 9ddd1b3568743d885bd6405baafa9de7faadf174..1db119b2986e33f6537d8b9e67714be16d1f1588 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -58,6 +58,9 @@ Abstract:
 #define EFI_INCOMPATIBLE_VERSION  EFIERR (25)\r
 #define EFI_SECURITY_VIOLATION    EFIERR (26)\r
 #define EFI_CRC_ERROR             EFIERR (27)\r
+#define EFI_END_OF_MEDIA          EFIERR (28)\r
+#define EFI_END_OF_FILE           EFIERR (31)\r
+#define EFI_INVALID_LANGUAGE      EFIERR (32)\r
 \r
 #define EFI_WARN_UNKNOWN_GLYPH    EFIWARN (1)\r
 #define EFI_WARN_DELETE_FAILURE   EFIWARN (2)\r
index 30e001963c43cbf9b7d627e07a0bd066f9bf33f5..fd15d4f179947e22f52914d86e0d96fe49da8744 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -59,13 +59,13 @@ typedef struct {
 \r
 #define EFI_HII_PACKAGE_TYPE_ALL             0x00\r
 #define EFI_HII_PACKAGE_TYPE_GUID            0x01\r
-#define EFI_HII_PACKAGE_FORM                 0x02\r
-#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT      0x03\r
+#define EFI_HII_PACKAGE_FORMS                0x02\r
 #define EFI_HII_PACKAGE_STRINGS              0x04\r
 #define EFI_HII_PACKAGE_FONTS                0x05\r
 #define EFI_HII_PACKAGE_IMAGES               0x06\r
 #define EFI_HII_PACKAGE_SIMPLE_FONTS         0x07\r
 #define EFI_HII_PACKAGE_DEVICE_PATH          0x08\r
+#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT      0x09\r
 #define EFI_HII_PACKAGE_END                  0xDF\r
 #define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN    0xE0\r
 #define EFI_HII_PACKAGE_TYPE_SYSTEM_END      0xFF\r
@@ -108,6 +108,7 @@ typedef struct _EFI_HII_SIMPLE_FONT_PACKAGE_HDR {
 // Font Package\r
 //\r
 \r
+#define EFI_HII_FONT_STYLE_NORMAL            0x00000000\r
 #define EFI_HII_FONT_STYLE_BOLD              0x00000001\r
 #define EFI_HII_FONT_STYLE_ITALIC            0x00000002\r
 #define EFI_HII_FONT_STYLE_EMBOSS            0x00010000\r
@@ -237,8 +238,8 @@ typedef struct _EFI_HII_GUID_PACKAGE_HDR {
 // String Package\r
 //\r
 \r
-#define UEFI_CONFIG_LANG  L"x-UEFI"\r
-#define UEFI_CONFIG_LANG2 L"x-i-UEFI"     // BUGBUG, spec need to be updated.\r
+#define UEFI_CONFIG_LANG   "x-UEFI"\r
+#define UEFI_CONFIG_LANG_2 "x-i-UEFI"\r
 \r
 typedef struct _EFI_HII_STRING_PACKAGE_HDR {\r
   EFI_HII_PACKAGE_HEADER  Header;\r
@@ -697,14 +698,14 @@ typedef struct _EFI_IFR_VARSTORE {
 \r
 typedef struct _EFI_IFR_VARSTORE_EFI {\r
   EFI_IFR_OP_HEADER        Header;\r
-  UINT16                   VarStoreId;\r
+  EFI_VARSTORE_ID          VarStoreId;\r
   EFI_GUID                 Guid;\r
   UINT32                   Attributes;\r
 } EFI_IFR_VARSTORE_EFI;\r
 \r
 typedef struct _EFI_IFR_VARSTORE_NAME_VALUE {\r
   EFI_IFR_OP_HEADER        Header;\r
-  UINT16                   VarStoreId;\r
+  EFI_VARSTORE_ID          VarStoreId;\r
   EFI_GUID                 Guid;\r
 } EFI_IFR_VARSTORE_NAME_VALUE;\r
 \r
@@ -713,8 +714,13 @@ typedef struct _EFI_IFR_FORM_SET {
   EFI_GUID                 Guid;\r
   EFI_STRING_ID            FormSetTitle;\r
   EFI_STRING_ID            Help;\r
+  UINT8                    Flags;\r
+  EFI_GUID                 ClassGuid[1];\r
 } EFI_IFR_FORM_SET;\r
 \r
+#define EFI_HII_PLATFORM_SETUP_FORMSET_GUID \\r
+  { 0x93039971, 0x8545, 0x4b04, { 0xb4, 0x5e, 0x32, 0xeb, 0x83, 0x26, 0x4, 0xe } }\r
+\r
 typedef struct _EFI_IFR_END {\r
   EFI_IFR_OP_HEADER        Header;\r
 } EFI_IFR_END;\r
@@ -805,7 +811,7 @@ typedef struct _EFI_IFR_REF4 {
 \r
 typedef struct _EFI_IFR_RESET_BUTTON {\r
   EFI_IFR_OP_HEADER        Header;\r
-  EFI_IFR_QUESTION_HEADER  Question;\r
+  EFI_IFR_STATEMENT_HEADER Statement;\r
   EFI_DEFAULT_ID           DefaultId;\r
 } EFI_IFR_RESET_BUTTON;\r
 \r
@@ -1273,7 +1279,7 @@ typedef enum {
   EfiKeyB8,\r
   EfiKeyB9,\r
   EfiKeyB10,\r
-  EfiKeyRshift,\r
+  EfiKeyRShift,\r
   EfiKeyUpArrow,\r
   EfiKeyOne,\r
   EfiKeyTwo,\r
@@ -1396,16 +1402,16 @@ typedef struct {
   // EFI_HII_KEYBOARD_LAYOUT Layout[];\r
 } EFI_HII_KEYBOARD_PACKAGE_HDR;\r
 \r
-typedef struct {\r
-  CHAR16                  Language[3];\r
-  CHAR16                  Space;\r
-  CHAR16                  DescriptionString[1];\r
-} EFI_DESCRIPTION_STRING;\r
+//typedef struct {\r
+//  CHAR16                  Language[];           // RFC4646 Language Code\r
+//  CHAR16                  Space;\r
+//  CHAR16                  DescriptionString[];\r
+//} EFI_DESCRIPTION_STRING;\r
 \r
-typedef struct {\r
-  UINT16                  DescriptionCount;\r
-  EFI_DESCRIPTION_STRING  DescriptionString[1];\r
-} EFI_DESCRIPTION_STRING_BUNDLE;\r
+//typedef struct {\r
+//  UINT16                  DescriptionCount;\r
+//  EFI_DESCRIPTION_STRING  DescriptionString[];\r
+//} EFI_DESCRIPTION_STRING_BUNDLE;\r
 \r
 //\r
 // Modifier values\r
@@ -1425,7 +1431,7 @@ typedef struct {
 #define EFI_LEFT_SHIFT_MODIFIER          0x000C\r
 #define EFI_RIGHT_SHIFT_MODIFIER         0x000D\r
 #define EFI_CAPS_LOCK_MODIFIER           0x000E\r
-#define EFI_NUM_LOCK _MODIFIER           0x000F\r
+#define EFI_NUM_LOCK_MODIFIER            0x000F\r
 #define EFI_LEFT_ARROW_MODIFIER          0x0010\r
 #define EFI_RIGHT_ARROW_MODIFIER         0x0011\r
 #define EFI_DOWN_ARROW_MODIFIER          0x0012\r
@@ -1458,6 +1464,10 @@ typedef struct {
 #define EFI_PAUSE_MODIFIER               0x0025\r
 #define EFI_BREAK_MODIFIER               0x0026\r
 \r
+#define EFI_LEFT_LOGO_MODIFIER           0x0027\r
+#define EFI_RIGHT_LOGO_MODIFIER          0x0028\r
+#define EFI_MENU_MODIFIER                0x0029\r
+\r
 #pragma pack()\r
 \r
 #endif\r
index fa6dc424c3b482e1729a12b723a774d27f5fc8a2..90f7b75b478c5e41c1fef641fed289f01d3c211f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -622,6 +622,48 @@ typedef struct {
   //\r
 } EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;\r
 \r
+//\r
+// Resource Format\r
+//\r
+typedef struct {\r
+  UINT32  Characteristics;\r
+  UINT32  TimeDateStamp;\r
+  UINT16  MajorVersion;\r
+  UINT16  MinorVersion;\r
+  UINT16  NumberOfNamedEntries;\r
+  UINT16  NumberOfIdEntries;\r
+//  EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];\r
+} EFI_IMAGE_RESOURCE_DIRECTORY;\r
+\r
+typedef struct {\r
+  union {\r
+    struct {\r
+      UINT32  NameOffset:31;\r
+      UINT32  NameIsString:1;\r
+    } s;\r
+    UINT32  Id;\r
+  } u1;\r
+  union {\r
+    UINT32  OffsetToData;\r
+    struct {\r
+      UINT32  OffsetToDirectory:31;\r
+      UINT32  DataIsDirectory:1;\r
+    } s;\r
+  } u2;\r
+} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;\r
+\r
+typedef struct {\r
+  UINT16  Length;\r
+  CHAR16  String[1];\r
+} EFI_IMAGE_RESOURCE_DIRECTORY_STRING;\r
+\r
+typedef struct {\r
+  UINT32  OffsetToData;\r
+  UINT32  Size;\r
+  UINT32  CodePage;\r
+  UINT32  Reserved;\r
+} EFI_IMAGE_RESOURCE_DATA_ENTRY;\r
+\r
 //\r
 // Header format for TE images\r
 //\r
index 3fba60ff5d156607d589b2e4ed11c7d29be6c531..5de817e09168f2e2f402bb41c607a88d9b2ce860 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -90,11 +90,11 @@ typedef UINT64 EFI_LBA;
 // EFI Constants. They may exist in other build structures, so #ifndef them.\r
 //\r
 #ifndef TRUE\r
-#define TRUE  ((BOOLEAN) 1 == 1)\r
+#define TRUE  ((BOOLEAN) (1 == 1))\r
 #endif\r
 \r
 #ifndef FALSE\r
-#define FALSE ((BOOLEAN) 0 == 1)\r
+#define FALSE ((BOOLEAN) (0 == 1))\r
 #endif\r
 \r
 #ifndef NULL\r
index ac914f7508c5cde44143e1caf0a2f99f236a6181..0767b8a4a1c1e7b3f9b8d2e3f748361c62512396 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -185,9 +185,16 @@ typedef struct {
   UINT32  IoAlign;\r
 \r
   EFI_LBA LastBlock;\r
+\r
+  EFI_LBA LowestAlignedLba;\r
+  UINT32  LogicalBlocksPerPhysicalBlock;\r
 } EFI_BLOCK_IO_MEDIA;\r
 \r
-#define EFI_BLOCK_IO_PROTOCOL_REVISION  0x00010000\r
+#define EFI_BLOCK_IO_PROTOCOL_REVISION     0x00010000\r
+#define EFI_BLOCK_IO_PROTOCOL_REVISION2    0x00020001\r
+\r
+#define SIZE_OF_EFI_BLOCK_IO_MEDIA_REV1  ((UINTN)&((EFI_BLOCK_IO_MEDIA *)0)->LastBlock + sizeof(EFI_LBA))\r
+#define SIZE_OF_EFI_BLOCK_IO_MEDIA_REV2  sizeof(EFI_BLOCK_IO_MEDIA)\r
 \r
 struct _EFI_BLOCK_IO_PROTOCOL {\r
   UINT64              Revision;\r
index 6a3a42bd9df8d2fc2de57ffa984760429c6f0c57..19c6d5a09d2f2ae97acdef18064bceb2026b2d9e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -50,12 +50,13 @@ EFI_STATUS
     Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
 \r
   Arguments:\r
-    This       - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
-    Language   - A pointer to a three character ISO 639-2 language identifier.\r
-                 This is the language of the driver name that that the caller \r
-                 is requesting, and it must match one of the languages specified\r
-                 in SupportedLanguages.  The number of languages supported by a \r
-                 driver is up to the driver writer.\r
+    This       - A pointer to the EFI_COMPONENT_NAME2_PROTOCOL instance.\r
+    Language   - A pointer to a Null-terminated ASCII string array indicating the \r
+                 language.  This is the language of the driver name that the caller \r
+                 is requesting, and it must match one of the languages specified in \r
+                 SupportedLanguages. The number of languages supported by a \r
+                 driver is up to the driver writer.  Language is specified in RFC \r
+                 4646 language code format.\r
     DriverName - A pointer to the Unicode string to return.  This Unicode string\r
                  is the name of the driver specified by This in the language \r
                  specified by Language.\r
@@ -86,7 +87,7 @@ EFI_STATUS
     that is being managed by an EFI Driver.\r
 \r
   Arguments:\r
-    This             - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
+    This             - A pointer to the EFI_COMPONENT_NAME2_PROTOCOL instance.\r
     ControllerHandle - The handle of a controller that the driver specified by \r
                        This is managing.  This handle specifies the controller \r
                        whose name is to be returned.\r
@@ -96,12 +97,12 @@ EFI_STATUS
                        for a bus drivers that wish to retrieve the name of the \r
                        bus controller.  It will not be NULL for a bus driver \r
                        that wishes to retrieve the name of a child controller.\r
-    Language         - A pointer to a three character ISO 639-2 languag\r
-                       identifier.  This is the language of the controller name \r
-                       that that the caller is requesting, and it must match one\r
-                       of the languages specified in SupportedLanguages.  The \r
-                       number of languages supported by a driver is up to the \r
-                       driver writer.\r
+    Language         - A pointer to a Null-terminated ASCII string array indicating th\r
+                       language.  This is the language of the driver name that the caller \r
+                       is requesting, and it must match one of the languages specified in \r
+                       SupportedLanguages. The number of languages supported by a \r
+                       driver is up to the driver writer.  Language is specified in RFC \r
+                       4646 language code format.\r
     ControllerName   - A pointer to the Unicode string to return.  This Unicode\r
                        string is the name of the controller specified by \r
                        ControllerHandle and ChildHandle in the language specified\r
index 854efb354e956230770017b3415d4de9219a79b2..e99e26de272450a5af174a949ba6fbc783ae33ed 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2004 - 2010, 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
@@ -117,6 +117,8 @@ COMPONENT_TYPE=   LIBRARY
   HiiFont/HiiFont.c\r
   HiiImage/HiiImage.h\r
   HiiImage/HiiImage.c\r
+  HiiPackageList/HiiPackageList.h\r
+  HiiPackageList/HiiPackageList.c\r
   HiiString/HiiString.h\r
   HiiString/HiiString.c  \r
   Ip4/Ip4.h\r
index 8cb526613eebb688fd757046ff88ca1e19fc60ff..b319aae973d13795fea8346485bd82be272ae310 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -138,8 +138,7 @@ EFI_STATUS
   Returns:\r
     EFI_SUCCESS            - The data associated with the Handle was removed from \r
                              the HII database.\r
-    EFI_NOT_FOUND          - The specified PackageList could not be found in database.\r
-    EFI_INVALID_PARAMETER  - The Handle was not valid.\r
+    EFI_NOT_FOUND          - The specified Handle is not in database.\r
      \r
 --*/\r
 ;\r
@@ -166,8 +165,8 @@ EFI_STATUS
   Returns:\r
     EFI_SUCCESS            - The HII database was successfully updated.\r
     EFI_OUT_OF_RESOURCES   - Unable to allocate enough memory for the updated database.\r
-    EFI_INVALID_PARAMETER  - Handle or PackageList was NULL.\r
-    EFI_NOT_FOUND          - The Handle was not valid or could not be found in database.\r
+    EFI_INVALID_PARAMETER  - PackageList was NULL.\r
+    EFI_NOT_FOUND          - The specified Handle is not in database.\r
      \r
 --*/\r
 ;\r
@@ -203,12 +202,16 @@ EFI_STATUS
         \r
   Returns:\r
     EFI_SUCCESS            - The matching handles are outputed successfully.\r
+                             HandleBufferLength is updated with the actual length.\r
     EFI_BUFFER_TO_SMALL    - The HandleBufferLength parameter indicates that\r
                              Handle is too small to support the number of handles.\r
                              HandleBufferLength is updated with a value that will \r
                              enable the data to fit.\r
     EFI_NOT_FOUND          - No matching handle could not be found in database.\r
     EFI_INVALID_PARAMETER  - Handle or HandleBufferLength was NULL.\r
+    EFI_INVALID_PARAMETER  - PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but\r
+                             PackageGuid is not NULL, PackageType is a EFI_HII_\r
+                             PACKAGE_TYPE_GUID but PackageGuid is NULL.\r
      \r
 --*/  \r
 ;\r
@@ -312,7 +315,8 @@ EFI_STATUS
                          \r
   Returns:\r
     EFI_SUCCESS            - Notification is unregistered successfully.    \r
-    EFI_INVALID_PARAMETER  - The Handle is invalid.\r
+    EFI_NOT_FOUND          - The incoming notification handle does not exist \r
+                             in current hii database.\r
      \r
 --*/  \r
 ;  \r
index 36f5a872eb6f83f7424b3795aae5b48a0d9413a3..46c922cf123b6c2a8ac0525654724e01624e30a5 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -53,9 +53,9 @@ typedef struct _EFI_HII_ROW_INFO {
 } EFI_HII_ROW_INFO;\r
 \r
 typedef struct {\r
-  UINT32 FontStyle;\r
-  UINT16 FontSize; // character cell size in pixels\r
-  CHAR16 FontName[1];\r
+  EFI_HII_FONT_STYLE FontStyle;\r
+  UINT16             FontSize; // character cell height in pixels\r
+  CHAR16             FontName[1];\r
 } EFI_FONT_INFO;\r
 \r
 typedef struct _EFI_FONT_DISPLAY_INFO {\r
@@ -65,25 +65,25 @@ typedef struct _EFI_FONT_DISPLAY_INFO {
   EFI_FONT_INFO                 FontInfo;  \r
 } EFI_FONT_DISPLAY_INFO;\r
 \r
-#define EFI_HII_OUT_FLAG_CLIP        0x00000001\r
-#define EFI_HII_OUT_FLAG_WRAP        0x00000002\r
-#define EFI_HII_OUT_FLAG_CLEAN_Y     0x00000004\r
-#define EFI_HII_OUT_FLAG_CLEAN_X     0x00000008\r
-#define EFI_HII_OUT_FLAG_TRANSPARENT 0x00000010\r
-#define EFI_HII_IGNORE_IF_NO_GLYPH   0x00000020\r
-#define EFI_HII_IGNORE_LINE_BREAK    0x00000040\r
-#define EFI_HII_DIRECT_TO_SCREEN     0x00000080\r
-\r
-#define EFI_FONT_INFO_SYS_FONT       0x00000001\r
-#define EFI_FONT_INFO_SYS_SIZE       0x00000002\r
-#define EFI_FONT_INFO_SYS_STYLE      0x00000004\r
-#define EFI_FONT_INFO_SYS_FORE_COLOR 0x00000010\r
-#define EFI_FONT_INFO_SYS_BACK_COLOR 0x00000020\r
-#define EFI_FONT_INFO_RESIZE         0x00001000\r
-#define EFI_FONT_INFO_RESTYLE        0x00002000\r
-#define EFI_FONT_INFO_ANY_FONT       0x00010000\r
-#define EFI_FONT_INFO_ANY_SIZE       0x00020000\r
-#define EFI_FONT_INFO_ANY_STYLE      0x00040000\r
+#define EFI_HII_OUT_FLAG_CLIP         0x00000001\r
+#define EFI_HII_OUT_FLAG_WRAP         0x00000002\r
+#define EFI_HII_OUT_FLAG_CLIP_CLEAN_Y 0x00000004\r
+#define EFI_HII_OUT_FLAG_CLIP_CLEAN_X 0x00000008\r
+#define EFI_HII_OUT_FLAG_TRANSPARENT  0x00000010\r
+#define EFI_HII_IGNORE_IF_NO_GLYPH    0x00000020\r
+#define EFI_HII_IGNORE_LINE_BREAK     0x00000040\r
+#define EFI_HII_DIRECT_TO_SCREEN      0x00000080\r
+\r
+#define EFI_FONT_INFO_SYS_FONT        0x00000001\r
+#define EFI_FONT_INFO_SYS_SIZE        0x00000002\r
+#define EFI_FONT_INFO_SYS_STYLE       0x00000004\r
+#define EFI_FONT_INFO_SYS_FORE_COLOR  0x00000010\r
+#define EFI_FONT_INFO_SYS_BACK_COLOR  0x00000020\r
+#define EFI_FONT_INFO_RESIZE          0x00001000\r
+#define EFI_FONT_INFO_RESTYLE         0x00002000\r
+#define EFI_FONT_INFO_ANY_FONT        0x00010000\r
+#define EFI_FONT_INFO_ANY_SIZE        0x00020000\r
+#define EFI_FONT_INFO_ANY_STYLE       0x00040000\r
 \r
 typedef\r
 EFI_STATUS\r
@@ -109,7 +109,7 @@ EFI_STATUS
     Flags             - Describes how the string is to be drawn.                 \r
     String            - Points to the null-terminated string to be displayed.\r
     StringInfo        - Points to the string output information, including the color and font. \r
-                        If NULL, then the string will be output in the default system font and color.                             \r
+                        If NULL, then the string will be output in the default system font and color.\r
     Blt               - If this points to a non-NULL on entry, this points to the image, which is Width pixels  \r
                         wide and Height pixels high. The string will be drawn onto this image and               \r
                         EFI_HII_OUT_FLAG_CLIP is implied. If this points to a NULL on entry, then a             \r
@@ -132,7 +132,8 @@ EFI_STATUS
   Returns:\r
     EFI_SUCCESS           - The string was successfully rendered.                           \r
     EFI_OUT_OF_RESOURCES  - Unable to allocate an output buffer for RowInfoArray or Blt.\r
-    EFI_INVALID_PARAMETER - The String was NULL.    \r
+    EFI_INVALID_PARAMETER - The String or Blt was NULL.\r
+    EFI_INVALID_PARAMETER - Flags were invalid combination.\r
         \r
 --*/\r
 ;\r
@@ -166,7 +167,7 @@ EFI_STATUS
     Language          - Points to the language for the retrieved string. If NULL, then the current system\r
                         language is used.                                                                \r
     StringInfo        - Points to the string output information, including the color and font. \r
-                        If NULL, then the string will be output in the default system font and color.                             \r
+                        If NULL, then the string will be output in the default system font and color.\r
     Blt               - If this points to a non-NULL on entry, this points to the image, which is Width pixels  \r
                         wide and Height pixels high. The string will be drawn onto this image and               \r
                         EFI_HII_OUT_FLAG_CLIP is implied. If this points to a NULL on entry, then a             \r
@@ -187,9 +188,12 @@ EFI_STATUS
                         is possible when character display is normalized that some character cells overlap.           \r
                      \r
   Returns:\r
-    EFI_SUCCESS           - The string was successfully rendered.                           \r
+    EFI_SUCCESS           - The string was successfully rendered.\r
     EFI_OUT_OF_RESOURCES  - Unable to allocate an output buffer for RowInfoArray or Blt.\r
-    EFI_INVALID_PARAMETER - The String was NULL.    \r
+    EFI_INVALID_PARAMETER - The Blt or PackageList was NULL.\r
+    EFI_INVALID_PARAMETER - Flags were invalid combination.\r
+    EFI_NOT_FOUND         - The specified PackageList is not in the Database or the stringid is not \r
+                            in the specified PackageList. \r
         \r
 --*/\r
 ;\r
@@ -233,7 +237,7 @@ EFI_STATUS
 (EFIAPI *EFI_HII_GET_FONT_INFO) (\r
   IN  CONST EFI_HII_FONT_PROTOCOL    *This,\r
   IN  OUT   EFI_FONT_HANDLE          *FontHandle,\r
-  IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfoIn,\r
+  IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfoIn, OPTIONAL\r
   OUT       EFI_FONT_DISPLAY_INFO    **StringInfoOut,\r
   IN  CONST EFI_STRING               String OPTIONAL\r
   )\r
@@ -246,11 +250,13 @@ EFI_STATUS
     \r
   Arguments:          \r
     This              - A pointer to the EFI_HII_FONT_PROTOCOL instance.\r
-    FontHandle        - On entry, points to the font handle returned by a \r
-                        previous call to GetFontInfo() or NULL to start with the \r
+    FontHandle        - On entry, points to the font handle returned by a previous \r
+                        call to GetFontInfo() or points to NULL to start with the \r
                         first font. On return, points to the returned font handle or\r
-                        points to NULL if there are no more matching fonts.                                               \r
-    StringInfoIn      - Upon entry, points to the font to return information about.                        \r
+                        points to NULL if there are no more matching fonts.\r
+    StringInfoIn      - Upon entry, points to the font to return information about.\r
+                        If NULL, then the information about the system default \r
+                        font will be returned.\r
     StringInfoOut     - Upon return, contains the matching font's information. \r
                         If NULL, then no information is returned.\r
                         It's caller's responsibility to free this buffer.\r
@@ -261,10 +267,10 @@ EFI_STATUS
   Returns:\r
     EFI_SUCCESS            - Matching font returned successfully.\r
     EFI_NOT_FOUND          - No matching font was found.\r
-    EFI_INVALID_PARAMETER  - StringInfoIn is NULL.\r
+    EFI_INVALID_PARAMETER  - StringInfoIn->FontInfoMask is an invalid combination.\r
     EFI_OUT_OF_RESOURCES   - There were insufficient resources to complete the request.\r
             \r
---*/     \r
+--*/\r
 ;\r
 \r
 \r
index 1eb4e6fab0626fabe1f3c9507f0fbe408d378024..0a27599e8a39d75629d5366be1f3cb02fb8d5572 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -45,7 +45,7 @@ typedef struct _EFI_IMAGE_INPUT {
   UINT32                             Flags;  \r
   UINT16                             Width;\r
   UINT16                             Height;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      Bitmap[1];\r
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *Bitmap;\r
 } EFI_IMAGE_INPUT;\r
 \r
 #define EFI_IMAGE_TRANSPARENT          0x00000001\r
@@ -101,8 +101,7 @@ EFI_STATUS
   IN  CONST EFI_HII_IMAGE_PROTOCOL   *This,\r
   IN  EFI_HII_HANDLE                 PackageList,\r
   IN  EFI_IMAGE_ID                   ImageId,\r
-  OUT EFI_IMAGE_INPUT                *Image,\r
-  OUT UINTN                          *ImageSize\r
+  OUT EFI_IMAGE_INPUT                *Image\r
   )\r
 /*++\r
 \r
@@ -115,14 +114,14 @@ EFI_STATUS
     PackageList       - Handle of the package list where this image will be searched.    \r
     ImageId           - The image's id,, which is unique within PackageList.\r
     Image             - Points to the image.\r
-    ImageSize         - On entry, points to the size of the buffer pointed to by Image, in bytes. On return,\r
-                        points to the length of the image, in bytes.                                        \r
                         \r
   Returns:\r
     EFI_SUCCESS            - The new image was returned successfully.\r
     EFI_NOT_FOUND          - The image specified by ImageId is not available.\r
-    EFI_BUFFER_TOO_SMALL   - The buffer specified by ImageSize is too small to hold the image.                                                      \r
+                             The specified PackageList is not in the database.\r
     EFI_INVALID_PARAMETER  - The Image or ImageSize was NULL.\r
+    EFI_OUT_OF_RESOURCES   - The bitmap could not be retrieved because there was not\r
+                             enough memory.\r
     \r
 --*/  \r
 ;\r
@@ -149,7 +148,8 @@ EFI_STATUS
                         \r
   Returns:\r
     EFI_SUCCESS            - The new image was updated successfully.\r
-    EFI_NOT_FOUND          - The image specified by ImageId is not in the database.    \r
+    EFI_NOT_FOUND          - The image specified by ImageId is not in the database.\r
+                             The specified PackageList is not in the database.    \r
     EFI_INVALID_PARAMETER  - The Image was NULL.\r
     \r
 --*/  \r
@@ -233,7 +233,9 @@ EFI_STATUS
   Returns:\r
     EFI_SUCCESS            - The image was successfully drawn.\r
     EFI_OUT_OF_RESOURCES   - Unable to allocate an output buffer for Blt.\r
-    EFI_INVALID_PARAMETER  - The Image was NULL.\r
+    EFI_NOT_FOUND          - The image specified by ImageId is not in the database. \r
+                             The specified PackageList is not in the database.                            \r
+    EFI_INVALID_PARAMETER  - The Blt was NULL.    \r
 \r
 --*/\r
 ;\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c
new file mode 100644 (file)
index 0000000..aa424ab
--- /dev/null
@@ -0,0 +1,27 @@
+/*++\r
+\r
+Copyright (c) 2008 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HiiPackageList.c\r
+\r
+Abstract:\r
+\r
+  EFI_HII_PACKAGE_LIST_PROTOCOL as defined in UEFI 2.1 spec.\r
+\r
+--*/\r
+\r
+#include "EfiSpec.h"\r
+#include EFI_PROTOCOL_DEFINITION (HiiPackageList)\r
+\r
+EFI_GUID  gEfiHiiPackageListProtocolGuid = EFI_HII_PACKAGE_LIST_PROTOCOL_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiHiiPackageListProtocolGuid, "HII Package List Protocol", "HII Package List 2.1 protocol");\r
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h b/EdkCompatibilityPkg/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h
new file mode 100644 (file)
index 0000000..a3d057a
--- /dev/null
@@ -0,0 +1,36 @@
+/*++\r
+\r
+Copyright (c) 2008 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HiiPackageList.h\r
+\r
+Abstract:\r
+\r
+  EFI_HII_PACKAGE_LIST_PROTOCOL as defined in UEFI 2.1 spec.\r
+\r
+--*/\r
+\r
+#ifndef _HII_PACKAGE_LIST_H_\r
+#define _HII_PACKAGE_LIST_H_\r
+\r
+#include "EfiHii.h"\r
+\r
+#define EFI_HII_PACKAGE_LIST_PROTOCOL_GUID \\r
+  { \\r
+    0x6a1ee763, 0xd47a, 0x43b4, {0xaa, 0xbe, 0xef, 0x1d, 0xe2, 0xab, 0x56, 0xfc} \\r
+  }\r
+\r
+typedef EFI_HII_PACKAGE_LIST_HEADER *    EFI_HII_PACKAGE_LIST_PROTOCOL;\r
+\r
+extern EFI_GUID gEfiHiiPackageListProtocolGuid;\r
+\r
+#endif\r
index c243d9e6802fc93d052f7f8988a9e350dc0dcc76..0c27218b38db14481eba65ad5486678eb71eadcb 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -54,6 +54,8 @@ EFI_STATUS
   Routine Description:\r
     This function adds the string String to the group of strings owned by PackageList, with the\r
     specified font information StringFontInfo and returns a new string id.                         \r
+    The new string identifier is guaranteed to be unique within the package list. \r
+    That new string identifier is reserved for all languages in the package list. \r
     \r
   Arguments:          \r
     This              - A pointer to the EFI_HII_STRING_PROTOCOL instance.\r
@@ -104,13 +106,19 @@ EFI_STATUS
     String            - Points to the new null-terminated string.            \r
     StringSize        - On entry, points to the size of the buffer pointed to by \r
                         String, in bytes. On return,\r
-                        points to the length of the string, in bytes.                                                                                             \r
-    StringFontInfo    - If not NULL, points to the string's font information. \r
-                        It's caller's responsibility to free this buffer.\r
+                        points to the length of the string, in bytes.\r
+    StringFontInfo    - Points to a buffer that will be callee allocated and will \r
+                        have the string's font information into this buffer.  \r
+                        The caller is responsible for freeing this buffer.  \r
+                        If the parameter is NULL a buffer will not be allocated \r
+                        and the string font information will not be returned.\r
 \r
   Returns:\r
     EFI_SUCCESS            - The string was returned successfully.\r
     EFI_NOT_FOUND          - The string specified by StringId is not available.\r
+                             The specified PackageList is not in the database.\r
+    EFI_INVALID_LANGUAGE   - The string specified by StringId is available but\r
+                             not in the specified language.                             \r
     EFI_BUFFER_TOO_SMALL   - The buffer specified by StringSize is too small to \r
                              hold the string.                                                      \r
     EFI_INVALID_PARAMETER  - The String or Language or StringSize was NULL.\r
@@ -147,7 +155,8 @@ EFI_STATUS
 \r
   Returns:\r
     EFI_SUCCESS            - The string was updated successfully.\r
-    EFI_NOT_FOUND          - The string specified by StringId is not in the database.    \r
+    EFI_NOT_FOUND          - The string specified by StringId is not in the database.\r
+                             The specified PackageList is not in the database.\r
     EFI_INVALID_PARAMETER  - The String or Language was NULL.\r
     EFI_OUT_OF_RESOURCES   - The system is out of resources to accomplish the task.\r
     \r
@@ -182,6 +191,7 @@ EFI_STATUS
     EFI_BUFFER_TOO_SMALL   - The LanguagesSize is too small to hold the list of \r
                              supported languages. LanguageSize is updated to\r
                              contain the required size.\r
+    EFI_NOT_FOUND          - The specified PackageList is not in the database.\r
     \r
 --*/\r
 ;\r
@@ -220,9 +230,12 @@ EFI_STATUS
     EFI_BUFFER_TOO_SMALL   - The buffer specified by SecondLanguagesSize is   \r
                              too small to hold the returned information.      \r
                              SecondLanguageSize is updated to hold the size of\r
-                             the buffer required.                             \r
-                             \r
---*/                         \r
+                             the buffer required.\r
+    EFI_INVALID_LANGUAGE   - The language specified by FirstLanguage is not\r
+                             present in the specified package list.\r
+    EFI_NOT_FOUND          - The specified PackageList is not in the Database.    \r
+    \r
+--*/\r
 ;\r
 //\r
 // Interface structure for the EFI_HII_STRING_PROTOCOL\r
index 0263bf04f4695993daec8d388d5d09bb410f9736..3e315c0bb23fcfedf5b6a03df58b8b49ba3e9740 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2010, 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
@@ -15,7 +15,7 @@ Module Name:
 \r
 Abstract:\r
 \r
-  UEFI IPv4 protocol.\r
+  EFI_IP4_PROTOCOL definition in UEFI 2.2 specification.\r
 \r
 --*/\r
 \r
@@ -80,7 +80,7 @@ typedef struct _EFI_IP4_ICMP_TYPE {
 typedef struct {\r
   BOOLEAN                 IsStarted;\r
   UINT32                  MaxPacketSize;\r
-\r
+  \r
   EFI_IP4_CONFIG_DATA     ConfigData;\r
   BOOLEAN                 IsConfigured;\r
 \r
index d9f003255960478927230d3468ad8d14cd2a8242..6abd11d5bf86d4aebb3e74509d806e4d28a641ee 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -35,6 +35,8 @@ Abstract:
 \r
 EFI_FORWARD_DECLARATION (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL);\r
 EFI_FORWARD_DECLARATION (EFI_FILE);\r
+typedef struct _EFI_FILE *EFI_FILE_HANDLE;\r
+typedef struct _EFI_FILE EFI_FILE_PROTOCOL;\r
 \r
 typedef\r
 EFI_STATUS\r
@@ -356,7 +358,7 @@ EFI_STATUS
 ;\r
 \r
 #define EFI_FILE_HANDLE_REVISION  0x00010000\r
-typedef struct _EFI_FILE {\r
+struct _EFI_FILE {\r
   UINT64                Revision;\r
   EFI_FILE_OPEN         Open;\r
   EFI_FILE_CLOSE        Close;\r
@@ -368,7 +370,7 @@ typedef struct _EFI_FILE {
   EFI_FILE_GET_INFO     GetInfo;\r
   EFI_FILE_SET_INFO     SetInfo;\r
   EFI_FILE_FLUSH        Flush;\r
-} *EFI_FILE_HANDLE;\r
+};\r
 \r
 extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;\r
 \r
index a4b83c33d9670f6afee6d15f36b590ed0e485810..482e69e114f6e8605da50b49644e85c74a562f50 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -140,7 +140,9 @@ typedef enum _EFI_MEMORY_ARRAY_TYPE {
   EfiMemoryTypeRdram                          = 0x11,\r
   EfiMemoryTypeDdr                            = 0x12,\r
   EfiMemoryTypeDdr2                           = 0x13,\r
-  EfiMemoryTypeDdr2FbDimm                     = 0x14\r
+  EfiMemoryTypeDdr2FbDimm                     = 0x14,\r
+  EfiMemoryTypeDdr3                           = 0x18,\r
+  EfiMemoryTypeFbd2                           = 0x19\r
 } EFI_MEMORY_ARRAY_TYPE;\r
 \r
 typedef struct {\r
@@ -189,6 +191,8 @@ typedef struct {
   UINT16                      MemorySpeed;\r
   EFI_MEMORY_STATE            MemoryState;\r
   UINT8                       MemoryAttributes;\r
+  UINT8                       MemoryBankConnections;\r
+  UINT8                       MemoryErrorStatus;\r
 } EFI_MEMORY_ARRAY_LINK;\r
 \r
 \r
@@ -304,11 +308,15 @@ typedef struct {
 \r
 typedef struct {\r
   UINT8  Five                  :1;\r
-  UINT8  There                 :1;\r
+  UINT8  Three                 :1;\r
   UINT8  Two                   :1;\r
   UINT8  Reserved              :5;\r
 } EFI_MEMORY_MODULE_VOLTAGE_TYPE;\r
 \r
+//\r
+//  EFI_MEMORY_CONTROLLER_INFORMATION is obsolete\r
+//  Use EFI_MEMORY_CONTROLLER_INFORMATION_DATA instead\r
+//\r
 typedef struct {\r
   EFI_MEMORY_ERROR_DETECT_METHOD_TYPE   ErrorDetectingMethod;\r
   EFI_MEMORY_ERROR_CORRECT_CAPABILITY   ErrorCorrectingCapability;\r
@@ -323,6 +331,20 @@ typedef struct {
   UINT16                                *MemoryModuleConfigHandles;\r
 } EFI_MEMORY_CONTROLLER_INFORMATION;\r
 \r
+typedef struct {\r
+  EFI_MEMORY_ERROR_DETECT_METHOD_TYPE   ErrorDetectingMethod;\r
+  EFI_MEMORY_ERROR_CORRECT_CAPABILITY   ErrorCorrectingCapability;\r
+  EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE    MemorySupportedInterleave;\r
+  EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE    MemoryCurrentInterleave;\r
+  UINT8                                 MaxMemoryModuleSize;\r
+  EFI_MEMORY_SPEED_TYPE                 MemorySpeedType;\r
+  EFI_MEMORY_SUPPORTED_TYPE             MemorySupportedType;\r
+  EFI_MEMORY_MODULE_VOLTAGE_TYPE        MemoryModuleVoltage;\r
+  UINT8                                 NumberofMemorySlot;\r
+  EFI_MEMORY_ERROR_CORRECT_CAPABILITY   EnabledCorrectingCapability;\r
+  EFI_INTER_LINK_DATA                   MemoryModuleConfig[1];\r
+} EFI_MEMORY_CONTROLLER_INFORMATION_DATA;\r
+\r
 //\r
 //  Memory. Error Information - SMBIOS Type 18\r
 //\r
index 56124059a67df3319c94edc0db97dcd9f00d975e..d7545afc8bbcb3857fd77c0057a5f20bee2adb5f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
  \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -261,6 +261,7 @@ typedef enum {
 \r
 typedef struct {\r
   UINT32  RecordType  :1;\r
+  UINT32  Type        :7;\r
   UINT32  Reserved    :24;\r
 } EFI_MISC_ELEMENT_TYPE;\r
 \r
@@ -417,7 +418,7 @@ typedef enum {
   EfiSlotTypeApg2X = 0x10,\r
   EfiSlotTypeAgp4X = 0x11,\r
   EfiSlotTypePciX = 0x12,\r
-  EfiSlotTypeAgp4x = 0x13,\r
+  EfiSlotTypeAgp8X = 0x13,\r
   EfiSlotTypePC98C20 = 0xA0,\r
   EfiSlotTypePC98C24 = 0xA1,\r
   EfiSlotTypePC98E = 0xA2,\r
@@ -428,7 +429,13 @@ typedef enum {
   EfiSlotTypePciExpressX2 = 0xA7,\r
   EfiSlotTypePciExpressX4 = 0xA8,\r
   EfiSlotTypePciExpressX8 = 0xA9,\r
-  EfiSlotTypePciExpressX16 = 0xAA\r
+  EfiSlotTypePciExpressX16 = 0xAA,\r
+  EfiSlotTypePciExpressGen2    = 0xAB,\r
+  EfiSlotTypePciExpressGen2X1  = 0xAC,\r
+  EfiSlotTypePciExpressGen2X2  = 0xAD,\r
+  EfiSlotTypePciExpressGen2X4  = 0xAE,\r
+  EfiSlotTypePciExpressGen2X8  = 0xAF,\r
+  EfiSlotTypePciExpressGen2X16 = 0xB0\r
 } EFI_MISC_SLOT_TYPE;\r
 \r
 typedef enum {  \r
@@ -595,6 +602,7 @@ typedef struct {
   EFI_INTER_LINK_DATA GroupLink;\r
   UINT16              GroupId;\r
   UINT16              GroupElementId;\r
+  UINT8               ItemType;\r
 } EFI_MISC_GROUP_ITEM_SET_DATA;\r
 \r
 //\r
@@ -711,7 +719,12 @@ typedef struct {
 //\r
 // Misc. Hardware Security - SMBIOS Type 24\r
 //\r
-#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER 0x00000012\r
+#define EFI_MISC_HARDWARE_SECURITY_RECORD_NUMBER 0x00000012\r
+\r
+//\r
+// Backward Compatibility\r
+//\r
+#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER  EFI_MISC_HARDWARE_SECURITY_RECORD_NUMBER\r
 \r
 typedef enum {\r
   EfiHardwareSecurityStatusDisabled = 0,\r
@@ -966,6 +979,7 @@ typedef struct {
   EFI_INTER_LINK_DATA   ManagementDeviceLink;\r
   EFI_INTER_LINK_DATA   ManagementDeviceComponentLink;\r
   EFI_INTER_LINK_DATA   ManagementDeviceThresholdLink;\r
+  UINT8                 ComponentType;\r
 } EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION;\r
 \r
 //\r
@@ -1013,7 +1027,7 @@ typedef struct {
 } POWER_SUPPLY_CHARACTERISTICS;\r
 \r
 typedef struct {\r
-  UINT                          PowerUnitGroup;\r
+  UINT16                          PowerUnitGroup;\r
   STRING_REF                      PowerSupplyLocation;\r
   STRING_REF                      PowerSupplyDeviceName;\r
   STRING_REF                      PowerSupplyManufacturer;\r
@@ -1098,18 +1112,62 @@ typedef struct {
 //  Misc. System Event Log  - SMBIOS Type 15\r
 //\r
 #define EFI_MISC_SYSTEM_EVENT_LOG_RECORD_NUMBER 0x00000020\r
+\r
+typedef enum {  \r
+  EfiEventLogTypeReserved1                          = 0,\r
+  EfiEventLogTypeSingleBitEccMemoryError            = 1,\r
+  EfiEventLogTypeMultiBitEccMemoryError             = 2,\r
+  EfiEventLogTypeParityMemoryError                  = 3,\r
+  EfiEventLogTypeBusTimeOut                         = 4,\r
+  EfiEventLogTypeIoChannelCheck                     = 5,\r
+  EfiEventLogTypeSoftwareNmi                        = 6,\r
+  EfiEventLogTypePostMemoryResize                   = 7,\r
+  EfiEventLogTypePostError                          = 8,\r
+  EfiEventLogTypePciParityError                     = 9,\r
+  EfiEventLogTypePciSystemError                     = 0xA,\r
+  EfiEventLogTypeCpuFailure                         = 0xB,\r
+  EfiEventLogTypeEisaFailSafeTimerTimeOut           = 0xC,\r
+  EfiEventLogTypeCorrectableMemoryLogDisabled       = 0xD,\r
+  EfiEventLogTypeLoggingDisabled                    = 0xE,\r
+  EfiEventLogTypeReserved2                          = 0xF,\r
+  EfiEventLogTypeSystemLimitExceeded                = 0x10,\r
+  EfiEventLogTypeAsynchronousHardwareTimerExpired   = 0x11,\r
+  EfiEventLogTypeSystemConfigurationInformation     = 0x12,\r
+  EfiEventLogTypeHardDiskInformation                = 0x13,\r
+  EfiEventLogTypeSystemReconfigured                 = 0x14,\r
+  EfiEventLogTypeUncorrectableCpuComplexError       = 0x15,\r
+  EfiEventLogTypeLogAreaResetCleared                = 0x16,\r
+  EfiEventLogTypeSystemBoot                         = 0x17,\r
+  EfiEventLogTypeEndOfLog                           = 0xFF\r
+} EFI_MISC_LOG_TYPE;\r
+\r
+typedef enum {  \r
+  EfiEventLogDataFormatTypeNone = 0,\r
+  EfiEventLogDataFormatTypeHandle = 1,\r
+  EfiEventLogDataFormatTypeMultipleEvent = 2,\r
+  EfiEventLogDataFormatTypeMultipleEventHandle = 3,\r
+  EfiEventLogDataFormatTypePostResultsBitmap = 4,\r
+  EfiEventLogDataFormatTypeSystemManagement = 5,\r
+  EfiEventLogDataFormatTypeMultipleEventSystemManagement = 6\r
+} EFI_MISC_VARIABLE_DATA_FORMAT_TYPE;\r
+\r
+typedef struct {\r
+  UINT8                 LogType;\r
+  UINT8                 DataFormatType;\r
+} EFI_MISC_EVENT_LOG_TYPE;\r
+\r
 typedef struct {\r
-  //SMBIOS_STRUCTURE_HDR  Header;\r
-  UINT16                LogAreaLength;\r
-  UINT16                LogHeaderStartOffset;\r
-  UINT16                LogDataStartOffset;\r
-  UINT8                 AccessMethod;\r
-  UINT8                 LogStatus;\r
-  UINT32                LogChangeToken;\r
-  UINT32                AccessMethodAddress;\r
-  UINT8                 LogHeaderFormat;\r
-  UINT8                 NumberOfSupportedLogType;\r
-  UINT8                 LengthOfLogDescriptor;\r
+  UINT16                    LogAreaLength;\r
+  UINT16                    LogHeaderStartOffset;\r
+  UINT16                    LogDataStartOffset;\r
+  UINT8                     AccessMethod;\r
+  UINT8                     LogStatus;\r
+  UINT32                    LogChangeToken;\r
+  UINT32                    AccessMethodAddress;\r
+  UINT8                     LogHeaderFormat;\r
+  UINT8                     NumberOfSupportedLogType;\r
+  UINT8                     LengthOfLogDescriptor;\r
+  EFI_PHYSICAL_ADDRESS      EventLogTypeDescriptors; // Pointer to EFI_MISC_EVENT_LOG_TYPE\r
 } EFI_MISC_SYSTEM_EVENT_LOG;\r
 \r
 //\r
index fc094b7b9cbcec66c79a10aab4a542272a6ab863..f55bd30830ff250bb9a501985680d5ff2aebf816 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -49,6 +49,7 @@ typedef STRING_REF            EFI_PROCESSOR_MANUFACTURER_DATA;
 typedef STRING_REF            EFI_PROCESSOR_SERIAL_NUMBER_DATA;\r
 \r
 typedef STRING_REF            EFI_PROCESSOR_ASSET_TAG_DATA;\r
+\r
 typedef STRING_REF            EFI_PROCESSOR_PART_NUMBER_DATA;\r
 \r
 typedef struct {\r
@@ -159,6 +160,10 @@ typedef enum {
   EfiProcessorFamilyPowerPC620   = 0x25,\r
   EfiProcessorFamilyPowerPC704   = 0x26,\r
   EfiProcessorFamilyPowerPC750   = 0x27,\r
+  EfiProcessorFamilyIntelCoreDuo = 0x28,\r
+  EfiProcessorFamilyIntelCoreDuoMobile = 0x29,\r
+  EfiProcessorFamilyIntelCoreSoloMobile = 0x2A,\r
+  EfiProcessorFamilyIntelAtom    = 0x2B,\r
   EfiProcessorFamilyAlpha2       = 0x30,\r
   EfiProcessorFamilyAlpha21064   = 0x31,\r
   EfiProcessorFamilyAlpha21066   = 0x32,\r
@@ -201,6 +206,12 @@ typedef enum {
   EfiProcessorFamilyDualCoreAmdOpteron = 0x87,\r
   EfiProcessorFamilyAmdAthlon64X2DualCore = 0x88,\r
   EfiProcessorFamilyAmdTurion64X2Mobile   = 0x89,\r
+  EfiProcessorFamilyQuadCoreAmdOpteron = 0x8A,\r
+  EfiProcessorFamilyThirdGenerationAmdOpteron = 0x8B,\r
+  EfiProcessorFamilyAmdPhenomFxQuadCore = 0x8C,\r
+  EfiProcessorFamilyAmdPhenomX4QuadCore = 0x8D,\r
+  EfiProcessorFamilyAmdPhenomX2DualCore = 0x8E,\r
+  EfiProcessorFamilyAmdAthlonX2DualCore = 0x8F,\r
   EfiProcessorFamilyPARISC       = 0x90,\r
   EfiProcessorFamilyPaRisc8500   = 0x91,\r
   EfiProcessorFamilyPaRisc8000   = 0x92,\r
@@ -209,6 +220,21 @@ typedef enum {
   EfiProcessorFamilyPaRisc7100LC = 0x95,\r
   EfiProcessorFamilyPaRisc7100   = 0x96,\r
   EfiProcessorFamilyV30          = 0xA0,\r
+  EfiProcessorFamilyQuadCoreIntelXeon3200Series  = 0xA1,\r
+  EfiProcessorFamilyDualCoreIntelXeon3000Series  = 0xA2,\r
+  EfiProcessorFamilyQuadCoreIntelXeon5300Series  = 0xA3,\r
+  EfiProcessorFamilyDualCoreIntelXeon5100Series  = 0xA4,\r
+  EfiProcessorFamilyDualCoreIntelXeon5000Series  = 0xA5,\r
+  EfiProcessorFamilyDualCoreIntelXeonLV          = 0xA6,\r
+  EfiProcessorFamilyDualCoreIntelXeonULV         = 0xA7,\r
+  EfiProcessorFamilyDualCoreIntelXeon7100Series  = 0xA8,\r
+  EfiProcessorFamilyQuadCoreIntelXeon5400Series  = 0xA9,\r
+  EfiProcessorFamilyQuadCoreIntelXeon            = 0xAA,\r
+  EfiProcessorFamilyDualCoreIntelXeon5200Series  = 0xAB,\r
+  EfiProcessorFamilyDualCoreIntelXeon7200Series  = 0xAC,\r
+  EfiProcessorFamilyQuadCoreIntelXeon7300Series  = 0xAD,\r
+  EfiProcessorFamilyQuadCoreIntelXeon7400Series  = 0xAE,\r
+  EfiProcessorFamilyMultiCoreIntelXeon7400Series = 0xAF,\r
   EfiProcessorFamilyPentiumIIIXeon = 0xB0,\r
   EfiProcessorFamilyPentiumIIISpeedStep = 0xB1,\r
   EfiProcessorFamilyPentium4     = 0xB2,\r
@@ -222,9 +248,17 @@ typedef enum {
   EfiProcessorFamilyIntelCeleronD = 0xBA,\r
   EfiProcessorFamilyIntelPentiumD = 0xBB,\r
   EfiProcessorFamilyIntelPentiumEx = 0xBC,\r
-  EfiProcessorFamilyIntelCoreBrand = 0xBD,\r
+  EfiProcessorFamilyIntelCoreSolo  = 0xBD,  // SMBIOS spec 2.6 correct this value\r
   EfiProcessorFamilyReserved       = 0xBE,\r
   EfiProcessorFamilyIntelCore2     = 0xBF,\r
+  EfiProcessorFamilyIntelCore2Solo          = 0xC0,\r
+  EfiProcessorFamilyIntelCore2Extreme       = 0xC1,\r
+  EfiProcessorFamilyIntelCore2Quad          = 0xC2,\r
+  EfiProcessorFamilyIntelCore2ExtremeMobile = 0xC3,\r
+  EfiProcessorFamilyIntelCore2DuoMobile     = 0xC4,\r
+  EfiProcessorFamilyIntelCore2SoloMobile    = 0xC5,\r
+  EfiProcessorFamilyIntelCoreI7             = 0xC6,\r
+  EfiProcessorFamilyDualCoreIntelCeleron    = 0xC7,\r
   EfiProcessorFamilyIBM390       = 0xC8,\r
   EfiProcessorFamilyG4           = 0xC9,\r
   EfiProcessorFamilyG5           = 0xCA,\r
@@ -234,6 +268,20 @@ typedef enum {
   EfiProcessorFamilyViaC7D      = 0xD3,\r
   EfiProcessorFamilyViaC7       = 0xD4,\r
   EfiProcessorFamilyViaEden     = 0xD5,\r
+  EfiProcessorFamilyMultiCoreIntelXeon           = 0xD6,\r
+  EfiProcessorFamilyDualCoreIntelXeon3Series     = 0xD7,\r
+  EfiProcessorFamilyQuadCoreIntelXeon3Series     = 0xD8,\r
+  EfiProcessorFamilyDualCoreIntelXeon5Series     = 0xDA,\r
+  EfiProcessorFamilyQuadCoreIntelXeon5Series     = 0xDB,\r
+  EfiProcessorFamilyDualCoreIntelXeon7Series     = 0xDD,\r
+  EfiProcessorFamilyQuadCoreIntelXeon7Series     = 0xDE,\r
+  EfiProcessorFamilyMultiCoreIntelXeon7Series    = 0xDF,\r
+  EfiProcessorFamilyEmbeddedAmdOpteronQuadCore   = 0xE6,\r
+  EfiProcessorFamilyAmdPhenomTripleCore          = 0xE7,\r
+  EfiProcessorFamilyAmdTurionUltraDualCoreMobile = 0xE8,\r
+  EfiProcessorFamilyAmdTurionDualCoreMobile      = 0xE9,\r
+  EfiProcessorFamilyAmdAthlonDualCore            = 0xEA,\r
+  EfiProcessorFamilyAmdSempronSI                 = 0xEB,\r
   EfiProcessorFamilyi860         = 0xFA,\r
   EfiProcessorFamilyi960         = 0xFB,\r
   EfiProcessorFamilyIndicatorFamily2    = 0xFE\r
@@ -314,7 +362,8 @@ typedef enum {
   EfiProcessorSocketLGA775 = 0x15,\r
   EfiProcessorSocketS1 = 0x16,\r
   EfiProcessorSocketAm2 = 0x17,\r
-  EfiProcessorSocketF   = 0x18\r
+  EfiProcessorSocketF   = 0x18,\r
+  EfiProcessorSocketLGA1366 = 0x19\r
 } EFI_PROCESSOR_SOCKET_TYPE_DATA;\r
 \r
 typedef STRING_REF EFI_PROCESSOR_SOCKET_NAME_DATA;\r
index f2e996a794d37e59f98305c8b7675c2ae8d3aa25..cae8aec1619e771cc7349e57fe935f041df096ee 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -59,6 +59,11 @@ typedef struct {
   VOID*    CapsulePtr[1];\r
 } EFI_CAPSULE_TABLE;\r
 \r
+//\r
+// This struct is deprecated because VendorTable entries physical address will not be fixed up when \r
+// transitioning from preboot to runtime phase. So we don't need CapsuleInfoTable to record capsule\r
+// GUIDs any more for runtime convert.\r
+//\r
 typedef struct {\r
   UINT32      CapsuleGuidNumber;\r
   EFI_GUID    CapsuleGuidPtr[1];\r
@@ -66,6 +71,7 @@ typedef struct {
 \r
 //\r
 // This GUID is used for collecting all capsules' Guids who install in ConfigTable.\r
+// This GUID is deprecated as well.\r
 //\r
 #define EFI_CAPSULE_INFO_GUID \\r
   { \\r
index c5c180d3376a50598699712dacc3651031771234..1db788670f548c622bc34049b1c6532e1342be28 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -50,11 +50,10 @@ typedef enum {
 } EFI_PEI_PCI_CFG_PPI_WIDTH;\r
 \r
 #define EFI_PEI_PCI_CFG_ADDRESS(bus, dev, func, reg)   \\r
-            (   ((bus) << 24)  | \\r
-                ((dev) << 16)  | \\r
-                ((func) << 8)  | \\r
-                ((reg) < 256 ? (reg): ((UINT64)(reg) << 32))) \r
-\r
+      (UINT64) ((((UINTN) (bus)) << 24) | \\r
+                (((UINTN) (dev)) << 16) | \\r
+                (((UINTN) (func)) << 8) | \\r
+                ((reg) < 256 ? ((UINTN) (reg)): ((UINT64) (reg) << 32)))\r
 \r
 #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
 \r
index 5d1ce1f63fb4e788cec367d8131bc28b85591506..e37baeb10c2c0be93095b7abd8908b4cf9dfd427 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -361,8 +361,8 @@ EFI_STATUS
 (EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2) (\r
   IN CONST  EFI_PEI_SERVICES        **PeiServices,\r
   IN EFI_FV_FILETYPE                SearchType,\r
-  IN CONST EFI_PEI_FV_HANDLE        *FwVolHeader,\r
-  IN OUT EFI_PEI_FILE_HANDLE        **FileHandle  \r
+  IN CONST EFI_PEI_FV_HANDLE        FvHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE        *FileHandle  \r
   );\r
 \r
 typedef\r
@@ -370,7 +370,7 @@ EFI_STATUS
 (EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2) (\r
   IN CONST  EFI_PEI_SERVICES    **PeiServices,\r
   IN EFI_SECTION_TYPE           SectionType,\r
-  IN EFI_PEI_FILE_HANDLE        *FileHandle,\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
   OUT VOID                      **SectionData\r
   );\r
 \r
@@ -443,7 +443,7 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO) (\r
-  IN  EFI_PEI_FV_HANDLE     *VolumeHandle,\r
+  IN  EFI_PEI_FV_HANDLE     VolumeHandle,\r
   OUT EFI_FV_INFO           *VolumeInfo\r
   );\r
 \r
index c8eec3d946b8b2517b1efde725cdf636c476e33c..4f6cb395d68f439540ae021d40b591b37cebc52c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
  \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -22,28 +22,11 @@ Abstract:
 #ifndef _TIANO_SPEC_DEVICE_PATH_H\r
 #define _TIANO_SPEC_DEVICE_PATH_H\r
 \r
-#pragma pack(1)\r
+#include "EfiDevicePath.h"\r
 \r
-#if (EFI_SPECIFICATION_VERSION <= 0x00020000)\r
 //\r
-// EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-// In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-// EFI 1.10 and UEFI 2.10.\r
+// MEDIA_FW_VOL_FILEPATH_DEVICE_PATH and MEDIA_FW_VOL_DEVICE_PATH are defined in \r
+// EfiDevicePath.h\r
 //\r
-#define MEDIA_FV_FILEPATH_DP  0x06\r
-typedef struct {\r
-  EFI_DEVICE_PATH_PROTOCOL  Header;\r
-  EFI_GUID                  NameGuid;\r
-} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;\r
-#endif\r
-\r
-\r
-#if (EFI_SPECIFICATION_VERSION > 0x00020000)\r
-//\r
-// EFI Specification extension on Media Device Path was added to UEFI 2.1 specification,\r
-// so the definition is moved to EfiDevicePath.h\r
-//\r
-#endif\r
 \r
-#pragma pack()\r
 #endif\r
index b39121583980ade0186ba7f4c36ede0f897145c7..cba842faa145ee7122c0f3751bc574059fc42ff8 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2004 - 2010, 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
@@ -102,4 +102,7 @@ COMPONENT_TYPE=   LIBRARY
     GuidedSectionExtraction/GuidedSectionExtraction.c\r
     EcpPciCfg/EcpPciCfg.h\r
     EcpPciCfg/EcpPciCfg.c\r
-    \r
+    TemporaryRamSupport/TemporaryRamSupport.h\r
+    TemporaryRamSupport/TemporaryRamSupport.c\r
+    LoadedImage/LoadedImage.h\r
+    LoadedImage/LoadedImage.c    \r
index 006a4fb23a9b14a54c438699699006e17d5f89d3..e3740169ae3da8420c2ae1ec8b3acda19049c811 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -77,7 +77,7 @@ EFI_STATUS
 (EFIAPI *EFI_PEI_FV_FIND_FILE_NAME) (\r
   IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI     *This,\r
   IN CONST EFI_GUID                        *FileName,\r
-  IN EFI_PEI_FV_HANDLE                     FvHandle,\r
+  IN OUT EFI_PEI_FV_HANDLE                 *FvHandle,\r
   OUT EFI_PEI_FILE_HANDLE                  *FileHandle\r
   );\r
 \r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.c
new file mode 100644 (file)
index 0000000..09d4a8b
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2009 - 2010, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ LoadedImage.c\r
+\r
+Abstract:\r
+\r
+  The file describes the PPI which notifies other drivers \r
+  of the PEIM being initialized by the PEI Dispatcher.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (LoadedImage)\r
+\r
+EFI_GUID  gEfiPeiLoadedImagePpiGuid = EFI_PEI_LOADED_IMAGE_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiPeiLoadedImagePpiGuid, "LoadedImagePpi", "LoadedImage PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/LoadedImage/LoadedImage.h
new file mode 100644 (file)
index 0000000..909b109
--- /dev/null
@@ -0,0 +1,56 @@
+/*++\r
+\r
+Copyright (c) 2009 - 2010, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ LoadedImage.h\r
+\r
+Abstract:\r
+\r
+  The file describes the PPI which notifies other drivers \r
+  of the PEIM being initialized by the PEI Dispatcher.\r
+\r
+--*/\r
+\r
+#ifndef __LOADED_IMAGE_PPI_H__\r
+#define __LOADED_IMAGE_PPI_H__\r
+\r
+#include "Tiano.h"\r
+\r
+#define EFI_PEI_LOADED_IMAGE_PPI_GUID \\r
+  { 0xc1fcd448, 0x6300, 0x4458, {0xb8, 0x64, 0x28, 0xdf, 0x01, 0x53, 0x64, 0xbc} }\r
+  \r
+typedef struct _EFI_PEI_LOADED_IMAGE_PPI  EFI_PEI_LOADED_IMAGE_PPI;\r
+\r
+///\r
+/// This interface is installed by the PEI Dispatcher after the image has been\r
+/// loaded and after all security checks have been performed, \r
+/// to notify other PEIMs of the files which are being loaded.\r
+///\r
+struct _EFI_PEI_LOADED_IMAGE_PPI {\r
+  ///\r
+  /// Address of the image at the address where it will be executed.\r
+  ///\r
+  EFI_PHYSICAL_ADDRESS  ImageAddress;\r
+  ///\r
+  /// Size of the image as it will be executed.\r
+  ///\r
+  UINT64                ImageSize;\r
+  ///\r
+  /// File handle from which the image was loaded.\r
+  /// Can be NULL, indicating the image was not loaded from a handle.\r
+  ///\r
+  EFI_PEI_FILE_HANDLE   FileHandle;\r
+};\r
+\r
+extern EFI_GUID gEfiPeiLoadedImagePpiGuid;\r
+\r
+#endif \r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c b/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.c
new file mode 100644 (file)
index 0000000..b4a2b86
--- /dev/null
@@ -0,0 +1,30 @@
+/*++\r
+\r
+Copyright (c) 2009 - 2010, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ TemporaryRamSupport.c\r
+\r
+Abstract:\r
+\r
+  This file declares Temporary RAM Support PPI.                                   \r
+  This Ppi provides the service that migrates temporary RAM into permanent memory.\r
+\r
+--*/\r
+\r
+#include "Tiano.h"\r
+#include "PeiBind.h"\r
+#include "PeiApi.h"\r
+#include EFI_PPI_DEFINITION (TemporaryRamSupport)\r
+\r
+EFI_GUID  gEfiTemporaryRamSupportPpiGuid = TEMPORARY_RAM_SUPPORT_PPI_GUID;\r
+\r
+EFI_GUID_STRING(&gEfiTemporaryRamSupportPpiGuid, "TemporaryRamSupportPpi", "TemporaryRamSupport PPI");\r
diff --git a/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h b/EdkCompatibilityPkg/Foundation/Framework/Ppi/TemporaryRamSupport/TemporaryRamSupport.h
new file mode 100644 (file)
index 0000000..635c3f8
--- /dev/null
@@ -0,0 +1,66 @@
+/*++\r
+\r
+Copyright (c) 2009 - 2010, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+ TemporaryRamSupport.h\r
+\r
+Abstract:\r
+\r
+  This file declares Temporary RAM Support PPI.                                   \r
+  This Ppi provides the service that migrates temporary RAM into permanent memory.\r
+\r
+--*/\r
+\r
+#ifndef __TEMPORARY_RAM_SUPPORT_H__\r
+#define __TEMPORARY_RAM_SUPPORT_H__\r
+\r
+#include "Tiano.h"\r
+\r
+#define TEMPORARY_RAM_SUPPORT_PPI_GUID \\r
+  { \\r
+     0xdbe23aa9, 0xa345, 0x4b97, {0x85, 0xb6, 0xb2, 0x26, 0xf1, 0x61, 0x73, 0x89} \\r
+  }\r
+\r
+/**                                                                                                             \r
+  This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into                                \r
+  permanent memory.                                                                                             \r
+\r
+  @param PeiServices            Pointer to the PEI Services Table.                                              \r
+  @param TemporaryMemoryBase    Source Address in temporary memory from which the SEC or PEIM will copy the     \r
+                                Temporary RAM contents.                                                         \r
+  @param PermanentMemoryBase    Destination Address in permanent memory into which the SEC or PEIM will copy the\r
+                                Temporary RAM contents.                                                         \r
+  @param CopySize               Amount of memory to migrate from temporary to permanent memory.                 \r
+\r
+  @retval EFI_SUCCESS           The data was successfully returned.                                             \r
+  @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when TemporaryMemoryBase > PermanentMemoryBase.                                      \r
+\r
+  **/                                                                                                             \r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * TEMPORARY_RAM_MIGRATION)(\r
+  IN CONST EFI_PEI_SERVICES   **PeiServices,\r
+  IN EFI_PHYSICAL_ADDRESS     TemporaryMemoryBase,\r
+  IN EFI_PHYSICAL_ADDRESS     PermanentMemoryBase,\r
+  IN UINTN                    CopySize\r
+);                                                                          \r
+\r
+///                                                                                                             \r
+/// This service abstracts the ability to migrate contents of the platform early memory store.                  \r
+///                                                                                                             \r
+typedef struct {                                                                                                \r
+  TEMPORARY_RAM_MIGRATION   TemporaryRamMigration;                                                              \r
+} TEMPORARY_RAM_SUPPORT_PPI;  \r
+\r
+extern EFI_GUID  gEfiTemporaryRamSupportPpiGuid;\r
+\r
+#endif \r
index ffa2f5b3623e0fe2f97f634b802e4c54346ab6bd..30cff849dbabc8229147582cb594e29a00e290e5 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -27,5 +27,7 @@ Abstract:
 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
 \r
 EFI_GUID  gEfiFirmwareVolumeBlockProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;\r
+EFI_GUID  gEfiFirmwareVolumeBlock2ProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;\r
 \r
 EFI_GUID_STRING(&gEfiFirmwareVolumeBlockProtocolGuid, "FirmwareVolumeBlock Protocol", "Firmware Volume Block protocol");\r
+EFI_GUID_STRING(&gEfiFirmwareVolumeBlock2ProtocolGuid, "FirmwareVolumeBlock2 Protocol", "Firmware Volume Block2 protocol");\r
index d431aedc5d1a4414bf0525ce03b96696b5e8e148..a2fd4e9d7a0b7644308e391c9861c03128b5d11d 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -40,6 +40,8 @@ Abstract:
 \r
 EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL);\r
 \r
+typedef EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL;\r
+\r
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_FVB_GET_ATTRIBUTES) (\r
index c28852c64b14cda63e2ddeb010ba9e85ff41c99b..6e3691cb3b1760e56242ac5c8be84644eae62bbf 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -174,10 +174,17 @@ typedef struct {
   UINT16  command_set_feature_enb_86; // word 86\r
   UINT16  command_set_feature_default; // word 87\r
   UINT16  ultra_dma_mode; // word 88\r
-  UINT16  reserved_89_127[39];\r
+  UINT16  reserved_89_105[17];\r
+  UINT16  phy_logic_sector_support; // word 106\r
+  UINT16  reserved_107_116[10];\r
+  UINT16  logic_sector_size_lo; // word 117\r
+  UINT16  logic_sector_size_hi; // word 118\r
+  UINT16  reserved_119_127[9];\r
   UINT16  security_status;\r
   UINT16  vendor_data_129_159[31];\r
-  UINT16  reserved_160_255[96];\r
+  UINT16  reserved_160_208[49];\r
+  UINT16  alignment_logic_in_phy_blocks; // word 209\r
+  UINT16  reserved_210_255[46];\r
 } EFI_ATA_IDENTIFY_DATA;\r
 \r
 #pragma pack()\r
index 4c1462712cc20a62b89001c49c630ee0cb3ad124..a2e6fd4f5be3c5256676de222157eb41690663ec 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -28,6 +28,7 @@ Abstract:
     0x3c699197, 0x93c, 0x4c69, {0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9} \\r
   }\r
 \r
+#pragma pack(1)\r
 typedef struct {\r
   UINT8   AddressSpaceId;\r
   UINT8   RegisterBitWidth;\r
@@ -52,7 +53,6 @@ typedef struct {
 // Following structure defines ACPI Description information.\r
 // This information is platform specific, may be consumed by DXE generic driver.\r
 //\r
-#pragma pack(1)\r
 typedef struct _EFI_ACPI_DESCRIPTION {\r
   //\r
   // For Timer\r
index 8e5025161fc5b559214be5dd36ce6dc40119b553..396d89cbd4b8276c9adbcce1b1fdf8ae88b23d5e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -20,6 +20,7 @@ Abstract:
 --*/\r
 \r
 #ifndef _PCI_OPTION_ROM_TABLE_GUID_H_\r
+#define _PCI_OPTION_ROM_TABLE_GUID_H_\r
 \r
 #define EFI_PCI_OPTION_ROM_TABLE_GUID \\r
   { 0x7462660f, 0x1cbd, 0x48da, {0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c} }\r
index 7fc640de96d74859ebd080057955a3bcd5625d57..57f91b7ff34a98275abe4b8500c4ae88613a2359 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2010, 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
@@ -75,6 +75,9 @@ typedef struct {
 #ifdef EFI_NT_EMULATOR\r
   VOID                              **ModHandle;\r
 #endif\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+  EFI_PHYSICAL_ADDRESS              HiiResourceData;\r
+#endif\r
 } EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT;\r
 \r
 typedef \r
index d64c2b2b561d99cda3500414b4b69b8e29661570..31b50deb8bfdabb0d421bbb5d275d50275cb84d4 100644 (file)
@@ -33,19 +33,5 @@ Abstract:
 #include "EfiApi.h"\r
 #include "EfiDevicePath.h"\r
 \r
-//\r
-// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.\r
-//\r
-#if !defined(EFI_SPECIFICATION_VERSION)\r
-  #error EFI_SPECIFICATION_VERSION not defined\r
-#elif !defined(TIANO_RELEASE_VERSION)\r
-  #error TIANO_RELEASE_VERSION not defined\r
-#elif (TIANO_RELEASE_VERSION == 0)\r
-//\r
-// UEFI mode with no Tiano extensions is legal\r
-//\r
-#elif ((TIANO_RELEASE_VERSION < 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000))\r
-  #error Illegal combination of EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION versions\r
-#endif\r
 \r
 #endif\r
index 6d03ec48960f160b8afd4b8b4ffa4a3ac8c3b89b..07a7fec735bf1eba5ec30c31b09c9d8f4958d0dd 100644 (file)
@@ -25,7 +25,12 @@ Abstract:
 #define _EFI_TPM_H_\r
 \r
 #include "Tiano.h"\r
-#include "IndustryStandard/Tpm12.h"\r
+\r
+//\r
+// The start of TPM return codes\r
+//\r
+#define TPM_BASE                    (EFI_MAX_BIT + (EFI_MAX_BIT >> 1))\r
+#include "Tpm12.h"\r
 \r
 //\r
 // Standard event types\r
index 89b30157138dafd574d63d08e21c88a54274d95a..901bd52ea7179cca9b31202b41706deb8bd0a8da 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -22,6 +22,32 @@ Abstract:
 \r
 #include "Tiano.h"\r
 \r
+//\r
+// Reference SMBIOS 2.6, chapter 3.1.2.\r
+// For v2.1 and later, handle values in the range 0FF00h to 0FFFFh are reserved for\r
+// use by this specification.\r
+//\r
+#define SMBIOS_HANDLE_RESERVED_BEGIN 0xFF00\r
+\r
+//\r
+// Reference SMBIOS 2.6, chapter 3.1.3\r
+// Each text string is limited to 64 significant characters due to system MIF limitations\r
+//\r
+#define SMBIOS_STRING_MAX_LENGTH     64\r
+\r
+//\r
+// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43.\r
+// Upper-level software that interprets the SMBIOS structure-table should bypass an \r
+// Inactive structure just like a structure type that the software does not recognize.\r
+//\r
+#define SMBIOS_TYPE_INACTIVE         0x007E    \r
+\r
+//\r
+// End-of-table type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.44.\r
+// The end-of-table indicator is used in the last physical structure in a table\r
+//\r
+#define SMBIOS_TYPE_END_OF_TABLE     0x007F\r
+\r
 #pragma pack(1)\r
 \r
 typedef UINT8 SMBIOS_TABLE_STRING;\r
index 0ba14cecfb2631c5ea10bbac838c497283572b82..aa54b384ee8052dca5c95ada1072ca53661fe46e 100644 (file)
@@ -15,7 +15,7 @@ Module Name:
 \r
 Abstract:\r
 \r
-  TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 94)\r
+  TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 103)\r
 \r
   See http://trustedcomputinggroup.org for latest specification updates\r
 \r
@@ -39,6 +39,7 @@ Abstract:
 typedef UINT8                       TPM_AUTH_DATA_USAGE;\r
 typedef UINT8                       TPM_PAYLOAD_TYPE;\r
 typedef UINT8                       TPM_VERSION_BYTE;\r
+typedef UINT8                       TPM_DA_STATE;\r
 typedef UINT16                      TPM_TAG;\r
 typedef UINT16                      TPM_PROTOCOL_ID;\r
 typedef UINT16                      TPM_STARTUP_TYPE;\r
@@ -144,6 +145,9 @@ typedef UINT32                      TPM_FAMILY_OPERATION;
 #define TPM_TAG_CMK_SIGTICKET       ((TPM_STRUCTURE_TAG) 0x0034)\r
 #define TPM_TAG_CMK_MA_APPROVAL     ((TPM_STRUCTURE_TAG) 0x0035)\r
 #define TPM_TAG_QUOTE_INFO2         ((TPM_STRUCTURE_TAG) 0x0036)\r
+#define TPM_TAG_DA_INFO             ((TPM_STRUCTURE_TAG) 0x0037)\r
+#define TPM_TAG_DA_LIMITED          ((TPM_STRUCTURE_TAG) 0x0038)\r
+#define TPM_TAG_DA_ACTION_TYPE      ((TPM_STRUCTURE_TAG) 0x0039)\r
 \r
 //\r
 // Part 2, section 4: TPM Types\r
@@ -190,6 +194,7 @@ typedef UINT32                      TPM_FAMILY_OPERATION;
 #define TPM_ET_DEL_KEY_BLOB         ((UINT16) 0x0009) // The entity is a delegate key blob\r
 #define TPM_ET_COUNTER              ((UINT16) 0x000A) // The entity is a counter\r
 #define TPM_ET_NV                   ((UINT16) 0x000B) // The entity is a NV index\r
+#define TPM_ET_OPERATOR             ((UINT16) 0x000C) // The entity is the operator\r
 #define TPM_ET_RESERVED_HANDLE      ((UINT16) 0x0040) // Reserved. This value avoids collisions with the handle MSB setting.\r
 //\r
 // TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable\r
@@ -323,8 +328,6 @@ typedef TPM_DIGEST                  TPM_DIRVALUE; // This SHALL be the value of
 typedef TPM_DIGEST                  TPM_HMAC;\r
 typedef TPM_DIGEST                  TPM_PCRVALUE; // The value inside of the PCR\r
 typedef TPM_DIGEST                  TPM_AUDITDIGEST; // This SHALL be the value of the current internal audit state\r
-typedef TPM_DIGEST                  TPM_DAA_TPM_SEED; // This SHALL be a random value generated by a TPM immediately after the EK is installed in that TPM, whenever an EK is installed in that TPM\r
-typedef TPM_DIGEST                  TPM_DAA_CONTEXT_SEED; // This SHALL be a random value\r
 \r
 //\r
 // Part 2, section 5.5: TPM_NONCE\r
@@ -333,6 +336,9 @@ typedef struct tdTPM_NONCE{
   UINT8                             nonce[20];\r
 } TPM_NONCE;\r
 \r
+typedef TPM_NONCE                  TPM_DAA_TPM_SEED; // This SHALL be a random value generated by a TPM immediately after the EK is installed in that TPM, whenever an EK is installed in that TPM\r
+typedef TPM_NONCE                  TPM_DAA_CONTEXT_SEED; // This SHALL be a random value\r
+\r
 //\r
 // Part 2, section 5.6: TPM_AUTHDATA\r
 //\r
@@ -393,7 +399,8 @@ typedef struct tdTPM_KEY_HANDLE_LIST {
 #define TPM_ES_NONE                 ((TPM_ENC_SCHEME) 0x0001)\r
 #define TPM_ES_RSAESPKCSv15         ((TPM_ENC_SCHEME) 0x0002)\r
 #define TPM_ES_RSAESOAEP_SHA1_MGF1  ((TPM_ENC_SCHEME) 0x0003)\r
-#define TPM_ES_SYM_CNT              ((TPM_ENC_SCHEME) 0x0004)\r
+#define TPM_ES_SYM_CNT              ((TPM_ENC_SCHEME) 0x0004)  // rev94 defined\r
+#define TPM_ES_SYM_CTR              ((TPM_ENC_SCHEME) 0x0004)\r
 #define TPM_ES_SYM_OFB              ((TPM_ENC_SCHEME) 0x0005)\r
 \r
 #define TPM_SS_NONE                 ((TPM_SIG_SCHEME) 0x0001)\r
@@ -584,6 +591,7 @@ typedef struct tdTPM_PERMANENT_FLAGS{
   BOOLEAN                           readSRKPub;\r
   BOOLEAN                           tpmEstablished;\r
   BOOLEAN                           maintenanceDone;\r
+  BOOLEAN                           disableFullDALogicInfo;\r
 } TPM_PERMANENT_FLAGS;\r
 \r
 //\r
@@ -608,6 +616,7 @@ typedef struct tdTPM_PERMANENT_FLAGS{
 #define TPM_PF_READSRKPUB                   ((TPM_CAPABILITY_AREA) 17)\r
 #define TPM_PF_TPMESTABLISHED               ((TPM_CAPABILITY_AREA) 18)\r
 #define TPM_PF_MAINTENANCEDONE              ((TPM_CAPABILITY_AREA) 19)\r
+#define TPM_PF_DISABLEFULLDALOGICINFO       ((TPM_CAPABILITY_AREA) 20)\r
 \r
 //\r
 // Part 2, section 7.2: TPM_STCLEAR_FLAGS\r
@@ -655,10 +664,11 @@ typedef struct tdTPM_STANY_FLAGS{
 //\r
 // Part 2, section 7.4: TPM_PERMANENT_DATA\r
 //\r
-//#define TPM_MIN_COUNTERS            4   // the minimum number of counters is 4\r
-//#define TPM_DELEGATE_KEY            TPM_KEY\r
-//#define TPM_NUM_PCR                 16\r
-//#define TPM_MAX_NV_WRITE_NOOWNER    64\r
+#define TPM_MIN_COUNTERS            4   // the minimum number of counters is 4\r
+#define TPM_DELEGATE_KEY            TPM_KEY\r
+#define TPM_NUM_PCR                 16\r
+#define TPM_MAX_NV_WRITE_NOOWNER    64\r
+\r
 //typedef struct tdTPM_PERMANENT_DATA\r
 //{\r
 //    TPM_STRUCTURE_TAG               tag;\r
@@ -686,20 +696,62 @@ typedef struct tdTPM_STANY_FLAGS{
 //    UINT32                          noOwnerNVWrite;\r
 //    TPM_CMK_DELEGATE                restrictDelegate;\r
 //    TPM_DAA_TPM_SEED                tpmDAASeed;\r
+//    TPM_NONCE                       daaProff;\r
+//    TPM_KEY                         daaBlobKey;\r
 //} TPM_PERMANENT_DATA;\r
 \r
+//\r
+// Part 2, section 7.4.1: PERMANENT_DATA Subcap for SetCapability\r
+//\r
+#define TPM_PD_REVMAJOR               ((TPM_CAPABILITY_AREA) 1)\r
+#define TPM_PD_REVMINOR               ((TPM_CAPABILITY_AREA) 2)\r
+#define TPM_PD_TPMPROOF               ((TPM_CAPABILITY_AREA) 3)\r
+#define TPM_PD_OWNERAUTH              ((TPM_CAPABILITY_AREA) 4)\r
+#define TPM_PD_OPERATORAUTH           ((TPM_CAPABILITY_AREA) 5)\r
+#define TPM_PD_MANUMAINTPUB           ((TPM_CAPABILITY_AREA) 6)\r
+#define TPM_PD_ENDORSEMENTKEY         ((TPM_CAPABILITY_AREA) 7)\r
+#define TPM_PD_SRK                    ((TPM_CAPABILITY_AREA) 8)\r
+#define TPM_PD_DELEGATEKEY            ((TPM_CAPABILITY_AREA) 9)\r
+#define TPM_PD_CONTEXTKEY             ((TPM_CAPABILITY_AREA) 10)\r
+#define TPM_PD_AUDITMONOTONICCOUNTER  ((TPM_CAPABILITY_AREA) 11)\r
+#define TPM_PD_MONOTONICCOUNTER       ((TPM_CAPABILITY_AREA) 12)\r
+#define TPM_PD_PCRATTRIB              ((TPM_CAPABILITY_AREA) 13)\r
+#define TPM_PD_ORDINALAUDITSTATUS     ((TPM_CAPABILITY_AREA) 14)\r
+#define TPM_PD_AUTHDIR                ((TPM_CAPABILITY_AREA) 15)\r
+#define TPM_PD_RNGSTATE               ((TPM_CAPABILITY_AREA) 16)\r
+#define TPM_PD_FAMILYTABLE            ((TPM_CAPABILITY_AREA) 17)\r
+#define TPM_DELEGATETABLE             ((TPM_CAPABILITY_AREA) 18)\r
+#define TPM_PD_EKRESET                ((TPM_CAPABILITY_AREA) 19)\r
+#define TPM_PD_MAXNVBUFSIZE           ((TPM_CAPABILITY_AREA) 20)\r
+#define TPM_PD_LASTFAMILYID           ((TPM_CAPABILITY_AREA) 21)\r
+#define TPM_PD_NOOWNERNVWRITE         ((TPM_CAPABILITY_AREA) 22)\r
+#define TPM_PD_RESTRICTDELEGATE       ((TPM_CAPABILITY_AREA) 23)\r
+#define TPM_PD_TPMDAASEED             ((TPM_CAPABILITY_AREA) 24)\r
+#define TPM_PD_DAAPROOF               ((TPM_CAPABILITY_AREA) 25)\r
+\r
 //\r
 // Part 2, section 7.5: TPM_STCLEAR_DATA\r
 //   available inside TPM only\r
 //\r
-//typedef struct tdTPM_STCLEAR_DATA\r
-//{\r
-//    TPM_STRUCTURE_TAG               tag;\r
-//    TPM_NONCE                       contextNonceKey;\r
-//    TPM_COUNT_ID                    countID;\r
-//    UINT32                          ownerReference;\r
-//    BOOLEAN                         disableResetLock;\r
-//} TPM_STCLEAR_DATA;\r
+ typedef struct tdTPM_STCLEAR_DATA{\r
+   TPM_STRUCTURE_TAG                  tag;\r
+   TPM_NONCE                          contextNonceKey;\r
+   TPM_COUNT_ID                       countID;\r
+   UINT32                             ownerReference;\r
+   BOOLEAN                            disableResetLock;\r
+   TPM_PCRVALUE                       PCR[TPM_NUM_PCR];\r
+   UINT32                             deferredPhysicalPresence;\r
+ }TPM_STCLEAR_DATA;\r
+\r
+//\r
+// Part 2, section 7.5.1: STCLEAR_DATA Subcap for SetCapability\r
+//\r
+#define TPM_SD_CONTEXTNONCEKEY            ((TPM_CAPABILITY_AREA)0x00000001)\r
+#define TPM_SD_COUNTID                    ((TPM_CAPABILITY_AREA)0x00000002)\r
+#define TPM_SD_OWNERREFERENCE             ((TPM_CAPABILITY_AREA)0x00000003)\r
+#define TPM_SD_DISABLERESETLOCK           ((TPM_CAPABILITY_AREA)0x00000004)\r
+#define TPM_SD_PCR                        ((TPM_CAPABILITY_AREA)0x00000005)\r
+#define TPM_SD_DEFERREDPHYSICALPRESENCE   ((TPM_CAPABILITY_AREA)0x00000006)\r
 \r
 //\r
 // Part 2, section 7.6: TPM_STANY_DATA\r
@@ -716,6 +768,16 @@ typedef struct tdTPM_STANY_FLAGS{
 //    TPM_SESSION_DATA                sessions[TPM_MIN_SESSIONS];\r
 //} TPM_STANY_DATA;\r
 \r
+//\r
+// Part 2, section 7.6.1: STANY_DATA Subcap for SetCapability\r
+//\r
+#define TPM_AD_CONTEXTNONCESESSION        ((TPM_CAPABILITY_AREA) 1)\r
+#define TPM_AD_AUDITDIGEST                ((TPM_CAPABILITY_AREA) 2)\r
+#define TPM_AD_CURRENTTICKS               ((TPM_CAPABILITY_AREA) 3)\r
+#define TPM_AD_CONTEXTCOUNT               ((TPM_CAPABILITY_AREA) 4)\r
+#define TPM_AD_CONTEXTLIST                ((TPM_CAPABILITY_AREA) 5)\r
+#define TPM_AD_SESSIONS                   ((TPM_CAPABILITY_AREA) 6)\r
+\r
 //\r
 // Part 2, section 8: PCR Structures\r
 // \r
@@ -1137,7 +1199,9 @@ typedef struct tdTPM_AUDIT_EVENT_OUT
 //\r
 // Part 2, section 16: Return Codes\r
 //\r
-#define TPM_BASE                    0\r
+#ifndef TPM_BASE\r
+#error "TPM Error Codes require definition of TPM_BASE"\r
+#endif\r
 \r
 #define TPM_VENDOR_ERROR            TPM_Vendor_Specific32\r
 #define TPM_NON_FATAL               0x00000800\r
@@ -1498,12 +1562,14 @@ typedef struct tdTPM_NV_DATA_PUBLIC
 //\r
 \r
 //\r
-// Part 2, section 20.3: Owner Permissions Settings for per1 bits\r
+// Part 2, section 20.2.1: Owner Permissions Settings for per1 bits\r
 //\r
 #define TPM_DELEGATE_SetOrdinalAuditStatus          (((UINT32)1)<<30)\r
 #define TPM_DELEGATE_DirWriteAuth                   (((UINT32)1)<<29)\r
 #define TPM_DELEGATE_CMK_ApproveMA                  (((UINT32)1)<<28)\r
+#define TPM_DELEGATE_NV_WriteValue                  (((UINT32)1)<<27)\r
 #define TPM_DELEGATE_CMK_CreateTicket               (((UINT32)1)<<26)\r
+#define TPM_DELEGATE_NV_ReadValue                   (((UINT32)1)<<25)\r
 #define TPM_DELEGATE_Delegate_LoadOwnerDelegation   (((UINT32)1)<<24)\r
 #define TPM_DELEGATE_DAA_Join                       (((UINT32)1)<<23)\r
 #define TPM_DELEGATE_AuthorizeMigrationKey          (((UINT32)1)<<22)\r
@@ -1514,6 +1580,7 @@ typedef struct tdTPM_NV_DATA_PUBLIC
 #define TPM_DELEGATE_ResetLockValue                 (((UINT32)1)<<17)\r
 #define TPM_DELEGATE_OwnerClear                     (((UINT32)1)<<16)\r
 #define TPM_DELEGATE_DisableOwnerClear              (((UINT32)1)<<15)\r
+#define TPM_DELEGATE_NV_DefineSpace                 (((UINT32)1)<<14)\r
 #define TPM_DELEGATE_OwnerSetDisable                (((UINT32)1)<<13)\r
 #define TPM_DELEGATE_SetCapability                  (((UINT32)1)<<12)\r
 #define TPM_DELEGATE_MakeIdentity                   (((UINT32)1)<<11)\r
@@ -1530,7 +1597,7 @@ typedef struct tdTPM_NV_DATA_PUBLIC
 #define TPM_DELEGATE_DAA_Sign                       (((UINT32)1)<<0)\r
 \r
 //\r
-// Part 2, section 20.3: Key Permissions Settings for per1 bits\r
+// Part 2, section 20.2.3: Key Permissions Settings for per1 bits\r
 //\r
 #define TPM_KEY_DELEGATE_CMK_ConvertMigration       (((UINT32)1)<<28)\r
 #define TPM_KEY_DELEGATE_TickStampBlob              (((UINT32)1)<<27)\r
@@ -1723,6 +1790,15 @@ typedef struct tdTPM_DELEGATE_KEY_BLOB
 #define TPM_CAP_PROP_INPUT_BUFFER       ((TPM_CAPABILITY_AREA) 0x00000124)\r
 \r
 //\r
+// Part 2, section 21.4: TPM_CAPABILITY_AREA for SetCapability\r
+//\r
+#define TPM_SET_PERM_FLAGS              ((TPM_CAPABILITY_AREA) 0x00000001)\r
+#define TPM_SET_PERM_DATA               ((TPM_CAPABILITY_AREA) 0x00000002)\r
+#define TPM_SET_STCLEAR_FLAGS           ((TPM_CAPABILITY_AREA) 0x00000003)\r
+#define TPM_SET_STCLEAR_DATA            ((TPM_CAPABILITY_AREA) 0x00000004)\r
+#define TPM_SET_STANY_FLAGS             ((TPM_CAPABILITY_AREA) 0x00000005)\r
+#define TPM_SET_STANY_DATA              ((TPM_CAPABILITY_AREA) 0x00000006)\r
+\r
 // Part 2, section 21.6: TPM_CAP_VERSION_INFO\r
 //   [size_is(vendorSpecificSize)] BYTE* vendorSpecific;\r
 //\r
@@ -1736,6 +1812,50 @@ typedef struct tdTPM_CAP_VERSION_INFO {
   UINT8                             *vendorSpecific;\r
 } TPM_CAP_VERSION_INFO;\r
 \r
+//\r
+// Part 2, section 21.10: TPM_DA_ACTION_TYPE\r
+//\r
+typedef struct tdTPM_DA_ACTION_TYPE {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  UINT32                            actions;\r
+} TPM_DA_ACTION_TYPE;\r
+\r
+#define TPM_DA_ACTION_FAILURE_MODE     (((UINT32)1)<<3)\r
+#define TPM_DA_ACTION_DEACTIVATE       (((UINT32)1)<<2)\r
+#define TPM_DA_ACTION_DISABLE          (((UINT32)1)<<1)\r
+#define TPM_DA_ACTION_TIMEOUT          (((UINT32)1)<<0)\r
+\r
+//\r
+// Part 2, section 21.7: TPM_DA_INFO\r
+//\r
+typedef struct tdTPM_DA_INFO {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_DA_STATE                      state;\r
+  UINT16                            currentCount;\r
+  UINT16                            thresholdCount;\r
+  TPM_DA_ACTION_TYPE                actionAtThreshold;\r
+  UINT32                            actionDependValue;\r
+  UINT32                            vendorDataSize;\r
+  UINT8                             *vendorData;\r
+} TPM_DA_INFO;\r
+\r
+//\r
+// Part 2, section 21.8: TPM_DA_INFO_LIMITED\r
+//\r
+typedef struct tdTPM_DA_INFO_LIMITED {\r
+  TPM_STRUCTURE_TAG                 tag;\r
+  TPM_DA_STATE                      state;\r
+  TPM_DA_ACTION_TYPE                actionAtThreshold;\r
+  UINT32                            vendorDataSize;\r
+  UINT8                             *vendorData;\r
+} TPM_DA_INFO_LIMITED;\r
+\r
+//\r
+// Part 2, section 21.9: CAP_PROPERTY Subcap values for GetCapability\r
+//\r
+#define TPM_DA_STATE_INACTIVE          ((UINT8)0x00)\r
+#define TPM_DA_STATE_ACTIVE            ((UINT8)0x01)\r
+\r
 //\r
 // Part 2, section 22: DAA Structures\r
 //\r
index 0957c86d2500ebc8c1a5b350be948b22284e1e9b..e1be8f5a87632734f698d477c2de19aa0831bbf4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -25,6 +25,16 @@ Revision History
 \r
 #include "pci22.h"\r
 \r
+//\r
+// PCI_CLASS_MASS_STORAGE\r
+//\r
+#define PCI_CLASS_MASS_STORAGE_ATA    0x05\r
+\r
+//\r
+// PCI_CLASS_SERIAL\r
+//\r
+#define PCI_CLASS_SERIAL_IB           0x06\r
+\r
 #define PCI_EXP_MAX_CONFIG_OFFSET     0x1000\r
 #define EFI_PCI_CAPABILITY_ID_PCIEXP  0x10\r
 \r
index 2c2025583bd7ee462f579dd4f80d7adad7776873..0ae3bfd33687ccb61c4088ca898bf39a8568f914 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -56,6 +56,7 @@ Revision History
 #define EFI_SCSI_OP_READ6           0x08\r
 #define EFI_SCSI_OP_READ10          0x28\r
 #define EFI_SCSI_OP_READ_CAPACITY   0x25\r
+#define EFI_SCSI_OP_READ_CAPACITY16 0x9e\r
 #define EFI_SCSI_OP_READ_DEFECT     0x37\r
 #define EFI_SCSI_OP_READ_LONG       0x3e\r
 #define EFI_SCSI_OP_REASSIGN_BLK    0x07\r
@@ -238,6 +239,27 @@ typedef struct {
   UINT8 BlockSize0;\r
 } EFI_SCSI_DISK_CAPACITY_DATA;\r
 \r
+typedef struct {\r
+  UINT8 LastLba7;\r
+  UINT8 LastLba6;\r
+  UINT8 LastLba5;\r
+  UINT8 LastLba4;\r
+  UINT8 LastLba3;\r
+  UINT8 LastLba2;\r
+  UINT8 LastLba1;\r
+  UINT8 LastLba0;\r
+  UINT8 BlockSize3;\r
+  UINT8 BlockSize2;\r
+  UINT8 BlockSize1;\r
+  UINT8 BlockSize0;\r
+  UINT8 Protection;\r
+  UINT8 LogicPerPhysical;\r
+  UINT8 LowestAlignLogic2;  \r
+  UINT8 LowestAlignLogic1;    \r
+  UINT8 Reserved[16];  \r
+} EFI_SCSI_DISK_CAPACITY_DATA16;\r
+\r
+\r
 #pragma pack()\r
 //\r
 // Sense Key\r
index f26515251c0015c7b9d7af43aa0025b6df805afe..159936fa75d7bf8a09e38827a3249d2c9f400c51 100644 (file)
@@ -27,18 +27,6 @@ Abstract:
 #ifndef _TIANO_H_\r
 #define _TIANO_H_\r
 \r
-//\r
-// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.\r
-//\r
-#if !defined(EFI_SPECIFICATION_VERSION)\r
-  #error EFI_SPECIFICATION_VERSION not defined\r
-#elif !defined(TIANO_RELEASE_VERSION)\r
-  #error TIANO_RELEASE_VERSION not defined\r
-#elif (TIANO_RELEASE_VERSION == 0)\r
-  #error TIANO_RELEASE_VERSION can not be zero\r
-#elif (EFI_SPECIFICATION_VERSION <= 0x00020000)\r
-  #define TIANO_EXTENSION_FLAG\r
-#endif\r
 \r
 #include "TianoCommon.h"\r
 #include "TianoApi.h"\r
index fd97e4215a76217d553f7645498e835bc43b9c24..ba17702d150e12538ca3bb123de199c00d87a042 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -50,6 +50,11 @@ Revision History
 //\r
 #define EFI_IFR_TIANO_GUID \\r
   { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce} }\r
+//\r
+// ClassGuid for Front Page\r
+//\r
+#define EFI_HII_FRONT_PAGE_CLASS_GUID \\r
+  { 0x94d411b7, 0x7669, 0x45c3, {0xba, 0x3b, 0xf3, 0xa5, 0x8a, 0x71, 0x56, 0x81} }\r
 \r
 #pragma pack(1)\r
 \r
index d0aef2f1b6d43a98287e7095358c37ae53a6239c..72f19fbca74c42f972708dc06fc1615ea8b40e61 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-#  Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2010, 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
@@ -34,8 +34,8 @@ COMPONENT_TYPE  = LIBRARY
   memset.c            | GCC\r
   \r
 [sources.x64]  \r
-  x64/memcpyRep1.asm | MSFT\r
-  x64/memcpyRep1.asm | INTEL \r
+  x64/memcpyRep4.asm | MSFT\r
+  x64/memcpyRep4.asm | INTEL \r
   x64/memsetRep4.asm | MSFT\r
   x64/memsetRep4.asm | INTEL\r
   memcpy.c           | GCC\r
index 909ee60936f14955d44e5ae30855eb2dec6ab629..bbe3f33d5db4171d39af6e754729b792d8a54b90 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-#  Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2010, 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
@@ -34,7 +34,7 @@ COMPONENT_TYPE  = LIBRARY
 [sources.x64]  \r
   memcpy.c | GCC\r
   \r
-  x64/memcpyRep1.asm\r
+  x64/memcpyRep4.asm\r
   x64/memsetRep4.asm\r
 #  x64/memcpy.asm\r
 #  x64/memset.asm\r
index 568ac126135b33db75744cce561296348df7e302..daa01a29a7c91fa58aa5d24fab0970a1edbcb518 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -502,13 +502,6 @@ Routine Description:
 \r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability.\r
-\r
 Arguments:\r
 \r
   FvDevicePathNode  - Pointer to a FV device path node to initialize\r
@@ -520,12 +513,6 @@ Returns:
 \r
 --*/\r
 {\r
-  //\r
-  // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-  // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-  // EFI 1.10 and UEFI 2.10.\r
-  //\r
-\r
   FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
   FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_DP;\r
   SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
@@ -544,15 +531,6 @@ Routine Description:
 \r
   Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability. The return value to this\r
-  function points to a location in FvDevicePathNode and it does not allocate\r
-  new memory for the GUID pointer that is returned.\r
-\r
 Arguments:\r
 \r
   FvDevicePathNode  - Pointer to FV device path to check\r
@@ -564,11 +542,6 @@ Returns:
 \r
 --*/\r
 {\r
-  //\r
-  // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-  // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-  // EFI 1.10 and UEFI 2.10.\r
-  //\r
   if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
       DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
     return &FvDevicePathNode->NameGuid;\r
index 3de6c59dc28810c8bea1f9e04dc60b67b420cf17..ef10d41702d02c56c86b2c8f735c330e14c55232 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -21,6 +21,18 @@ Abstract:
 \r
 #include "Tiano.h"\r
 #include "EfiDriverLib.h"\r
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+\r
+VOID\r
+EFIAPI\r
+OnStatusCodeInstall (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  );\r
+\r
+#endif\r
 \r
 //\r
 // Global Interface for Debug Mask Protocol\r
@@ -50,6 +62,10 @@ Returns:
 \r
 --*/\r
 {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  VOID *Registration;\r
+#endif\r
+  \r
   gST = SystemTable;\r
 \r
   ASSERT (gST != NULL);\r
@@ -70,6 +86,21 @@ Returns:
         (VOID *) &gDebugMaskInterface\r
         );\r
 #endif\r
+\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  //\r
+  // Register EFI_STATUS_CODE_PROTOCOL notify function\r
+  //\r
+  EfiLibCreateProtocolNotifyEvent (\r
+    &gEfiStatusCodeRuntimeProtocolGuid,\r
+    EFI_TPL_CALLBACK,\r
+    OnStatusCodeInstall,\r
+    NULL,\r
+    &Registration\r
+    );\r
+\r
+#endif\r
+\r
   //\r
   // Should be at EFI_D_INFO, but lets us know things are running\r
   //\r
@@ -78,55 +109,107 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+STATIC\r
+BOOLEAN\r
+IsIso639LanguageCode (\r
+  IN CHAR8                *Languages\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Tests whether a language code has format of ISO639-2.\r
+\r
+Arguments:\r
+\r
+  Languages - The language code to be tested.\r
+\r
+Returns:\r
+\r
+  TRUE      - Language code format is ISO 639-2.\r
+  FALSE     - Language code format is not ISO 639-2.\r
+\r
+--*/\r
+{\r
+  UINTN  Index;\r
+\r
+  //\r
+  // Find out format of Languages\r
+  //\r
+  for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);\r
+  if (Languages[Index] != 0) {\r
+    //\r
+    // RFC4646 language code\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code\r
+  //\r
+  if (Index == 2) {\r
+    //\r
+    // Single RFC4646 language code without country code, e.g. "en"\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Languages in format of ISO639-2\r
+  //\r
+  return TRUE;\r
+}\r
+\r
 BOOLEAN\r
 EfiLibCompareLanguage (\r
-  IN  CHAR8  *Language1,\r
-  IN  CHAR8  *Language2\r
+  IN  CHAR8               *Language1,\r
+  IN  CHAR8               *Language2\r
   )\r
 /*++\r
 \r
 Routine Description:\r
 \r
-  Compare whether two names of languages are identical.\r
+  Compare the first language instance of two language codes, either could be a\r
+  single language code or a language code list. This function assume Language1\r
+  and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.\r
 \r
 Arguments:\r
 \r
-  Language1 - Name of language 1\r
-  Language2 - Name of language 2\r
+  Language1 - The first language code to be tested.\r
+  Language2 - The second language code to be tested.\r
 \r
 Returns:\r
 \r
-  TRUE      - same\r
-  FALSE     - not same\r
+  TRUE      - Language code match.\r
+  FALSE     - Language code mismatch.\r
 \r
 --*/\r
 {\r
   UINTN Index;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {\r
-    if (Language1[Index] != Language2[Index]) {\r
-      return FALSE;\r
-    }\r
+  //\r
+  // Compare first two bytes of language tag\r
+  //\r
+  if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {\r
+    return FALSE;\r
   }\r
 \r
-  if (((Language1[Index] == 0) && (Language2[Index] == 0))   || \r
-         ((Language1[Index] == 0) && (Language2[Index] != ';')) ||\r
-         ((Language1[Index] == ';') && (Language2[Index] != 0)) ||\r
-         ((Language1[Index] == ';') && (Language2[Index] != ';'))) {\r
-    return TRUE;\r
+  if (IsIso639LanguageCode (Language1)) {\r
+    //\r
+    // ISO639-2 language code, compare the third byte of language tag\r
+    //\r
+    return (BOOLEAN) ((Language1[2] == Language2[2]) ? TRUE : FALSE);\r
   }\r
 \r
-  return FALSE;\r
-#else\r
-  for (Index = 0; Index < 3; Index++) {\r
-    if (Language1[Index] != Language2[Index]) {\r
-      return FALSE;\r
-    }\r
+  //\r
+  // RFC4646 language code\r
+  //\r
+  for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);\r
+  if ((EfiAsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {\r
+    return TRUE;\r
   }\r
 \r
-  return TRUE;\r
-#endif\r
+  return FALSE;\r
 }\r
 \r
 STATIC\r
@@ -134,19 +217,39 @@ CHAR8 *
 NextSupportedLanguage (\r
   IN CHAR8                *Languages\r
   )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Step to next language code of a language code list.\r
+\r
+Arguments:\r
+\r
+  Languages - The language code list to traverse.\r
+\r
+Returns:\r
+\r
+  Pointer to next language code or NULL terminator if it's the last one.\r
+\r
+--*/\r
 {\r
-#ifdef LANGUAGE_RFC_3066   // LANGUAGE_RFC_3066\r
-  for (; (*Languages != 0) && (*Languages != ';'); Languages++)\r
-    ;\r
+  UINTN    Index;\r
 \r
-  if (*Languages == ';') {\r
-    Languages++;\r
+  if (IsIso639LanguageCode (Languages)) {\r
+    //\r
+    // ISO639-2 language code\r
+    //\r
+    return (Languages + 3);\r
   }\r
 \r
-  return Languages;\r
-#else                      // LANGUAGE_ISO_639_2\r
-  return (Languages + 3);\r
-#endif\r
+  //\r
+  // Search in RFC4646 language code list\r
+  //\r
+  for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);\r
+  if (Languages[Index] == ';') {\r
+    Index++;\r
+  }\r
+  return (Languages + Index);\r
 }\r
 \r
 EFI_STATUS\r
@@ -217,7 +320,7 @@ Returns:
       return EFI_UNSUPPORTED;\r
     }\r
 \r
-    SupportedLanguages = NextSupportedLanguage(SupportedLanguages);\r
+    SupportedLanguages = NextSupportedLanguage (SupportedLanguages);\r
   }\r
 \r
   return EFI_UNSUPPORTED;\r
@@ -326,7 +429,7 @@ Returns:
       //\r
       // Allocate space for a copy of the Language specifier\r
       //\r
-      NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrLen(Language) + 1, Language);\r
+      NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrSize (Language), Language);\r
       if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
         gBS->FreePool (NewUnicodeStringTable);\r
         return EFI_OUT_OF_RESOURCES;\r
@@ -372,7 +475,7 @@ Returns:
       return EFI_SUCCESS;\r
     }\r
 \r
-    SupportedLanguages = NextSupportedLanguage(SupportedLanguages);\r
+    SupportedLanguages = NextSupportedLanguage (SupportedLanguages);\r
   }\r
 \r
   return EFI_UNSUPPORTED;\r
index 547c203a832ad9f907deefdfd5f616f860a25bba..e5b84d205a49ca333ad74644fe23ab745079f99c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -19,12 +19,85 @@ Abstract:
 \r
 #include "Tiano.h"\r
 #include "EfiDriverLib.h"\r
+#include "PeiHob.h"\r
 #include EFI_PROTOCOL_DEFINITION (DevicePath)\r
+#include EFI_GUID_DEFINITION (Hob)\r
 #include EFI_GUID_DEFINITION (StatusCodeDataTypeId)\r
 #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-STATIC EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+\r
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;\r
+\r
+VOID\r
+EFIAPI\r
+OnStatusCodeInstall (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_STATUS_CODE_PROTOCOL  *StatusCode;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);\r
+  if (!EFI_ERROR (Status)) {\r
+    gReportStatusCode = StatusCode->ReportStatusCode;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+GetPeiProtocol (\r
+  IN EFI_GUID  *ProtocolGuid,\r
+  IN VOID      **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Searches for a Protocol Interface passed from PEI through a HOB\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid - The Protocol GUID to search for in the HOB List\r
+  Interface    - A pointer to the interface for the Protocol GUID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - The Protocol GUID was found and its interface is returned in Interface\r
+  EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  //\r
+  // Get Hob list\r
+  //\r
+  Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **)  &GuidHob.Raw);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {\r
+    if (END_OF_HOB_LIST (GuidHob)) {\r
+      Status = EFI_NOT_FOUND;\r
+      break;\r
+    }\r
+\r
+    if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
+      if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {\r
+        Status     = EFI_SUCCESS;\r
+        *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+      }\r
+    }\r
+\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
 #endif\r
 \r
 EFI_STATUS\r
@@ -59,18 +132,28 @@ Returns:
 {\r
   EFI_STATUS  Status;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
-  if (gStatusCode == NULL) {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  if (gReportStatusCode == NULL) {\r
+    //\r
+    // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,\r
+    //   running here indicates that the StatusCode driver has not started yet.\r
+    //\r
     if (gBS == NULL) {\r
+      //\r
+      // Running here only when StatusCode driver never starts.\r
+      //\r
       return EFI_UNSUPPORTED;\r
     }\r
-    Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-    if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
+\r
+    //\r
+    // Try to get the PEI version of ReportStatusCode.\r
+    //      \r
+    Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);\r
+    if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
   }\r
-  Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data);\r
-  return Status;\r
+  Status = gReportStatusCode (Type, Value, Instance, CallerId, Data);\r
 #else\r
   if (gRT == NULL) {\r
     return EFI_UNSUPPORTED;\r
@@ -84,8 +167,8 @@ Returns:
       gRT->ReportStatusCode != NULL) {\r
     Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data);\r
   }\r
-  return Status;\r
 #endif\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
index 63e09d0087f3921c2a8d0adb4d59a37a21c5c1e7..5cbbe02104864cf5cb671915c0455ec5df708a47 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-# Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2004 - 2010, 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
@@ -41,7 +41,6 @@ COMPONENT_TYPE      = LIBRARY
   $(EDK_SOURCE)/Foundation/Include/IndustryStandard\r
   $(EDK_SOURCE)/Foundation/Core/Dxe\r
   $(EDK_SOURCE)/Foundation/Library/Dxe/Include\r
-  $(EDK_SOURCE)/Foundation/Library/Dxe/EfiDriverLib\r
 \r
 [libraries.common]\r
   EfiGuidLib\r
index 47b084e09b1e9cc26c53edec74ad944541a65aab..a6b7f06a508d1bd9c2d1bded86a2974baa3fd8ec 100644 (file)
@@ -30,7 +30,6 @@ COMPONENT_TYPE      = LIBRARY
 [includes.common]\r
   $(EDK_SOURCE)/Foundation/Framework\r
   $(EDK_SOURCE)/Foundation/Efi\r
-#  $(EFI_SOURCE)/Framework\r
   .\r
   $(EDK_SOURCE)/Foundation/Include\r
   $(EDK_SOURCE)/Foundation/Efi/Include\r
index b913d3fac2a83a1b7954fb56a98eb80eb811d96b..9d4260768c3f10569c94a25c641d9ff86e494457 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -23,7 +23,6 @@ Revision History:
 \r
 #define IS_DIGIT(Ch)  (((Ch) >= L'0') && ((Ch) <= L'9'))\r
 \r
-STATIC\r
 EFI_STATUS\r
 EfiStringToValue (\r
   OUT UINT64        *Val,\r
@@ -37,8 +36,6 @@ Routine Description:
   The returned value is 64-bit.\r
   The string is expected in decimal format,\r
   the string is parsed and format verified.\r
-  This function is missing from the libs. One day it maybe\r
-  replaced with a lib function when it'll become available.\r
 \r
 Arguments:\r
   Val    - pointer to the variable to store the value to\r
index bd8de3a1cfb9465dea1e7b75584208627df035c6..c417242552662a9a451d3b9abbac96ab3f467256 100644 (file)
@@ -106,10 +106,8 @@ typedef struct {
   CHAR16  *UnicodeString;\r
 } EFI_UNICODE_STRING_TABLE;\r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-#define LANGUAGE_RFC_3066\r
 #define LANGUAGE_CODE_ENGLISH    "en-US"\r
 #else\r
-#define LANGUAGE_ISO_639_2\r
 #define LANGUAGE_CODE_ENGLISH    "eng"\r
 #endif\r
 \r
@@ -1179,13 +1177,6 @@ EfiInitializeFwVolDevicepathNode (
 Routine Description:\r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability.\r
-\r
 Arguments:\r
   FvDevicePathNode   - Pointer to a FV device path node to initialize\r
   NameGuid           - FV file name to use in FvDevicePathNode\r
@@ -1202,15 +1193,6 @@ EfiGetNameGuidFromFwVolDevicePathNode (
 Routine Description:\r
   Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability. The return value to this\r
-  function points to a location in FvDevicePathNode and it does not allocate\r
-  new memory for the GUID pointer that is returned.\r
-\r
 Arguments:\r
   FvDevicePathNode   - Pointer to FV device path to check\r
 \r
index 7cfeffe5fb66d80e03030ef16bcb6ea6855b81b5..946742cb17d19adbc163de8580e302b21a1c8a1f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -202,4 +202,33 @@ Returns:
 --*/\r
 ;\r
 \r
+EFI_STATUS\r
+EfiStringToValue (\r
+  OUT UINT64        *Val,\r
+  IN  CHAR16        *String,\r
+  OUT UINT8         *EndIdx OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Parses and converts Unicode string to decimal value.\r
+  The returned value is 64-bit.\r
+  The string is expected in decimal format,\r
+  the string is parsed and format verified.\r
+\r
+Arguments:\r
+  Val    - pointer to the variable to store the value to\r
+  String - string that contains the value to parse and convert\r
+  EndIdx - index on which the parsing stopped. It points to the\r
+           first character that was not part of the returned Val.\r
+           It's valid only if the function returns success.\r
+           It's optional and it could be NULL.\r
+\r
+Returns:\r
+  EFI_SUCCESS           - if successful\r
+  EFI_INVALID_PARAMETER - if String is in unexpected format\r
+\r
+--*/\r
+;\r
+\r
 #endif\r
index c70fb87e7942303b90b314eefe339680e6a37b1f..ae771b13a5710e2915a92990795bc6c57416a84a 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2010, 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
@@ -41,7 +41,6 @@ COMPONENT_TYPE      = LIBRARY
   $(EDK_SOURCE)/Foundation/Include/IndustryStandard\r
   $(EDK_SOURCE)/Foundation/Core/Dxe\r
   $(EDK_SOURCE)/Foundation/Library/Dxe/Include\r
-  $(EDK_SOURCE)/Foundation/Library/Dxe/EfiDriverLib\r
 \r
 [libraries.common]\r
   EfiGuidLib\r
index 90afafe83721df7d5243e31d9264e77d458ffb21..c41a85c38da223264d0ef7621fbdfe05b86c0f80 100644 (file)
@@ -37,6 +37,7 @@ HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePathTemplate = {
       },\r
       EFI_IFR_TIANO_GUID,\r
     },\r
+    0,\r
     0\r
   },\r
   {\r
@@ -181,22 +182,23 @@ Returns:
 {\r
   EFI_STATUS                   Status;\r
   HII_VENDOR_DEVICE_PATH_NODE  *VendorDevicePath;\r
-  UINT64                       MonotonicCount;\r
 \r
   VendorDevicePath = EfiLibAllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);\r
   if (VendorDevicePath == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  gBS->GetNextMonotonicCount (&MonotonicCount);\r
-  VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;\r
+  //\r
+  // Use memory address as unique ID to distinguish from different device paths\r
+  //\r
+  VendorDevicePath->UniqueId = (UINT64) ((UINTN) VendorDevicePath);\r
 \r
   *DriverHandle = NULL;\r
-  Status = gBS->InstallProtocolInterface (\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
                   DriverHandle,\r
                   &gEfiDevicePathProtocolGuid,\r
-                  EFI_NATIVE_INTERFACE,\r
-                  VendorDevicePath\r
+                  VendorDevicePath,\r
+                  NULL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -240,7 +242,7 @@ Returns:
                   &gEfiDevicePathProtocolGuid,\r
                   DevicePath\r
                   );\r
-\r
+  gBS->FreePool (DevicePath);\r
   return Status;\r
 }\r
 \r
@@ -511,6 +513,7 @@ Arguments:
 \r
 Returns:\r
   EFI_SUCCESS     - Successfully extract Class for specified Hii handle.\r
+  EFI_NOT_FOUND   - Class not found.\r
 \r
 --*/\r
 {\r
@@ -525,10 +528,12 @@ Returns:
   UINT32                       Offset2;\r
   UINT32                       PackageListLength;\r
   EFI_HII_PACKAGE_HEADER       PackageHeader;\r
+  BOOLEAN                      ClassFound;\r
 \r
   *Class = EFI_NON_DEVICE_CLASS;\r
   *FormSetTitle = 0;\r
   *FormSetHelp = 0;\r
+  ClassFound = FALSE;\r
 \r
   //\r
   // Locate HII Database protocol\r
@@ -574,7 +579,7 @@ Returns:
     Package = ((UINT8 *) HiiPackageList) + Offset;\r
     EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
 \r
-    if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {\r
+    if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {\r
       //\r
       // Search Class Opcode in this Form Package\r
       //\r
@@ -602,6 +607,139 @@ Returns:
           //\r
           // Till now, we ought to have found the formset Opcode\r
           //\r
+          ClassFound = TRUE;\r
+          break;\r
+        }\r
+\r
+        Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;\r
+      }\r
+\r
+      if (Offset2 < PackageHeader.Length) {\r
+        //\r
+        // Target formset found\r
+        //\r
+        break;\r
+      }\r
+    }\r
+\r
+    Offset += PackageHeader.Length;\r
+  }\r
+\r
+  gBS->FreePool (HiiPackageList);\r
+\r
+  return ClassFound ? EFI_SUCCESS : EFI_NOT_FOUND;\r
+}\r
+\r
+EFI_STATUS\r
+ExtractClassGuidFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      Handle,\r
+  OUT     UINT8               *NumberOfClassGuid,\r
+  OUT     EFI_GUID            **ClassGuid,\r
+  OUT     EFI_STRING_ID       *FormSetTitle,\r
+  OUT     EFI_STRING_ID       *FormSetHelp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Extract formset ClassGuid for given HII handle.\r
+\r
+Arguments:\r
+  HiiHandle         - Hii handle\r
+  NumberOfClassGuid - Number of ClassGuid\r
+  ClassGuid         - Pointer to callee allocated buffer, an array of ClassGuid\r
+  FormSetTitle      - Formset title string\r
+  FormSetHelp       - Formset help string\r
+\r
+Returns:\r
+  EFI_SUCCESS     - Successfully extract Class for specified Hii handle.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                   Status;\r
+  UINTN                        BufferSize;\r
+  EFI_HII_DATABASE_PROTOCOL    *HiiDatabase;\r
+  EFI_HII_PACKAGE_LIST_HEADER  *HiiPackageList;\r
+  UINT8                        *Package;\r
+  UINT8                        *FormSet;\r
+  UINT8                        *OpCodeData;\r
+  UINT32                       Offset;\r
+  UINT32                       Offset2;\r
+  UINT32                       PackageListLength;\r
+  EFI_HII_PACKAGE_HEADER       PackageHeader;\r
+\r
+  if (NumberOfClassGuid == NULL || ClassGuid == NULL || FormSetTitle == NULL || FormSetHelp == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *NumberOfClassGuid = 0;\r
+  *ClassGuid = NULL;\r
+  *FormSetTitle = 0;\r
+  *FormSetHelp = 0;\r
+\r
+  //\r
+  // Locate HII Database protocol\r
+  //\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiHiiDatabaseProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &HiiDatabase\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get HII PackageList\r
+  //\r
+  BufferSize = 0;\r
+  HiiPackageList = NULL;\r
+  Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    HiiPackageList = EfiLibAllocatePool (BufferSize);\r
+    ASSERT (HiiPackageList != NULL);\r
+\r
+    Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);\r
+  }\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get Form package from this HII package List\r
+  //\r
+  Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+  Offset2 = 0;\r
+  FormSet = NULL;\r
+  EfiCopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));\r
+\r
+  while (Offset < PackageListLength) {\r
+    Package = ((UINT8 *) HiiPackageList) + Offset;\r
+    EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
+\r
+    if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {\r
+      //\r
+      // Search Class Opcode in this Form Package\r
+      //\r
+      Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);\r
+      while (Offset2 < PackageHeader.Length) {\r
+        OpCodeData = Package + Offset2;\r
+\r
+        if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {\r
+          //\r
+          // Find FormSet OpCode\r
+          //\r
+          EfiCopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));\r
+          EfiCopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));\r
+          if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > ((UINTN) &((EFI_IFR_FORM_SET *) 0)->Flags)) {\r
+            //\r
+            // New version of formset OpCode\r
+            //\r
+            *NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);\r
+            *ClassGuid = EfiLibAllocateCopyPool (\r
+                           *NumberOfClassGuid * sizeof (EFI_GUID),\r
+                           ((EFI_IFR_FORM_SET *) OpCodeData)->ClassGuid\r
+                           );\r
+          }\r
           break;\r
         }\r
 \r
index fbb46075c482ea03ed5af73d83ce30786e425518..355935322c5c0cc87d7d657e3024f27448c2ae43 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -26,7 +26,6 @@ Abstract:
 //\r
 UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0";\r
 \r
-STATIC\r
 EFI_STATUS\r
 GetPackageDataFromPackageList (\r
   IN  EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,\r
@@ -72,7 +71,6 @@ GetPackageDataFromPackageList (
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
 EFI_STATUS\r
 UpdateFormPackageData (\r
   IN  EFI_GUID               *FormSetGuid,\r
@@ -86,17 +84,15 @@ UpdateFormPackageData (
   OUT UINT32                 *TempBufferSize\r
   )\r
 {\r
-  UINTN                     AddSize;\r
   UINT8                     *BufferPos;\r
   EFI_HII_PACKAGE_HEADER    PackageHeader;\r
-  UINT                    Offset;\r
+  UINT32                    Offset;\r
   EFI_IFR_OP_HEADER         *IfrOpHdr;\r
   BOOLEAN                   GetFormSet;\r
   BOOLEAN                   GetForm;\r
   UINT8                     ExtendOpCode;\r
   UINT16                    LabelNumber;\r
   BOOLEAN                   Updated;\r
-  EFI_IFR_OP_HEADER         *AddOpCode;\r
 \r
   if ((TempBuffer == NULL) || (TempBufferSize == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -122,7 +118,7 @@ UpdateFormPackageData (
   GetForm    = FALSE;\r
   Updated    = FALSE;\r
 \r
-  while (Offset < PackageHeader.Length) {\r
+  while (!Updated && Offset < PackageHeader.Length) {\r
     EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);\r
     BufferPos += IfrOpHdr->Length;\r
     *TempBufferSize += IfrOpHdr->Length;\r
@@ -132,6 +128,8 @@ UpdateFormPackageData (
       if (FormSetGuid != NULL) {\r
         if (EfiCompareMem (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {\r
           GetFormSet = TRUE;\r
+        } else {\r
+          GetFormSet = FALSE;\r
         }\r
       }\r
       break;\r
@@ -139,17 +137,24 @@ UpdateFormPackageData (
     case EFI_IFR_FORM_OP:\r
       if (EfiCompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {\r
         GetForm = TRUE;\r
+      } else {\r
+        GetForm = FALSE;\r
       }\r
       break;\r
 \r
     case EFI_IFR_GUID_OP :\r
-      if (!GetFormSet || !GetForm || Updated) {\r
+      if (!GetFormSet || !GetForm) {\r
         //\r
         // Go to the next Op-Code\r
         //\r
-        Offset   += IfrOpHdr->Length;\r
-        IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
-        continue;\r
+        break;\r
+      }\r
+\r
+      if (!EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid)) {\r
+        //\r
+        // GUID mismatch, skip this op-code\r
+        //\r
+        break;\r
       }\r
 \r
       ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;\r
@@ -158,29 +163,18 @@ UpdateFormPackageData (
         //\r
         // Go to the next Op-Code\r
         //\r
-        Offset   += IfrOpHdr->Length;\r
-        IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
-        continue;\r
+        break;\r
       }\r
 \r
-      if (Insert && (Data != NULL)) {\r
+      if (Insert) {\r
         //\r
-        // insert the DataCount amount of opcodes to TempBuffer if Data is NULL remove\r
-        // DataCount amount of opcodes unless runing into a label.\r
+        // Insert data after current Label, skip myself\r
         //\r
-        AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;\r
-        AddSize   = 0;\r
-        while (AddSize < Data->Offset) {\r
-          EfiCopyMem (BufferPos, AddOpCode, AddOpCode->Length);\r
-          BufferPos += AddOpCode->Length;\r
-          *TempBufferSize += AddOpCode->Length;\r
-\r
-          AddSize += AddOpCode->Length;\r
-          AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);\r
-        }\r
+        Offset   += IfrOpHdr->Length;\r
+        IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
       } else {\r
         //\r
-        // Search the next Label.\r
+        // Replace data between two paired Label, try to find the next Label.\r
         //\r
         while (TRUE) {\r
           Offset   += IfrOpHdr->Length;\r
@@ -193,33 +187,28 @@ UpdateFormPackageData (
           IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);\r
           if (IfrOpHdr->OpCode == EFI_IFR_GUID_OP) {\r
             ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;\r
-            if (ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {\r
+            if (EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid) && ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {\r
               break;\r
             }\r
           }\r
         }\r
+      }\r
 \r
-        if (Data != NULL) {\r
-          AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;\r
-          AddSize   = 0;\r
-          while (AddSize < Data->Offset) {\r
-            EfiCopyMem (BufferPos, AddOpCode, AddOpCode->Length);\r
-            BufferPos += AddOpCode->Length;\r
-            *TempBufferSize += AddOpCode->Length;\r
-\r
-            AddSize   += AddOpCode->Length;\r
-            AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);\r
-          }\r
-        }\r
-\r
-        //\r
-        // copy the next label\r
-        //\r
-        EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);\r
-        BufferPos += IfrOpHdr->Length;\r
-        *TempBufferSize += IfrOpHdr->Length;\r
+      //\r
+      // Fill in the update data\r
+      //\r
+      if (Data != NULL) {\r
+        EfiCopyMem (BufferPos, Data->Data, Data->Offset);\r
+        BufferPos += Data->Offset;\r
+        *TempBufferSize += Data->Offset;\r
       }\r
 \r
+      //\r
+      // Copy the reset data\r
+      //\r
+      EfiCopyMem (BufferPos, IfrOpHdr, PackageHeader.Length - Offset);\r
+      *TempBufferSize += PackageHeader.Length - Offset;\r
+\r
       Updated = TRUE;\r
       break;\r
     default :\r
@@ -249,6 +238,68 @@ Fail:
   return EFI_SUCCESS;\r
 }\r
 \r
+EFI_STATUS\r
+IfrLibInitUpdateData (\r
+  IN OUT EFI_HII_UPDATE_DATA   *UpdateData,\r
+  IN UINT32                    BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function initialize the data structure for dynamic opcode.\r
+\r
+Arguments:\r
+  UpdateData     - The adding data;\r
+  BufferSize     - Length of the buffer to fill dynamic opcodes.\r
+\r
+Returns:\r
+  EFI_SUCCESS           - Update data is initialized.\r
+  EFI_INVALID_PARAMETER - UpdateData is NULL.\r
+  EFI_OUT_OF_RESOURCES  - No enough memory to allocate.\r
+\r
+--*/\r
+{\r
+  if (UpdateData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  UpdateData->BufferSize = BufferSize;\r
+  UpdateData->Offset = 0;\r
+  UpdateData->Data = EfiLibAllocatePool (BufferSize);\r
+\r
+  return (UpdateData->Data != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;\r
+}\r
+\r
+EFI_STATUS\r
+IfrLibFreeUpdateData (\r
+  IN EFI_HII_UPDATE_DATA       *UpdateData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function free the resource of update data.\r
+\r
+Arguments:\r
+  UpdateData     - The adding data;\r
+\r
+Returns:\r
+  EFI_SUCCESS           - Resource in UpdateData is released.\r
+  EFI_INVALID_PARAMETER - UpdateData is NULL.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  if (UpdateData == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  Status = gBS->FreePool (UpdateData->Data);\r
+  UpdateData->Data = NULL;\r
+\r
+  return Status;\r
+}\r
+\r
 EFI_STATUS\r
 IfrLibUpdateForm (\r
   IN EFI_HII_HANDLE            Handle,\r
@@ -339,7 +390,7 @@ Returns:
     Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);\r
     if (Status == EFI_SUCCESS) {\r
       EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));\r
-      if ((PackageHeader.Type == EFI_HII_PACKAGE_FORM) && !Updated) {\r
+      if ((PackageHeader.Type == EFI_HII_PACKAGE_FORMS) && !Updated) {\r
         Status = UpdateFormPackageData (FormSetGuid, FormId, Package, PackageLength, Label, Insert, Data, (UINT8 **)&TempBuffer, &TempBufferSize);\r
         if (!EFI_ERROR(Status)) {\r
           if (FormSetGuid == NULL) {\r
@@ -644,7 +695,376 @@ ExtractDefault(
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
+EFI_STATUS\r
+ExtractBlockName (\r
+  IN UINT8                        *Buffer,\r
+  OUT CHAR16                      **BlockName\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Extract block name from the array generated by VFR compiler. The name of\r
+  this array is "Vfr + <StorageName> + BlockName", e.g. "VfrMyIfrNVDataBlockName".\r
+  Format of this array is:\r
+     Array length | 4-bytes\r
+       Offset     | 2-bytes\r
+       Width      | 2-bytes\r
+       Offset     | 2-bytes\r
+       Width      | 2-bytes\r
+       ... ...\r
+\r
+  Arguments:\r
+    Buffer                - Array generated by VFR compiler.\r
+    BlockName             - The returned <BlockName>\r
+\r
+  Returns:\r
+    EFI_OUT_OF_RESOURCES  - Run out of memory resource.\r
+    EFI_INVALID_PARAMETER - Buffer is NULL or BlockName is NULL.\r
+    EFI_SUCCESS           - Operation successful.\r
+\r
+--*/\r
+{\r
+  UINTN       Index;\r
+  UINT32      Length;\r
+  UINT32      BlockNameNumber;\r
+  UINTN       HexStringBufferLen;\r
+  CHAR16      *StringPtr;\r
+\r
+  if ((Buffer == NULL) || (BlockName == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Calculate number of Offset/Width pair\r
+  //\r
+  EfiCopyMem (&Length, Buffer, sizeof (UINT32));\r
+  BlockNameNumber = (Length - sizeof (UINT32)) / (sizeof (UINT16) * 2);\r
+\r
+  //\r
+  // <BlockName> ::= &OFFSET=1234&WIDTH=1234\r
+  //                 |   8  | 4 |  7   | 4 |\r
+  //\r
+  StringPtr = EfiLibAllocateZeroPool ((BlockNameNumber * (8 + 4 + 7 + 4) + 1) * sizeof (CHAR16));\r
+  *BlockName = StringPtr;\r
+  if (StringPtr == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Buffer += sizeof (UINT32);\r
+  for (Index = 0; Index < BlockNameNumber; Index++) {\r
+    EfiStrCpy (StringPtr, L"&OFFSET=");\r
+    StringPtr += 8;\r
+\r
+    HexStringBufferLen = 5;\r
+    BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));\r
+    Buffer += sizeof (UINT16);\r
+    StringPtr += 4;\r
+\r
+    EfiStrCpy (StringPtr, L"&WIDTH=");\r
+    StringPtr += 7;\r
+\r
+    HexStringBufferLen = 5;\r
+    BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));\r
+    Buffer += sizeof (UINT16);\r
+    StringPtr += 4;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ExtractBlockConfig (\r
+  IN UINT8                        *Buffer,\r
+  OUT CHAR16                      **BlockConfig\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+    Extract block config from the array generated by VFR compiler. The name of\r
+  this array is "Vfr + <StorageName> + Default<HexCh>4", e.g. "VfrMyIfrNVDataDefault0000".\r
+\r
+  Arguments:\r
+    Buffer                - Array generated by VFR compiler.\r
+    BlockConfig           - The returned <BlockConfig>\r
+\r
+  Returns:\r
+    EFI_OUT_OF_RESOURCES  - Run out of memory resource.\r
+    EFI_INVALID_PARAMETER - Buffer is NULL or BlockConfig is NULL.\r
+    EFI_SUCCESS           - Operation successful.\r
+\r
+--*/\r
+{\r
+  UINT32      Length;\r
+  UINT16      Width;\r
+  UINTN       HexStringBufferLen;\r
+  CHAR16      *StringPtr;\r
+  UINT8       *BufferEnd;\r
+  CHAR16      *StringEnd;\r
+  EFI_STATUS  Status;\r
+\r
+  if ((Buffer == NULL) || (BlockConfig == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Calculate length of AltResp string\r
+  // Format of Default value array is:\r
+  //  Array length | 4-bytes\r
+  //        Offset | 2-bytes\r
+  //        Width  | 2-bytes\r
+  //        Value  | Variable length\r
+  //        Offset | 2-bytes\r
+  //        Width  | 2-bytes\r
+  //        Value  | Variable length\r
+  //        ... ...\r
+  // When value is 1 byte in length, overhead of AltResp string will be maximum,\r
+  //  BlockConfig ::= <&OFFSET=1234&WIDTH=1234&VALUE=12>+\r
+  //                   |   8   | 4  |  7   | 4 |  7  |2|\r
+  // so the maximum length of BlockConfig could be calculated as:\r
+  // (ArrayLength / 5) * (8 + 4 + 7 + 4 + 7 + 2) = ArrayLength * 6.4 < ArrayLength * 7\r
+  //\r
+  EfiCopyMem (&Length, Buffer, sizeof (UINT32));\r
+  BufferEnd = Buffer + Length;\r
+  StringPtr = EfiLibAllocatePool (Length * 7 * sizeof (CHAR16));\r
+  *BlockConfig = StringPtr;\r
+  if (StringPtr == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  StringEnd = StringPtr + (Length * 7);\r
+\r
+  Buffer += sizeof (UINT32);\r
+  while (Buffer < BufferEnd) {\r
+    EfiStrCpy (StringPtr, L"&OFFSET=");\r
+    StringPtr += 8;\r
+\r
+    HexStringBufferLen = 5;\r
+    BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));\r
+    Buffer += sizeof (UINT16);\r
+    StringPtr += 4;\r
+\r
+    EfiStrCpy (StringPtr, L"&WIDTH=");\r
+    StringPtr += 7;\r
+\r
+    HexStringBufferLen = 5;\r
+    BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));\r
+    EfiCopyMem (&Width, Buffer, sizeof (UINT16));\r
+    Buffer += sizeof (UINT16);\r
+    StringPtr += 4;\r
+\r
+    EfiStrCpy (StringPtr, L"&VALUE=");\r
+    StringPtr += 7;\r
+\r
+    HexStringBufferLen = StringEnd - StringPtr;\r
+    Status = BufToHexString (StringPtr, &HexStringBufferLen, Buffer, Width);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    Buffer += Width;\r
+    StringPtr += (Width * 2);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+ConstructConfigAltResp (\r
+  IN  EFI_STRING                  ConfigRequest,  OPTIONAL\r
+  OUT EFI_STRING                  *Progress,\r
+  OUT EFI_STRING                  *ConfigAltResp,\r
+  IN  EFI_GUID                    *Guid,\r
+  IN  CHAR16                      *Name,\r
+  IN  EFI_HANDLE                  *DriverHandle,\r
+  IN  VOID                        *BufferStorage,\r
+  IN  UINTN                       BufferStorageSize,\r
+  IN  VOID                        *BlockNameArray, OPTIONAL\r
+  IN  UINTN                       NumberAltCfg,\r
+  ...\r
+//IN  UINT16                      AltCfgId,\r
+//IN  VOID                        *DefaultValueArray,\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+  Construct <ConfigAltResp> for a buffer storage.\r
+\r
+  Arguments:\r
+    ConfigRequest         - The Config request string. If set to NULL, all the\r
+                            configurable elements will be extracted from BlockNameArray.\r
+    ConfigAltResp         - The returned <ConfigAltResp>.\r
+    Progress              - On return, points to a character in the Request.\r
+    Guid                  - GUID of the buffer storage.\r
+    Name                  - Name of the buffer storage.\r
+    DriverHandle          - The DriverHandle which is used to invoke HiiDatabase\r
+                            protocol interface NewPackageList().\r
+    BufferStorage         - Content of the buffer storage.\r
+    BufferStorageSize     - Length in bytes of the buffer storage.\r
+    BlockNameArray        - Array generated by VFR compiler.\r
+    NumberAltCfg          - Number of Default value array generated by VFR compiler.\r
+                            The sequential input parameters will be number of\r
+                            AltCfgId and DefaultValueArray pairs. When set to 0,\r
+                            there will be no <AltResp>.\r
+\r
+  Returns:\r
+    EFI_OUT_OF_RESOURCES  - Run out of memory resource.\r
+    EFI_INVALID_PARAMETER - ConfigAltResp is NULL.\r
+    EFI_SUCCESS           - Operation successful.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS                      Status;\r
+  CHAR16                          *ConfigHdr;\r
+  CHAR16                          *BlockName;\r
+  CHAR16                          *DescHdr;\r
+  CHAR16                          *StringPtr;\r
+  CHAR16                          **AltCfg;\r
+  UINT16                          AltCfgId;\r
+  VOID                            *DefaultValueArray;\r
+  UINTN                           StrBufferLen;\r
+  EFI_STRING                      ConfigResp;\r
+  EFI_STRING                      TempStr;\r
+  VA_LIST                         Args;\r
+  UINTN                           AltRespLen;\r
+  UINTN                           Index;\r
+  BOOLEAN                         NeedFreeConfigRequest;\r
+  EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
+\r
+  if (ConfigAltResp == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."\r
+  //\r
+  ConfigHdr = NULL;\r
+  StrBufferLen = 0;\r
+  Status = ConstructConfigHdr (\r
+             ConfigHdr,\r
+             &StrBufferLen,\r
+             Guid,\r
+             Name,\r
+             DriverHandle\r
+             );\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    ConfigHdr = EfiLibAllocateZeroPool (StrBufferLen);\r
+    Status = ConstructConfigHdr (\r
+               ConfigHdr,\r
+               &StrBufferLen,\r
+               Guid,\r
+               Name,\r
+               DriverHandle\r
+               );\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Construct <ConfigResp>\r
+  //\r
+  NeedFreeConfigRequest = FALSE;\r
+  if (ConfigRequest == NULL) {\r
+    //\r
+    // If ConfigRequest is set to NULL, export all configurable elements in BlockNameArray\r
+    //\r
+    Status = ExtractBlockName (BlockNameArray, &BlockName);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
+    StrBufferLen = EfiStrSize (ConfigHdr);\r
+    StrBufferLen = StrBufferLen + EfiStrSize (BlockName) - sizeof (CHAR16);\r
+    ConfigRequest = EfiLibAllocateZeroPool (StrBufferLen);\r
+    EfiStrCpy (ConfigRequest, ConfigHdr);\r
+    EfiStrCat (ConfigRequest, BlockName);\r
+    NeedFreeConfigRequest = TRUE;\r
+  }\r
+\r
+  Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = HiiConfigRouting->BlockToConfig (\r
+                               HiiConfigRouting,\r
+                               ConfigRequest,\r
+                               BufferStorage,\r
+                               BufferStorageSize,\r
+                               &ConfigResp,\r
+                               (Progress == NULL) ? &TempStr : Progress\r
+                               );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Construct <AltResp>\r
+  //\r
+  DescHdr = EfiLibAllocateZeroPool (NumberAltCfg * 16 * sizeof (CHAR16));\r
+  StringPtr = DescHdr;\r
+  AltCfg = EfiLibAllocateZeroPool (NumberAltCfg * sizeof (CHAR16 *));\r
+  AltRespLen = 0;\r
+  VA_START (Args, NumberAltCfg);\r
+  for (Index = 0; Index < NumberAltCfg; Index++) {\r
+    AltCfgId = (UINT16) VA_ARG (Args, UINT16);\r
+    DefaultValueArray = (UINT8 *) VA_ARG (Args, VOID *);\r
+\r
+    //\r
+    // '&' <ConfigHdr>\r
+    //\r
+    AltRespLen += (EfiStrLen (ConfigHdr) + 1);\r
+\r
+    StringPtr = DescHdr + Index * 16;\r
+    EfiStrCpy (StringPtr, L"&ALTCFG=");\r
+    AltRespLen += (8 + sizeof (UINT16) * 2);\r
+\r
+    StrBufferLen = 5;\r
+    BufToHexString (StringPtr + 8, &StrBufferLen, (UINT8 *) &AltCfgId, sizeof (UINT16));\r
+    Status = ExtractBlockConfig (DefaultValueArray, &AltCfg[Index]);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    AltRespLen += EfiStrLen (AltCfg[Index]);\r
+  }\r
+  VA_END (Args);\r
+\r
+  //\r
+  // Generate the final <ConfigAltResp>\r
+  //\r
+  StrBufferLen = (EfiStrLen ((CHAR16 *) ConfigResp) + AltRespLen + 1) * sizeof (CHAR16);\r
+  TempStr = EfiLibAllocateZeroPool (StrBufferLen);\r
+  *ConfigAltResp = TempStr;\r
+  if (TempStr == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  //\r
+  // <ConfigAltResp> ::= <ConfigResp> ['&' <AltResp>]*\r
+  //\r
+  EfiStrCpy (TempStr, ConfigResp);\r
+  for (Index = 0; Index < NumberAltCfg; Index++) {\r
+    EfiStrCat (TempStr, L"&");\r
+    EfiStrCat (TempStr, ConfigHdr);\r
+    EfiStrCat (TempStr, DescHdr + Index * 16);\r
+    EfiStrCat (TempStr, AltCfg[Index]);\r
+\r
+    gBS->FreePool (AltCfg[Index]);\r
+  }\r
+\r
+  if (NeedFreeConfigRequest) {\r
+    gBS->FreePool (ConfigRequest);\r
+  }\r
+  gBS->FreePool (ConfigHdr);\r
+  gBS->FreePool (ConfigResp);\r
+  gBS->FreePool (DescHdr);\r
+  gBS->FreePool (AltCfg);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 VOID\r
 SwapBuffer (\r
   IN OUT UINT8     *Buffer,\r
@@ -668,7 +1088,7 @@ Returns:
   UINT8  Temp;\r
   UINTN  SwapCount;\r
 \r
-  SwapCount = (BufferSize - 1) / 2;\r
+  SwapCount = BufferSize / 2;\r
   for (Index = 0; Index < SwapCount; Index++) {\r
     Temp = Buffer[Index];\r
     Buffer[Index] = Buffer[BufferSize - 1 - Index];\r
@@ -676,6 +1096,31 @@ Returns:
   }\r
 }\r
 \r
+VOID\r
+ToLower (\r
+  IN OUT CHAR16    *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts the unicode character of the string from uppercase to lowercase.\r
+\r
+Arguments:\r
+  Str        -  String to be converted\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  CHAR16      *Ptr;\r
+\r
+  for (Ptr = Str; *Ptr != L'\0'; Ptr++) {\r
+    if (*Ptr >= L'A' && *Ptr <= L'Z') {\r
+      *Ptr = (CHAR16) (*Ptr - L'A' + L'a');\r
+    }\r
+  }\r
+}\r
+\r
 EFI_STATUS\r
 BufferToHexString (\r
   IN OUT CHAR16    *Str,\r
@@ -704,10 +1149,14 @@ Returns:
   NewBuffer = EfiLibAllocateCopyPool (BufferSize, Buffer);\r
   SwapBuffer (NewBuffer, BufferSize);\r
 \r
-  StrBufferLen = (BufferSize + 1) * sizeof (CHAR16);\r
+  StrBufferLen = BufferSize * 2 + 1;\r
   Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);\r
 \r
   gBS->FreePool (NewBuffer);\r
+  //\r
+  // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.\r
+  //\r
+  ToLower (Str);\r
 \r
   return Status;\r
 }\r
@@ -741,12 +1190,138 @@ Returns:
   ConvertedStrLen = 0;\r
   Status = HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen);\r
   if (!EFI_ERROR (Status)) {\r
-    SwapBuffer (Buffer, ConvertedStrLen);\r
+    SwapBuffer (Buffer, (ConvertedStrLen + 1) / 2);\r
   }\r
 \r
   return Status;\r
 }\r
 \r
+EFI_STATUS\r
+ConfigStringToUnicode (\r
+  IN OUT CHAR16                *UnicodeString,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CHAR16                    *ConfigString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Convert binary representation Config string (e.g. "0041004200430044") to the\r
+  original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.\r
+  "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").\r
+\r
+Arguments:\r
+  UnicodeString - Original Unicode string.\r
+  StrBufferLen  - On input: Length in bytes of buffer to hold the Unicode string.\r
+                  Includes tailing '\0' character.\r
+                  On output:\r
+                    If return EFI_SUCCESS, containing length of Unicode string buffer.\r
+                    If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
+  ConfigString  - Binary representation of Unicode String, <string> := (<HexCh>4)+\r
+\r
+Returns:\r
+  EFI_SUCCESS          - Routine success.\r
+  EFI_BUFFER_TOO_SMALL - The string buffer is too small.\r
+\r
+--*/\r
+{\r
+  UINTN       Index;\r
+  UINTN       Len;\r
+  UINTN       BufferSize;\r
+  CHAR16      BackupChar;\r
+\r
+  Len = EfiStrLen (ConfigString) / 4;\r
+  BufferSize = (Len + 1) * sizeof (CHAR16);\r
+\r
+  if (*StrBufferLen < BufferSize) {\r
+    *StrBufferLen = BufferSize;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  *StrBufferLen = BufferSize;\r
+\r
+  for (Index = 0; Index < Len; Index++) {\r
+    BackupChar = ConfigString[4];\r
+    ConfigString[4] = L'\0';\r
+\r
+    HexStringToBuf ((UINT8 *) UnicodeString, &BufferSize, ConfigString, NULL);\r
+\r
+    ConfigString[4] = BackupChar;\r
+\r
+    ConfigString += 4;\r
+    UnicodeString += 1;\r
+  }\r
+\r
+  //\r
+  // Add tailing '\0' character\r
+  //\r
+  *UnicodeString = L'\0';\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+UnicodeToConfigString (\r
+  IN OUT CHAR16                *ConfigString,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CHAR16                    *UnicodeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Convert Unicode string to binary representation Config string, e.g.\r
+  "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.\r
+  "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").\r
+\r
+Arguments:\r
+  ConfigString  - Binary representation of Unicode String, <string> := (<HexCh>4)+\r
+  StrBufferLen  - On input: Length in bytes of buffer to hold the Unicode string.\r
+                  Includes tailing '\0' character.\r
+                  On output:\r
+                    If return EFI_SUCCESS, containing length of Unicode string buffer.\r
+                    If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
+  UnicodeString - Original Unicode string.\r
+\r
+Returns:\r
+  EFI_SUCCESS          - Routine success.\r
+  EFI_BUFFER_TOO_SMALL - The string buffer is too small.\r
+\r
+--*/\r
+{\r
+  UINTN       Index;\r
+  UINTN       Len;\r
+  UINTN       BufferSize;\r
+  CHAR16      *String;\r
+\r
+  Len = EfiStrLen (UnicodeString);\r
+  BufferSize = (Len * 4 + 1) * sizeof (CHAR16);\r
+\r
+  if (*StrBufferLen < BufferSize) {\r
+    *StrBufferLen = BufferSize;\r
+    return EFI_BUFFER_TOO_SMALL;\r
+  }\r
+\r
+  *StrBufferLen = BufferSize;\r
+  String        = ConfigString;\r
+\r
+  for (Index = 0; Index < Len; Index++) {\r
+    BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2);\r
+\r
+    ConfigString += 4;\r
+    UnicodeString += 1;\r
+  }\r
+\r
+  //\r
+  // Add tailing '\0' character\r
+  //\r
+  *ConfigString = L'\0';\r
+\r
+  //\r
+  // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.\r
+  //\r
+  ToLower (String);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 EFI_STATUS\r
 ConstructConfigHdr (\r
   IN OUT CHAR16                *ConfigHdr,\r
@@ -811,10 +1386,10 @@ Returns:
   DevicePathSize = EfiDevicePathSize (DevicePath);\r
 \r
   //\r
-  // GUID=<HexCh>32&NAME=<Alpha>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>\r
-  // | 5  |   32   |  6  |   NameStrLen   |  6  |    DevicePathStrLen   |\r
+  // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>\r
+  // | 5  |   32   |  6  |  NameStrLen*4 |  6  |    DevicePathStrLen    | 1 |\r
   //\r
-  BufferSize = (5 + 32 + 6 + NameStrLen + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);\r
+  BufferSize = (5 + 32 + 6 + NameStrLen * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);\r
   if (*StrBufferLen < BufferSize) {\r
     *StrBufferLen = BufferSize;\r
     return EFI_BUFFER_TOO_SMALL;\r
@@ -829,11 +1404,15 @@ Returns:
   BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));\r
   StrPtr += 32;\r
 \r
+  //\r
+  // Convert name string, e.g. name "ABCD" => "&NAME=0041004200430044"\r
+  //\r
   EfiStrCpy (StrPtr, L"&NAME=");\r
   StrPtr += 6;\r
   if (Name != NULL) {\r
-    EfiStrCpy (StrPtr, Name);\r
-    StrPtr += NameStrLen;\r
+    BufferSize = (NameStrLen * 4 + 1) * sizeof (CHAR16);\r
+    UnicodeToConfigString (StrPtr, &BufferSize, Name);\r
+    StrPtr += (NameStrLen * 4);\r
   }\r
 \r
   EfiStrCpy (StrPtr, L"&PATH=");\r
@@ -843,6 +1422,105 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+BOOLEAN\r
+IsConfigHdrMatch (\r
+  IN EFI_STRING                ConfigString,\r
+  IN EFI_GUID                  *StorageGuid, OPTIONAL\r
+  IN CHAR16                    *StorageName  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.\r
+\r
+Arguments:\r
+  ConfigString - Either <ConfigRequest> or <ConfigResp>.\r
+  StorageGuid  - GUID of the storage.\r
+  StorageName  - Name of the stoarge.\r
+\r
+Returns:\r
+  TRUE         - Routing information is correct in ConfigString.\r
+  FALSE        - Routing information is incorrect in ConfigString.\r
+\r
+--*/\r
+{\r
+  EFI_STATUS  Status;\r
+  BOOLEAN     Match;\r
+  EFI_GUID    Guid;\r
+  CHAR16      *Name;\r
+  CHAR16      *StrPtr;\r
+  UINTN       BufferSize;\r
+\r
+  //\r
+  // <ConfigHdr> ::=\r
+  // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>\r
+  // | 5  |   32   |  6  |  NameStrLen*4 |  6  |    DevicePathStrLen    | 1 |\r
+  //\r
+  if (EfiStrLen (ConfigString) <= (5 + 32 + 6)) {\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Compare GUID\r
+  //\r
+  if (StorageGuid != NULL) {\r
+\r
+    StrPtr = ConfigString + 5 + 32;\r
+    if (*StrPtr != L'&') {\r
+      return FALSE;\r
+    }\r
+    *StrPtr = L'\0';\r
+\r
+    BufferSize = sizeof (EFI_GUID);\r
+    Status = HexStringToBuffer (\r
+               (UINT8 *) &Guid,\r
+               &BufferSize,\r
+               ConfigString + 5\r
+               );\r
+    *StrPtr = L'&';\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return FALSE;\r
+    }\r
+\r
+    if (!EfiCompareGuid (&Guid, StorageGuid)) {\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Compare Name\r
+  //\r
+  Match = TRUE;\r
+  if (StorageName != NULL) {\r
+    StrPtr = ConfigString + 5 + 32 + 6;\r
+    while (*StrPtr != L'\0' && *StrPtr != L'&') {\r
+      StrPtr++;\r
+    }\r
+    if (*StrPtr != L'&') {\r
+      return FALSE;\r
+    }\r
+\r
+    *StrPtr = L'\0';\r
+    BufferSize = (EfiStrLen (ConfigString + 5 + 32 + 6) + 1) * sizeof (CHAR16);\r
+    Name = EfiLibAllocatePool (BufferSize);\r
+    ASSERT (Name != NULL);\r
+    Status = ConfigStringToUnicode (\r
+               Name,\r
+               &BufferSize,\r
+               ConfigString + 5 + 32 + 6\r
+               );\r
+    *StrPtr = L'&';\r
+\r
+    if (EFI_ERROR (Status) || (EfiStrCmp (Name, StorageName) != 0)) {\r
+      Match = FALSE;\r
+    }\r
+    gBS->FreePool (Name);\r
+  }\r
+\r
+  return Match;\r
+}\r
+\r
 BOOLEAN\r
 FindBlockName (\r
   IN OUT CHAR16                *String,\r
@@ -965,7 +1643,7 @@ Returns:
   HeaderLen = EfiStrLen (ConfigHdr);\r
 \r
   BufferLen = 0x4000;\r
-  ConfigResp = EfiLibAllocateZeroPool (BufferLen + HeaderLen);\r
+  ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));\r
 \r
   StringPtr = ConfigResp + HeaderLen;\r
   *StringPtr = L'&';\r
@@ -981,7 +1659,7 @@ Returns:
                            );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     gBS->FreePool (ConfigResp);\r
-    ConfigResp = EfiLibAllocateZeroPool (BufferLen + HeaderLen);\r
+    ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));\r
 \r
     StringPtr = ConfigResp + HeaderLen;\r
     *StringPtr = L'&';\r
@@ -1116,7 +1794,7 @@ Returns:
                                 &Progress\r
                                 );\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePool (ConfigResp);\r
+    gBS->FreePool (ConfigRequest);\r
     return Status;\r
   }\r
 \r
@@ -1133,9 +1811,10 @@ Returns:
                            &BufferSize,\r
                            StringPtr,\r
                            FALSE,\r
-                           NULL,\r
-                           NULL\r
+                           VariableGuid,\r
+                           VariableName\r
                            );\r
   gBS->FreePool (ConfigResp);\r
+  gBS->FreePool (ConfigRequest);\r
   return Status;\r
 }\r
index bd85764d4a2c327a633ea6b0e6c48b587c56389b..3de0efb65186c2c09185144d059e77956d01260b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -78,10 +78,13 @@ typedef struct {
 } IFR_OPTION;\r
 #pragma pack()\r
 \r
+#pragma pack(1)\r
 typedef struct {\r
   VENDOR_DEVICE_PATH             VendorDevicePath;\r
-  UINT32                         MonotonicCount;\r
+  UINT32                         Reserved;\r
+  UINT64                         UniqueId;\r
 } HII_VENDOR_DEVICE_PATH_NODE;\r
+#pragma pack()\r
 \r
 typedef struct {\r
   HII_VENDOR_DEVICE_PATH_NODE    Node;\r
@@ -280,7 +283,8 @@ CreateOneOfOptionOpCode (
   IN     IFR_OPTION           *OptionsList,\r
   IN     UINT8                Type,\r
   IN OUT EFI_HII_UPDATE_DATA  *Data\r
-  );\r
+  )\r
+;\r
 \r
 EFI_STATUS\r
 CreateOneOfOpCode (\r
@@ -599,6 +603,53 @@ ExtractDefault(
 --*/\r
 ;\r
 \r
+EFI_STATUS\r
+ConstructConfigAltResp (\r
+  IN  EFI_STRING                  ConfigRequest,  OPTIONAL\r
+  OUT EFI_STRING                  *Progress,\r
+  OUT EFI_STRING                  *ConfigAltResp,\r
+  IN  EFI_GUID                    *Guid,\r
+  IN  CHAR16                      *Name,\r
+  IN  EFI_HANDLE                  *DriverHandle,\r
+  IN  VOID                        *BufferStorage,\r
+  IN  UINTN                       BufferStorageSize,\r
+  IN  VOID                        *BlockNameArray, OPTIONAL\r
+  IN  UINTN                       NumberAltCfg,\r
+  ...\r
+//IN  UINT16                      AltCfgId,\r
+//IN  VOID                        *DefaultValueArray,\r
+  )\r
+/*++\r
+\r
+  Routine Description:\r
+\r
+  Construct <ConfigAltResp> for a buffer storage.\r
+\r
+  Arguments:\r
+    ConfigRequest         - The Config request string. If set to NULL, all the\r
+                            configurable elements will be extracted from BlockNameArray.\r
+    ConfigAltResp         - The returned <ConfigAltResp>.\r
+    Progress              - On return, points to a character in the Request.\r
+    Guid                  - GUID of the buffer storage.\r
+    Name                  - Name of the buffer storage.\r
+    DriverHandle          - The DriverHandle which is used to invoke HiiDatabase\r
+                            protocol interface NewPackageList().\r
+    BufferStorage         - Content of the buffer storage.\r
+    BufferStorageSize     - Length in bytes of the buffer storage.\r
+    BlockNameArray        - Array generated by VFR compiler.\r
+    NumberAltCfg          - Number of Default value array generated by VFR compiler.\r
+                            The sequential input parameters will be number of\r
+                            AltCfgId and DefaultValueArray pairs. When set to 0,\r
+                            there will be no <AltResp>.\r
+\r
+  Returns:\r
+    EFI_OUT_OF_RESOURCES  - Run out of memory resource.\r
+    EFI_INVALID_PARAMETER - ConfigAltResp is NULL.\r
+    EFI_SUCCESS           - Operation successful.\r
+\r
+--*/\r
+;\r
+\r
 EFI_STATUS\r
 ExtractGuidFromHiiHandle (\r
   IN      EFI_HII_HANDLE      Handle,\r
@@ -643,6 +694,49 @@ Returns:
 --*/\r
 ;\r
 \r
+EFI_STATUS\r
+ExtractClassGuidFromHiiHandle (\r
+  IN      EFI_HII_HANDLE      Handle,\r
+  OUT     UINT8               *NumberOfClassGuid,\r
+  OUT     EFI_GUID            **ClassGuid,\r
+  OUT     EFI_STRING_ID       *FormSetTitle,\r
+  OUT     EFI_STRING_ID       *FormSetHelp\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Extract formset ClassGuid for given HII handle.\r
+\r
+Arguments:\r
+  HiiHandle         - Hii handle\r
+  NumberOfClassGuid - Number of ClassGuid\r
+  ClassGuid         - Pointer to callee allocated buffer, an array of ClassGuid\r
+  FormSetTitle      - Formset title string\r
+  FormSetHelp       - Formset help string\r
+\r
+Returns:\r
+  EFI_SUCCESS     - Successfully extract Class for specified Hii handle.\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+ToLower (\r
+  IN OUT CHAR16    *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Converts the unicode character from uppercase to lowercase.\r
+\r
+Arguments:\r
+  Str        -  String to be converted\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
 EFI_STATUS\r
 BufferToHexString (\r
   IN OUT CHAR16    *Str,\r
@@ -689,6 +783,64 @@ Returns:
 --*/\r
 ;\r
 \r
+EFI_STATUS\r
+ConfigStringToUnicode (\r
+  IN OUT CHAR16                *UnicodeString,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CHAR16                    *ConfigString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Convert binary representation Config string (e.g. "0041004200430044") to the\r
+  original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.\r
+  "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").\r
+\r
+Arguments:\r
+  UnicodeString - Original Unicode string.\r
+  StrBufferLen  - On input: Length in bytes of buffer to hold the Unicode string.\r
+                  Includes tailing '\0' character.\r
+                  On output:\r
+                    If return EFI_SUCCESS, containing length of Unicode string buffer.\r
+                    If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
+  ConfigString  - Binary representation of Unicode String, <string> := (<HexCh>4)+\r
+\r
+Returns:\r
+  EFI_SUCCESS          - Routine success.\r
+  EFI_BUFFER_TOO_SMALL - The string buffer is too small.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+UnicodeToConfigString (\r
+  IN OUT CHAR16                *ConfigString,\r
+  IN OUT UINTN                 *StrBufferLen,\r
+  IN CHAR16                    *UnicodeString\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Convert Unicode string to binary representation Config string, e.g.\r
+  "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.\r
+  "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").\r
+\r
+Arguments:\r
+  ConfigString  - Binary representation of Unicode String, <string> := (<HexCh>4)+\r
+  StrBufferLen  - On input: Length in bytes of buffer to hold the Unicode string.\r
+                  Includes tailing '\0' character.\r
+                  On output:\r
+                    If return EFI_SUCCESS, containing length of Unicode string buffer.\r
+                    If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.\r
+  UnicodeString - Original Unicode string.\r
+\r
+Returns:\r
+  EFI_SUCCESS          - Routine success.\r
+  EFI_BUFFER_TOO_SMALL - The string buffer is too small.\r
+\r
+--*/\r
+;\r
+\r
 EFI_STATUS\r
 ConstructConfigHdr (\r
   IN OUT CHAR16                *ConfigHdr,\r
@@ -719,6 +871,29 @@ Returns:
 --*/\r
 ;\r
 \r
+BOOLEAN\r
+IsConfigHdrMatch (\r
+  IN EFI_STRING                ConfigString,\r
+  IN EFI_GUID                  *StorageGuid, OPTIONAL\r
+  IN CHAR16                    *StorageName  OPTIONAL\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.\r
+\r
+Arguments:\r
+  ConfigString - Either <ConfigRequest> or <ConfigResp>.\r
+  StorageGuid  - GUID of the storage.\r
+  StorageName  - Name of the stoarge.\r
+\r
+Returns:\r
+  TRUE         - Routing information is correct in ConfigString.\r
+  FALSE        - Routing information is incorrect in ConfigString.\r
+\r
+--*/\r
+;\r
+\r
 BOOLEAN\r
 FindBlockName (\r
   IN OUT CHAR16                *String,\r
@@ -1093,6 +1268,47 @@ Returns:
 --*/\r
 ;\r
 \r
+EFI_STATUS\r
+IfrLibInitUpdateData (\r
+  IN OUT EFI_HII_UPDATE_DATA   *UpdateData,\r
+  IN UINT32                    BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function initialize the data structure for dynamic opcode.\r
+\r
+Arguments:\r
+  UpdateData     - The adding data;\r
+  BufferSize     - Length of the buffer to fill dynamic opcodes.\r
+\r
+Returns:\r
+  EFI_SUCCESS           - Update data is initialized.\r
+  EFI_INVALID_PARAMETER - UpdateData is NULL.\r
+  EFI_OUT_OF_RESOURCES  - No enough memory to allocate.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+IfrLibFreeUpdateData (\r
+  IN EFI_HII_UPDATE_DATA       *UpdateData\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  This function free the resource of update data.\r
+\r
+Arguments:\r
+  UpdateData     - The adding data;\r
+\r
+Returns:\r
+  EFI_SUCCESS           - Resource in UpdateData is released.\r
+  EFI_INVALID_PARAMETER - UpdateData is NULL.\r
+\r
+--*/\r
+;\r
+\r
 EFI_STATUS\r
 IfrLibUpdateForm (\r
   IN EFI_HII_HANDLE            Handle,\r
index c46bc7d73ec21ecb1bece88632fb2ab5b0b003cd..2c454de95178478d97886695450cd4760d7f2067 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -394,9 +394,7 @@ CreateOrderedListOpCode (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if ((OrderedListFlags != 0) &&\r
-      (OrderedListFlags != EFI_IFR_UNIQUE_SET) &&\r
-      (OrderedListFlags != EFI_IFR_NO_EMPTY_SET)) {\r
+  if ((OrderedListFlags & (~(EFI_IFR_UNIQUE_SET | EFI_IFR_NO_EMPTY_SET))) != 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
index 0a5739965aa84009a0ea7207f2c801b57ac93742..ece78bfb441624a6b0bc83adb7d1bbb384975767 100644 (file)
@@ -555,20 +555,37 @@ IfrLibNewString (
   if (Languages == NULL) {\r
     return EFI_NOT_FOUND;\r
   }\r
+  \r
+  if (StringId == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  *StringId = 0;\r
 \r
   LangStrings = Languages;\r
   while (*LangStrings != 0) {\r
     GetNextLanguage (&LangStrings, Lang);\r
 \r
-    Status = gIfrLibHiiString->NewString (\r
-                                 gIfrLibHiiString,\r
-                                 PackageList,\r
-                                 StringId,\r
-                                 Lang,\r
-                                 NULL,\r
-                                 String,\r
-                                 NULL\r
-                                 );\r
+    if (*StringId == 0) {\r
+      Status = gIfrLibHiiString->NewString (\r
+                                   gIfrLibHiiString,\r
+                                   PackageList,\r
+                                   StringId,\r
+                                   Lang,\r
+                                   NULL,\r
+                                   String,\r
+                                   NULL\r
+                                   );\r
+    } else {\r
+      Status = gIfrLibHiiString->SetString (\r
+                                   gIfrLibHiiString,\r
+                                   PackageList,\r
+                                   *StringId,\r
+                                   Lang,\r
+                                   String,\r
+                                   NULL\r
+                                   );\r
+    }\r
+\r
     if (EFI_ERROR (Status)) {\r
       break;\r
     }\r
index 7968995794fd7a83085655bc1c08ff7efbb1083a..be5bf00f7c8eee4d8caa861fd509f3da2c97caed 100644 (file)
@@ -23,6 +23,81 @@ Abstract:
 #include "EdkIIGlueDxe.h"\r
 #include "Common/EdkIIGlueDependencies.h"\r
 \r
+//\r
+// Check definitions in .inf file to determine __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__\r
+//\r
+// __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__\r
+//    1: only install ComponentName, DriverConfiguration and DriverDiagnostics\r
+//    2: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2\r
+//    3: install all including ComponentName, DriverConfiguration, DriverDiagnostics AND\r
+//                             ComponentName2, DriverConfiguration2 and DriverDiagnostics2\r
+//    4: install automatically according to EFI_SPECIFICATION_VERSION:\r
+//        if EFI_SPECIFICATION_VERSION <  0x00020000: only install ComponentName, DriverConfiguration and DriverDiagnostics\r
+//        if EFI_SPECIFICATION_VERSION >= 0x00020000: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2\r
+//\r
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__\r
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__\r
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__\r
+#endif\r
+\r
+#ifdef  __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__\r
+#undef  __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)\r
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)\r
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)\r
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1\r
+#endif\r
+\r
+#if !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)\r
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)\r
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 3\r
+#endif\r
+\r
+//\r
+//  To use Auto-Select, it must be:\r
+//    1. both Protocol and Protocol2 are defined\r
+//    2. The Protocol and Protocol2 must use same names, for example, gDriverControllerName as __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__ and __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__\r
+//\r
+#if defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)\r
+#if !(defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__))\r
+#error "To use Auto-Select please define both Protocol and Protocol2 instances"\r
+#endif\r
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 4\r
+#endif\r
+\r
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 4)\r
+#undef  __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__  2\r
+#else\r
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__  1\r
+#endif\r
+#endif\r
+\r
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)\r
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 1;\r
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)\r
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 2;\r
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)\r
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 3;\r
+#else\r
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 0;\r
+#endif\r
+\r
 STATIC EFI_EVENT  _mDriverExitBootServicesNotifyEvent;\r
 \r
 //\r
@@ -31,27 +106,38 @@ STATIC EFI_EVENT  _mDriverExitBootServicesNotifyEvent;
 // In case where multiple Driver Model protocols need to be installed in a single driver,\r
 // manually edit this file and compile/link the modified file with the driver.\r
 //\r
-\r
-#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__\r
+#if defined(__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__)\r
 extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__;\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-extern EFI_COMPONENT_NAME2_PROTOCOL  __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;\r
-#else\r
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)\r
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__)\r
 extern EFI_COMPONENT_NAME_PROTOCOL   __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;\r
 #endif\r
-#endif\r
 \r
-#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__\r
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__)\r
 extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__;\r
 #endif\r
+#endif\r
 \r
-#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__\r
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)\r
 extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__;\r
 #endif\r
 \r
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)\r
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__)\r
+extern EFI_COMPONENT_NAME2_PROTOCOL  __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__;\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__)\r
+extern EFI_DRIVER_CONFIGURATION2_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__;\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)\r
+extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__;\r
+#endif\r
+#endif\r
+\r
 GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverModelProtocolList[] = {\r
  {\r
 #ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__\r
@@ -60,23 +146,41 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST  _gDriverMode
   NULL,\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__\r
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)\r
   &__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__,\r
 #else\r
   NULL,\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__\r
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)\r
   &__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__,\r
 #else\r
   NULL,\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__\r
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)\r
  &__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__,\r
 #else\r
   NULL,\r
 #endif\r
+\r
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)\r
+  &__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)\r
+  &__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
+\r
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)\r
+ &__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__,\r
+#else\r
+  NULL,\r
+#endif\r
   }\r
 };\r
 \r
@@ -249,15 +353,15 @@ ProcessLibraryConstructorList (
 // NOTE: the constructors must be called according to dependency order\r
 //\r
 // UefiBootServicesTableLib     UefiBootServicesTableLibConstructor()\r
+// UefiRuntimeServicesTableLib  UefiRuntimeServicesTableLibConstructor() \r
+// DxeServicesTableLib          DxeServicesTableLibConstructor()\r
 // DxeIoLibCpuIo                IoLibConstructor()\r
 // DxeSalLib                    DxeSalLibConstructor(), IPF only\r
 // EdkDxeRuntimeDriverLib       RuntimeDriverLibConstruct()\r
-// DxeHobLib                    HobLibConstructor()\r
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()\r
 // UefiDriverModelLib           UefiDriverModelLibConstructor()\r
+// DxeHobLib                    HobLibConstructor()\r
 // DxeSmbusLib                  SmbusLibConstructor()    \r
-// DxeServicesTableLib          DxeServicesTableLibConstructor()\r
-// UefiRuntimeServicesTableLib  UefiRuntimeServicesTableLibConstructor() \r
-// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()\r
 // \r
 \r
 #ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
@@ -265,6 +369,16 @@ ProcessLibraryConstructorList (
   ASSERT_EFI_ERROR (Status);\r
 #endif\r
 \r
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
+  Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
+  Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status); \r
+#endif\r
+\r
 #ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
   Status = IoLibConstructor (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);\r
@@ -280,8 +394,8 @@ ProcessLibraryConstructorList (
   ASSERT_EFI_ERROR (Status);\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
-  Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);\r
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__\r
+  Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);\r
 #endif\r
 \r
@@ -290,16 +404,6 @@ ProcessLibraryConstructorList (
   ASSERT_EFI_ERROR (Status);\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
-  Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);\r
-  ASSERT_EFI_ERROR (Status); \r
-#endif\r
-\r
-#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__\r
-  Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);\r
-  ASSERT_EFI_ERROR (Status);\r
-#endif\r
-\r
 #ifdef __EDKII_GLUE_DXE_HOB_LIB__\r
   Status = HobLibConstructor (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);\r
index c83b28efbb659e1c0c6e177dde4f758879197ca3..13cddfbe1df3f8ba9c38162ac7030c80e3df756c 100644 (file)
@@ -83,23 +83,18 @@ ProcessLibraryConstructorList (
 //       here\r
 //\r
 // UefiBootServicesTableLib     UefiBootServicesTableLibConstructor()\r
+// UefiRuntimeServicesTableLib  UefiRuntimeServicesTableLibConstructor() \r
+// DxeServicesTableLib          DxeServicesTableLibConstructor()\r
 // DxeIoLibCpuIo                IoLibConstructor \r
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()\r
 // DxeHobLib                    HobLibConstructor()\r
 // DxeSmbusLib                  SmbusLibConstructor()    \r
-// DxeServicesTableLib          DxeServicesTableLibConstructor()\r
-// UefiRuntimeServicesTableLib  UefiRuntimeServicesTableLibConstructor() \r
-// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()\r
-// check here: check lib usage\r
+\r
 #ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\r
   Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);\r
 #endif\r
 \r
-#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
-  Status = IoLibConstructor (ImageHandle, SystemTable);\r
-  ASSERT_EFI_ERROR (Status);\r
-#endif\r
-\r
 #ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__\r
   Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);\r
@@ -110,6 +105,11 @@ ProcessLibraryConstructorList (
   ASSERT_EFI_ERROR (Status); \r
 #endif\r
 \r
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__\r
+  Status = IoLibConstructor (ImageHandle, SystemTable);\r
+  ASSERT_EFI_ERROR (Status);\r
+#endif\r
+\r
 #ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__\r
   Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);\r
   ASSERT_EFI_ERROR (Status);\r
@@ -321,14 +321,26 @@ _ModuleEntryPoint (
   EFI_HANDLE                 Handle;\r
 \r
   //\r
-  // Call constructor for all libraries\r
+  // Cache a pointer to the Boot Services Table \r
   //\r
-  ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+  mBS = SystemTable->BootServices;\r
 \r
   //\r
-  // Cache a pointer to the Boot Services Table \r
+  // Initialize gBS as ASSERT needs it\r
+  // Both DxeReportStatusCodeLib and SmmRuntimeDxeReportStatusCodeLib implementations\r
+  // Can handle this cleanly before lib constructors are called.\r
   //\r
-  mBS = SystemTable->BootServices;\r
+  gBS = mBS;\r
+\r
+  //\r
+  // Retrieve the Loaded Image Protocol\r
+  //\r
+  Status = mBS->HandleProtocol (\r
+                  ImageHandle, \r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID*)&LoadedImage\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Retrieve SMM Base Protocol\r
@@ -349,27 +361,6 @@ _ModuleEntryPoint (
   //\r
   //\r
   if (!InSmm) {\r
-    //\r
-    // Retrieve the Loaded Image Protocol\r
-    //\r
-    Status = mBS->HandleProtocol (\r
-                    ImageHandle, \r
-                    &gEfiLoadedImageProtocolGuid,\r
-                    (VOID*)&LoadedImage\r
-                    );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    //\r
-    // Install the unload handler\r
-    //\r
-    Status = mBS->HandleProtocol (\r
-                      ImageHandle,\r
-                      &gEfiLoadedImageProtocolGuid,\r
-                      (VOID **)&LoadedImage\r
-                      );\r
-    ASSERT_EFI_ERROR (Status);\r
-    LoadedImage->Unload = _DriverUnloadHandler;\r
-\r
     //\r
     // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from\r
     //\r
@@ -391,18 +382,34 @@ _ModuleEntryPoint (
     //\r
     Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE);\r
     ASSERT_EFI_ERROR (Status);\r
-  } else {\r
-\r
-    //\r
-    // Call the list of driver entry points\r
-    //\r
-    #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__\r
-    Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));\r
-    #else\r
-    Status = EFI_SUCCESS;\r
-    #endif\r
+    return Status;\r
   }\r
 \r
+  //\r
+  // Call constructor for all libraries\r
+  //\r
+  ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+\r
+  //\r
+  // Install the unload handler\r
+  //\r
+  Status = mBS->HandleProtocol (\r
+                    ImageHandle,\r
+                    &gEfiLoadedImageProtocolGuid,\r
+                    (VOID **)&LoadedImage\r
+                    );\r
+  ASSERT_EFI_ERROR (Status);\r
+  LoadedImage->Unload = _DriverUnloadHandler;\r
+\r
+  //\r
+  // Call the list of driver entry points\r
+  //\r
+  #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__\r
+  Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));\r
+  #else\r
+  Status = EFI_SUCCESS;\r
+  #endif\r
+\r
   if (EFI_ERROR (Status)) {\r
     ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
   }\r
index b3b1f0ef7361bf5947709ee5f772a95e972fe0a7..321e5fb0ec5befe8e0ede605ced98a27f1379aea 100644 (file)
@@ -332,6 +332,15 @@ Abstract:
   #endif\r
 #endif\r
 \r
+//\r
+// DxeServicesTableLib\r
+//\r
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
+  #ifndef __EDKII_GLUE_UEFI_LIB__\r
+  #define __EDKII_GLUE_UEFI_LIB__\r
+  #endif\r
+#endif\r
+\r
 //\r
 // UefiLib\r
 //\r
@@ -489,15 +498,6 @@ Abstract:
   #endif\r
 #endif\r
 \r
-//\r
-// DxeServicesTableLib\r
-//\r
-#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\r
-  #ifndef __EDKII_GLUE_UEFI_LIB__\r
-  #define __EDKII_GLUE_UEFI_LIB__\r
-  #endif\r
-#endif\r
-\r
 //\r
 // BasePrintLib\r
 //\r
index 2650379ba99c589f42ca392625b0388538f9ce80..3513f87d69f02a1956a5d526affb17a1d8bb7a2d 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -33,10 +33,15 @@ Abstract:
 //  0x6000  - support EBC. Feb, 2007\r
 //  0x7000  - size reduction, Jun, 2007\r
 //  0x7100  - backward compatibility supported, Jun, 2007\r
+//  0x8000  - Driver model protocols2 supported, May, 2008\r
+//  0x9000  - add SmmRuntimeDxeReportStatusCodeLib and OemHookStatusCodeLibNull, Feb, 2009\r
+//  0x9100  - change to use unique member RT variable names in various library instances, June, 2009\r
+//  0x9200  - Update LEGACY_BOOT and READY_TO_BOOT event handling in UefiLib, July, 2009\r
+//  0x9300  - Remove OemHookStatusCodeLibNull. SmmRuntimeDxeReportStatusCodeLib uses SMM StatusCode Protocol, Oct, 2009\r
 //\r
 //  For reference only, don't change the value\r
 //\r
-#define EDKII_GLUE_LIBRARY_VERSION 0x7100\r
+#define EDKII_GLUE_LIBRARY_VERSION 0x9300\r
 \r
 \r
 //\r
@@ -120,7 +125,9 @@ Abstract:
 // This value is FSB Clock frequency. Its unit is Hz and its \r
 // default value is 200000000, that means FSB frequency is 200Mhz.\r
 //\r
+#ifndef EDKII_GLUE_FSBClock\r
 #define EDKII_GLUE_FSBClock                     200000000\r
+#endif\r
 \r
 //\r
 // post code property mask\r
@@ -142,7 +149,9 @@ Abstract:
 // The base address of IPF IO Block\r
 //\r
 #ifdef MDE_CPU_IPF\r
+#ifndef EDKII_GLUE_IoBlockBaseAddressForIpf\r
 #define EDKII_GLUE_IoBlockBaseAddressForIpf     0x0ffffc000000\r
 #endif\r
+#endif\r
 \r
 #endif\r
index 5482785b77fb1812d3a065eef7c58f1d05bceb6a..8c4e2ae946a9e81f93cdfb6c93489e8084dbb8a0 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -173,4 +173,6 @@ Abstract:
 #include "Library/EdkIIGlueUefiLib.h"\r
 #include "Library/EdkIIGlueUefiRuntimeServicesTableLib.h"\r
 \r
+extern UINT8 _gEdkIIGlueDriverModelProtocolSelection;\r
+\r
 #endif\r
index 9bb057f5abfa259da0f7b1d52b79618952ec0283..ef947fa7ebd8c6644e4e99a64527ff3e54b0e122 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -34,15 +34,14 @@ Abstract:
 // Data structure that declares pointers to the Driver Model \r
 // Protocols.\r
 //\r
-typedef struct {\r
-  const EFI_DRIVER_BINDING_PROTOCOL        *DriverBinding;\r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  const EFI_COMPONENT_NAME2_PROTOCOL       *ComponentName;\r
-#else\r
-  const EFI_COMPONENT_NAME_PROTOCOL        *ComponentName;\r
-#endif\r
-  const EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration;\r
-  const EFI_DRIVER_DIAGNOSTICS_PROTOCOL    *DriverDiagnostics;\r
+typedef struct {  \r
+  const EFI_DRIVER_BINDING_PROTOCOL         *DriverBinding;\r
+  const EFI_COMPONENT_NAME_PROTOCOL         *ComponentName;\r
+  const EFI_DRIVER_CONFIGURATION_PROTOCOL   *DriverConfiguration;\r
+  const EFI_DRIVER_DIAGNOSTICS_PROTOCOL     *DriverDiagnostics;\r
+  const EFI_COMPONENT_NAME2_PROTOCOL        *ComponentName2;\r
+  const EFI_DRIVER_CONFIGURATION2_PROTOCOL  *DriverConfiguration2;\r
+  const EFI_DRIVER_DIAGNOSTICS2_PROTOCOL    *DriverDiagnostics2;\r
 } EFI_DRIVER_MODEL_PROTOCOL_LIST;\r
 \r
 //\r
index 15d5f2e7304beda20b3a7a147755d403cd8c4fc9..48c8f5e8be67f4d55d46e3fcd77ecc73ed49afbb 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -585,13 +585,6 @@ EfiCreateEventReadyToBootEx (
 /**\r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for Tiano extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability.\r
-\r
   @param  FvDevicePathNode  Pointer to a FV device path node to initialize\r
   @param  NameGuid          FV file name to use in FvDevicePathNode\r
 \r
@@ -606,15 +599,6 @@ GlueEfiInitializeFwVolDevicepathNode (
 /**\r
   Check to see if the Firmware Volume (FV) Media Device Path is valid \r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for Tiano extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability. The return value to this\r
-  function points to a location in FvDevicePathNode and it does not allocate\r
-  new memory for the GUID pointer that is returned.\r
-\r
   @param  FvDevicePathNode  Pointer to FV device path to check.\r
 \r
   @retval NULL              FvDevicePathNode is not valid.\r
index 4caec5f371009413af7349f1adee3683481c0018..9562460e0f5af793c4433f9acd2365ce37f66643 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -51,7 +51,7 @@ GlueCompareMem (
   IN UINTN       Length\r
   )\r
 {\r
-  if (Length == 0) {\r
+  if (Length == 0 || DestinationBuffer == SourceBuffer) {\r
     return 0;\r
   }\r
   ASSERT (DestinationBuffer != NULL);\r
index 6cc2da31b0942897bf7b68062de1651420de30c0..387a6835a682d319970028b6877ad7dbadefaca3 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -29,7 +29,7 @@ Abstract:
 STATIC EFI_EVENT              mEfiVirtualNotifyEvent;\r
 STATIC BOOLEAN                mEfiGoneVirtual         = FALSE;\r
 STATIC BOOLEAN                mEfiAtRuntime           = FALSE;\r
-EFI_RUNTIME_SERVICES          *mRT;\r
+EFI_RUNTIME_SERVICES          *mRTEdkDxeRuntimeDriverLib;\r
 \r
 /**\r
   Set AtRuntime flag as TRUE after ExitBootServices\r
@@ -44,6 +44,11 @@ RuntimeDriverExitBootServices (
   IN VOID             *Context\r
   )\r
 {\r
+  //\r
+  // Clear out BootService globals\r
+  //\r
+  gBS             = NULL;\r
+\r
   mEfiAtRuntime = TRUE;\r
 }\r
 \r
@@ -76,7 +81,7 @@ RuntimeLibVirtualNotifyEvent (
   //\r
   // Update global for Runtime Services Table and IO\r
   //\r
-  EfiConvertPointer (0, (VOID **) &mRT);\r
+  EfiConvertPointer (0, (VOID **) &mRTEdkDxeRuntimeDriverLib);\r
 \r
   mEfiGoneVirtual = TRUE;\r
 }\r
@@ -99,8 +104,8 @@ RuntimeDriverLibConstruct (
   EFI_STATUS  Status;\r
 \r
   ASSERT (SystemTable != NULL);\r
-  mRT = SystemTable->RuntimeServices;\r
-  ASSERT (mRT != NULL);\r
+  mRTEdkDxeRuntimeDriverLib = SystemTable->RuntimeServices;\r
+  ASSERT (mRTEdkDxeRuntimeDriverLib != NULL);\r
   \r
   //\r
   // Register SetVirtualAddressMap () notify function\r
index 1fcfddb5859d45edb2884ea91792557e522f784e..c57588c7704d5619d24166b017eb41a3d1dd7014 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -50,11 +50,11 @@ Returns:
 \r
 --*/\r
 {\r
-  mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
+  mRTEdkDxeRuntimeDriverLib->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r
 }\r
 \r
 //\r
-// The following functions hide the mRT local global from the call to\r
+// The following functions hide the mRTEdkDxeRuntimeDriverLib local global from the call to\r
 // runtime service in the EFI system table.\r
 //\r
 EFI_STATUS\r
@@ -82,7 +82,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->GetTime (Time, Capabilities);\r
+  return mRTEdkDxeRuntimeDriverLib->GetTime (Time, Capabilities);\r
 }\r
 \r
 EFI_STATUS\r
@@ -106,7 +106,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->SetTime (Time);\r
+  return mRTEdkDxeRuntimeDriverLib->SetTime (Time);\r
 }\r
 \r
 EFI_STATUS\r
@@ -134,7 +134,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->GetWakeupTime (Enabled, Pending, Time);\r
+  return mRTEdkDxeRuntimeDriverLib->GetWakeupTime (Enabled, Pending, Time);\r
 }\r
 \r
 EFI_STATUS\r
@@ -161,7 +161,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->SetWakeupTime (Enable, Time);\r
+  return mRTEdkDxeRuntimeDriverLib->SetWakeupTime (Enable, Time);\r
 }\r
 \r
 \r
@@ -199,7 +199,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+  return mRTEdkDxeRuntimeDriverLib->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
 }\r
 \r
 EFI_STATUS\r
@@ -232,7 +232,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
+  return mRTEdkDxeRuntimeDriverLib->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r
 }\r
 \r
 EFI_STATUS\r
@@ -265,7 +265,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
+  return mRTEdkDxeRuntimeDriverLib->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r
 }\r
 \r
 EFI_STATUS\r
@@ -289,7 +289,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->GetNextHighMonotonicCount (HighCount);\r
+  return mRTEdkDxeRuntimeDriverLib->GetNextHighMonotonicCount (HighCount);\r
 }\r
 \r
 EFI_STATUS\r
@@ -316,7 +316,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->ConvertPointer (DebugDisposition, Address);\r
+  return mRTEdkDxeRuntimeDriverLib->ConvertPointer (DebugDisposition, Address);\r
 }\r
 \r
 EFI_STATUS\r
@@ -399,7 +399,7 @@ EfiSetVirtualAddressMap (
   IN CONST EFI_MEMORY_DESCRIPTOR    *VirtualMap\r
   )\r
 {\r
-  return mRT->SetVirtualAddressMap (\r
+  return mRTEdkDxeRuntimeDriverLib->SetVirtualAddressMap (\r
                 MemoryMapSize,\r
                 DescriptorSize,\r
                 DescriptorVersion,\r
@@ -417,7 +417,7 @@ EfiUpdateCapsule (
   )\r
 {\r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  return mRT->UpdateCapsule (\r
+  return mRTEdkDxeRuntimeDriverLib->UpdateCapsule (\r
                 CapsuleHeaderArray,\r
                 CapsuleCount,\r
                 ScatterGatherList\r
@@ -437,7 +437,7 @@ EfiQueryCapsuleCapabilities (
   )\r
 {\r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  return mRT->QueryCapsuleCapabilities (\r
+  return mRTEdkDxeRuntimeDriverLib->QueryCapsuleCapabilities (\r
           CapsuleHeaderArray,\r
           CapsuleCount,\r
           MaximumCapsuleSize,\r
@@ -459,7 +459,7 @@ EfiQueryVariableInfo (
   )\r
 {\r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  return mRT->QueryVariableInfo (\r
+  return mRTEdkDxeRuntimeDriverLib->QueryVariableInfo (\r
           Attributes,\r
           MaximumVariableStorageSize,\r
           RemainingVariableStorageSize,\r
index 8f154a888cb556fa05bce22f407ec8adc8738755..e0f4deb6ce16091f58bc8ecfe660d8b0a49572b1 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -26,7 +26,7 @@ Abstract:
 // Driver Lib Module Globals\r
 //\r
 static EFI_EVENT      mEfiVirtualNotifyEvent;\r
-EFI_RUNTIME_SERVICES  *mRT;\r
+EFI_RUNTIME_SERVICES  *mRTEdkDxeRuntimeDriverLib;\r
 \r
 VOID\r
 EFIAPI\r
@@ -95,7 +95,7 @@ Returns:
   //\r
   // Update global for Runtime Services Table\r
   //\r
-  EfiConvertPointer (0, (VOID **) &mRT);\r
+  EfiConvertPointer (0, (VOID **) &mRTEdkDxeRuntimeDriverLib);\r
 }\r
 \r
 EFI_STATUS\r
@@ -126,7 +126,7 @@ Returns:
 {\r
   EFI_STATUS  Status;\r
 \r
-  mRT = SystemTable->RuntimeServices;\r
+  mRTEdkDxeRuntimeDriverLib = SystemTable->RuntimeServices;\r
 \r
   //\r
   // Register SetVirtualAddressMap () notify function\r
index bcaa7448bd7766546dc8c3ade740cae1adb7415f..a270fc5508e3953d790fa39d056e8b5bf1b0869f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -70,7 +70,7 @@ Returns:
 \r
 \r
 //\r
-// The following functions hide the mRT local global from the call to\r
+// The following functions hide the mRTEdkDxeRuntimeDriverLib local global from the call to\r
 // runtime service in the EFI system table.\r
 //\r
 EFI_STATUS\r
@@ -415,7 +415,7 @@ Returns:
 \r
 --*/\r
 {\r
-  return mRT->ConvertPointer (DebugDisposition, Address);\r
+  return mRTEdkDxeRuntimeDriverLib->ConvertPointer (DebugDisposition, Address);\r
 }\r
 \r
 EFI_STATUS\r
index 2d8e4e7760415ccee5ed5d7b6b976f87d7cd820d..287f525cb9e45a87245b17fcf6cb75835f6d25d0 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -25,6 +25,6 @@ Abstract:
 \r
 #include "EdkIIGlueDxe.h"\r
 \r
-extern EFI_RUNTIME_SERVICES   *mRT;\r
+extern EFI_RUNTIME_SERVICES   *mRTEdkDxeRuntimeDriverLib;\r
 \r
 #endif //__RUNTIMELIBINTERNAL_H__\r
index cd8da602b8a02f1ce3cb8d974d59c2bf573a94d0..c82736c74be3280182f874e7fbdef669a1b898ff 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -22,13 +22,6 @@ Abstract:
 \r
 #include "EdkIIGlueUefi.h"\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID  gEfiComponentName2ProtocolGuid\r
-  #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL       EFI_COMPONENT_NAME2_PROTOCOL\r
-#else\r
-  #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID  gEfiComponentNameProtocolGuid\r
-  #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL       EFI_COMPONENT_NAME_PROTOCOL\r
-#endif\r
 \r
 /**\r
   The constructor function installs the standard EFI Driver Model Protocols.\r
@@ -46,7 +39,7 @@ UefiDriverModelLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_STATUS                   Status;\r
+  EFI_STATUS                   Status = EFI_UNSUPPORTED;\r
   EFI_HANDLE                   DriverBindingHandle;\r
   EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;\r
 \r
@@ -60,16 +53,17 @@ UefiDriverModelLibConstructor (
   // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1\r
   //\r
 \r
-    //\r
-    // The Driver Binding Protocol must never be NULL\r
-    //\r
-    ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);\r
+  //\r
+  // The Driver Binding Protocol must never be NULL\r
+  //\r
+  ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);\r
 \r
-    //\r
-    // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol\r
-    // These are all checks against const pointers, so the optimizing compiler will only select one of the\r
-    // calls to InstallMultipleProtocolInterfaces()\r
-    //\r
+  //\r
+  // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol\r
+  // These are all checks against const pointers, so the optimizing compiler will only select one of the\r
+  // calls to InstallMultipleProtocolInterfaces()\r
+  //\r
+  if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {\r
     if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {\r
       if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {\r
         if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
@@ -82,7 +76,7 @@ UefiDriverModelLibConstructor (
           Status = gBS->InstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           NULL\r
                           );\r
         }\r
@@ -98,7 +92,7 @@ UefiDriverModelLibConstructor (
           Status = gBS->InstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID,      (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
                           NULL\r
                           );\r
@@ -117,7 +111,7 @@ UefiDriverModelLibConstructor (
           Status = gBS->InstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID,    (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid,     (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
                           NULL\r
                           );\r
@@ -135,7 +129,7 @@ UefiDriverModelLibConstructor (
           Status = gBS->InstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID,      (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
                           &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
                           NULL\r
@@ -143,18 +137,95 @@ UefiDriverModelLibConstructor (
         }\r
       }\r
     }\r
+  } // selection == 1 or 3\r
 \r
-    //\r
-    // ASSERT if the call to InstallMultipleProtocolInterfaces() failed\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
+  if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {\r
+    if (_gDriverModelProtocolList[0].DriverDiagnostics2== NULL) {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration2== NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName2== NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,  (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          NULL\r
+                          );\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,       (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          NULL\r
+                          );\r
+        }\r
+      }\r
+    } else {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,      (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,      (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,     (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->InstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,       (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        }\r
+      }\r
+    }\r
+  } // selection == 2 or 3\r
 \r
-    //\r
-    // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol\r
-    //\r
-    DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;\r
-    DriverBinding->ImageHandle         = ImageHandle;\r
-    DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
+  //\r
+  // ASSERT if the call to InstallMultipleProtocolInterfaces() failed\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol\r
+  //\r
+  DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;\r
+  DriverBinding->ImageHandle         = ImageHandle;\r
+  DriverBinding->DriverBindingHandle = DriverBindingHandle;\r
 \r
   \r
   return EFI_SUCCESS;\r
@@ -176,7 +247,7 @@ UefiDriverModelLibDestructor (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS  Status = EFI_UNSUPPORTED;\r
   EFI_HANDLE  DriverBindingHandle;\r
 \r
   //\r
@@ -184,21 +255,22 @@ UefiDriverModelLibDestructor (
   // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1\r
   //\r
 \r
-    //\r
-    // The Driver Binding Protocol must never be NULL\r
-    //\r
-    ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);\r
+  //\r
+  // The Driver Binding Protocol must never be NULL\r
+  //\r
+  ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);\r
 \r
-    //\r
-    // Retrieve the DriverBindingHandle from the Driver Binding Protocol\r
-    //\r
-    DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;\r
+  //\r
+  // Retrieve the DriverBindingHandle from the Driver Binding Protocol\r
+  //\r
+  DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;\r
 \r
-    //\r
-    // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol\r
-    // These are all checks against const pointers, so the optimizing compiler will only select one of the\r
-    // calls to InstallMultipleProtocolInterfaces()\r
-    //\r
+  //\r
+  // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol\r
+  // These are all checks against const pointers, so the optimizing compiler will only select one of the\r
+  // calls to InstallMultipleProtocolInterfaces()\r
+  //\r
+  if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {\r
     if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {\r
       if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {\r
         if (_gDriverModelProtocolList[0].ComponentName == NULL) {\r
@@ -211,7 +283,7 @@ UefiDriverModelLibDestructor (
           Status = gBS->UninstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           NULL\r
                           );\r
         }\r
@@ -227,7 +299,7 @@ UefiDriverModelLibDestructor (
           Status = gBS->UninstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID,      (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
                           NULL\r
                           );\r
@@ -246,7 +318,7 @@ UefiDriverModelLibDestructor (
           Status = gBS->UninstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid,     (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID,    (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid,     (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
                           NULL\r
                           );\r
@@ -264,7 +336,7 @@ UefiDriverModelLibDestructor (
           Status = gBS->UninstallMultipleProtocolInterfaces (\r
                           &DriverBindingHandle,\r
                           &gEfiDriverBindingProtocolGuid,       (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
-                          &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID,      (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
+                          &gEfiComponentNameProtocolGuid,       (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,\r
                           &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,\r
                           &gEfiDriverDiagnosticsProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,\r
                           NULL\r
@@ -272,11 +344,88 @@ UefiDriverModelLibDestructor (
         }\r
       }\r
     }\r
+  } // selection == 1 or 3\r
+\r
+  if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {\r
+    if (_gDriverModelProtocolList[0].DriverDiagnostics2 == NULL) {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          NULL\r
+                          );\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,       (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          NULL\r
+                          );\r
+        }\r
+      }\r
+    } else {\r
+      if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,      (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,      (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,     (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        }\r
+      } else {\r
+        if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        } else {\r
+          Status = gBS->UninstallMultipleProtocolInterfaces (\r
+                          &DriverBindingHandle,\r
+                          &gEfiDriverBindingProtocolGuid,        (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,\r
+                          &gEfiComponentName2ProtocolGuid,       (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,\r
+                          &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,\r
+                          &gEfiDriverDiagnostics2ProtocolGuid,   (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,\r
+                          NULL\r
+                          );\r
+        }\r
+      }\r
+    }\r
+  } // selection == 2 or 3\r
 \r
-    //\r
-    // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed\r
-    //\r
-    ASSERT_EFI_ERROR (Status);\r
+  //\r
+  // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed\r
+  //\r
+  ASSERT_EFI_ERROR (Status);\r
   \r
   return EFI_SUCCESS;\r
 }\r
index b8852e43f36c45ca85ca3152c2b6e4c6c99002c9..cdfea2daf382994e65c884e3349314cfa9917398 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -16,32 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "Library/EdkIIGlueMemoryAllocationLib.h"\r
 \r
 \r
-/**\r
-  Compare whether two names of languages are identical.\r
-\r
-  @param  Language1 Name of language 1.\r
-  @param  Language2 Name of language 2.\r
-\r
-  @retval TRUE      Language 1 and language 2 are the same.\r
-  @retval FALSE     Language 1 and language 2 are not the same.\r
-\r
-**/\r
-STATIC\r
-BOOLEAN\r
-CompareIso639LanguageCode (\r
-  IN CONST CHAR8  *Language1,\r
-  IN CONST CHAR8  *Language2\r
-  )\r
-{\r
-  UINT32  Name1;\r
-  UINT32  Name2;\r
-\r
-  Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);\r
-  Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);\r
-\r
-  return (BOOLEAN) (Name1 == Name2);\r
-}\r
-\r
 /**\r
   This function searches the list of configuration tables stored in the EFI System \r
   Table for a table with a GUID that matches TableGuid.  If a match is found, \r
@@ -509,6 +483,130 @@ EfiTestChildHandle (
   return Status;\r
 }\r
 \r
+/**\r
+  Tests whether a language code has format of ISO639-2.\r
+\r
+  @param  Languages     The language code to be tested.\r
+\r
+  @retval TRUE          Language code format is ISO 639-2.\r
+  @retval FALSE         Language code format is not ISO639-2.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+IsIso639LanguageCode (\r
+  IN CONST CHAR8          *Languages\r
+  )\r
+{\r
+  UINTN  Index;\r
+\r
+  //\r
+  // Find out format of Languages\r
+  //\r
+  for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);\r
+  if (Languages[Index] != 0) {\r
+    //\r
+    // RFC4646 language code\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code\r
+  //\r
+  if (Index == 2) {\r
+    //\r
+    // Single RFC4646 language code without country code, e.g. "en"\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  //\r
+  // Languages in format of ISO639-2\r
+  //\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Compare the first language instance of two language codes, either could be a\r
+  single language code or a language code list. This function assume Language1\r
+  and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.\r
+\r
+  @param  Language1     The first language code to be tested.\r
+  @param  Language2     The second language code to be tested.\r
+\r
+  @retval TRUE          Language code match.\r
+  @retval FALSE         Language code mismatch.\r
+\r
+**/\r
+STATIC\r
+BOOLEAN\r
+CompareLanguageCode (\r
+  IN CONST CHAR8          *Language1,\r
+  IN CONST CHAR8          *Language2\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  //\r
+  // Compare first two bytes of language tag\r
+  //\r
+  if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {\r
+    return FALSE;\r
+  }\r
+\r
+  if (IsIso639LanguageCode (Language1)) {\r
+    //\r
+    // ISO639-2 language code, compare the third byte of language tag\r
+    //\r
+    return (BOOLEAN) ((Language1[2] == Language2[2]) ? TRUE : FALSE);\r
+  }\r
+\r
+  //\r
+  // RFC4646 language code\r
+  //\r
+  for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);\r
+  if ((AsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {\r
+    return TRUE;\r
+  }\r
+\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Step to next language code of a language code list.\r
+\r
+  @param  Languages     The language code list to traverse.\r
+\r
+  @return Pointer to next language code or NULL terminator if it's the last one.\r
+\r
+**/\r
+STATIC\r
+CONST\r
+CHAR8 *\r
+NextSupportedLanguage (\r
+  IN CONST CHAR8          *Languages\r
+  )\r
+{\r
+  UINTN    Index;\r
+\r
+  if (IsIso639LanguageCode (Languages)) {\r
+    //\r
+    // ISO639-2 language code\r
+    //\r
+    return (Languages + 3);\r
+  }\r
+\r
+  //\r
+  // Search in RFC4646 language code list\r
+  //\r
+  for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);\r
+  if (Languages[Index] == ';') {\r
+    Index++;\r
+  }\r
+  return (Languages + Index);\r
+}\r
+\r
 /**\r
   This function looks up a Unicode string in UnicodeStringTable.  If Language is \r
   a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
@@ -566,13 +664,13 @@ LookupUnicodeString (
   // Make sure Language is in the set of Supported Languages\r
   //\r
   while (*SupportedLanguages != 0) {\r
-    if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+    if (CompareLanguageCode (Language, SupportedLanguages)) {\r
 \r
       //\r
       // Search the Unicode String Table for the matching Language specifier\r
       //\r
       while (UnicodeStringTable->Language != NULL) {\r
-        if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) {\r
+        if (CompareLanguageCode (Language, UnicodeStringTable->Language)) {\r
 \r
           //\r
           // A matching string was found, so return it\r
@@ -587,7 +685,7 @@ LookupUnicodeString (
       return EFI_UNSUPPORTED;\r
     }\r
 \r
-    SupportedLanguages += 3;\r
+    SupportedLanguages = NextSupportedLanguage (SupportedLanguages);\r
   }\r
 \r
   return EFI_UNSUPPORTED;\r
@@ -664,7 +762,7 @@ AddUnicodeString (
   // Make sure Language is a member of SupportedLanguages\r
   //\r
   while (*SupportedLanguages != 0) {\r
-    if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+    if (CompareLanguageCode (Language, SupportedLanguages)) {\r
 \r
       //\r
       // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
@@ -673,7 +771,7 @@ AddUnicodeString (
       if (*UnicodeStringTable != NULL) {\r
         OldUnicodeStringTable = *UnicodeStringTable;\r
         while (OldUnicodeStringTable->Language != NULL) {\r
-          if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) {\r
+          if (CompareLanguageCode (Language, OldUnicodeStringTable->Language)) {\r
             return EFI_ALREADY_STARTED;\r
           }\r
 \r
@@ -707,7 +805,7 @@ AddUnicodeString (
       //\r
       // Allocate space for a copy of the Language specifier\r
       //\r
-      NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language);\r
+      NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize (Language), Language);\r
       if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
         (gBS->FreePool) (NewUnicodeStringTable);\r
         return EFI_OUT_OF_RESOURCES;\r
@@ -753,7 +851,7 @@ AddUnicodeString (
       return EFI_SUCCESS;\r
     }\r
 \r
-    SupportedLanguages += 3;\r
+    SupportedLanguages = NextSupportedLanguage (SupportedLanguages);\r
   }\r
 \r
   return EFI_UNSUPPORTED;\r
index c995b92bc9d1cb928e535f50247ba442a27c4b5d..bccb35a44b68ad8219577cca4b3c139782c761a4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -67,7 +67,7 @@ GlueEfiCreateEventLegacyBoot (
 {\r
   return EfiCreateEventLegacyBootEx (\r
            EFI_TPL_CALLBACK,\r
-           InternalEmptyFuntion,\r
+           NULL,\r
            NULL,\r
            LegacyBootEvent\r
            );\r
@@ -101,29 +101,50 @@ EfiCreateEventLegacyBootEx (
   OUT EFI_EVENT         *LegacyBootEvent\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
+  EFI_STATUS        Status;\r
+  UINT32            EventType;\r
+  EFI_EVENT_NOTIFY  WorkerNotifyFunction;\r
 \r
   ASSERT (LegacyBootEvent != NULL);\r
 \r
 #if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
+\r
+  if (NotifyFunction == NULL) {\r
+    EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
+  } else {\r
+    EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;\r
+  }\r
+  WorkerNotifyFunction = NotifyFunction;\r
+\r
   //\r
   // prior to UEFI 2.0 use Tiano extension to EFI\r
   //\r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
+                  EventType,\r
                   NotifyTpl,\r
-                  NotifyFunction,\r
+                  WorkerNotifyFunction,\r
                   NotifyContext,\r
                   LegacyBootEvent\r
                   );\r
 #else\r
+\r
+  EventType = EVENT_NOTIFY_SIGNAL;\r
+  if (NotifyFunction == NULL) {\r
+    //\r
+    // CreatEventEx will check NotifyFunction is NULL or not\r
+    //\r
+    WorkerNotifyFunction = InternalEmptyFuntion;\r
+  } else {\r
+    WorkerNotifyFunction = NotifyFunction;\r
+  }\r
+\r
   //\r
   // For UEFI 2.0 and the future use an Event Group\r
   //\r
   Status = gBS->CreateEventEx (\r
-                  EVENT_NOTIFY_SIGNAL,\r
+                  EventType,\r
                   NotifyTpl,\r
-                  NotifyFunction,\r
+                  WorkerNotifyFunction,\r
                   NotifyContext,\r
                   &gEfiEventLegacyBootGuid,\r
                   LegacyBootEvent\r
@@ -157,7 +178,7 @@ GlueEfiCreateEventReadyToBoot (
 {\r
   return EfiCreateEventReadyToBootEx (\r
            EFI_TPL_CALLBACK,\r
-           InternalEmptyFuntion,\r
+           NULL,\r
            NULL,\r
            ReadyToBootEvent\r
            );\r
@@ -191,29 +212,51 @@ EfiCreateEventReadyToBootEx (
   OUT EFI_EVENT         *ReadyToBootEvent\r
   )\r
 {\r
-  EFI_STATUS    Status;\r
+  EFI_STATUS        Status;\r
+  UINT32            EventType;\r
+  EFI_EVENT_NOTIFY     WorkerNotifyFunction;\r
 \r
   ASSERT (ReadyToBootEvent != NULL);\r
 \r
-#if (EFI_SPECIFICATION_VERSION < 0x00020000) \r
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)\r
+  \r
+  if (NotifyFunction == NULL) {\r
+       EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;\r
+  } else {\r
+       EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;\r
+  }\r
+  WorkerNotifyFunction = NotifyFunction;\r
+\r
   //\r
   // prior to UEFI 2.0 use Tiano extension to EFI\r
   //\r
   Status = gBS->CreateEvent (\r
-                  EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,\r
+                  EventType,\r
                   NotifyTpl,\r
-                  NotifyFunction,\r
+                  WorkerNotifyFunction,\r
                   NotifyContext,\r
                   ReadyToBootEvent\r
                   );\r
 #else\r
+\r
+  EventType = EVENT_NOTIFY_SIGNAL;\r
+\r
+  if (NotifyFunction == NULL) {\r
+    //\r
+    // CreatEventEx will check NotifyFunction is NULL or not\r
+    //\r
+    WorkerNotifyFunction = InternalEmptyFuntion;\r
+  } else {\r
+    WorkerNotifyFunction = NotifyFunction;\r
+  }\r
+\r
   //\r
   // For UEFI 2.0 and the future use an Event Group\r
   //\r
   Status = gBS->CreateEventEx (\r
-                  EVENT_NOTIFY_SIGNAL,\r
+                  EventType,\r
                   NotifyTpl,\r
-                  NotifyFunction,\r
+                  WorkerNotifyFunction,\r
                   NotifyContext,\r
                   &gEfiEventReadyToBootGuid,\r
                   ReadyToBootEvent\r
@@ -274,15 +317,6 @@ EfiSignalEventLegacyBoot (
 /**\r
   Check to see if the Firmware Volume (FV) Media Device Path is valid \r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability. The return value to this\r
-  function points to a location in FvDevicePathNode and it does not allocate\r
-  new memory for the GUID pointer that is returned.\r
-\r
   @param  FvDevicePathNode  Pointer to FV device path to check.\r
 \r
   @retval NULL              FvDevicePathNode is not valid.\r
@@ -297,11 +331,6 @@ GlueEfiGetNameGuidFromFwVolDevicePathNode (
 {\r
   ASSERT (FvDevicePathNode != NULL);\r
 \r
-  //\r
-  // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-  // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-  // EFI 1.10 and UEFI 2.10.\r
-  //\r
   if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
       DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
     return (EFI_GUID *) &FvDevicePathNode->NameGuid;\r
@@ -314,13 +343,6 @@ GlueEfiGetNameGuidFromFwVolDevicePathNode (
 /**\r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability.\r
-\r
   @param  FvDevicePathNode  Pointer to a FV device path node to initialize\r
   @param  NameGuid          FV file name to use in FvDevicePathNode\r
 \r
@@ -335,16 +357,10 @@ GlueEfiInitializeFwVolDevicepathNode (
   ASSERT (FvDevicePathNode  != NULL);\r
   ASSERT (NameGuid          != NULL);\r
 \r
-  //\r
-  // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-  // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-  // EFI 1.10 and UEFI 2.10.\r
-  //\r
   FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
   FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_DP;\r
   SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
-  \r
-  CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
 \r
+  CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);\r
 }\r
 \r
index 8aff8813ad81cda5e26e2e678266d1a0068ad060..722c9a966408fe06756f6762ade7b0389d3f0f9e 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-#  Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -60,7 +60,7 @@ COMPONENT_TYPE  = LIBRARY
   Math.c\r
   \r
 [sources.x64]\r
-  X64/EfiCopyMemRep1.asm\r
+  X64/EfiCopyMemRep4.asm\r
   X64/EfiSetMemRep4.asm\r
   X64/EfiZeroMemRep4.asm\r
 #  X64/EfiCopyMem.asm\r
index a6f930dacf1104ae1d3ed7587ce1271266493e65..fd183c1d6a7e848c00a6ce04a8279d6de3f3d900 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-#  Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -85,14 +85,14 @@ COMPONENT_TYPE  = LIBRARY
   Math.c\r
   \r
 [sources.x64]\r
-  X64/EfiCopyMemRep1.asm         | MSFT\r
+  X64/EfiCopyMemRep4.asm         | MSFT\r
   X64/EfiSetMemRep4.asm     | MSFT\r
   X64/EfiZeroMemRep4.asm    | MSFT\r
 #  X64/EfiCopyMem.asm                    | MSFT\r
 #  X64/EfiSetMem.asm        | MSFT\r
 #  X64/EfiZeroMem.asm       | MSFT\r
 \r
-  X64/EfiCopyMemRep1.asm         | INTEL\r
+  X64/EfiCopyMemRep4.asm         | INTEL\r
   X64/EfiSetMemRep4.asm     | INTEL\r
   X64/EfiZeroMemRep4.asm    | INTEL\r
 #  X64/EfiCopyMem.asm                    | INTEL\r
index ed41ff994d3331b03ac03951ca229ad99e253657..580c3fe94b8433278fa6eabb9c31dfb67355883e 100644 (file)
@@ -75,16 +75,16 @@ ASM_PFX(EfiCommonLibCopyMem):
   movl  %esi, %eax\r
   addl  %ecx, %eax                    # Source + Count\r
   cmpl  %edi, %eax\r
-  jle   _StartByteCopy\r
+  jbe   _StartByteCopy\r
 \r
   movl  %edi, %eax\r
   addl  %ecx, %eax                    # Dest + Count\r
   cmpl  %esi, %eax\r
-  jle   _StartByteCopy\r
+  jbe   _StartByteCopy\r
 \r
   cmpl  %edi, %esi\r
   je    _CopyMemDone\r
-  jl    _CopyOverlapped               # too bad -- overlaps\r
+  jb    _CopyOverlapped               # too bad -- overlaps\r
 \r
   # Pick up misaligned start bytes to get destination pointer 4-byte aligned\r
 _StartByteCopy: \r
index 7cf8b7f630789226f818ecf9b4e2e311515d7268..275e29b0c59e5ae35674f610070bcca28a1073e1 100644 (file)
@@ -73,16 +73,16 @@ EfiCommonLibCopyMem PROC
   mov   eax, esi\r
   add   eax, ecx                      ; Source + Count\r
   cmp   eax, edi\r
-  jle   _StartByteCopy\r
+  jbe   _StartByteCopy\r
 \r
   mov   eax, edi\r
   add   eax, ecx                      ; Dest + Count\r
   cmp   eax, esi\r
-  jle   _StartByteCopy\r
+  jbe   _StartByteCopy\r
 \r
   cmp   esi, edi\r
   je    _CopyMemDone         \r
-  jl    _CopyOverlapped               ; too bad -- overlaps\r
+  jb    _CopyOverlapped               ; too bad -- overlaps\r
 \r
   ; Pick up misaligned start bytes to get destination pointer 4-byte aligned\r
 _StartByteCopy:\r
index 0acfdc9e5c0c92fa5eb5b8d4075f1b3fd7e0e70b..cb6b8ffe89d993efcccb1bd7667d7deda29b7b15 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -58,20 +58,21 @@ Returns:
   ;   if (Source == Destination)           => do nothing\r
   ;   if (Source + Count <= Destination)   => regular copy\r
   ;   if (Destination + Count <= Source)   => regular copy\r
+  ;   if (Source >= Destination)           => regular copy\r
   ;   otherwise, do a reverse copy\r
   mov   eax, esi\r
   add   eax, ecx                      ; Source + Count\r
   cmp   eax, edi\r
-  jle   _StartByteCopy\r
+  jbe   _StartByteCopy\r
 \r
   mov   eax, edi\r
   add   eax, ecx                      ; Dest + Count\r
   cmp   eax, esi\r
-  jle   _StartByteCopy\r
+  jbe   _StartByteCopy\r
 \r
   cmp   esi, edi\r
   je    _CopyMemDone         \r
-  jl    _CopyOverlapped               ; too bad -- overlaps\r
+  jb    _CopyOverlapped               ; too bad -- overlaps\r
 \r
   ; Pick up misaligned start bytes to get destination pointer 4-byte aligned\r
 _StartByteCopy:\r
index 9a15288f5c793a5ec923c6aa856dd2a6ee8d345d..595c008a049acaec7cb881689f5e87f90092d06a 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -104,13 +104,13 @@ _CopyBlocks:
 copyxmm:\r
   \r
   movdqu xmm0, OWORD PTR ds:[esi]\r
-  movdqu QWORD PTR ds:[edi], xmm0\r
+  movdqu OWORD PTR ds:[edi], xmm0\r
   movdqu xmm1, OWORD PTR ds:[esi+16]\r
-  movdqu QWORD PTR ds:[edi+16], xmm1\r
+  movdqu OWORD PTR ds:[edi+16], xmm1\r
   movdqu xmm2, OWORD PTR ds:[esi+32]\r
-  movdqu QWORD PTR ds:[edi+32], xmm2\r
+  movdqu OWORD PTR ds:[edi+32], xmm2\r
   movdqu xmm3, OWORD PTR ds:[esi+48]\r
-  movdqu QWORD PTR ds:[edi+48], xmm3\r
+  movdqu OWORD PTR ds:[edi+48], xmm3\r
   \r
   add   edi, 64\r
   add   esi, 64\r
index b22609afb3990beaaadbb0fc2dc13fbc69198665..a40c56bcb1b15d33dff5586af3f4b140b42b6f83 100644 (file)
@@ -65,11 +65,13 @@ ASM_PFX(Power10U64):
   jcxz   _Power10U64_Done\r
 \r
 _Power10U64_Wend: \r
+  pushl  %ecx\r
   pushl  $10\r
   push   0xC(%ebp)\r
   push   0x8(%ebp)\r
   call   ASM_PFX(MultU64x32)\r
   addl   $0xc, %esp\r
+  popl   %ecx\r
   movl   %eax, 8(%ebp)  # dword ptr Operand[0]\r
   movl   %edx, 0xC(%ebp)  # dword ptr Operand[4]\r
   loopl  _Power10U64_Wend\r
index b7d3373fd35154159c9add1578b79ec11ac0d299..b6e25320d45074cee2e018ba62867c944606c57c 100644 (file)
@@ -64,11 +64,13 @@ Power10U64 PROC
   jcxz   _Power10U64_Done\r
   \r
 _Power10U64_Wend:\r
+  push   ecx\r
   push   10\r
   push   [ebp + 0Ch]; dword ptr Operand[4]\r
   push   [ebp + 8]; dword ptr Operand[0]\r
   call   MultU64x32\r
   add    esp, 0cH\r
+  pop    ecx\r
   mov    [ebp + 8] , eax; dword ptr Operand[0]\r
   mov    [ebp + 0Ch] , edx; dword ptr Operand[4]\r
   loop   _Power10U64_Wend\r
index c74e7933dde1d07fcc1775709995d46cec84027b..2a31fe133e4211062b4eb0fa309cb5a6adb85f9c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -56,11 +56,13 @@ Returns:
   jcxz   _Power10U64_Done\r
   \r
 _Power10U64_Wend:\r
+  push   ecx\r
   push   10\r
   push   dword ptr Operand[4]\r
   push   dword ptr Operand[0]\r
   call   MultU64x32\r
   add    esp, 0Ch\r
+  pop    ecx\r
   mov    dword ptr Operand[0], eax\r
   mov    dword ptr Operand[4], edx\r
   loop   _Power10U64_Wend\r
index a931b533ea5912d5691622cb3d9eb9f6ebbfe2a4..c5588691491ecf46256b712eafb0eef198a0a353 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -75,6 +75,21 @@ Returns:
   return Multiplicand * Multiplier;\r
 }\r
 \r
+UINT64\r
+Power10U64 (\r
+  IN UINT64   Operand,\r
+  IN UINTN    Power\r
+  )\r
+{\r
+  UINT64 Result;\r
+\r
+  Result = Operand;\r
+  while (Power-- > 0) {\r
+    Result *= 10;\r
+  }\r
+  return Result;\r
+}\r
+\r
 UINT64\r
 RShiftU64 (\r
   IN UINT64   Operand,\r
index 5356e235e87666ebd87f34cad1cf7a1da77d9aea..ef68647569317b75f5d1b6c83c5ea2d6e4dbe08d 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -20,8 +20,8 @@ Abstract:
 #include "Tiano.h"\r
 #include "pei.h"\r
 #include "cpuio.h"\r
-#include "pcicfg.h"\r
-#include "pcicfg2.h"\r
+#include EFI_PPI_CONSUMER (PciCfg)\r
+#include EFI_PPI_CONSUMER (PciCfg2)\r
 #include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)\r
 \r
 //\r
@@ -68,8 +68,6 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS  Status;\r
-\r
   mPeiServices  = NULL;\r
   CpuIoPpi      = NULL;\r
   PciCfgPpi     = NULL;\r
@@ -136,7 +134,7 @@ Returns:
   EFI_STATUS                      Status;\r
   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
 \r
-  if (mPeiServices == NULL) {\r
+  if (mPeiServices != NULL) {\r
     //\r
     // The function is called in PEI phase, use PEI interfaces\r
     //\r
@@ -197,7 +195,7 @@ Returns:
   EFI_STATUS                      Status;\r
   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
 \r
-  if (mPeiServices == NULL) {\r
+  if (mPeiServices != NULL) {\r
     //\r
     // The function is called in PEI phase, use PEI interfaces\r
     //\r
@@ -260,7 +258,7 @@ Returns:
   UINT8                           *Buffer8;\r
   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;\r
 \r
-  if (mPeiServices == NULL) {\r
+  if (mPeiServices != NULL) {\r
     //\r
     // The function is called in PEI phase, use PEI interfaces\r
     //\r
index b2fde2721d953fb2ec27e65e826b29912964678f..8fd3f932474a829d4b24260d4036c0ed85d75660 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -195,8 +195,8 @@ EFI_STATUS
 EFIAPI\r
 PeiLibFfsFindNextFile (\r
   IN EFI_FV_FILETYPE            SearchType,\r
-  IN EFI_PEI_FV_HANDLE          FwVolHeader,\r
-  IN OUT EFI_PEI_FILE_HANDLE    *FileHeader\r
+  IN EFI_PEI_FV_HANDLE          FvHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
   )\r
 /*++\r
 \r
@@ -207,7 +207,7 @@ Routine Description:
 Arguments:\r
 \r
   SearchType   - Filter to find only file of this type.\r
-  FwVolHeader  - Pointer to the current FV to search.\r
+  FvHandle     - Pointer to the current FV to search.\r
   FileHandle   - Pointer to the file matching SearchType in FwVolHeader.\r
                 - NULL if file not found\r
 \r
@@ -271,7 +271,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 PeiLibFfsGetVolumeInfo (\r
-  IN EFI_PEI_FV_HANDLE  *VolumeHandle,\r
+  IN EFI_PEI_FV_HANDLE  VolumeHandle,\r
   OUT EFI_FV_INFO       *VolumeInfo\r
   )\r
 /*++\r
@@ -464,7 +464,7 @@ MigrateIdtTable (
 \r
 Routine Description:\r
 \r
-  Migrate IDT from temporary memory to real memory where preceded with 4 bytes for\r
+  Migrate IDT from CAR to real memory where preceded with 4 bytes for\r
   storing PeiService pointer.\r
 \r
 Arguments:\r
index bc4ca8ee6689c6a119b3c8bf8b277fc8e3a9095d..1904902c7878c8868fbd8cbb34a5a306a806b2bb 100644 (file)
@@ -70,7 +70,7 @@ PeCoffLoaderLoadImage (
 EFI_STATUS\r
 EFIAPI\r
 PeCoffLoaderUnloadImage (\r
-  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext\r
+  IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext\r
   );\r
 \r
 #if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)\r
@@ -565,7 +565,10 @@ Returns:
     // Pe image and in Te image header there is not a field to describe the imagesize,\r
     // we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize\r
     //\r
-    ImageContext->ImageSize         = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);\r
+    ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);\r
+    if(Hdr.Te->DataDirectory[1].VirtualAddress > Hdr.Te->DataDirectory[0].VirtualAddress) {\r
+      ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[1].VirtualAddress + Hdr.Te->DataDirectory[1].Size);\r
+    }\r
     ImageContext->SectionAlignment  = 4096;\r
     ImageContext->SizeOfHeaders     = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize;\r
 \r
@@ -1013,6 +1016,12 @@ Returns:
   UINT32                                TempDebugEntryRva;\r
   UINT32                                NumberOfRvaAndSizes;\r
   UINT16                                Magic;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+  EFI_IMAGE_RESOURCE_DIRECTORY          *ResourceDirectory;\r
+  EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY    *ResourceDirectoryEntry;\r
+  EFI_IMAGE_RESOURCE_DIRECTORY_STRING   *ResourceDirectoryString;\r
+  EFI_IMAGE_RESOURCE_DATA_ENTRY         *ResourceDataEntry;\r
+#endif\r
 \r
   if (NULL == ImageContext) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1368,6 +1377,73 @@ Returns:
     }\r
   }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)\r
+  //\r
+  // Get Image's HII resource section\r
+  //\r
+  if (!(ImageContext->IsTeImage)) {\r
+    if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {\r
+      //\r
+      // Use PE32 offset\r
+      //\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];\r
+    } else {\r
+      //\r
+      // Use PE32+ offset\r
+      //\r
+      DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];\r
+    }\r
+\r
+    if (DirectoryEntry->Size != 0) {\r
+      Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);\r
+\r
+      ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;\r
+      ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+\r
+      for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {\r
+        if (ResourceDirectoryEntry->u1.s.NameIsString) {\r
+          ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);\r
+\r
+          if (ResourceDirectoryString->Length == 3 &&\r
+              ResourceDirectoryString->String[0] == L'H' &&\r
+              ResourceDirectoryString->String[1] == L'I' &&\r
+              ResourceDirectoryString->String[2] == L'I') {\r
+            //\r
+            // Resource Type "HII" found\r
+            //\r
+            if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+              //\r
+              // Move to next level - resource Name\r
+              //\r
+              ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
+              ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+\r
+              if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+                //\r
+                // Move to next level - resource Language\r
+                //\r
+                ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
+                ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+              }\r
+            }\r
+\r
+            //\r
+            // Now it ought to be resource Data\r
+            //\r
+            if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+              ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);\r
+              ImageContext->HiiResourceData = (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);\r
+              break;\r
+            }\r
+          }\r
+        }\r
+\r
+        ResourceDirectoryEntry++;\r
+      }\r
+    }\r
+  }\r
+#endif\r
+\r
 #if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)\r
   AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress));\r
 #endif\r
@@ -1378,7 +1454,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 PeCoffLoaderUnloadImage (\r
-  IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext\r
+  IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext\r
   )\r
 /*++\r
 \r
index 824ab4b8ceb4b74c25c9c648101ca41e8b50a1c3..11ae5a17f0a0c20d262eadac7ee16b4a2a1aee46 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -383,8 +383,8 @@ EFI_STATUS
 EFIAPI\r
 PeiLibFfsFindNextFile (\r
   IN EFI_FV_FILETYPE            SearchType,\r
-  IN EFI_PEI_FV_HANDLE          FwVolHeader,\r
-  IN OUT EFI_PEI_FILE_HANDLE    *FileHeader\r
+  IN EFI_PEI_FV_HANDLE          FvHandle,\r
+  IN OUT EFI_PEI_FILE_HANDLE    *FileHandle\r
   )\r
 /*++\r
 \r
@@ -395,9 +395,9 @@ Routine Description:
 Arguments:\r
 \r
   SearchType   - Filter to find only file of this type.\r
-  FwVolHeader  - Pointer to the current FV to search.\r
+  FvHandle     - Pointer to the current FV to search.\r
   FileHandle   - Pointer to the file matching SearchType in FwVolHeader.\r
-                - NULL if file not found\r
+               - NULL if file not found\r
 \r
 Returns:\r
   EFI_STATUS\r
@@ -407,7 +407,7 @@ Returns:
   EFI_PEI_SERVICES  **PeiServices;\r
   \r
   PeiServices = GetPeiServicesTablePointer();\r
-  return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader);\r
+  return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FvHandle, FileHandle);\r
 }\r
 \r
 \r
@@ -471,13 +471,13 @@ Returns:
   EFI_PEI_SERVICES  **PeiServices;\r
   \r
   PeiServices = GetPeiServicesTablePointer();\r
-  return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData);\r
+  return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, (EFI_PEI_FILE_HANDLE)FfsFileHeader, SectionData);\r
 }\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 PeiLibFfsGetVolumeInfo (\r
-  IN EFI_PEI_FV_HANDLE  *VolumeHandle,\r
+  IN EFI_PEI_FV_HANDLE  VolumeHandle,\r
   OUT EFI_FV_INFO       *VolumeInfo\r
   )\r
 /*++\r
index 9e01b2cd9e693ac7a67148f805d04aa6ef785435..884ec1cc27eb84b058093c6ca99de485da34fb18 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2010, 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
@@ -35,6 +35,8 @@ typedef struct {
   UINT64 R14;\r
   UINT64 R15;\r
   UINT64 Rip;\r
+  UINT32 MxCsr;\r
+  UINT8  XmmBuffer[160]; // XMM6-XMM15\r
 } EFI_JUMP_BUFFER;\r
 \r
 #endif\r
index aa366c2a1f59021cc5711fe1a7bd6c85f97e12fe..c930486183fe4133df5fb1a27b1d68f50bcecc5e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2010, 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
@@ -84,8 +84,6 @@ Returns:
 --*/\r
 {\r
   *This = &mTransferControl;\r
-  mTransferControl.SetJump = TransferControlSetJump;\r
-  mTransferControl.LongJump = TransferControlLongJump;\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -112,7 +110,6 @@ Returns:
 --*/\r
 {\r
   *This = &mFlushInstructionCache;\r
-  mFlushInstructionCache.Flush = FlushInstructionCacheFlush;\r
   return EFI_SUCCESS;\r
 }\r
 \r
index b6be0b2f60e544b6b11ac587f0ee7fba0bfc556d..418400c15a14269c044b91f2e3efc9375171d2e2 100644 (file)
@@ -1,6 +1,6 @@
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2005 - 2010, 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
@@ -73,6 +73,8 @@ _r13            QWORD           ?
 _r14            QWORD           ?\r
 _r15            QWORD           ?\r
 _rip            QWORD           ?\r
+_MxCsr          DWORD           ?\r
+_XmmBuffer      DB              160 DUP (?)\r
 _EFI_JUMP_BUFFER                ENDS\r
 \r
 EFI_JUMP_BUFFER         TYPEDEF         _EFI_JUMP_BUFFER\r
@@ -116,6 +118,19 @@ TransferControlSetJump  PROC
   mov   (EFI_JUMP_BUFFER PTR [rdx])._r13, r13\r
   mov   (EFI_JUMP_BUFFER PTR [rdx])._r14, r14\r
   mov   (EFI_JUMP_BUFFER PTR [rdx])._r15, r15\r
+  ; save non-volatile fp registers\r
+  stmxcsr    (EFI_JUMP_BUFFER PTR [rdx])._MxCsr\r
+  lea   rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer\r
+  movdqu [rax], xmm6\r
+  movdqu [rax + 10h], xmm7\r
+  movdqu [rax + 20h], xmm8\r
+  movdqu [rax + 30h], xmm9\r
+  movdqu [rax + 40h], xmm10\r
+  movdqu [rax + 50h], xmm11\r
+  movdqu [rax + 60h], xmm12\r
+  movdqu [rax + 70h], xmm13\r
+  movdqu [rax + 80h], xmm14\r
+  movdqu [rax + 90h], xmm15\r
   mov   rax, QWORD PTR [rsp+0]\r
   mov   (EFI_JUMP_BUFFER PTR [rdx])._rip, rax\r
   mov   rax, EFI_SUCCESS  \r
@@ -134,6 +149,19 @@ TransferControlSetJump      ENDP
 ;\r
 PUBLIC  TransferControlLongJump\r
 TransferControlLongJump  PROC  \r
+  ; load non-volatile fp registers\r
+  ldmxcsr    (EFI_JUMP_BUFFER PTR [rdx])._MxCsr\r
+  lea   rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer\r
+  movdqu xmm6, [rax]\r
+  movdqu xmm7, [rax + 10h]\r
+  movdqu xmm8, [rax + 20h]\r
+  movdqu xmm9, [rax + 30h]\r
+  movdqu xmm10, [rax + 40h]\r
+  movdqu xmm11, [rax + 50h]\r
+  movdqu xmm12, [rax + 60h]\r
+  movdqu xmm13, [rax + 70h]\r
+  movdqu xmm14, [rax + 80h]\r
+  movdqu xmm15, [rax + 90h]\r
   ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP\r
   mov   rax, EFI_WARN_RETURN_FROM_LONG_JUMP          \r
   mov   rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx\r
index 5253c0e2d10388c45216212b7afe24b4589b3216..2d464488cc2fea7593cf0a140752a0425f99a650 100644 (file)
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------
 #
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
 # 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        
@@ -99,6 +99,19 @@ ASM_PFX(TransferControlSetJump):
       mov    %r13,0x40(%rdx)
       mov    %r14,0x48(%rdx)
       mov    %r15,0x50(%rdx)
+      #; save non-volatile fp registers\r
+      stmxcsr 0x60(%rdx)\r
+      lea     0x68(%rdx), %rax\r
+      movdqu  %xmm6, (%rax) \r
+      movdqu  %xmm7, 0x10(%rax)\r
+      movdqu  %xmm8, 0x20(%rax)\r
+      movdqu  %xmm9, 0x30(%rax)\r
+      movdqu  %xmm10, 0x40(%rax)\r
+      movdqu  %xmm11, 0x50(%rax)\r
+      movdqu  %xmm12, 0x60(%rax)\r
+      movdqu  %xmm13, 0x70(%rax)\r
+      movdqu  %xmm14, 0x80(%rax)\r
+      movdqu  %xmm15, 0x90(%rax)\r
       mov    (%rsp),%rax
       mov    %rax,0x58(%rdx)
       mov    $0x0,%rax
@@ -115,7 +128,20 @@ ASM_PFX(TransferControlSetJump):
 #
 #
 ASM_PFX(TransferControlLongJump):
-  # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+      # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+      #; load non-volatile fp registers\r
+      ldmxcsr 0x60(%rdx)\r
+      lea     0x68(%rdx), %rax\r
+      movdqu  (%rax), %xmm6\r
+      movdqu  0x10(%rax), %xmm7\r
+      movdqu  0x20(%rax), %xmm8\r
+      movdqu  0x30(%rax), %xmm9\r
+      movdqu  0x40(%rax), %xmm10\r
+      movdqu  0x50(%rax), %xmm11\r
+      movdqu  0x60(%rax), %xmm12\r
+      movdqu  0x70(%rax), %xmm13\r
+      movdqu  0x80(%rax), %xmm14\r
+      movdqu  0x90(%rax), %xmm15\r
       mov    $0x5,%rax
       mov    (%rdx),%rbx
       mov    0x8(%rdx),%rsp
index 9807b45035bbc890ccd0099f655405dc0f6c217f..29cdeb967a2173a172f11f754322f1f7ea8bd0fc 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -21,9 +21,11 @@ Abstract:
 \r
 #include "Tiano.h"\r
 #include "EfiRuntimeLib.h"\r
+#include "PeiHob.h"\r
 #include EFI_PROTOCOL_DEFINITION (CpuIo)\r
 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
 #include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (Hob)\r
 #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
 \r
 //\r
@@ -43,7 +45,81 @@ BOOLEAN                     mEfiAtRuntime = FALSE;
 FVB_ENTRY                   *mFvbEntry;\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-static EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+\r
+EFI_REPORT_STATUS_CODE      gReportStatusCode         = NULL;\r
+EFI_EVENT                   gEfiStatusCodeNotifyEvent = NULL;\r
+\r
+VOID\r
+EFIAPI\r
+OnStatusCodeInstall (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_STATUS_CODE_PROTOCOL  *StatusCode;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);\r
+  if (!EFI_ERROR (Status)) {\r
+    gReportStatusCode = StatusCode->ReportStatusCode;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+GetPeiProtocol (\r
+  IN EFI_GUID  *ProtocolGuid,\r
+  IN VOID      **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Searches for a Protocol Interface passed from PEI through a HOB\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid - The Protocol GUID to search for in the HOB List\r
+\r
+  Interface    - A pointer to the interface for the Protocol GUID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - The Protocol GUID was found and its interface is returned in Interface\r
+\r
+  EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  //\r
+  // Get Hob list\r
+  //\r
+  Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {\r
+    if (END_OF_HOB_LIST (GuidHob)) {\r
+      Status = EFI_NOT_FOUND;\r
+      break;\r
+    }\r
+\r
+    if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
+      if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {\r
+        Status     = EFI_SUCCESS;\r
+        *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+      }\r
+    }\r
+\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
 #endif\r
 \r
 EFI_STATUS\r
@@ -214,9 +290,8 @@ Returns:
   //\r
   EfiConvertInternalPointer ((VOID **) &gCpuIo);\r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  if (gStatusCode != NULL) {\r
-    EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);\r
-    EfiConvertInternalPointer ((VOID **) &gStatusCode);\r
+  if (gReportStatusCode != NULL) {\r
+    EfiConvertInternalPointer ((VOID **) &gReportStatusCode);\r
   }\r
 #endif\r
   EfiConvertInternalPointer ((VOID **) &mRT);\r
@@ -256,6 +331,9 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS  Status;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  VOID *Registration;\r
+#endif\r
 \r
   if (mRuntimeLibInitialized) {\r
     return EFI_ALREADY_STARTED;\r
@@ -275,10 +353,26 @@ Returns:
   ASSERT_EFI_ERROR (Status);\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-  if (EFI_ERROR (Status)) {\r
-    gStatusCode = NULL;\r
-  }\r
+  //\r
+  // Register EFI_STATUS_CODE_PROTOCOL notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  EFI_TPL_CALLBACK,\r
+                  OnStatusCodeInstall,\r
+                  NULL,\r
+                  &gEfiStatusCodeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  gEfiStatusCodeNotifyEvent,\r
+                  &Registration\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  gBS->SignalEvent (gEfiStatusCodeNotifyEvent);\r
 #endif\r
 \r
   Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);\r
@@ -363,6 +457,16 @@ Returns:
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  //\r
+  // Close EfiStatusCodeRuntimeProtocol notify function\r
+  //\r
+  if (gEfiStatusCodeNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+#endif\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -390,6 +494,9 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS  Status;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  VOID *Registration;\r
+#endif\r
 \r
   if (mRuntimeLibInitialized) {\r
     return EFI_ALREADY_STARTED;\r
@@ -406,10 +513,26 @@ Returns:
   ASSERT (mRT != NULL);\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-  if (EFI_ERROR (Status)) {\r
-    gStatusCode = NULL;\r
-  }\r
+  //\r
+  // Register EFI_STATUS_CODE_PROTOCOL notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  EFI_TPL_CALLBACK,\r
+                  OnStatusCodeInstall,\r
+                  NULL,\r
+                  &gEfiStatusCodeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  gEfiStatusCodeNotifyEvent,\r
+                  &Registration\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  gBS->SignalEvent (gEfiStatusCodeNotifyEvent);\r
 #endif\r
 \r
   Status  = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);\r
@@ -761,8 +884,8 @@ EfiReportStatusCode (
   IN EFI_STATUS_CODE_TYPE     CodeType,\r
   IN EFI_STATUS_CODE_VALUE    Value,\r
   IN UINT32                   Instance,\r
-  IN EFI_GUID                 * CallerId,\r
-  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  IN EFI_GUID                 *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL  \r
   )\r
 /*++\r
 \r
@@ -788,19 +911,30 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS               Status;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
-  if (gStatusCode == NULL) {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  if (gReportStatusCode == NULL) {\r
+    //\r
+    // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,\r
+    //   running here indicates that the StatusCode driver has not started yet.\r
+    //\r
     if (EfiAtRuntime ()) {\r
+      //\r
+      // Running here only when StatusCode driver never starts.\r
+      //\r
       return EFI_UNSUPPORTED;\r
     }\r
-    Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-    if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
+\r
+    //\r
+    // Try to get the PEI version of ReportStatusCode.\r
+    //\r
+    Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);\r
+    if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
   }\r
-  Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
+  Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
 #else\r
   if (mRT == NULL) {\r
     return EFI_UNSUPPORTED;\r
index c94ee431ef32303fbb16f704fc81bba95fb46d20..ac169a1166785a27f00d87c593910e1df7378f81 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -599,13 +599,6 @@ Routine Description:
 \r
   Initialize a Firmware Volume (FV) Media Device Path node.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability.\r
-\r
 Arguments:\r
 \r
   FvDevicePathNode  - Pointer to a FV device path node to initialize\r
@@ -617,11 +610,6 @@ Returns:
 \r
 --*/\r
 {\r
-  //\r
-  // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-  // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-  // EFI 1.10 and UEFI 2.10.\r
-  //\r
   FvDevicePathNode->Header.Type     = MEDIA_DEVICE_PATH;\r
   FvDevicePathNode->Header.SubType  = MEDIA_FV_FILEPATH_DP;\r
   SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));\r
@@ -640,15 +628,6 @@ Routine Description:
 \r
   Check to see if the Firmware Volume (FV) Media Device Path is valid.\r
   \r
-  Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum\r
-  so as we move to UEFI 2.0 support we must use a mechanism that conforms with\r
-  the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed \r
-  device path is defined for PIWG extensions of device path. If the code \r
-  is compiled to conform with the UEFI 2.0 specification use the new device path\r
-  else use the old form for backwards compatability. The return value to this\r
-  function points to a location in FvDevicePathNode and it does not allocate\r
-  new memory for the GUID pointer that is returned.\r
-\r
 Arguments:\r
 \r
   FvDevicePathNode  - Pointer to FV device path to check\r
@@ -660,16 +639,11 @@ Returns:
 \r
 --*/\r
 {\r
-  //\r
-  // EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10. \r
-  // In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with\r
-  // EFI 1.10 and UEFI 2.10.\r
-  //\r
   if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&\r
       DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {\r
     return &FvDevicePathNode->NameGuid;\r
   }\r
 \r
-   return NULL;\r
+  return NULL;\r
 }\r
 \r
index 8771e2bcd3ba88c1721ebffef53eece6a7b5e5ac..11b36e056dda8434d98a2db3f991b28d9dce7a3b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2010, 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
@@ -21,9 +21,11 @@ Abstract:
 \r
 #include "Tiano.h"\r
 #include "EfiRuntimeLib.h"\r
+#include "PeiHob.h"\r
 #include EFI_PROTOCOL_DEFINITION (CpuIo)\r
 #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r
 #include EFI_GUID_DEFINITION (StatusCodeCallerId)\r
+#include EFI_GUID_DEFINITION (Hob)\r
 #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r
 \r
 //\r
@@ -43,7 +45,81 @@ BOOLEAN                     mEfiAtRuntime = FALSE;
 FVB_ENTRY                   *mFvbEntry;\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-static EFI_STATUS_CODE_PROTOCOL  *gStatusCode = NULL;\r
+\r
+EFI_REPORT_STATUS_CODE      gReportStatusCode         = NULL;\r
+EFI_EVENT                   gEfiStatusCodeNotifyEvent = NULL;\r
+\r
+VOID\r
+EFIAPI\r
+OnStatusCodeInstall (\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_STATUS_CODE_PROTOCOL  *StatusCode;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);\r
+  if (!EFI_ERROR (Status)) {\r
+    gReportStatusCode = StatusCode->ReportStatusCode;\r
+  }\r
+}\r
+\r
+EFI_STATUS\r
+GetPeiProtocol (\r
+  IN EFI_GUID  *ProtocolGuid,\r
+  IN VOID      **Interface\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Searches for a Protocol Interface passed from PEI through a HOB\r
+\r
+Arguments:\r
+\r
+  ProtocolGuid - The Protocol GUID to search for in the HOB List\r
+\r
+  Interface    - A pointer to the interface for the Protocol GUID\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS   - The Protocol GUID was found and its interface is returned in Interface\r
+\r
+  EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List\r
+\r
+--*/\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PEI_HOB_POINTERS  GuidHob;\r
+\r
+  //\r
+  // Get Hob list\r
+  //\r
+  Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {\r
+    if (END_OF_HOB_LIST (GuidHob)) {\r
+      Status = EFI_NOT_FOUND;\r
+      break;\r
+    }\r
+\r
+    if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
+      if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {\r
+        Status     = EFI_SUCCESS;\r
+        *Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));\r
+      }\r
+    }\r
+\r
+    GuidHob.Raw = GET_NEXT_HOB (GuidHob);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
 #endif\r
 \r
 EFI_STATUS\r
@@ -214,9 +290,8 @@ Returns:
   //\r
   EfiConvertInternalPointer ((VOID **) &gCpuIo);\r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  if (gStatusCode != NULL) {\r
-    EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);\r
-    EfiConvertInternalPointer ((VOID **) &gStatusCode);\r
+  if (gReportStatusCode != NULL) {\r
+    EfiConvertInternalPointer ((VOID **) &gReportStatusCode);\r
   }\r
 #endif\r
   EfiConvertInternalPointer ((VOID **) &mRT);\r
@@ -256,6 +331,9 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS  Status;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  VOID *Registration;\r
+#endif\r
 \r
   if (mRuntimeLibInitialized) {\r
     return EFI_ALREADY_STARTED;\r
@@ -275,10 +353,26 @@ Returns:
   ASSERT_EFI_ERROR (Status);\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-  if (EFI_ERROR (Status)) {\r
-    gStatusCode = NULL;\r
-  }\r
+  //\r
+  // Register EFI_STATUS_CODE_PROTOCOL notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  EFI_TPL_CALLBACK,\r
+                  OnStatusCodeInstall,\r
+                  NULL,\r
+                  &gEfiStatusCodeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  gEfiStatusCodeNotifyEvent,\r
+                  &Registration\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  gBS->SignalEvent (gEfiStatusCodeNotifyEvent);\r
 #endif\r
 \r
   Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);\r
@@ -363,6 +457,16 @@ Returns:
     ASSERT_EFI_ERROR (Status);\r
   }\r
 \r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  //\r
+  // Close EfiStatusCodeRuntimeProtocol notify function\r
+  //\r
+  if (gEfiStatusCodeNotifyEvent != NULL) {\r
+    Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+#endif\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -390,6 +494,9 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS  Status;\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  VOID *Registration;\r
+#endif\r
 \r
   if (mRuntimeLibInitialized) {\r
     return EFI_ALREADY_STARTED;\r
@@ -406,10 +513,26 @@ Returns:
   ASSERT (mRT != NULL);\r
 \r
 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
-  Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-  if (EFI_ERROR (Status)) {\r
-    gStatusCode = NULL;\r
-  }\r
+  //\r
+  // Register EFI_STATUS_CODE_PROTOCOL notify function\r
+  //\r
+  Status = gBS->CreateEvent (\r
+                  EFI_EVENT_NOTIFY_SIGNAL,\r
+                  EFI_TPL_CALLBACK,\r
+                  OnStatusCodeInstall,\r
+                  NULL,\r
+                  &gEfiStatusCodeNotifyEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gBS->RegisterProtocolNotify (\r
+                  &gEfiStatusCodeRuntimeProtocolGuid,\r
+                  gEfiStatusCodeNotifyEvent,\r
+                  &Registration\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  gBS->SignalEvent (gEfiStatusCodeNotifyEvent);\r
 #endif\r
 \r
   Status  = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);\r
@@ -761,8 +884,8 @@ EfiReportStatusCode (
   IN EFI_STATUS_CODE_TYPE     CodeType,\r
   IN EFI_STATUS_CODE_VALUE    Value,\r
   IN UINT32                   Instance,\r
-  IN EFI_GUID                 * CallerId,\r
-  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  IN EFI_GUID                 *CallerId OPTIONAL,\r
+  IN EFI_STATUS_CODE_DATA     *Data     OPTIONAL  \r
   )\r
 /*++\r
 \r
@@ -788,19 +911,30 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS  Status;\r
+  EFI_STATUS               Status;\r
 \r
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000) \r
-  if (gStatusCode == NULL) {\r
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r
+  if (gReportStatusCode == NULL) {\r
+    //\r
+    // Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,\r
+    //   running here indicates that the StatusCode driver has not started yet.\r
+    //\r
     if (EfiAtRuntime ()) {\r
+      //\r
+      // Running here only when StatusCode driver never starts.\r
+      //\r
       return EFI_UNSUPPORTED;\r
     }\r
-    Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r
-    if (EFI_ERROR (Status) || gStatusCode == NULL) {\r
+\r
+    //\r
+    // Try to get the PEI version of ReportStatusCode.\r
+    //\r
+    Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);\r
+    if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
   }\r
-  Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
+  Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r
 #else\r
   if (mRT == NULL) {\r
     return EFI_UNSUPPORTED;\r
index fcf7ff44d454ea04654d0ed0b5177506e0303249..dd1cb289fc1352793a17b2ad7b98bdf774c49872 100644 (file)
@@ -1,6 +1,6 @@
 #*****************************************************************************\r
 #*\r
-#*   Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+#*   Copyright (c) 2006 - 2010, 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
@@ -51,4 +51,26 @@ ASM_PFX(AsmFxRestore):
     ret\r
 #AsmFxRestore ENDP\r
 \r
+#------------------------------------------------------------------------------\r
+# UINTN\r
+# AsmGetEflags (\r
+#   VOID\r
+#   );\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(AsmGetEflags):\r
+    pushfl\r
+    pop   %eax\r
+    ret\r
+#AsmGetEflags ENDP\r
 \r
+#------------------------------------------------------------------------------\r
+# VOID\r
+# AsmSetEflags (\r
+#   IN UINTN   Eflags\r
+#   );\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(AsmSetEflags):\r
+    push  4(%esp)\r
+    popfl\r
+    ret\r
+#AsmSetEflags ENDP\r
index e07b52a46c220bb728f755c4f2c670a21943ecd1..7f3f275b37cf5eeb7c4a6b18049177adb6632cb4 100644 (file)
@@ -1,6 +1,6 @@
 ;*****************************************************************************\r
 ;*\r
-;*   Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+;*   Copyright (c) 2006 - 2010, 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
@@ -48,4 +48,28 @@ AsmFxRestore  PROC
     ret\r
 AsmFxRestore  ENDP\r
 \r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; AsmGetEflags (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmGetEflags PROC\r
+    pushfd\r
+    pop   eax\r
+    ret\r
+AsmGetEflags ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; AsmSetEflags (\r
+;   IN UINTN   Eflags\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmSetEflags PROC\r
+    push  [esp + 4]\r
+    popfd\r
+    ret\r
+AsmSetEflags ENDP\r
+\r
     END\r
index d1feb9972e9a8ece1037c60ef2ec537a6e1b01c2..55415d87035c9140ea98988fb92f2bc216c32eff 100644 (file)
@@ -1,6 +1,6 @@
 #*****************************************************************************\r
 #*\r
-#*   Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+#*   Copyright (c) 2006 - 2010, 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
@@ -72,6 +72,9 @@ ASM_PFX(Thunk16):
     push   $0xd\r
     pop    %ecx\r
     rep movsl %ds:(%esi),%es:(%edi)   #; copy context to 16-bit stack\r
+    #; copy eflags to stack frame\r
+    mov    -12(%esi), %eax\r
+    mov    %eax, -72(%edi) \r
     pop    %ebx                       #; ebx <- 16-bit stack offset\r
     mov    $L_Lable1,%eax\r
     stos   %eax,%es:(%edi)\r
@@ -140,20 +143,23 @@ ASM_PFX(RealMode):
     popw    %es\r
     popw    %fs\r
     popw    %gs\r
-    addw    $4, %sp                     # skip EFlags\r
-    testw   $1, 14(%esp)                  #(_STK16 ptr [esp + 8]).ThunkFlags, 1\r
+    sub     60, %esp\r
+    popfw\r
+    testw   $1, 74(%esp)                #(_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1\r
+\r
     jz      1f\r
-    pushf\r
+    pushf                               # push Flags when it's INT#\r
 1: \r
     pushw   %cs\r
 #    push    @FarCallRet - _Code16Addr\r
     .byte   0x68                        # push /iw\r
     .word   FarCallRet - _Code16Addr\r
     jz      2f\r
-    ljmp    *6(%esp)                  #bugbug\r
+    ljmp    *66(%esp)                   #[esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]\r
 2: \r
-    ljmp    *4(%esp)                  #bugbug\r
+    ljmp    *64(%esp)                   #[esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]\r
 FarCallRet: \r
+    add     60, %esp\r
     pushfl\r
     pushw   %gs\r
     pushw   %fs\r
index 410347764ac1e2479809aba6381a7ac54b45cb37..76c1317469af9de0f1ce12291a2e3402cd11cce3 100644 (file)
@@ -1,6 +1,6 @@
 ;*****************************************************************************\r
 ;*\r
-;*   Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+;*   Copyright (c) 2006 - 2010, 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
@@ -55,6 +55,8 @@ _DATA   ENDS
 \r
 _TEXT   SEGMENT FLAT    "CODE"  PARA\r
 \r
+STACK_PARAM_SIZE  EQU  16\r
+\r
 IA32_REGS   STRUC   4t\r
 _EDI        DD      ?\r
 _ESI        DD      ?\r
@@ -99,6 +101,11 @@ __Thunk16   PROC    USES    ebp ebx esi edi ds  es  fs  gs
     push    sizeof (IA32_REGS) / 4\r
     pop     ecx\r
     rep     movsd                       ; copy context to 16-bit stack\r
+\r
+    ; copy eflags to stack frame\r
+    mov     eax, [esi - sizeof(IA32_REGS)]._EFLAGS\r
+    mov     [edi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 4], eax\r
+\r
     pop     ebx                         ; ebx <- 16-bit stack offset\r
     mov     eax, offset @F              ; return offset\r
     stosd\r
@@ -158,20 +165,22 @@ RealMode    PROC
     pop     es\r
     pop     fs\r
     pop     gs\r
-    add     sp, 4                       ; skip EFlags\r
-    test    (_STK16 ptr [esp + 8]).ThunkFlags, 1\r
+    sub     esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4\r
+    popfd\r
+    test    (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1\r
     jz      @F\r
-    pushf\r
+    pushf                               ; push Flags when it's INT#\r
 @@:\r
     push    cs\r
 ;    push    @FarCallRet - _Code16Addr\r
     DB      68h                         ; push /iw\r
     DW      @FarCallRet - _Code16Addr\r
     jz      @F\r
-    jmp     fword ptr [esp + 6]\r
+    jmp     fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]\r
 @@:\r
-    jmp     fword ptr [esp + 4]\r
+    jmp     fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]\r
 @FarCallRet:\r
+    add     esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4\r
     pushfd\r
     push    gs\r
     push    fs\r
index 8a865616c138701294360ccd9dc51ef0ab7965a3..6c16e25e4b04e4aaa35fa0ad2816db1391ae7fbd 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -237,6 +237,13 @@ Returns:
 --*/\r
 ;\r
 \r
+BOOLEAN\r
+AsmThunk16SetUserStack (\r
+  IN THUNK_CONTEXT             *ThunkContext,\r
+  IN VOID                      *Stack,\r
+  IN UINTN                     StackSize\r
+  );\r
+\r
 VOID\r
 EFIAPI\r
 AsmThunk16Destroy (\r
index 30c76974e2f640dc1e543527e5aa4f0bc37f1d23..c0807bc5236e35589802a8a9b9411a51625dd3b4 100644 (file)
@@ -41,8 +41,30 @@ ASM_PFX(AsmFxSave):
 #   IN CONST IA32_FX_BUFFER *Buffer
 #   );
 #------------------------------------------------------------------------------
-
 ASM_PFX(AsmFxRestore):
     fxrstor (%rcx)
     retq
-    
\ No newline at end of file
+
+#------------------------------------------------------------------------------\r
+# UINTN\r
+# AsmGetEflags (\r
+#   VOID\r
+#   );\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(AsmGetEflags):\r
+    pushfq\r
+    popq  %rax\r
+    ret\r
+#AsmGetEflags ENDP\r
+\r
+#------------------------------------------------------------------------------\r
+# VOID\r
+# AsmSetEflags (\r
+#   IN UINTN   Eflags\r
+#   );\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(AsmSetEflags):\r
+    pushq  %rcx\r
+    popfq\r
+    ret\r
+#AsmSetEflags ENDP\r
index f9c2e4d57b591253e28c7ad6cd17ee90445e4a20..ab4a97f23a0ab80f31aab30236117c1de46de912 100644 (file)
@@ -1,6 +1,6 @@
 ;*****************************************************************************\r
 ;*\r
-;*   Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+;*   Copyright (c) 2006 - 2010, 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
@@ -43,4 +43,28 @@ AsmFxRestore  PROC
     ret\r
 AsmFxRestore  ENDP\r
 \r
+;------------------------------------------------------------------------------\r
+; UINTN\r
+; AsmGetEflags (\r
+;   VOID\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmGetEflags PROC\r
+    pushfq\r
+    pop   rax\r
+    ret\r
+AsmGetEflags ENDP\r
+\r
+;------------------------------------------------------------------------------\r
+; VOID\r
+; AsmSetEflags (\r
+;   IN UINTN   Eflags\r
+;   );\r
+;------------------------------------------------------------------------------\r
+AsmSetEflags PROC\r
+    push  rcx\r
+    popfq\r
+    ret\r
+AsmSetEflags ENDP\r
+\r
     END\r
index 888801b1ab3ced0f2f909dfbf8e3a557e6be907e..10f3a34c1920d2a1e96853cb72025480ecceea5c 100644 (file)
@@ -1,6 +1,6 @@
 #*****************************************************************************\r
 #*\r
-#*   Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
+#*   Copyright (c) 2008 - 2010, 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
@@ -106,6 +106,9 @@ ASM_PFX(Thunk16):
       pushq  $0xe                       #push    sizeof (IA32_REGS) / 4\r
       pop    %rcx\r
       rep movsl %ds:(%rsi),%es:(%rdi)\r
+      #; copy eflags to stack frame\r
+      mov    -16(%rsi), %rax\r
+      mov    %rax, -80(%rsi)\r
       pop    %rbx                       #rbx <- 16-bit stack offset\r
       lea    Label,%eax                 #42 <_Thunk16+0x42>\r
       stos   %eax,%es:(%rdi)\r
@@ -183,27 +186,30 @@ ASM_PFX(RealMode):
    .byte   0x07                        #pop es\r
     popq   %fs\r
     popq   %gs\r
-    add    $0x8,%esp                   #skip RFLAGS\r
-   .byte   0x67                        #test [esp + 0eh], 1\r
+    sub    64, %esp\r
+    .byte  0x66, 0x9d                  #popfd\r
+    add    $0x4,%esp                   #skip high part of RFLAGS\r
+   .byte   0x67                        #; test    (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1\r
    .byte   0xf7    \r
    .byte   0x44\r
    .byte   0x24\r
-   .byte   0x0e\r
+   .byte   0x4e\r
    .byte   0x01\r
    .byte   0x00\r
     jz      1f\r
-    pushfq                             #pushf, actually\r
+    pushfq                             #pushf, actually, when it's INT#\r
 1:\r
    .byte   0x0e                        #push cs\r
    .byte   0x68                        #push /iw\r
    .word   FarCallRet - _Code16Addr\r
     jz     2f\r
    .byte   0x66\r
-    ljmp   *6(%esp)\r
+    ljmp   *70(%esp)\r
 2:    \r
    .byte   0x66\r
-    ljmp   *4(%esp)\r
+    ljmp   *68(%esp)\r
 FarCallRet: \r
+    add    64, %esp\r
    .byte   0x66\r
     push   $0x00                       #push a dword of zero\r
    .byte   0x66\r
index b6a8f86879bf1adaef349f8f4c43ed7f4a9d84d5..0638d5faa8de9a3a6067853c506387572faaad76 100644 (file)
@@ -1,6 +1,6 @@
 ;*****************************************************************************\r
 ;*\r
-;*   Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+;*   Copyright (c) 2006 - 2010, 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
@@ -49,6 +49,8 @@ _16Gdtr         LABEL   FWORD
 \r
     .code\r
 \r
+STACK_PARAM_SIZE  EQU  16\r
+\r
 IA32_REGS   STRUC   4t\r
 _EDI        DD      ?\r
 _ESI        DD      ?\r
@@ -98,6 +100,11 @@ _Thunk16    PROC    USES    rbp rbx rsi rdi r12 r13 r14 r15
     push    sizeof (IA32_REGS) / 4\r
     pop     rcx\r
     rep     movsd\r
+\r
+    ; copy eflags to stack frame\r
+    mov     rax, (IA32_REGS ptr [rsi - sizeof(IA32_REGS)])._RFLAGS\r
+    mov     [rdi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 8], rax\r
+\r
     pop     rbx                         ; rbx <- 16-bit stack offset\r
     lea     eax, @F                     ; return offset\r
     stosd\r
@@ -165,22 +172,27 @@ RealMode    PROC
     DB      7                           ; pop es\r
     pop     fs\r
     pop     gs\r
+    sub     esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8\r
 \r
-    add     esp, 8                      ; skip RFLAGS\r
-    DB      67h, 0f7h, 44h, 24h, 0eh, 1, 0  ; test [esp + 0eh], 1\r
+    DB      66h, 9Dh                    ; popfd\r
+    add     esp, 4                      ; skip high part of RFLAGS\r
+    DB      67h, 0f7h, 44h, 24h         ; test    (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1\r
+    DB      (STACK_PARAM_SIZE + sizeof(IA32_REGS) + 6)\r
+    DB      1, 0\r
     jz      @F\r
-    pushfq                              ; pushf, actually\r
+    pushfq                              ; pushf, actually, when it's INT#\r
 @@:\r
     DB      0eh                         ; push cs\r
     DB      68h                         ; push /iw\r
     DW      @FarCallRet - _Code16Addr\r
     jz      @F\r
     DB      66h\r
-    jmp     fword ptr [esp + 6]\r
+    jmp     fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]\r
 @@:\r
     DB      66h\r
-    jmp     fword ptr [esp + 4]\r
+    jmp     fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]\r
 @FarCallRet:\r
+    add     esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8\r
     DB      66h\r
     push    0                           ; push a dword of zero\r
     pushf                               ; pushfd, actually\r
index c9aafd36aacc229a6476dce51d98e01d4e01c9e6..ed24663b48a17dc081832fac6e24e0bc66493628 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -53,6 +53,18 @@ AsmFxSave (
   OUT IA32_FX_BUFFER *Buffer\r
   );\r
 \r
+UINTN\r
+EFIAPI\r
+AsmGetEflags (\r
+  VOID\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+AsmSetEflags (\r
+  IN UINTN   Eflags\r
+  );\r
+\r
 //\r
 // Implementation\r
 //\r
@@ -98,6 +110,7 @@ Returns:
 {\r
   IA32_FX_BUFFER                    *FpSavedState;\r
   UINT8                             FpBuffer[sizeof (*FpSavedState) + 0x10];\r
+  UINTN                             Eflags;\r
 \r
   FpSavedState = (IA32_FX_BUFFER*)(((UINTN)FpBuffer + 0xf) & ~0xf);\r
 \r
@@ -110,6 +123,8 @@ Returns:
     AsmFxSave (FpSavedState);\r
   }\r
 \r
+  Eflags = AsmGetEflags ();\r
+\r
   EfiCommonLibCopyMem (\r
     RegisterSet,\r
     _Thunk16 (\r
@@ -120,6 +135,8 @@ Returns:
     sizeof (*RegisterSet)\r
     );\r
 \r
+   AsmSetEflags (Eflags);\r
+\r
   if (ThunkFlags & THUNK_SAVE_FP_STATE) {\r
     AsmFxRestore (FpSavedState);\r
   }\r
@@ -200,6 +217,67 @@ Returns:
   return ThunkContext;\r
 }\r
 \r
+#pragma pack (1)\r
+\r
+typedef struct {\r
+  UINT32                            EDI;\r
+  UINT32                            ESI;\r
+  UINT32                            EBP;\r
+  UINT32                            ESP;\r
+  UINT32                            EBX;\r
+  UINT32                            EDX;\r
+  UINT32                            ECX;\r
+  UINT32                            EAX;\r
+  UINT16                            DS;\r
+  UINT16                            ES;\r
+  UINT16                            FS;\r
+  UINT16                            GS;\r
+  UINTN                             EFLAGS;\r
+  UINT32                            EIP;\r
+  UINT16                            CS;\r
+  UINT16                            SS;\r
+} IA32_REGS;\r
+\r
+typedef struct {\r
+  UINT16  Limit;\r
+  UINT32  Base;\r
+} IA32_DESC;\r
+\r
+typedef struct {\r
+  UINT32    RetEip;\r
+  UINT16    RetCs;\r
+  UINT16    ThunkFlags;\r
+#ifdef EFI32\r
+  UINT32    SavedEsp;\r
+  UINT16    SavedSs;\r
+#endif\r
+  IA32_DESC SavedGdtr;\r
+#ifdef EFIX64\r
+  UINT16    Resvd1;\r
+#endif\r
+  UINT32    SavedCr0;\r
+  UINT32    SavedCr4;\r
+} _STK16;\r
+#pragma pack ()\r
+\r
+#define STACK_PARAM_SIZE  16\r
+\r
+BOOLEAN\r
+AsmThunk16SetUserStack (\r
+  IN THUNK_CONTEXT             *ThunkContext,\r
+  IN VOID                      *Stack,\r
+  IN UINTN                     StackSize\r
+  )\r
+{\r
+  if (StackSize > STACK_PARAM_SIZE) {\r
+    return FALSE;\r
+  }\r
+\r
+  EfiCommonLibCopyMem ((VOID *)(UINTN)(ThunkContext->DefaultStack - sizeof(_STK16) - sizeof(IA32_REGS) - STACK_PARAM_SIZE), Stack, StackSize);\r
+\r
+  return TRUE;\r
+}\r
+\r
 VOID\r
 EFIAPI\r
 AsmThunk16Destroy (\r
@@ -253,12 +331,8 @@ Arguments:
                   set on input, otherwise ignored.\r
                   EFlages is ignored on input.\r
                   On output, values of CS, EIP, SS and ESP should be ignored.\r
-  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
-                  THUNK_USER_STACK.\r
-                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
-                                        before/after calling real mode code.\r
-                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
-                                        used instead of the default stack.\r
+  ThunkFlags    - THUNK_USER_STACK: The stack specified by SS:ESP would be\r
+                  used instead of the default stack.\r
 \r
 Returns:\r
 \r
@@ -298,12 +372,8 @@ Arguments:
                   set on input, otherwise ignored.\r
                   EFlages is ignored on input.\r
                   On output, values of CS, EIP, SS and ESP should be ignored.\r
-  ThunkFlags    - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and\r
-                  THUNK_USER_STACK.\r
-                  THUNK_SAVE_FP_STATE - FPU state would be saved/restored\r
-                                        before/after calling real mode code.\r
-                  THUNK_USER_STACK    - The stack specified by SS:ESP would be\r
-                                        used instead of the default stack.\r
+  ThunkFlags    - THUNK_USER_STACK: The stack specified by SS:ESP would be\r
+                  used instead of the default stack.\r
 \r
 Returns:\r
 \r
index f6f2c44fb7fa7247ead7ac3720b76a72dd92ee61..c52ef47f73751f0ec14fe107b0bbb1c55bdb3952 100644 (file)
@@ -1,6 +1,6 @@
 /*++ \r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -68,7 +68,7 @@ typedef
 EFI_STATUS\r
 (EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) (\r
   IN  EFI_CONSOLE_CONTROL_PROTOCOL      *This,\r
-  OUT EFI_CONSOLE_CONTROL_SCREEN_MODE   Mode\r
+  IN  EFI_CONSOLE_CONTROL_SCREEN_MODE   Mode\r
   )\r
 /*++\r
 \r
index c9c96f762c7873b9a41d7d92971fc9d031539e16..56e03e2266b135ebd2c8172aa54b6693f80bcf3a 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -42,7 +42,7 @@ enum {
   IP4_CONFIG_SOURCE_MAX,\r
   \r
   IP4_NIC_NAME_LENGTH        = 64,\r
-  MAX_IP4_CONFIG_IN_VARIABLE = 16\r
+  MAX_IP4_CONFIG_IN_VARIABLE = 128\r
 };\r
 \r
 //\r
index 84d244555e4b3d440e512b2bcee6a7eed495277a..e0290c0b0acc099ba21504c5ecae83e8a531870b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -111,8 +111,8 @@ typedef
 EFI_STATUS\r
 (EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM) (\r
   IN      EFI_TCG_PROTOCOL          *This,\r
-  IN      UINT32                    TpmInputParamterBlockSize,\r
-  IN      UINT8                     *TpmInputParamterBlock,\r
+  IN      UINT32                    TpmInputParameterBlockSize,\r
+  IN      UINT8                     *TpmInputParameterBlock,\r
   IN      UINT32                    TpmOutputParameterBlockSize,\r
   IN      UINT8                     *TpmOutputParameterBlock\r
   );\r
@@ -121,7 +121,7 @@ typedef
 EFI_STATUS\r
 (EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT) (\r
   IN      EFI_TCG_PROTOCOL          *This,\r
-  IN      UINT8                     *HashData,\r
+  IN      EFI_PHYSICAL_ADDRESS      HashData,\r
   IN      UINT64                    HashDataLen,\r
   IN      TCG_ALGORITHM_ID          AlgorithmId,\r
   IN OUT  TCG_PCR_EVENT             *TCGLogData,\r
@@ -160,9 +160,16 @@ EFI_STATUS
   IN      CHAR8                     *ActionString\r
   );\r
 \r
-typedef struct tdEFI_TCG_PLATFORM_PROTOCOL {\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_TCG_MEASURE_GPT_TABLE) (\r
+  IN      EFI_DEVICE_PATH_PROTOCOL  *DevicePath\r
+  );\r
+\r
+typedef struct _EFI_TCG_PLATFORM_PROTOCOL {\r
   EFI_TCG_MEASURE_PE_IMAGE          MeasurePeImage;\r
   EFI_TCG_MEASURE_ACTION            MeasureAction;\r
+  EFI_TCG_MEASURE_GPT_TABLE         MeasureGptTable;\r
 } EFI_TCG_PLATFORM_PROTOCOL;\r
 \r
 extern EFI_GUID                     gEfiTcgPlatformProtocolGuid;\r
index cd7d4c2ea773555f98ee68e28e09feb304dfde05..567e746c83bdabb538999f84d8be5b37bec79c9d 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #  \r
-#  Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -83,6 +83,7 @@ GENFVIMAGE      = $(EDK_TOOLS_OUTPUT)\GenFvImage
 GENSECTION      = $(EDK_TOOLS_OUTPUT)\GenSection\r
 GENTEIMAGE      = $(EDK_TOOLS_OUTPUT)\GenTEImage\r
 GUIDCHK         = $(EDK_TOOLS_OUTPUT)\GuidChk\r
+HIIPACK         = $(EDK_TOOLS_OUTPUT)\HiiPack\r
 MAKEDEPS        = $(EDK_TOOLS_OUTPUT)\MakeDeps\r
 PROCESSDSC      = $(EDK_TOOLS_OUTPUT)\ProcessDsc\r
 STRGATHER       = $(EDK_TOOLS_OUTPUT)\StrGather\r
@@ -188,6 +189,7 @@ ASMLINK           = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
 !ENDIF\r
 \r
 BSCMAKE           = bscmake\r
+RC                = rc\r
 \r
 !IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
 ASM_ARCH_FLAGS      = $(ASM_ARCH_FLAGS) /Zi /DDEBUG\r
@@ -274,6 +276,7 @@ ASMLINK           = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
 !ENDIF\r
 \r
 BSCMAKE           = bscmake\r
+RC                = rc\r
 \r
 !IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
 ASM_ARCH_FLAGS      = $(ASM_ARCH_FLAGS) /Zi /DDEBUG\r
@@ -381,6 +384,7 @@ ASMLINK           = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\link
 !ENDIF\r
 \r
 BSCMAKE           = bscmake\r
+RC                = rc\r
 \r
 !IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
 C_STD_FLAGS         = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj\r
@@ -531,8 +535,10 @@ EBC_CC            = $(EBC_TOOLS_PATH)\Bin\Iec
 EBC_LINK          = $(EBC_TOOLS_PATH)\Bin\Link\r
 EBC_LIB           = $(EBC_TOOLS_PATH)\Bin\Link /lib\r
 \r
+RC                = rc\r
+\r
 !IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"\r
-EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /Zd /Zi\r
+EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) /Zi\r
 EBC_LINK_STD_FLAGS  = $(EBC_LINK_STD_FLAGS) /DEBUG\r
 !ENDIF\r
 \r
@@ -579,6 +585,15 @@ VFRCOMPILE_FLAGS    = $(VFRCOMPILE_FLAGS) -ppflag "$(VERSION_FLAGS)"
 ASM_STD_FLAGS       = $(ASM_STD_FLAGS) $(VERSION_FLAGS)\r
 !ENDIF\r
 \r
+!IF "$(TOOLCHAIN)" != "TOOLCHAIN_MSVC"\r
+BUILD_STRING_FLAGS       = /D EFI_BUILD_VERSION="L\"$(EDK_BUILD_VERSION)\"" /D EFI_FIRMWARE_VENDOR="L\"TianoCore.org\""\r
+!ELSE\r
+BUILD_STRING_FLAGS       = /D UTILITY_BUILD="\"$(EDK_BUILD_VERSION)\"" /D UTILITY_VENDOR="\"TianoCore.org\""\r
+!ENDIF\r
+\r
+C_STD_FLAGS         = $(C_STD_FLAGS) $(BUILD_STRING_FLAGS)\r
+EBC_C_STD_FLAGS     = $(EBC_C_STD_FLAGS) $(BUILD_STRING_FLAGS)\r
+\r
 !IF "$(EFI_DEBUG)" == "YES"\r
 FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_DEBUG\r
 !ENDIF\r
@@ -611,6 +626,10 @@ FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_DXE_PERFORMANCE
 FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_S3_RESUME\r
 !ENDIF\r
 \r
+!IF "$(EFI_NO_CSM_SUPPORT)" == "YES"\r
+FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_NO_CSM_SUPPORT\r
+!ENDIF\r
+\r
 !IF "$(EFI_SIZE_REDUCTION_APPLIED)" == "YES"\r
 FEATURE_FLAGS   = $(FEATURE_FLAGS) /D EFI_SIZE_REDUCTION_APPLIED\r
 !ENDIF\r
index c077e81c9e4e2f3100919c9444ce5320b7724e15..be582eec680cee00c599b6c38c1e2923648732da 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2004 - 2010, 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
@@ -268,7 +268,7 @@ $(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
 # know how to create the .apr file, then you're missing (or mispelled) the\r
 # "APRIORI=" on the component lines in components section in the DSC file.\r
 #\r
-$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)\r
+$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME) $(INF_FILENAME)\r
   $(GENAPRIORI) -v -f $(SOURCE_FILE_NAME) -o $(DEST_DIR)\$(BASE_NAME).bin\r
 \r
 $(DEST_DIR)\$(BASE_NAME).sec : $(DEST_DIR)\$(BASE_NAME).bin\r
@@ -299,34 +299,29 @@ clean :
 [Build.Ia32.Makefile,Build.Ipf.Makefile,Build.Ebc.Makefile,Build.x64.Makefile]\r
 \r
 #\r
-# Copy the makefile directly from the source directory, then make it\r
-# writable so we can copy over it later if we try to.\r
+# Set some required macros\r
 #\r
-$(DEST_DIR)\makefile.new : $(SOURCE_DIR)\makefile.new\r
-  copy $(SOURCE_DIR)\makefile.new $(DEST_DIR)\makefile.new\r
-  attrib -r $(DEST_DIR)\makefile.new\r
+MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR)                \\r
+                  BUILD_DIR=$(BUILD_DIR)                  \\r
+                  FILE_GUID=$(FILE_GUID)                  \\r
+                  DEST_DIR=$(DEST_DIR)                    \\r
+                  PROCESSOR=$(PROCESSOR)                  \\r
+                  TOOLCHAIN=TOOLCHAIN_$(PROCESSOR)        \\r
+                  BASE_NAME=$(BASE_NAME)                  \\r
+                  PACKAGE_FILENAME=$(PACKAGE_FILENAME)\r
 \r
 #\r
-# Make the all target, set some required macros.\r
+# Just call the makefile from the source directory, passing in some\r
+# useful info.\r
 #\r
-call_makefile :\r
-  $(MAKE) -f $(DEST_DIR)\makefile.new all   \\r
-          SOURCE_DIR=$(SOURCE_DIR)          \\r
-          BUILD_DIR=$(BUILD_DIR)            \\r
-          FILE_GUID=$(FILE_GUID)            \\r
-          DEST_DIR=$(DEST_DIR)              \\r
-          PROCESSOR=$(PROCESSOR)            \\r
-          TOOLCHAIN=TOOLCHAIN_$(PROCESSOR)  \\r
-          BASE_NAME=$(BASE_NAME)            \\r
-          PACKAGE_FILENAME=$(PACKAGE_FILENAME)\r
-\r
-all : $(DEST_DIR)\makefile.new call_makefile\r
+all :\r
+  $(MAKE) -f $(SOURCE_DIR)\makefile.new all $(MAKEFILE_MACROS)\r
 \r
 #\r
 # Remove the generated temp and final files for this modules.\r
 #\r
 clean :\r
-  @- $(MAKE) -f $(DEST_DIR)\makefile.new clean > NUL 2>&1\r
+  @- $(MAKE) -f $(SOURCE_DIR)\makefile.new clean $(MAKEFILE_MACROS) > NUL 2>&1\r
 !IF ("$(FILE_GUID)" != "")\r
   @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
 !ENDIF\r
@@ -344,28 +339,32 @@ clean :
 [=============================================================================]\r
 [Build.Ia32.Custom_Makefile,Build.Ipf.Custom_Makefile,Build.Ebc.Custom_Makefile,Build.x64.Custom_Makefile]\r
 \r
+#\r
+# Set some required macros\r
+#\r
+MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR)                \\r
+                  BUILD_DIR=$(BUILD_DIR)                  \\r
+                  DEST_DIR=$(DEST_DIR)                    \\r
+                  FILE_GUID=$(FILE_GUID)                  \\r
+                  PROCESSOR=$(PROCESSOR)                  \\r
+                  TOOLCHAIN=TOOLCHAIN_$(PROCESSOR)        \\r
+                  BASE_NAME=$(BASE_NAME)                  \\r
+                  PLATFORM=$(PLATFORM)                    \\r
+                  SOURCE_FV=$(SOURCE_FV)                  \\r
+                  PACKAGE_FILENAME=$(PACKAGE_FILENAME)\r
+\r
 #\r
 # Just call the makefile from the source directory, passing in some\r
 # useful info.\r
 #\r
 all : \r
-  $(MAKE) -f $(SOURCE_DIR)\makefile all    \\r
-          SOURCE_DIR=$(SOURCE_DIR)         \\r
-          BUILD_DIR=$(BUILD_DIR)           \\r
-          DEST_DIR=$(DEST_DIR)             \\r
-          FILE_GUID=$(FILE_GUID)           \\r
-          PROCESSOR=$(PROCESSOR)           \\r
-          TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \\r
-          BASE_NAME=$(BASE_NAME)           \\r
-          PLATFORM=$(PLATFORM)             \\r
-          SOURCE_FV=$(SOURCE_FV)           \\r
-          PACKAGE_FILENAME=$(PACKAGE_FILENAME)\r
+  $(MAKE) -f $(SOURCE_DIR)\makefile all $(MAKEFILE_MACROS)\r
 \r
 #\r
 # Remove the generated temp and final files for this modules.\r
 #\r
 clean :\r
-  @- $(MAKE) -f $(SOURCE_DIR)\makefile clean > NUL 2>&1\r
+  @- $(MAKE) -f $(SOURCE_DIR)\makefile clean $(MAKEFILE_MACROS) > NUL 2>&1\r
 !IF ("$(FILE_GUID)" != "")\r
   @if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*\r
 !ENDIF\r
@@ -496,9 +495,29 @@ clean :
 \r
 !IF "$(LOCALIZE)" == "YES"\r
 \r
-!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"\r
-STRGATHER_FLAGS   = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))\r
+#\r
+# This will generate HII resource section in PE/COFF image.\r
+#\r
+# Note: when HII package list is built into resource section, Driver no longer\r
+# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather\r
+# ($(BASE_NAME)Strings); while in current build rule, those C array objects\r
+# will still be linked with the Driver, so please turn on link flag "/OPT:REF"\r
+# to minimize the code size.\r
+#\r
+HII_PACK_FILES   = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res\r
+LINK_FLAGS_DLL   = $(LINK_FLAGS_DLL) $(DEST_DIR)\$(BASE_NAME).res\r
+\r
+$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)\r
+  $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii\r
+\r
+$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc\r
+  $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc\r
 \r
+!ENDIF\r
+\r
+!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))\r
 #\r
 # There will be one HII pack containing all the strings. Add that file\r
 # to the list of HII pack files we'll use to create our final HII export file.\r
@@ -507,6 +526,15 @@ HII_PACK_FILES    = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
 LOCALIZE_TARGETS  = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii\r
 !ENDIF\r
 \r
+!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")\r
+#\r
+# Note: currently -ppflag option is only available for UefiStrGather\r
+# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG\r
+#\r
+STRGATHER_PPFLAG = $(C_FLAGS: /GS-=)\r
+STRGATHER_FLAGS  = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+!ENDIF\r
+\r
 $(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)\r
   $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \\r
     -skipext .uni -skipext .h $(SOURCE_FILES)\r
@@ -528,7 +556,7 @@ OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj
 $(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)\r
   $(CC) $(C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c\r
 \r
-LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)\r
 \r
 !ENDIF\r
 \r
@@ -677,7 +705,7 @@ $(TARGET_VER) : $(INF_FILENAME)
   $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_VER) : \r
+$(TARGET_VER) : $(INF_FILENAME)\r
   echo.>$(TARGET_VER)\r
   type $(TARGET_VER)>$(TARGET_VER)\r
 !ENDIF\r
@@ -741,7 +769,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
 !ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_DPX) : \r
+$(TARGET_DPX) : $(INF_FILENAME)\r
   echo. > $(TARGET_DPX)\r
   type $(TARGET_DPX) > $(TARGET_DPX)\r
 !ENDIF\r
@@ -796,7 +824,7 @@ $(TARGET_DXE_DPX) : $(SOURCE_DIR)\$(DXE_DPX_SOURCE) $(INF_FILENAME)
 !ERROR Dependency expression source file "$(SOURCE_DIR)\$(DXE_DPX_SOURCE)" does not exist.\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_DXE_DPX) : \r
+$(TARGET_DXE_DPX) : $(INF_FILENAME)\r
   echo. > $(TARGET_DXE_DPX)\r
   type $(TARGET_DXE_DPX) > $(TARGET_DXE_DPX)\r
 !ENDIF\r
@@ -963,7 +991,7 @@ $(TARGET_VER) : $(INF_FILENAME)
   $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_VER) : \r
+$(TARGET_VER) : $(INF_FILENAME)\r
   echo.>$(TARGET_VER)\r
   type $(TARGET_VER)>$(TARGET_VER)\r
 !ENDIF\r
@@ -1027,7 +1055,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
 !ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_DPX) : \r
+$(TARGET_DPX) : $(INF_FILENAME)\r
   echo. > $(TARGET_DPX)\r
   type $(TARGET_DPX) > $(TARGET_DPX)\r
 !ENDIF\r
@@ -1069,9 +1097,29 @@ LIBS = $(LIBS) $(EBC_TOOLS_PATH)\lib\EbcLib.lib
 \r
 !IF "$(LOCALIZE)" == "YES"\r
 \r
-!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"\r
-STRGATHER_FLAGS   = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))\r
+#\r
+# This will generate HII resource section in PE/COFF image.\r
+#\r
+# Note: when HII package list is built into resource section, Driver no longer\r
+# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather\r
+# ($(BASE_NAME)Strings); while in current build rule, those C array objects\r
+# will still be linked with the Driver, so please turn on link flag "/OPT:REF"\r
+# to minimize the code size.\r
+#\r
+HII_PACK_FILES   = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk\r
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res\r
+OBJECTS          = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME).res\r
+\r
+$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)\r
+  $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii\r
 \r
+$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc\r
+  $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc\r
+\r
+!ENDIF\r
+\r
+!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))\r
 #\r
 # There will be one HII pack containing all the strings. Add that file\r
 # to the list of HII pack files we'll use to create our final HII export file.\r
@@ -1081,6 +1129,15 @@ HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
 LOCALIZE_TARGETS  = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii\r
 !ENDIF\r
 \r
+!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")\r
+#\r
+# Note: currently -ppflag option is only available for UefiStrGather\r
+# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG\r
+#\r
+STRGATHER_PPFLAG = $(EBC_C_FLAGS: /GS-=)\r
+STRGATHER_FLAGS  = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+!ENDIF\r
+\r
 $(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)\r
   $(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \\r
     -skipext .uni -skipext .h $(SOURCE_FILES)\r
@@ -1102,7 +1159,7 @@ OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj
 $(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)\r
   $(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c\r
 \r
-LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h\r
+LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)\r
 \r
 !ENDIF\r
 \r
@@ -1170,7 +1227,7 @@ $(TARGET_VER) : $(INF_FILENAME)
   $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_VER) : \r
+$(TARGET_VER) : $(INF_FILENAME)\r
   echo. > $(TARGET_VER)\r
   type $(TARGET_VER) > $(TARGET_VER)\r
 !ENDIF\r
@@ -1234,7 +1291,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
 !ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_DPX) : \r
+$(TARGET_DPX) : $(INF_FILENAME)\r
   echo. > $(TARGET_DPX)\r
   type $(TARGET_DPX) > $(TARGET_DPX)\r
 !ENDIF\r
@@ -1293,7 +1350,7 @@ clean :
 # This section, as it now exists, only supports boot service drivers.\r
 #\r
 [=============================================================================]\r
-[Build.Ia32.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.Ipf.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.Ebc.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.x64.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI]\r
+[Build.Ia32.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI,Build.Ipf.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI,Build.Ebc.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.x64.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI]\r
 #\r
 # Defines for standard intermediate files and build targets. For the source\r
 # .efi file, take the one in the source directory if it exists. If there's not\r
@@ -1320,6 +1377,8 @@ TARGET_DLL        = $(BIN_DIR)\$(BASE_NAME).dll
 #\r
 !IF "$(COMPONENT_TYPE)" == "APPLICATION"\r
 TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app\r
+!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM"\r
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei\r
 !ELSE\r
 TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe\r
 !ENDIF\r
@@ -1348,7 +1407,7 @@ $(TARGET_VER) : $(INF_FILENAME)
   $(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_VER) : \r
+$(TARGET_VER) : $(INF_FILENAME)\r
   echo. > $(TARGET_VER)\r
   type $(TARGET_VER) > $(TARGET_VER)\r
 !ENDIF\r
@@ -1412,7 +1471,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
 !ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.\r
 !ENDIF\r
 !ELSE\r
-$(TARGET_DPX) : \r
+$(TARGET_DPX) : $(INF_FILENAME)\r
   echo. > $(TARGET_DPX)\r
   type $(TARGET_DPX) > $(TARGET_DPX)\r
 !ENDIF\r
@@ -1438,18 +1497,17 @@ clean :
 [=============================================================================]\r
 [Compile.Ia32.Bin|Bmp,Compile.x64.Bin|Bmp,Compile.Ipf.Bin|Bmp]\r
 #\r
-# We simply copy the binary file from the source directory to the destination directory\r
+# We simply define the binary source file name\r
 #\r
-$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)\r
-  copy $** $@\r
+BINARY_SOURCE_FILE = $(SOURCE_FILE_NAME)\r
 \r
 [=============================================================================]\r
 [Build.Ia32.BINARY|Legacy16|Logo,Build.Ipf.BINARY|Legacy16|Logo,Build.x64.BINARY|Legacy16|Logo]\r
 #\r
 # Use GenFfsFile to convert it to an FFS file\r
 #\r
-$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)\r
-  $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW\r
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)\r
+  $(GENSECTION) -I $(BINARY_SOURCE_FILE) -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW\r
   $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
 \r
 all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs\r
@@ -1469,7 +1527,8 @@ clean :
 #\r
 # Use GenFfsFile to convert it to an raw FFS file\r
 #\r
-$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)\r
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)\r
+  copy $(BINARY_SOURCE_FILE) $(DEST_DIR)\$(BASE_NAME).bin /Y\r
   $(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V\r
 \r
 all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw\r
@@ -1515,6 +1574,8 @@ SDB_FILES       = $(SDB_FILES) $(DEST_DIR)\$(FILE).sdb
 STRGATHER_FLAGS = $(STRGATHER_FLAGS) -db $(DEST_DIR)\$(FILE).sdb\r
 LOCALIZE        = YES\r
 \r
+[=============================================================================]\r
+[Compile.Ia32.hfr,Compile.Ipf.hfr,Compile.Ebc.hfr,Compile.x64.hfr]\r
 [=============================================================================]\r
 [Compile.Ia32.Vfr,Compile.Ipf.Vfr,Compile.x64.Vfr]\r
 \r
@@ -1695,7 +1756,7 @@ HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
 #\r
 # Run GenSection on the firmware volume image.\r
 #\r
-$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME)\r
+$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME) $(INF_FILENAME)\r
   $(GENSECTION) -I $(SOURCE_FILE_NAME) -O $(DEST_DIR)\$(SOURCE_FV)Fv.sec -S EFI_SECTION_FIRMWARE_VOLUME_IMAGE\r
 \r
 [=============================================================================]\r
index 533695cd47fe9960e3bf52c8c8ea64e103ddcd8b..0eba5f9e3a7575886fb4c2654ca6499315208e0e 100644 (file)
@@ -1,5 +1,5 @@
 #/*++\r
-#  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2010, 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
@@ -54,3 +54,4 @@ $(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib\DxeSmbusLib.inf
 $(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib\PeiSmbusLib.inf\r
 $(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxePerformanceLib\DxePerformanceLib.inf\r
 $(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiPerformanceLib\PeiPerformanceLib.inf\r
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\SmmRuntimeDxeReportStatusCodeLib\SmmRuntimeDxeReportStatusCodeLib.inf\r
index 6f2839fa4a8a1b4fa266d41c4f86579e6d34b0dd..099ce167d324ee6daeb57af7f36a044f874fa567 100644 (file)
@@ -1,6 +1,6 @@
 /*++        \r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -20,8 +20,21 @@ Abstract:
 #ifndef _CAPSULE_PEIM_H\r
 #define _CAPSULE_PEIM_H\r
 \r
+#include "Tiano.h"\r
+\r
 //\r
 // If capsule data is passed via a variable, then this name should be used.\r
 //\r
 #define EFI_CAPSULE_VARIABLE_NAME L"CapsuleUpdateData"\r
+\r
+//\r
+// The variable describes the long mode buffer used by IA32 Capsule PEIM\r
+// to call X64 CapsuleCoalesce code to handle >4GB capsule blocks.\r
+//\r
+#define EFI_CAPSULE_LONG_MODE_BUFFER_NAME L"CapsuleLongModeBuffer"\r
+typedef struct {\r
+  UINT64   Base;\r
+  UINT64   Length;\r
+} EFI_CAPSULE_LONG_MODE_BUFFER;\r
+\r
 #endif\r
index 341204852c6b7fa773458a28ca69139ae16f2289..f133d358d5c8f02b7fedbd82ec6e71e5acf05378 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -707,8 +707,13 @@ Returns:
     //\r
     FileLength          = GetLength (FfsHeader->Size);\r
     OccupiedFileLength  = (FileLength + 0x07) & (-1 << 3);\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
     Checksum            = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);\r
     Checksum            = (UINT8) (Checksum - FfsHeader->State);\r
+#else\r
+    Checksum            = CalculateSum8 ((UINT8 *) ((UINTN)FfsHeader + sizeof (EFI_FFS_FILE_HEADER)), FileLength - TailSize - sizeof (EFI_FFS_FILE_HEADER));\r
+    Checksum            =  Checksum + (UINT8)FfsHeader->IntegrityCheck.Checksum.File;\r
+#endif\r
     if (Checksum != 0) {\r
       Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");\r
       return EFI_ABORTED;\r
@@ -716,10 +721,10 @@ Returns:
   } else {\r
     //\r
     // File does not have a checksum\r
-    // Verify contents are 0x5A as spec'd\r
+    // Verify contents are 0x5A(Framework) and 0xAA(PI 1.0) as spec'd\r
     //\r
     if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {\r
-      Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");\r
+      Error (NULL, 0, 0, FileGuidString, "invalid fixed file checksum");\r
       return EFI_ABORTED;\r
     }\r
   }\r
index 3d9fe11ab9d55fddb9e0a349a0a9e19649c26cf5..5abea631069f4fcc2c2418e137bff59a4df09579 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -343,6 +343,152 @@ Returns:
   return EFI_NOT_FOUND;\r
 }\r
 \r
+EFI_STATUS\r
+FindTokenInstanceInSection (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section,\r
+  IN UINTN          Instance,\r
+  OUT CHAR8         *Token,\r
+  OUT CHAR8         *Value\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds the Instance-th token in a section.\r
+\r
+Arguments:\r
+\r
+  InputFile Memory file image.\r
+  Section   The section to search for, a string within [].\r
+  Instance  Specify the Instance-th token to search for, starting from zero\r
+  Token     The token name to return. Caller should allocate the buffer.\r
+            Must be _MAX_PATH in size.\r
+  Value     The token value to return. Caller should allocate the buffer.\r
+            Must be _MAX_PATH in size.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Token and Value found.\r
+  EFI_ABORTED             Format error detected in INF file.\r
+  EFI_INVALID_PARAMETER   Input argument was null.\r
+  EFI_LOAD_ERROR          Error reading from the file.\r
+  EFI_NOT_FOUND           Section/Token/Value not found.\r
+\r
+--*/\r
+{\r
+  CHAR8   InputBuffer[_MAX_PATH];\r
+  CHAR8   *CurrentToken;\r
+  CHAR8   *CurrentValue;\r
+  BOOLEAN ParseError;\r
+  BOOLEAN ReadError;\r
+  UINTN   InstanceIndex;\r
+\r
+  //\r
+  // Check input parameters\r
+  //\r
+  if (InputFile->FileImage == NULL ||\r
+      InputFile->Eof == NULL ||\r
+      InputFile->CurrentFilePointer == NULL ||\r
+      Section == NULL ||\r
+      strlen (Section) == 0 ||\r
+      Value == NULL\r
+      ) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  //\r
+  // Initialize error codes\r
+  //\r
+  ParseError  = FALSE;\r
+  ReadError   = FALSE;\r
+\r
+  //\r
+  // Initialize our instance counter for the search token\r
+  //\r
+  InstanceIndex = 0;\r
+\r
+  if (FindSection (InputFile, Section)) {\r
+    //\r
+    // Found the desired section, find and read the desired token\r
+    //\r
+    do {\r
+      //\r
+      // Read a line from the file\r
+      //\r
+      if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {\r
+        //\r
+        // Error reading from input file\r
+        //\r
+        ReadError = TRUE;\r
+        break;\r
+      }\r
+      //\r
+      // Get the first non-whitespace string\r
+      //\r
+      CurrentToken = strtok (InputBuffer, " \t\n");\r
+      if (CurrentToken == NULL) {\r
+        //\r
+        // Whitespace line found (or comment) so continue\r
+        //\r
+        CurrentToken = InputBuffer;\r
+        continue;\r
+      }\r
+      //\r
+      // Make sure we have not reached the end of the current section\r
+      //\r
+      if (CurrentToken[0] == '[') {\r
+        break;\r
+      }\r
+      //\r
+      // Check if it is the correct instance\r
+      //\r
+      if (Instance == InstanceIndex) {\r
+        //\r
+        // Copy the contents following the =\r
+        //\r
+        CurrentValue = strtok (NULL, "= \t\n");\r
+        if (CurrentValue == NULL) {\r
+          //\r
+          // Nothing found, parsing error\r
+          //\r
+          ParseError = TRUE;\r
+        } else {\r
+          //\r
+          // Copy the current token to the output value\r
+          //\r
+          strcpy (Token, CurrentToken);\r
+          strcpy (Value, CurrentValue);\r
+          return EFI_SUCCESS;\r
+        }\r
+      } else {\r
+        //\r
+        // Increment the occurrance found\r
+        //\r
+        InstanceIndex++;\r
+      }\r
+    } while (\r
+      !ParseError &&\r
+      !ReadError &&\r
+      InputFile->CurrentFilePointer < InputFile->Eof &&\r
+      CurrentToken[0] != '[' &&\r
+      InstanceIndex <= Instance\r
+    );\r
+  }\r
+  //\r
+  // Distinguish between read errors and INF file format errors.\r
+  //\r
+  if (ReadError) {\r
+    return EFI_LOAD_ERROR;\r
+  }\r
+\r
+  if (ParseError) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
+\r
 EFI_STATUS\r
 StringToGuid (\r
   IN CHAR8      *AsciiGuidBuffer,\r
index 7dba8f8fdcc36e632a211986d554c09ece38e2f5..3d5eb5c34fb2e031e70f0ca81966b67f2c1f2e53 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -124,6 +124,42 @@ Returns:
   EFI_NOT_FOUND           Section/Token/Value not found.\r
 \r
 --*/\r
+\r
+EFI_STATUS\r
+FindTokenInstanceInSection (\r
+  IN MEMORY_FILE    *InputFile,\r
+  IN CHAR8          *Section,\r
+  IN UINTN          Instance,\r
+  OUT CHAR8         *Token,\r
+  OUT CHAR8         *Value\r
+  )\r
+;\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Finds the Instance-th token in a section.\r
+\r
+Arguments:\r
+\r
+  InputFile Memory file image.\r
+  Section   The section to search for, a string within [].\r
+  Instance  Specify the Instance-th token to search for, starting from zero\r
+  Token     The token name to return. Caller should allocate the buffer.\r
+            Must be _MAX_PATH in size.\r
+  Value     The token value to return. Caller should allocate the buffer.\r
+            Must be _MAX_PATH in size.\r
+\r
+Returns:\r
+\r
+  EFI_SUCCESS             Token and Value found.\r
+  EFI_ABORTED             Format error detected in INF file.\r
+  EFI_INVALID_PARAMETER   Input argument was null.\r
+  EFI_LOAD_ERROR          Error reading from the file.\r
+  EFI_NOT_FOUND           Section/Token/Value not found.\r
+\r
+--*/\r
+\r
 EFI_STATUS\r
 StringToGuid (\r
   IN CHAR8        *AsciiGuidBuffer,\r
index d30d6272cf0bb289edccbae5ad3652024fa78432..8fbcd10a4e4d6241204a72560fcdef3d849efb02 100644 (file)
@@ -1,6 +1,6 @@
 /*++ \r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -25,6 +25,9 @@ Abstract:
 #include "TianoCommon.h"\r
 #include "Compress.h"\r
 \r
+#define UTILITY_VERSION "v1.0"\r
+#define UTILITY_NAME    "EfiCompress"\r
+\r
 typedef enum {\r
   EFI_COMPRESS   = 1,\r
   TIANO_COMPRESS = 2\r
@@ -365,22 +368,32 @@ Usage (
   CHAR8 *ExeName\r
   )\r
 {\r
-  fprintf (\r
-      stdout, \r
-      "\n"\r
-      "Usage: %s [-tCompressType] InFileName OutFileName\n"\r
-      "       %*c [[-tCompressType] InFileName OutFileName ...]\n"\r
-      "\n"\r
-      "where:\n"\r
-      "  CompressType - optional compress algorithm (EFI | Tiano), case insensitive.\n"\r
-      "                 If ommitted, compress type specified ahead is used, \n"\r
-      "                 default is EFI\n"\r
-      "                 e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\ \n"\r
-      "                                     c.in c.out -tEFI d.in d.out\n"\r
-      "                 a.in and d.in are compressed using EFI compress algorithm\n"\r
-      "                 b.in and c.in are compressed using Tiano compress algorithm\n"\r
-      "  InFileName   - input file path\n"\r
-      "  OutFileName  - output file path\n",\r
-      ExeName, strlen(ExeName), ' '\r
-      );\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Compress Utility",\r
+    "  Copyright (C), 2006 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION] SOURCE DEST ...",\r
+    "Description:",\r
+    "  Compress a list of SOURCE(s) to accordingly DEST(s) using the specified",\r
+    "  compress algorithm.",\r
+    "Options:",\r
+    "  -tCompressAlgo   Optional compress algorithm (EFI | Tiano), case insensitive.",\r
+    "                   If ommitted, compress type specified ahead is used,",\r
+    "                   default is EFI\n"\r
+    "                   e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\",\r
+    "                                     c.in c.out -tEFI d.in d.out",\r
+    "                   a.in and d.in are compressed using EFI compress algorithm",\r
+    "                   b.in and c.in are compressed using Tiano compress algorithm",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+  \r
 }\r
index 11ae84f8ff26b1ed81ed1955c96d6ce234307d93..cf8efc86e1b4855b9e64416a7f4daec2d3f67afa 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, 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
@@ -45,7 +45,8 @@ Abstract:
 //\r
 // Version of this utility\r
 //\r
-#define UTILITY_VERSION "v2.6"\r
+#define UTILITY_NAME    "EfiRom"\r
+#define UTILITY_VERSION "v2.7"\r
 \r
 //\r
 // Define some status return values\r
@@ -1311,39 +1312,42 @@ Returns:
 \r
 --*/\r
 {\r
-  int               Index;\r
-  static const char *Msg[] = {\r
-    "EfiRom "UTILITY_VERSION" - Intel EFI Make Option ROM utility",\r
-    "  Copyright (C), 1999 - 2002 Intel Coproration\n",\r
-    "  Create an option ROM image from a list of input files",\r
-    "  Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",\r
-    "                [-e|-b] [FileName(s)]",\r
-    "    where:",\r
-    "      VendorId       - required hex PCI Vendor ID for the device",\r
-    "      DeviceId       - required hex PCI Device ID for the device",\r
-    "      OutFileName    - optional output file name. Default is the first input",\r
-    "                       file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",\r
-    "      FileNames      - input PE32 or binary file name(s)",\r
-    "      BinFileName    - input binary file name(s)",\r
-    "      -p             - for verbose output",\r
-    "      -l             - to not automatically set the LAST bit on the last file",\r
-    "      -b             - following FileNames are binary files",\r
-    "      -e             - following FileNames are EFI PE32 image files",\r
-    "      -ec            - following FileNames are EFI PE32 image files, and should",\r
-    "                       be compressed by this utility",\r
-    "      -cc ClassCode  - to use hex ClassCode in the PCI data structure header for",\r
-    "                       the following FileName",\r
-    "      -rev Revision  - to use hex Revision in the PCI data structure header for",\r
-    "                       the following FileName",\r
-    "      -dump          - to dump the headers of an existing option ROM image",\r
-    "",\r
-    "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",\r
+  int        Index;\r
+  const char *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Make Option ROM Utility",\r
+    "  Copyright (C), 1999 - 2008 Intel Coproration",\r
+\r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+\r
     "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]... SOURCE ...",\r
+    "Description:",\r
+    "  Create an option ROM image from a list of input files",\r
+    "Options:",\r
+    "  -v  VendorId      - required hex PCI Vendor ID for the device",\r
+    "  -d  DeviceId      - required hex PCI Device ID for the device",\r
+    "  -o  OutFileName   - optional output file name. Default is the first input",\r
+    "                      file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",\r
+    "  -e  SOURCE ...    - input are EFI PE32 image file(s)",\r
+    "  -b  SOURCE ...    - input are Legacy binary file(s)",\r
+    "  -ec SOURCE ...    - input are EFI PE32 image file(s) and should be compressed",\r
+    "  -p                - for verbose output",\r
+    "  -l                - to not automatically set the LAST bit on the last file",\r
+    "  -cc ClassCode     - to use hex ClassCode in the PCI data structure header for",\r
+    "                      the following SOURCE(s)",\r
+    "  -rev Revision     - to use hex Revision in the PCI data structure header for",\r
+    "                      the following one SOURCE",\r
+    "  -dump             - to dump the headers of an existing option ROM image",\r
+    "Example Usage:",\r
+    "  EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",\r
     NULL\r
   };\r
 \r
-  for (Index = 0; Msg[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Msg[Index]);\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
   }\r
 }\r
 \r
index eb23dc7637934a2a4e850a38126a779c2567ccd2..d5f2ecee0aa4859b36f1cf028ebb604796aa4917 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -29,7 +29,8 @@ Abstract:
 #include "EfiImage.h"\r
 #include "EfiUtilityMsgs.c"\r
 \r
-#define UTILITY_NAME  "FwImage"\r
+#define UTILITY_NAME    "FwImage"\r
+#define UTILITY_VERSION "v1.0"\r
 \r
 typedef union {\r
   IMAGE_NT_HEADERS32 PeHeader32;\r
@@ -41,10 +42,33 @@ Usage (
   VOID\r
   )\r
 {\r
-  printf ("Usage: " UTILITY_NAME "  {-t time-date} {-e} {-r} [APPLICATION|BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|COMBINED_PEIM_DRIVER|SECURITY_CORE|PEI_CORE|PE32_PEIM|RELOCATABLE_PEIM] peimage [outimage]\n");\r
-  printf ("  -t: Add Time Stamp for output image\n");\r
-  printf ("  -e: Not clear ExceptionTable for output image\n");\r
-  printf ("  -r: Not strip zero pending of .reloc for output image\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Firmware Image Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+\r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]... FWTYPE SOURCE [DEST]",\r
+    "Description:",\r
+    "  Converts a pe32/pe32+ SOURCE to DEST with FWTYPE image type.",\r
+    "Options:",\r
+    "  FWTYPE        Can be one of APPLICATION, BS_DRIVER, RT_DRIVER, SAL_RT_DRIVER,",\r
+    "                COMBINED_PEIM_DRIVER, SECURITY_CORE, PEI_CORE, PE32_PEIM and",\r
+    "                RELOCATABLE_PEIM",\r
+    "  -t time-date  Add Time Stamp for output image",\r
+    "  -e            Not clear ExceptionTable for output image",\r
+    "  -r            Not strip zero pending of .reloc for output image",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }  \r
 }\r
 \r
 static\r
index e346a1e4c879c7421df5519e47034f36d99a1692..81ffcb78dfa03df8aa97ea26374c37d1bd9d8783 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
- Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2010, 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
@@ -39,7 +39,8 @@ Abstract:
 // #define STATUS_WARNING        1\r
 // #define STATUS_ERROR          2\r
 //\r
-#define UTILITY_NAME  "GenAprioriFile"\r
+#define UTILITY_NAME    "GenAprioriFile"\r
+#define UTILITY_VERSION "v1.0"\r
 //\r
 // Here's all our globals.\r
 //\r
@@ -447,18 +448,26 @@ Returns:
   \r
 --*/\r
 {\r
-  int               Index;\r
-  static const char *Str[] = {\r
-    UTILITY_NAME " -- create an Apriori file consumable by the DXE dispatcher",\r
-    "  Usage: "UTILITY_NAME " [Options]",\r
-    "  Options include:",\r
-    "    -h or -?         for this help information",\r
-    "    -f AprioriFile   parse the GUID'ed files in AprioriFile (required)",\r
-    "    -o OutputFile    write output to OutputFile (required)",\r
-    "    -i               for intelligent re-creation of OutputFile",\r
-    "    -null            to terminate the output file with a NULL GUID",\r
-    "    -v               verbose option",\r
+  int        Index;\r
+  const char *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Apriori File Utility",\r
+    "  Copyright (C), 2006 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
     "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]...",\r
+    "Description:",\r
+    "  Generate an Apriori file consumable by the DXE or PEI dispatcher.",\r
+    "Options:",\r
+    "  -h or -?         for this help information",\r
+    "  -f AprioriFile   parse the GUID'ed files in AprioriFile (required)",\r
+    "  -o OutputFile    write output to OutputFile (required)",\r
+    "  -i               for intelligent re-creation of OutputFile",\r
+    "  -null            to terminate the output file with a NULL GUID",\r
+    "  -v               verbose option",\r
     NULL\r
   };\r
   for (Index = 0; Str[Index] != NULL; Index++) {\r
index b1f3f1eec480f0663684e63f5c0ae5bd7e587ff2..5bbbd14c7e036de24827c8a27eed113e7ecb7c57 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -35,9 +35,9 @@ Abstract:
 \r
 #include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)\r
 \r
-#define TOOLVERSION   "0.2"\r
+#define UTILITY_VERSION "v1.0"\r
 \r
-#define UTILITY_NAME  "GenCrc32Section"\r
+#define UTILITY_NAME    "GenCrc32Section"\r
 \r
 EFI_GUID  gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;\r
 \r
@@ -134,12 +134,26 @@ PrintUsage (
   VOID\r
   )\r
 {\r
-  printf ("Usage:\n");\r
-  printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");\r
-  printf ("   -i \"inputfile\":\n ");\r
-  printf ("       specifies the input files that would be signed to CRC32 Guided section.\n");\r
-  printf ("   -o \"outputfile\":\n");\r
-  printf ("       specifies the output file that is a CRC32 Guided section.\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate CRC32 Section Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]",\r
+    "Options:",\r
+    "  -i Input1 ...  specifies the input file(s) that would be signed to CRC32",\r
+    "                 Guided section.",\r
+    "  -o Output      specifies the output file that is a CRC32 Guided section",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 INT32\r
index 37c1039c0f135a91a882f3ecdc325402a3c11891..2cfc3079abc9cb3f8b62b9d229cf8e1972f4b0cc 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -77,7 +77,15 @@ Abstract:
 \r
 #include "GenDepex.h"\r
 \r
-#define TOOL_NAME "GenDepex"\r
+//\r
+// Utility Name\r
+//\r
+#define UTILITY_NAME  "GenDepex"\r
+\r
+//\r
+// Utility version information\r
+//\r
+#define UTILITY_VERSION "v1.0"\r
 \r
 extern\r
 BOOLEAN\r
@@ -106,13 +114,19 @@ Returns:
 \r
 --*/\r
 {\r
-  printf (\r
-    "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION\r
-    );\r
-  printf ("Copyright (C) 1996-2002 Intel Corporation.  All rights reserved.\n\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Dependency Expression Utility",\r
+    "  Copyright (C), 1996 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 VOID\r
@@ -135,15 +149,22 @@ Returns:
 \r
 --*/\r
 {\r
-  printf (\r
-    "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",\r
-    UTILITY_NAME\r
-    );\r
-  printf (" Where:\n");\r
-  printf ("  <INFILE> is the input pre-processed dependency text files name.\n");\r
-  printf ("  <OUTFILE> is the output binary dependency files name.\n");\r
-  printf ("  <Optional Boundary for padding up> is the padding integer value.\n");\r
-  printf ("    This is the boundary to align the output file size to.\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]...",\r
+    "Options:",\r
+    "  -I INFILE    The input pre-processed dependency text files name",\r
+    "  -O OUTFILE   The output binary dependency files name",\r
+    "  -P BOUNDARY  The padding integer value to align the output file size",\r
+    NULL\r
+  };\r
+\r
+  PrintGenDepexUtilityInfo ();\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 DEPENDENCY_OPCODE\r
@@ -742,7 +763,7 @@ Returns:
       // print an error message.\r
       //\r
       *(Ptrx + 20) = 0;\r
-      printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);\r
+      printf (UTILITY_NAME" ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r
index a1d6ec30d34e390d3a43366cf3aaae478b08a29e..0321a4c8406bb72241f2a61f62c63bab186db7fd 100644 (file)
@@ -1,5 +1,5 @@
 /*++\r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -53,15 +53,5 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define EVAL_STACK_SIZE             0x1024\r
 #define BUFFER_SIZE                 0x100\r
 \r
-//\r
-// Utility Name\r
-//\r
-#define UTILITY_NAME  "GenDepex"\r
-\r
-//\r
-// Utility version information\r
-//\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 4\r
 \r
 #endif\r
index d4053671f5ae9bbe43c181c33499a731ddae45df..269a5b81cb9c9eb4d163571fc5ff14819de1ed52 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -43,7 +43,7 @@ Abstract:
 #include "SimpleFileParsing.h"\r
 \r
 #define UTILITY_NAME    "GenFfsFile"\r
-#define TOOLVERSION     "0.32"\r
+#define UTILITY_VERSION "v1.1"\r
 #define MAX_ARRAY_SIZE  100\r
 \r
 static\r
@@ -123,6 +123,7 @@ static struct {
   UINT8   BuildDirectory[_MAX_PATH];\r
   UINT8   PrimaryPackagePath[_MAX_PATH];\r
   UINT8   OverridePackagePath[_MAX_PATH];\r
+  UINT8   OutputFilePath[_MAX_PATH];\r
   BOOLEAN Verbose;\r
   MACRO   *MacroList;\r
 } mGlobals;\r
@@ -187,22 +188,33 @@ Returns:
 \r
 --*/\r
 {\r
-  printf ("Usage:\n");\r
-  printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\"\n");\r
-  printf ("           -d \"name=value\" -v\n");\r
-  printf ("   -b \"build directory\":\n");\r
-  printf ("       specifies the full path to the component build directory.\n");\r
-  printf ("   -p1 \"P1_path\":\n");\r
-  printf ("       specifies fully qualified file name to the primary package file.\n");\r
-  printf ("       This file will normally exist in the same directory as the makefile\n");\r
-  printf ("       for the component. Required.\n");\r
-  printf ("   -p2 \"P2_path\":\n");\r
-  printf ("       specifies fully qualified file name to the override package file.\n");\r
-  printf ("       This file will normally exist in the build tip. Optional.\n");\r
-  printf ("   -d \"name=value\":\n");\r
-  printf ("       add a macro definition for package file. Optional.\n");\r
-  printf ("   -v :\n");\r
-  printf ("       verbose. Optional.\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate FFS File Utility",\r
+    "  Copyright (C), 2004 - 2009 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]...",\r
+    "Options:",\r
+    "  -b BuildDirectory  Specifies the full path to the component build directory",\r
+    "  -p1 P1Path         Specifies fully qualified file name to the primary package",\r
+    "                     file. This file will normally exist in the same directory",\r
+    "                     as the makefile for the component. Required.",\r
+    "  -p2 P2Path         Specifies fully qualified file name to the override",\r
+    "                     package. This file will normally exist in the build tip.",\r
+    "                     Optional.",\r
+    "  -d Name=Value      Add a macro definition for the package file. Optional.",\r
+    "  -o OutputFile      Specifies the file name of output file. Optional.",\r
+    "  -v                 Verbose. Optional.",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 static\r
@@ -2160,54 +2172,64 @@ here:
       StripQuotes (BaseName);\r
     }\r
 \r
-    if (BaseName[0] != 0) {\r
-      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+    if (mGlobals.OutputFilePath[0]) {\r
+      //\r
+      // Use user specified output file name\r
+      //\r
+      strcpy (InputString, mGlobals.OutputFilePath);\r
     } else {\r
-      strcpy (InputString, GuidString);\r
-    }\r
+      //\r
+      // Construct the output file name according to FileType\r
+      //\r
+      if (BaseName[0] != 0) {\r
+        sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+      } else {\r
+        strcpy (InputString, GuidString);\r
+      }\r
 \r
-    switch (StringToType (FileType)) {\r
+      switch (StringToType (FileType)) {\r
 \r
-    case EFI_FV_FILETYPE_SECURITY_CORE:\r
-      strcat (InputString, ".SEC");\r
-      break;\r
+      case EFI_FV_FILETYPE_SECURITY_CORE:\r
+        strcat (InputString, ".SEC");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_PEIM:\r
-    case EFI_FV_FILETYPE_PEI_CORE:\r
-    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
-      strcat (InputString, ".PEI");\r
-      break;\r
+      case EFI_FV_FILETYPE_PEIM:\r
+      case EFI_FV_FILETYPE_PEI_CORE:\r
+      case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
+        strcat (InputString, ".PEI");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_DRIVER:\r
-    case EFI_FV_FILETYPE_DXE_CORE:\r
-      strcat (InputString, ".DXE");\r
-      break;\r
+      case EFI_FV_FILETYPE_DRIVER:\r
+      case EFI_FV_FILETYPE_DXE_CORE:\r
+        strcat (InputString, ".DXE");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_APPLICATION:\r
-      strcat (InputString, ".APP");\r
-      break;\r
+      case EFI_FV_FILETYPE_APPLICATION:\r
+        strcat (InputString, ".APP");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
-      strcat (InputString, ".FVI");\r
-      break;\r
+      case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
+        strcat (InputString, ".FVI");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_RAW:\r
-      strcat (InputString, ".RAW");\r
-      break;\r
+      case EFI_FV_FILETYPE_RAW:\r
+        strcat (InputString, ".RAW");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_ALL:\r
-      Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
-      goto Done;\r
+      case EFI_FV_FILETYPE_ALL:\r
+        Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
+        goto Done;\r
 \r
-    default:\r
-      strcat (InputString, ".FFS");\r
-      break;\r
+      default:\r
+        strcat (InputString, ".FFS");\r
+        break;\r
+      }\r
     }\r
 \r
     if (ForceUncompress) {\r
       strcat (InputString, ".ORG");\r
     }\r
-\r
+       \r
     Out = fopen (InputString, "wb");\r
     if (Out == NULL) {\r
       Error (NULL, 0, 0, InputString, "could not open output file for writing");\r
@@ -2242,7 +2264,11 @@ here:
                                                   sizeof (EFI_FFS_FILE_HEADER)\r
                                                   );\r
     if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
       FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);\r
+#else\r
+      FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)&FileHeader + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));\r
+#endif\r
     } else {\r
       FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
     }\r
@@ -2307,48 +2333,58 @@ here:
       StripQuotes (BaseName);\r
     }\r
 \r
-    if (BaseName[0] != 0) {\r
-      sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+    if (mGlobals.OutputFilePath[0]) {\r
+      //\r
+      // Use user specified output file name\r
+      //\r
+      strcpy (InputString, mGlobals.OutputFilePath);\r
     } else {\r
-      strcpy (InputString, GuidString);\r
-    }\r
+      //\r
+      // Construct the output file name according to FileType\r
+      //\r
+      if (BaseName[0] != 0) {\r
+        sprintf (InputString, "%s-%s", GuidString, BaseName);\r
+      } else {\r
+        strcpy (InputString, GuidString);\r
+      }\r
 \r
-    switch (StringToType (FileType)) {\r
+      switch (StringToType (FileType)) {\r
 \r
-    case EFI_FV_FILETYPE_SECURITY_CORE:\r
-      strcat (InputString, ".SEC");\r
-      break;\r
+      case EFI_FV_FILETYPE_SECURITY_CORE:\r
+        strcat (InputString, ".SEC");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_PEIM:\r
-    case EFI_FV_FILETYPE_PEI_CORE:\r
-    case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
-      strcat (InputString, ".PEI");\r
-      break;\r
+      case EFI_FV_FILETYPE_PEIM:\r
+      case EFI_FV_FILETYPE_PEI_CORE:\r
+      case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:\r
+        strcat (InputString, ".PEI");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_DRIVER:\r
-    case EFI_FV_FILETYPE_DXE_CORE:\r
-      strcat (InputString, ".DXE");\r
-      break;\r
+      case EFI_FV_FILETYPE_DRIVER:\r
+      case EFI_FV_FILETYPE_DXE_CORE:\r
+        strcat (InputString, ".DXE");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_APPLICATION:\r
-      strcat (InputString, ".APP");\r
-      break;\r
+      case EFI_FV_FILETYPE_APPLICATION:\r
+        strcat (InputString, ".APP");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
-      strcat (InputString, ".FVI");\r
-      break;\r
+      case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:\r
+        strcat (InputString, ".FVI");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_RAW:\r
-      strcat (InputString, ".RAW");\r
-      break;\r
+      case EFI_FV_FILETYPE_RAW:\r
+        strcat (InputString, ".RAW");\r
+        break;\r
 \r
-    case EFI_FV_FILETYPE_ALL:\r
-      Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
-      goto Done;\r
+      case EFI_FV_FILETYPE_ALL:\r
+        Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);\r
+        goto Done;\r
 \r
-    default:\r
-      strcat (InputString, ".FFS");\r
-      break;\r
+      default:\r
+        strcat (InputString, ".FFS");\r
+        break;\r
+      }\r
     }\r
 \r
     if (ForceUncompress) {\r
@@ -2624,6 +2660,23 @@ Returns:
       OriginalOverridePackagePath = Argv[1];\r
       Argc--;\r
       Argv++;\r
+    } else if (_strcmpi (Argv[0], "-o") == 0) {\r
+      //\r
+      // OPTION: -o OutputFilePath\r
+      // Make sure there is another argument, then save it to out globals.\r
+      //\r
+      if (Argc < 2) {\r
+        Error (NULL, 0, 0, Argv[0], "option requires the output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      if (mGlobals.OutputFilePath[0]) {\r
+        Error (NULL, 0, 0, Argv[0], "option can only be specified once");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      strcpy (mGlobals.OutputFilePath, Argv[1]);\r
+      Argc--;\r
+      Argv++;\r
     } else if (_strcmpi (Argv[0], "-v") == 0) {\r
       //\r
       // OPTION: -v       verbose\r
index 8d9a7768ecd5acbda248caa1cb60cdf871172752..6e45c8695d8f9a231656f10b013ec6806eaaf381 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -49,12 +49,19 @@ Returns:
 \r
 --*/\r
 {\r
-  printf (\r
-    "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",\r
-    UTILITY_NAME,\r
-    UTILITY_MAJOR_VERSION,\r
-    UTILITY_MINOR_VERSION\r
-    );\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Firmware Volume Utility",\r
+    "  Copyright (C), 2004 - 2009 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 VOID\r
@@ -77,9 +84,19 @@ Returns:
 \r
 --*/\r
 {\r
-  printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);\r
-  printf ("  Where:\n");\r
-  printf ("\tFvInfFileName is the name of the image description file.\n\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]",\r
+    "Options:",\r
+    "  -I FvInfFileName  The name of the image description file.",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 EFI_STATUS\r
index d0dd1bbe025448ab37afbdc5bb408908bb2605b3..08a62af3e693eed9364d40f3164eaae049e4b870 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -38,8 +38,7 @@ Abstract:
 //\r
 // Utility version information\r
 //\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_VERSION "v1.1"\r
 #define UTILITY_DATE          __DATE__\r
 \r
 //\r
index cb193ce2ce42cb475c0babc562d8f1cb2d8cd04f..b5ed87a13127a6ed90304591631f4f81ef2fefe0 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -968,13 +968,17 @@ Returns:
     Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);\r
 \r
     if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Update the number of blocks\r
-      //\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);\r
-        return EFI_ABORTED;\r
+      if (strcmp (Value, AUTO_STRING) == 0) {\r
+        Value64 = (UINT64) -1;\r
+      } else {\r
+        //\r
+        // Update the number of blocks\r
+        //\r
+        Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+        if (EFI_ERROR (Status)) {\r
+          Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);\r
+          return EFI_ABORTED;\r
+        }\r
       }\r
 \r
       FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;\r
@@ -1040,99 +1044,59 @@ Returns:
 \r
   if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {\r
     Index = 0;\r
-    //\r
-    // Read component FV_VARIABLE\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
+    while (TRUE) {\r
+      Status = FindTokenInstanceInSection (\r
+                 InfFile,\r
+                 COMPONENT_SECTION_STRING,\r
+                 Index,\r
+                 FvInfo->FvComponents[Index].ComponentName,\r
+                 Value\r
+                 );\r
       if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);\r
-        return EFI_ABORTED;\r
+        break;\r
       }\r
-\r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);\r
-    }\r
-\r
-    Index++;\r
-    //\r
-    // Read component FV_EVENT_LOG\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);\r
       Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
       if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);\r
+        Error (NULL, 0, 0, Value, "not a valid integer");\r
         return EFI_ABORTED;\r
       }\r
 \r
       FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);\r
+      Index++;\r
     }\r
-\r
-    Index++;\r
-    //\r
-    // Read component FV_FTW_WORKING\r
-    //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
+  }\r
+  //\r
+  // Compute size for easy access later\r
+  //\r
+  FvInfo->Size = 0;\r
+  for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {\r
+    if ((FvInfo->Size == (UINTN) -1 && Index > 0) ||\r
+        (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1 && Index > 0)\r
+        ) {\r
       //\r
-      // Add the component\r
+      // Error 1. more pairs after AUTO\r
+      // Error 2. AUTO appear in non-first position\r
       //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
+      Error (NULL, 0, 0, NULL, "cannot have more than one pair of %s and %s if %s is set to %s", \r
+        EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING,\r
+        EFI_NUM_BLOCKS_STRING, AUTO_STRING\r
+        );\r
+      return EFI_ABORTED;\r
+    }\r
 \r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
+    if (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1) {\r
+      FvInfo->Size = (UINTN) -1;\r
     } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);\r
+      FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;\r
     }\r
+  }\r
 \r
-    Index++;\r
+  if (FvInfo->Size == (UINTN) -1 && FvInfo->FvFiles[0][0] == 0) {\r
     //\r
-    // Read component FV_FTW_SPARE\r
+    // Non FFS FV cannot set block number to AUTO\r
     //\r
-    Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);\r
-\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Add the component\r
-      //\r
-      strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);\r
-      Status = AsciiStringToUint64 (Value, FALSE, &Value64);\r
-      if (EFI_ERROR (Status)) {\r
-        printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);\r
-        return EFI_ABORTED;\r
-      }\r
-\r
-      FvInfo->FvComponents[Index].Size = (UINTN) Value64;\r
-    } else {\r
-      printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);\r
-    }\r
-  }\r
-  //\r
-  // Compute size for easy access later\r
-  //\r
-  FvInfo->Size = 0;\r
-  for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {\r
-    FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;\r
+    Error (NULL, 0, 0, "non-FFS FV", "cannot set %s to %s",   EFI_NUM_BLOCKS_STRING, AUTO_STRING);\r
+    return EFI_ABORTED;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -1372,7 +1336,11 @@ Returns:
   PadFile->State                          = 0;\r
   PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
   if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)  \r
     PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);\r
+#else\r
+    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)PadFile + sizeof (EFI_FFS_FILE_HEADER)), PadFileSize - sizeof (EFI_FFS_FILE_HEADER));\r
+#endif\r
   } else {\r
     PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
   }\r
@@ -1875,13 +1843,140 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+EFI_STATUS\r
+ReallocateFvImage (\r
+  IN OUT MEMORY_FILE         *FvImage,\r
+  IN OUT FV_INFO             *FvInfo,\r
+  IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,\r
+  IN OUT UINTN               *FvImageCapacity\r
+  )\r
+/*++\r
+Routine Description:\r
+  Increase the size of FV image by 1 block. The routine may reallocate memory\r
+  depending on the capacity of the FV image.\r
+\r
+Arguments:\r
+  FvImage         The memory image of the FV to add it to.  The current offset\r
+                  must be valid.\r
+  FvInfo          Pointer to information about the FV.\r
+  VtfFileImage    A pointer to the VTF file within the FvImage.  If this is equal\r
+                  to the end of the FvImage then no VTF previously found.\r
+  FvImageCapacity Capacity of image buffer for FV.\r
+\r
+Returns:\r
+  EFI_SUCCESS              The function completed successfully.\r
+  EFI_OUT_OF_RESOURCES     Insufficient resources exist to complete the reallocation.\r
+\r
+--*/\r
+{\r
+  CHAR8                      *FileImage;\r
+  UINTN                      OldSize;\r
+  UINTN                      IncreaseSize;\r
+  EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
+  BOOLEAN                    AllocateNewMemory;\r
+  EFI_FFS_FILE_HEADER        *NewVtfFileImage;\r
+  UINT32                     VtfFileLength;\r
+  UINT8                      TempByte;\r
+\r
+  OldSize      = (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage;\r
+  IncreaseSize = FvInfo->FvBlocks[0].BlockLength;\r
+  assert (OldSize == FvInfo->FvBlocks[0].NumBlocks * FvInfo->FvBlocks[0].BlockLength);\r
+\r
+  //\r
+  // Assume we have enough capacity\r
+  //\r
+  AllocateNewMemory = FALSE;\r
+  \r
+\r
+  if (OldSize + IncreaseSize > *FvImageCapacity) {\r
+    AllocateNewMemory = TRUE;\r
+    //\r
+    // Increase capacity by one unit\r
+    //\r
+    *FvImageCapacity = OldSize + FV_CAPACITY_INCREASE_UNIT;\r
+    FileImage = malloc (*FvImageCapacity);\r
+\r
+    if (FileImage == NULL) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+\r
+    //\r
+    // Initialize the content per FV polarity\r
+    //\r
+    if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
+      memset (FileImage, -1, *FvImageCapacity);\r
+    } else {\r
+      memset (FileImage, 0, *FvImageCapacity);\r
+    }\r
+\r
+    //\r
+    // Copy the FV content before VTF\r
+    //\r
+    memcpy (FileImage, FvImage->FileImage, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage);\r
+  } else {\r
+    FileImage = FvImage->FileImage;\r
+  }\r
+\r
+  //\r
+  // Move VTF if it exists\r
+  //\r
+  NewVtfFileImage = (EFI_FFS_FILE_HEADER *) (FileImage + ((UINTN) *VtfFileImage - (UINTN) FvImage->FileImage) + IncreaseSize);\r
+  if ((UINTN) *VtfFileImage != (UINTN) FvImage->Eof) {\r
+    //\r
+    // Exchange the VTF buffer from end to start for two purpose:\r
+    // 1. Exchange: Preserve the default value per FV polarity\r
+    // 2. End->Start: Avoid destroying the VTF data during exchanging\r
+    //\r
+    VtfFileLength = GetLength ((*VtfFileImage)->Size);\r
+    while (VtfFileLength-- != 0) {\r
+      TempByte = ((UINT8 *) VtfFileImage)[VtfFileLength];\r
+      ((UINT8 *) VtfFileImage)[VtfFileLength]    = ((UINT8 *) NewVtfFileImage)[VtfFileLength];\r
+      ((UINT8 *) NewVtfFileImage)[VtfFileLength] = TempByte;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Update VTF Pointer\r
+  //\r
+  *VtfFileImage = NewVtfFileImage;\r
+\r
+  //\r
+  // Update FvInfo\r
+  //\r
+  FvInfo->FvBlocks[0].NumBlocks ++;\r
+\r
+  //\r
+  // Update FV Header\r
+  //\r
+  FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FileImage;\r
+  FvHeader->FvBlockMap[0].NumBlocks = FvInfo->FvBlocks[0].NumBlocks;\r
+  FvHeader->FvLength                = OldSize + IncreaseSize;\r
+  FvHeader->Checksum                = 0;\r
+  FvHeader->Checksum                = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));\r
+      \r
+  //\r
+  // Update FvImage\r
+  //\r
+  if (AllocateNewMemory) {\r
+    free (FvImage->FileImage);\r
+    FvImage->CurrentFilePointer = FileImage + (FvImage->CurrentFilePointer - FvImage->FileImage);    \r
+    FvImage->FileImage          = FileImage;\r
+  }\r
+  FvImage->Eof                  = FvImage->FileImage + OldSize + IncreaseSize;\r
+\r
+  InitializeFvLib (FvImage->FileImage, OldSize + IncreaseSize);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 EFI_STATUS\r
 AddFile (\r
   IN OUT MEMORY_FILE          *FvImage,\r
   IN FV_INFO                  *FvInfo,\r
   IN UINTN                    Index,\r
   IN OUT EFI_FFS_FILE_HEADER  **VtfFileImage,\r
-  IN OUT MEMORY_FILE          *SymImage\r
+  IN OUT MEMORY_FILE          *SymImage,\r
+  IN OUT UINTN                *FvImageCapacity\r
   )\r
 /*++\r
 \r
@@ -1892,14 +1987,15 @@ Routine Description:
 \r
 Arguments:\r
 \r
-  FvImage       The memory image of the FV to add it to.  The current offset\r
-                must be valid.\r
-  FvInfo        Pointer to information about the FV.\r
-  Index         The file in the FvInfo file list to add.\r
-  VtfFileImage  A pointer to the VTF file within the FvImage.  If this is equal\r
-                to the end of the FvImage then no VTF previously found.\r
-  SymImage      The memory image of the Sym file to update if symbols are present.\r
-                The current offset must be valid.\r
+  FvImage         The memory image of the FV to add it to.  The current offset\r
+                  must be valid.\r
+  FvInfo          Pointer to information about the FV.\r
+  Index           The file in the FvInfo file list to add.\r
+  VtfFileImage    A pointer to the VTF file within the FvImage.  If this is equal\r
+                  to the end of the FvImage then no VTF previously found.\r
+  SymImage        The memory image of the Sym file to update if symbols are present.\r
+                  The current offset must be valid.\r
+  FvImageCapacity Capacity of image buffer for FV.\r
 \r
 Returns:\r
 \r
@@ -1964,16 +2060,28 @@ Returns:
   // Verify read successful\r
   //\r
   if (NumBytesRead != sizeof (UINT8) * FileSize) {\r
-    free (FileBuffer);\r
     Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");\r
-    return EFI_ABORTED;\r
+    Status = EFI_ABORTED;\r
+    goto Exit;\r
   }\r
   //\r
   // Verify space exists to add the file\r
   //\r
-  if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {\r
-    Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");\r
-    return EFI_OUT_OF_RESOURCES;\r
+  while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {\r
+    if (FvInfo->Size != (UINTN) -1) {\r
+      Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+      goto Exit;\r
+    } else {\r
+      //\r
+      // FV Size is AUTO, increase by one block\r
+      //\r
+      Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");\r
+        goto Exit;\r
+      }\r
+    }\r
   }\r
   //\r
   // Update the file state based on polarity of the FV.\r
@@ -2033,7 +2141,11 @@ Returns:
       }\r
 \r
       if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+    #if (PI_SPECIFICATION_VERSION < 0x00010000)\r
         VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);\r
+    #else\r
+        VtfFileChecksum = CalculateChecksum8 ((UINT8 *) ((UINTN)*VtfFileImage + sizeof (EFI_FFS_FILE_HEADER)), FileSize - TailSize - sizeof(EFI_FFS_FILE_HEADER));\r
+    #endif\r
         (*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;\r
       } else {\r
         (*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
@@ -2048,15 +2160,15 @@ Returns:
       }\r
     #endif  \r
       (*VtfFileImage)->State = FileState;\r
-      free (FileBuffer);\r
-      return EFI_SUCCESS;\r
+      Status = EFI_SUCCESS;\r
+      goto Exit;\r
     } else {\r
       //\r
       // Already found a VTF file.\r
       //\r
       Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);\r
-      free (FileBuffer);\r
-      return EFI_ABORTED;\r
+      Status = EFI_ABORTED;\r
+      goto Exit;\r
     }\r
   }\r
   //\r
@@ -2065,68 +2177,93 @@ Returns:
   Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);\r
   if (EFI_ERROR (Status)) {\r
     printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);\r
-    free (FileBuffer);\r
-    return EFI_ABORTED;\r
+    Status = EFI_ABORTED;\r
+    goto Exit;\r
   }\r
   //\r
   // Add pad file if necessary\r
   //\r
-  Status = AddPadFile (FvImage, CurrentFileAlignment);\r
-  if (EFI_ERROR (Status)) {\r
-    printf ("ERROR: Could not align the file data properly.\n");\r
-    free (FileBuffer);\r
-    return EFI_ABORTED;\r
+  while (EFI_ERROR (AddPadFile (FvImage, CurrentFileAlignment))) {\r
+    if (FvInfo->Size != (UINTN) -1) {\r
+      printf ("ERROR: Could not align the file data properly.\n");\r
+      Status = EFI_ABORTED;\r
+      goto Exit;\r
+    } else {    \r
+      //\r
+      // FV Size is AUTO, increase by one block\r
+      //\r
+      Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");\r
+        goto Exit;\r
+      }      \r
+    }\r
   }\r
+\r
   //\r
   // Add file\r
   //\r
-  if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {\r
-    //\r
-    // Copy the file\r
-    //\r
-    memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);\r
+  while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {\r
+    if (FvInfo->Size != (UINTN) -1) {\r
+      printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);\r
+      Status = EFI_ABORTED;\r
+      goto Exit;\r
+    } else {      \r
+      //\r
+      // FV Size is AUTO, increase by one one block\r
+      //\r
+      Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);\r
+      if (EFI_ERROR (Status)) {\r
+        Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");\r
+        goto Exit;\r
+      }\r
+    }\r
+  }\r
 \r
-    //\r
-    // If the file is XIP, rebase\r
-    //\r
-    CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);\r
-    //\r
-    //    Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);\r
-    //    if (EFI_ERROR(Status)) {\r
-    //      printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);\r
-    //      return EFI_ABORTED;\r
-    //    }\r
-    //\r
-    // Update Symbol file\r
-    //\r
-    Status = AddSymFile (\r
-              CurrentFileBaseAddress,\r
-              (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,\r
-              SymImage,\r
-              FvInfo->FvFiles[Index]\r
-              );\r
-    assert (!EFI_ERROR (Status));\r
+  //\r
+  // Copy the file\r
+  //\r
+  memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);\r
+\r
+  //\r
+  // If the file is XIP, rebase\r
+  //\r
+  CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);\r
+  //\r
+  //    Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);\r
+  //    if (EFI_ERROR(Status)) {\r
+  //      printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);\r
+  //      return EFI_ABORTED;\r
+  //    }\r
+  //\r
+  // Update Symbol file\r
+  //\r
+  Status = AddSymFile (\r
+            CurrentFileBaseAddress,\r
+            (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,\r
+            SymImage,\r
+            FvInfo->FvFiles[Index]\r
+            );\r
+  assert (!EFI_ERROR (Status));\r
+\r
+  //\r
+  // Update the current pointer in the FV image\r
+  //\r
+  FvImage->CurrentFilePointer += FileSize;\r
 \r
-    //\r
-    // Update the current pointer in the FV image\r
-    //\r
-    FvImage->CurrentFilePointer += FileSize;\r
-  } else {\r
-    printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);\r
-    return EFI_ABORTED;\r
-  }\r
   //\r
   // Make next file start at QWord Boundry\r
   //\r
   while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {\r
     FvImage->CurrentFilePointer++;\r
   }\r
+\r
+Exit:\r
   //\r
   // Free allocated memory.\r
   //\r
   free (FileBuffer);\r
-\r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
@@ -2250,8 +2387,7 @@ Returns:
     } else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {\r
       AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);\r
     } else {\r
-      printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);\r
-      return EFI_ABORTED;\r
+      printf ("Warning: Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);\r
     }\r
 \r
     FvImage   = FvImage + FvInfo->FvComponents[Index].Size;\r
@@ -2332,7 +2468,11 @@ Returns:
   PadFile->State                          = 0;\r
   PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));\r
   if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
     PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);\r
+#else\r
+    PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN) PadFile + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));\r
+#endif\r
   } else {\r
     PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
   }\r
@@ -2611,10 +2751,18 @@ Returns:
   VtfFile->IntegrityCheck.Checksum.File = 0;\r
   VtfFile->State                        = 0;\r
   if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {\r
+#if (PI_SPECIFICATION_VERSION < 0x00010000)\r
     VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
                                               (UINT8 *) VtfFile,\r
                                               GetLength (VtfFile->Size) - TailSize\r
                                               );\r
+\r
+#else\r
+    VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (\r
+                                              (UINT8 *) ((UINTN)VtfFile + sizeof (EFI_FFS_FILE_HEADER)),\r
+                                              GetLength (VtfFile->Size) - TailSize - sizeof (EFI_FFS_FILE_HEADER)\r
+                                              );\r
+#endif\r
   } else {\r
     VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;\r
   }\r
@@ -2780,6 +2928,7 @@ Returns:
   UINTN                       Index;\r
   EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;\r
   EFI_FFS_FILE_HEADER         *VtfFileImage;\r
+  UINTN                       FvImageCapacity;\r
 \r
   //\r
   // Check for invalid parameter\r
@@ -2811,12 +2960,22 @@ Returns:
   //\r
   // Calculate the FV size\r
   //\r
-  *FvImageSize = FvInfo.Size;\r
+  if (FvInfo.Size != (UINTN) -1) {\r
+    *FvImageSize    = FvInfo.Size;\r
+    FvImageCapacity = FvInfo.Size;\r
+  } else {\r
+    //\r
+    // For auto size, set default as one block\r
+    //\r
+    FvInfo.FvBlocks[0].NumBlocks = 1;\r
+    *FvImageSize    = FvInfo.FvBlocks[0].BlockLength;\r
+    FvImageCapacity = FV_CAPACITY_INCREASE_UNIT;\r
+  }\r
 \r
   //\r
   // Allocate the FV\r
   //\r
-  *FvImage = malloc (*FvImageSize);\r
+  *FvImage = malloc (FvImageCapacity);\r
   if (*FvImage == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -2831,9 +2990,9 @@ Returns:
   // Initialize the FV to the erase polarity\r
   //\r
   if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {\r
-    memset (*FvImage, -1, *FvImageSize);\r
+    memset (*FvImage, -1, FvImageCapacity);\r
   } else {\r
-    memset (*FvImage, 0, *FvImageSize);\r
+    memset (*FvImage, 0, FvImageCapacity);\r
   }\r
   //\r
   // Initialize FV header\r
@@ -2913,7 +3072,7 @@ Returns:
   //\r
   // Initialize the FV library.\r
   //\r
-  InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);\r
+  InitializeFvLib (FvImageMemoryFile.FileImage, *FvImageSize);\r
 \r
   //\r
   // Files start on 8 byte alignments, so move to the next 8 byte aligned\r
@@ -2935,7 +3094,15 @@ Returns:
     //\r
     // Add the file\r
     //\r
-    Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);\r
+    Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile, &FvImageCapacity);\r
+\r
+    //\r
+    // Update FvImageSize and FvImage as they may be changed in AddFile routine\r
+    //\r
+    if (FvInfo.Size == (UINTN) -1) {\r
+      *FvImageSize = FvInfo.FvBlocks[0].NumBlocks * FvInfo.FvBlocks[0].BlockLength;\r
+      *FvImage     = FvImageMemoryFile.FileImage;\r
+    }\r
 \r
     //\r
     // Exit if error detected while adding the file\r
@@ -2966,7 +3133,7 @@ Returns:
     // reset vector. If the PEI Core is found, the VTF file will probably get  \r
     // corrupted by updating the entry point.                                  \r
     //\r
-    if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {       \r
+    if ((FvInfo.BaseAddress + *FvImageSize) == FV_IMAGES_TOP_ADDRESS) {       \r
       Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);\r
       if (EFI_ERROR(Status)) {                                               \r
         printf ("ERROR: Could not update the reset vector.\n");              \r
@@ -2974,7 +3141,7 @@ Returns:
         return EFI_ABORTED;                                                  \r
       }                                                                      \r
     }\r
-  } \r
+  }\r
   //\r
   // Determine final Sym file size\r
   //\r
index c8e63e83d19e8547ce7290a2dbe25e27e0b82aa4..7b8ab1141315d3a26c5f4e997fa9120b16d59f49 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -44,6 +44,8 @@ Abstract:
 #define MAX_NUMBER_OF_FILES_IN_FV       1000\r
 #define MAX_NUMBER_OF_COMPONENTS_IN_FV  10\r
 \r
+#define FV_CAPACITY_INCREASE_UNIT       0x100000\r
+\r
 //\r
 // INF file strings\r
 //\r
@@ -150,6 +152,7 @@ Abstract:
 #define TRUE_STRING               "TRUE"\r
 #define FALSE_STRING              "FALSE"\r
 #define NULL_STRING               "NULL"\r
+#define AUTO_STRING               "AUTO"\r
 \r
 //\r
 // Defines to calculate the offset for PEI CORE entry points\r
@@ -206,6 +209,7 @@ EFI_STATUS
 ParseFvInf (\r
   IN MEMORY_FILE  *InfFile,\r
   IN FV_INFO      *FvInfo\r
-  );\r
+  )\r
+;\r
 \r
 #endif\r
index 1d1c307e87526091235f4f1ab9cb939c158b6ed0..fd367c3d620acbfd59f8ff0e1cc018e12ae7588e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -35,6 +35,7 @@ Abstract:
 #include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)\r
 \r
 #define UTILITY_NAME            "GenSection"\r
+#define UTILITY_VERSION         "v1.0"\r
 \r
 #define PARAMETER_NOT_SPECIFIED "Parameter not specified"\r
 #define MAXIMUM_INPUT_FILE_NUM  10\r
@@ -81,37 +82,52 @@ PrintUsageMessage (
   VOID\r
   )\r
 {\r
-  UINTN SectionType;\r
-  UINTN DisplayCount;\r
-\r
-  printf ("Usage: "UTILITY_NAME "  -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");\r
-  printf ("    Where SectionType is one of the following section types:\n\n");\r
+  UINTN       SectionType;\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Section Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]",\r
+    "Common Options:",\r
+    "  -i InputFile    Specifies the input file",\r
+    "  -o OutputFile   Specifies the output file",\r
+    "  -s SectionType  Specifies the type of the section, which can be one of",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 \r
-  DisplayCount = 0;\r
   for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {\r
     if (SectionTypeName[SectionType] != NULL) {\r
-      printf ("       %s\n", SectionTypeName[SectionType]);\r
+      fprintf (stdout, "                  %s\n", SectionTypeName[SectionType]);\r
     }\r
   }\r
-\r
-  printf ("\n    and SectionType dependent parameters are as follows:\n\n");\r
-  printf (\r
-    "       %s:       -t < %s | %s >\n",\r
+  fprintf (stdout, "Section dependent options:\n");\r
+  fprintf (stdout, \r
+    "  %s:       -t < %s | %s >\n",\r
     SectionTypeName[EFI_SECTION_COMPRESSION],\r
     CompressionTypeName[EFI_NOT_COMPRESSED],\r
     CompressionTypeName[EFI_STANDARD_COMPRESSION]\r
     );\r
-  printf (\r
-    "       %s:      -t < %s >\n""                          // Currently only CRC32 is supported\n\n",\r
+  fprintf (stdout,\r
+    "  %s:      -t < %s >  // Only CRC32 is supported\n",\r
     SectionTypeName[EFI_SECTION_GUID_DEFINED],\r
     GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]\r
     );\r
   printf (\r
-    "       %s:           -v VersionNumber\n""                          [-a \"Version string\"]\n\n",\r
+    "  %s:           -v VersionNumber [-a \"Version string\"]\n",\r
     SectionTypeName[EFI_SECTION_VERSION]\r
     );\r
   printf (\r
-    "       %s:    -a \"Human readable name\"\n\n",\r
+    "  %s:    -a \"Human readable name\"\n",\r
     SectionTypeName[EFI_SECTION_USER_INTERFACE]\r
     );\r
 }\r
index f9988257f107339708936b5bb13ab22b08697a26..178e9322aaa2c4b14c7daa3ef5004e1948656936 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 1999 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 1999 - 2010, 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
@@ -33,7 +33,7 @@ Abstract:
 // Version of this utility\r
 //\r
 #define UTILITY_NAME    "GenTEImage"\r
-#define UTILITY_VERSION "v0.11"\r
+#define UTILITY_VERSION "v1.0"\r
 \r
 //\r
 // Define the max length of a filename\r
@@ -767,23 +767,28 @@ Returns:
 \r
 --*/\r
 {\r
-  int               Index;\r
-  static const char *Msg[] = {\r
-    UTILITY_NAME " version "UTILITY_VERSION " - TE image utility",\r
-    "  Generate a TE image from an EFI PE32 image",\r
-    "  Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",\r
-    "                [-e|-b] [FileName(s)]",\r
-    "    where:",\r
-    "      -v             - for verbose output",\r
-    "      -dump          - to dump the input file to a text file",\r
-    "      -h -?          - for this help information",\r
-    "      -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,\r
-    "      InFileName     - name of the input PE32 file",\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Generate TE Image Utility",\r
+    "  Copyright (C), 1999 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
     "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]... PE32IMAGE",\r
+    "Description:",\r
+    "  Generate a TE image from an EFI PE32 image.",\r
+    "Options:",\r
+    "  -v             - for verbose output",\r
+    "  -dump          - to dump the input file to a text file",\r
+    "  -h -?          - for this help information",\r
+    "  -o OutFileName - to write output to OutFileName rather than PE32IMAGE"DEFAULT_OUTPUT_EXTENSION,\r
     NULL\r
   };\r
-  for (Index = 0; Msg[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Msg[Index]);\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
   }\r
 }\r
 \r
index 7b9aa041c5fa0834d1af90316289403b45bbad48..f1084a3cd921d479b6b4f6d652aee5f74775f14b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -38,6 +38,9 @@ Abstract:
 #define MAX_PATH  1024\r
 #endif\r
 \r
+#define UTILITY_NAME    "GuidChk"\r
+#define UTILITY_VERSION "v1.0"\r
+\r
 typedef struct {\r
   INT8  *Extension;\r
   INT8  ExtensionCode;\r
@@ -593,25 +596,32 @@ Usage (
   VOID\r
   )\r
 {\r
-  int   Index;\r
-  char  *Str[] = {\r
-    "GuidChk - scan files for duplicate GUID or signature definitions",\r
-    "",\r
-    "Usage:  GuidChk {options}\n",\r
-    "  Options: ",\r
-    "    -d dirname     exclude searching of a directory",\r
-    "    -f filename    exclude searching of a file",\r
-    "    -e extension   exclude searching of files by extension",\r
-    "    -p             print all GUIDS found",\r
-    "    -g             check for duplicate guids",\r
-    "    -s             check for duplicate signatures",\r
-    "    -x             print guid+defined symbol name",\r
-    "    -b outfile     write internal GUID+basename list to outfile",\r
-    "    -u dirname     exclude searching all subdirectories of a directory",\r
-    "    -h -?          print this help text",\r
-    " ",\r
-    "   Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel GUID Check Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
     "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]...",\r
+    "Description:",\r
+    "  Scan files for duplicate GUID or signature definitions.",\r
+    "Options:",\r
+    "  -d dirname     exclude searching of a directory",\r
+    "  -f filename    exclude searching of a file",\r
+    "  -e extension   exclude searching of files by extension",\r
+    "  -p             print all GUIDS found",\r
+    "  -g             check for duplicate guids",\r
+    "  -s             check for duplicate signatures",\r
+    "  -x             print guid+defined symbol name",\r
+    "  -b outfile     write internal GUID+basename list to outfile",\r
+    "  -u dirname     exclude searching all subdirectories of a directory",\r
+    "  -h -?          print this help text",\r
+    "Example Usage:",\r
+    "  GuidChk -g -u build -d fv -f make.inf -e .pkg",\r
     NULL\r
   };\r
   for (Index = 0; Str[Index] != NULL; Index++) {\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
new file mode 100644 (file)
index 0000000..b63a1f8
--- /dev/null
@@ -0,0 +1,208 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  FindFiles.c \r
+  \r
+Abstract:\r
+\r
+  OS-specific functions to assist in finding files in\r
+  subdirectories.\r
+  \r
+--*/\r
+\r
+#include <windows.h>\r
+#include <direct.h>\r
+//\r
+// #include <io.h>         // for _chmod()\r
+//\r
+#include <sys/stat.h>\r
+//\r
+// #include <errno.h>      // for errno\r
+//\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "HiiPack.h"\r
+\r
+extern\r
+void\r
+Error (\r
+  char    *Name,\r
+  UINT32  LineNumber,\r
+  UINT32  MessageCode,\r
+  char    *Text,\r
+  char    *MsgFmt,\r
+  ...\r
+  );\r
+\r
+static\r
+int\r
+ProcessDirectory (\r
+  char                *RootDirectory,\r
+  char                *FileMask,\r
+  FIND_FILE_CALLBACK  Callback\r
+  );\r
+\r
+/*****************************************************************************/\r
+int\r
+FindFiles (\r
+  char                *RootDirectory,\r
+  char                *FileMask,\r
+  FIND_FILE_CALLBACK  Callback\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Find files of a given name under a root directory\r
+\r
+Arguments:\r
+  RootDirectory - base directory -- look in this directory and\r
+                  all its subdirectories for files matching FileMask.\r
+  FileMask      - file mask of files to find\r
+  Callback      - function to call for each file found \r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  char  FullPath[MAX_PATH];\r
+  //\r
+  // If RootDirectory is relative, then append to cwd.\r
+  //\r
+  if (isalpha (RootDirectory[0]) && (RootDirectory[1] == ':')) {\r
+    strcpy (FullPath, RootDirectory);\r
+  } else {\r
+    //\r
+    // Get current working directory\r
+    //\r
+    if (_getcwd (FullPath, sizeof (FullPath)) == NULL) {\r
+      Error (NULL, 0, 0, "failed to get current working directory", NULL);\r
+      return 1;\r
+    }\r
+    //\r
+    // Append the relative path they passed in\r
+    //\r
+    if (FullPath[strlen (FullPath) - 1] != '\\') {\r
+      strcat (FullPath, "\\");\r
+    }\r
+\r
+    strcat (FullPath, RootDirectory);\r
+  }\r
+\r
+  if (FullPath[strlen (FullPath) - 1] == '\\') {\r
+    FullPath[strlen (FullPath) - 1] = 0;\r
+  }\r
+  //\r
+  // Process the directory\r
+  //\r
+  return ProcessDirectory (FullPath, FileMask, Callback);\r
+}\r
+\r
+static\r
+int\r
+ProcessDirectory (\r
+  char                *RootDirectory,\r
+  char                *FileMask,\r
+  FIND_FILE_CALLBACK  Callback\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  Process a directory to find all files matching a given file mask\r
+\r
+Arguments:\r
+  RootDirectory - base directory -- look in this directory and\r
+                  all its subdirectories for files matching FileMask.\r
+  FileMask      - file mask of files to find\r
+  Callback      - function to call for each file found \r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  HANDLE          Handle;\r
+  WIN32_FIND_DATA FindData;\r
+  char            TempName[MAX_PATH];\r
+\r
+  Handle = INVALID_HANDLE_VALUE;\r
+  //\r
+  // Concatenate the filemask to the directory to create the full\r
+  // path\mask path name.\r
+  //\r
+  strcpy (TempName, RootDirectory);\r
+  strcat (TempName, "\\");\r
+  strcat (TempName, FileMask);\r
+  memset (&FindData, 0, sizeof (FindData));\r
+  Handle = FindFirstFile (TempName, &FindData);\r
+  if (Handle != INVALID_HANDLE_VALUE) {\r
+    do {\r
+      if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {\r
+        strcpy (TempName, RootDirectory);\r
+        strcat (TempName, "\\");\r
+        strcat (TempName, FindData.cFileName);\r
+        if (Callback (TempName) != 0) {\r
+          goto Done;\r
+        }\r
+      }\r
+    } while (FindNextFile (Handle, &FindData));\r
+  }\r
+\r
+  if (Handle != INVALID_HANDLE_VALUE) {\r
+    FindClose (Handle);\r
+    Handle = INVALID_HANDLE_VALUE;\r
+  }\r
+  //\r
+  // Now create a *.* file mask to get all subdirectories and recursive call this\r
+  // function to handle each one found.\r
+  //\r
+  strcpy (TempName, RootDirectory);\r
+  strcat (TempName, "\\*.*");\r
+  memset (&FindData, 0, sizeof (FindData));\r
+  Handle = FindFirstFile (TempName, &FindData);\r
+  //\r
+  // Loop until no more files/directories\r
+  //\r
+  if (Handle != INVALID_HANDLE_VALUE) {\r
+    do {\r
+      if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\r
+        //\r
+        // Make sure it's not "." or ".."\r
+        //\r
+        if ((strcmp (FindData.cFileName, ".") != 0) && (strcmp (FindData.cFileName, "..") != 0)) {\r
+          //\r
+          // Found a valid directory. Put it all together and make a recursive call\r
+          // to process it.\r
+          //\r
+          strcpy (TempName, RootDirectory);\r
+          strcat (TempName, "\\");\r
+          strcat (TempName, FindData.cFileName);\r
+          if (ProcessDirectory (TempName, FileMask, Callback) != 0) {\r
+            goto Done;\r
+          }\r
+        }\r
+      }\r
+    } while (FindNextFile (Handle, &FindData));\r
+  }\r
+\r
+Done:\r
+  //\r
+  // Free the handle\r
+  //\r
+  if (Handle != INVALID_HANDLE_VALUE) {\r
+    FindClose (Handle);\r
+  }\r
+\r
+  return 0;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
new file mode 100644 (file)
index 0000000..70b8827
--- /dev/null
@@ -0,0 +1,2561 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HiiPack.c  \r
+\r
+Abstract:\r
+\r
+  Process HII export and pack files and create HII export files,\r
+  dumps, or variable defaults packs.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "ParseInf.h"\r
+#include "EfiInternalFormRepresentation.h"\r
+#include "HiiPack.h"\r
+#include "Hii.h"\r
+#include "IfrParse.h"\r
+#include "StringParse.h"\r
+\r
+#define UTILITY_VERSION "v1.0"\r
+#define UTILITY_NAME    "HiiPack"\r
+#define MAX_PATH        260\r
+\r
+//\r
+// We may have to create an empty IFR formset to provide a GUID for an HII\r
+// export pack. Create a structure definition to make it easier.\r
+//\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  EFI_HII_IFR_PACK      PackHeader;\r
+  EFI_IFR_FORM_SET      Formset;\r
+  EFI_IFR_END_FORM_SET  EndFormset;\r
+} EMPTY_FORMSET_PACK;\r
+\r
+#pragma pack()\r
+//\r
+// We'll store lists of file names from the command line in\r
+// a linked list of these\r
+//\r
+typedef struct _FILE_NAME_LIST {\r
+  struct _FILE_NAME_LIST  *Next;\r
+  UINT8                   FileName[MAX_PATH];\r
+  int                     Tag;  // used for whatever\r
+} FILE_NAME_LIST;\r
+\r
+//\r
+// When merging HII export packs, we save HII data table headers in a linked\r
+// list of these.\r
+//\r
+typedef struct _DATA_TABLE_HEADER_LIST {\r
+  struct _DATA_TABLE_HEADER_LIST  *Next;\r
+  EFI_HII_DATA_TABLE              DataTableHeader;\r
+} DATA_TABLE_HEADER_LIST;\r
+//\r
+// Create some defines for the different operation modes supported by this utility\r
+//\r
+#define MODE_CREATE_HII_EXPORT  1\r
+#define MODE_MERGE_HII_EXPORTS  2\r
+#define MODE_EMIT_DEFAULTS      3\r
+#define MODE_DUMP_HII_EXPORT    4\r
+//\r
+// Here's all our globals.\r
+//\r
+static struct {\r
+  FILE_NAME_LIST  *PackFileNames;           // Input HII pack file names\r
+  FILE_NAME_LIST  *HiiExportFileNames;      // Input files when merging\r
+  CHAR8           OutputFileName[MAX_PATH]; // Output dump file\r
+  BOOLEAN         MfgFlag;                  // From -mfg command line arg\r
+  BOOLEAN         NoEmptyVarPacks;          // From -noemptyvarpacks command line arg\r
+  BOOLEAN         NoVarPacks;               // From -novarpacks command line arg\r
+  EFI_GUID        Guid;                     // Guid specified on command line\r
+  BOOLEAN         GuidSpecified;\r
+  BOOLEAN         DumpStrings;              // In dump mode, dump string data\r
+  int             Verbose;\r
+  int             Mode;                     // Mode this utility is operating in\r
+} mGlobals;\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+STATUS\r
+DumpHiiExportFile (\r
+  char    *HiiExportFileName,\r
+  char    *OutputFileName\r
+  );\r
+\r
+static\r
+void\r
+DumpString (\r
+  FILE    *OutFptr,\r
+  int     StringIndex,\r
+  CHAR16  *Str,\r
+  int     Indent\r
+  );\r
+\r
+static\r
+void\r
+DumpStringPack (\r
+  FILE                  *OutFptr,\r
+  EFI_HII_STRING_PACK   *Pack,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  );\r
+\r
+static\r
+void\r
+DumpVariablePacks (\r
+  FILE                  *OutFptr,\r
+  EFI_HII_VARIABLE_PACK *Pack,\r
+  int                   NumPacks,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  );\r
+\r
+static\r
+void\r
+TestDumpHiiPack (\r
+  FILE    *OutFptr,\r
+  char    *BufferStart,\r
+  int     BufferSize\r
+  );\r
+\r
+static\r
+void\r
+DumpRawBytes (\r
+  FILE                  *OutFptr,\r
+  char                  *Buffer,\r
+  int                   Count,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  );\r
+\r
+static\r
+void\r
+DumpIfrPack (\r
+  FILE                  *OutFptr,\r
+  EFI_HII_IFR_PACK      *Pack,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  );\r
+\r
+static\r
+void\r
+FreeGlobals (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+AddStringPack (\r
+  EFI_HII_STRING_PACK   *PackHeader\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessHiiExportFile (\r
+  char    *FileName,\r
+  int     MfgDefaults\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessIfrFiles (\r
+  FILE_NAME_LIST *FileName\r
+  );\r
+\r
+static\r
+STATUS\r
+EmitDefaults (\r
+  FILE_NAME_LIST *HiiExportFiles,\r
+  int            MfgDefaults,\r
+  int            NoEmptyVarPacks\r
+  );\r
+\r
+static\r
+STATUS\r
+MergeHiiExports (\r
+  FILE_NAME_LIST *HiiExportFiles,\r
+  char           *OutputFileName,\r
+  int            MfgDefaults,\r
+  int            NoEmptyVarPacks\r
+  );\r
+\r
+void\r
+GuidToString (\r
+  EFI_GUID   *Guid,\r
+  char       *Str\r
+  );\r
+\r
+static\r
+CHAR16  *\r
+AsciiToWchar (\r
+  CHAR8 *Str\r
+  );\r
+\r
+static\r
+STATUS\r
+CreateHiiExport (\r
+  char              *OutputFileName,\r
+  EFI_GUID          *DummyFormsetGuid,\r
+  FILE_NAME_LIST    *PackFiles,\r
+  int               MfgDefaults\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process the file.\r
+  \r
+Arguments:\r
+\r
+  Standard C main() argc and argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+  \r
+--*/\r
+// GC_TODO:    Argc - add argument and description to function comment\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  STATUS  Status;\r
+  //\r
+  // Set the utility name for error reporting purposes\r
+  //\r
+  SetUtilityName (UTILITY_NAME);\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+  //\r
+  // Switch based on whether we're dumping, merging, etc.\r
+  //\r
+  if (mGlobals.Mode == MODE_DUMP_HII_EXPORT) {\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "Dumping HII export file %s => %s\n", mGlobals.HiiExportFileNames, mGlobals.OutputFileName);\r
+    }\r
+\r
+    DumpHiiExportFile (mGlobals.HiiExportFileNames->FileName, mGlobals.OutputFileName);\r
+  } else if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {\r
+    CreateHiiExport (mGlobals.OutputFileName, &mGlobals.Guid, mGlobals.PackFileNames, mGlobals.MfgFlag);\r
+  } else if (mGlobals.Mode == MODE_MERGE_HII_EXPORTS) {\r
+    MergeHiiExports (mGlobals.HiiExportFileNames, mGlobals.OutputFileName, mGlobals.MfgFlag, mGlobals.NoEmptyVarPacks);\r
+  } else if (mGlobals.Mode == MODE_EMIT_DEFAULTS) {\r
+    EmitDefaults (mGlobals.HiiExportFileNames, mGlobals.MfgFlag, mGlobals.NoEmptyVarPacks);\r
+  }\r
+  //\r
+  //\r
+  FreeGlobals ();\r
+  IfrParseEnd ();\r
+  StringEnd ();\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+/******************************************************************************/\r
+static\r
+STATUS\r
+MergeHiiExports (\r
+  FILE_NAME_LIST *HiiExportFiles,\r
+  char           *OutputFileName,\r
+  int            MfgDefaults,\r
+  int            NoEmptyVarPacks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a linked list of input HII export pack files, read in the contents\r
+  of each and create a single HII export pack that contains the contents\r
+  of all the input files.\r
+  \r
+Arguments:\r
+\r
+  HiiExportFiles    - pointer to linked list of input HII export pack file names\r
+  OutputFileName    - name of output (merged) HII export file\r
+  MfgDefaults       - non-zero to emit manufacturing defaults in output file\r
+  NoEmptyVarPacks   - non-zero to not emit 0-length variable packs to the output file\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+  \r
+--*/\r
+{\r
+  EFI_HII_HANDLE          HiiHandle;\r
+  FILE                    *OutFptr;\r
+  FILE                    *InFptr;\r
+  STATUS                  Status;\r
+  CHAR8                   *Buffer;\r
+  int                     FileSize;\r
+  int                     DataTableIndex;\r
+  int                     Count;\r
+  int                     NumDataTables;\r
+  EFI_HII_EXPORT_TABLE    *HiiExportTableHeader;\r
+  EFI_HII_EXPORT_TABLE    TempHiiExportTableHeader;\r
+  EFI_HII_DATA_TABLE      *DataTableHeader;\r
+  EFI_HII_STRING_PACK     *StringPack;\r
+  EFI_HII_VARIABLE_PACK   *VarPack;\r
+  EFI_HII_IFR_PACK        *IfrPack;\r
+  EFI_GUID                HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;\r
+  EFI_GUID                PackageGuid;\r
+  EFI_GUID                FormsetGuid;\r
+  long                    DataTableHeaderOffset;\r
+  DATA_TABLE_HEADER_LIST  *DataTableList;\r
+  DATA_TABLE_HEADER_LIST  *LastDataTable;\r
+  DATA_TABLE_HEADER_LIST  *TempDataTable;\r
+  //\r
+  // Init locals\r
+  //\r
+  HiiHandle     = FIRST_HII_PACK_HANDLE;\r
+  Buffer        = NULL;\r
+  InFptr        = NULL;\r
+  OutFptr       = NULL;\r
+  Status        = STATUS_ERROR;\r
+  DataTableList = NULL;\r
+  LastDataTable = NULL;\r
+  //\r
+  // Initialize our IFR parser and string routines\r
+  //\r
+  IfrParseInit ();\r
+  StringInit ();\r
+  //\r
+  // Process each input HII export file\r
+  //\r
+  NumDataTables = 0;\r
+  while (HiiExportFiles != NULL) {\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "Processing file %s\n", HiiExportFiles->FileName);\r
+    }\r
+    //\r
+    // Read in the entire file contents\r
+    //\r
+    if ((InFptr = fopen (HiiExportFiles->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to open HII export file for reading");\r
+      goto Done;\r
+    }\r
+\r
+    fseek (InFptr, 0, SEEK_END);\r
+    FileSize = (int) ftell (InFptr);\r
+    fseek (InFptr, 0, SEEK_SET);\r
+    Buffer = (CHAR8 *) malloc (FileSize);\r
+    if (Buffer == NULL) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to read file contents");\r
+      goto Done;\r
+    }\r
+\r
+    fclose (InFptr);\r
+    InFptr                = NULL;\r
+    HiiExportTableHeader  = (EFI_HII_EXPORT_TABLE *) Buffer;\r
+    //\r
+    // Walk all the data tables\r
+    //\r
+    DataTableHeader = (EFI_HII_DATA_TABLE *) (HiiExportTableHeader + 1);\r
+    for (DataTableIndex = 0; DataTableIndex < (int) HiiExportTableHeader->NumberOfHiiDataTables; DataTableIndex++) {\r
+      NumDataTables++;\r
+      //\r
+      // Make sure we're still pointing into our buffer\r
+      //\r
+      if (((char *) DataTableHeader < Buffer) || ((char *) DataTableHeader > Buffer + FileSize)) {\r
+        Error (NULL, 0, 0, "bad data table size in input file", NULL);\r
+        goto Done;\r
+      }\r
+      //\r
+      // Save a copy of the data table header\r
+      //\r
+      TempDataTable = (DATA_TABLE_HEADER_LIST *) malloc (sizeof (DATA_TABLE_HEADER_LIST));\r
+      if (TempDataTable == NULL) {\r
+        Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      memset ((void *) TempDataTable, 0, sizeof (DATA_TABLE_HEADER_LIST));\r
+      memcpy (&TempDataTable->DataTableHeader, DataTableHeader, sizeof (EFI_HII_DATA_TABLE));\r
+      if (DataTableList == NULL) {\r
+        DataTableList = TempDataTable;\r
+      } else {\r
+        LastDataTable->Next = TempDataTable;\r
+      }\r
+\r
+      LastDataTable = TempDataTable;\r
+      //\r
+      // If there is an IFR pack, parse it\r
+      //\r
+      if (DataTableHeader->IfrDataOffset != 0) {\r
+        if (IfrParsePack (\r
+            HiiHandle,\r
+            (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),\r
+            &DataTableHeader->PackageGuid\r
+            ) != STATUS_SUCCESS\r
+            ) {\r
+          goto Done;\r
+        }\r
+      }\r
+      //\r
+      // If there is string data, save it\r
+      //\r
+      if (DataTableHeader->StringDataOffset != 0) {\r
+        Status = StringParsePack (\r
+                  HiiHandle,\r
+                  (EFI_HII_STRING_PACK *) ((char *) DataTableHeader + DataTableHeader->StringDataOffset),\r
+                  NULL,\r
+                  &DataTableHeader->PackageGuid\r
+                  );\r
+        if (Status != STATUS_SUCCESS) {\r
+          goto Done;\r
+        }\r
+      }\r
+      //\r
+      // If there is device path data, process it\r
+      //\r
+      if (DataTableHeader->DevicePathOffset != 0) {\r
+        Error (NULL, 0, 0, "application error", "%s contains unsupported device path data", HiiExportFiles->FileName);\r
+        goto Done;\r
+      }\r
+      //\r
+      // Next data pack\r
+      //\r
+      DataTableHeader = (EFI_HII_DATA_TABLE *) ((char *) DataTableHeader + DataTableHeader->DataTableSize);\r
+      HiiHandle++;\r
+    }\r
+\r
+    free (Buffer);\r
+    Buffer = NULL;\r
+    //\r
+    // Next input file\r
+    //\r
+    HiiExportFiles = HiiExportFiles->Next;\r
+  }\r
+  //\r
+  // Now create defaults\r
+  //\r
+  if (IfrSetDefaults (MfgDefaults) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Create and write the output HII export header\r
+  //\r
+  if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    goto Done;\r
+  }\r
+\r
+  memset ((void *) &TempHiiExportTableHeader, 0, sizeof (EFI_HII_EXPORT_TABLE));\r
+  TempHiiExportTableHeader.NumberOfHiiDataTables = HiiHandle - FIRST_HII_PACK_HANDLE;\r
+  memcpy (&TempHiiExportTableHeader.Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID));\r
+  if (fwrite ((void *) &TempHiiExportTableHeader, sizeof (EFI_HII_EXPORT_TABLE), 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to write HII export table header to output file");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Now go back through all the handles and create new data packs for each, writing out\r
+  // the contents as we go.\r
+  //\r
+  HiiHandle = FIRST_HII_PACK_HANDLE;\r
+  for (TempDataTable = DataTableList; TempDataTable != NULL; TempDataTable = TempDataTable->Next) {\r
+    //\r
+    // Write a data table header to the output file. We'll rewind the file and\r
+    // write an updated one when we're done with this data set\r
+    //\r
+    DataTableHeaderOffset                         = ftell (OutFptr);\r
+    TempDataTable->DataTableHeader.HiiHandle      = HiiHandle;\r
+    TempDataTable->DataTableHeader.DataTableSize  = sizeof (EFI_HII_DATA_TABLE);\r
+    //\r
+    // We may change the number of variable data when merging export files, so init to 0\r
+    //\r
+    TempDataTable->DataTableHeader.NumberOfVariableData = 0;\r
+    if (fwrite ((void *) &TempDataTable->DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, OutputFileName, "failed to write HII data table header to output file");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Get the string pack if any\r
+    //\r
+    Status = StringGetPack (HiiHandle, &StringPack, &FileSize, &Count, &FormsetGuid, &PackageGuid);\r
+    if (Status == STATUS_SUCCESS) {\r
+      TempDataTable->DataTableHeader.StringDataOffset = TempDataTable->DataTableHeader.DataTableSize;\r
+      TempDataTable->DataTableHeader.DataTableSize += FileSize;\r
+      //\r
+      // TempDataTable->DataTableHeader.NumberOfLanguages should be unchanged\r
+      //\r
+      if (fwrite ((void *) StringPack, FileSize, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, "failed to write string pack to output file", NULL);\r
+        goto Done;\r
+      }\r
+    }\r
+    //\r
+    // Get the IFR pack\r
+    //\r
+    Status = IfrGetIfrPack (HiiHandle, &IfrPack, &FormsetGuid);\r
+    if (Status == STATUS_SUCCESS) {\r
+      //\r
+      // Write the IFR pack, followed by the variable packs\r
+      //\r
+      TempDataTable->DataTableHeader.IfrDataOffset = TempDataTable->DataTableHeader.DataTableSize;\r
+      TempDataTable->DataTableHeader.DataTableSize += IfrPack->Header.Length;\r
+      if (fwrite ((void *) IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, "failed to write IFR pack to output file", NULL);\r
+        goto Done;\r
+      }\r
+      //\r
+      // If this is just a formset stub, then don't write the variable packs\r
+      //\r
+      if (IfrPack->Header.Length != sizeof (EMPTY_FORMSET_PACK)) {\r
+        //\r
+        // Go through all the variable packs and see if they're referenced by this IFR\r
+        //\r
+        Count = 0;\r
+        do {\r
+          Status = IfrGetVarPack (Count, &VarPack);\r
+          if (Status == STATUS_SUCCESS) {\r
+            //\r
+            // Check for variable data length of 0\r
+            //\r
+            if ((NoEmptyVarPacks == 0) ||\r
+                ((VarPack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - VarPack->VariableNameLength) != 0)\r
+                ) {\r
+              //\r
+              // See if it's referenced by this IFR\r
+              //\r
+              if (IfrReferencesVarPack (HiiHandle, VarPack) == STATUS_SUCCESS) {\r
+                if (TempDataTable->DataTableHeader.VariableDataOffset == 0) {\r
+                  TempDataTable->DataTableHeader.VariableDataOffset = TempDataTable->DataTableHeader.DataTableSize;\r
+                }\r
+\r
+                TempDataTable->DataTableHeader.DataTableSize += VarPack->Header.Length;\r
+                TempDataTable->DataTableHeader.NumberOfVariableData++;\r
+                if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {\r
+                  Error (NULL, 0, 0, "failed to write variable pack to output file", NULL);\r
+                  goto Done;\r
+                }\r
+\r
+              }\r
+            }\r
+          }\r
+\r
+          Count++;\r
+        } while (Status == STATUS_SUCCESS);\r
+      }\r
+\r
+      Status = STATUS_SUCCESS;\r
+    }\r
+    //\r
+    // Get the device path pack\r
+    //\r
+    //\r
+    // Rewind the file and write the updated data table header.\r
+    //\r
+    fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);\r
+    if (fwrite ((void *) &TempDataTable->DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, OutputFileName, "failed to write HII data table header to output file");\r
+      goto Done;\r
+    }\r
+\r
+    fseek (OutFptr, 0, SEEK_END);\r
+    HiiHandle++;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  IfrParseEnd ();\r
+  StringEnd ();\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  while (DataTableList != NULL) {\r
+    TempDataTable = DataTableList->Next;\r
+    free (DataTableList);\r
+    DataTableList = TempDataTable;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/******************************************************************************/\r
+static\r
+STATUS\r
+CreateHiiExport (\r
+  char              *OutputFileName,\r
+  EFI_GUID          *DummyFormsetGuid,\r
+  FILE_NAME_LIST    *PackFiles,\r
+  int               MfgDefaults\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a linked list of HII pack file names, walk the list to\r
+  process them and create a single HII export file.\r
+  \r
+Arguments:\r
+\r
+  OutputFileName    - name of output HII export file to create\r
+  DummyFormsetGuid  - IFR formsets contain a GUID which is used in many \r
+                      places while processing data tables. If we were not\r
+                      given an IFR pack, then we'll create a stub IFR\r
+                      pack using this GUID as the formset GUID.\r
+  PackFiles         - linked list of HII pack files to process\r
+  MfgDefaults       - when creating variable packs (via IFR pack processing),\r
+                      use manufacturing defaults rather than standard defaults\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+  \r
+--*/\r
+{\r
+  STATUS                      Status;\r
+  EMPTY_FORMSET_PACK          EmptyFormset;\r
+  EFI_HII_DATA_TABLE          DataTableHeader;\r
+  EFI_HII_EXPORT_TABLE        ExportTableHeader;\r
+  long                        DataTableHeaderOffset;\r
+  long                        FileSize;\r
+  FILE                        *OutFptr;\r
+  FILE                        *InFptr;\r
+  FILE_NAME_LIST              *TempFile;\r
+  EFI_GUID                    HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;\r
+  EFI_GUID                    TempGuid;\r
+  EFI_GUID                    PackageGuid;\r
+  char                        *Buffer;\r
+  EFI_HII_VARIABLE_PACK       *VarPack;\r
+  EFI_HII_IFR_PACK            *IfrPack;\r
+  EFI_HII_STRING_PACK_HEADER  *StringPack;\r
+  EFI_HII_STRING_PACK_HEADER  TerminatorStringPack;\r
+  int                         NumIfr;\r
+  int                         NumStrings;\r
+  int                         Index;\r
+  int                         VarPackIndex;\r
+  //\r
+  // If no input HII pack files, then why are we here? Should have been caught when\r
+  // args were processed though.\r
+  //\r
+  if (PackFiles == NULL) {\r
+    Error (NULL, 0, 0, "no input pack files specified", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  InFptr  = NULL;\r
+  Status  = STATUS_ERROR;\r
+  Buffer  = NULL;\r
+  //\r
+  // Open the output file for writing\r
+  //\r
+  if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Figure out how many data tables we are going to need. We'll create one\r
+  // data table if no more than one IFR, or we'll create one data table per IFR,\r
+  // and then one for strings if multiple IFR\r
+  //\r
+  NumIfr      = 0;\r
+  NumStrings  = 0;\r
+  for (TempFile = PackFiles; TempFile != NULL; TempFile = TempFile->Next) {\r
+    if (TempFile->Tag == EFI_HII_IFR) {\r
+      NumIfr++;\r
+    } else if (TempFile->Tag == EFI_HII_STRING) {\r
+      NumStrings++;\r
+    }\r
+  }\r
+  //\r
+  // Three possibilities:\r
+  //  1) No IFR, so create one data table that contains only strings and an empty formset\r
+  //  2) Only 1 IFR, so create an export table with one data table that contains the IFR\r
+  //     and all the strings\r
+  //  3) Multiple IFR, so create a data table for each IFR and another data table with\r
+  //     all the strings.\r
+  //\r
+  // Initialize the export table header and write it out\r
+  //\r
+  memset ((void *) &ExportTableHeader, 0, sizeof (EFI_HII_EXPORT_TABLE));\r
+  if (NumIfr < 2) {\r
+    ExportTableHeader.NumberOfHiiDataTables = 1;\r
+  } else {\r
+    //\r
+    // One data table per IFR, plus one for strings (if any).\r
+    //\r
+    ExportTableHeader.NumberOfHiiDataTables = (UINT16) NumIfr;\r
+    if (NumStrings != 0) {\r
+      ExportTableHeader.NumberOfHiiDataTables++;\r
+    }\r
+  }\r
+  //\r
+  // Init the GUID in the HII export table header\r
+  //\r
+  memcpy (&ExportTableHeader.Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID));\r
+  if (fwrite ((void *) &ExportTableHeader, sizeof (EFI_HII_EXPORT_TABLE), 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to write HII export table header to output file");\r
+    goto Done;\r
+  }\r
+  //\r
+  // *****************************************************************************************\r
+  //\r
+  //  CASE 1 - No IFR => one data table that contains only strings and an empty formset.\r
+  //           No variable data.\r
+  //\r
+  //  CASE 2 - Only 1 IFR => create an export table with one data table that contains the IFR\r
+  //           and all the strings plus variable data\r
+  //\r
+  //  CASE 3 - Multiple IFR => create a data table for each IFR and another data table with\r
+  //           all the strings. Each IFR data table has variable data if applicable.\r
+  //\r
+  // *****************************************************************************************\r
+  //\r
+  // If the user did not give us an IFR file, then we'll have to create an empty formset\r
+  // and emit it to the output file. In this case, we need a formset GUID on the command\r
+  // line.\r
+  //\r
+  if ((NumIfr == 0) && (mGlobals.GuidSpecified == 0)) {\r
+    //\r
+    //    Warning (NULL, 0, 0, "using NULL GUID for empty formset", "specify -g GUID on the command line if desired");\r
+    //\r
+    memset ((void *) &PackageGuid, 0, sizeof (EFI_GUID));\r
+  } else if (mGlobals.GuidSpecified) {\r
+    //\r
+    // Use it for the package GUID\r
+    //\r
+    memcpy (&PackageGuid, &mGlobals.Guid, sizeof (EFI_GUID));\r
+  }\r
+  //\r
+  // Init the data table header.\r
+  // Write out the blank data table header. Save the offset so we can\r
+  // write an updated version at the end of processing.\r
+  //\r
+  memset ((void *) &DataTableHeader, 0, sizeof (EFI_HII_DATA_TABLE));\r
+  DataTableHeaderOffset     = ftell (OutFptr);\r
+  DataTableHeader.HiiHandle = FIRST_HII_PACK_HANDLE;\r
+  if (mGlobals.Verbose) {\r
+    fprintf (stdout, "writing data table (first time) to offset 0x%X\n", ftell (OutFptr));\r
+  }\r
+\r
+  if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+    Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Set the data table size, then write out all the string packs\r
+  //\r
+  DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);\r
+  //\r
+  // Write out the string files to a single data record\r
+  //\r
+  for (TempFile = PackFiles; TempFile != NULL; TempFile = TempFile->Next) {\r
+    //\r
+    // Continue to next file if it's not a string pack file\r
+    //\r
+    if (TempFile->Tag != EFI_HII_STRING) {\r
+      continue;\r
+    }\r
+    //\r
+    // Set the offset in the header if this is the first string pack\r
+    //\r
+    if (DataTableHeader.StringDataOffset == 0) {\r
+      DataTableHeader.StringDataOffset = DataTableHeader.DataTableSize;\r
+    }\r
+\r
+    if ((InFptr = fopen (TempFile->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, TempFile->FileName, "failed to open input string pack file for reading");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Get the file size, then read it into a buffer\r
+    //\r
+    fseek (InFptr, 0, SEEK_END);\r
+    FileSize = ftell (InFptr);\r
+    fseek (InFptr, 0, SEEK_SET);\r
+    Buffer = (char *) malloc (FileSize);\r
+    if (Buffer == NULL) {\r
+      Error (NULL, 0, 0, TempFile->FileName, "memory allocation failure reading in file contents");\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, TempFile->FileName, "failed to read file contents");\r
+      goto Done;\r
+    }\r
+\r
+    fclose (InFptr);\r
+    InFptr = NULL;\r
+    //\r
+    // Verify that it's actually a string pack\r
+    //\r
+    StringPack = (EFI_HII_STRING_PACK_HEADER *) Buffer;\r
+    while ((char *) StringPack < Buffer + FileSize) {\r
+      if (StringPack->Header.Type != EFI_HII_STRING) {\r
+        Error (NULL, 0, 0, TempFile->FileName, "file does not consist entirely of string packs");\r
+        goto Done;\r
+      }\r
+\r
+      if (StringPack->Header.Length == 0) {\r
+        break;\r
+      }\r
+\r
+      DataTableHeader.NumberOfLanguages++;\r
+      DataTableHeader.DataTableSize += StringPack->Header.Length;\r
+      //\r
+      // Write the string pack to the output file\r
+      //\r
+      if (mGlobals.Verbose) {\r
+        fprintf (stdout, "writing string pack to offset 0x%X\n", ftell (OutFptr));\r
+      }\r
+\r
+      if (fwrite (StringPack, StringPack->Header.Length, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, TempFile->FileName, "failed to write string pack to output file");\r
+        goto Done;\r
+      }\r
+      //\r
+      // Sanity check that adding the length advances us (no wrap)\r
+      //\r
+      if ((char *) StringPack + StringPack->Header.Length <= (char *) StringPack) {\r
+        Error (NULL, 0, 0, TempFile->FileName, "invalid pack size in file");\r
+        goto Done;\r
+      }\r
+\r
+      StringPack = (EFI_HII_STRING_PACK_HEADER *) ((char *) StringPack + StringPack->Header.Length);\r
+    }\r
+    //\r
+    // Free up buffer, go to next input string pack file\r
+    //\r
+    free (Buffer);\r
+    Buffer = NULL;\r
+  }\r
+  //\r
+  // Write a null-terminator string pack if we had any string packs at all\r
+  //\r
+  if (DataTableHeader.StringDataOffset != 0) {\r
+    memset (&TerminatorStringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));\r
+    TerminatorStringPack.Header.Length  = 0;\r
+    TerminatorStringPack.Header.Type    = EFI_HII_STRING;\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "writing terminator string pack to offset 0x%X\n", ftell (OutFptr));\r
+    }\r
+\r
+    if (fwrite (&TerminatorStringPack, sizeof (EFI_HII_STRING_PACK_HEADER), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, "failed to write string pack terminator to output file", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    DataTableHeader.DataTableSize += sizeof (EFI_HII_STRING_PACK_HEADER);\r
+  }\r
+  //\r
+  // Parse all the IFR packs, then get the GUID from the first\r
+  // one so we can use it for the package GUID if necessary.\r
+  //\r
+  memcpy (&PackageGuid, &mGlobals.Guid, sizeof (EFI_GUID));\r
+  if (NumIfr != 0) {\r
+    IfrParseInit ();\r
+    if (ProcessIfrFiles (PackFiles) != STATUS_SUCCESS) {\r
+      goto Done;\r
+    }\r
+    //\r
+    // Set variable defaults in all variable packs\r
+    //\r
+    IfrSetDefaults (MfgDefaults);\r
+    //\r
+    // Get the GUID from the first IFR pack if the user did not specify a GUID on\r
+    // the command line.\r
+    //\r
+    if (mGlobals.GuidSpecified == 0) {\r
+      if (IfrGetIfrPack (FIRST_HII_PACK_HANDLE, &IfrPack, &PackageGuid) != STATUS_SUCCESS) {\r
+        Error (NULL, 0, 0, "internal application error", "failed to retrieve IFR pack after parsing");\r
+        goto Done;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Set the package GUID in the data table header.\r
+  //\r
+  memcpy (&DataTableHeader.PackageGuid, &PackageGuid, sizeof (EFI_GUID));\r
+  //\r
+  // If no IFR, then create and write the empty formset. Otherwise\r
+  // parse the IFR and emit it and the variable data for it.\r
+  //\r
+  if (NumIfr == 0) {\r
+    memset ((void *) &EmptyFormset, 0, sizeof (EMPTY_FORMSET_PACK));\r
+    EmptyFormset.PackHeader.Header.Type   = EFI_HII_IFR;\r
+    EmptyFormset.PackHeader.Header.Length = sizeof (EMPTY_FORMSET_PACK);\r
+    //\r
+    // Formset Opcode\r
+    //\r
+    EmptyFormset.Formset.Header.OpCode  = EFI_IFR_FORM_SET_OP;\r
+    EmptyFormset.Formset.Header.Length  = (UINT8) sizeof (EFI_IFR_FORM_SET);\r
+    memcpy (&EmptyFormset.Formset.Guid, &PackageGuid, sizeof (EFI_GUID));\r
+    //\r
+    // EndFormset Opcode\r
+    //\r
+    EmptyFormset.EndFormset.Header.OpCode = EFI_IFR_END_FORM_SET_OP;\r
+    EmptyFormset.EndFormset.Header.Length = (UINT8) sizeof (EFI_IFR_END_FORM_SET);\r
+    DataTableHeader.IfrDataOffset         = DataTableHeader.DataTableSize;\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "writing stub IFR formset to to offset 0x%X\n", ftell (OutFptr));\r
+    }\r
+\r
+    if (fwrite (&EmptyFormset, sizeof (EMPTY_FORMSET_PACK), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, OutputFileName, "failed to write formset stub to output file");\r
+      goto Done;\r
+    }\r
+\r
+    DataTableHeader.DataTableSize += sizeof (EMPTY_FORMSET_PACK);\r
+    //\r
+    // Go back and re-write the data table header, reposition to the end, then return.\r
+    //\r
+    fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "writing data table (second time) to offset 0x%X\n", ftell (OutFptr));\r
+    }\r
+\r
+    if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    fseek (OutFptr, 0, SEEK_END);\r
+    if (mGlobals.Verbose) {\r
+      fprintf (\r
+        stdout,\r
+        "final file offset=0x%X DataTableHeader.DataTableSize=0x%X\n",\r
+        ftell (OutFptr),\r
+        DataTableHeader.DataTableSize\r
+        );\r
+    }\r
+  } else if (NumIfr == 1) {\r
+    //\r
+    // They gave us one input IFR file. We parsed it above, so get each one\r
+    // and emit the IFR and each variable pack it references.\r
+    // Update the data pack header for the IFR pack, then write the IFR pack data\r
+    //\r
+    DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;\r
+    if (IfrGetIfrPack (FIRST_HII_PACK_HANDLE, &IfrPack, &TempGuid) != STATUS_SUCCESS) {\r
+      Error (NULL, 0, 0, "internal application error", "failed to retrieve IFR pack after parsing");\r
+      goto Done;\r
+    }\r
+\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "writing IFR pack to 0x%X\n", ftell (OutFptr));\r
+    }\r
+\r
+    if (fwrite (IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, OutputFileName, "failed to write IFR pack to output file");\r
+      goto Done;\r
+    }\r
+\r
+    DataTableHeader.DataTableSize += IfrPack->Header.Length;\r
+    //\r
+    // Now go through all the variable packs discovered during IFR processing\r
+    // and write them to the output file\r
+    //\r
+    if (mGlobals.NoVarPacks == 0) {\r
+      Index = 0;\r
+      do {\r
+        Status = IfrGetVarPack (Index, &VarPack);\r
+        if (Status == STATUS_SUCCESS) {\r
+          //\r
+          // If this is the first variable pack, then update the "offset\r
+          // to variable data" in the data table header\r
+          //\r
+          if (Index == 0) {\r
+            DataTableHeader.VariableDataOffset = DataTableHeader.DataTableSize;\r
+          }\r
+\r
+          DataTableHeader.DataTableSize += VarPack->Header.Length;\r
+          DataTableHeader.NumberOfVariableData++;\r
+          if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {\r
+            Error (NULL, 0, 0, OutputFileName, "failed to write variable pack to output file");\r
+            goto Done;\r
+          }\r
+\r
+          Index++;\r
+        }\r
+      } while (Status == STATUS_SUCCESS);\r
+    }\r
+    //\r
+    // Reposition in the output file and write the updated data table header\r
+    //\r
+    fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);\r
+    if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+      Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    fseek (OutFptr, 0, SEEK_END);\r
+  } else {\r
+    //\r
+    // Multiple IFR input files. Close out the current data table (strings)\r
+    // if applicable. Then retrieve each parsed IFR pack and create a data pack\r
+    // that contains the IFR (one per data set) and the variable packs that\r
+    // the given IFR form references.\r
+    //\r
+    if (NumStrings != 0) {\r
+      fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);\r
+      if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      fseek (OutFptr, 0, SEEK_END);\r
+    } else {\r
+      //\r
+      // No strings, so back up over the data table header we wrote because we assumed\r
+      // at least one string pack.\r
+      //\r
+      fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);\r
+    }\r
+    //\r
+    // Now go through all the IFR packs and write them out, along with variable\r
+    // data referenced by each. Note that multiple IFR forms can refer to the\r
+    // same variables, so the same variable data could be duplicated in multiple\r
+    // data packs.\r
+    //\r
+    Index = FIRST_HII_PACK_HANDLE;\r
+    while (IfrGetIfrPack (Index, &IfrPack, &TempGuid) == STATUS_SUCCESS) {\r
+      //\r
+      // Initialize the data table header\r
+      //\r
+      memset (&DataTableHeader, 0, sizeof (EFI_HII_DATA_TABLE));\r
+      memcpy (&DataTableHeader.PackageGuid, &PackageGuid, sizeof (EFI_GUID));\r
+      //\r
+      // If we didn't have strings, then the HiiHandle should be just Index,\r
+      // rather than Index+1. But since the HiiHandle is not required to start\r
+      // with 1, we'll let it be Index+1.\r
+      //\r
+      DataTableHeader.HiiHandle     = (EFI_HII_HANDLE) (Index + 1);\r
+      DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);\r
+      //\r
+      // Save the file offset of the data table header so we can write an updated\r
+      // version later.\r
+      //\r
+      DataTableHeaderOffset = ftell (OutFptr);\r
+      if (mGlobals.Verbose) {\r
+        fprintf (stdout, "writing data table header to 0x%X\n", ftell (OutFptr));\r
+      }\r
+\r
+      if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;\r
+      if (fwrite (IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, OutputFileName, "failed to write IFR pack to output file");\r
+        goto Done;\r
+      }\r
+\r
+      DataTableHeader.DataTableSize += IfrPack->Header.Length;\r
+      //\r
+      // Go through all the variable packs and see if this IFR references each. If the\r
+      // IFR does reference it, then add the variable pack to the output.\r
+      //\r
+      if (mGlobals.NoVarPacks == 0) {\r
+        VarPackIndex = 0;\r
+        while (IfrGetVarPack (VarPackIndex, &VarPack) == STATUS_SUCCESS) {\r
+          //\r
+          // See if the IFR references this variable pack\r
+          //\r
+          if (IfrReferencesVarPack (Index, VarPack) == STATUS_SUCCESS) {\r
+            //\r
+            // If this is the first variable pack, then set the offset in\r
+            // the data table header.\r
+            //\r
+            if (DataTableHeader.VariableDataOffset == 0) {\r
+              DataTableHeader.VariableDataOffset = DataTableHeader.DataTableSize;\r
+            }\r
+            //\r
+            // Write the variable pack\r
+            //\r
+            if (fwrite (VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {\r
+              Error (NULL, 0, 0, OutputFileName, "failed to write variable pack to output file");\r
+              goto Done;\r
+            }\r
+\r
+            DataTableHeader.NumberOfVariableData++;\r
+            DataTableHeader.DataTableSize += VarPack->Header.Length;\r
+          }\r
+\r
+          VarPackIndex++;\r
+        }\r
+      }\r
+      //\r
+      // Write the updated data table header\r
+      //\r
+      fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);\r
+      if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {\r
+        Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);\r
+        goto Done;\r
+      }\r
+\r
+      fseek (OutFptr, 0, SEEK_END);\r
+      //\r
+      // Next IFR pack\r
+      //\r
+      Index++;\r
+    }\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  IfrParseEnd ();\r
+  StringEnd ();\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+/******************************************************************************/\r
+static\r
+STATUS\r
+ProcessIfrFiles (\r
+  FILE_NAME_LIST  *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a linked list of pack file names, read in each IFR pack file\r
+  and process the contents.\r
+  \r
+Arguments:\r
+\r
+  FileName    - pointer to linked list of input pack file names\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+  \r
+--*/\r
+{\r
+  FILE                *InFptr;\r
+  char                *Buffer;\r
+  long                BufferSize;\r
+  STATUS              Status;\r
+  STATUS              IfrStatus;\r
+  int                 Handle;\r
+  EFI_GUID            FormsetGuid;\r
+  EFI_HII_PACK_HEADER *PackHeader;\r
+  //\r
+  // Process each input IFR file\r
+  //\r
+  Status  = STATUS_ERROR;\r
+  Handle  = 1;\r
+  InFptr  = NULL;\r
+  Buffer  = NULL;\r
+  while (FileName != NULL) {\r
+    //\r
+    // Only process IFR pack files\r
+    //\r
+    if (FileName->Tag != EFI_HII_IFR) {\r
+      FileName = FileName->Next;\r
+      continue;\r
+    }\r
+    //\r
+    // Open the input file, then read the contents\r
+    //\r
+    if ((InFptr = fopen (FileName->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, FileName->FileName, "failed to open input IFR file");\r
+      goto Done;\r
+    }\r
+\r
+    fseek (InFptr, 0, SEEK_END);\r
+    BufferSize = ftell (InFptr);\r
+    fseek (InFptr, 0, SEEK_SET);\r
+    Buffer = (char *) malloc (BufferSize);\r
+    if (Buffer == NULL) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (Buffer, BufferSize, 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, FileName->FileName, "failed to read file contents");\r
+      goto Done;\r
+    }\r
+\r
+    fclose (InFptr);\r
+    InFptr = NULL;\r
+    //\r
+    // Check the buffer contents -- better be an IFR pack\r
+    //\r
+    if (BufferSize < sizeof (EFI_HII_PACK_HEADER)) {\r
+      Error (NULL, 0, 0, FileName->FileName, "file is not large enough to contain an IFR pack");\r
+      goto Done;\r
+    }\r
+\r
+    PackHeader = (EFI_HII_PACK_HEADER *) Buffer;\r
+    if (PackHeader->Type != EFI_HII_IFR) {\r
+      Error (NULL, 0, 0, FileName->FileName, "file does not appear to be an IFR pack");\r
+      goto Done;\r
+    }\r
+    //\r
+    // Process the contents\r
+    //\r
+    memset ((void *) &FormsetGuid, 0, sizeof (EFI_GUID));\r
+    IfrStatus = IfrParsePack (Handle, (EFI_HII_IFR_PACK *) PackHeader, &FormsetGuid);\r
+    if (IfrStatus != STATUS_SUCCESS) {\r
+      goto Done;\r
+    }\r
+\r
+    Handle++;\r
+    free (Buffer);\r
+    Buffer    = NULL;\r
+    FileName  = FileName->Next;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+EmitDefaults (\r
+  FILE_NAME_LIST  *HiiExportFiles,\r
+  int             MfgDefaults,\r
+  int             NoEmptyVarPacks\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a linked list of HII export files, read in each file,\r
+  process the contents, and then emit variable packs.\r
+  \r
+Arguments:\r
+\r
+  HiiExportFiles  - linked list of HII export files to process\r
+  MfgDefaults     - emit manufacturing defaults\r
+  NoEmptyVarPacks - don't emit variable packs if they are 0-length\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+  \r
+--*/\r
+{\r
+  int                   HiiHandle;\r
+  FILE                  *OutFptr;\r
+  FILE                  *InFptr;\r
+  EFI_HII_VARIABLE_PACK *VarPack;\r
+  CHAR8                 OutFileName[MAX_PATH];\r
+  CHAR8                 GuidString[100];\r
+  STATUS                Status;\r
+  CHAR8                 *Buffer;\r
+  int                   FileSize;\r
+  int                   DataTableIndex;\r
+  EFI_HII_EXPORT_TABLE  *HiiExportTableHeader;\r
+  EFI_HII_DATA_TABLE    *DataTableHeader;\r
+  //\r
+  // Init locals\r
+  //\r
+  HiiHandle = FIRST_HII_PACK_HANDLE;\r
+  Buffer    = NULL;\r
+  InFptr    = NULL;\r
+  OutFptr   = NULL;\r
+  Status    = STATUS_ERROR;\r
+  //\r
+  // Initialize our IFR parser\r
+  //\r
+  IfrParseInit ();\r
+  //\r
+  // Process each input HII export file\r
+  //\r
+  while (HiiExportFiles != NULL) {\r
+    if (mGlobals.Verbose) {\r
+      fprintf (stdout, "Processing file %s\n", HiiExportFiles->FileName);\r
+    }\r
+    //\r
+    // Read in the entire file contents\r
+    //\r
+    if ((InFptr = fopen (HiiExportFiles->FileName, "rb")) == NULL) {\r
+      Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to open HII export file for reading");\r
+      goto Done;\r
+    }\r
+\r
+    fseek (InFptr, 0, SEEK_END);\r
+    FileSize = (int) ftell (InFptr);\r
+    fseek (InFptr, 0, SEEK_SET);\r
+    Buffer = (CHAR8 *) malloc (FileSize);\r
+    if (Buffer == NULL) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      goto Done;\r
+    }\r
+\r
+    if (fread (Buffer, FileSize, 1, InFptr) != 1) {\r
+      Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to read file contents");\r
+      goto Done;\r
+    }\r
+\r
+    fclose (InFptr);\r
+    InFptr                = NULL;\r
+    HiiExportTableHeader  = (EFI_HII_EXPORT_TABLE *) Buffer;\r
+    //\r
+    // Walk all the data tables\r
+    //\r
+    DataTableHeader = (EFI_HII_DATA_TABLE *) (HiiExportTableHeader + 1);\r
+    for (DataTableIndex = 0; DataTableIndex < (int) HiiExportTableHeader->NumberOfHiiDataTables; DataTableIndex++) {\r
+      //\r
+      // Make sure we're still pointing into our buffer\r
+      //\r
+      if (((char *) DataTableHeader < Buffer) || ((char *) DataTableHeader > Buffer + FileSize)) {\r
+        Error (NULL, 0, 0, "bad data table size in input file", NULL);\r
+        goto Done;\r
+      }\r
+      //\r
+      // If there is an IFR pack, parse it\r
+      //\r
+      HiiHandle++;\r
+      if (DataTableHeader->IfrDataOffset != 0) {\r
+        if (IfrParsePack (\r
+            HiiHandle,\r
+            (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),\r
+            &DataTableHeader->PackageGuid\r
+            ) != STATUS_SUCCESS\r
+            ) {\r
+          goto Done;\r
+        }\r
+      }\r
+      //\r
+      // Next data pack\r
+      //\r
+      DataTableHeader = (EFI_HII_DATA_TABLE *) ((char *) DataTableHeader + DataTableHeader->DataTableSize);\r
+    }\r
+\r
+    free (Buffer);\r
+    Buffer = NULL;\r
+    //\r
+    // Next input file\r
+    //\r
+    HiiExportFiles = HiiExportFiles->Next;\r
+  }\r
+  //\r
+  // Now create defaults\r
+  //\r
+  if (IfrSetDefaults (MfgDefaults) != STATUS_SUCCESS) {\r
+    goto Done;\r
+  }\r
+  //\r
+  // Now retrieve each variable pack and write it out to a GUID-VarName.hpk file\r
+  //\r
+  HiiHandle = 0;\r
+  do {\r
+    Status = IfrGetVarPack (HiiHandle, &VarPack);\r
+    if (Status == STATUS_SUCCESS) {\r
+      //\r
+      // Check for variable data length of 0\r
+      //\r
+      if ((NoEmptyVarPacks == 0) ||\r
+          ((VarPack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - VarPack->VariableNameLength) != 0)\r
+          ) {\r
+        //\r
+        // Open the output file and write the variable pack\r
+        //\r
+        GuidToString (&VarPack->VariableGuid, GuidString);\r
+        if (MfgDefaults) {\r
+          sprintf (\r
+            OutFileName,\r
+            "%s-%S-MfgDefaults%s",\r
+            GuidString,\r
+            (CHAR16 *) (VarPack + 1),\r
+            DEFAULT_HII_PACK_FILENAME_EXTENSION\r
+            );\r
+        } else {\r
+          sprintf (\r
+            OutFileName,\r
+            "%s-%S-Defaults%s",\r
+            GuidString,\r
+            (CHAR16 *) (VarPack + 1),\r
+            DEFAULT_HII_PACK_FILENAME_EXTENSION\r
+            );\r
+        }\r
+\r
+        if (mGlobals.Verbose) {\r
+          fprintf (\r
+            stdout,\r
+            "Creating %svariable defaults pack file %s\n",\r
+            MfgDefaults ? "manufacturing " : "",\r
+            OutFileName\r
+            );\r
+        }\r
+\r
+        if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {\r
+          Error (NULL, 0, 0, OutFileName, "failed to open output file for writing", NULL);\r
+          goto Done;\r
+        }\r
+\r
+        if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {\r
+          Error (NULL, 0, 0, OutFileName, "failed to write defaults to output file");\r
+          goto Done;\r
+        }\r
+\r
+        fclose (OutFptr);\r
+        OutFptr = NULL;\r
+      } else {\r
+        //\r
+        // Print a message that we skipped one if in verbose mode\r
+        //\r
+        if (mGlobals.Verbose) {\r
+          GuidToString (&VarPack->VariableGuid, GuidString);\r
+          if (MfgDefaults) {\r
+            sprintf (\r
+              OutFileName,\r
+              "%s-%S-MfgDefaults%s",\r
+              GuidString,\r
+              (CHAR16 *) (VarPack + 1),\r
+              DEFAULT_HII_PACK_FILENAME_EXTENSION\r
+              );\r
+          } else {\r
+            sprintf (\r
+              OutFileName,\r
+              "%s-%S-Defaults%s",\r
+              GuidString,\r
+              (CHAR16 *) (VarPack + 1),\r
+              DEFAULT_HII_PACK_FILENAME_EXTENSION\r
+              );\r
+          }\r
+\r
+          fprintf (\r
+            stdout,\r
+            "Skipping 0-length %svariable defaults pack file %s\n",\r
+            MfgDefaults ? "manufacturing " : "",\r
+            OutFileName\r
+            );\r
+        }\r
+      }\r
+    }\r
+\r
+    HiiHandle++;\r
+  } while (Status == STATUS_SUCCESS);\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  IfrParseEnd ();\r
+  if (Buffer != NULL) {\r
+    free (Buffer);\r
+  }\r
+\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+void\r
+FreeGlobals (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free up an memory we allocated so we can exit cleanly\r
+  \r
+Arguments:\r
+\r
+Returns: NA\r
+\r
+--*/\r
+{\r
+  FILE_NAME_LIST  *Next;\r
+  //\r
+  // Free up input pack file names\r
+  //\r
+  while (mGlobals.PackFileNames != NULL) {\r
+    Next = mGlobals.PackFileNames->Next;\r
+    free (mGlobals.PackFileNames);\r
+    mGlobals.PackFileNames = Next;\r
+  }\r
+  //\r
+  // Free up input HII export file names\r
+  //\r
+  while (mGlobals.HiiExportFileNames != NULL) {\r
+    Next = mGlobals.HiiExportFileNames->Next;\r
+    free (mGlobals.HiiExportFileNames);\r
+    mGlobals.HiiExportFileNames = Next;\r
+  }\r
+}\r
+\r
+static\r
+STATUS\r
+DumpHiiExportFile (\r
+  char    *HiiExportFileName,\r
+  char    *OutputFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of an HII export file for debug purposes\r
+  \r
+Arguments:\r
+\r
+  HiiExportFileName - name of input HII export file\r
+  OutputFileName    - name of output file to dump contents\r
+\r
+Returns: \r
+  STATUS_SUCCESS  - no problems\r
+  STATUS_ERROR    - problems encountered processing the file\r
+\r
+--*/\r
+{\r
+  FILE                *InFptr;\r
+\r
+  FILE                *OutFptr;\r
+  char                *Buffer;\r
+  char                *BufferStart;\r
+  char                *BufferEnd;\r
+  int                 BufferSize;\r
+  STATUS              Status;\r
+  char                GuidString[100];\r
+  int                 Counter;\r
+  int                 NumberOfTables;\r
+  EFI_HII_DATA_TABLE  *DataTableHeader;\r
+  EFI_GUID              HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;\r
+  //\r
+  // Init locals\r
+  //\r
+  InFptr      = NULL;\r
+  OutFptr     = NULL;\r
+  BufferStart = NULL;\r
+  Status      = STATUS_ERROR;\r
+  //\r
+  // Open the input file\r
+  //\r
+  if ((InFptr = fopen (HiiExportFileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, HiiExportFileName, "failed to open input HII export file for reading");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Open the output file\r
+  //\r
+  if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    goto Done;\r
+  }\r
+  //\r
+  // Get the file size, then allocate a buffer and read in the file contents.\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  BufferSize = (int) ftell (InFptr);\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  BufferStart = (char *) malloc (BufferSize);\r
+  if (BufferStart == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  if (fread (BufferStart, BufferSize, 1, InFptr) != 1) {\r
+    Error (NULL, 0, 0, HiiExportFileName, "error reading file contents");\r
+    goto Done;\r
+  }\r
+\r
+  fclose (InFptr);\r
+  InFptr = NULL;\r
+  //\r
+  // Crude check of the input data -- check the size and GUID\r
+  //\r
+  if (BufferSize < sizeof (EFI_HII_EXPORT_TABLE)) {\r
+    Error (NULL, 0, 0, HiiExportFileName, "files not large enough to contain an HII export table header");\r
+    goto Done;\r
+  }\r
+\r
+  if (memcmp (&((EFI_HII_EXPORT_TABLE *) BufferStart)->Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID)) != 0) {\r
+    Error (NULL, 0, 0, HiiExportFileName, "invalid HII export revision GUID -- is this an HII export file?");\r
+    //\r
+    // See if it's a HII pack file\r
+    //\r
+    TestDumpHiiPack (OutFptr, BufferStart, BufferSize);\r
+    goto Done;\r
+  }\r
+  //\r
+  // Now walk the export data\r
+  //\r
+  Buffer    = BufferStart;\r
+  BufferEnd = BufferStart + BufferSize;\r
+  //\r
+  // Dump the header\r
+  //\r
+  fprintf (OutFptr, "HII dump of file %s\n\n", HiiExportFileName);\r
+  NumberOfTables = ((EFI_HII_EXPORT_TABLE *) Buffer)->NumberOfHiiDataTables;\r
+  fprintf (OutFptr, "Number of data tables:  %d\n", NumberOfTables);\r
+  GuidToString (&((EFI_HII_EXPORT_TABLE *) Buffer)->Revision, GuidString);\r
+  fprintf (OutFptr, "HII export revision:    %s\n", GuidString);\r
+  //\r
+  // Now walk the data tables\r
+  //\r
+  Buffer += sizeof (EFI_HII_EXPORT_TABLE);\r
+  for (Counter = 0; Counter < NumberOfTables; Counter++) {\r
+    DataTableHeader = (EFI_HII_DATA_TABLE *) Buffer;\r
+    fprintf (OutFptr, "----------------------------------------------------------\n");\r
+    fprintf (OutFptr, "  DataTable at offset 0x%08X\n", (int) Buffer - (int) BufferStart);\r
+    fprintf (OutFptr, "    HII Handle:                            0x%08X\n", DataTableHeader->HiiHandle);\r
+    GuidToString (&DataTableHeader->PackageGuid, GuidString);\r
+    fprintf (OutFptr, "    Package GUID:                          %s\n", GuidString);\r
+    fprintf (OutFptr, "    Data table size:                       0x%08X\n", DataTableHeader->DataTableSize);\r
+    fprintf (OutFptr, "    IFR data offset:                       0x%08X\n", DataTableHeader->IfrDataOffset);\r
+    fprintf (OutFptr, "    String data offset:                    0x%08X\n", DataTableHeader->StringDataOffset);\r
+    fprintf (OutFptr, "    Variable data offset:                  0x%08X\n", DataTableHeader->VariableDataOffset);\r
+    fprintf (OutFptr, "    Device path offset:                    0x%08X\n", DataTableHeader->DevicePathOffset);\r
+    fprintf (OutFptr, "    Number of variable data:               0x%08X\n", DataTableHeader->NumberOfVariableData);\r
+    fprintf (OutFptr, "    Number of languages:                   0x%08X\n", DataTableHeader->NumberOfLanguages);\r
+    //\r
+    // Dump strings\r
+    //\r
+    if (DataTableHeader->StringDataOffset != 0) {\r
+      DumpStringPack (\r
+        OutFptr,\r
+        (EFI_HII_STRING_PACK *) ((char *) DataTableHeader + DataTableHeader->StringDataOffset),\r
+        DataTableHeader->StringDataOffset,\r
+        6\r
+        );\r
+    }\r
+    //\r
+    // Dump IFR\r
+    //\r
+    if (DataTableHeader->IfrDataOffset != 0) {\r
+      DumpIfrPack (\r
+        OutFptr,\r
+        (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),\r
+        DataTableHeader->IfrDataOffset,\r
+        6\r
+        );\r
+    }\r
+    //\r
+    // Dump variables\r
+    //\r
+    if (DataTableHeader->VariableDataOffset != 0) {\r
+      DumpVariablePacks (\r
+        OutFptr,\r
+        (EFI_HII_VARIABLE_PACK *) ((char *) DataTableHeader + DataTableHeader->VariableDataOffset),\r
+        DataTableHeader->NumberOfVariableData,\r
+        DataTableHeader->VariableDataOffset,\r
+        6\r
+        );\r
+    }\r
+    //\r
+    // Dump device path\r
+    //\r
+    //\r
+    // Check position before advancing\r
+    //\r
+    if ((Buffer + DataTableHeader->DataTableSize < Buffer) || (Buffer + DataTableHeader->DataTableSize > BufferEnd)) {\r
+      Error (NULL, 0, 0, HiiExportFileName, "bad data table size at offset 0x%X", (int) Buffer - (int) BufferStart);\r
+      goto Done;\r
+    }\r
+\r
+    Buffer += DataTableHeader->DataTableSize;\r
+  }\r
+\r
+  Status = STATUS_SUCCESS;\r
+Done:\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  if (InFptr != NULL) {\r
+    fclose (InFptr);\r
+  }\r
+\r
+  if (BufferStart != NULL) {\r
+    free (BufferStart);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+void\r
+DumpIfrPack (\r
+  FILE                  *OutFptr,\r
+  EFI_HII_IFR_PACK      *Pack,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of an IFR pack for debug purposes\r
+  \r
+Arguments:\r
+\r
+  OutFptr         - file pointer to which to dump the output\r
+  Pack            - pointer to IFR pack to dump\r
+  BaseOffset      - offset from which Pack starts in its parent data table\r
+  Indent          - indent this many spaces when printing text to OutFptr\r
+\r
+Returns: \r
+  NA\r
+\r
+--*/\r
+{\r
+  EFI_IFR_FORM_SET  *IfrFormSet;\r
+  char              GuidString[100];\r
+  if (Pack->Header.Type != EFI_HII_IFR) {\r
+    Error (NULL, 0, 0, "found non-IFR pack type at IFR data offset", NULL);\r
+    return ;\r
+  }\r
+\r
+  fprintf (OutFptr, "%*cIFR pack at offset      0x%08X\n", Indent, ' ', BaseOffset);\r
+  fprintf (OutFptr, "%*c  Length                0x%08X\n", Indent, ' ', Pack->Header.Length);\r
+  //\r
+  // Get the GUID from the formset\r
+  //\r
+  IfrFormSet = (EFI_IFR_FORM_SET *) (Pack + 1);\r
+  GuidToString (&IfrFormSet->Guid, GuidString);\r
+  fprintf (OutFptr, "%*c  Variable GUID         %s\n", Indent, ' ', GuidString);\r
+  //\r
+  // Print the IFR formset size, with a note indicating if it's a min (likely stub)\r
+  // formset\r
+  //\r
+  if (Pack->Header.Length == sizeof (EMPTY_FORMSET_PACK)) {\r
+    fprintf (\r
+      OutFptr,\r
+      "%*c  IFR formset size      0x%08X (empty formset)\n",\r
+      Indent,\r
+      ' ',\r
+      Pack->Header.Length - sizeof (EFI_HII_IFR_PACK)\r
+      );\r
+  } else {\r
+    fprintf (\r
+      OutFptr,\r
+      "%*c  IFR formset size      0x%08X\n",\r
+      Indent,\r
+      ' ',\r
+      Pack->Header.Length - sizeof (EFI_HII_IFR_PACK)\r
+      );\r
+  }\r
+  //\r
+  // Dump raw bytes -- not much use\r
+  //\r
+}\r
+\r
+static\r
+void\r
+DumpVariablePacks (\r
+  FILE                  *OutFptr,\r
+  EFI_HII_VARIABLE_PACK *Pack,\r
+  int                   NumPacks,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of an IFR pack for debug purposes\r
+  \r
+Arguments:\r
+\r
+  OutFptr         - file pointer to which to dump the output\r
+  Pack            - pointer to variable pack to dump\r
+  NumPacks        - number of packs in Pack[] array\r
+  BaseOffset      - offset from which Pack starts in its parent data table\r
+  Indent          - indent this many spaces when printing text to OutFptr\r
+\r
+Returns: \r
+  NA\r
+\r
+--*/\r
+{\r
+  int   Count;\r
+\r
+  int   Len;\r
+  char  GuidString[100];\r
+\r
+  for (Count = 0; Count < NumPacks; Count++) {\r
+    if (Pack->Header.Type != EFI_HII_VARIABLE) {\r
+      Error (NULL, 0, 0, "found non-variable pack type in variable pack array", NULL);\r
+      return ;\r
+    }\r
+\r
+    fprintf (OutFptr, "%*cVariable pack at offset 0x%08X\n", Indent, ' ', BaseOffset);\r
+    fprintf (OutFptr, "%*c  Length                0x%08X\n", Indent, ' ', Pack->Header.Length);\r
+    GuidToString (&Pack->VariableGuid, GuidString);\r
+    fprintf (OutFptr, "%*c  Variable GUID         %s\n", Indent, ' ', GuidString);\r
+    fprintf (OutFptr, "%*c  Variable Name         %S\n", Indent, ' ', (CHAR16 *) (Pack + 1));\r
+    Len = sizeof (EFI_HII_VARIABLE_PACK) + Pack->VariableNameLength;\r
+    fprintf (OutFptr, "%*c  Variable Size         0x%08X\n", Indent, ' ', Pack->Header.Length - Len);\r
+    //\r
+    // Dump raw bytes\r
+    //\r
+    DumpRawBytes (OutFptr, (char *) Pack + Len, Pack->Header.Length - Len, Len, Indent + 2);\r
+    BaseOffset += Pack->Header.Length;\r
+    Pack = (EFI_HII_VARIABLE_PACK *) ((char *) Pack + Pack->Header.Length);\r
+  }\r
+}\r
+\r
+static\r
+void\r
+DumpStringPack (\r
+  FILE                  *OutFptr,\r
+  EFI_HII_STRING_PACK   *Pack,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump the contents of a string pack array for debug purposes\r
+  \r
+Arguments:\r
+\r
+  OutFptr         - file pointer to which to dump the output\r
+  Pack            - pointer to string pack array to dump\r
+  BaseOffset      - offset from which Pack starts in its parent data table\r
+  Indent          - indent this many spaces when printing text to OutFptr\r
+\r
+Returns: \r
+  NA\r
+\r
+--*/\r
+{\r
+  int     Count;\r
+  int     *IndexPtr;\r
+  CHAR16  *WCPtr;\r
+  //\r
+  // String pack array is terminated with a zero-length string pack\r
+  //\r
+  while (Pack->Header.Length > 0) {\r
+    if (Pack->Header.Type != EFI_HII_STRING) {\r
+      Error (NULL, 0, 0, "found non-string pack type in string pack array", NULL);\r
+      return ;\r
+    }\r
+\r
+    fprintf (OutFptr, "%*cString pack at offset   0x%08X\n", Indent, ' ', BaseOffset);\r
+    fprintf (OutFptr, "%*c  Length                0x%08X\n", Indent, ' ', Pack->Header.Length);\r
+    fprintf (\r
+      OutFptr,\r
+      "%*c  Language              %S\n",\r
+      Indent,\r
+      ' ',\r
+      (CHAR16 *) ((char *) Pack + Pack->LanguageNameString)\r
+      );\r
+    fprintf (\r
+      OutFptr,\r
+      "%*c  Printable Language    %S\n",\r
+      Indent,\r
+      ' ',\r
+      (CHAR16 *) ((char *) Pack + Pack->PrintableLanguageName)\r
+      );\r
+    fprintf (OutFptr, "%*c  Number of strings     0x%08X\n", Indent, ' ', Pack->NumStringPointers);\r
+    fprintf (OutFptr, "%*c  Attributes            0x%08X\n", Indent, ' ', Pack->Attributes);\r
+    IndexPtr = (int *) (Pack + 1);\r
+    //\r
+    // Dump string data\r
+    //\r
+    if (mGlobals.DumpStrings) {\r
+      for (Count = 0; Count < (int) Pack->NumStringPointers; Count++) {\r
+        fprintf (OutFptr, "%*c    String 0x%04X: ", Indent, ' ', Count);\r
+        //\r
+        // Print raw hex bytes\r
+        //\r
+        for (WCPtr = (CHAR16 *) ((char *) Pack +*IndexPtr); *WCPtr != 0; WCPtr++) {\r
+          fprintf (OutFptr, "%02X ", (unsigned int) *WCPtr);\r
+        }\r
+\r
+        fprintf (OutFptr, "00\n");\r
+        IndexPtr++;\r
+      }\r
+    }\r
+\r
+    BaseOffset += Pack->Header.Length;\r
+    Pack = (EFI_HII_STRING_PACK *) ((char *) Pack + Pack->Header.Length);\r
+  }\r
+}\r
+\r
+static\r
+void\r
+TestDumpHiiPack (\r
+  FILE    *OutFptr,\r
+  char    *Buffer,\r
+  int     BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  OutFptr     - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_HII_PACK_HEADER *PackHeader;\r
+\r
+  PackHeader = (EFI_HII_PACK_HEADER *) Buffer;\r
+  //\r
+  // Check size match\r
+  //\r
+  if (PackHeader->Length != (unsigned int) BufferSize) {\r
+    return ;\r
+  }\r
+  //\r
+  // Check type\r
+  //\r
+  switch (PackHeader->Type) {\r
+  case EFI_HII_STRING:\r
+    fprintf (stdout, "Dumping as string pack\n");\r
+    DumpStringPack (OutFptr, (EFI_HII_STRING_PACK *) Buffer, 0, 2);\r
+    break;\r
+\r
+  case EFI_HII_IFR:\r
+    fprintf (stdout, "Dumping as IFR pack\n");\r
+    DumpIfrPack (OutFptr, (EFI_HII_IFR_PACK *) Buffer, 0, 2);\r
+    break;\r
+\r
+  case EFI_HII_VARIABLE:\r
+    fprintf (stdout, "Dumping as IFR pack\n");\r
+    DumpVariablePacks (OutFptr, (EFI_HII_VARIABLE_PACK *) Buffer, 1, 0, 2);\r
+    break;\r
+  }\r
+}\r
+\r
+static\r
+void\r
+DumpRawBytes (\r
+  FILE                  *OutFptr,\r
+  char                  *Buffer,\r
+  int                   Count,\r
+  int                   BaseOffset,\r
+  int                   Indent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  OutFptr     - GC_TODO: add argument description\r
+  Buffer      - GC_TODO: add argument description\r
+  Count       - GC_TODO: add argument description\r
+  BaseOffset  - GC_TODO: add argument description\r
+  Indent      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  int Counter;\r
+\r
+  for (Counter = 0; Counter < Count; Counter++) {\r
+    if ((Counter & 0xF) == 0) {\r
+      if (Counter != 0) {\r
+        fprintf (OutFptr, "\n%*c%08X ", Indent, ' ', Counter);\r
+      } else {\r
+        fprintf (OutFptr, "\n%*c%08X ", Indent, ' ', Counter);\r
+      }\r
+    }\r
+\r
+    fprintf (OutFptr, "%02X ", (unsigned int) (unsigned char) *Buffer);\r
+    Buffer++;\r
+  }\r
+\r
+  fprintf (OutFptr, "\n");\r
+}\r
+\r
+void\r
+GuidToString (\r
+  EFI_GUID   *Guid,\r
+  char       *Str\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a pointer to a GUID, sprint the value into a string\r
+  \r
+Arguments:\r
+\r
+  Guid   - pointer to input GUID\r
+  Str    - pointer to outgoing printed GUID value\r
+\r
+Returns:\r
+  NA\r
+  \r
+--*/\r
+{\r
+  sprintf (\r
+    Str,\r
+    "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",\r
+    Guid->Data1,\r
+    Guid->Data2,\r
+    Guid->Data3,\r
+    Guid->Data4[0],\r
+    Guid->Data4[1],\r
+    Guid->Data4[2],\r
+    Guid->Data4[3],\r
+    Guid->Data4[4],\r
+    Guid->Data4[5],\r
+    Guid->Data4[6],\r
+    Guid->Data4[7]\r
+    );\r
+}\r
+\r
+int\r
+FindFilesCallback (\r
+  char *FoundFileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Callback function used to get files matching a file mask. This\r
+  function is called when the command-line arguments to this utility\r
+  are parsed and the user specified "-s Path FileMask" to process\r
+  all HII export files in Path and its subdirectories that match\r
+  FileMask.\r
+  \r
+Arguments:\r
+\r
+  FoundFileName - name of file found.\r
+\r
+Returns:\r
+  non-zero    - caller should halt processing\r
+  zero        - no problems while processing FoundFileName\r
+  \r
+--*/\r
+{\r
+  FILE_NAME_LIST  *FileName;\r
+\r
+  FILE_NAME_LIST  *TempFileName;\r
+\r
+  FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));\r
+  if (FileName == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));\r
+  strcpy (FileName->FileName, FoundFileName);\r
+  if (mGlobals.HiiExportFileNames == NULL) {\r
+    mGlobals.HiiExportFileNames = FileName;\r
+  } else {\r
+    //\r
+    // Add to the end of the list\r
+    //\r
+    for (TempFileName = mGlobals.HiiExportFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)\r
+      ;\r
+    TempFileName->Next = FileName;\r
+  }\r
+\r
+  return 0;\r
+}\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the command line arguments\r
+  \r
+Arguments:\r
+\r
+  As per standard C main()\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+  \r
+--*/\r
+// GC_TODO:    Argc - add argument and description to function comment\r
+// GC_TODO:    ] - add argument and description to function comment\r
+{\r
+  FILE_NAME_LIST      *FileName;\r
+\r
+  FILE_NAME_LIST      *TempFileName;\r
+  FILE                *InFptr;\r
+  EFI_HII_PACK_HEADER PackHeader;\r
+\r
+  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+  //\r
+  // First arg must be one of create, merge, defaults, or dump\r
+  //\r
+  if (_stricmp (Argv[0], "create") == 0) {\r
+    mGlobals.Mode = MODE_CREATE_HII_EXPORT;\r
+  } else if (_stricmp (Argv[0], "merge") == 0) {\r
+    mGlobals.Mode = MODE_MERGE_HII_EXPORTS;\r
+  } else if (_stricmp (Argv[0], "defaults") == 0) {\r
+    mGlobals.Mode = MODE_EMIT_DEFAULTS;\r
+  } else if (_stricmp (Argv[0], "dump") == 0) {\r
+    mGlobals.Mode = MODE_DUMP_HII_EXPORT;\r
+  } else if (strcmp (Argv[0], "-?") == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  } else {\r
+    Error (NULL, 0, 0, Argv[0], "unrecognized mode");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  Argv++;\r
+  Argc--;\r
+  //\r
+  // Process until no more args.\r
+  //\r
+  while (Argc > 0) {\r
+    if (_stricmp (Argv[0], "-o") == 0) {\r
+      //\r
+      // -o option to specify the output file\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output file name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if (mGlobals.OutputFileName[0] == 0) {\r
+        mGlobals.OutputFileName[MAX_PATH - 1] = 0;\r
+        strncpy (mGlobals.OutputFileName, Argv[1], MAX_PATH - 1);\r
+      } else {\r
+        Error (UTILITY_NAME, 0, 0, Argv[1], "-o option already specified with '%s'", mGlobals.OutputFileName);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argv++;\r
+      Argc--;\r
+    } else if (_stricmp (Argv[0], "-mfg") == 0) {\r
+      mGlobals.MfgFlag = 1;\r
+    } else if (_stricmp (Argv[0], "-g") == 0) {\r
+      //\r
+      // -g option to specify the guid\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing GUID");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      StringToGuid (Argv[1], &mGlobals.Guid);\r
+      mGlobals.GuidSpecified = 1;\r
+      Argv++;\r
+      Argc--;\r
+    } else if (_stricmp (Argv[0], "-v") == 0) {\r
+      mGlobals.Verbose = 1;\r
+    } else if (_stricmp (Argv[0], "-p") == 0) {\r
+      //\r
+      // -p option to specify an input pack file. Only valid for 'create' mode\r
+      //\r
+      if (mGlobals.Mode != MODE_CREATE_HII_EXPORT) {\r
+        Error (NULL, 0, 0, Argv[0], "option only valid in 'create' mode");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing pack file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Consume arguments until next -arg or end\r
+      //\r
+      do {\r
+        Argv++;\r
+        Argc--;\r
+        //\r
+        // Open the file, read the pack header, and figure out what type of\r
+        // HII pack it is.\r
+        //\r
+        if ((InFptr = fopen (Argv[0], "rb")) == NULL) {\r
+          Error (NULL, 0, 0, Argv[0], "failed to open input HII pack file for reading");\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        if (fread (&PackHeader, sizeof (EFI_HII_PACK_HEADER), 1, InFptr) != 1) {\r
+          Error (NULL, 0, 0, Argv[0], "failed to read pack header from input HII pack file");\r
+          fclose (InFptr);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        fclose (InFptr);\r
+        if ((PackHeader.Type != EFI_HII_STRING) &&\r
+            (PackHeader.Type != EFI_HII_IFR) &&\r
+            (PackHeader.Type != EFI_HII_VARIABLE)\r
+            ) {\r
+          Error (NULL, 0, 0, Argv[0], "unsupported HII pack type 0x%X", (unsigned int) PackHeader.Type);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Add this file name to our list of pack files\r
+        //\r
+        FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));\r
+        if (FileName == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));\r
+        FileName->Tag = (int) PackHeader.Type;\r
+        strcpy (FileName->FileName, Argv[0]);\r
+        if (mGlobals.PackFileNames == NULL) {\r
+          mGlobals.PackFileNames = FileName;\r
+        } else {\r
+          //\r
+          // Add to the end of the list\r
+          //\r
+          for (TempFileName = mGlobals.PackFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)\r
+            ;\r
+          TempFileName->Next = FileName;\r
+        }\r
+      } while ((Argc > 1) && (Argv[1][0] != '-'));\r
+    } else if (_stricmp (Argv[0], "-noemptyvarpacks") == 0) {\r
+      mGlobals.NoEmptyVarPacks = 1;\r
+    } else if (_stricmp (Argv[0], "-novarpacks") == 0) {\r
+      mGlobals.NoVarPacks = 1;\r
+    } else if (_stricmp (Argv[0], "-x") == 0) {\r
+      //\r
+      // -x option to specify an input HII export file name. Not valid for 'create' mode\r
+      //\r
+      if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {\r
+        Error (NULL, 0, 0, Argv[0], "option is not valid in 'create' mode");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing HII export input file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Consume arguments until next -arg or end\r
+      //\r
+      do {\r
+        Argv++;\r
+        Argc--;\r
+        //\r
+        // Add this file name to our list of export files\r
+        //\r
+        FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));\r
+        if (FileName == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));\r
+        strcpy (FileName->FileName, Argv[0]);\r
+        if (mGlobals.HiiExportFileNames == NULL) {\r
+          mGlobals.HiiExportFileNames = FileName;\r
+        } else {\r
+          //\r
+          // Add to the end of the list\r
+          //\r
+          for (TempFileName = mGlobals.HiiExportFileNames;\r
+               TempFileName->Next != NULL;\r
+               TempFileName = TempFileName->Next\r
+              )\r
+            ;\r
+          TempFileName->Next = FileName;\r
+        }\r
+      } while ((Argc > 1) && (Argv[1][0] != '-'));\r
+    } else if (_stricmp (Argv[0], "-dumpstrings") == 0) {\r
+      mGlobals.DumpStrings = 1;\r
+    } else if (_stricmp (Argv[0], "-s") == 0) {\r
+      //\r
+      // -s option to specify input HII export files using a path and file mask.\r
+      // Only valid in merge mode\r
+      //\r
+      if (mGlobals.Mode != MODE_MERGE_HII_EXPORTS) {\r
+        Error (NULL, 0, 0, Argv[0], "option only valid in 'merge' mode");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing root directory name");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if ((Argc <= 2) || (Argv[2][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing file mask");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Call our function to process the directory and file mask. If\r
+      // the directory does not start with c:\, then prepend cwd to it.\r
+      //\r
+      if (FindFiles (Argv[1], Argv[2], FindFilesCallback)) {\r
+        Error (NULL, 0, 0, "failed to process matching files", "%s\\%s", Argv[1], Argv[2]);\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      Argv += 2;\r
+      Argc -= 2;\r
+    } else if (_stricmp (Argv[0], "-p") == 0) {\r
+      //\r
+      // -p option to specify an input pack file. Only valid for 'create' mode\r
+      //\r
+      if (mGlobals.Mode != MODE_CREATE_HII_EXPORT) {\r
+        Error (NULL, 0, 0, Argv[0], "option only valid in 'create' mode");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing pack file name");\r
+        return STATUS_ERROR;\r
+      }\r
+      //\r
+      // Consume arguments until next -arg or end\r
+      //\r
+      do {\r
+        Argv++;\r
+        Argc--;\r
+        //\r
+        // Open the file, read the pack header, and figure out what type of\r
+        // HII pack it is.\r
+        //\r
+        if ((InFptr = fopen (Argv[0], "rb")) == NULL) {\r
+          Error (NULL, 0, 0, Argv[0], "failed to open input HII pack file for reading");\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        if (fread (&PackHeader, sizeof (EFI_HII_PACK_HEADER), 1, InFptr) != 1) {\r
+          Error (NULL, 0, 0, Argv[0], "failed to read pack header from input HII pack file");\r
+          fclose (InFptr);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        fclose (InFptr);\r
+        if ((PackHeader.Type != EFI_HII_STRING) &&\r
+            (PackHeader.Type != EFI_HII_IFR) &&\r
+            (PackHeader.Type != EFI_HII_VARIABLE)\r
+            ) {\r
+          Error (NULL, 0, 0, Argv[0], "unsupported HII pack type 0x%X", (unsigned int) PackHeader.Type);\r
+          return STATUS_ERROR;\r
+        }\r
+        //\r
+        // Add this file name to our list of pack files\r
+        //\r
+        FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));\r
+        if (FileName == NULL) {\r
+          Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));\r
+        FileName->Tag = (int) PackHeader.Type;\r
+        strcpy (FileName->FileName, Argv[0]);\r
+        if (mGlobals.PackFileNames == NULL) {\r
+          mGlobals.PackFileNames = FileName;\r
+        } else {\r
+          //\r
+          // Add to the end of the list\r
+          //\r
+          for (TempFileName = mGlobals.PackFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)\r
+            ;\r
+          TempFileName->Next = FileName;\r
+        }\r
+      } while ((Argc > 1) && (Argv[1][0] != '-'));\r
+    } else {\r
+      Error (NULL, 0, 0, Argv[0], "unrecognized option");\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Argv++;\r
+    Argc--;\r
+  }\r
+  //\r
+  // All modes except 'defaults' requires an output file name\r
+  //\r
+  if (mGlobals.Mode != MODE_EMIT_DEFAULTS) {\r
+    if (mGlobals.OutputFileName[0] == 0) {\r
+      Error (NULL, 0, 0, "must specify '-o OutputFileName'", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // If merging, then you have to specify at least one HII export files.\r
+    // We support specifying only one file in case you want to take an export file\r
+    // and emit a copy with different (for example, manufacturing) defaults.\r
+    //\r
+    if (mGlobals.Mode == MODE_MERGE_HII_EXPORTS) {\r
+      if (mGlobals.HiiExportFileNames == NULL) {\r
+        Error (NULL, 0, 0, "must specify at least one HII export file in 'merge' mode", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+    } else if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {\r
+      //\r
+      // Must have specified at least one HII pack file\r
+      //\r
+      if (mGlobals.PackFileNames == NULL) {\r
+        Error (NULL, 0, 0, "must specify at least one input HII pack file in 'create' mode", NULL);\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+  } else {\r
+    //\r
+    // Must have specified an input HII export file name\r
+    //\r
+    if (mGlobals.HiiExportFileNames == NULL) {\r
+      Error (NULL, 0, 0, "must specify at least one '-x HiiExportFileName'", NULL);\r
+      return STATUS_ERROR;\r
+    }\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int          Index;\r
+  const char   *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Create/Dump HII Database Files Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME " [MODE] [OPTION]",\r
+    "Modes:",\r
+    "  create     create an HII export file from one or more HII pack files",\r
+    "  merge      merge two or more HII export files into one HII export file",\r
+    "  defaults   emit variable defaults from an input HII export file",\r
+    "  dump       ASCII dump the contents of an HII export file",\r
+    "Options for all modes:",\r
+    "  -o FileName write output to FileName",\r
+    "  -mfg        use manufacturing defaults from IFR rather than standard defaults",\r
+    "  -g GUID     use GUID for a package GUID in the data tables where applicable",\r
+    "  -v          verbose operation",\r
+    "Options for 'create' mode:",\r
+    "  -p PackFileName(s)  include contents of HII pack file PackFileName",\r
+    "                      in the output file",\r
+    "  -novarpacks         don't emit variable packs to the output file",\r
+    "Options for 'merge' mode:",\r
+    "  -x HiiExportFileName(s)  include contents of HII export file",\r
+    "                           HiiExportFileName in the output file",\r
+    "  -s Path FileMask         include all matching HII export files in Path",\r
+    "                           and its subdirectories in the output file.",\r
+    "                           If Path does not begin with the form C:\\, then",\r
+    "                           it is assumed to be relative to the current working",\r
+    "                           directory. FileMask may contain wildcard characters.",\r
+    "Options for 'defaults' mode:",\r
+    "  -x HiiExportFileName     emit defaults from all variables referenced",\r
+    "                           in input file HiiExportFileName",\r
+    "  -noemptyvarpacks         don't emit variable packs for 0-length variables",\r
+    "Options for 'dump' mode:",\r
+    "  -x HiiExportFileName     dump contents of input file HiiExportFileName",\r
+    "  -dumpstrings             dump string data",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
new file mode 100644 (file)
index 0000000..e9fa66b
--- /dev/null
@@ -0,0 +1,63 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HiiPack.h\r
+\r
+Abstract:\r
+\r
+  Common defines and prototypes for the HII pack tool.\r
+  \r
+--*/\r
+\r
+#ifndef _HII_PACK_H_\r
+#define _HII_PACK_H_\r
+\r
+#define DEFAULT_VARIABLE_NAME_L L"Setup"\r
+#define DEFAULT_VARIABLE_NAME   "Setup"\r
+\r
+#define MAX_VARIABLE_NAME       256\r
+#define FIRST_HII_PACK_HANDLE   1\r
+\r
+typedef\r
+int\r
+(*FIND_FILE_CALLBACK) (\r
+  char *FileName\r
+  );\r
+\r
+extern\r
+int\r
+FindFiles (\r
+  char                *RootDirectory,\r
+  char                *FileMask,\r
+  FIND_FILE_CALLBACK  Callback\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  RootDirectory - GC_TODO: add argument description\r
+  FileMask      - GC_TODO: add argument description\r
+  Callback      - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif // #ifndef _HII_PACK_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
new file mode 100644 (file)
index 0000000..e69af5c
--- /dev/null
@@ -0,0 +1,2533 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  IfrParse.c  \r
+\r
+Abstract:\r
+\r
+  Routines for parsing and managing HII IFR packs.\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "EfiInternalFormRepresentation.h"\r
+#include "Hii.h"\r
+#include "IfrParse.h"\r
+#include "HiiPack.h"\r
+\r
+typedef struct _VARIABLE_STORE_ENTRY {\r
+  struct _VARIABLE_STORE_ENTRY  *Next;\r
+  CHAR8                         VarName[MAX_VARIABLE_NAME];\r
+  char                          *VarBuffer;\r
+  int                           VarBufferSize;\r
+  EFI_HII_VARIABLE_PACK         *VarPack;\r
+  int                           VarPackSize;\r
+} VARIABLE_STORE_ENTRY;\r
+\r
+typedef STATUS (*IFR_PARSE_FUNCTION) (IFR_PARSE_CONTEXT * Context);\r
+\r
+typedef struct {\r
+  INT8                *Name;\r
+  INT32               Size;\r
+  IFR_PARSE_FUNCTION  Parse;\r
+} IFR_PARSE_TABLE_ENTRY;\r
+\r
+static\r
+STATUS\r
+IfrParse01 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse02 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse03 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse05 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse06 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse07 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse08 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse09 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse0A (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse0B (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse0C (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse0D (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse0E (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse0F (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse10 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse11 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse12 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse13 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse14 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse15 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse16 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse17 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse18 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse19 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse1A (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse1B (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse1C (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse1D (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse1E (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse1F (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse20 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse21 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse22 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse23 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse24 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse25 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse26 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse27 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse28 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse29 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+static\r
+STATUS\r
+IfrParse2A (\r
+  IFR_PARSE_CONTEXT *Context\r
+  );\r
+\r
+static const IFR_PARSE_TABLE_ENTRY  mIfrParseTable[] = {\r
+  {\r
+    0,\r
+    0,\r
+    NULL\r
+  },  // invalid\r
+  {\r
+    "EFI_IFR_FORM",\r
+    sizeof (EFI_IFR_FORM),\r
+    IfrParse01\r
+  },\r
+  {\r
+    "EFI_IFR_SUBTITLE",\r
+    sizeof (EFI_IFR_SUBTITLE),\r
+    IfrParse02\r
+  },\r
+  {\r
+    "EFI_IFR_TEXT",\r
+    -6,\r
+    IfrParse03\r
+  },  // sizeof (EFI_IFR_TEXT) },\r
+  {\r
+    "unused 0x04 opcode",\r
+    0,\r
+    NULL\r
+  },  // EFI_IFR_GRAPHIC_OP\r
+  {\r
+    "EFI_IFR_ONE_OF",\r
+    sizeof (EFI_IFR_ONE_OF),\r
+    IfrParse05\r
+  },\r
+  {\r
+    "EFI_IFR_CHECK_BOX",\r
+    sizeof (EFI_IFR_CHECK_BOX),\r
+    IfrParse06\r
+  },\r
+  {\r
+    "EFI_IFR_NUMERIC",\r
+    sizeof (EFI_IFR_NUMERIC),\r
+    IfrParse07\r
+  },\r
+  {\r
+    "EFI_IFR_PASSWORD",\r
+    sizeof (EFI_IFR_PASSWORD),\r
+    IfrParse08\r
+  },\r
+  {\r
+    "EFI_IFR_ONE_OF_OPTION",\r
+    sizeof (EFI_IFR_ONE_OF_OPTION),\r
+    IfrParse09\r
+  },\r
+  {\r
+    "EFI_IFR_SUPPRESS",\r
+    sizeof (EFI_IFR_SUPPRESS),\r
+    IfrParse0A\r
+  },\r
+  {\r
+    "EFI_IFR_END_FORM",\r
+    sizeof (EFI_IFR_END_FORM),\r
+    IfrParse0B\r
+  },\r
+  {\r
+    "EFI_IFR_HIDDEN",\r
+    sizeof (EFI_IFR_HIDDEN),\r
+    IfrParse0C\r
+  },\r
+  {\r
+    "EFI_IFR_END_FORM_SET",\r
+    sizeof (EFI_IFR_END_FORM_SET),\r
+    IfrParse0D\r
+  },\r
+  {\r
+    "EFI_IFR_FORM_SET",\r
+    sizeof (EFI_IFR_FORM_SET),\r
+    IfrParse0E\r
+  },\r
+  {\r
+    "EFI_IFR_REF",\r
+    sizeof (EFI_IFR_REF),\r
+    IfrParse0F\r
+  },\r
+  {\r
+    "EFI_IFR_END_ONE_OF",\r
+    sizeof (EFI_IFR_END_ONE_OF),\r
+    IfrParse10\r
+  },\r
+  {\r
+    "EFI_IFR_INCONSISTENT",\r
+    sizeof (EFI_IFR_INCONSISTENT),\r
+    IfrParse11\r
+  },\r
+  {\r
+    "EFI_IFR_EQ_ID_VAL",\r
+    sizeof (EFI_IFR_EQ_ID_VAL),\r
+    IfrParse12\r
+  },\r
+  {\r
+    "EFI_IFR_EQ_ID_ID",\r
+    sizeof (EFI_IFR_EQ_ID_ID),\r
+    IfrParse13\r
+  },\r
+  {\r
+    "EFI_IFR_EQ_ID_LIST",\r
+    -(int) (sizeof (EFI_IFR_EQ_ID_LIST)),\r
+    IfrParse14\r
+  },\r
+  {\r
+    "EFI_IFR_AND",\r
+    sizeof (EFI_IFR_AND),\r
+    IfrParse15\r
+  },\r
+  {\r
+    "EFI_IFR_OR",\r
+    sizeof (EFI_IFR_OR),\r
+    IfrParse16\r
+  },\r
+  {\r
+    "EFI_IFR_NOT",\r
+    sizeof (EFI_IFR_NOT),\r
+    IfrParse17\r
+  },\r
+  {\r
+    "EFI_IFR_END_IF",\r
+    sizeof (EFI_IFR_END_IF),\r
+    IfrParse18\r
+  },\r
+  {\r
+    "EFI_IFR_GRAYOUT",\r
+    sizeof (EFI_IFR_GRAYOUT),\r
+    IfrParse19\r
+  },\r
+  {\r
+    "EFI_IFR_DATE",\r
+    sizeof (EFI_IFR_DATE) / 3,\r
+    IfrParse1A\r
+  },\r
+  {\r
+    "EFI_IFR_TIME",\r
+    sizeof (EFI_IFR_TIME) / 3,\r
+    IfrParse1B\r
+  },\r
+  {\r
+    "EFI_IFR_STRING",\r
+    sizeof (EFI_IFR_STRING),\r
+    IfrParse1C\r
+  },\r
+  {\r
+    "EFI_IFR_LABEL",\r
+    sizeof (EFI_IFR_LABEL),\r
+    IfrParse1D\r
+  },\r
+  {\r
+    "EFI_IFR_SAVE_DEFAULTS",\r
+    sizeof (EFI_IFR_SAVE_DEFAULTS),\r
+    IfrParse1E\r
+  },\r
+  {\r
+    "EFI_IFR_RESTORE_DEFAULTS",\r
+    sizeof (EFI_IFR_RESTORE_DEFAULTS),\r
+    IfrParse1F\r
+  },\r
+  {\r
+    "EFI_IFR_BANNER",\r
+    sizeof (EFI_IFR_BANNER),\r
+    IfrParse20\r
+  },\r
+  {\r
+    "EFI_IFR_INVENTORY",\r
+    sizeof (EFI_IFR_INVENTORY),\r
+    IfrParse21\r
+  },\r
+  {\r
+    "EFI_IFR_EQ_VAR_VAL_OP",\r
+    sizeof (EFI_IFR_EQ_VAR_VAL),\r
+    IfrParse22\r
+  },\r
+  {\r
+    "EFI_IFR_ORDERED_LIST_OP",\r
+    sizeof (EFI_IFR_ORDERED_LIST),\r
+    IfrParse23\r
+  },\r
+  {\r
+    "EFI_IFR_VARSTORE_OP",\r
+    -(int) (sizeof (EFI_IFR_VARSTORE)),\r
+    IfrParse24\r
+  },\r
+  {\r
+    "EFI_IFR_VARSTORE_SELECT_OP",\r
+    sizeof (EFI_IFR_VARSTORE_SELECT),\r
+    IfrParse25\r
+  },\r
+  {\r
+    "EFI_IFR_VARSTORE_SELECT_PAIR_OP",\r
+    sizeof (EFI_IFR_VARSTORE_SELECT_PAIR),\r
+    IfrParse26\r
+  },\r
+  {\r
+    "EFI_IFR_TRUE",\r
+    sizeof (EFI_IFR_TRUE),\r
+    IfrParse27\r
+  },\r
+  {\r
+    "EFI_IFR_FALSE",\r
+    sizeof (EFI_IFR_FALSE),\r
+    IfrParse28\r
+  },\r
+  {\r
+    "EFI_IFR_GT",\r
+    sizeof (EFI_IFR_GT),\r
+    IfrParse29\r
+  },\r
+  {\r
+    "EFI_IFR_GE",\r
+    sizeof (EFI_IFR_GE),\r
+    IfrParse2A\r
+  },\r
+};\r
+#define PARSE_TABLE_ENTRIES (sizeof (mIfrParseTable) / sizeof (mIfrParseTable[0]))\r
+\r
+static\r
+STATUS\r
+GetVarStoreInfo (\r
+  IFR_PARSE_CONTEXT   *Context,\r
+  UINT16              VarId,\r
+  EFI_GUID            **VarStoreGuid,\r
+  char                **VarStoreName\r
+  );\r
+\r
+static\r
+void\r
+FreeVarStores (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+CreateVarStore (\r
+  EFI_GUID *VarGuid,\r
+  CHAR8    *VarName,\r
+  int      VarStoreSize\r
+  );\r
+\r
+static\r
+STATUS\r
+SetDefaults (\r
+  IFR_PARSE_CONTEXT *Context,\r
+  UINT32            MfgDefaults\r
+  );\r
+\r
+//\r
+// Globals\r
+//\r
+static IFR_PARSE_CONTEXT            *mParseContext    = NULL;\r
+static VARIABLE_STORE_ENTRY         *mVariableStores  = NULL;\r
+static int                          BreakOnOpcodeTag  = 0;\r
+static int                          OpcodeTag         = 1;\r
+\r
+/*****************************************************************************/\r
+STATUS\r
+IfrParseCheck (\r
+  char    *Buffer,\r
+  long    BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Check a buffer to ensure that is is parseable IFR\r
+  \r
+Arguments:\r
+\r
+  Buffer      - pointer to raw IFR bytes\r
+  BufferSize  - size of IFR pointed to by Buffer\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      if successful\r
+  STATUS_ERROR        otherwise\r
+  \r
+--*/\r
+{\r
+  char              *Start;\r
+\r
+  char              *End;\r
+\r
+  char              *Pos;\r
+  EFI_IFR_OP_HEADER *OpHeader;\r
+  char              *FileName;\r
+  FileName = "";\r
+  //\r
+  // Walk the list of IFR statements in the IFR pack\r
+  //\r
+  Start = Buffer;\r
+  Pos   = Buffer;\r
+  End   = Start + BufferSize;\r
+  while ((Pos >= Start) && (Pos < End)) {\r
+    OpHeader = (EFI_IFR_OP_HEADER *) Pos;\r
+    //\r
+    // Check range on size\r
+    //\r
+    if (Pos + OpHeader->Length > End) {\r
+      Error (NULL, 0, 0, FileName, "invalid IFR opcode size at offset 0x%X", (int) Pos - (int) Start);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    if (OpHeader->Length == 0) {\r
+      Error (NULL, 0, 0, FileName, "IFR opcode size=0 at offset 0x%X", (int) Pos - (int) Start);\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // See if it's the END_FORMSET opcode\r
+    //\r
+    if (OpHeader->OpCode == EFI_IFR_END_FORM_SET_OP) {\r
+      break;\r
+    }\r
+    //\r
+    // Advance to next IFR statement/opcode\r
+    //\r
+    Pos += OpHeader->Length;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+IfrParseInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Initialize this module for IFR pack parsing\r
+  \r
+Arguments:\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      always\r
+  \r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+IfrParseEnd (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free up memory allocated during IFR pack parsing done by this module\r
+  \r
+Arguments:\r
+  None\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      always\r
+  \r
+--*/\r
+{\r
+  IFR_PARSE_CONTEXT *NextContext;\r
+  IFR_PARSE_ENTRY   *NextEntry;\r
+  //\r
+  // Free up the memory from our parse contexts\r
+  //\r
+  while (mParseContext != NULL) {\r
+    while (mParseContext->Ifr != NULL) {\r
+      NextEntry = mParseContext->Ifr->Next;\r
+      //\r
+      // We pointed directly into the user buffer, rather than make\r
+      // a copy, so don't free up the bytes.\r
+      //\r
+      free (mParseContext->Ifr);\r
+      mParseContext->Ifr = NextEntry;\r
+    }\r
+\r
+    NextContext = mParseContext->Next;\r
+    free (mParseContext->PackHeader);\r
+    free (mParseContext);\r
+    mParseContext = NextContext;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+FreeVarStores (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  VARIABLE_STORE_ENTRY  *NextVarStore;\r
+  //\r
+  // Free up memory from our variable stores\r
+  //\r
+  while (mVariableStores != NULL) {\r
+    if (mVariableStores->VarPack != NULL) {\r
+      free (mVariableStores->VarPack);\r
+    }\r
+\r
+    NextVarStore = mVariableStores->Next;\r
+    free (mVariableStores);\r
+    mVariableStores = NextVarStore;\r
+  }\r
+}\r
+\r
+/******************************************************************************\r
+  FUNCTION: IfrParsePack() \r
+   \r
+  DESCRIPTION:  Given a pointer to an IFR pack, parse it to create a linked\r
+    list of opcodes and relevant data required for later dumping.\r
+\r
+\r
+*******************************************************************************/\r
+STATUS\r
+IfrParsePack (\r
+  int               Handle,\r
+  EFI_HII_IFR_PACK  *PackHeader,\r
+  EFI_GUID          *PackageGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a pointer to an IFR pack, parse it to create a linked\r
+  list of opcodes and relevant data required for later dumping.\r
+  \r
+Arguments:\r
+\r
+  Handle          - the handle number associated with this IFR pack. It\r
+                    can be used later to retrieve more info on the particular\r
+                    pack\r
+  PackHeader      - pointer to IFR pack to parse\r
+  PackageGuid     - on input, it comes from the HII data table entry for this pack. \r
+                    On output, we'll return the IFR formset GUID.\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      always\r
+\r
+--*/\r
+{\r
+  EFI_IFR_OP_HEADER *OpHeader;\r
+  IFR_PARSE_CONTEXT *Context;\r
+  IFR_PARSE_CONTEXT *TempContext;\r
+  IFR_PARSE_ENTRY   *IfrEntry;\r
+  //\r
+  // Initialize our context\r
+  //\r
+  Context = (IFR_PARSE_CONTEXT *) malloc (sizeof (IFR_PARSE_CONTEXT));\r
+  if (Context == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((void *) Context, 0, sizeof (IFR_PARSE_CONTEXT));\r
+  //\r
+  // Cache a copy of the input pack so the caller can free their copy\r
+  //\r
+  Context->PackHeader = (EFI_HII_IFR_PACK *) malloc (PackHeader->Header.Length);\r
+  if (Context->PackHeader == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    free (Context);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memcpy (Context->PackHeader, PackHeader, PackHeader->Header.Length);\r
+  Context->IfrBufferStart = (char *) (Context->PackHeader + 1);\r
+  Context->CurrentPos     = Context->IfrBufferStart;\r
+  Context->IfrBufferLen   = PackHeader->Header.Length - sizeof (EFI_HII_IFR_PACK);\r
+  Context->Handle         = Handle;\r
+  Context->FormsetGuid    = &Context->NullGuid;\r
+  Context->PackageGuid    = *PackageGuid;\r
+  //\r
+  // Add it to the end of our list\r
+  //\r
+  if (mParseContext == NULL) {\r
+    mParseContext = Context;\r
+  } else {\r
+    TempContext = mParseContext;\r
+    while (TempContext->Next != NULL) {\r
+      TempContext = TempContext->Next;\r
+    }\r
+\r
+    TempContext->Next = Context;\r
+  }\r
+  //\r
+  // Walk the opcodes in the pack\r
+  //\r
+  while\r
+  (\r
+    (Context->CurrentPos >= Context->IfrBufferStart) &&\r
+    (Context->CurrentPos < Context->IfrBufferStart + Context->IfrBufferLen)\r
+  ) {\r
+    OpHeader = (EFI_IFR_OP_HEADER *) Context->CurrentPos;\r
+    //\r
+    // Allocate a new IFR entry to put in our linked list, then\r
+    // point directly to the caller's raw data.\r
+    //\r
+    IfrEntry = (IFR_PARSE_ENTRY *) malloc (sizeof (IFR_PARSE_ENTRY));\r
+    if (IfrEntry == NULL) {\r
+      Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+      free (Context->PackHeader);\r
+      free (Context);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    memset ((void *) IfrEntry, 0, sizeof (IFR_PARSE_ENTRY));\r
+    IfrEntry->Tag = ++OpcodeTag;\r
+    if (OpcodeTag == BreakOnOpcodeTag) {\r
+      EFI_BREAKPOINT ();\r
+    }\r
+\r
+    IfrEntry->RawIfrHeader = (EFI_IFR_OP_HEADER *) (Context->CurrentPos);\r
+    //\r
+    // Add this entry to our linked list. If it's not the first, then\r
+    // forward the variable store settings from the previous entry.\r
+    //\r
+    if (Context->LastIfr != NULL) {\r
+      IfrEntry->VarStoreGuid1 = Context->LastIfr->VarStoreGuid1;\r
+      IfrEntry->VarStoreName1 = Context->LastIfr->VarStoreName1;\r
+      IfrEntry->VarStoreGuid2 = Context->LastIfr->VarStoreGuid2;\r
+      IfrEntry->VarStoreName2 = Context->LastIfr->VarStoreName2;\r
+      Context->LastIfr->Next  = IfrEntry;\r
+    } else {\r
+      Context->Ifr = IfrEntry;\r
+    }\r
+\r
+    Context->LastIfr = IfrEntry;\r
+    //\r
+    // Switch on the opcode to parse it\r
+    //\r
+    if (OpHeader->OpCode < PARSE_TABLE_ENTRIES) {\r
+      if (mIfrParseTable[OpHeader->OpCode].Parse != NULL) {\r
+        mIfrParseTable[OpHeader->OpCode].Parse (Context);\r
+      }\r
+    } else {\r
+      Error (\r
+        NULL,\r
+        0,\r
+        0,\r
+        "invalid opcode found in IFR",\r
+        "offset=0x%X opcode=0x%02X",\r
+        (int) OpHeader - (int) Context->PackHeader,\r
+        (int) OpHeader->OpCode\r
+        );\r
+      free (IfrEntry);\r
+      free (Context->PackHeader);\r
+      free (Context);\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // If it's the END_FORMSET opcode, then we're done\r
+    //\r
+    if (OpHeader->OpCode == EFI_IFR_END_FORM_SET_OP) {\r
+      break;\r
+    }\r
+    //\r
+    // Advance to next IFR statement/opcode\r
+    //\r
+    if (OpHeader->Length == 0) {\r
+      Error (NULL, 0, 0, "0-length IFR opcode encountered", NULL);\r
+      free (IfrEntry);\r
+      free (Context->PackHeader);\r
+      free (Context);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    Context->CurrentPos += OpHeader->Length;\r
+  }\r
+  //\r
+  // Return the form GUID.\r
+  //\r
+  *PackageGuid = *Context->FormsetGuid;  \r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/******************************************************************************\r
+  FUNCTION:  GetVarStoreInfo()\r
+   \r
+  DESCRIPTION:  IFR contains VARSTORE opcodes to specify where variable data \r
+    for following opcodes is supposed to be stored. One VARSTORE statement\r
+    allows you to specify the variable store GUID and a key, and another\r
+    VARSTORE (select) allows you to specify the key of a VARSTORE statement. \r
+    Given the key from a VARSTORE_SELECT statement, go find the corresponding\r
+    VARSTORE statement with a matching key and return the varstore GUID and \r
+    name. If key == 0, then the variable store is FormsetGuid."Setup"\r
+*******************************************************************************/\r
+static\r
+STATUS\r
+GetVarStoreInfo (\r
+  IFR_PARSE_CONTEXT     *Context,\r
+  UINT16                VarId,\r
+  EFI_GUID              **VarStoreGuid,\r
+  char                  **VarStoreName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get variable store information from an IFR pack for a given variable store ID.\r
+  \r
+Arguments:\r
+\r
+  Context       - pointer to IFR parse context\r
+  VarId         - variable store ID referenced by IFR being parsed\r
+  VarStoreGuid  - outgoing GUID of the variable store corresponding to VarId\r
+  VarStoreName  - outgoing variable name of variable store corresponding to VarId\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      - variable store with matching VarId found, and outoing GUID/Name are valid\r
+  STATUS_ERROR        - otherwise\r
+\r
+--*/\r
+{\r
+  IFR_PARSE_ENTRY   *Ptr;\r
+  EFI_IFR_VARSTORE  *VarStore;\r
+  if (Context == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Walk the entire IFR form and find a variable store opcode that\r
+  // has a matching variable store ID.\r
+  //\r
+  for (Ptr = Context->Ifr; Ptr != NULL; Ptr = Ptr->Next) {\r
+    if (Ptr->RawIfrHeader->OpCode == EFI_IFR_FORM_SET_OP) {\r
+      if (VarId == 0) {\r
+        *VarStoreGuid = &((EFI_IFR_FORM_SET *) (Ptr->RawIfrHeader))->Guid;\r
+        *VarStoreName = DEFAULT_VARIABLE_NAME;\r
+        return STATUS_SUCCESS;\r
+      }\r
+    } else if (Ptr->RawIfrHeader->OpCode == EFI_IFR_VARSTORE_OP) {\r
+      //\r
+      // See if it's a variable ID match\r
+      //\r
+      VarStore = (EFI_IFR_VARSTORE *) Ptr->RawIfrHeader;\r
+      if (VarStore->VarId == VarId) {\r
+        *VarStoreGuid = &VarStore->Guid;\r
+        *VarStoreName = (char *) (VarStore + 1);\r
+        return STATUS_SUCCESS;\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+STATUS\r
+IfrSetDefaults (\r
+  int MfgDefaults\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Go through all the IFR forms we've parsed so far and create and set variable\r
+  defaults.\r
+  \r
+Arguments:\r
+\r
+  MfgDefaults   - non-zero if manufacturing defaults are desired\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      - always\r
+\r
+--*/\r
+{\r
+  IFR_PARSE_CONTEXT *Context;\r
+  //\r
+  // First free up any variable stores we've created so far.\r
+  //\r
+  FreeVarStores ();\r
+  for (Context = mParseContext; Context != NULL; Context = Context->Next) {\r
+    //\r
+    // Call our internal function to handle it\r
+    //\r
+    SetDefaults (Context, MfgDefaults);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+\r
+}\r
+\r
+/******************************************************************************/\r
+STATUS\r
+IfrGetIfrPack (\r
+  int               Handle,\r
+  EFI_HII_IFR_PACK  **PackHeader,\r
+  EFI_GUID          *FormsetGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle      - GC_TODO: add argument description\r
+  PackHeader  - GC_TODO: add argument description\r
+  FormsetGuid - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  IFR_PARSE_CONTEXT *Context;\r
+\r
+  for (Context = mParseContext; Context != NULL; Context = Context->Next) {\r
+    if (Context->Handle == Handle) {\r
+      *PackHeader = Context->PackHeader;\r
+      memcpy (FormsetGuid, Context->FormsetGuid, sizeof (EFI_GUID));\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+STATUS\r
+IfrReferencesVarPack (\r
+  int                   IfrHandle,\r
+  EFI_HII_VARIABLE_PACK *VarPack\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given an HII handle number (which corrresponds to a handle number passed \r
+  in to IfrParsePack()), see if the IFR references the specified variable\r
+  pack.\r
+  \r
+Arguments:\r
+\r
+  IfrHandle   - handle number for the IFR pack to check (passed to IfrParsePack())\r
+  VarPack     - variable pack to check to see if the IFR references\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS      if the IFR on the given handle references the variable pack\r
+  STATUS_WARNING      the IFR does not reference the variable pack\r
+  STATUS_ERROR        invalid IFR handle\r
+  \r
+--*/\r
+{\r
+  IFR_PARSE_CONTEXT *Context;\r
+  char              VarName[MAX_VARIABLE_NAME];\r
+  IFR_PARSE_ENTRY   *ParseEntry;\r
+\r
+  for (Context = mParseContext; Context != NULL; Context = Context->Next) {\r
+    if (Context->Handle == IfrHandle) {\r
+      //\r
+      // Create an ASCII version of the variable name, since that's what is\r
+      // referenced in IFR.\r
+      //\r
+      sprintf (VarName, "%S", (CHAR16 *) (VarPack + 1));\r
+      //\r
+      // Walk all the opcodes and see if the IFR references this variable pack\r
+      //\r
+      for (ParseEntry = Context->Ifr; ParseEntry != NULL; ParseEntry = ParseEntry->Next) {\r
+        //\r
+        // Check for Name.Guid match for primary IFR variable store\r
+        //\r
+        if ((strcmp (VarName, ParseEntry->VarStoreName1) == 0) &&\r
+            (memcmp (&VarPack->VariableGuid, ParseEntry->VarStoreGuid1, sizeof (EFI_GUID)) == 0)\r
+            ) {\r
+          return STATUS_SUCCESS;\r
+        }\r
+        //\r
+        // Check for Name.Guid match for secondary IFR variable store\r
+        //\r
+        if ((ParseEntry->VarStoreName2 != NULL) &&\r
+            (strcmp (VarName, ParseEntry->VarStoreName2) == 0) &&\r
+            (memcmp (&VarPack->VariableGuid, ParseEntry->VarStoreGuid2, sizeof (EFI_GUID)) == 0)\r
+            ) {\r
+          return STATUS_SUCCESS;\r
+        }\r
+      }\r
+\r
+      return STATUS_WARNING;\r
+    }\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+STATUS\r
+IfrGetVarPack (\r
+  int                     VarIndex,\r
+  EFI_HII_VARIABLE_PACK   **VarPack\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get the variable defaults. It is expected that the caller\r
+  called IfrSetDefaults() previously to walk all the IFR forms we know about\r
+  and create and initialize default values.\r
+  \r
+Arguments:\r
+\r
+  VarIndex - a 0-based index into all the variable stores we know about\r
+  VarPack  - outgoing pointer to a variable pack\r
+\r
+Returns:\r
+\r
+  STATUS_ERROR    - VarIndex exceeds the number of variable packs we know of\r
+  STATUS_SUCCESS  - otherwise\r
+  \r
+--*/\r
+{\r
+  VARIABLE_STORE_ENTRY  *Entry;\r
+  //\r
+  // Initialize outgoing parameters\r
+  //\r
+  *VarPack = NULL;\r
+  for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {\r
+    if (VarIndex == 0) {\r
+      *VarPack = Entry->VarPack;\r
+      return STATUS_SUCCESS;\r
+    }\r
+\r
+    VarIndex--;\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+static\r
+STATUS\r
+SetVariableValue (\r
+  EFI_GUID    *VarGuid,\r
+  char        *VarName,\r
+  int         VarOffset,\r
+  int         VarSize,\r
+  void        *VarValue\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a variable GUID.Name, offset, size, and value, set the bytes in\r
+  the variable to the provided value.\r
+  \r
+Arguments:\r
+  VarGuid           - GUID of variable to set\r
+  VarName           - name of variable to set\r
+  VarOffset         - byte offset into the variable store \r
+  VarSize           - size of the value in the variable store (in bytes)\r
+  VarValue          - pointer to buffer containing the value to set\r
+\r
+Returns:\r
+\r
+  \r
+--*/\r
+{\r
+  VARIABLE_STORE_ENTRY  *Entry;\r
+  char                  *Src;\r
+  char                  *Dest;\r
+  //\r
+  // Go through our list of variable stores to find the match\r
+  //\r
+  for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {\r
+    if (memcmp (VarGuid, &Entry->VarPack->VariableGuid, sizeof (EFI_GUID)) == 0) {\r
+      if (strcmp (VarName, Entry->VarName) == 0) {\r
+        //\r
+        // Found match -- check offset. If it's beyond the size of the variable store\r
+        // buffer, then return a warning. Note that date-time can be beyond the\r
+        // end of the varstore, which is ok.\r
+        //\r
+        if (VarOffset + VarSize <= Entry->VarBufferSize) {\r
+          //\r
+          // Stuff the data\r
+          //\r
+          Dest  = Entry->VarBuffer + VarOffset;\r
+          Src   = (char *) VarValue;\r
+          while (VarSize > 0) {\r
+            *Dest = *Src;\r
+            Src++;\r
+            Dest++;\r
+            VarSize--;\r
+          }\r
+\r
+          return STATUS_SUCCESS;\r
+        }\r
+\r
+        return STATUS_WARNING;\r
+      }\r
+    }\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+static\r
+STATUS\r
+SetDefaults (\r
+  IFR_PARSE_CONTEXT *Context,\r
+  UINT32            MfgDefaults\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Set variable defaults by walking a single IFR form.\r
+  \r
+Arguments:\r
+  \r
+  Context     - Pointer to the IFR context.\r
+  MfgDefaults - Number of Mfg defaults\r
+\r
+Returns:\r
+\r
+  EFI_INVALID_PARAMETER - arguments to function are invalid\r
+  STATUS_SUCCESS        - function executed successfully\r
+  \r
+--*/\r
+{\r
+  int                   Size;\r
+  int                   CachedVarOffset;\r
+  int                   CachedVarSize;\r
+  int                   OrderedList;\r
+  IFR_PARSE_ENTRY       *SavedParseEntry;\r
+  EFI_IFR_CHECK_BOX     *IfrCheckBox;\r
+  EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;\r
+  EFI_IFR_NUMERIC       *IfrNumeric;\r
+  STATUS                Status;\r
+  char                  ZeroByte;\r
+\r
+  //\r
+  // Walk the opcodes to set default values and stuff them into the variable stores\r
+  //\r
+\r
+  if (Context == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  Status              = STATUS_SUCCESS;\r
+  Context->CurrentIfr = Context->Ifr;\r
+  SavedParseEntry     = NULL;\r
+  OrderedList         = 0;\r
+  CachedVarOffset     = 0;\r
+  CachedVarSize       = 0;\r
+  ZeroByte            = 0;\r
+\r
+  while (Context->CurrentIfr != NULL) {\r
+    if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_FORM_SET_OP) {\r
+      //\r
+      // Formset opcode -- create a variable pack\r
+      //\r
+      Status = CreateVarStore (\r
+                &((EFI_IFR_FORM_SET *) (Context->CurrentIfr->RawIfrHeader))->Guid,\r
+                DEFAULT_VARIABLE_NAME,\r
+                ((EFI_IFR_FORM_SET *) (Context->CurrentIfr->RawIfrHeader))->NvDataSize\r
+                );\r
+    } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_VARSTORE_OP) {\r
+      //\r
+      // Variable store opcode -- create a variable pack\r
+      //\r
+      Status = CreateVarStore (\r
+                &((EFI_IFR_VARSTORE *) (Context->CurrentIfr->RawIfrHeader))->Guid,\r
+                (char *) Context->CurrentIfr->RawIfrHeader + sizeof (EFI_IFR_VARSTORE),\r
+                ((EFI_IFR_VARSTORE *) (Context->CurrentIfr->RawIfrHeader))->Size\r
+                );\r
+    } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ONE_OF_OP) {\r
+      //\r
+      // Need this parse context later when we find the default ONE_OF_OPTION.\r
+      // Clear out the variable store first, so that we're covered if someone\r
+      // has two one-of opcode that operate on the same data.\r
+      // So "last one wins" is the behavior.\r
+      //\r
+      OrderedList     = 0;\r
+      SavedParseEntry = Context->CurrentIfr;\r
+      CachedVarOffset = ((EFI_IFR_ONE_OF *) Context->CurrentIfr->RawIfrHeader)->QuestionId;\r
+      CachedVarSize   = ((EFI_IFR_ONE_OF *) Context->CurrentIfr->RawIfrHeader)->Width;\r
+    } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ORDERED_LIST_OP) {\r
+      //\r
+      // Need this parse context later as we parse the ONE_OF_OP's in the ordered list\r
+      //\r
+      OrderedList     = 1;\r
+      SavedParseEntry = Context->CurrentIfr;\r
+      CachedVarOffset = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->QuestionId;\r
+      CachedVarSize   = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->MaxEntries;\r
+\r
+      while (CachedVarSize > 0) {\r
+        Status = SetVariableValue (\r
+                  SavedParseEntry->VarStoreGuid1, // GUID of variable store to write\r
+                  SavedParseEntry->VarStoreName1, // name of variable store to write\r
+                  CachedVarOffset,                // offset into variable store\r
+                  1,                              // variable data size\r
+                  (void *) &ZeroByte\r
+                  );\r
+        //\r
+        // variable value\r
+        //\r
+        CachedVarSize--;\r
+        CachedVarOffset++;\r
+      }\r
+\r
+      CachedVarOffset = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->QuestionId;\r
+      CachedVarSize   = 1;\r
+      //\r
+      // ((EFI_IFR_ORDERED_LIST *)Context->CurrentIfr->RawIfrHeader)->Width;\r
+      //\r
+    } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ONE_OF_OPTION_OP) {\r
+      IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) Context->CurrentIfr->RawIfrHeader;\r
+      //\r
+      // If we're in an ordered list, then copy the value to the data store\r
+      //\r
+      if (OrderedList) {\r
+        Status = SetVariableValue (\r
+                  SavedParseEntry->VarStoreGuid1, // GUID of variable store to write\r
+                  SavedParseEntry->VarStoreName1, // name of variable store to write\r
+                  CachedVarOffset,                // offset into variable store\r
+                  1,                              // variable data size\r
+                  (void *) &IfrOneOfOption->Value\r
+                  );\r
+        //\r
+        // variable value\r
+        //\r
+        // Advance the offset for the next ordered list item\r
+        //\r
+        CachedVarOffset += CachedVarSize;\r
+      } else {\r
+        //\r
+        // ONE-OF list. See if the default flag is set (provided we're not doing mfg defaults)\r
+        //\r
+        if (!MfgDefaults) {\r
+          if (IfrOneOfOption->Flags & EFI_IFR_FLAG_DEFAULT) {\r
+            Status = SetVariableValue (\r
+                      SavedParseEntry->VarStoreGuid1, // GUID of variable store to write\r
+                      SavedParseEntry->VarStoreName1, // name of variable store to write\r
+                      CachedVarOffset,                // offset into variable store\r
+                      CachedVarSize,                  // variable data size\r
+                      &IfrOneOfOption->Value\r
+                      );\r
+            //\r
+            // variable value\r
+            //\r
+          }\r
+        } else {\r
+          if (IfrOneOfOption->Flags & EFI_IFR_FLAG_MANUFACTURING) {\r
+            Status = SetVariableValue (\r
+                      SavedParseEntry->VarStoreGuid1, // GUID of variable store to write\r
+                      SavedParseEntry->VarStoreName1, // name of variable store to write\r
+                      CachedVarOffset,                // offset into variable store\r
+                      CachedVarSize,                  // variable data size\r
+                      &IfrOneOfOption->Value\r
+                      );\r
+            //\r
+            // variable value\r
+            //\r
+          }\r
+        }\r
+      }\r
+    } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_CHECKBOX_OP) {\r
+      //\r
+      // If we're saving defaults, and the default flag is set, or we're saving\r
+      // manufacturing defaults and the manufacturing flag is set, then save a 1.\r
+      // By default the varstore buffer is cleared, so we don't need to save a 0 ever.\r
+      //\r
+      IfrCheckBox = (EFI_IFR_CHECK_BOX *) Context->CurrentIfr->RawIfrHeader;\r
+      if (((MfgDefaults == 0) && (IfrCheckBox->Flags & EFI_IFR_FLAG_DEFAULT)) ||\r
+          ((MfgDefaults != 0) && (IfrCheckBox->Flags & EFI_IFR_FLAG_MANUFACTURING))\r
+          ) {\r
+        Size = 1;\r
+        Status = SetVariableValue (\r
+                  Context->CurrentIfr->VarStoreGuid1, // GUID of variable store to write\r
+                  Context->CurrentIfr->VarStoreName1, // name of variable store to write\r
+                  IfrCheckBox->QuestionId,            // offset into variable store\r
+                  IfrCheckBox->Width,                 // variable data size\r
+                  (void *) &Size\r
+                  );\r
+        //\r
+        // variable value\r
+        //\r
+      }\r
+    } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_NUMERIC_OP) {\r
+      IfrNumeric = (EFI_IFR_NUMERIC *) Context->CurrentIfr->RawIfrHeader;\r
+      Status = SetVariableValue (\r
+                Context->CurrentIfr->VarStoreGuid1, // GUID of variable store to write\r
+                Context->CurrentIfr->VarStoreName1, // name of variable store to write\r
+                IfrNumeric->QuestionId,             // offset into variable store\r
+                IfrNumeric->Width,                  // variable data size\r
+                (void *) &IfrNumeric->Default\r
+                );\r
+      //\r
+      // variable value\r
+      //\r
+    }\r
+\r
+    Context->CurrentIfr = Context->CurrentIfr->Next;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+CreateVarStore (\r
+  EFI_GUID  *VarGuid,\r
+  CHAR8     *VarName,\r
+  int       VarStoreSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a variable GUID.Name and the size of the variable store, allocate\r
+  storage for maintaining the variable value.\r
+  \r
+Arguments:\r
+\r
+  VarGuid - GUID for a variable\r
+  VarName - Name of the variable\r
+  VarStoreSize - size of the variable store\r
+\r
+Returns:\r
+\r
+  STATUS_ERROR   - problem with storage allocation \r
+  STATUS_SUCCESS - function executed successfully\r
\r
+--*/\r
+{\r
+  VARIABLE_STORE_ENTRY  *Entry;\r
+\r
+  VARIABLE_STORE_ENTRY  *TempEntry;\r
+  int                   PackSize;\r
+  int                   VarNameLen;\r
+  //\r
+  // If the variable store size is zero, then do nothing. This could be valid\r
+  // if variable steering is used in the IFR such that FormsetGUID."Setup" variable\r
+  // store is never used.\r
+  //\r
+  // OPEN: What about a form that only has a time/date question? Then if some other\r
+  // function called SetDefaults(), attempting to set time/date would result in an\r
+  // error in the SetVarValue() function.\r
+  //\r
+   if (VarStoreSize == 0) {\r
+    return STATUS_SUCCESS;\r
+   }\r
+  //\r
+  // Go through our list of variable stores and see if we've already created one\r
+  // for this Guid.Name. If so, check the size and return. Otherwise create\r
+  // one and add it to the list.\r
+  //\r
+  for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {\r
+    if (memcmp (VarGuid, &Entry->VarPack->VariableGuid, sizeof (EFI_GUID)) == 0) {\r
+      if (strcmp (VarName, Entry->VarName) == 0) {\r
+        //\r
+        // Already have one. Check size.\r
+        //\r
+        if (Entry->VarBufferSize != VarStoreSize) {\r
+          Error (NULL, 0, 0, "mismatched variable store size between two formsets", VarName);\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        return STATUS_SUCCESS;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // Create a new one.\r
+  //\r
+  Entry = (VARIABLE_STORE_ENTRY *) malloc (sizeof (VARIABLE_STORE_ENTRY));\r
+  if (Entry == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset ((void *) Entry, 0, sizeof (VARIABLE_STORE_ENTRY));\r
+  //\r
+  // Compute size of the varpack\r
+  //\r
+  VarNameLen      = strlen (VarName) + 1;\r
+  PackSize        = sizeof (EFI_HII_VARIABLE_PACK) + VarNameLen * sizeof (CHAR16) + VarStoreSize;\r
+  Entry->VarPack  = (EFI_HII_VARIABLE_PACK *) malloc (PackSize);\r
+  if (Entry->VarPack == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    free (Entry);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  Entry->VarPack->Header.Length       = PackSize;\r
+  Entry->VarPack->Header.Type         = EFI_HII_VARIABLE;\r
+  Entry->VarPack->VariableNameLength  = VarNameLen * sizeof (CHAR16);\r
+  Entry->VarName[MAX_VARIABLE_NAME - 1] = 0;\r
+  strncpy (Entry->VarName, VarName, MAX_VARIABLE_NAME - 1);\r
+#ifdef USE_VC8\r
+  swprintf ((CHAR16 *) (Entry->VarPack + 1), (strlen (VarName) + 1) * sizeof (CHAR16), L"%S", VarName);\r
+#else\r
+  swprintf ((CHAR16 *) (Entry->VarPack + 1), L"%S", VarName);\r
+#endif\r
+  memcpy (&Entry->VarPack->VariableGuid, VarGuid, sizeof (EFI_GUID));\r
+  //\r
+  // Point VarBuffer into the allocated buffer (for convenience)\r
+  //\r
+  Entry->VarBuffer = (char *) Entry->VarPack + sizeof (EFI_HII_VARIABLE_PACK) + VarNameLen * sizeof (CHAR16);\r
+  memset ((void *) Entry->VarBuffer, 0, VarStoreSize);\r
+  Entry->VarBufferSize = VarStoreSize;\r
+  //\r
+  // Add this new varstore to our list\r
+  //\r
+  if (mVariableStores == NULL) {\r
+    mVariableStores = Entry;\r
+  } else {\r
+    for (TempEntry = mVariableStores; TempEntry->Next != NULL; TempEntry = TempEntry->Next)\r
+      ;\r
+    TempEntry->Next = Entry;\r
+  }\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+/******************************************************************************/\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  The following IfrParseXX() functions are used to parse an IFR opcode numbered\r
+  XX via a dispatch table. \r
+  \r
+Arguments:\r
+\r
+  Context - IFR parsing context into which pertinent data for the \r
+            current opcode can be saved. Context->LastIfr->RawIfrHeader points to \r
+            the raw IFR bytes currently being parsed.\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS  - always\r
+  \r
+--*/\r
+\r
+/*******************************************************************************/\r
+static\r
+STATUS\r
+IfrParse01 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse02 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse03 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// Parse the IFR EFI_IFR_ONE_OF opcode.\r
+//\r
+static\r
+STATUS\r
+IfrParse05 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse06 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse07 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse08 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse09 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse0A (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse0B (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse0C (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse0D (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse0E (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_IFR_FORM_SET  *Op;\r
+  Op  = (EFI_IFR_FORM_SET *) Context->LastIfr->RawIfrHeader;\r
+  Context->LastIfr->VarStoreGuid1 = &Op->Guid;\r
+  Context->LastIfr->VarStoreName1 = "Setup";\r
+  Context->FormsetGuid            = &Op->Guid;\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse0F (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse10 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse11 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse12 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse13 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse14 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse15 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse16 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse17 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse18 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse19 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse1A (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse1B (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse1C (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse1D (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse1E (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse1F (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse20 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse21 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse22 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+STATUS\r
+IfrParse23 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// EFI_IFR_VARSTORE\r
+//\r
+static\r
+STATUS\r
+IfrParse24 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  EFI_IFR_VARSTORE  *Op;\r
+  Op = (EFI_IFR_VARSTORE *) Context->LastIfr->RawIfrHeader;\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// VARSTORE_SELECT\r
+//\r
+static\r
+STATUS\r
+IfrParse25 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  STATUS                  Status;\r
+  EFI_IFR_VARSTORE_SELECT *Op;\r
+  Op      = (EFI_IFR_VARSTORE_SELECT *) Context->LastIfr->RawIfrHeader;\r
+  Status  = GetVarStoreInfo (Context, Op->VarId, &Context->LastIfr->VarStoreGuid1, &Context->LastIfr->VarStoreName1);\r
+  //\r
+  // VARSTORE_SELECT sets both\r
+  //\r
+  Context->LastIfr->VarStoreGuid2 = Context->LastIfr->VarStoreGuid1;\r
+  Context->LastIfr->VarStoreName2 = Context->LastIfr->VarStoreName1;\r
+  return Status;\r
+}\r
+//\r
+// VARSTORE_SELECT_PAIR\r
+//\r
+static\r
+STATUS\r
+IfrParse26 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  STATUS                        Status;\r
+  EFI_IFR_VARSTORE_SELECT_PAIR  *Op;\r
+\r
+  Op      = (EFI_IFR_VARSTORE_SELECT_PAIR *) Context->LastIfr->RawIfrHeader;\r
+  Status  = GetVarStoreInfo (Context, Op->VarId, &Context->LastIfr->VarStoreGuid1, &Context->LastIfr->VarStoreName1);\r
+  Status = GetVarStoreInfo (\r
+            Context,\r
+            Op->SecondaryVarId,\r
+            &Context->LastIfr->VarStoreGuid2,\r
+            &Context->LastIfr->VarStoreName2\r
+            );\r
+  return Status;\r
+}\r
+//\r
+// TRUE\r
+//\r
+static\r
+STATUS\r
+IfrParse27 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+//\r
+// FALSe\r
+//\r
+static\r
+STATUS\r
+IfrParse28 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+static\r
+STATUS\r
+IfrParse29 (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
+static\r
+STATUS\r
+IfrParse2A (\r
+  IFR_PARSE_CONTEXT *Context\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Context - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
new file mode 100644 (file)
index 0000000..6a2a597
--- /dev/null
@@ -0,0 +1,267 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  IfrParse.h\r
+\r
+Abstract:\r
+\r
+  Prototypes and defines for the IFR parsing services.\r
+\r
+--*/\r
+\r
+#ifndef _IFR_PARSE_H_\r
+#define _IFR_PARSE_H_\r
+\r
+#define DEFAULT_HII_PACK_FILENAME_EXTENSION ".hpk"\r
+//\r
+// When we parse IFR, we'll keep the IFR in a linked list of\r
+// these.\r
+//\r
+typedef struct _IFR_PARSE_ENTRY {\r
+  struct _IFR_PARSE_ENTRY *Next;\r
+  int                     Tag;  // for debugging\r
+  EFI_IFR_OP_HEADER       *RawIfrHeader;\r
+  //\r
+  // GUIDs for variable storage\r
+  //\r
+  EFI_GUID                *VarStoreGuid1;\r
+  char                    *VarStoreName1;\r
+  EFI_GUID                *VarStoreGuid2;\r
+  char                    *VarStoreName2;\r
+} IFR_PARSE_ENTRY;\r
+\r
+typedef struct _IFR_PARSE_CONTEXT {\r
+  struct _IFR_PARSE_CONTEXT *Next;\r
+  EFI_HII_IFR_PACK          *PackHeader;\r
+  char                      *IfrBufferStart;\r
+  char                      *CurrentPos;\r
+  long                      IfrBufferLen;\r
+  int                       Handle;\r
+  IFR_PARSE_ENTRY           *Ifr;\r
+  IFR_PARSE_ENTRY           *LastIfr;\r
+  IFR_PARSE_ENTRY           *CurrentIfr;\r
+  FILE                      *OutFptr;\r
+  CHAR16                    *Language;\r
+  EFI_GUID                  *FormsetGuid;\r
+  EFI_GUID                  NullGuid;     // for use until we set the Guid field correctly\r
+  EFI_GUID                  PackageGuid;  // from the PackageGuid in the HII data table\r
+} IFR_PARSE_CONTEXT;\r
+\r
+STATUS\r
+IfrGetVarPack (\r
+  int                   VarIndex,\r
+  EFI_HII_VARIABLE_PACK **VarPack\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  VarIndex  - GC_TODO: add argument description\r
+  VarPack   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrParsePack (\r
+  int              Handle,\r
+  EFI_HII_IFR_PACK *PackHeader,\r
+  EFI_GUID         *PackageGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle      - GC_TODO: add argument description\r
+  PackHeader  - GC_TODO: add argument description\r
+  PackageGuid - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrParseCheck (\r
+  char *Buffer,\r
+  long BufferSize\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Buffer      - GC_TODO: add argument description\r
+  BufferSize  - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrParseInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrParseEnd (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrParseDump (\r
+  int    Handle,\r
+  CHAR16 *Language,\r
+  FILE   *OutFptr\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle    - GC_TODO: add argument description\r
+  Language  - GC_TODO: add argument description\r
+  OutFptr   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrSetDefaults (\r
+  int MfgDefaults\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  MfgDefaults - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrGetIfrPack (\r
+  int              Handle,\r
+  EFI_HII_IFR_PACK **PackHeader,\r
+  EFI_GUID         *FormsetGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle      - GC_TODO: add argument description\r
+  PackHeader  - GC_TODO: add argument description\r
+  FormsetGuid - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+IfrReferencesVarPack (\r
+  int                   IfrHandle,\r
+  EFI_HII_VARIABLE_PACK *VarPack\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  IfrHandle - GC_TODO: add argument description\r
+  VarPack   - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif // #ifndef _IFR_PARSE_H_\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
new file mode 100644 (file)
index 0000000..83f6ba7
--- /dev/null
@@ -0,0 +1,103 @@
+#/*++\r
+#\r
+#  Copyright (c) 2004 - 2010, 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
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#  Module Name:\r
+#\r
+#    Makefile\r
+#\r
+#  Abstract:\r
+#\r
+#    This file is used to build the HiiPack utility\r
+#\r
+#--*/\r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set\r
+!ENDIF\r
+\r
+#\r
+# Do this if you want to compile from this directory\r
+#\r
+!IFNDEF TOOLCHAIN\r
+TOOLCHAIN = TOOLCHAIN_MSVC\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+\r
+TARGET_NAME         = HiiPack\r
+TARGET_SRC_DIR      = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\HiiPack.exe\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+INC       = $(INC) -I "$(EDK_SOURCE)\Foundation\Framework\Protocol\Hii"\r
+\r
+INC_DEPS  = "$(TARGET_SRC_DIR)\HiiPack.h" "$(TARGET_SRC_DIR)\IfrParse.h" "$(TARGET_SRC_DIR)\StringParse.h"\r
+\r
+LIBS      = "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
+\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\FindFiles.obj   \\r
+            $(EDK_TOOLS_OUTPUT)\HiiPack.obj     \\r
+            $(EDK_TOOLS_OUTPUT)\IfrParse.obj    \\r
+            $(EDK_TOOLS_OUTPUT)\StringParse.obj\r
+\r
+#\r
+# Build EXE\r
+#\r
+\r
+$(EDK_TOOLS_OUTPUT)\FindFiles.obj : $(TARGET_SRC_DIR)\FindFiles.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FindFiles.c  /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SRC_DIR)\HiiPack.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\HiiPack.c  /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\IfrParse.obj : $(TARGET_SRC_DIR)\IfrParse.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\IfrParse.c  /Fo$@\r
+\r
+$(EDK_TOOLS_OUTPUT)\StringParse.obj : $(TARGET_SRC_DIR)\StringParse.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\StringParse.c  /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+!IF ("$(EFI_BINARY_BUILD)" == "YES")\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+!ENDIF\r
+\r
+clean:\r
+  @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\FindFiles.* del $(EDK_TOOLS_OUTPUT)\FindFiles.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\IfrParse* del $(EDK_TOOLS_OUTPUT)\IfrParse.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\StringParse.* del $(EDK_TOOLS_OUTPUT)\StringParse.* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
new file mode 100644 (file)
index 0000000..8dd26e1
--- /dev/null
@@ -0,0 +1,244 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  StringParse.c  \r
+\r
+Abstract:\r
+\r
+  Routines for parsing HII string packs\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiUtilityMsgs.h"\r
+#include "EfiInternalFormRepresentation.h"\r
+#include "Hii.h"\r
+#include "StringParse.h"\r
+#include "HiiPack.h"\r
+\r
+typedef struct _STRING_PACK_RECORD {\r
+  struct _STRING_PACK_RECORD  *Next;\r
+  int                         Handle;\r
+  EFI_GUID                    PackageGuid;\r
+  EFI_GUID                    FormsetGuid;\r
+  EFI_HII_STRING_PACK         *StringPack;\r
+  int                         StringPackSize;\r
+  int                         NumStringPacks;\r
+} STRING_PACK_RECORD;\r
+\r
+static STRING_PACK_RECORD *mStringPacks = NULL;\r
+\r
+STATUS\r
+StringGetPack (\r
+  int                 Handle,           // matches handle passed in with StringParsePack()\r
+  EFI_HII_STRING_PACK **StringPack,     // returned pointer to string pack\r
+  int                 *StringPackSize,  // sizeof buffer pointed to by StringPack\r
+  int                 *NumStringPacks,  // in the array pointed to by StringPack\r
+  EFI_GUID            *FormsetGuid,\r
+  EFI_GUID            *PackageGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Get a string pack given to us previously\r
+  \r
+Arguments:\r
+  Handle            - handle of string pack to get\r
+  StringPack        - outgoing pointer to string pack on the given handle\r
+  StringPackSize    - outgoing size of string pack pointed to by StringPack\r
+  NumStringPacks    - outgoing number of string packs in StringPack[] array\r
+  FormsetGuid       - outgoing GUID passed in with the string pack when it was parsed\r
+  PackageGuid       - outgoing GUID passed in with the string pack when it was parsed\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS  - string pack with matching handle was found\r
+  STATUS_ERROR    - otherwise\r
+  \r
+--*/\r
+{\r
+  STRING_PACK_RECORD  *Rec;\r
+\r
+  for (Rec = mStringPacks; Rec != NULL; Rec = Rec->Next) {\r
+    if (Rec->Handle == Handle) {\r
+      *StringPack     = Rec->StringPack;\r
+      *StringPackSize = Rec->StringPackSize;\r
+      *NumStringPacks = Rec->NumStringPacks;\r
+      return STATUS_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return STATUS_ERROR;\r
+}\r
+\r
+STATUS\r
+StringParsePack (\r
+  int                   Handle,\r
+  EFI_HII_STRING_PACK   *StringPack,\r
+  EFI_GUID              *FormsetGuid,\r
+  EFI_GUID              *PackageGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Parse a string pack, saving the information for later retrieval by the caller\r
+  \r
+Arguments:\r
+  Handle            - handle of string pack\r
+  StringPack        - pointer to string pack array to parse\r
+  FormsetGuid       - GUID of the string pack\r
+  PackageGuid       - package GUID from the HII data table from which this string pack orginated\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS  - Stringpack processed successfully\r
+  STATUS_ERROR    - otherwise\r
+  \r
+--*/\r
+{\r
+  STRING_PACK_RECORD  *Rec;\r
+\r
+  STRING_PACK_RECORD  *TempRec;\r
+  int                 PackSize;\r
+  EFI_HII_STRING_PACK *TempPack;\r
+  //\r
+  // Allocate a new string pack record\r
+  //\r
+  Rec = (STRING_PACK_RECORD *) malloc (sizeof (STRING_PACK_RECORD));\r
+  if (Rec == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memset (Rec, 0, sizeof (STRING_PACK_RECORD));\r
+  Rec->Handle = Handle;\r
+  if (PackageGuid != NULL) {\r
+    memcpy (&Rec->PackageGuid, PackageGuid, sizeof (EFI_GUID));\r
+  }\r
+\r
+  if (FormsetGuid != NULL) {\r
+    memcpy (&Rec->FormsetGuid, FormsetGuid, sizeof (EFI_GUID));\r
+  }\r
+  //\r
+  // Walk the string packs to find the terminator\r
+  //\r
+  TempPack  = StringPack;\r
+  PackSize  = 0;\r
+  while (TempPack->Header.Length > 0) {\r
+    if (TempPack->Header.Type != EFI_HII_STRING) {\r
+      Error (NULL, 0, 0, "found a non-string pack in the string pack array", NULL);\r
+      free (Rec);\r
+      return STATUS_ERROR;\r
+    }\r
+\r
+    PackSize += TempPack->Header.Length;\r
+    Rec->NumStringPacks++;\r
+    TempPack = (EFI_HII_STRING_PACK *) ((char *) TempPack + TempPack->Header.Length);\r
+  }\r
+  //\r
+  // Add space for the terminator\r
+  //\r
+  PackSize += sizeof (EFI_HII_STRING_PACK);\r
+  Rec->StringPackSize = PackSize;\r
+  //\r
+  // Make a copy of the incoming string pack\r
+  //\r
+  Rec->StringPack = (EFI_HII_STRING_PACK *) malloc (PackSize);\r
+  if (Rec->StringPack == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    free (Rec);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  memcpy ((void *) Rec->StringPack, StringPack, PackSize);\r
+  //\r
+  // Add this record to our list\r
+  //\r
+  if (mStringPacks == NULL) {\r
+    mStringPacks = Rec;\r
+  } else {\r
+    for (TempRec = mStringPacks; TempRec->Next != NULL; TempRec = TempRec->Next)\r
+      ;\r
+    TempRec->Next = Rec;\r
+  }\r
+  free (Rec->StringPack);\r
+  free (Rec);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+StringInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  StringEnd ();\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+STATUS\r
+StringEnd (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+{\r
+  STRING_PACK_RECORD  *Next;\r
+  //\r
+  // Free up all the memory we've allocated\r
+  //\r
+  while (mStringPacks != NULL) {\r
+    if (mStringPacks->StringPack != NULL) {\r
+      free (mStringPacks->StringPack);\r
+    }\r
+\r
+    Next = mStringPacks->Next;\r
+    free (mStringPacks);\r
+    mStringPacks = Next;\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
new file mode 100644 (file)
index 0000000..a5df7d0
--- /dev/null
@@ -0,0 +1,125 @@
+/*++\r
+\r
+Copyright (c) 2004 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  StringParse.h\r
+\r
+Abstract:\r
+\r
+  Prototypes and defines for the string pack parsing services.\r
+\r
+--*/\r
+\r
+#ifndef _STRING_PARSE_H_\r
+#define _STRING_PARSE_H_\r
+\r
+STATUS\r
+StringGetPack (\r
+  int                 Handle,           // matches handle passed in with StringParsePack()\r
+  EFI_HII_STRING_PACK **StringPack,     // returned pointer to string pack\r
+  int                 *StringPackSize,  // sizeof buffer pointed to by StringPack\r
+  int                 *NumStringPacks,  // in the array pointed to by StringPack\r
+  EFI_GUID            *FormsetGuid,\r
+  EFI_GUID            *PackageGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle          - GC_TODO: add argument description\r
+  StringPack      - GC_TODO: add argument description\r
+  StringPackSize  - GC_TODO: add argument description\r
+  NumStringPacks  - GC_TODO: add argument description\r
+  FormsetGuid     - GC_TODO: add argument description\r
+  PackageGuid     - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+StringParsePack (\r
+  int                   Handle,\r
+  EFI_HII_STRING_PACK   *StringPack,\r
+  EFI_GUID              *FormsetGuid,\r
+  EFI_GUID              *PackageGuid\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  Handle      - GC_TODO: add argument description\r
+  StringPack  - GC_TODO: add argument description\r
+  FormsetGuid - GC_TODO: add argument description\r
+  PackageGuid - GC_TODO: add argument description\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+StringInit (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+STATUS\r
+StringEnd (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  GC_TODO: Add function description\r
+\r
+Arguments:\r
+\r
+  None\r
+\r
+Returns:\r
+\r
+  GC_TODO: add return values\r
+\r
+--*/\r
+;\r
+\r
+#endif // #ifndef _STRING_PARSE_H_\r
index 3b780de4ab1e47e3e57273c8d52735054553ac0a..13fdd22aa560e6f31291070019c054d5562fd1b4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -37,6 +37,7 @@ typedef struct _STRING_LIST {
 } STRING_LIST;\r
 \r
 #define UTILITY_NAME      "MakeDeps"\r
+#define UTILITY_VERSION   "v1.0"\r
 \r
 #define MAX_LINE_LEN      2048\r
 #define MAX_PATH          2048\r
@@ -1488,30 +1489,36 @@ Returns:
   \r
 --*/\r
 {\r
-  int               Index;\r
-  static const char *Str[] = {\r
-    UTILITY_NAME " -- make dependencies",\r
-    "  Usage: MakeDeps [options]",\r
-    "    Options include:",\r
-    "      -h or -?         for this help information",\r
-    "      -f SourceFile    add SourceFile to list of files to scan",\r
-    "      -i IncludePath   add IncludePath to list of search paths",\r
-    "      -o OutputFile    write output dependencies to OutputFile",\r
-    "      -s SubDir        for each IncludePath, also search IncludePath\\SubDir",\r
-    "      -v               for verbose output",\r
-    "      -ignorenotfound  don't warn for files not found",\r
-    "      -target Target   for single SourceFile, target is Target, not SourceFile.obj",\r
-    "      -q               quiet mode to not report files not found if ignored",\r
-    "      -sub sym str     replace all occurrances of 'str' with 'sym' in the output",\r
-    "      -nosystem        not process system <include> files",\r
-    "      -neverfail       always return a success return code",\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Make Dependencies Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]...",\r
+    "Options:",\r
+    "  -h or -?         for this help information",\r
+    "  -f SourceFile    add SourceFile to list of files to scan",\r
+    "  -i IncludePath   add IncludePath to list of search paths",\r
+    "  -o OutputFile    write output dependencies to OutputFile",\r
+    "  -s SubDir        for each IncludePath, also search IncludePath\\SubDir",\r
+    "  -v               for verbose output",\r
+    "  -ignorenotfound  don't warn for files not found",\r
+    "  -target Target   for single SourceFile, target is Target, not SourceFile.obj",\r
+    "  -q               quiet mode to not report files not found if ignored",\r
+    "  -sub sym str     replace all occurrances of 'str' with 'sym' in the output",\r
+    "  -nosystem        not process system <include> files",\r
+    "  -neverfail       always return a success return code",\r
     //\r
-    //    "      -nodupes         keep track of include files, don't rescan duplicates",\r
+    //    "  -nodupes         keep track of include files, don't rescan duplicates",\r
     //\r
-    "      -usesumdeps path use summary dependency files in 'path' directory.",\r
-    "      -asm             The SourceFiles are assembler files",\r
-    "      -cl              The SourceFiles are the output of cl with /showIncludes",\r
-    "",\r
+    "  -usesumdeps path use summary dependency files in 'path' directory.",\r
+    "  -asm             The SourceFiles are assembler files",\r
+    "  -cl              The SourceFiles are the output of cl with /showIncludes",\r
     NULL\r
   };\r
   for (Index = 0; Str[Index] != NULL; Index++) {\r
index 772417e1f7071c24ea74eacc97f6a2b84badac96..c8e85e51f6f8c62cef944f3f3c674bf075b6f63f 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #\r
-#  Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -44,9 +44,11 @@ MAKEFILES = $(EDK_TOOLS_SOURCE)\Common\Makefile             \
 !IF "$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"\r
             $(EDK_TOOLS_SOURCE)\UefiVfrCompile\makefile     \\r
             $(EDK_TOOLS_SOURCE)\UefiStrGather\makefile      \\r
+            $(EDK_TOOLS_SOURCE)\UefiHiiPack\Makefile        \\r
 !ELSE\r
             $(EDK_TOOLS_SOURCE)\VfrCompile\makefile         \\r
             $(EDK_TOOLS_SOURCE)\StrGather\makefile          \\r
+            $(EDK_TOOLS_SOURCE)\HiiPack\Makefile            \\r
 !ENDIF\r
             $(EDK_TOOLS_SOURCE)\SplitFile\Makefile          \\r
             $(EDK_TOOLS_SOURCE)\Strip\Makefile              \\r
index 3d7a97ca7ddb2311e14cc485c33b6f5c1da14751..2f6ac471e6dae748041b5218b910e8bd9b76eea8 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 1999 - 2002, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 1999 - 2010, 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
@@ -23,6 +23,8 @@ Abstract:
 #include "stdio.h"\r
 #include "string.h"\r
 \r
+#define UTILITY_NAME    "ModifyInf"\r
+#define UTILITY_VERSION "v1.0"\r
 //\r
 // Read a line into buffer including '\r\n'\r
 //\r
@@ -263,7 +265,22 @@ Returns:
 \r
 --*/\r
 {\r
-  printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Modify INF File Utility",\r
+    "  Copyright (C), 1999 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" SOURCE DEST [PATTERN]",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }  \r
 }\r
 \r
 int\r
index 3e60b0344b4b6d627c72de456934996829fe8987..5181373a54037235ba4d3c869d3e23376a82b11a 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -35,18 +35,7 @@ Abstract:
 #define EFI_BASE_ADDRESS    "EFI_BASE_ADDRESS"\r
 #define DEFAULT_FV_INF_DIR  "FV"            // default dir for where we create the FV INF file\r
 #define DEFAULT_FV_DIR      "$(BUILD_DIR)"  // where the FV file comes from\r
-#define MALLOC(size)        malloc (size)\r
-#define FREE(ptr)           free (ptr)\r
 \r
-//\r
-// Disable warning for unused function arguments\r
-//\r
-#pragma warning(disable : 4100)\r
-//\r
-// Disable warning for while(1) code\r
-//\r
-// #pragma warning (disable : 4127)\r
-//\r
 typedef struct {\r
   char  *ComponentType;\r
   char  *Extension;\r
@@ -196,8 +185,7 @@ static
 void\r
 AddFirmwareVolumes (\r
   char          *FVs,\r
-  int           ComponentsInstance,\r
-  FILE_LIST     *FileListPtr\r
+  int           ComponentsInstance\r
   );\r
 \r
 static\r
@@ -503,7 +491,7 @@ Returns:
   // Add these firmware volumes to the list of known firmware\r
   // volume names.\r
   //\r
-  AddFirmwareVolumes (FVs, ComponentsInstance, Ptr);\r
+  AddFirmwareVolumes (FVs, ComponentsInstance);\r
 \r
   return STATUS_SUCCESS;\r
 }\r
@@ -528,7 +516,7 @@ CFVDestructor (
   //\r
   while (mFVList != NULL) {\r
     mFVListLast = mFVList->Next;\r
-    FREE (mFVList);\r
+    free (mFVList);\r
     mFVList = mFVListLast;\r
   }\r
 }\r
@@ -957,10 +945,10 @@ Returns:
   //\r
   // Now go through the list of all NonFFS FVs they specified and search for\r
   // a [build.fv.$(FV)] or [build.fv] command and emit the commands to the\r
-  // output makefile. Add them to the "fvs" target as well.\r
+  // output makefile. Add them to the "fvs_0" target as well.\r
   //\r
   if (mNonFfsFVList != NULL) {\r
-    fprintf (MakeFptr, "fvs ::");\r
+    fprintf (MakeFptr, "fvs_0 ::");\r
     FVPtr = mNonFfsFVList;\r
     while (FVPtr != NULL) {\r
       fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);\r
@@ -1022,43 +1010,40 @@ Returns:
       DSCFileRestorePosition (DSC);\r
     }\r
   }\r
+\r
   //\r
-  // Go through our list of firmware volumes and create an "fvs" target that\r
-  // builds everything. It has to be a mix of components and FV's in order.\r
-  // For example:  fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv\r
+  // Get the components count\r
   //\r
-  ComponentsInstance  = 0;\r
-  ComponentCount      = 0;\r
-  fprintf (MakeFptr, "fvs ::");\r
-  for (;;) {\r
-    //\r
-    // First see if we have any components for this section. If we don't,\r
-    // then we're done\r
-    //\r
-    for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
-      if (FileListPtr->ComponentsInstance == ComponentsInstance) {\r
-        break;\r
-      }\r
-    }\r
-\r
-    if (FileListPtr == NULL) {\r
-      break;\r
+  ComponentCount = -1;\r
+  for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {\r
+    if (FileListPtr->ComponentsInstance > ComponentCount) {\r
+      ComponentCount = FileListPtr->ComponentsInstance;\r
     }\r
+  }\r
+  ComponentCount++;\r
 \r
-    fprintf (MakeFptr, " components_%d", ComponentsInstance);\r
-    ComponentCount++;\r
-    //\r
-    // Now print any firmware volumes that match this components instance\r
-    //\r
+  //\r
+  // Now print firmware volumes build targets fvs_0, fvs_1 etc.\r
+  //\r
+  for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {\r
+    fprintf (MakeFptr, "fvs_%d ::", ComponentsInstance);\r
     for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {\r
       if (FVPtr->ComponentsInstance == ComponentsInstance) {\r
         fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);\r
       }\r
     }\r
-\r
-    ComponentsInstance++;\r
+    fprintf (MakeFptr, "\n\n");\r
+  }\r
+      \r
+  //\r
+  // Create an "fvs" target that builds everything. It has to be a mix of \r
+  // components and FV's in order. For example:\r
+  // fvs :: components_0 fvs_0 components_1 fvs_1\r
+  //\r
+  fprintf (MakeFptr, "fvs ::");\r
+  for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {\r
+    fprintf (MakeFptr, " components_%d fvs_%d", ComponentsInstance, ComponentsInstance);\r
   }\r
-\r
   fprintf (MakeFptr, "\n\n");\r
 \r
   //\r
@@ -1351,8 +1336,7 @@ static
 void\r
 AddFirmwareVolumes (\r
   char          *FVs,\r
-  int           ComponentsInstance,\r
-  FILE_LIST     *FileListPtr\r
+  int           ComponentsInstance\r
   )\r
 {\r
   FV_LIST *FvPtr;\r
@@ -1386,7 +1370,7 @@ AddFirmwareVolumes (
       // If we didn't find a match, then create a new one\r
       //\r
       if (FvPtr == NULL) {\r
-        FvPtr = MALLOC (sizeof (FV_LIST));\r
+        FvPtr = malloc (sizeof (FV_LIST));\r
         if (FvPtr == NULL) {\r
           Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");\r
           return ;\r
index 417951cf59a0c9b2a3185750088ac02e1658392a..e2a4b5f06bc41257b3f06cad35538948061d3dfc 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #  \r
-#  Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -49,25 +49,31 @@ TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\ProcessDsc.exe
 \r
 all: $(TARGET_EXE)\r
 \r
-INC_DEPS  = $(TARGET_SRC_DIR)\DSCFile.h    $(INC_DEPS)\r
-INC_DEPS  = $(TARGET_SRC_DIR)\FWVolume.h   $(INC_DEPS)\r
-INC_DEPS  = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)\r
-INC_DEPS  = $(TARGET_SRC_DIR)\Common.h     $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\DSCFile.h     $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\MultiThread.h $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\FWVolume.h    $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\Exceptions.h  $(INC_DEPS)\r
+INC_DEPS  = $(TARGET_SRC_DIR)\Common.h      $(INC_DEPS)\r
 \r
 LIBS      = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib"\r
 \r
-OBJECTS   = $(EDK_TOOLS_OUTPUT)\DSCFile.obj  \\r
-            $(EDK_TOOLS_OUTPUT)\FWVolume.obj   \\r
-            $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \\r
+OBJECTS   = $(EDK_TOOLS_OUTPUT)\DSCFile.obj     \\r
+            $(EDK_TOOLS_OUTPUT)\MultiThread.obj \\r
+            $(EDK_TOOLS_OUTPUT)\FWVolume.obj    \\r
+            $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj  \\r
             $(EDK_TOOLS_OUTPUT)\Exceptions.obj\r
 \r
 #\r
 # Compile each source file\r
 #\r
+C_FLAGS   = $(C_FLAGS) /MT /wd4201\r
 \r
 $(EDK_TOOLS_OUTPUT)\DSCFile.obj : $(TARGET_SRC_DIR)\DSCFile.c $(INC_DEPS)\r
   $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\DSCFile.c /Fo$@\r
 \r
+$(EDK_TOOLS_OUTPUT)\MultiThread.obj : $(TARGET_SRC_DIR)\MultiThread.c $(INC_DEPS)\r
+  $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\MultiThread.c /Fo$@\r
+\r
 $(EDK_TOOLS_OUTPUT)\FWVolume.obj : $(TARGET_SRC_DIR)\FWVolume.c $(INC_DEPS)\r
   $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\FWVolume.c /Fo$@\r
 \r
@@ -88,7 +94,9 @@ $(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
   copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
 !ELSE\r
 $(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
-  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) shlwapi.lib \\r
+  /NODEFAULTLIB:libc.lib  /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib \\r
+  /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib\r
 !IF ("$(EFI_BINARY_BUILD)" == "YES")\r
   if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
   if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
@@ -100,5 +108,6 @@ $(TARGET_EXE) : $(OBJECTS) $(LIBS)
 clean:\r
   @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL\r
   @if exist $(EDK_TOOLS_OUTPUT)\DscFile.* del $(EDK_TOOLS_OUTPUT)\DscFile.* > NUL\r
+  @if exist $(EDK_TOOLS_OUTPUT)\MultiThread.* del $(EDK_TOOLS_OUTPUT)\MultiThread.* > NUL\r
   @if exist $(EDK_TOOLS_OUTPUT)\Exceptions* del $(EDK_TOOLS_OUTPUT)\Exceptions.* > NUL\r
   @if exist $(EDK_TOOLS_OUTPUT)\FwVolume.* del $(EDK_TOOLS_OUTPUT)\FwVolume.* > NUL\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
new file mode 100644 (file)
index 0000000..b6a72ec
--- /dev/null
@@ -0,0 +1,905 @@
+/*++\r
+\r
+Copyright (c) 2008 - 2010, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:\r
+\r
+  MultiThread.c\r
+\r
+Abstract:\r
+\r
+  This module is used to add multi-thread build support to ProcessDsc utility \r
+  to improve the build performance. \r
+\r
+--*/\r
+\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <direct.h>\r
+#include "Common.h"\r
+#include "MultiThread.h"\r
+\r
+BUILD_ITEM *\r
+AddBuildItem (\r
+  BUILD_ITEM  **BuildList,\r
+  INT8        *BaseName,\r
+  INT8        *Processor,\r
+  INT8        *Makefile\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Add a build item to a specified build list\r
+\r
+Arguments:\r
+  \r
+  BuildList  - build list where the new build item will be added\r
+  BaseName   - base name of the new module\r
+  Processor  - processor type of the new module\r
+  Makefile   - makefile name of the new module\r
+\r
+Returns:\r
+\r
+  Pointer to the newly added build item\r
+\r
+--*/\r
+{\r
+  BUILD_ITEM  *NewBuildItem;\r
+  \r
+  //\r
+  // Create a new build item\r
+  //\r
+  NewBuildItem = malloc (sizeof (BUILD_ITEM));\r
+  if (NewBuildItem == NULL) {\r
+    return NULL;\r
+  }\r
+  memset (NewBuildItem, 0, sizeof (BUILD_ITEM));\r
+  NewBuildItem->BaseName  = _strdup (BaseName);\r
+  NewBuildItem->Processor = _strdup (Processor);\r
+  NewBuildItem->Makefile = _strdup (Makefile);\r
+  \r
+  //\r
+  // Add the build item to the head of the build list\r
+  //\r
+  NewBuildItem->Next = *BuildList;\r
+  *BuildList = NewBuildItem;\r
+  \r
+  return NewBuildItem;\r
+}\r
+\r
+SOURCE_FILE_ITEM *\r
+AddSourceFile (\r
+  BUILD_ITEM  *BuildItem, \r
+  INT8        *FileName\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Add a source file for a build item\r
+\r
+Arguments:\r
+  \r
+  BuildItem - build item to add the source file\r
+  FileName  - source file name to be added\r
+\r
+Returns:\r
+\r
+  Pointer to the newly added source file item\r
+\r
+--*/\r
+{\r
+  SOURCE_FILE_ITEM *NewSourceFile;\r
+  \r
+  //\r
+  // Create a new source file item\r
+  //\r
+  NewSourceFile = malloc (sizeof (SOURCE_FILE_ITEM));\r
+  if (NewSourceFile == NULL) {\r
+    return NULL;\r
+  }\r
+  memset (NewSourceFile, 0, sizeof (SOURCE_FILE_ITEM));\r
+  NewSourceFile->FileName  = _strdup (FileName);\r
+  \r
+  //\r
+  // Add the source file item to the head of the source file list\r
+  //\r
+  NewSourceFile->Next = BuildItem->SourceFileList;\r
+  BuildItem->SourceFileList = NewSourceFile;\r
+  \r
+  return NewSourceFile; \r
+}\r
+\r
+DEPENDENCY_ITEM *\r
+AddDependency (\r
+  BUILD_ITEM  *BuildList, \r
+  BUILD_ITEM  *BuildItem, \r
+  INT8        *BaseName,\r
+  INT8        AdjustIndex\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Add a build dependency for a build item in the specified build list\r
+\r
+Arguments:\r
+  \r
+  BuildList   - build list where to search the dependency\r
+  BuildItem   - build item to add the dependency\r
+  BaseName    - dependency module base name\r
+  AdjustIndex - Adjust BuildItem->Index when non-zero\r
+\r
+Returns:\r
+\r
+  Pointer to the newly added build dependency\r
+\r
+--*/\r
+{\r
+  BUILD_ITEM       *TempBuildItem;\r
+  DEPENDENCY_ITEM  *NewDependency;\r
+  \r
+  //\r
+  // Search the dependency in the build list\r
+  //\r
+  TempBuildItem = BuildList;\r
+  while (TempBuildItem != NULL) {\r
+    if ((_stricmp (TempBuildItem->BaseName, BaseName) == 0) &&\r
+        (_stricmp (TempBuildItem->Processor, BuildItem->Processor) == 0) &&\r
+        (TempBuildItem != BuildItem)) {\r
+      break;\r
+    }\r
+    TempBuildItem = TempBuildItem->Next;\r
+  }\r
+  if (TempBuildItem == NULL) {\r
+    return NULL;\r
+  }\r
+  \r
+  //\r
+  // This index is used to isolate two modules with same base name and processor.\r
+  // (ProcessDsc allows duplicate base name libraries.)\r
+  //\r
+  if (AdjustIndex) {\r
+    BuildItem->Index = TempBuildItem->Index + 1;\r
+  }\r
+  \r
+  //\r
+  // Create a new build dependency item\r
+  //\r
+  NewDependency = malloc (sizeof (DEPENDENCY_ITEM));\r
+  if (NewDependency == NULL) {\r
+    return NULL;\r
+  }\r
+  memset (NewDependency, 0, sizeof (DEPENDENCY_ITEM));\r
+  NewDependency->Dependency  = TempBuildItem;\r
+  \r
+  //\r
+  // Add the build dependency item to the head of the dependency list\r
+  //\r
+  NewDependency->Next = BuildItem->DependencyList;\r
+  BuildItem->DependencyList = NewDependency;\r
+  \r
+  return NewDependency; \r
+}\r
+\r
+void\r
+FreeBuildList (\r
+  BUILD_ITEM  *BuildList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Free a build list\r
+\r
+Arguments:\r
+  \r
+  BuildList  - build list to be freed\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  BUILD_ITEM       *TempBuildItem;\r
+  BUILD_ITEM       *FreeBuildItem;\r
+  SOURCE_FILE_ITEM *TempSourceFile;\r
+  SOURCE_FILE_ITEM *FreeSourceFile;\r
+  DEPENDENCY_ITEM  *TempDependency;\r
+  DEPENDENCY_ITEM  *FreeDependency;\r
+  \r
+  TempBuildItem = BuildList;\r
+  while (TempBuildItem != NULL) {\r
+    free (TempBuildItem->BaseName);\r
+    free (TempBuildItem->Processor);\r
+    free (TempBuildItem->Makefile);\r
+\r
+    //\r
+    // Free source file list\r
+    //\r
+    TempSourceFile = TempBuildItem->SourceFileList;\r
+    while (TempSourceFile != NULL) {\r
+      FreeSourceFile = TempSourceFile;\r
+      TempSourceFile = TempSourceFile->Next;\r
+      free (FreeSourceFile);\r
+    }\r
+\r
+    //\r
+    // Free dependency list\r
+    //\r
+    TempDependency = TempBuildItem->DependencyList;\r
+    while (TempDependency != NULL) {\r
+      FreeDependency = TempDependency;\r
+      TempDependency = TempDependency->Next;\r
+      free (FreeDependency);\r
+    }\r
+\r
+    FreeBuildItem = TempBuildItem;\r
+    TempBuildItem = TempBuildItem->Next;\r
+    free (FreeBuildItem);\r
+  }\r
+}\r
+\r
+COMPONENTS_ITEM *\r
+AddComponentsItem (\r
+  COMPONENTS_ITEM  **ComponentsList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Add a new components item to a specified components list\r
+\r
+Arguments:\r
+  \r
+  ComponentsList  - components list where the new components item will be added\r
+\r
+Returns:\r
+\r
+  Pointer to the newly added components item\r
+\r
+--*/\r
+{\r
+  COMPONENTS_ITEM  *NewComponents;\r
+  COMPONENTS_ITEM  *TempComponents;\r
+  \r
+  //\r
+  // Create a new components item\r
+  //\r
+  NewComponents = malloc (sizeof (COMPONENTS_ITEM));\r
+  if (NewComponents == NULL) {\r
+    return NULL;\r
+  }\r
+  memset (NewComponents, 0, sizeof (COMPONENTS_ITEM));\r
+  \r
+  //\r
+  // Add the components item to the tail of the components list\r
+  //\r
+  TempComponents = *ComponentsList;\r
+  if (TempComponents == NULL) {\r
+    *ComponentsList = NewComponents;\r
+  } else {\r
+    while (TempComponents->Next != NULL) {\r
+      TempComponents = TempComponents->Next;\r
+    }\r
+    TempComponents->Next = NewComponents;\r
+  }\r
+  \r
+  return NewComponents;\r
+}\r
+\r
+void\r
+FreeComponentsList (\r
+  COMPONENTS_ITEM  *ComponentsList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Free a components list\r
+\r
+Arguments:\r
+  \r
+  ComponentsList  - components list to be freed\r
+\r
+Returns:\r
+\r
+--*/\r
+{\r
+  COMPONENTS_ITEM  *TempComponents;\r
+  COMPONENTS_ITEM  *FreeComponents;\r
+  \r
+  TempComponents = ComponentsList;\r
+  while (TempComponents != NULL) {\r
+    FreeBuildList (TempComponents->BuildList);\r
+    FreeComponents = TempComponents;\r
+    TempComponents = TempComponents->Next;\r
+    free (FreeComponents);\r
+  }\r
+}\r
+\r
+//\r
+// Module globals for multi-thread build\r
+//\r
+static INT8             mError;            // non-zero means error occurred\r
+static INT8             mDone;             // non-zero means no more build items available for build\r
+static UINT32           mThreadNumber;     // thread number\r
+static INT8             *mBuildDir;        // build directory\r
+static INT8             mLogDir[MAX_PATH]; // build item log dir\r
+static CRITICAL_SECTION mCriticalSection;  // critical section object\r
+static HANDLE           mSemaphoreHandle;  // semaphore for "ready for build" items in mWaitingList\r
+static HANDLE           mEventHandle;      // event signaled when one build item is finished\r
+static BUILD_ITEM       *mPendingList;     // build list for build items which are not ready for build\r
+static BUILD_ITEM       *mWaitingList;     // build list for build items which are ready for build\r
+static BUILD_ITEM       *mBuildingList;    // build list for build items which are buiding\r
+static BUILD_ITEM       *mDoneList;        // build list for build items which already finish the build\r
+\r
+//\r
+// Restore the BuildList (not care about the sequence of the build items)\r
+//\r
+static void\r
+RestoreBuildList (\r
+  BUILD_ITEM  **BuildList\r
+  )\r
+{\r
+  BUILD_ITEM  *TempBuildItem;\r
+  \r
+  if (mPendingList != NULL) {\r
+    //\r
+    // Add the mPendingList to the header of *BuildList\r
+    //\r
+    TempBuildItem = mPendingList;\r
+    while (TempBuildItem->Next != NULL) {\r
+      TempBuildItem = TempBuildItem->Next;\r
+    }\r
+    TempBuildItem->Next = *BuildList;\r
+    *BuildList = mPendingList;\r
+  }\r
+\r
+  if (mWaitingList != NULL) {\r
+    //\r
+    // Add the mWaitingList to the header of *BuildList\r
+    //\r
+    TempBuildItem = mWaitingList;\r
+    while (TempBuildItem->Next != NULL) {\r
+      TempBuildItem = TempBuildItem->Next;\r
+    }\r
+    TempBuildItem->Next = *BuildList;\r
+    *BuildList = mWaitingList;\r
+  }\r
+\r
+  if (mBuildingList != NULL) {\r
+    //\r
+    // Add the mBuildingList to the header of *BuildList\r
+    //\r
+    TempBuildItem = mBuildingList;\r
+    while (TempBuildItem->Next != NULL) {\r
+      TempBuildItem = TempBuildItem->Next;\r
+    }\r
+    TempBuildItem->Next = *BuildList;\r
+    *BuildList = mBuildingList;\r
+  }\r
+\r
+  if (mDoneList != NULL) {\r
+    //\r
+    // Add the mDoneList to the header of *BuildList\r
+    //\r
+    TempBuildItem = mDoneList;\r
+    while (TempBuildItem->Next != NULL) {\r
+      TempBuildItem = TempBuildItem->Next;\r
+    }\r
+    TempBuildItem->Next = *BuildList;\r
+    *BuildList = mDoneList;\r
+  }\r
+}\r
+\r
+//\r
+// Return non-zero when no source file build conflict\r
+//\r
+static INT8\r
+CheckSourceFile (\r
+  SOURCE_FILE_ITEM  *SourceFileList\r
+  )\r
+{\r
+  BUILD_ITEM        *TempBuildItem;\r
+  SOURCE_FILE_ITEM  *TempSourceFile;\r
+  \r
+  while (SourceFileList != NULL) {\r
+    TempBuildItem = mBuildingList;\r
+    while (TempBuildItem != NULL) {\r
+      TempSourceFile = TempBuildItem->SourceFileList;\r
+      while (TempSourceFile != NULL) {\r
+        if (_stricmp (SourceFileList->FileName, TempSourceFile->FileName) == 0) {\r
+          return 0;\r
+        }\r
+        TempSourceFile = TempSourceFile->Next;\r
+      }\r
+      TempBuildItem = TempBuildItem->Next;\r
+    }\r
+    SourceFileList = SourceFileList->Next;\r
+  }\r
+  \r
+  return 1;\r
+}\r
+\r
+//\r
+// Return non-zero when all the dependency build items has been built\r
+//\r
+static INT8\r
+CheckDependency (\r
+  DEPENDENCY_ITEM  *DependencyList\r
+  )\r
+{\r
+  while (DependencyList != NULL) {\r
+    if (!(DependencyList->Dependency->CompleteFlag)) {\r
+      return 0;\r
+    }\r
+    DependencyList = DependencyList->Next;\r
+  }\r
+  \r
+  return 1;\r
+}\r
+\r
+//\r
+// Run the build task. The system() function call  will cause stdout conflict \r
+// in multi-thread envroment, so implement this through CreateProcess().\r
+//\r
+static INT8\r
+RunBuildTask (\r
+  INT8  *WorkingDir, \r
+  INT8  *LogFile, \r
+  INT8  *BuildCmd\r
+  )\r
+{\r
+  HANDLE                FileHandle;\r
+  SECURITY_ATTRIBUTES   SecAttr;\r
+  PROCESS_INFORMATION   ProcInfo; \r
+  STARTUPINFO           StartInfo;\r
+  BOOL                  FuncRetn;\r
+  DWORD                 ExitCode;\r
+  \r
+  //\r
+  // Init SecAttr\r
+  //\r
+  SecAttr.nLength              = sizeof (SECURITY_ATTRIBUTES); \r
+  SecAttr.bInheritHandle       = TRUE; \r
+  SecAttr.lpSecurityDescriptor = NULL;\r
+  \r
+  //\r
+  // Create the log file\r
+  //\r
+  FileHandle = CreateFile (\r
+                 LogFile,                // file to create\r
+                 GENERIC_WRITE,          // open for writing\r
+                 0,                      // do not share\r
+                 &SecAttr,               // can be inherited by child processes\r
+                 CREATE_ALWAYS,          // overwrite existing\r
+                 FILE_ATTRIBUTE_NORMAL,  // normal file\r
+                 NULL                    // no attr. template\r
+                 );\r
+\r
+  if (FileHandle == INVALID_HANDLE_VALUE) { \r
+      EnterCriticalSection (&mCriticalSection);\r
+      Error (NULL, 0, 0, NULL, "could not open file %s", LogFile);\r
+      LeaveCriticalSection (&mCriticalSection);\r
+      return 1;\r
+  }\r
+  \r
+  //\r
+  // Init ProcInfo and StartInfo\r
+  //\r
+  ZeroMemory (&ProcInfo, sizeof (PROCESS_INFORMATION));\r
+  ZeroMemory (&StartInfo, sizeof (STARTUPINFO));\r
+  StartInfo.cb         = sizeof (STARTUPINFO); \r
+  StartInfo.hStdError  = FileHandle;\r
+  StartInfo.hStdOutput = FileHandle;\r
+  StartInfo.hStdInput  = GetStdHandle (STD_INPUT_HANDLE);\r
+  StartInfo.dwFlags    = STARTF_USESTDHANDLES;\r
+\r
+  //\r
+  // Create the child process\r
+  //\r
+  FuncRetn = CreateProcess (\r
+               NULL,          // no application name\r
+               BuildCmd,      // command line \r
+               NULL,          // process security attributes \r
+               NULL,          // primary thread security attributes \r
+               TRUE,          // handles are inherited \r
+               0,             // creation flags \r
+               NULL,          // use parent's environment \r
+               WorkingDir,    // set current directory \r
+               &StartInfo,    // STARTUPINFO pointer \r
+               &ProcInfo      // receives PROCESS_INFORMATION \r
+               );\r
+  \r
+  if (FuncRetn == FALSE) {\r
+    EnterCriticalSection (&mCriticalSection);\r
+    Error (NULL, 0, 0, NULL, "could not create child process");\r
+    LeaveCriticalSection (&mCriticalSection);\r
+    CloseHandle (FileHandle);\r
+    return 1;\r
+  } \r
+  \r
+  //\r
+  // Wait until child process exits\r
+  //\r
+  WaitForSingleObject (ProcInfo.hProcess, INFINITE);\r
+  GetExitCodeProcess (ProcInfo.hProcess, &ExitCode);\r
+  CloseHandle (ProcInfo.hProcess);\r
+  CloseHandle (ProcInfo.hThread);\r
+  CloseHandle (FileHandle);\r
+  \r
+  if (ExitCode != 0) {\r
+    return 1;\r
+  } else {\r
+    return 0;\r
+  }\r
+}\r
+\r
+//\r
+// Thread function\r
+//\r
+static DWORD WINAPI\r
+ThreadProc (\r
+  LPVOID lpParam\r
+  )\r
+{\r
+  UINT32      ThreadId;\r
+  BUILD_ITEM  *PreviousBuildItem;\r
+  BUILD_ITEM  *CurrentBuildItem;\r
+  BUILD_ITEM  *NextBuildItem;\r
+  INT8        WorkingDir[MAX_PATH];  \r
+  INT8        LogFile[MAX_PATH];\r
+  INT8        BuildCmd[MAX_PATH];\r
+  \r
+  ThreadId = (UINT32)lpParam;\r
+  //\r
+  // Loop until error occurred or no more build items available for build\r
+  //\r
+  for (;;) {\r
+    WaitForSingleObject (mSemaphoreHandle, INFINITE);\r
+    if (mError || mDone) {\r
+      return 0;\r
+    }\r
+    \r
+    //\r
+    // When code runs here, there must have one build item available for this \r
+    // thread. Loop until error occurred or get one build item for build.\r
+    //\r
+    for (;;) {\r
+      EnterCriticalSection (&mCriticalSection);\r
+      PreviousBuildItem = NULL;\r
+      CurrentBuildItem  = mWaitingList;\r
+      while (CurrentBuildItem != NULL) {\r
+        NextBuildItem = CurrentBuildItem->Next;\r
+        //\r
+        // CheckSourceFile() is to avoid concurrently build the same source file\r
+        // which may cause the muti-thread build failure\r
+        //\r
+        if (CheckSourceFile (CurrentBuildItem->SourceFileList)) {\r
+          //\r
+          // Move the current build item from mWaitingList\r
+          //\r
+          if (PreviousBuildItem != NULL) {\r
+            PreviousBuildItem->Next = NextBuildItem;\r
+          } else {\r
+            mWaitingList = NextBuildItem;\r
+          }\r
+          //\r
+          // Add the current build item to the head of mBuildingList\r
+          //\r
+          CurrentBuildItem->Next = mBuildingList;\r
+          mBuildingList = CurrentBuildItem;\r
+          //\r
+          // If no more build items is pending or waiting for build,\r
+          // wake up every child thread for exit.\r
+          //\r
+          if ((mPendingList == NULL) && (mWaitingList == NULL)) {\r
+            mDone = 1;\r
+            //\r
+            // Make sure to wake up every child thread for exit\r
+            //        \r
+            ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);\r
+          }\r
+          break;\r
+        }\r
+        PreviousBuildItem = CurrentBuildItem;\r
+        CurrentBuildItem  = NextBuildItem;\r
+      }\r
+      if (CurrentBuildItem != NULL) {\r
+        //\r
+        // Display build item info\r
+        //\r
+        printf ("\t[Thread_%d] nmake -nologo -f %s all\n", ThreadId, CurrentBuildItem->Makefile);\r
+        //\r
+        // Prepare build task\r
+        //\r
+        sprintf (WorkingDir, "%s\\%s", mBuildDir, CurrentBuildItem->Processor);\r
+        sprintf (LogFile, "%s\\%s_%s_%d.txt", mLogDir, CurrentBuildItem->BaseName, \r
+                 CurrentBuildItem->Processor, CurrentBuildItem->Index);\r
+        sprintf (BuildCmd, "nmake -nologo -f %s all", CurrentBuildItem->Makefile);\r
+        LeaveCriticalSection (&mCriticalSection);\r
+        break;\r
+      } else {\r
+        LeaveCriticalSection (&mCriticalSection);\r
+        //\r
+        // All the build items in mWaitingList have source file conflict with \r
+        // mBuildingList. This rarely hapeens. Need wait for the build items in\r
+        // mBuildingList to be finished by other child threads.\r
+        //\r
+        Sleep (1000);\r
+        if (mError) {\r
+          return 0;\r
+        }\r
+      }\r
+    }\r
+    \r
+    //\r
+    // Start to build the CurrentBuildItem\r
+    //\r
+    if (RunBuildTask (WorkingDir, LogFile, BuildCmd)) {\r
+      //\r
+      // Build failure\r
+      //\r
+      mError = 1;\r
+      //\r
+      // Make sure to wake up every child thread for exit\r
+      //\r
+      ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);\r
+      SetEvent(mEventHandle);\r
+\r
+      return mError;\r
+    } else {\r
+      //\r
+      // Build success\r
+      //\r
+      CurrentBuildItem->CompleteFlag = 1;\r
+      \r
+      EnterCriticalSection (&mCriticalSection);\r
+      //\r
+      // Move this build item from mBuildingList\r
+      //\r
+      if (mBuildingList == CurrentBuildItem) {\r
+        mBuildingList = mBuildingList->Next;\r
+      } else {\r
+        NextBuildItem = mBuildingList;\r
+        while (NextBuildItem->Next != CurrentBuildItem) {\r
+          NextBuildItem = NextBuildItem->Next;\r
+        }\r
+        NextBuildItem->Next = CurrentBuildItem->Next;\r
+      }\r
+      //\r
+      // Add this build item to mDoneList\r
+      //\r
+      CurrentBuildItem->Next = mDoneList;\r
+      mDoneList = CurrentBuildItem;\r
+      LeaveCriticalSection (&mCriticalSection);\r
+      \r
+      SetEvent(mEventHandle);\r
+    }\r
+  }\r
+}\r
+\r
+INT8\r
+StartMultiThreadBuild (\r
+  BUILD_ITEM  **BuildList,\r
+  UINT32      ThreadNumber,\r
+  INT8        *BuildDir\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+  \r
+  Start multi-thread build for a specified build list\r
+\r
+Arguments:\r
+  \r
+  BuildList     - build list for multi-thread build\r
+  ThreadNumber  - thread number for multi-thread build\r
+  BuildDir      - build dir\r
+\r
+Returns:\r
+\r
+  0             - Successfully finished the multi-thread build\r
+  other value   - Build failure\r
+\r
+--*/\r
+{\r
+  UINT32        Index;\r
+  UINT32        Count;\r
+  BUILD_ITEM    *PreviousBuildItem;\r
+  BUILD_ITEM    *CurrentBuildItem;\r
+  BUILD_ITEM    *NextBuildItem;\r
+  HANDLE        *ThreadHandle;\r
+  INT8          Cmd[MAX_PATH];\r
+  \r
+  mError        = 0;\r
+  mDone         = 0;\r
+  mThreadNumber = ThreadNumber;\r
+  mBuildDir     = BuildDir;\r
+  mPendingList  = *BuildList;\r
+  *BuildList    = NULL;\r
+  mWaitingList  = NULL;\r
+  mBuildingList = NULL;\r
+  mDoneList     = NULL;\r
+  \r
+  //\r
+  // Do nothing when mPendingList is empty\r
+  //\r
+  if (mPendingList == NULL) {\r
+    return 0;\r
+  }\r
+  \r
+  //\r
+  // Get build item count of mPendingList\r
+  //\r
+  Count = 0;\r
+  CurrentBuildItem = mPendingList;\r
+  while (CurrentBuildItem != NULL) {\r
+    Count++;\r
+    CurrentBuildItem = CurrentBuildItem->Next;\r
+  }\r
+  \r
+  //\r
+  // The semaphore is also used to wake up child threads for exit,\r
+  // so need to make sure "maximum count" >= "thread number".\r
+  //\r
+  if (Count < ThreadNumber) {\r
+    Count = ThreadNumber;\r
+  }\r
+  \r
+  //\r
+  // Init mSemaphoreHandle\r
+  //\r
+  mSemaphoreHandle = CreateSemaphore (\r
+                       NULL,       // default security attributes\r
+                       0,          // initial count\r
+                       Count,      // maximum count\r
+                       NULL        // unnamed semaphore\r
+                       );\r
+  if (mSemaphoreHandle == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to create semaphore");\r
+    RestoreBuildList (BuildList);\r
+    return 1;\r
+  }  \r
+\r
+  //\r
+  // Init mEventHandle\r
+  //\r
+  mEventHandle = CreateEvent( \r
+                   NULL,     // default security attributes\r
+                   FALSE,    // auto-reset event\r
+                   TRUE,     // initial state is signaled\r
+                   NULL      // object not named\r
+                   ); \r
+  if (mEventHandle == NULL) { \r
+    Error (NULL, 0, 0, NULL, "failed to create event");\r
+    CloseHandle (mSemaphoreHandle);\r
+    RestoreBuildList (BuildList);\r
+    return 1;\r
+  }\r
+  \r
+  //\r
+  // Init mCriticalSection\r
+  //\r
+  InitializeCriticalSection (&mCriticalSection);\r
+  \r
+  //\r
+  // Create build item log dir\r
+  //\r
+  sprintf (mLogDir, "%s\\Log", mBuildDir);\r
+  _mkdir (mLogDir);\r
+  \r
+  //\r
+  // Create child threads for muti-thread build\r
+  //\r
+  ThreadHandle = malloc (ThreadNumber * sizeof (HANDLE));\r
+  if (ThreadHandle == NULL) {\r
+    Error (NULL, 0, 0, NULL, "failed to allocate memory");\r
+    CloseHandle (mSemaphoreHandle);\r
+    CloseHandle (mEventHandle);\r
+    RestoreBuildList (BuildList);\r
+    return 1;\r
+  }\r
+  for (Index = 0; Index < ThreadNumber; Index++) {\r
+    ThreadHandle[Index] = CreateThread (\r
+                            NULL,           // default security attributes\r
+                            0,              // use default stack size\r
+                            ThreadProc,     // thread function\r
+                            (LPVOID)Index,  // argument to thread function: use Index as thread id\r
+                            0,              // use default creation flags\r
+                            NULL            // thread identifier not needed\r
+                            );\r
+    if (ThreadHandle[Index] == NULL) {\r
+      Error (NULL, 0, 0, NULL, "failed to create Thread_%d", Index);\r
+      mError       = 1;\r
+      ThreadNumber = Index;\r
+      //\r
+      // Make sure to wake up every child thread for exit\r
+      //\r
+      ReleaseSemaphore (mSemaphoreHandle, ThreadNumber, NULL);\r
+      break;\r
+    }\r
+  }\r
+  \r
+  //\r
+  // Loop until error occurred or no more build items pending for build\r
+  //\r
+  for (;;) {\r
+    WaitForSingleObject (mEventHandle, INFINITE);\r
+    if (mError) {\r
+      break;\r
+    }\r
+    Count = 0;\r
+    \r
+    EnterCriticalSection (&mCriticalSection);\r
+    PreviousBuildItem = NULL;\r
+    CurrentBuildItem  = mPendingList;\r
+    while (CurrentBuildItem != NULL) {\r
+      NextBuildItem = CurrentBuildItem->Next;\r
+      if (CheckDependency (CurrentBuildItem->DependencyList)) {\r
+        //\r
+        // Move the current build item from mPendingList\r
+        //\r
+        if (PreviousBuildItem != NULL) {\r
+          PreviousBuildItem->Next = NextBuildItem;\r
+        } else {\r
+          mPendingList = NextBuildItem;\r
+        }\r
+        //\r
+        // Add the current build item to the head of mWaitingList\r
+        //\r
+        CurrentBuildItem->Next = mWaitingList;\r
+        mWaitingList = CurrentBuildItem;\r
+        Count++;\r
+      } else {\r
+        PreviousBuildItem = CurrentBuildItem;\r
+      }\r
+      CurrentBuildItem  = NextBuildItem;\r
+    }\r
+    LeaveCriticalSection (&mCriticalSection);\r
+    \r
+    ReleaseSemaphore (mSemaphoreHandle, Count, NULL);\r
+    if (mPendingList == NULL) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Wait until all threads have terminated\r
+  //\r
+  WaitForMultipleObjects (ThreadNumber, ThreadHandle, TRUE, INFINITE);\r
+  \r
+  if (mError && (mBuildingList != NULL)) {\r
+    //\r
+    // Dump build failure log of the first build item which doesn't finish the build\r
+    //\r
+    printf ("\tnmake -nologo -f %s all\n", mBuildingList->Makefile);\r
+    sprintf (Cmd, "type %s\\%s_%s_%d.txt 2>NUL", mLogDir, mBuildingList->BaseName,\r
+             mBuildingList->Processor, mBuildingList->Index);\r
+    _flushall ();\r
+    if (system (Cmd)) {\r
+      Error (NULL, 0, 0, NULL, "failed to run \"%s\"", Cmd);\r
+    }\r
+  }\r
+\r
+  DeleteCriticalSection (&mCriticalSection);\r
+  for (Index = 0; Index < ThreadNumber; Index++) {\r
+    CloseHandle (ThreadHandle[Index]);\r
+  }\r
+  free (ThreadHandle);\r
+  CloseHandle (mSemaphoreHandle);\r
+  CloseHandle (mEventHandle);\r
+  RestoreBuildList (BuildList);\r
+\r
+  return mError;\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
new file mode 100644 (file)
index 0000000..7a5566a
--- /dev/null
@@ -0,0 +1,116 @@
+/*++\r
+\r
+Copyright (c) 2008 - 2010, 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+Module Name:  \r
+\r
+  MultiThread.h\r
+  \r
+Abstract:\r
+\r
+  Defines and function prototypes for the ProcessDsc utility.\r
+  \r
+--*/\r
+\r
+#ifndef _MULTI_THREAD_H_\r
+#define _MULTI_THREAD_H_\r
+\r
+typedef struct _COMPONENTS_ITEM  COMPONENTS_ITEM;\r
+typedef struct _BUILD_ITEM       BUILD_ITEM;\r
+typedef struct _SOURCE_FILE_ITEM SOURCE_FILE_ITEM;\r
+typedef struct _DEPENDENCY_ITEM  DEPENDENCY_ITEM;\r
+\r
+//\r
+// Use this structure to keep track of module build items\r
+//\r
+typedef struct _BUILD_ITEM {\r
+  BUILD_ITEM        *Next;\r
+  INT8              *BaseName;\r
+  INT8              *Processor;\r
+  INT8              *Makefile;\r
+  UINT32            Index;\r
+  UINT32            CompleteFlag;\r
+  SOURCE_FILE_ITEM  *SourceFileList;\r
+  DEPENDENCY_ITEM   *DependencyList;\r
+} BUILD_ITEM;\r
+\r
+//\r
+// Use this structure to keep track of module source files\r
+//\r
+typedef struct _SOURCE_FILE_ITEM {\r
+  SOURCE_FILE_ITEM  *Next;\r
+  INT8              *FileName;\r
+} SOURCE_FILE_ITEM;\r
+\r
+//\r
+// Use this structure to keep track of module build dependencies\r
+//\r
+typedef struct _DEPENDENCY_ITEM {\r
+  DEPENDENCY_ITEM   *Next;\r
+  BUILD_ITEM        *Dependency;\r
+} DEPENDENCY_ITEM;\r
+\r
+//\r
+// Use this structure to keep track of [components] and [components.n] sections\r
+//\r
+typedef struct _COMPONENTS_ITEM {\r
+  COMPONENTS_ITEM   *Next;\r
+  BUILD_ITEM        *BuildList;\r
+} COMPONENTS_ITEM;\r
+\r
+//\r
+// Function prototypes\r
+//\r
+BUILD_ITEM *\r
+AddBuildItem (\r
+  BUILD_ITEM  **BuildList,\r
+  INT8        *BaseName,\r
+  INT8        *Processor,\r
+  INT8        *Makefile\r
+  );\r
+\r
+\r
+SOURCE_FILE_ITEM *\r
+AddSourceFile (\r
+  BUILD_ITEM  *BuildItem, \r
+  INT8        *FileName\r
+  );\r
+\r
+DEPENDENCY_ITEM *\r
+AddDependency (\r
+  BUILD_ITEM  *BuildList, \r
+  BUILD_ITEM  *BuildItem, \r
+  INT8        *BaseName,\r
+  INT8        AdjustIndex\r
+  );\r
+\r
+void\r
+FreeBuildList (\r
+  BUILD_ITEM  *BuildList\r
+  );\r
+\r
+COMPONENTS_ITEM *\r
+AddComponentsItem (\r
+  COMPONENTS_ITEM  **ComponentsList\r
+  );\r
+\r
+void\r
+FreeComponentsList (\r
+  COMPONENTS_ITEM  *ComponentsList\r
+  );\r
+  \r
+INT8\r
+StartMultiThreadBuild (\r
+  BUILD_ITEM  **BuildList,\r
+  UINT32      ThreadNumber,\r
+  INT8        *BuildDir\r
+  );\r
+\r
+#endif // ifndef _MULTI_THREAD_H_\r
index 20faf6f69f9443505efbfd25d642969cabdb9f12..5f64bf5685fc8a45a3500281c29b114811fcaae1 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -27,25 +27,18 @@ Abstract:
 #include <direct.h>   // for _mkdir()\r
 #include <errno.h>\r
 #include <stdlib.h>   // for getenv()\r
+#include <shlwapi.h>  // for PathCanonicalize()\r
 #include "DSCFile.h"\r
+#include "MultiThread.h"\r
 #include "FWVolume.h"\r
 #include "Exceptions.h"\r
 #include "Common.h"\r
 \r
 #include "EfiUtilityMsgs.h"\r
 #include "TianoBind.h"\r
-//\r
-// Disable warning for while(1) code\r
-//\r
-#pragma warning(disable : 4127)\r
-//\r
-// Disable warning for unreferenced function parameters\r
-//\r
-#pragma warning(disable : 4100)\r
-\r
-extern int  errno;\r
 \r
-#define PROGRAM_NAME  "ProcessDsc"\r
+#define UTILITY_NAME    "ProcessDsc"\r
+#define UTILITY_VERSION "v1.0"\r
 \r
 //\r
 // Common symbol name definitions. For example, the user can reference\r
@@ -220,25 +213,39 @@ typedef struct _SYMBOL {
 } SYMBOL;\r
 \r
 //\r
-// Define new SYMBOL list to record all module name used in the platform.dsc file.\r
+// Module globals for multi-thread build\r
 //\r
-SYMBOL *gModuleList = NULL;\r
+static BUILD_ITEM  **mCurrentBuildList;          // build list currently handling\r
+static BUILD_ITEM  *mCurrentBuildItem;           // build item currently handling\r
+\r
+//\r
+// Define masks for the build targets\r
+//\r
+#define BUILD_TARGET_COMPONENTS 0x01\r
+#define BUILD_TARGET_LIBRARIES  0x02\r
+#define BUILD_TARGET_FVS        0x04\r
+#define BUILD_TARGET_ALL        0xff\r
+\r
 \r
 //\r
 // This structure is used to save globals\r
 //\r
 struct {\r
-  INT8    *DscFilename;\r
-  SYMBOL  *Symbol;\r
-  INT8    MakefileName[MAX_PATH]; // output makefile name\r
-  INT8    XRefFileName[MAX_PATH];\r
-  INT8    GuidDatabaseFileName[MAX_PATH];\r
-  INT8    ModuleMakefileName[MAX_PATH];\r
-  FILE    *MakefileFptr;\r
-  FILE    *ModuleMakefileFptr;\r
-  SYMBOL  *ModuleList;\r
-  SYMBOL  *OutdirList;\r
-  UINT32  Verbose;\r
+  INT8                *DscFilename;\r
+  SYMBOL              *Symbol;\r
+  INT8                MakefileName[MAX_PATH]; // output makefile name\r
+  INT8                XRefFileName[MAX_PATH];\r
+  INT8                GuidDatabaseFileName[MAX_PATH];\r
+  INT8                ModuleMakefileName[MAX_PATH];\r
+  FILE                *MakefileFptr;\r
+  FILE                *ModuleMakefileFptr;\r
+  SYMBOL              *ModuleList;\r
+  SYMBOL              *OutdirList;\r
+  UINT32              Verbose;\r
+  UINT32              ThreadNumber;\r
+  UINT32              BuildTarget;\r
+  BUILD_ITEM          *LibraryList;\r
+  COMPONENTS_ITEM     *ComponentsList;\r
 } gGlobals;\r
 \r
 //\r
@@ -584,16 +591,18 @@ Returns:
 \r
 --*/\r
 {\r
-  int       i;\r
-  DSC_FILE  DSCFile;\r
-  SECTION   *Sect;\r
-  INT8      Line[MAX_LINE_LEN];\r
-  INT8      ExpLine[MAX_LINE_LEN];\r
-  INT8      *EMsg;\r
-  FILE      *FpModule;\r
-  SYMBOL    *TempSymbol;\r
-\r
-  SetUtilityName (PROGRAM_NAME);\r
+  int                   i;\r
+  DSC_FILE              DSCFile;\r
+  SECTION               *Sect;\r
+  INT8                  Line[MAX_LINE_LEN];\r
+  INT8                  ExpLine[MAX_LINE_LEN];\r
+  INT8                  *BuildDir;\r
+  INT8                  *EMsg;\r
+  FILE                  *FpModule;\r
+  SYMBOL                *TempSymbol;\r
+  COMPONENTS_ITEM       *TempComponents;\r
+\r
+  SetUtilityName (UTILITY_NAME);\r
 \r
   InitExceptions ();\r
 \r
@@ -710,6 +719,7 @@ Returns:
   //\r
   Sect = DSCFileFindSection (&DSCFile, LIBRARIES_SECTION_NAME);\r
   if (Sect != NULL) {\r
+    mCurrentBuildList = &gGlobals.LibraryList;\r
     ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_LIBRARIES, 0);\r
   }\r
 \r
@@ -721,6 +731,7 @@ Returns:
   //\r
   Sect = DSCFileFindSection (&DSCFile, LIBRARIES_PLATFORM_SECTION_NAME);\r
   if (Sect != NULL) {\r
+    mCurrentBuildList = &gGlobals.LibraryList;\r
     ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_PLATFORM_LIBRARIES, 0);\r
   }\r
 \r
@@ -735,6 +746,8 @@ Returns:
   Sect = DSCFileFindSection (&DSCFile, COMPONENTS_SECTION_NAME);\r
   if (Sect != NULL) {\r
     fprintf (gGlobals.MakefileFptr, "components_0 : \n");\r
+    TempComponents    = AddComponentsItem (&gGlobals.ComponentsList);\r
+    mCurrentBuildList = &TempComponents->BuildList;\r
     ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, 0);\r
     fprintf (gGlobals.MakefileFptr, "\n");\r
   }\r
@@ -754,6 +767,8 @@ Returns:
     Sect = DSCFileFindSection (&DSCFile, Line);\r
     if (Sect != NULL) {\r
       fprintf (gGlobals.MakefileFptr, "components_%d : \n", i);\r
+      TempComponents    = AddComponentsItem (&gGlobals.ComponentsList);\r
+      mCurrentBuildList = &TempComponents->BuildList;\r
       ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, i);\r
       fprintf (gGlobals.MakefileFptr, "\n");\r
     } else {\r
@@ -807,12 +822,52 @@ ProcessingError:
     fclose (gGlobals.ModuleMakefileFptr);\r
     gGlobals.ModuleMakefileFptr = NULL;\r
   }\r
-    \r
+  \r
+  //\r
+  // Start multi-thread build if ThreadNumber is specified and no error status\r
+  //\r
+  if ((gGlobals.ThreadNumber != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
+    BuildDir = GetSymbolValue (BUILD_DIR);\r
+    if (gGlobals.BuildTarget & BUILD_TARGET_LIBRARIES) {\r
+      if (StartMultiThreadBuild (&gGlobals.LibraryList, gGlobals.ThreadNumber, BuildDir) != 0) {\r
+        Error (NULL, 0, 0, NULL, "Multi-thread build libraries failure");\r
+        goto Cleanup;\r
+      }\r
+    }\r
+    i = 0;\r
+    TempComponents = gGlobals.ComponentsList;\r
+    while (TempComponents != NULL) {\r
+      if (gGlobals.BuildTarget & BUILD_TARGET_COMPONENTS) {\r
+        if (StartMultiThreadBuild (&TempComponents->BuildList, gGlobals.ThreadNumber, BuildDir) != 0) {\r
+          Error (NULL, 0, 0, NULL, "Multi-thread build components %d failure", i);\r
+          goto Cleanup;\r
+        }\r
+      }\r
+      if (gGlobals.BuildTarget & BUILD_TARGET_FVS) {\r
+        sprintf (ExpLine, "nmake -nologo -f %s fvs_%d", gGlobals.MakefileName, i);\r
+        _flushall ();\r
+        if (system (ExpLine)) {\r
+          Error (NULL, 0, 0, NULL, "Build FVs for components %d failure", i);\r
+          goto Cleanup;\r
+        }\r
+      }\r
+      i++;\r
+      TempComponents = TempComponents->Next;\r
+    }\r
+  }\r
+\r
+Cleanup:    \r
   //\r
   // Clean up\r
   //\r
+  FreeBuildList (gGlobals.LibraryList);\r
+  gGlobals.LibraryList = NULL;\r
+  FreeComponentsList (gGlobals.ComponentsList);\r
+  gGlobals.ComponentsList = NULL;\r
   FreeSymbols (gGlobals.ModuleList);\r
+  gGlobals.ModuleList = NULL;\r
   FreeSymbols (gGlobals.OutdirList);\r
+  gGlobals.OutdirList = NULL;\r
   FreeSymbols (gGlobals.Symbol);\r
   gGlobals.Symbol = NULL;\r
   CFVDestructor ();\r
@@ -1311,6 +1366,16 @@ Returns:
     CreatePackageFile (DSCFile);\r
   }\r
 \r
+  //\r
+  // Add a new build item to mCurrentBuildList\r
+  //\r
+  mCurrentBuildItem = AddBuildItem (mCurrentBuildList, GetSymbolValue (BASE_NAME), Processor, FileName);\r
+  //\r
+  // ProcessDsc allows duplicate base name libraries. Make sure the duplicate \r
+  // base name libraries will be built in the same order as listed in DSC file.\r
+  //\r
+  AddDependency (*mCurrentBuildList, mCurrentBuildItem, mCurrentBuildItem->BaseName, 1);\r
+\r
   //\r
   // Add Module name to the global module list\r
   //\r
@@ -1336,6 +1401,7 @@ Returns:
   // files in this component. This macro can then be used elsewhere to\r
   // process all the files making up the component. Required for scanning\r
   // files for string localization.\r
+  // Also add source files to mCurrentBuildItem.\r
   //\r
   ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_SOURCE_FILES);\r
   //\r
@@ -1370,7 +1436,8 @@ Returns:
   // Process all the libraries to define "LIBS = x.lib y.lib..."\r
   // Be generous and append ".lib" if they forgot.\r
   // Make a macro definition: LIBS = $(LIBS) xlib.lib ylib.lib...\r
-  // Also add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...\r
+  // Add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...\r
+  // Also add libs dependency to mCurrentBuildItem.\r
   //\r
   ProcessLibs (&ComponentFile, MakeFptr);\r
 \r
@@ -1829,8 +1896,14 @@ Returns:
   OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);\r
   if (OverridePath != NULL) {\r
     ReplaceSlash (OverridePath);\r
+    fprintf (MakeFptr, "!IF EXIST(%s)\n", OverridePath);\r
     fprintf (MakeFptr, "INC = $(INC) -I %s\n", OverridePath);\r
-    fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", OverridePath, Processor);\r
+    fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", OverridePath, Processor);\r
+    fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", OverridePath, Processor);\r
+    fprintf (MakeFptr, "!ENDIF\n");\r
+    fprintf (MakeFptr, "!ELSE\n");\r
+    fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", OverridePath);\r
+    fprintf (MakeFptr, "!ENDIF\n");\r
   }\r
   //\r
   // Try for an [includes.$(PROCESSOR).$(PLATFORM)]\r
@@ -1909,43 +1982,45 @@ ProcessIncludesSectionSingle (
           //\r
           if (Cptr[1] == 0) {\r
             fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\n");\r
-            fprintf (\r
-              MakeFptr,\r
-              "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",\r
-              Processor\r
-              );\r
+            fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Processor);\r
+            fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Processor);\r
+            fprintf (MakeFptr, "!ENDIF\n");\r
           } else {\r
             //\r
             // Handle case of ".\path\path\path" or "..\path\path\path"\r
             //\r
-            fprintf (\r
-              MakeFptr,\r
-              "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",\r
-              Cptr\r
-              );\r
-            fprintf (\r
-              MakeFptr,\r
-              "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s \n",\r
-              Cptr,\r
-              Processor\r
-              );\r
+            fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Cptr);\r
+            fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Cptr);\r
+            fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s\\%s)\n", Cptr, Processor);\r
+            fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s\n", Cptr, Processor);\r
+            fprintf (MakeFptr, "!ENDIF\n");\r
+            fprintf (MakeFptr, "!ELSE\n");\r
+            fprintf (MakeFptr, "!MESSAGE Warning: include dir $(SOURCE_DIR)\\%s does not exist\n", Cptr);\r
+            fprintf (MakeFptr, "!ENDIF\n");\r
           }\r
         } else if ((Cptr[1] != ':') && isalpha (*Cptr)) {\r
-          fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s \n", Cptr);\r
-          fprintf (\r
-            MakeFptr,\r
-            "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s \n",\r
-            Cptr,\r
-            Processor\r
-            );\r
+          fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s)\n", Cptr);\r
+          fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\n", Cptr);\r
+          fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s\\%s)\n", Cptr, Processor);\r
+          fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s\n", Cptr, Processor);\r
+          fprintf (MakeFptr, "!ENDIF\n");\r
+          fprintf (MakeFptr, "!ELSE\n");\r
+          fprintf (MakeFptr, "!MESSAGE Warning: include dir $(EFI_SOURCE)\\%s does not exist\n", Cptr);\r
+          fprintf (MakeFptr, "!ENDIF\n");\r
         } else {\r
           //\r
           // The line is something like: $(EFI_SOURCE)\dxe\include. Add it to\r
           // the existing $(INC) definition. Add user includes before any\r
           // other existing paths.\r
           //\r
-          fprintf (MakeFptr, "INC = $(INC) -I %s \n", Cptr);\r
-          fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", Cptr, Processor);\r
+          fprintf (MakeFptr, "!IF EXIST(%s)\n", Cptr);\r
+          fprintf (MakeFptr, "INC = $(INC) -I %s\n", Cptr);\r
+          fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", Cptr, Processor);\r
+          fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", Cptr, Processor);\r
+          fprintf (MakeFptr, "!ENDIF\n");\r
+          fprintf (MakeFptr, "!ELSE\n");\r
+          fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", Cptr);\r
+          fprintf (MakeFptr, "!ENDIF\n");\r
         }\r
       }\r
     }\r
@@ -2260,16 +2335,35 @@ ProcessSourceFilesSection (
             // SOURCE_FILES = $(SOURCE_FILES) c:\Path\ThisFile.c\r
             //\r
             fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", TempFileName);\r
+            //\r
+            // Save the source absolute path\r
+            //\r
+            if (PathCanonicalize (FilePath, TempFileName)) {\r
+              AddSourceFile (mCurrentBuildItem, FilePath);\r
+            }\r
           } else if (IsAbsolutePath (FileName)) {\r
             //\r
             // For Absolute path, don't print $(SOURCE_FILE) directory.\r
             //\r
             fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", FileName);\r
+            //\r
+            // Save the source absolute path\r
+            //\r
+            if (PathCanonicalize (FilePath, FileName)) {\r
+              AddSourceFile (mCurrentBuildItem, FilePath);\r
+            }\r
           } else {\r
             //\r
             // SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\ThisFile.c\r
             //\r
             fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\\%s\n", FileName);\r
+            //\r
+            // Save the source absolute path\r
+            //\r
+            sprintf (Str, "%s\\%s", GetSymbolValue (SOURCE_DIR), FileName);\r
+            if (PathCanonicalize (FilePath, Str)) {\r
+              AddSourceFile (mCurrentBuildItem, FilePath);\r
+            }\r
           }\r
         } else if (Mode & SOURCE_MODE_BUILD_COMMANDS) {\r
           //\r
@@ -2612,6 +2706,10 @@ ProcessLibsSingle (
           Cptr[strlen (Cptr) - 4] = 0;\r
           fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr);\r
         }\r
+        //\r
+        // Add libs dependency for mCurrentBuildItem \r
+        //\r
+        AddDependency (*mCurrentBuildList, mCurrentBuildItem, Cptr, 0);\r
       }\r
     }\r
   }\r
@@ -2767,8 +2865,9 @@ ProcessIncludeFilesSingle (
               if (Cptr >= TempFileName) {\r
                 *Cptr = 0;\r
               }\r
-\r
+              fprintf (MakeFptr, "!IF EXIST(%s)\n", TempFileName);\r
               fprintf (MakeFptr, "INC = -I %s $(INC)\n", TempFileName);\r
+              fprintf (MakeFptr, "!ENDIF\n");\r
             }\r
           }\r
           //\r
@@ -4173,6 +4272,63 @@ Returns:
         }\r
         break;\r
 \r
+      //\r
+      // Enable multi-thread build and specify the thread number\r
+      //\r
+      case 'n':\r
+      case 'N':\r
+        //\r
+        // Skip to next arg\r
+        //\r
+        Argc--;\r
+        Argv++;\r
+        if (Argc == 0) {\r
+          Argv--;\r
+          Error (NULL, 0, 0, Argv[0], "missing input thread number with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        } else {\r
+          gGlobals.ThreadNumber = atoi (Argv[0]);\r
+          if (gGlobals.ThreadNumber == 0) {\r
+            Argv--;\r
+            Error (NULL, 0, 0, Argv[0], "input thread number should not be %s", Argv[1]);\r
+            return STATUS_ERROR;\r
+          } else if (gGlobals.ThreadNumber > MAXIMUM_WAIT_OBJECTS) {\r
+            Argv--;\r
+            Error (NULL, 0, 0, Argv[0], "input thread number should not greater than %d", MAXIMUM_WAIT_OBJECTS);\r
+            return STATUS_ERROR;\r
+          }\r
+        }\r
+        break;\r
+\r
+      //\r
+      // Specify the multi-thread build target\r
+      //\r
+      case 't':\r
+      case 'T':\r
+        //\r
+        // Skip to next arg\r
+        //\r
+        Argc--;\r
+        Argv++;\r
+        if (Argc == 0) {\r
+          Argv--;\r
+          Error (NULL, 0, 0, Argv[0], "missing input build target with option");\r
+          Usage ();\r
+          return STATUS_ERROR;\r
+        } else if (_stricmp (Argv[0], "all") == 0) {\r
+          gGlobals.BuildTarget |= BUILD_TARGET_ALL;\r
+        } else if (_stricmp (Argv[0], "libraries") == 0) {\r
+          gGlobals.BuildTarget |= BUILD_TARGET_LIBRARIES;\r
+        } else if (_stricmp (Argv[0], "components") == 0) {\r
+          gGlobals.BuildTarget |= BUILD_TARGET_COMPONENTS;\r
+        } else {\r
+          Argv--;\r
+          Error (NULL, 0, 0, Argv[0], "input build target not supported");\r
+          Usage ();\r
+        }\r
+        break;\r
+\r
       case 'v':\r
       case 'V':\r
         gGlobals.Verbose = 1;\r
@@ -4228,7 +4384,14 @@ Returns:
   if (FreeCwd) {\r
     free (Cptr);\r
   }\r
-\r
+  \r
+  //\r
+  // Default build target is all\r
+  //\r
+  if (gGlobals.BuildTarget == 0) {\r
+    gGlobals.BuildTarget = BUILD_TARGET_ALL;\r
+  }\r
+  \r
   return 0;\r
 }\r
 \r
@@ -4426,18 +4589,29 @@ Usage (
   VOID\r
   )\r
 {\r
-  int               i;\r
-  static const INT8 *Help[] = {\r
-    "Usage:  ProcessDsc {options} [Dsc Filename]",\r
-    "    Options:",\r
-    "       -d var=value        to define symbol 'var' to 'value'",\r
-    "       -v                  for verbose mode",\r
-    "       -g filename         to preparse GUID listing file",\r
-    "       -x filename         to create a cross-reference file",\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Process DSC File Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION]... DSCFILE",\r
+    "Options:",\r
+    "  -d var=value        to define symbol 'var' to 'value'",\r
+    "  -v                  for verbose mode",\r
+    "  -g filename         to preparse GUID listing file",\r
+    "  -x filename         to create a cross-reference file",\r
+    "  -n threadnumber     to build with multi-thread",\r
+    "  -t target           to build the specified target:",\r
+    "                      all, libraries or components",\r
     NULL\r
   };\r
-  for (i = 0; Help[i] != NULL; i++) {\r
-    fprintf (stdout, "%s\n", Help[i]);\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
   }\r
 }\r
 \r
@@ -4562,7 +4736,7 @@ SmartOpen (
     if (SmartFile->FileContent != NULL) {\r
       memset (SmartFile->FileContent, 0, FileSize + 1);\r
       //\r
-      // Usually FileLength < FileSize, because in text mode, carriage return-linefeed\r
+      // Usually FileLength < FileSize, because in text mode, carriage return¨Clinefeed\r
       // combinations are translated into single linefeeds on input\r
       //       \r
       SmartFile->FileLength = fread (SmartFile->FileContent, sizeof(char), FileSize, Fptr);\r
index 866c6a45234db60b8d55e539db29b476c1d2a2c9..677797381027c04a241e7369ae5e94ae229991de 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -22,7 +22,8 @@ Abstract:
 #include <time.h>\r
 \r
 #define LINE_MAXLEN 80\r
-\r
+#define UTILITY_NAME    "SetStamp"\r
+#define UTILITY_VERSION "v1.0"\r
 void\r
 PrintUsage (\r
   void\r
@@ -38,10 +39,25 @@ Returns:
   None\r
 --*/\r
 {\r
-  //\r
-  // print usage of command\r
-  //\r
-  printf ("Usage: SetStamp <PE-File> <TIME-File>\n");\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Set Time Stamp Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" PEFILE TIMEFILE",\r
+    "Description:",\r
+    "  Set Date/Time Stamp of Portable Executable (PE) format file",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+  \r
 }\r
 \r
 int\r
index 74ac5a143c5d4e961686e4250bdd8daa6543e6a7..c0df181f63a97cddba2ecca2255cc88de1207d68 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2010, 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
@@ -21,6 +21,9 @@ Abstract:
 #include "string.h"\r
 #include "stdlib.h"\r
 \r
+#define UTILITY_NAME    "SplitFile"\r
+#define UTILITY_VERSION "v1.0"\r
+\r
 void\r
 helpmsg (\r
   void\r
@@ -40,11 +43,24 @@ Returns:
 \r
 --*/\r
 {\r
-  printf (\r
-    "SplitFile Filename Offset\n""   Filename = Input file to split\n""   Offset = offset at which to split file\n"\r
-    "\n\n""SplitFile will break a file in two pieces at the requested offset\n"\r
-    "  outputting Filename1 and Filename2\n"\r
-    );\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Split File Utility",\r
+    "  Copyright (C), 2006 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" FILE OFFSET",\r
+    "Description:",\r
+    "  Break the FILE in two pieces FILE1 and FILE2 at the requested OFFSET.",\r
+    NULL\r
+  };\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
 }\r
 \r
 int\r
index f830400b24fe98253f0d1ea567063eca959ef1f9..2d6d35bb885fc96e3bc080c8634dbd65ecc57e20 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -29,7 +29,8 @@ Abstract:
 #include "StrGather.h"\r
 #include "StringDB.h"\r
 \r
-#define TOOL_VERSION  "0.31"\r
+#define UTILITY_NAME     "StrGather"\r
+#define UTILITY_VERSION  "v1.0"\r
 \r
 typedef UINT16  WCHAR;\r
 \r
@@ -281,11 +282,6 @@ ParseIndirectionFiles (
   TEXT_STRING_LIST    *Files\r
   );\r
 \r
-STATUS\r
-StringDBCreateHiiExportPack (\r
-  INT8                *OutputFileName\r
-  );\r
-\r
 int\r
 main (\r
   int   Argc,\r
@@ -311,7 +307,7 @@ Returns:
 {\r
   STATUS  Status;\r
 \r
-  SetUtilityName (PROGRAM_NAME);\r
+  SetUtilityName (UTILITY_NAME);\r
   //\r
   // Process the command-line arguments\r
   //\r
@@ -405,7 +401,7 @@ Returns:
   // Dump the string data as HII binary string pack if requested\r
   //\r
   if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);\r
+    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);\r
   }\r
   //\r
   // Always update the database if no errors and not in dump mode. If they specified -od\r
@@ -1481,7 +1477,7 @@ FindFile (
     // Put the path and filename together\r
     //\r
     if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
       return NULL;\r
     }\r
     //\r
@@ -1581,7 +1577,7 @@ ProcessArgs (
       // check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");\r
         return STATUS_ERROR;\r
       }\r
       //\r
@@ -1591,7 +1587,7 @@ ProcessArgs (
       //\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1599,7 +1595,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 2);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1624,7 +1620,7 @@ ProcessArgs (
       // Indirection file -- check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");\r
         return STATUS_ERROR;\r
       }\r
       //\r
@@ -1634,7 +1630,7 @@ ProcessArgs (
       //\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1642,7 +1638,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 1);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1665,13 +1661,13 @@ ProcessArgs (
       // Check for one more arg (the database file name)\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1679,7 +1675,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 1);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1702,14 +1698,14 @@ ProcessArgs (
       // which we can dump our database.\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       if (mGlobals.DumpUFileName[0] == 0) {\r
         strcpy (mGlobals.DumpUFileName, Argv[1]);\r
       } else {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
+        Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1720,14 +1716,14 @@ ProcessArgs (
       // -hpk option to create an HII export pack of the input database file\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       if (mGlobals.HiiExportPackFileName[0] == 0) {\r
         strcpy (mGlobals.HiiExportPackFileName, Argv[1]);\r
       } else {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
+        Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1751,7 +1747,7 @@ ProcessArgs (
       // check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1763,7 +1759,7 @@ ProcessArgs (
       // check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");\r
         Usage ();\r
         return STATUS_ERROR;\r
       }\r
@@ -1776,7 +1772,7 @@ ProcessArgs (
       // -oh to specify output .h defines file name\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1788,7 +1784,7 @@ ProcessArgs (
       // -dep to specify output dependency file name\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1800,7 +1796,7 @@ ProcessArgs (
       // -skipext to skip scanning of files with certain filename extensions\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");\r
         return STATUS_ERROR;\r
       }\r
       //\r
@@ -1810,7 +1806,7 @@ ProcessArgs (
       //\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1818,7 +1814,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 2);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1845,7 +1841,7 @@ ProcessArgs (
       // "-lang eng" or "-lang spa+cat" to only output certain languages\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");\r
         Usage ();\r
         return STATUS_ERROR;\r
       }\r
@@ -1861,7 +1857,7 @@ ProcessArgs (
       // Output database file name -- check for another arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1872,7 +1868,7 @@ ProcessArgs (
       //\r
       // Unrecognized arg\r
       //\r
-      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");\r
       Usage ();\r
       return STATUS_ERROR;\r
     }\r
@@ -1919,7 +1915,7 @@ ProcessArgs (
   //\r
   if (mGlobals.Mode == MODE_SCAN) {\r
     if (Argc < 1) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
       Usage ();\r
       return STATUS_ERROR;\r
     }\r
@@ -1929,14 +1925,14 @@ ProcessArgs (
     while (Argc > 0) {\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);\r
         return STATUS_ERROR;\r
       }\r
 \r
       memset (NewList, 0, sizeof (TEXT_STRING_LIST));\r
       NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);\r
       if (NewList->Str == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1956,7 +1952,7 @@ ProcessArgs (
     // Parse mode -- must specify an input unicode file name\r
     //\r
     if (Argc < 1) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
       Usage ();\r
       return STATUS_ERROR;\r
     }\r
@@ -1989,7 +1985,7 @@ AddCommandLineLanguage (
     //\r
     WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));\r
     if (WNewList == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
       return STATUS_ERROR;\r
     }\r
 \r
@@ -1997,7 +1993,7 @@ AddCommandLineLanguage (
     WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));\r
     if (WNewList->Str == NULL) {\r
       free (WNewList);\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
       return STATUS_ERROR;\r
     }\r
     //\r
@@ -2024,7 +2020,7 @@ AddCommandLineLanguage (
               (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')\r
             )\r
           ) {\r
-        Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");\r
+        Error (UTILITY_NAME, 0, 0, Language, "invalid format for language name on command line");\r
         FREE (WNewList->Str);\r
         FREE (WNewList);\r
         return STATUS_ERROR;\r
@@ -2523,48 +2519,56 @@ Returns:
   \r
 --*/\r
 {\r
-  int               Index;\r
-  static const char *Str[] = {\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel String Gather Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
     "",\r
-    PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",\r
-    "  Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",\r
-    "         "PROGRAM_NAME " -scan {scan options} [FileName]",\r
-    "         "PROGRAM_NAME " -dump {dump options}",\r
-    "    Common options include:",\r
-    "      -h or -?         for this help information",\r
-    "      -db Database     required name of output/input database file",\r
-    "      -bn BaseName     for use in the .h and .c output files",\r
-    "                       Default = "DEFAULT_BASE_NAME,\r
-    "      -v               for verbose output",\r
-    "      -vdbw            for verbose output when writing database",\r
-    "      -vdbr            for verbose output when reading database",\r
-    "      -od FileName     to specify an output database file name",\r
-    "    Parse options include:",\r
-    "      -i IncludePath   add IncludePath to list of search paths",\r
-    "      -dep FileName    to specify an output dependency file name",\r
-    "      -newdb           to not read in existing database file",\r
-    "      -uqs             to indicate that unquoted strings are used",\r
-    "      FileNames        name of one or more unicode files to parse",\r
-    "    Scan options include:",\r
-    "      -scan            scan text file(s) for STRING_TOKEN() usage",\r
-    "      -skipext .ext    to skip scan of files with .ext filename extension",\r
-    "      -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
-    "                       found in the database",\r
-    "      FileNames        one or more files to scan",\r
-    "    Dump options include:",\r
-    "      -oc FileName     write string data to FileName",\r
-    "      -oh FileName     write string defines to FileName",\r
-    "      -ou FileName     dump database to unicode file FileName",\r
-    "      -lang Lang       only dump for the language 'Lang'",\r
-    "      -if FileName     to specify an indirection file",\r
-    "      -hpk FileName    to create an HII export pack of the strings",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" -parse [OPTION] FILE",\r
+    "  "UTILITY_NAME" -scan  [OPTION] FILE",\r
+    "  "UTILITY_NAME" -dump  [OPTION]",\r
+    "Description:",\r
+    "  Process unicode strings file.",\r
+    "Common options include:",\r
+    "  -h or -?         for this help information",\r
+    "  -db Database     required name of output/input database file",\r
+    "  -bn BaseName     for use in the .h and .c output files",\r
+    "                   Default = "DEFAULT_BASE_NAME,\r
+    "  -v               for verbose output",\r
+    "  -vdbw            for verbose output when writing database",\r
+    "  -vdbr            for verbose output when reading database",\r
+    "  -od FileName     to specify an output database file name",\r
+    "Parse options include:",\r
+    "  -i IncludePath   add IncludePath to list of search paths",\r
+    "  -dep FileName    to specify an output dependency file name",\r
+    "  -newdb           to not read in existing database file",\r
+    "  -uqs             to indicate that unquoted strings are used",\r
+    "  FileNames        name of one or more unicode files to parse",\r
+    "Scan options include:",\r
+    "  -scan            scan text file(s) for STRING_TOKEN() usage",\r
+    "  -skipext .ext    to skip scan of files with .ext filename extension",\r
+    "  -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
+    "                   found in the database",\r
+    "  FileNames        one or more files to scan",\r
+    "Dump options include:",\r
+    "  -oc FileName     write string data to FileName",\r
+    "  -oh FileName     write string defines to FileName",\r
+    "  -ou FileName     dump database to unicode file FileName",\r
+    "  -lang Lang       only dump for the language 'Lang'",\r
+    "  -if FileName     to specify an indirection file",\r
+    "  -hpk FileName    to create an HII export pack of the strings",\r
     "",\r
-    "  The expected process is to parse a unicode string file to create an initial",\r
-    "  database of string identifier names and string definitions. Then text files",\r
-    "  should be scanned for STRING_TOKEN() usages, and the referenced",\r
-    "  strings will be tagged as used in the database. After all files have been",\r
-    "  scanned, then the database should be dumped to create the necessary output",\r
-    "  files.",\r
+    "The expected process is to parse a unicode string file to create an initial",\r
+    "database of string identifier names and string definitions. Then text files",\r
+    "should be scanned for STRING_TOKEN() usages, and the referenced",\r
+    "strings will be tagged as used in the database. After all files have been",\r
+    "scanned, then the database should be dumped to create the necessary output",\r
+    "files.",\r
     "",\r
     NULL\r
   };\r
index d4da8e8690db159d852b31f744e52ef8640a9799..e0dc783a8d4db699c94633454bbdb0d5684a9627 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -25,8 +25,6 @@ Abstract:
 #define MALLOC(size)  malloc (size)\r
 #define FREE(ptr)     free (ptr)\r
 \r
-#define PROGRAM_NAME  "StrGather"\r
-\r
 typedef CHAR16  WCHAR;\r
 \r
 #define UNICODE_TO_ASCII(w)   (INT8) ((w) & 0xFF)\r
index 6b17f48c6d7ef41bbec278e0f90cdc7a17b9d0a5..08afd83fb31cba9a20ad0979f4042425427e666e 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -2508,7 +2508,8 @@ Returns:
 --*/\r
 STATUS\r
 StringDBCreateHiiExportPack (\r
-  INT8                        *FileName\r
+  INT8                        *FileName,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest\r
   )\r
 {\r
   FILE                        *Fptr;\r
@@ -2524,6 +2525,9 @@ StringDBCreateHiiExportPack (
   WCHAR                       *TempStringPtr;\r
   WCHAR                       *LangName;\r
   STRING_IDENTIFIER           *StringIdentifier;\r
+  WCHAR_STRING_LIST           *LOIPtr;\r
+  BOOLEAN                     LanguageOk;\r
+\r
 \r
   if ((Fptr = fopen (FileName, "wb")) == NULL) {\r
     Error (NULL, 0, 0, FileName, "failed to open output HII export file");\r
@@ -2544,6 +2548,25 @@ StringDBCreateHiiExportPack (
   //\r
   ZeroString[0] = 0;\r
   for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    //\r
+    // If we have a language list, then make sure this language is in that\r
+    // list.\r
+    //\r
+    LanguageOk  = TRUE;\r
+    if (LanguagesOfInterest != NULL) {\r
+      LanguageOk = FALSE;\r
+      for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {\r
+        if (wcsncmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {\r
+          LanguageOk  = TRUE;\r
+          break;\r
+        }\r
+      }\r
+    }\r
+\r
+    if (!LanguageOk) {\r
+      continue;\r
+    }\r
+\r
     //\r
     // Process each string for this language. We have to make 3 passes on the strings:\r
     //   Pass1: computes sizes and fill in the string pack header\r
index 92801f70f88376e65f0b5bf8a469000d9743563b..a4c2837ae0c38e1d74bc15601486d4eb56ff1847 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -28,11 +28,13 @@ Abstract:
 void\r
 StringDBConstructor (\r
   void\r
-  );\r
+  )\r
+;\r
 void\r
 StringDBDestructor (\r
   void\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBAddString (\r
@@ -42,12 +44,14 @@ StringDBAddString (
   WCHAR   *String,\r
   BOOLEAN Format,\r
   UINT16  Flags\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBSetScope (\r
   WCHAR   *Scope\r
-  );\r
+  )\r
+;\r
 \r
 #define STRING_FLAGS_REFERENCED           0x0001  // if referenced somewhere\r
 #define STRING_FLAGS_UNDEFINED            0x0002  // if we added it for padding purposes\r
@@ -61,33 +65,38 @@ StringDBAddStringIdentifier (
   WCHAR     *StringIdentifier,\r
   UINT16    *NewId,\r
   UINT16    Flags\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBReadDatabase (\r
   INT8    *DBFileName,\r
   BOOLEAN IgnoreIfNotExist,\r
   BOOLEAN Verbose\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBWriteDatabase (\r
   INT8    *DBFileName,\r
   BOOLEAN Verbose\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBDumpDatabase (\r
   INT8                *DBFileName,\r
   INT8                *OutputFileName,\r
   BOOLEAN             Verbose\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBAddLanguage (\r
   WCHAR *LanguageName,\r
   WCHAR *PrintableLanguageName\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBDumpCStrings (\r
@@ -95,28 +104,40 @@ StringDBDumpCStrings (
   INT8                        *BaseName,\r
   WCHAR_STRING_LIST           *LanguagesOfInterest,\r
   WCHAR_MATCHING_STRING_LIST  *IndirectionList\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBDumpStringDefines (\r
   INT8                *FileName,\r
   INT8                *BaseName\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBSetCurrentLanguage (\r
   WCHAR *LanguageName\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBSetStringReferenced (\r
   INT8      *StringIdentifierName,\r
   BOOLEAN   IgnoreNotFound\r
-  );\r
+  )\r
+;\r
 \r
 void\r
 StringDBFormatString (\r
   WCHAR   *String\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBCreateHiiExportPack (\r
+  INT8                *OutputFileName,\r
+  WCHAR_STRING_LIST   *LanguagesOfInterest\r
   );\r
 \r
+\r
 #endif // #ifndef _STRING_DB_H_\r
index 03e1831ca7c8156f5fc1bbf223b513d10c897c4a..03d3c3e5dd4dcdac9276eb3d130ccda5a84009d2 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>                                                         \r
+Copyright (c) 2006 - 2010, 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
@@ -24,6 +24,50 @@ Abstract:
 #include <string.h>\r
 #include <malloc.h>\r
 \r
+#define UTILITY_NAME      "Strip"\r
+#define UTILITY_VERSION   "v1.0"\r
+\r
+static\r
+void\r
+Usage (\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+  \r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+  \r
+--*/\r
+{\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel Strip Utility",\r
+    "  Copyright (C), 2006 - 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" SOURCE DEST",\r
+    "Description:",\r
+    "  Convert executable files to binary files.",\r
+    NULL\r
+  };\r
+\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
+  }\r
+}\r
+\r
 int\r
 main (\r
   int  argc,\r
@@ -55,7 +99,7 @@ Returns:
   char  *Ptrx;\r
 \r
   if (argc < 3) {\r
-    printf ("Need more args, such as file name to convert and output name\n");\r
+    Usage ();\r
     return -1;\r
   }\r
 \r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
new file mode 100644 (file)
index 0000000..c1a4c33
--- /dev/null
@@ -0,0 +1,740 @@
+/*++\r
+\r
+Copyright (c) 2008 - 2010, 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+  HiiPack.c\r
+\r
+Abstract:\r
+\r
+  Process HII package files to generate HII package list binary file or PE/COFF\r
+  resource script file (i.e. .rc file).\r
+\r
+--*/\r
+\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#include "Tiano.h"\r
+#include "EfiHii.h"\r
+\r
+#include "EfiUtilityMsgs.h"\r
+#include "ParseInf.h"\r
+\r
+#define UTILITY_VERSION "v1.0"\r
+#define UTILITY_NAME    "HiiPack"\r
+#define MAX_PATH        260\r
+\r
+//\r
+// Define HII resource section type and name\r
+//\r
+#define HII_RESOURCE_TYPE   "HII"\r
+#define HII_RESOURCE_NAME   1\r
+\r
+//\r
+// We'll store lists of file names from the command line in\r
+// a linked list of these\r
+//\r
+typedef struct _FILE_NAME_LIST {\r
+  struct _FILE_NAME_LIST  *Next;\r
+  UINT8                   FileName[MAX_PATH];\r
+  UINT32                  PackageType;\r
+  UINT32                  Length;\r
+  UINT8                   *Data;\r
+} FILE_NAME_LIST;\r
+\r
+//\r
+// Create some defines for the different operation modes supported by this utility\r
+//\r
+#define MODE_CREATE_HII_RESOURCE_FILE   0x0001\r
+#define MODE_CREATE_HII_PACKAGE_LIST    0x0002\r
+\r
+//\r
+// Here's all our globals.\r
+//\r
+static struct {\r
+  FILE_NAME_LIST  *PackageFile;                  // all include paths to search\r
+  FILE_NAME_LIST  *LastPackageFile;\r
+  UINT8           PackageListFileName[MAX_PATH]; // Output package list file name\r
+  UINT8           ResourceFileName[MAX_PATH];    // Output HII resource file name\r
+  EFI_GUID        Guid;                          // Guid specified on command line\r
+  BOOLEAN         GuidSpecified;\r
+  BOOLEAN         Verbose;\r
+  UINT32          Mode;                          // Mode this utility is operating in\r
+} mGlobals;\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  );\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  );\r
+\r
+static\r
+void\r
+FreeGlobals (\r
+  VOID\r
+  );\r
+\r
+static\r
+void\r
+DumpRawBytes (\r
+  FILE                  *OutFptr,\r
+  UINT8                 *Buffer,\r
+  int                   Count,\r
+  int                   Indent\r
+  );\r
+\r
+static\r
+STATUS\r
+CreateResourceScript (\r
+  char              *OutputFileName,\r
+  EFI_GUID          *PackageListGuid,\r
+  FILE_NAME_LIST    *PackageFiles\r
+  );\r
+\r
+static\r
+STATUS\r
+CreatePackageList (\r
+  char              *OutputFileName,\r
+  EFI_GUID          *PackageListGuid,\r
+  FILE_NAME_LIST    *PackageFiles\r
+  );\r
+\r
+int\r
+main (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Call the routine to parse the command-line options, then process the file.\r
+\r
+Arguments:\r
+\r
+  Standard C main() argc and argv.\r
+\r
+Returns:\r
+\r
+  0       if successful\r
+  nonzero otherwise\r
+\r
+--*/\r
+{\r
+  STATUS  Status;\r
+\r
+  //\r
+  // Set the utility name for error reporting purposes\r
+  //\r
+  SetUtilityName (UTILITY_NAME);\r
+\r
+  //\r
+  // Process the command-line arguments\r
+  //\r
+  Status = ProcessArgs (Argc, Argv);\r
+  if (Status != STATUS_SUCCESS) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Switch based on args\r
+  //\r
+  if (mGlobals.Mode & MODE_CREATE_HII_RESOURCE_FILE) {\r
+    CreateResourceScript (mGlobals.ResourceFileName, &mGlobals.Guid, mGlobals.PackageFile);\r
+  }\r
+\r
+  if (mGlobals.Mode & MODE_CREATE_HII_PACKAGE_LIST) {\r
+    CreatePackageList (mGlobals.PackageListFileName, &mGlobals.Guid, mGlobals.PackageFile);\r
+  }\r
+\r
+  FreeGlobals ();\r
+\r
+  return GetUtilityStatus ();\r
+}\r
+\r
+/******************************************************************************/\r
+static const char *gRcFileHeader[] = {\r
+  "//",\r
+  "//  DO NOT EDIT -- auto-generated file",\r
+  "//",\r
+  "//  This file is generated by the hiipack utility",\r
+  "//",\r
+  NULL\r
+};\r
+\r
+static\r
+STATUS\r
+CreateResourceScript (\r
+  char              *OutputFileName,\r
+  EFI_GUID          *PackageListGuid,\r
+  FILE_NAME_LIST    *PackageFiles\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a linked list of HII package files, walk the list to\r
+  process them and create a single HII resource script file.\r
+\r
+Arguments:\r
+\r
+  OutputFileName    - name of output HII resource script file to create\r
+  PackageListGuid   - the specified package list GUID\r
+  PackageFiles      - linked list of HII package files to process\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+\r
+--*/\r
+{\r
+  STATUS            Status;\r
+  UINT8             *PackageList;\r
+  UINT8             *Buffer;\r
+  UINT32            PackageListLen;\r
+  FILE              *OutFptr;\r
+  UINTN             Index;\r
+  FILE_NAME_LIST    *Package;\r
+\r
+  //\r
+  // If no input HII pack files, then why are we here? Should have been caught when\r
+  // args were processed though.\r
+  //\r
+  if (PackageFiles == NULL) {\r
+    Error (NULL, 0, 0, "no input package file(s) specified", NULL);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  OutFptr = NULL;\r
+  Status  = STATUS_ERROR;\r
+\r
+  //\r
+  // Open the output file for writing\r
+  //\r
+  if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Write file header\r
+  //\r
+  for (Index = 0; gRcFileHeader[Index] != NULL; Index++) {\r
+    fprintf (OutFptr, "%s\n", gRcFileHeader[Index]);\r
+  }\r
+\r
+  //\r
+  // Write nameID and typeID\r
+  //\r
+  fprintf (OutFptr, "\n");\r
+  fprintf (OutFptr, "%d %s\n", HII_RESOURCE_NAME, HII_RESOURCE_TYPE);\r
+  fprintf (OutFptr, "{\n");\r
+\r
+  //\r
+  // Prepare package list\r
+  //\r
+  PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+  Package = PackageFiles;\r
+  while (Package != NULL) {\r
+    PackageListLen += Package->Length;\r
+    Package = Package->Next;\r
+  }\r
+  //\r
+  // Inlucde the length of EFI_HII_PACKAGE_END\r
+  //\r
+  PackageListLen += sizeof (EFI_HII_PACKAGE_HEADER);\r
+\r
+  Buffer = (UINT8 *) malloc (PackageListLen);\r
+  if (Buffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    goto Done;\r
+  }\r
+  PackageList = Buffer;\r
+\r
+  memcpy (Buffer, PackageListGuid, sizeof (EFI_GUID));\r
+  Buffer += sizeof (EFI_GUID);\r
+  memcpy (Buffer, &PackageListLen, sizeof (UINT32));\r
+  Buffer += sizeof (UINT32);\r
+\r
+  Package = PackageFiles;\r
+  while (Package != NULL) {\r
+    memcpy (Buffer, Package->Data, Package->Length);\r
+    Buffer += Package->Length;\r
+    Package = Package->Next;\r
+  }\r
+  //\r
+  // Append EFI_HII_PACKAGE_END\r
+  //\r
+  ((EFI_HII_PACKAGE_HEADER *) Buffer)->Type = EFI_HII_PACKAGE_END;\r
+  ((EFI_HII_PACKAGE_HEADER *) Buffer)->Length = sizeof (EFI_HII_PACKAGE_HEADER);\r
+\r
+  //\r
+  // Dump package list\r
+  //\r
+  DumpRawBytes (OutFptr, PackageList, PackageListLen, 2);\r
+\r
+  //\r
+  // Write file tail\r
+  //\r
+  fprintf (OutFptr, "}\n");\r
+\r
+  Status = STATUS_SUCCESS;\r
+\r
+Done:\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+STATUS\r
+CreatePackageList (\r
+  char              *OutputFileName,\r
+  EFI_GUID          *PackageListGuid,\r
+  FILE_NAME_LIST    *PackageFiles\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Given a linked list of HII package files, walk the list to\r
+  process them and create a binary HII package list file.\r
+\r
+Arguments:\r
+\r
+  OutputFileName    - name of output HII package list file to create\r
+  PackageListGuid   - the specified package list GUID\r
+  PackageFiles      - linked list of HII package files to process\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+\r
+--*/\r
+{\r
+  FILE            *OutFptr;\r
+  UINT32          PackageListLen;\r
+  FILE_NAME_LIST  *Package;\r
+\r
+  if (OutputFileName == NULL || PackageListGuid == NULL || PackageFiles == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Open the output file for writing\r
+  //\r
+  if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {\r
+    Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  // Write package list header\r
+  //\r
+  PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);\r
+  Package = PackageFiles;\r
+  while (Package != NULL) {\r
+    PackageListLen += Package->Length;\r
+    Package = Package->Next;\r
+  }\r
+  fwrite (PackageListGuid, sizeof (UINT8), sizeof (EFI_GUID), OutFptr);\r
+  fwrite (&PackageListLen, sizeof (UINT8), sizeof (UINT32), OutFptr);\r
+\r
+  //\r
+  // Write packages\r
+  //\r
+  Package = PackageFiles;\r
+  while (Package != NULL) {\r
+    fwrite (Package->Data, sizeof (UINT8), Package->Length, OutFptr);\r
+    Package = Package->Next;\r
+  }\r
+\r
+Done:\r
+  if (OutFptr != NULL) {\r
+    fclose (OutFptr);\r
+  }\r
+\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
+static\r
+void\r
+FreeGlobals (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Free up an memory we allocated so we can exit cleanly\r
+\r
+Arguments:\r
+\r
+Returns: NA\r
+\r
+--*/\r
+{\r
+  FILE_NAME_LIST  *Next;\r
+\r
+  //\r
+  // Free up input package file names\r
+  //\r
+  while (mGlobals.PackageFile != NULL) {\r
+    Next = mGlobals.PackageFile->Next;\r
+    if (mGlobals.PackageFile->Data != NULL) {\r
+      free (mGlobals.PackageFile->Data);\r
+    }\r
+    free (mGlobals.PackageFile);\r
+    mGlobals.PackageFile = Next;\r
+  }\r
+}\r
+\r
+static\r
+void\r
+DumpRawBytes (\r
+  FILE                  *OutFptr,\r
+  UINT8                 *Buffer,\r
+  int                   Count,\r
+  int                   Indent\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Dump buffer data into output file.\r
+\r
+Arguments:\r
+\r
+  OutFptr     - FILE pointer to output file.\r
+  Buffer      - the buffer to dump\r
+  Count       - number of bytes to dump\r
+  Indent      - indent at each line start\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  int    Counter;\r
+  int    Count2;\r
+  UINT16 *Ptr16;\r
+\r
+  Ptr16 = (UINT16 *) Buffer;\r
+  Count2 = Count - (Count & 0x1);\r
+\r
+  for (Counter = 0; Counter < Count2; Counter += 2) {\r
+    if ((Counter & 0xF) == 0) {\r
+      if (Counter == 0) {\r
+        fprintf (OutFptr, "%*c", Indent, ' ');\r
+      } else {\r
+        fprintf (OutFptr, "\n%*c", Indent, ' ');\r
+      }\r
+    }\r
+\r
+    fprintf (OutFptr, "0x%04X, ", (unsigned int) *Ptr16);\r
+    Ptr16++;\r
+  }\r
+\r
+  //\r
+  // Handle the last byte\r
+  //\r
+  if ((Count & 0x1) != 0) {\r
+    if ((Counter & 0xF) == 0) {\r
+      if (Counter == 0) {\r
+        fprintf (OutFptr, "%*c", Indent, ' ');\r
+      } else {\r
+        fprintf (OutFptr, "\n%*c", Indent, ' ');\r
+      }\r
+    }\r
+\r
+    fprintf (OutFptr, "0x%04X, ", (unsigned int) (*Ptr16 & 0xff));\r
+  }\r
+\r
+  fprintf (OutFptr, "\n");\r
+}\r
+\r
+static\r
+STATUS\r
+LoadPackage (\r
+  FILE_NAME_LIST      *NameList\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the command line arguments\r
+\r
+Arguments:\r
+\r
+  NameList    - the FILE_NAME_LIST linked list node\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+\r
+--*/\r
+{\r
+  STATUS                  Status;\r
+  FILE                    *InFptr;\r
+  UINT32                  BufferSize;\r
+  UINT8                   *Buffer;\r
+  EFI_HII_PACKAGE_HEADER  *PackageHeader;\r
+  EFI_IFR_FORM_SET        *FormSet;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  if (NameList == NULL) {\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Try to open the package file\r
+  //\r
+  if ((InFptr = fopen (NameList->FileName, "rb")) == NULL) {\r
+    Error (NULL, 0, 0, NameList->FileName, "failed to open input file for read");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Get the file size, then allocate a buffer and read in the file contents.\r
+  //\r
+  fseek (InFptr, 0, SEEK_END);\r
+  BufferSize = (UINT32) ftell (InFptr);\r
+  fseek (InFptr, 0, SEEK_SET);\r
+  Buffer = (UINT8 *) malloc (BufferSize);\r
+  if (Buffer == NULL) {\r
+    Error (NULL, 0, 0, "memory allocation failure", NULL);\r
+    goto Done;\r
+  }\r
+\r
+  if (fread (Buffer, sizeof (UINT8), BufferSize, InFptr) != BufferSize) {\r
+    Error (NULL, 0, 0, NameList->FileName, "error reading file contents");\r
+    Status = STATUS_ERROR;\r
+    goto Done;\r
+  }\r
+\r
+  NameList->Length = BufferSize;\r
+  NameList->Data = Buffer;\r
+\r
+  PackageHeader = (EFI_HII_PACKAGE_HEADER *) Buffer;\r
+  NameList->PackageType = PackageHeader->Type;\r
+\r
+  if (!mGlobals.GuidSpecified && NameList->PackageType == EFI_HII_PACKAGE_FORMS) {\r
+    FormSet = (EFI_IFR_FORM_SET *) (Buffer + sizeof (EFI_HII_PACKAGE_HEADER));\r
+    memcpy (&mGlobals.Guid, &FormSet->Guid, sizeof (EFI_GUID));\r
+    mGlobals.GuidSpecified = TRUE;\r
+  }\r
+\r
+Done:\r
+  fclose (InFptr);\r
+\r
+  return Status;\r
+}\r
+\r
+\r
+static\r
+STATUS\r
+ProcessArgs (\r
+  int   Argc,\r
+  char  *Argv[]\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Process the command line arguments\r
+\r
+Arguments:\r
+\r
+  As per standard C main()\r
+\r
+Returns:\r
+\r
+  STATUS_SUCCESS    - if successful\r
+  STATUS_ERROR      - otherwise\r
+\r
+--*/\r
+{\r
+  FILE_NAME_LIST  *NewList;\r
+  STATUS          Status;\r
+\r
+  Status = STATUS_SUCCESS;\r
+  memset ((void *) &mGlobals, 0, sizeof (mGlobals));\r
+\r
+  //\r
+  // Skip program name\r
+  //\r
+  Argc--;\r
+  Argv++;\r
+\r
+  if (Argc == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  if (_stricmp (Argv[0], "-h") == 0 || _stricmp (Argv[0], "-?") == 0) {\r
+    Usage ();\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Process until no more args.\r
+  //\r
+  while (Argc > 0) {\r
+    if (_stricmp (Argv[0], "-rc") == 0) {\r
+      Argc--;\r
+      Argv++;\r
+\r
+      if (Argc == 0) {\r
+        Error (UTILITY_NAME, 0, 0, "mising HII resource file name", NULL);\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      strcpy (mGlobals.ResourceFileName, Argv[0]);\r
+      mGlobals.Mode |= MODE_CREATE_HII_RESOURCE_FILE;\r
+\r
+    } else if (_stricmp (Argv[0], "-hii") == 0) {\r
+      Argc--;\r
+      Argv++;\r
+\r
+      if (Argc == 0) {\r
+        Error (UTILITY_NAME, 0, 0, "mising HII package list file name", NULL);\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      strcpy (mGlobals.PackageListFileName, Argv[0]);\r
+      mGlobals.Mode |= MODE_CREATE_HII_PACKAGE_LIST;\r
+\r
+    } else if (_stricmp (Argv[0], "-g") == 0) {\r
+      Argc--;\r
+      Argv++;\r
+\r
+      if (Argc == 0) {\r
+        Error (UTILITY_NAME, 0, 0, "mising package list GUID", NULL);\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      Status = StringToGuid (Argv[0], &mGlobals.Guid);\r
+      if (Status != STATUS_SUCCESS) {\r
+        goto Done;\r
+      }\r
+      mGlobals.GuidSpecified = TRUE;\r
+\r
+    } else {\r
+      //\r
+      // This is a package file\r
+      //\r
+      NewList = malloc (sizeof (FILE_NAME_LIST));\r
+      if (NewList == NULL) {\r
+        Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);\r
+        Status = STATUS_ERROR;\r
+        goto Done;\r
+      }\r
+\r
+      memset (NewList, 0, sizeof (FILE_NAME_LIST));\r
+      strcpy (NewList->FileName, Argv[0]);\r
+\r
+      if (mGlobals.PackageFile == NULL) {\r
+        mGlobals.PackageFile = NewList;\r
+      } else {\r
+        mGlobals.LastPackageFile->Next = NewList;\r
+      }\r
+      mGlobals.LastPackageFile = NewList;\r
+\r
+      Status = LoadPackage (NewList);\r
+      if (Status != STATUS_SUCCESS) {\r
+        goto Done;\r
+      }\r
+    }\r
+\r
+    Argc--;\r
+    Argv++;\r
+  }\r
+\r
+  if (!mGlobals.GuidSpecified) {\r
+    Error (UTILITY_NAME, 0, 0, "please specify HII pakcage list GUID", NULL);\r
+    Status = STATUS_ERROR;\r
+  }\r
+\r
+Done:\r
+  if (Status != STATUS_SUCCESS) {\r
+    FreeGlobals ();\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+static\r
+void\r
+Usage (\r
+  VOID\r
+  )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+  Print usage information for this utility.\r
+\r
+Arguments:\r
+\r
+  None.\r
+\r
+Returns:\r
+\r
+  Nothing.\r
+\r
+--*/\r
+{\r
+  int        i;\r
+  const char *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - UEFI HII Package List Utility",\r
+    "  Copyright (C), 2008 Intel Corporation",\r
+    \r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION] PACKAGE [PACKAGE [...]]",\r
+    "Description:",\r
+    "  Merge HII package files into a single HII Package List.",\r
+    "Options:",\r
+    "  -rc  FileName               write output to PE/COFF Resource Script file",\r
+    "  -hii FileName               write output to binary Package List file",\r
+    "  -g   GUID                   use GUID for the HII Package List Guid",\r
+    "",\r
+    "PACKAGE is the raw binary HII package file generated by StrGather or",\r
+    "VfrCompiler which named as *.hpk. For example, merge a Form package and",\r
+    "a String package into one HII package list:",\r
+    "  \""UTILITY_NAME" -rc Sample.rc -hii Sample.hii \\",\r
+    "           -g 12345678-1234-1234-1234-123456789abc Vfr.hpk Strings.hpk\"",\r
+    NULL\r
+  };\r
+  for (i = 0; Str[i] != NULL; i++) {\r
+    fprintf (stdout, "%s\n", Str[i]);\r
+  }\r
+}\r
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
new file mode 100644 (file)
index 0000000..ac12d76
--- /dev/null
@@ -0,0 +1,71 @@
+#/*++\r
+#\r
+#  Copyright (c) 2008 - 2010, 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
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+#  Module Name:\r
+#\r
+#    Makefile\r
+#\r
+#  Abstract:\r
+#\r
+#    Makefile for building the UEFI HiiPack utility\r
+#\r
+#--*/\r
+\r
+#\r
+# Make sure environmental variable EDK_SOURCE is set\r
+#\r
+!IFNDEF EDK_SOURCE\r
+!ERROR EDK_SOURCE environmental variable not set\r
+!ENDIF\r
+\r
+!INCLUDE $(BUILD_DIR)\PlatformTools.env\r
+\r
+#\r
+# Target specific information\r
+#\r
+TARGET_NAME         = HiiPack\r
+TARGET_SOURCE_DIR   = $(EDK_TOOLS_SOURCE)\Uefi$(TARGET_NAME)\r
+TARGET_EXE          = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe\r
+\r
+OBJECTS         = $(EDK_TOOLS_OUTPUT)\HiiPack.obj\r
+LIBS            = $(LIBS) $(EDK_TOOLS_OUTPUT)\Common.lib\r
+\r
+#\r
+# Build targets\r
+#\r
+\r
+all: $(TARGET_EXE)\r
+\r
+#\r
+# Compile each tool source file\r
+#\r
+$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SOURCE_DIR)\HiiPack.c\r
+  $(CC) $(C_FLAGS) $(TARGET_SOURCE_DIR)\HiiPack.c  /Fo$@\r
+\r
+#\r
+# Add Binary Build description for this tool.\r
+#\r
+\r
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))\r
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y\r
+  if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \\r
+  copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y\r
+!ELSE\r
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)\r
+  $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)\r
+!IF ("$(EFI_BINARY_BUILD)" == "YES")\r
+  if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools\r
+  if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y\r
+  if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \\r
+  copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y\r
+!ENDIF\r
+!ENDIF\r
index dd5bdb45ed55fade2aff5ca7ca8d6d38088b6151..535a2650469b03496c8902ee5dbad943f35f3c97 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 Module Name:\r
 \r
-  StrGather.c  \r
+  StrGather.c\r
 \r
 Abstract:\r
 \r
@@ -29,7 +29,8 @@ Abstract:
 #include "StrGather.h"\r
 #include "StringDB.h"\r
 \r
-#define TOOL_VERSION  "0.31"\r
+#define UTILITY_NAME     "StrGather"\r
+#define UTILITY_VERSION  "v1.2"\r
 \r
 typedef UINT16  WCHAR;\r
 \r
@@ -47,6 +48,15 @@ typedef UINT16  WCHAR;
 #define MODE_SCAN     2\r
 #define MODE_DUMP     3\r
 \r
+//\r
+// This is how we invoke the C preprocessor on the source file\r
+// to resolve #if, #else, etc.\r
+//\r
+#define PREPROCESSOR_COMMAND                "cl"\r
+#define PREPROCESSOR_OPTIONS                "/nologo /EP /TC /DSTRGATHER"\r
+#define PREPROCESS_TEMP_FILE_EXTENSION      ".ii"\r
+#define PREPROCESS_OUTPUT_FILE_EXTENSION    ".iii"\r
+\r
 //\r
 // We keep a linked list of these for the source files we process\r
 //\r
@@ -83,6 +93,8 @@ static struct {
   TEXT_STRING_LIST            *LastIndirectionFileName;\r
   TEXT_STRING_LIST            *DatabaseFileName;\r
   TEXT_STRING_LIST            *LastDatabaseFileName;\r
+  TEXT_STRING_LIST            *PreprocessFlags;\r
+  TEXT_STRING_LIST            *LastPreprocessFlags;\r
   WCHAR_STRING_LIST           *Language;\r
   WCHAR_STRING_LIST           *LastLanguage;\r
   WCHAR_MATCHING_STRING_LIST  *IndirectionList;                 // from indirection file(s)\r
@@ -94,6 +106,8 @@ static struct {
   BOOLEAN                     IgnoreNotFound;                   // when scanning\r
   BOOLEAN                     VerboseScan;\r
   BOOLEAN                     UnquotedStrings;                  // -uqs option\r
+  BOOLEAN                     Preprocess;                       // -ppflag option\r
+  INT8                        PreprocessFileName[MAX_PATH];\r
   INT8                        OutputDatabaseFileName[MAX_PATH];\r
   INT8                        StringHFileName[MAX_PATH];\r
   INT8                        StringCFileName[MAX_PATH];        // output .C filename\r
@@ -294,11 +308,6 @@ ParseIndirectionFiles (
   TEXT_STRING_LIST    *Files\r
   );\r
 \r
-STATUS\r
-StringDBCreateHiiExportPack (\r
-  INT8                *OutputFileName\r
-  );\r
-\r
 int\r
 main (\r
   int   Argc,\r
@@ -309,7 +318,7 @@ main (
 Routine Description:\r
 \r
   Call the routine to parse the command-line options, then process the file.\r
-  \r
+\r
 Arguments:\r
 \r
   Argc - Standard C main() argc and argv.\r
@@ -319,12 +328,12 @@ Returns:
 \r
   0       if successful\r
   nonzero otherwise\r
-  \r
+\r
 --*/\r
 {\r
   STATUS  Status;\r
 \r
-  SetUtilityName (PROGRAM_NAME);\r
+  SetUtilityName (UTILITY_NAME);\r
   //\r
   // Process the command-line arguments\r
   //\r
@@ -374,12 +383,12 @@ Returns:
       if ((mGlobals.OutputDependencyFptr = fopen (mGlobals.OutputDependencyFileName, "w")) == NULL) {\r
         Error (NULL, 0, 0, mGlobals.OutputDependencyFileName, "failed to open output dependency file");\r
         goto Finish;\r
-      }    \r
+      }\r
     }\r
     Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);\r
     if (mGlobals.OutputDependencyFptr != NULL) {\r
       fclose (mGlobals.OutputDependencyFptr);\r
-    }    \r
+    }\r
     if (Status != STATUS_SUCCESS) {\r
       goto Finish;\r
     }\r
@@ -401,7 +410,8 @@ Returns:
   if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
     Status = StringDBDumpCStrings (\r
               mGlobals.BaseName,\r
-              mGlobals.StringCFileName\r
+              mGlobals.StringCFileName,\r
+              mGlobals.Language\r
               );\r
     if (Status != EFI_SUCCESS) {\r
       goto Finish;\r
@@ -418,7 +428,7 @@ Returns:
   // Dump the string data as HII binary string pack if requested\r
   //\r
   if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {\r
-    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);\r
+    StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);\r
   }\r
   //\r
   // Always update the database if no errors and not in dump mode. If they specified -od\r
@@ -457,7 +467,7 @@ ProcessIncludeFile (
 Routine Description:\r
 \r
   Given a source file, open the file and parse it\r
-  \r
+\r
 Arguments:\r
 \r
   SourceFile        - name of file to parse\r
@@ -466,7 +476,7 @@ Arguments:
 Returns:\r
 \r
   Standard status.\r
-  \r
+\r
 --*/\r
 {\r
   static UINT32 NestDepth = 0;\r
@@ -513,18 +523,18 @@ Returns:
       goto Finish;\r
     }\r
   }\r
-  \r
+\r
   //\r
-  // Output the dependency \r
+  // Output the dependency\r
   //\r
   if (mGlobals.OutputDependencyFptr != NULL) {\r
-    fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);    \r
+    fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);\r
     //\r
     // Add pseudo target to avoid incremental build failure when the file is deleted\r
     //\r
-    fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName); \r
+    fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);\r
   }\r
-   \r
+\r
   //\r
   // Process the file found\r
   //\r
@@ -695,13 +705,13 @@ PreprocessFile (
 Routine Description:\r
   Preprocess a file to replace all carriage returns with NULLs so\r
   we can print lines from the file to the screen.\r
-  \r
+\r
 Arguments:\r
   SourceFile - structure that we use to keep track of an input file.\r
 \r
 Returns:\r
   Nothing.\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN InComment;\r
@@ -1736,7 +1746,7 @@ FindFile (
     // Put the path and filename together\r
     //\r
     if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");\r
       return NULL;\r
     }\r
     //\r
@@ -1770,6 +1780,9 @@ ProcessArgs (
   )\r
 {\r
   TEXT_STRING_LIST  *NewList;\r
+  char              *Cptr;\r
+  char              *Cptr2;\r
+\r
   //\r
   // Clear our globals\r
   //\r
@@ -1836,7 +1849,7 @@ ProcessArgs (
       // check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");\r
         return STATUS_ERROR;\r
       }\r
       //\r
@@ -1846,7 +1859,7 @@ ProcessArgs (
       //\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1854,7 +1867,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 2);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1879,7 +1892,7 @@ ProcessArgs (
       // Indirection file -- check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");\r
         return STATUS_ERROR;\r
       }\r
       //\r
@@ -1889,7 +1902,7 @@ ProcessArgs (
       //\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1897,7 +1910,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 1);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1920,13 +1933,13 @@ ProcessArgs (
       // Check for one more arg (the database file name)\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1934,7 +1947,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 1);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1957,14 +1970,14 @@ ProcessArgs (
       // which we can dump our database.\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       if (mGlobals.DumpUFileName[0] == 0) {\r
         strcpy (mGlobals.DumpUFileName, Argv[1]);\r
       } else {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
+        Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -1975,14 +1988,14 @@ ProcessArgs (
       // -hpk option to create an HII export pack of the input database file\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       if (mGlobals.HiiExportPackFileName[0] == 0) {\r
         strcpy (mGlobals.HiiExportPackFileName, Argv[1]);\r
       } else {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
+        Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2006,7 +2019,7 @@ ProcessArgs (
       // check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2018,7 +2031,7 @@ ProcessArgs (
       // check for one more arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");\r
         Usage ();\r
         return STATUS_ERROR;\r
       }\r
@@ -2031,7 +2044,7 @@ ProcessArgs (
       // -oh to specify output .h defines file name\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2043,7 +2056,7 @@ ProcessArgs (
       // -dep to specify output dependency file name\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2055,7 +2068,7 @@ ProcessArgs (
       // -skipext to skip scanning of files with certain filename extensions\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");\r
         return STATUS_ERROR;\r
       }\r
       //\r
@@ -2065,7 +2078,7 @@ ProcessArgs (
       //\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2073,7 +2086,7 @@ ProcessArgs (
       NewList->Str = malloc (strlen (Argv[1]) + 2);\r
       if (NewList->Str == NULL) {\r
         free (NewList);\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2097,10 +2110,10 @@ ProcessArgs (
       Argv++;\r
     } else if (_stricmp (Argv[0], "-lang") == 0) {\r
       //\r
-      // "-lang eng" or "-lang spa+cat" to only output certain languages\r
+      // "-lang zh-Hans" or "-lang en-US" to only output certain languages\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");\r
         Usage ();\r
         return STATUS_ERROR;\r
       }\r
@@ -2116,18 +2129,78 @@ ProcessArgs (
       // Output database file name -- check for another arg\r
       //\r
       if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");\r
         return STATUS_ERROR;\r
       }\r
 \r
       strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);\r
+      Argv++;\r
+      Argc--;\r
+    } else if (_stricmp (Argv[0], "-ppflag") == 0) {\r
+      //\r
+      // -ppflag "Preprocess flags" -- check for another arg\r
+      //\r
+      if ((Argc <= 1) || (Argv[1][0] == '-')) {\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing preprocess flags");\r
+        Usage ();\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      //\r
+      // Allocate memory for a new list element, fill it in, and\r
+      // add it to our list of preprocess flag.\r
+      //\r
+      NewList = malloc (sizeof (TEXT_STRING_LIST));\r
+      if (NewList == NULL) {\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));\r
+      NewList->Str = malloc (strlen (Argv[1]) * 2 + 1);\r
+      if (NewList->Str == NULL) {\r
+        free (NewList);\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
+        return STATUS_ERROR;\r
+      }\r
+\r
+      //\r
+      // Convert '"' to '\"' in preprocess flag\r
+      //\r
+      Cptr = Argv[1];\r
+      Cptr2 = NewList->Str;\r
+      if (*Cptr == '"') {\r
+        *Cptr2++ = '\\';\r
+        *Cptr2++ = '"';\r
+        Cptr++;\r
+      }\r
+      while (*Cptr != '\0') {\r
+        if ((*Cptr == '"') && (*(Cptr - 1) != '\\')) {\r
+          *Cptr2++ = '\\';\r
+        }\r
+        *Cptr2++ = *Cptr++;\r
+      }\r
+      *Cptr2 = '\0';\r
+\r
+      //\r
+      // Add it to our linked list\r
+      //\r
+      if (mGlobals.PreprocessFlags == NULL) {\r
+        mGlobals.PreprocessFlags = NewList;\r
+      } else {\r
+        mGlobals.LastPreprocessFlags->Next = NewList;\r
+      }\r
+      mGlobals.LastPreprocessFlags = NewList;\r
+\r
+      mGlobals.Preprocess = TRUE;\r
+\r
       Argv++;\r
       Argc--;\r
     } else {\r
       //\r
       // Unrecognized arg\r
       //\r
-      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");\r
       Usage ();\r
       return STATUS_ERROR;\r
     }\r
@@ -2174,7 +2247,15 @@ ProcessArgs (
   //\r
   if (mGlobals.Mode == MODE_SCAN) {\r
     if (Argc < 1) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");\r
+      Usage ();\r
+      return STATUS_ERROR;\r
+    }\r
+    //\r
+    // If -ppflag is specified, -oh should also be specified for preprocess\r
+    //\r
+    if (mGlobals.Preprocess && (mGlobals.StringHFileName[0] == 0)) {\r
+      Error (UTILITY_NAME, 0, 0, NULL, "must specify string defines file name to preprocess before scan");\r
       Usage ();\r
       return STATUS_ERROR;\r
     }\r
@@ -2184,14 +2265,14 @@ ProcessArgs (
     while (Argc > 0) {\r
       NewList = malloc (sizeof (TEXT_STRING_LIST));\r
       if (NewList == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);\r
         return STATUS_ERROR;\r
       }\r
 \r
       memset (NewList, 0, sizeof (TEXT_STRING_LIST));\r
       NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);\r
       if (NewList->Str == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);\r
+        Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2211,7 +2292,7 @@ ProcessArgs (
     // Parse mode -- must specify an input unicode file name\r
     //\r
     if (Argc < 1) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");\r
       Usage ();\r
       return STATUS_ERROR;\r
     }\r
@@ -2222,7 +2303,7 @@ ProcessArgs (
   return STATUS_SUCCESS;\r
 }\r
 //\r
-// Found "-lang eng,spa+cat" on the command line. Parse the\r
+// Found "-lang zh-Hans;en-US" on the command line. Parse the\r
 // language list and save the setting for later processing.\r
 //\r
 static\r
@@ -2231,69 +2312,33 @@ AddCommandLineLanguage (
   IN INT8          *Language\r
   )\r
 {\r
+  char              Separator[] = ";";\r
+  char              *Token;\r
   WCHAR_STRING_LIST *WNewList;\r
-  WCHAR             *From;\r
-  WCHAR             *To;\r
+\r
   //\r
   // Keep processing the input string until we find the end.\r
   //\r
-  while (*Language) {\r
-    //\r
-    // Allocate memory for a new list element, fill it in, and\r
-    // add it to our list.\r
-    //\r
+  Token = strtok (Language, Separator);\r
+  while (Token != NULL) {\r
     WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));\r
     if (WNewList == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
       return STATUS_ERROR;\r
     }\r
-\r
-    memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));\r
-    WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));\r
+    WNewList->Next = NULL;\r
+    WNewList->Str  = MALLOC ((strlen (Token) + 1) * sizeof (WCHAR));\r
     if (WNewList->Str == NULL) {\r
       free (WNewList);\r
-      Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+      Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
       return STATUS_ERROR;\r
     }\r
-    //\r
-    // Copy it as unicode to our new structure. Then remove the\r
-    // plus signs in it, and verify each language name is 3 characters\r
-    // long. If we find a comma, then we're done with this group, so\r
-    // break out.\r
-    //\r
 #ifdef USE_VC8\r
-    swprintf (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%S", Language);\r
+    swprintf (WNewList->Str, (strlen (Token) + 1) * sizeof (WCHAR), L"%S", Token);\r
 #else\r
-    swprintf (WNewList->Str, L"%S", Language);\r
+    swprintf (WNewList->Str, L"%S", Token);\r
 #endif\r
-    From = To = WNewList->Str;\r
-    while (*From) {\r
-      if (*From == L',') {\r
-        break;\r
-      }\r
 \r
-      if ((wcslen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||\r
-            (\r
-              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&\r
-              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&\r
-              (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')\r
-            )\r
-          ) {\r
-        Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");\r
-        FREE (WNewList->Str);\r
-        FREE (WNewList);\r
-        return STATUS_ERROR;\r
-      }\r
-\r
-      wcsncpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);\r
-      To += LANGUAGE_IDENTIFIER_NAME_LEN;\r
-      From += LANGUAGE_IDENTIFIER_NAME_LEN;\r
-      if (*From == L'+') {\r
-        From++;\r
-      }\r
-    }\r
-\r
-    *To = 0;\r
     //\r
     // Add it to our linked list\r
     //\r
@@ -2304,17 +2349,7 @@ AddCommandLineLanguage (
     }\r
 \r
     mGlobals.LastLanguage = WNewList;\r
-    //\r
-    // Skip to next entry (comma-separated list)\r
-    //\r
-    while (*Language) {\r
-      if (*Language == L',') {\r
-        Language++;\r
-        break;\r
-      }\r
-\r
-      Language++;\r
-    }\r
+    Token = strtok (NULL, Separator);\r
   }\r
 \r
   return STATUS_SUCCESS;\r
@@ -2449,6 +2484,166 @@ Done:
   return STATUS_SUCCESS;\r
 }\r
 \r
+static\r
+INTN\r
+PreprocessSourceFile (\r
+  UINT8 *SourceFileName\r
+  )\r
+{\r
+  char              *Cptr;\r
+  FILE              *InFptr;\r
+  FILE              *OutFptr;\r
+  UINT32            CmdLen;\r
+  char              *PreProcessCmd;\r
+  char              BaseName[MAX_PATH];\r
+  char              TempFileName[MAX_PATH];\r
+  char              SourceFileDir[MAX_PATH];\r
+  char              Line[MAX_LINE_LEN];\r
+  TEXT_STRING_LIST  *List;\r
+  char              InsertLine[] = "#undef STRING_TOKEN\n";\r
+  int               Status;\r
+\r
+  //\r
+  // Check whehter source file exist\r
+  //\r
+  InFptr = fopen (SourceFileName, "r");\r
+  if (InFptr == NULL) {\r
+    Error (NULL, 0, 0, SourceFileName, "failed to open input file for scanning");\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  //\r
+  // Get source file directory\r
+  //\r
+  strcpy (SourceFileDir, SourceFileName);\r
+  Cptr = strrchr (SourceFileDir, '\\');\r
+  if (Cptr != NULL) {\r
+    *Cptr = '\0';\r
+  }\r
+\r
+  //\r
+  // Generate preprocess output file name\r
+  //\r
+  strcpy (BaseName, mGlobals.OutputDatabaseFileName);\r
+  Cptr = strrchr (BaseName, '\\');\r
+  if (Cptr != NULL) {\r
+    *++Cptr = '\0';\r
+  }\r
+\r
+  Cptr = strrchr (SourceFileName, '\\');\r
+  if (Cptr != NULL) {\r
+    Cptr++;\r
+  }\r
+  strcat (BaseName, Cptr);\r
+\r
+  Cptr = strrchr (BaseName, '.');\r
+  if (Cptr != NULL) {\r
+    *Cptr = '\0';\r
+  }\r
+\r
+  strcpy (mGlobals.PreprocessFileName, BaseName);\r
+  strcat (mGlobals.PreprocessFileName, PREPROCESS_OUTPUT_FILE_EXTENSION);\r
+\r
+  strcpy (TempFileName, BaseName);\r
+  strcat (TempFileName, PREPROCESS_TEMP_FILE_EXTENSION);\r
+\r
+  //\r
+  // Insert "#undef STRING_TOKEN" after each line of "#include ...", so as to\r
+  // preserve the STRING_TOKEN() for scanning after preprocess\r
+  //\r
+  OutFptr = fopen (TempFileName, "w");\r
+  if (OutFptr == NULL) {\r
+    Error (NULL, 0, 0, TempFileName, "failed to open file for write");\r
+    fclose (InFptr);\r
+    return STATUS_ERROR;\r
+  }\r
+  while (fgets (Line, MAX_LINE_LEN, InFptr) != NULL) {\r
+    fputs (Line, OutFptr);\r
+    Cptr = Line;\r
+\r
+    //\r
+    // Skip leading blank space\r
+    //\r
+    while (*Cptr == ' ' || *Cptr == '\t') {\r
+      Cptr++;\r
+    }\r
+\r
+    if (*Cptr == '#' && strncmp (Cptr + 1, "include", 7) == 0){\r
+      fputs (InsertLine, OutFptr);\r
+    }\r
+  }\r
+  fclose (InFptr);\r
+  fclose (OutFptr);\r
+\r
+  //\r
+  // Prepare preprocess command\r
+  //\r
+  CmdLen = 1;\r
+  CmdLen += strlen (PREPROCESSOR_COMMAND);\r
+  CmdLen++;\r
+  CmdLen += strlen (PREPROCESSOR_OPTIONS);\r
+  CmdLen++;\r
+\r
+  //\r
+  // "-I SourceFileDir "\r
+  //\r
+  CmdLen += strlen (SourceFileDir);\r
+  CmdLen += 4;\r
+\r
+  List = mGlobals.PreprocessFlags;\r
+  while (List != NULL) {\r
+    CmdLen += strlen (List->Str);\r
+    CmdLen++;\r
+\r
+    List = List->Next;\r
+  }\r
+\r
+  CmdLen += strlen (TempFileName);\r
+  CmdLen += 3;\r
+  CmdLen += strlen (mGlobals.PreprocessFileName);\r
+\r
+  PreProcessCmd = malloc (CmdLen);\r
+  if (PreProcessCmd == NULL) {\r
+    Error (NULL, 0, 0, UTILITY_NAME, "memory allocation fail (%d bytes)\n", CmdLen);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  strcpy (PreProcessCmd, PREPROCESSOR_COMMAND);\r
+  strcat (PreProcessCmd, " ");\r
+  strcat (PreProcessCmd, PREPROCESSOR_OPTIONS);\r
+  strcat (PreProcessCmd, " ");\r
+\r
+\r
+  strcat (PreProcessCmd, "-I ");\r
+  strcat (PreProcessCmd, SourceFileDir);\r
+  strcat (PreProcessCmd, " ");\r
+\r
+  List = mGlobals.PreprocessFlags;\r
+  while (List != NULL) {\r
+    strcat (PreProcessCmd, List->Str);\r
+    strcat (PreProcessCmd, " ");\r
+\r
+    List = List->Next;\r
+  }\r
+\r
+  strcat (PreProcessCmd, TempFileName);\r
+  strcat (PreProcessCmd, " > ");\r
+  strcat (PreProcessCmd, mGlobals.PreprocessFileName);\r
+\r
+  //\r
+  // Preprocess the source file\r
+  //\r
+  Status = system (PreProcessCmd);\r
+  if (Status != 0) {\r
+    Error (NULL, 0, 0, PreProcessCmd, "failed to spawn C preprocessor on source file\n");\r
+    free (PreProcessCmd);\r
+    return STATUS_ERROR;\r
+  }\r
+\r
+  free (PreProcessCmd);\r
+  return STATUS_SUCCESS;\r
+}\r
+\r
 static\r
 STATUS\r
 ScanFiles (\r
@@ -2457,6 +2652,7 @@ ScanFiles (
 {\r
   char              Line[MAX_LINE_LEN];\r
   FILE              *Fptr;\r
+  char              *FileName;\r
   UINT32            LineNum;\r
   char              *Cptr;\r
   char              *SavePtr;\r
@@ -2464,6 +2660,7 @@ ScanFiles (
   char              *StringTokenPos;\r
   TEXT_STRING_LIST  *SList;\r
   BOOLEAN           SkipIt;\r
+  BOOLEAN           FileExist;\r
 \r
   //\r
   // Put a null-terminator at the end of the line. If we read in\r
@@ -2474,6 +2671,7 @@ ScanFiles (
   // Process each file. If they gave us a skip extension list, then\r
   // skip it if the extension matches.\r
   //\r
+  FileExist = FALSE;\r
   while (ScanFiles != NULL) {\r
     SkipIt = FALSE;\r
     for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {\r
@@ -2493,9 +2691,36 @@ ScanFiles (
         printf ("Scanning %s\n", ScanFiles->Str);\r
       }\r
 \r
-      Fptr = fopen (ScanFiles->Str, "r");\r
+      if (mGlobals.Preprocess) {\r
+        //\r
+        // Create an empty string defines file for preprocessor\r
+        //\r
+        if (!FileExist) {\r
+          Fptr = fopen (mGlobals.StringHFileName, "w");\r
+          if (Fptr == NULL) {\r
+            Error (NULL, 0, 0, mGlobals.StringHFileName, "failed to open file for write");\r
+            return STATUS_ERROR;\r
+          }\r
+\r
+          fclose (Fptr);\r
+          FileExist = TRUE;\r
+        }\r
+\r
+        //\r
+        // Preprocess using C preprocessor\r
+        //\r
+        if (PreprocessSourceFile (ScanFiles->Str) != STATUS_SUCCESS) {\r
+          return STATUS_ERROR;\r
+        }\r
+\r
+        FileName = mGlobals.PreprocessFileName;\r
+      } else {\r
+        FileName = ScanFiles->Str;\r
+      }\r
+\r
+      Fptr = fopen (FileName, "r");\r
       if (Fptr == NULL) {\r
-        Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");\r
+        Error (NULL, 0, 0, FileName, "failed to open input file for scanning");\r
         return STATUS_ERROR;\r
       }\r
 \r
@@ -2613,6 +2838,13 @@ ScanFiles (
     ScanFiles = ScanFiles->Next;\r
   }\r
 \r
+  //\r
+  // Remove the empty string defines file\r
+  //\r
+  if (FileExist) {\r
+    remove (mGlobals.StringHFileName);\r
+  }\r
+\r
   return STATUS_SUCCESS;\r
 }\r
 //\r
@@ -2647,6 +2879,15 @@ FreeLists (
     mGlobals.ScanFileName = Temp;\r
   }\r
   //\r
+  // Free up preprocess flags list\r
+  //\r
+  while (mGlobals.PreprocessFlags != NULL) {\r
+    Temp = mGlobals.PreprocessFlags->Next;\r
+    free (mGlobals.PreprocessFlags->Str);\r
+    free (mGlobals.PreprocessFlags);\r
+    mGlobals.PreprocessFlags = Temp;\r
+  }\r
+  //\r
   // If they gave us a list of filename extensions to\r
   // skip on scan, then free them up.\r
   //\r
@@ -2767,7 +3008,7 @@ Usage (
 Routine Description:\r
 \r
   Print usage information for this utility.\r
-  \r
+\r
 Arguments:\r
 \r
   None.\r
@@ -2775,51 +3016,62 @@ Arguments:
 Returns:\r
 \r
   Nothing.\r
-  \r
+\r
 --*/\r
 {\r
-  int               Index;\r
-  static const char *Str[] = {\r
+  int         Index;\r
+  const char  *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI String Gather Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+\r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
     "",\r
-    PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",\r
-    "  Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",\r
-    "         "PROGRAM_NAME " -scan {scan options} [FileName]",\r
-    "         "PROGRAM_NAME " -dump {dump options}",\r
-    "    Common options include:",\r
-    "      -h or -?         for this help information",\r
-    "      -db Database     required name of output/input database file",\r
-    "      -bn BaseName     for use in the .h and .c output files",\r
-    "                       Default = "DEFAULT_BASE_NAME,\r
-    "      -v               for verbose output",\r
-    "      -vdbw            for verbose output when writing database",\r
-    "      -vdbr            for verbose output when reading database",\r
-    "      -od FileName     to specify an output database file name",\r
-    "    Parse options include:",\r
-    "      -i IncludePath   add IncludePath to list of search paths",\r
-    "      -dep FileName    to specify an output dependency file name",\r
-    "      -newdb           to not read in existing database file",\r
-    "      -uqs             to indicate that unquoted strings are used",\r
-    "      FileNames        name of one or more unicode files to parse",\r
-    "    Scan options include:",\r
-    "      -scan            scan text file(s) for STRING_TOKEN() usage",\r
-    "      -skipext .ext    to skip scan of files with .ext filename extension",\r
-    "      -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
-    "                       found in the database",\r
-    "      FileNames        one or more files to scan",\r
-    "    Dump options include:",\r
-    "      -oc FileName     write string data to FileName",\r
-    "      -oh FileName     write string defines to FileName",\r
-    "      -ou FileName     dump database to unicode file FileName",\r
-    "      -lang Lang       only dump for the language 'Lang'",\r
-    "      -if FileName     to specify an indirection file",\r
-    "      -hpk FileName    to create an HII export pack of the strings",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" -parse [OPTION] FILE",\r
+    "  "UTILITY_NAME" -scan  [OPTION] FILE",\r
+    "  "UTILITY_NAME" -dump  [OPTION]",\r
+    "Description:",\r
+    "  Process unicode strings file.",\r
+    "Common options include:",\r
+    "  -h or -?         for this help information",\r
+    "  -db Database     required name of output/input database file",\r
+    "  -bn BaseName     for use in the .h and .c output files",\r
+    "                   Default = "DEFAULT_BASE_NAME,\r
+    "  -v               for verbose output",\r
+    "  -vdbw            for verbose output when writing database",\r
+    "  -vdbr            for verbose output when reading database",\r
+    "  -od FileName     to specify an output database file name",\r
+    "Parse options include:",\r
+    "  -i IncludePath   add IncludePath to list of search paths",\r
+    "  -dep FileName    to specify an output dependency file name",\r
+    "  -newdb           to not read in existing database file",\r
+    "  -uqs             to indicate that unquoted strings are used",\r
+    "  FileNames        name of one or more unicode files to parse",\r
+    "Scan options include:",\r
+    "  -scan            scan text file(s) for STRING_TOKEN() usage",\r
+    "  -skipext .ext    to skip scan of files with .ext filename extension",\r
+    "  -ppflag \"Flags\"  to specify the C preprocessor flags",\r
+    "  -oh FileName     to specify string defines file name for preprocessor",\r
+    "  -ignorenotfound  ignore if a given STRING_TOKEN(STR) is not ",\r
+    "                   found in the database",\r
+    "  FileNames        one or more files to scan",\r
+    "Dump options include:",\r
+    "  -oc FileName     write string data to FileName",\r
+    "  -oh FileName     write string defines to FileName",\r
+    "  -ou FileName     dump database to unicode file FileName",\r
+    "  -lang Lang       only dump for the language 'Lang'",\r
+    "                   use ';' to separate multiple languages",\r
+    "  -if FileName     to specify an indirection file",\r
+    "  -hpk FileName    to create an HII export pack of the strings",\r
     "",\r
-    "  The expected process is to parse a unicode string file to create an initial",\r
-    "  database of string identifier names and string definitions. Then text files",\r
-    "  should be scanned for STRING_TOKEN() usages, and the referenced",\r
-    "  strings will be tagged as used in the database. After all files have been",\r
-    "  scanned, then the database should be dumped to create the necessary output",\r
-    "  files.",\r
+    "The expected process is to parse a unicode string file to create an initial",\r
+    "database of string identifier names and string definitions. Then text files",\r
+    "should be scanned for STRING_TOKEN() usages, and the referenced",\r
+    "strings will be tagged as used in the database. After all files have been",\r
+    "scanned, then the database should be dumped to create the necessary output",\r
+    "files.",\r
     "",\r
     NULL\r
   };\r
index c45fe2855268c7361bfb34676aa50f4e652780fa..4ab20d935937be8146aeac450c4aa9886d68416c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -25,8 +25,6 @@ Abstract:
 #define MALLOC(size)  malloc (size)\r
 #define FREE(ptr)     do { if ((ptr) != NULL) { free (ptr); } } while (0)\r
 \r
-#define PROGRAM_NAME  "StrGather"\r
-\r
 typedef CHAR16  WCHAR;\r
 \r
 #define UNICODE_TO_ASCII(w)   (INT8) ((w) & 0xFF)\r
index 563204bab98c604d1c92e0d5a24cd7e911315548..eaa15ad76304af2af7198c18affe36a2fee732a0 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -2559,13 +2559,15 @@ ExportPackOut:
 \r
 STATUS\r
 StringDBCreateHiiExportPack (\r
-  INT8                        *FileName\r
+  INT8                        *FileName,\r
+  WCHAR_STRING_LIST           *LanguagesOfInterest\r
   )\r
 {\r
-  FILE                            *File       = NULL;\r
-  LANGUAGE_LIST                   *Lang       = NULL;\r
-  EFI_HII_STRING_PACKAGE_HDR      *StrPkgHdr  = NULL;\r
-  SPkgBlkBuffer                   *BlkList    = NULL;\r
+  FILE                            *File;\r
+  LANGUAGE_LIST                   *Lang;\r
+  EFI_HII_STRING_PACKAGE_HDR      *StrPkgHdr;\r
+  SPkgBlkBuffer                   *BlkList;\r
+  WCHAR_STRING_LIST               *LOIPtr;\r
 \r
   if (FileName == NULL) {\r
     return STATUS_ERROR;\r
@@ -2577,18 +2579,26 @@ StringDBCreateHiiExportPack (
   }\r
 \r
   for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
-    if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {\r
-      fclose (File);\r
-      return STATUS_SUCCESS;\r
+    for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {\r
+      if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {\r
+        break;\r
+      }\r
     }\r
 \r
-    StrPkgWriteHdrBinary (File, StrPkgHdr);\r
-    StrPkgWriteBlkListBinary (File, BlkList);\r
+    if ((LanguagesOfInterest == NULL) ||\r
+        (LanguagesOfInterest != NULL && LOIPtr != NULL)) {\r
+      if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {\r
+        fclose (File);\r
+        return STATUS_SUCCESS;\r
+      }\r
 \r
-    StrPkgHdrFree (StrPkgHdr);\r
-    StrPkgBlkBufferListFree (BlkList);\r
-  }\r
+      StrPkgWriteHdrBinary (File, StrPkgHdr);\r
+      StrPkgWriteBlkListBinary (File, BlkList);\r
 \r
+      StrPkgHdrFree (StrPkgHdr);\r
+      StrPkgBlkBufferListFree (BlkList);\r
+    }\r
+  }\r
   fclose (File);\r
   return STATUS_SUCCESS;\r
 }\r
@@ -2605,16 +2615,18 @@ static const char *gSourceFileHeader[] = {
 STATUS\r
 StringDBDumpCStrings (\r
   INT8                            *BaseName,\r
-  INT8                            *FileName\r
+  INT8                            *FileName,\r
+  WCHAR_STRING_LIST               *LanguagesOfInterest\r
   )\r
 {\r
   EFI_STATUS                      Status;\r
-  FILE                            *File       = NULL;\r
-  LANGUAGE_LIST                   *Lang       = NULL;\r
-  EFI_HII_STRING_PACKAGE_HDR      **StrPkgHdr = NULL;\r
-  SPkgBlkBuffer                   **BlkList   = NULL;\r
+  FILE                            *File;\r
+  LANGUAGE_LIST                   *Lang;\r
+  EFI_HII_STRING_PACKAGE_HDR      **StrPkgHdr;\r
+  SPkgBlkBuffer                   **BlkList;\r
   UINT32                          Index;\r
-  UINT32                          LangNumber  = 0;\r
+  UINT32                          LangNumber;\r
+  WCHAR_STRING_LIST               *LOIPtr;\r
 \r
   if ((BaseName == NULL) || (FileName == NULL)) {\r
     return STATUS_ERROR;\r
@@ -2631,14 +2643,36 @@ StringDBDumpCStrings (
   BlkList = (SPkgBlkBuffer **) malloc (sizeof (SPkgBlkBuffer *) * LangNumber);\r
   for (Index = 0; Index < LangNumber; Index++) {\r
     StrPkgHdr[Index] = NULL;\r
-    BlkList[Index] = NULL;\r
+    BlkList[Index]   = NULL;\r
   }\r
 \r
-  for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {\r
-    Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);\r
-    if (EFI_ERROR(Status)) {\r
-      return Status;\r
+  for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {\r
+    for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {\r
+      if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {\r
+        break;\r
+      }\r
     }\r
+    if ((LanguagesOfInterest == NULL) ||\r
+        (LanguagesOfInterest != NULL && LOIPtr != NULL)) {\r
+      Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);\r
+      Index++;\r
+      if (EFI_ERROR(Status)) {\r
+        free (StrPkgHdr);\r
+        free (BlkList);\r
+        return STATUS_ERROR;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // Update LangNumber after filter\r
+  //\r
+  LangNumber = Index;\r
+\r
+  if (LangNumber == 0) {\r
+    free (StrPkgHdr);\r
+    free (BlkList);\r
+    return STATUS_SUCCESS;\r
   }\r
 \r
   if ((File = fopen (FileName, "w")) == NULL) {\r
@@ -2657,11 +2691,9 @@ StringDBDumpCStrings (
   //\r
   StrPkgWirteArrayLength (File, LangNumber, StrPkgHdr);\r
 \r
-  for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {\r
-    if (StrPkgHdr[Index] != NULL) {\r
-      StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);\r
-      StrPkgWriteBlkListCFile (File, BlkList[Index], (Lang->Next == NULL) ? TRUE : FALSE);\r
-    }\r
+  for (Index = 0; Index < LangNumber; Index++) {\r
+    StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);\r
+    StrPkgWriteBlkListCFile (File, BlkList[Index], (Index == LangNumber - 1) ? TRUE : FALSE);\r
 \r
     StrPkgHdrFree (StrPkgHdr[Index]);\r
     StrPkgBlkBufferListFree (BlkList[Index]);\r
@@ -2670,5 +2702,7 @@ StringDBDumpCStrings (
   fprintf (File, "\n};\n");\r
 \r
   fclose (File);\r
+  free (StrPkgHdr);\r
+  free (BlkList);\r
   return STATUS_SUCCESS;\r
 }\r
index 9e4088bcf870b215f6e0a02b49c8fc668fe33135..d98b5b71cc74b9718095dc897a1fc7417435a9ec 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -134,11 +134,13 @@ typedef struct _SPkgBlkBuffer {
 void\r
 StringDBConstructor (\r
   void\r
-  );\r
+  )\r
+;\r
 void\r
 StringDBDestructor (\r
   void\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBAddString (\r
@@ -148,12 +150,14 @@ StringDBAddString (
   WCHAR   *String,\r
   BOOLEAN Format,\r
   UINT16  Flags\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBSetScope (\r
   WCHAR   *Scope\r
-  );\r
+  )\r
+;\r
 \r
 #define STRING_FLAGS_REFERENCED           0x0001  // if referenced somewhere\r
 #define STRING_FLAGS_UNDEFINED            0x0002  // if we added it for padding purposes\r
@@ -167,72 +171,92 @@ StringDBAddStringIdentifier (
   WCHAR     *StringIdentifier,\r
   UINT16    *NewId,\r
   UINT16    Flags\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBReadDatabase (\r
   INT8    *DBFileName,\r
   BOOLEAN IgnoreIfNotExist,\r
   BOOLEAN Verbose\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBWriteDatabase (\r
   INT8    *DBFileName,\r
   BOOLEAN Verbose\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBDumpDatabase (\r
   INT8                *DBFileName,\r
   INT8                *OutputFileName,\r
   BOOLEAN             Verbose\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBAddLanguage (\r
   WCHAR *LanguageName,\r
   WCHAR *PrintableLanguageName,\r
   WCHAR *SecondaryLanguageList\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBAddSecondaryLanguage (\r
   WCHAR *LanguageName,\r
   WCHAR *SecondaryLanguageList\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBDumpCStrings (\r
   INT8                            *BaseName,\r
-  INT8                            *FileName\r
-  );\r
+  INT8                            *FileName,\r
+  WCHAR_STRING_LIST               *LanguagesOfInterests\r
+  )\r
+;\r
+\r
+STATUS\r
+StringDBCreateHiiExportPack (\r
+  INT8                            *OutputFileName,\r
+  WCHAR_STRING_LIST               *LanguagesOfInterests\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBDumpStringDefines (\r
   INT8                *FileName,\r
   INT8                *BaseName\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBSetCurrentLanguage (\r
   WCHAR *LanguageName\r
-  );\r
+  )\r
+;\r
 \r
 STATUS\r
 StringDBSetStringReferenced (\r
   INT8      *StringIdentifierName,\r
   BOOLEAN   IgnoreNotFound\r
-  );\r
+  )\r
+;\r
 \r
 void\r
 StringDBFormatString (\r
   WCHAR   *String\r
-  );\r
+  )\r
+;\r
 \r
 LANGUAGE_LIST *\r
 StringDBFindLanguageList (\r
   WCHAR *LanguageName\r
-  );\r
+  )\r
+;\r
 \r
 #endif // #ifndef _STRING_DB_H_\r
index 55830c9907ef4200f09711fcb5005aaea5acda73..b4a849db7b6f6420ad0ee5cfd1f6585d60d74aff 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -15,8 +15,6 @@ Module Name:
 \r
 Abstract:\r
 \r
-  Defines and prototypes for the UEFI VFR compiler internal use.\r
-  \r
 --*/\r
 \r
 #ifndef _EFIVFR_H_\r
index 6adef8a41b2a68f850bcd32289cc7c820245e9cc..2972e1692ab2e755ddfc3a356bddeb663b75741d 100644 (file)
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 Module Name:\r
 \r
-VfrCompiler.cpp\r
+  VfrCompiler.cpp\r
 \r
 Abstract:\r
 \r
@@ -41,7 +41,7 @@ CVfrCompiler::IS_RUN_STATUS (
 \r
 VOID\r
 CVfrCompiler::OptionInitialization (\r
-  IN INT32      Argc, \r
+  IN INT32      Argc,\r
   IN INT8       **Argv\r
   )\r
 {\r
@@ -57,6 +57,7 @@ CVfrCompiler::OptionInitialization (
   mOptions.PreprocessorOutputFileName[0] = '\0';\r
   mOptions.VfrBaseFileName[0]            = '\0';\r
   mOptions.IncludePaths                  = NULL;\r
+  mOptions.SkipCPreprocessor             = FALSE;\r
   mOptions.CPreprocessorOptions          = NULL;\r
 \r
   for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {\r
@@ -70,7 +71,7 @@ CVfrCompiler::OptionInitialization (
     } else if (_stricmp(Argv[Index], "-i") == 0) {\r
       Index++;\r
       if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
-        printf ("%s -i - missing path argument\n", PROGRAM_NAME);\r
+        printf ("%s -i - missing path argument\n", UTILITY_NAME);\r
         goto Fail;\r
       }\r
 \r
@@ -78,30 +79,33 @@ CVfrCompiler::OptionInitialization (
     } else if (_stricmp(Argv[Index], "-od") == 0) {\r
       Index++;\r
       if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
-        printf ("%s -od - missing output directory name\n", PROGRAM_NAME);\r
+        printf ("%s -od - missing output directory name\n", UTILITY_NAME);\r
         goto Fail;\r
       }\r
       strcpy (mOptions.OutputDirectory, Argv[Index]);\r
+      strcat (mOptions.OutputDirectory, "\\");\r
     } else if (_stricmp(Argv[Index], "-ibin") == 0) {\r
       mOptions.CreateIfrPkgFile = TRUE;\r
     } else if (_stricmp(Argv[Index], "-nostrings") == 0) {\r
+    } else if (_stricmp(Argv[Index], "-nopp") == 0) {\r
+      mOptions.SkipCPreprocessor = TRUE;\r
     } else if (_stricmp(Argv[Index], "-ppflag") == 0) {\r
       Index++;\r
       if ((Index >= Argc) || (Argv[Index][0] == '-')) {\r
-        printf ("%s -od - missing C-preprocessor argument\n", PROGRAM_NAME);\r
+        printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);\r
         goto Fail;\r
       }\r
 \r
       AppendCPreprocessorOptions (Argv[Index]);\r
     } else {\r
-      printf ("%s unrecognized option %s\n", PROGRAM_NAME, Argv[Index]);\r
+      printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);\r
       Usage ();\r
       goto Fail;\r
     }\r
   }\r
 \r
   if (Index != Argc - 1) {\r
-    printf ("%s must specify VFR file name", PROGRAM_NAME);\r
+    printf ("%s must specify VFR file name\n", UTILITY_NAME);\r
     Usage ();\r
     goto Fail;\r
   } else {\r
@@ -140,7 +144,7 @@ Fail:
   if (mOptions.IncludePaths != NULL) {\r
     delete mOptions.IncludePaths;\r
     mOptions.IncludePaths                = NULL;\r
-  } \r
+  }\r
   if (mOptions.CPreprocessorOptions != NULL) {\r
     delete mOptions.CPreprocessorOptions;\r
     mOptions.CPreprocessorOptions        = NULL;\r
@@ -161,7 +165,7 @@ CVfrCompiler::AppendIncludePath (
   }\r
   IncludePaths = new INT8[Len];\r
   if (IncludePaths == NULL) {\r
-    printf ("%s memory allocation failure\n", PROGRAM_NAME);\r
+    printf ("%s memory allocation failure\n", UTILITY_NAME);\r
     return;\r
   }\r
   IncludePaths[0] = '\0';\r
@@ -190,7 +194,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
   }\r
   Opt = new INT8[Len];\r
   if (Opt == NULL) {\r
-    printf ("%s memory allocation failure\n", PROGRAM_NAME);\r
+    printf ("%s memory allocation failure\n", UTILITY_NAME);\r
     return;\r
   }\r
   Opt[0] = 0;\r
@@ -217,7 +221,11 @@ CVfrCompiler::SetBaseFileName (
   }\r
 \r
   pFileName = mOptions.VfrFileName;\r
-  while ((pPath = strchr (pFileName, '\\')) != NULL) {\r
+  while (\r
+    ((pPath = strchr (pFileName, '\\')) != NULL) ||\r
+    ((pPath = strchr (pFileName, '/')) != NULL)\r
+    )\r
+  {\r
     pFileName = pPath + 1;\r
   }\r
 \r
@@ -300,7 +308,7 @@ CVfrCompiler::SetRecordListFileName (
 }\r
 \r
 CVfrCompiler::CVfrCompiler (\r
-  IN INT32      Argc, \r
+  IN INT32      Argc,\r
   IN INT8       **Argv\r
   )\r
 {\r
@@ -333,35 +341,40 @@ CVfrCompiler::~CVfrCompiler (
   SET_RUN_STATUS(STATUS_DEAD);\r
 }\r
 \r
-VOID \r
+VOID\r
 CVfrCompiler::Usage (\r
   VOID\r
   )\r
 {\r
-  UINT32 Index;\r
-  CONST  INT8 *Help[] = {\r
-    " ", \r
-    "VfrCompile version " VFR_COMPILER_VERSION,\r
-    " ",\r
-    "  Usage: VfrCompile {options} [VfrFile]",\r
-    " ",\r
-    "    where options include:",\r
-    "      -? or -h       prints this help",\r
-    "      -l             create an output IFR listing file",\r
-    "      -i IncPath     add IncPath to the search path for VFR included files",\r
-    "      -od OutputDir  deposit all output files to directory OutputDir (default=cwd)",\r
-    "      -ibin          create an IFR HII pack file"\r
-    "      -ppflag        C-preprocessor argument",\r
-    "    where parameters include:",\r
-    "      VfrFile        name of the input VFR script file",\r
-    " ",\r
+  int          Index;\r
+  const char   *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION] VFRFILE",\r
+    "Description:",\r
+    "  Compile VFRFILE.",\r
+    "Options:",\r
+    "  -? or -h        print this help",\r
+    "  -l              create an output IFR listing file",\r
+    "  -i IncPath      add IncPath to the search path for VFR included files",\r
+    "  -od OutputDir   deposit all output files to directory OutputDir (default=cwd)",\r
+    "  -ibin           create an IFR HII pack file",\r
+    "  -ppflag CFlags  pass Flags as C-preprocessor-flag",\r
+    "  -v or -version  print version information",\r
     NULL\r
-    };\r
-  for (Index = 0; Help[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Help[Index]);\r
+  };\r
+\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
   }\r
 }\r
 \r
+\r
 VOID\r
 CVfrCompiler::PreProcess (\r
   VOID\r
@@ -375,8 +388,12 @@ CVfrCompiler::PreProcess (
     goto Fail;\r
   }\r
 \r
+  if (mOptions.SkipCPreprocessor == TRUE) {\r
+    goto Out;\r
+  }\r
+\r
   if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {\r
-    printf ("%s could not open input VFR file - %s\n", PROGRAM_NAME, mOptions.VfrFileName);\r
+    printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);\r
     goto Fail;\r
   }\r
   fclose (pVfrFile);\r
@@ -392,7 +409,7 @@ CVfrCompiler::PreProcess (
 \r
   PreProcessCmd = new INT8[CmdLen + 10];\r
   if (PreProcessCmd == NULL) {\r
-    printf ("%s could not allocate memory\n", PROGRAM_NAME);\r
+    printf ("%s could not allocate memory\n", UTILITY_NAME);\r
     goto Fail;\r
   }\r
   strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");\r
@@ -407,11 +424,13 @@ CVfrCompiler::PreProcess (
   strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);\r
 \r
   if (system (PreProcessCmd) != 0) {\r
-    printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", PROGRAM_NAME, PreProcessCmd);\r
+    printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);\r
     goto Fail;\r
   }\r
 \r
   delete PreProcessCmd;\r
+\r
+Out:\r
   SET_RUN_STATUS (STATUS_PREPROCESSED);\r
   return;\r
 \r
@@ -429,22 +448,27 @@ CVfrCompiler::Compile (
   VOID\r
   )\r
 {\r
-  FILE *VfrFile = NULL;\r
+  FILE *pInFile    = NULL;\r
+  INT8 *InFileName = NULL;\r
 \r
   if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {\r
     goto Fail;\r
   }\r
 \r
-  if ((VfrFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
-    printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);\r
+  InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;\r
+\r
+  gCVfrErrorHandle.SetInputFile (InFileName);\r
+\r
+  if ((pInFile = fopen (InFileName, "r")) == NULL) {\r
+    printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);\r
     goto Fail;\r
   }\r
 \r
-  if (VfrParserStart (VfrFile) != 0) {\r
+  if (VfrParserStart (pInFile) != 0) {\r
     goto Fail;\r
   }\r
 \r
-  fclose (VfrFile);\r
+  fclose (pInFile);\r
 \r
   if (gCFormPkg.HavePendingUnassigned () == TRUE) {\r
     gCFormPkg.PendingAssignPrintAll ();\r
@@ -456,11 +480,11 @@ CVfrCompiler::Compile (
 \r
 Fail:\r
   if (!IS_RUN_STATUS(STATUS_DEAD)) {\r
-    printf ("%s compile error!\n", PROGRAM_NAME);\r
+    printf ("%s compile error!\n", UTILITY_NAME);\r
     SET_RUN_STATUS (STATUS_FAILED);\r
   }\r
-  if (VfrFile != NULL) {\r
-    fclose (VfrFile);\r
+  if (pInFile != NULL) {\r
+    fclose (pInFile);\r
   }\r
 }\r
 \r
@@ -477,7 +501,7 @@ CVfrCompiler::GenBinary (
 \r
   if (mOptions.CreateIfrPkgFile == TRUE) {\r
     if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {\r
-      printf ("can not open PkgFileName\n", mOptions.PkgOutputFileName);\r
+      printf ("can not open %s\n", mOptions.PkgOutputFileName);\r
       goto Fail;\r
     }\r
     if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {\r
@@ -548,27 +572,30 @@ CVfrCompiler::GenRecordListFile (
   VOID\r
   )\r
 {\r
-  FILE   *pInFile  = NULL;\r
-  FILE   *pOutFile = NULL;\r
+  INT8   *InFileName = NULL;\r
+  FILE   *pInFile    = NULL;\r
+  FILE   *pOutFile   = NULL;\r
   INT8   LineBuf[MAX_LINE_LEN];\r
   UINT32 LineNo;\r
 \r
+  InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;\r
+\r
   if (mOptions.CreateRecordListFile == TRUE) {\r
-    if ((mOptions.PreprocessorOutputFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {\r
+    if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {\r
       return;\r
     }\r
 \r
-    if ((pInFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
-      printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);\r
+    if ((pInFile = fopen (InFileName, "r")) == NULL) {\r
+      printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);\r
       return;\r
     }\r
 \r
     if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {\r
-      printf ("%s failed to open record list file for writing - %s\n", PROGRAM_NAME, mOptions.RecordListFile);\r
+      printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);\r
       goto Err1;\r
     }\r
 \r
-    fprintf (pOutFile, "//\n//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+    fprintf (pOutFile, "//\n//  VFR compiler version " UTILITY_VERSION "\n//\n");\r
     LineNo = 0;\r
     while (!feof (pInFile)) {\r
       if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {\r
@@ -590,7 +617,7 @@ Err1:
 \r
 INT32\r
 main (\r
-  IN INT32             Argc, \r
+  IN INT32             Argc,\r
   IN INT8              **Argv\r
   )\r
 {\r
index 0410f8425246c0ed8bbb2ab3b03d962d1001e9fe..bc487f88ba57335c924a0a5c2c7adc7c62809108 100644 (file)
@@ -1,17 +1,17 @@
 /*++
 
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
 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.             
 
 Module Name:
 
-VfrCompiler.h
+  VfrCompiler.h
 
 Abstract:
 
@@ -26,8 +26,8 @@ Abstract:
 #include "VfrFormPkg.h"\r
 #include "VfrUtilityLib.h"\r
 \r
-#define PROGRAM_NAME                       "VfrCompile"\r
-#define VFR_COMPILER_VERSION               "UEFI 2.1"\r
+#define UTILITY_NAME                        "VfrCompile"\r
+#define UTILITY_VERSION                     "v1.1"\r
 \r
 //\r
 // This is how we invoke the C preprocessor on the VFR source file\r
@@ -56,6 +56,7 @@ typedef struct {
   INT8    PreprocessorOutputFileName[MAX_PATH];\r
   INT8    VfrBaseFileName[MAX_PATH];  // name of input VFR file with no path or extension\r
   INT8    *IncludePaths;\r
+  bool    SkipCPreprocessor;
   INT8    *CPreprocessorOptions;\r
 } OPTIONS;\r
 \r
index 4a366136bfe58c7bf4a655d72443dff7d1e81c82..d6fc7cf9090f2c632a0b8f49dafd65ec7c53de70 100644 (file)
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 Module Name:\r
 \r
-VfrError.cpp\r
+  VfrError.cpp\r
 \r
 Abstract:\r
 \r
@@ -25,33 +25,36 @@ Abstract:
 static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {\r
   { VFR_RETURN_SUCCESS, NULL },\r
   { VFR_RETURN_ERROR_SKIPED, NULL },\r
-  { VFR_RETURN_FATAL_ERROR, "fatal error!!" },\r
-\r
-  { VFR_RETURN_MISMATCHED, "unexpected token" },\r
-  { VFR_RETURN_INVALID_PARAMETER, "Invalid parameter" },\r
-  { VFR_RETURN_OUT_FOR_RESOURCES, "system out of memory" },\r
-  { VFR_RETURN_UNSUPPORTED, "unsupported" },\r
-  { VFR_RETURN_REDEFINED, "already defined" },\r
-  { VFR_RETURN_FORMID_REDEFINED, "form id already defined" },\r
-  { VFR_RETURN_QUESTIONID_REDEFINED, "question id already defined" },\r
-  { VFR_RETURN_VARSTOREID_REDEFINED, "varstore id already defined" },\r
-  { VFR_RETURN_UNDEFINED, "undefined" },\r
-  { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, "some variable has not defined by a question"},\r
-  { VFR_RETURN_GET_EFIVARSTORE_ERROR, "get efi varstore error"},\r
-  { VFR_RETURN_EFIVARSTORE_USE_ERROR, "can not use the efi varstore like this" },\r
-  { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, "unsupport efi varstore size should be <= 8 bytes" },\r
-  { VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },\r
-  { VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" }, \r
-  { VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" }, \r
-  { VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },\r
-  { VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},\r
-  { VFR_RETURN_CODEUNDEFINED, "Undefined Error Code" }\r
+  { VFR_RETURN_FATAL_ERROR, ": fatal error!!" },\r
+\r
+  { VFR_RETURN_MISMATCHED, ": unexpected token" },\r
+  { VFR_RETURN_INVALID_PARAMETER, ": invalid parameter" },\r
+  { VFR_RETURN_OUT_FOR_RESOURCES, ": system out of memory" },\r
+  { VFR_RETURN_UNSUPPORTED, ": unsupported" },\r
+  { VFR_RETURN_REDEFINED, ": already defined" },\r
+  { VFR_RETURN_FORMID_REDEFINED, ": form id already defined" },\r
+  { VFR_RETURN_QUESTIONID_REDEFINED, ": question id already defined" },\r
+  { VFR_RETURN_VARSTOREID_REDEFINED, ": varstore id already defined" },\r
+  { VFR_RETURN_UNDEFINED, ": undefined" },\r
+  { VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, ": some variable has not defined by a question"},\r
+  { VFR_RETURN_GET_EFIVARSTORE_ERROR, ": get efi varstore error"},\r
+  { VFR_RETURN_EFIVARSTORE_USE_ERROR, ": can not use the efi varstore like this" },\r
+  { VFR_RETURN_EFIVARSTORE_SIZE_ERROR, ": unsupport efi varstore size should be <= 8 bytes" },\r
+  { VFR_RETURN_GET_NVVARSTORE_ERROR, ": get name value varstore error" },\r
+  { VFR_RETURN_QVAR_REUSE, ": variable reused by more than one question" },\r
+  { VFR_RETURN_FLAGS_UNSUPPORTED, ": flags unsupported" },\r
+  { VFR_RETURN_ERROR_ARRARY_NUM, ": array number error" },\r
+  { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},\r
+  { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},\r
+  { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},\r
+  { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }\r
 };\r
 \r
 CVfrErrorHandle::CVfrErrorHandle (\r
   VOID\r
   )\r
 {\r
+  mInputFileName       = NULL;\r
   mScopeRecordListHead = NULL;\r
   mScopeRecordListTail = NULL;\r
   mVfrErrorHandleTable = VFR_ERROR_HANDLE_TABLE;\r
@@ -63,6 +66,10 @@ CVfrErrorHandle::~CVfrErrorHandle (
 {\r
   SVfrFileScopeRecord *pNode = NULL;\r
 \r
+  if (mInputFileName != NULL) {\r
+    delete mInputFileName;\r
+  }\r
+\r
   while (mScopeRecordListHead != NULL) {\r
     pNode = mScopeRecordListHead;\r
     mScopeRecordListHead = mScopeRecordListHead->mNext;\r
@@ -74,8 +81,19 @@ CVfrErrorHandle::~CVfrErrorHandle (
   mVfrErrorHandleTable = NULL;\r
 }\r
 \r
+VOID\r
+CVfrErrorHandle::SetInputFile (\r
+  IN INT8     *InputFile\r
+  )\r
+{\r
+  if (InputFile != NULL) {\r
+    mInputFileName = new INT8[strlen(InputFile) + 1];\r
+    strcpy (mInputFileName, InputFile);\r
+  }\r
+}\r
+\r
 SVfrFileScopeRecord::SVfrFileScopeRecord (\r
-  IN INT8     *Record, \r
+  IN INT8     *Record,\r
   IN UINT32   LineNum\r
   )\r
 {\r
@@ -116,7 +134,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord (
 \r
 VOID\r
 CVfrErrorHandle::ParseFileScopeRecord (\r
-  IN INT8      *Record, \r
+  IN INT8      *Record,\r
   IN UINT32    WholeScopeLine\r
   )\r
 {\r
@@ -155,6 +173,15 @@ CVfrErrorHandle::GetFileNameLineNum (
   *FileName = NULL;\r
   *FileLine = 0xFFFFFFFF;\r
 \r
+  //\r
+  // Some errors occur before scope record list been built.\r
+  //\r
+  if (mScopeRecordListHead == NULL) {\r
+    *FileLine = LineNum;\r
+    *FileName = mInputFileName;\r
+    return ;\r
+  }\r
+\r
   for (pNode = mScopeRecordListHead; pNode->mNext != NULL; pNode = pNode->mNext) {\r
     if ((LineNum > pNode->mWholeScopeLine) && (pNode->mNext->mWholeScopeLine > LineNum)) {\r
       *FileName = pNode->mFileName;\r
@@ -168,9 +195,10 @@ CVfrErrorHandle::GetFileNameLineNum (
 }\r
 \r
 VOID\r
-CVfrErrorHandle::PrintError (\r
+CVfrErrorHandle::PrintMsg (\r
   IN UINT32               LineNum,\r
   IN INT8                 *TokName,\r
+  IN INT8                 *MsgType,\r
   IN INT8                 *ErrorMsg\r
   )\r
 {\r
@@ -178,7 +206,7 @@ CVfrErrorHandle::PrintError (
   UINT32                 FileLine;\r
 \r
   GetFileNameLineNum (LineNum, &FileName, &FileLine);\r
-  printf ("%s line %d: error %s %s\n", FileName, FileLine, TokName, ErrorMsg);\r
+  printf ("%s line %d: %s %s %s\n", FileName, FileLine, MsgType, TokName, ErrorMsg);\r
 }\r
 \r
 UINT8\r
index 3becd9b6e166bde610b4eb0bb34f63c0332d2640..8c0e4c9a47fe26b20f17df3743362b8756520b97 100644 (file)
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 Module Name:\r
 \r
-VfrError.h\r
+  VfrError.h\r
 \r
 Abstract:\r
 \r
@@ -45,6 +45,8 @@ typedef enum {
   VFR_RETURN_FLAGS_UNSUPPORTED,\r
   VFR_RETURN_ERROR_ARRARY_NUM,\r
   VFR_RETURN_DATA_STRING_ERROR,\r
+  VFR_RETURN_DEFAULT_VALUE_REDEFINED,\r
+  VFR_RETURN_CONSTANT_ONLY,\r
   VFR_RETURN_CODEUNDEFINED\r
 } EFI_VFR_RETURN_CODE;\r
 \r
@@ -65,6 +67,7 @@ struct SVfrFileScopeRecord {
 \r
 class CVfrErrorHandle {\r
 private:\r
+  INT8                *mInputFileName;\r
   SVFR_ERROR_HANDLE   *mVfrErrorHandleTable;\r
   SVfrFileScopeRecord *mScopeRecordListHead;\r
   SVfrFileScopeRecord *mScopeRecordListTail;\r
@@ -73,10 +76,11 @@ public:
   CVfrErrorHandle (VOID);\r
   ~CVfrErrorHandle (VOID);\r
 \r
+  VOID  SetInputFile (IN INT8 *);\r
   VOID  ParseFileScopeRecord (IN INT8 *, IN UINT32);\r
   VOID  GetFileNameLineNum (IN UINT32, OUT INT8 **, OUT UINT32 *);\r
   UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN INT8 *TokName = "\0");\r
-  VOID  PrintError (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *ErrorMsg = "\0");\r
+  VOID  PrintMsg (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *MsgType = "Error", IN INT8 *ErrorMsg = "\0");\r
 };\r
 \r
 #define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)\r
index ddae8654988f0f058a6802ac2b612c548461fde4..50398c6317450b22c2d13aa1aee63d10911f8947 100644 (file)
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 Module Name:\r
 \r
-VfrFormPkg.cpp\r
+  VfrFormPkg.cpp\r
 \r
 Abstract:\r
 \r
@@ -25,25 +25,34 @@ Abstract:
  */\r
 \r
 SPendingAssign::SPendingAssign (\r
-  IN INT8   *Key, \r
-  IN VOID   *Addr, \r
-  IN UINT32 Len, \r
-  IN UINT32 LineNo\r
+  IN INT8   *Key,\r
+  IN VOID   *Addr,\r
+  IN UINT32 Len,\r
+  IN UINT32 LineNo,\r
+  IN INT8   *Msg\r
   )\r
 {\r
+  mKey    = NULL;\r
+  mAddr   = Addr;\r
+  mLen    = Len;\r
+  mFlag   = PENDING;\r
+  mLineNo = LineNo;\r
+  mMsg    = NULL;\r
+  mNext   = NULL;\r
+\r
   if (Key != NULL) {\r
     mKey = new INT8[strlen (Key) + 1];\r
     if (mKey != NULL) {\r
       strcpy (mKey, Key);\r
     }\r
-  } else {\r
-    mKey = NULL;\r
   }\r
-  mAddr   = Addr;\r
-  mLen    = Len;\r
-  mFlag   = PENDING;\r
-  mLineNo = LineNo;\r
-  mNext   = NULL;\r
+\r
+  if (Msg != NULL) {\r
+    mMsg = new INT8[strlen (Msg) + 1];\r
+    if (mMsg != NULL) {\r
+      strcpy (mMsg, Msg);\r
+    }\r
+  }\r
 }\r
 \r
 SPendingAssign::~SPendingAssign (\r
@@ -56,12 +65,15 @@ SPendingAssign::~SPendingAssign (
   mAddr   = NULL;\r
   mLen    = 0;\r
   mLineNo = 0;\r
+  if (mMsg != NULL) {\r
+    delete mMsg;\r
+  }\r
   mNext   = NULL;\r
 }\r
 \r
 VOID\r
 SPendingAssign::SetAddrAndLen (\r
-  IN VOID   *Addr, \r
+  IN VOID   *Addr,\r
   IN UINT32 LineNo\r
   )\r
 {\r
@@ -71,7 +83,7 @@ SPendingAssign::SetAddrAndLen (
 \r
 VOID\r
 SPendingAssign::AssignValue (\r
-  IN VOID   *Addr, \r
+  IN VOID   *Addr,\r
   IN UINT32 Len\r
   )\r
 {\r
@@ -227,7 +239,7 @@ CFormPkg::Close (
 \r
 UINT32\r
 CFormPkg::Read (\r
-  IN CHAR8     *Buffer, \r
+  IN CHAR8     *Buffer,\r
   IN UINT32    Size\r
   )\r
 {\r
@@ -270,7 +282,7 @@ CFormPkg::BuildPkgHdr (
     return VFR_RETURN_OUT_FOR_RESOURCES;\r
   }\r
 \r
-  (*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;\r
+  (*PkgHdr)->Type = EFI_HII_PACKAGE_FORMS;\r
   (*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);\r
   return VFR_RETURN_SUCCESS;\r
 }\r
@@ -357,7 +369,7 @@ CFormPkg::_WRITE_PKG_END (
 \r
 #define BYTES_PRE_LINE 0x10\r
 \r
-EFI_VFR_RETURN_CODE \r
+EFI_VFR_RETURN_CODE\r
 CFormPkg::GenCFile (\r
   IN INT8 *BaseName,\r
   IN FILE *pFile\r
@@ -407,15 +419,16 @@ CFormPkg::GenCFile (
 \r
 EFI_VFR_RETURN_CODE\r
 CFormPkg::AssignPending (\r
-  IN INT8   *Key, \r
-  IN VOID   *ValAddr, \r
+  IN INT8   *Key,\r
+  IN VOID   *ValAddr,\r
   IN UINT32 ValLen,\r
-  IN UINT32 LineNo\r
+  IN UINT32 LineNo,\r
+  IN INT8   *Msg\r
   )\r
 {\r
   SPendingAssign *pNew;\r
 \r
-  pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo);\r
+  pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo, Msg);\r
   if (pNew == NULL) {\r
     return VFR_RETURN_OUT_FOR_RESOURCES;\r
   }\r
@@ -427,8 +440,8 @@ CFormPkg::AssignPending (
 \r
 VOID\r
 CFormPkg::DoPendingAssign (\r
-  IN INT8   *Key, \r
-  IN VOID   *ValAddr, \r
+  IN INT8   *Key,\r
+  IN VOID   *ValAddr,\r
   IN UINT32 ValLen\r
   )\r
 {\r
@@ -470,7 +483,7 @@ CFormPkg::PendingAssignPrintAll (
 \r
   for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {\r
     if (pNode->mFlag == PENDING) {\r
-      gCVfrErrorHandle.PrintError (pNode->mLineNo, pNode->mKey, "can not assign value because not defined");\r
+      gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", pNode->mMsg);\r
     }\r
   }\r
 }\r
@@ -492,10 +505,7 @@ SIfrRecord::~SIfrRecord (
   VOID\r
   )\r
 {\r
-  if (mIfrBinBuf != NULL) {\r
-    delete mIfrBinBuf;\r
-    mIfrBinBuf = NULL;\r
-  }\r
+  mIfrBinBuf   = NULL;\r
   mLineNo      = 0xFFFFFFFF;\r
   mOffset      = 0xFFFFFFFF;\r
   mBinBufLen   = 0;\r
@@ -537,8 +547,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
     return NULL;\r
   }\r
 \r
-  for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead; \r
-       (Idx != RecordIdx) && (pNode != NULL); \r
+  for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;\r
+       (Idx != RecordIdx) && (pNode != NULL);\r
        Idx++, pNode = pNode->mNext)\r
   ;\r
 \r
@@ -547,8 +557,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
 \r
 UINT32\r
 CIfrRecordInfoDB::IfrRecordRegister (\r
-  IN UINT32 LineNo, \r
-  IN CHAR8  *IfrBinBuf, \r
+  IN UINT32 LineNo,\r
+  IN CHAR8  *IfrBinBuf,\r
   IN UINT8  BinBufLen,\r
   IN UINT32 Offset\r
   )\r
@@ -577,7 +587,7 @@ CIfrRecordInfoDB::IfrRecordRegister (
 \r
 VOID\r
 CIfrRecordInfoDB::IfrRecordInfoUpdate (\r
-  IN UINT32 RecordIdx, \r
+  IN UINT32 RecordIdx,\r
   IN UINT32 LineNo,\r
   IN CHAR8  *BinBuf,\r
   IN UINT8  BinBufLen,\r
@@ -585,23 +595,25 @@ CIfrRecordInfoDB::IfrRecordInfoUpdate (
   )\r
 {\r
   SIfrRecord *pNode;\r
+  SIfrRecord *Prev;\r
 \r
   if ((pNode = GetRecordInfoFromIdx (RecordIdx)) == NULL) {\r
     return;\r
   }\r
 \r
+  if (LineNo == 0) {\r
+    //\r
+    // Line number is not specified explicitly, try to use line number of previous opcode\r
+    //\r
+    Prev = GetRecordInfoFromIdx (RecordIdx - 1);\r
+    if (Prev != NULL) {\r
+      LineNo = Prev->mLineNo;\r
+    }\r
+  }\r
   pNode->mLineNo    = LineNo;\r
   pNode->mOffset    = Offset;\r
   pNode->mBinBufLen = BinBufLen;\r
-  if (BinBuf != NULL) {\r
-    if (pNode->mIfrBinBuf != NULL) {\r
-      delete pNode->mIfrBinBuf;\r
-    }\r
-    pNode->mIfrBinBuf = new CHAR8[BinBufLen];\r
-    if (pNode->mIfrBinBuf != NULL) {\r
-      memcpy (pNode->mIfrBinBuf, BinBuf, BinBufLen);\r
-    }\r
-  }\r
+  pNode->mIfrBinBuf = BinBuf;\r
 }\r
 \r
 VOID\r
@@ -626,7 +638,7 @@ CIfrRecordInfoDB::IfrRecordOutput (
       fprintf (File, ">%08X: ", pNode->mOffset);\r
       if (pNode->mIfrBinBuf != NULL) {\r
         for (Index = 0; Index < pNode->mBinBufLen; Index++) {\r
-          fprintf (File, "%02X ", pNode->mIfrBinBuf[Index]);\r
+          fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));\r
         }\r
       }\r
       fprintf (File, "\n");\r
@@ -650,6 +662,7 @@ CIfrObj::_EMIT_PENDING_OBJ (
 \r
   if (mObjBinBuf != NULL) {\r
     delete mObjBinBuf;\r
+    mObjBinBuf = ObjBinBuf;\r
   }\r
 }\r
 \r
@@ -689,7 +702,7 @@ static struct {
   { sizeof (EFI_IFR_DATE), 1 },                // EFI_IFR_DATE_OP\r
   { sizeof (EFI_IFR_TIME), 1 },                // EFI_IFR_TIME_OP\r
   { sizeof (EFI_IFR_STRING), 1 },              // EFI_IFR_STRING_OP\r
-  { sizeof (EFI_IFR_REFRESH), 1 },             // EFI_IFR_REFRESH_OP\r
+  { sizeof (EFI_IFR_REFRESH), 0 },             // EFI_IFR_REFRESH_OP\r
   { sizeof (EFI_IFR_DISABLE_IF), 1 },          // EFI_IFR_DISABLE_IF_OP - 0x1E\r
   { 0, 0 },                                    // 0x1F\r
   { sizeof (EFI_IFR_TO_LOWER), 0 },            // EFI_IFR_TO_LOWER_OP - 0x20\r
@@ -829,10 +842,10 @@ CIfrObj::~CIfrObj (
 UINT8 gScopeCount = 0;\r
 \r
 CIfrOpHeader::CIfrOpHeader (\r
-  IN UINT8 OpCode, \r
+  IN UINT8 OpCode,\r
   IN VOID *StartAddr,\r
-  IN UINT8 Length \r
-  ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr) \r
+  IN UINT8 Length\r
+  ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)\r
 {\r
   mHeader->OpCode = OpCode;\r
   mHeader->Length = (Length == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : Length;\r
index b890b27a25cefa8621f167ed6bfe5830aafba2ad..c8e7d987563edc96e7b41ef8275a25708d78ab95 100644 (file)
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 Module Name:\r
 \r
-VfrFormPkg.h\r
+  VfrFormPkg.h\r
 \r
 Abstract:\r
 \r
@@ -25,6 +25,8 @@ Abstract:
 #include "VfrError.h"\r
 #include "VfrUtilityLib.h"\r
 \r
+#define NO_QST_REFED "no question refered"\r
+\r
 /*\r
  * The functions below are used for flags setting\r
  */\r
@@ -75,9 +77,10 @@ struct SPendingAssign {
   UINT32                  mLen;\r
   ASSIGN_FLAG             mFlag;\r
   UINT32                  mLineNo;\r
+  INT8                    *mMsg;\r
   struct SPendingAssign   *mNext;\r
 \r
-  SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);\r
+  SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *);\r
   ~SPendingAssign ();\r
 \r
   VOID   SetAddrAndLen (IN VOID *, IN UINT32);\r
@@ -126,7 +129,7 @@ public:
   EFI_VFR_RETURN_CODE GenCFile (IN INT8 *, IN FILE *);\r
 \r
 public:\r
-  EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);\r
+  EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *Msg = NULL);\r
   VOID                DoPendingAssign (IN INT8 *, IN VOID *, IN UINT32);\r
   bool                HavePendingUnassigned (VOID);\r
   VOID                PendingAssignPrintAll (VOID);\r
@@ -368,48 +371,159 @@ public:
   }\r
 };\r
 \r
-static CIfrQuestionHeader *gCurrentQuestion = NULL;\r
-\r
 /*\r
  * The definition of CIfrMinMaxStepData\r
  */\r
 class CIfrMinMaxStepData {\r
 private:\r
   MINMAXSTEP_DATA *mMinMaxStepData;\r
+  BOOLEAN         ValueIsSet;\r
+  BOOLEAN         IsNumeric;\r
 \r
 public:\r
-  CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr) : mMinMaxStepData (DataAddr) {\r
+  CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr, BOOLEAN NumericOpcode=FALSE) : mMinMaxStepData (DataAddr) {\r
     mMinMaxStepData->u64.MinValue = 0;\r
     mMinMaxStepData->u64.MaxValue = 0;\r
     mMinMaxStepData->u64.Step     = 0;\r
+    ValueIsSet = FALSE;\r
+    IsNumeric = NumericOpcode;\r
   }\r
 \r
   VOID SetMinMaxStepData (IN UINT64 MinValue, IN UINT64 MaxValue, IN UINT64 Step) {\r
-    mMinMaxStepData->u64.MinValue = MinValue;\r
-    mMinMaxStepData->u64.MaxValue = MaxValue;\r
-    mMinMaxStepData->u64.Step     = Step;\r
+    if (!ValueIsSet) {\r
+      mMinMaxStepData->u64.MinValue = MinValue;\r
+      mMinMaxStepData->u64.MaxValue = MaxValue;\r
+      ValueIsSet = TRUE;\r
+    } else {\r
+      if (MinValue < mMinMaxStepData->u64.MinValue) {\r
+        mMinMaxStepData->u64.MinValue = MinValue;\r
+      }\r
+      if (MaxValue > mMinMaxStepData->u64.MaxValue) {\r
+        mMinMaxStepData->u64.MaxValue = MaxValue;\r
+      }\r
+    }\r
+    mMinMaxStepData->u64.Step = Step;\r
   }\r
 \r
   VOID SetMinMaxStepData (IN UINT32 MinValue, IN UINT32 MaxValue, IN UINT32 Step) {\r
-    mMinMaxStepData->u32.MinValue = MinValue;\r
-    mMinMaxStepData->u32.MaxValue = MaxValue;\r
-    mMinMaxStepData->u32.Step     = Step;\r
+    if (!ValueIsSet) {\r
+      mMinMaxStepData->u32.MinValue = MinValue;\r
+      mMinMaxStepData->u32.MaxValue = MaxValue;\r
+      ValueIsSet = TRUE;\r
+    } else {\r
+      if (MinValue < mMinMaxStepData->u32.MinValue) {\r
+        mMinMaxStepData->u32.MinValue = MinValue;\r
+      }\r
+      if (MaxValue > mMinMaxStepData->u32.MaxValue) {\r
+        mMinMaxStepData->u32.MaxValue = MaxValue;\r
+      }\r
+    }\r
+    mMinMaxStepData->u32.Step = Step;\r
   }\r
 \r
   VOID SetMinMaxStepData (IN UINT16 MinValue, IN UINT16 MaxValue, IN UINT16 Step) {\r
-    mMinMaxStepData->u16.MinValue = MinValue;\r
-    mMinMaxStepData->u16.MaxValue = MaxValue;\r
-    mMinMaxStepData->u16.Step     = Step;\r
+    if (!ValueIsSet) {\r
+      mMinMaxStepData->u16.MinValue = MinValue;\r
+      mMinMaxStepData->u16.MaxValue = MaxValue;\r
+      ValueIsSet = TRUE;\r
+    } else {\r
+      if (MinValue < mMinMaxStepData->u16.MinValue) {\r
+        mMinMaxStepData->u16.MinValue = MinValue;\r
+      }\r
+      if (MaxValue > mMinMaxStepData->u16.MaxValue) {\r
+        mMinMaxStepData->u16.MaxValue = MaxValue;\r
+      }\r
+    }\r
+    mMinMaxStepData->u16.Step = Step;\r
   }\r
 \r
   VOID SetMinMaxStepData (IN UINT8 MinValue, IN UINT8 MaxValue, IN UINT8 Step) {\r
-    mMinMaxStepData->u8.MinValue = MinValue;\r
-    mMinMaxStepData->u8.MaxValue = MaxValue;\r
-    mMinMaxStepData->u8.Step     = Step;\r
+    if (!ValueIsSet) {\r
+      mMinMaxStepData->u8.MinValue = MinValue;\r
+      mMinMaxStepData->u8.MaxValue = MaxValue;\r
+      ValueIsSet = TRUE;\r
+    } else {\r
+      if (MinValue < mMinMaxStepData->u8.MinValue) {\r
+        mMinMaxStepData->u8.MinValue = MinValue;\r
+      }\r
+      if (MaxValue > mMinMaxStepData->u8.MaxValue) {\r
+        mMinMaxStepData->u8.MaxValue = MaxValue;\r
+      }\r
+    }\r
+    mMinMaxStepData->u8.Step = Step;\r
+  }\r
+\r
+  UINT64 GetMinData (UINT8 VarType) {\r
+    UINT64 MinValue = 0;\r
+    switch (VarType) {\r
+    case EFI_IFR_TYPE_NUM_SIZE_64:\r
+      MinValue = mMinMaxStepData->u64.MinValue;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_32:\r
+      MinValue = (UINT64) mMinMaxStepData->u32.MinValue;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_16:\r
+      MinValue = (UINT64) mMinMaxStepData->u16.MinValue;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_8:\r
+      MinValue = (UINT64) mMinMaxStepData->u8.MinValue;\r
+      break;\r
+    default:\r
+      break;\r
+    }\r
+    return MinValue;\r
+  }\r
+\r
+  UINT64 GetMaxData (UINT8 VarType) {\r
+    UINT64 MaxValue = 0;\r
+    switch (VarType) {\r
+    case EFI_IFR_TYPE_NUM_SIZE_64:\r
+      MaxValue = mMinMaxStepData->u64.MaxValue;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_32:\r
+      MaxValue = (UINT64) mMinMaxStepData->u32.MaxValue;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_16:\r
+      MaxValue = (UINT64) mMinMaxStepData->u16.MaxValue;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_8:\r
+      MaxValue = (UINT64) mMinMaxStepData->u8.MaxValue;\r
+      break;\r
+    default:\r
+      break;\r
+    }\r
+    return MaxValue;\r
+  }\r
+\r
+  UINT64 GetStepData (UINT8 VarType) {\r
+    UINT64 MaxValue = 0;\r
+    switch (VarType) {\r
+    case EFI_IFR_TYPE_NUM_SIZE_64:\r
+      MaxValue = mMinMaxStepData->u64.Step;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_32:\r
+      MaxValue = (UINT64) mMinMaxStepData->u32.Step;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_16:\r
+      MaxValue = (UINT64) mMinMaxStepData->u16.Step;\r
+      break;\r
+    case EFI_IFR_TYPE_NUM_SIZE_8:\r
+      MaxValue = (UINT64) mMinMaxStepData->u8.Step;\r
+      break;\r
+    default:\r
+      break;\r
+    }\r
+    return MaxValue;\r
   }\r
 \r
+  BOOLEAN IsNumericOpcode () {\r
+    return IsNumeric;\r
+  }\r
 };\r
 \r
+static CIfrQuestionHeader *gCurrentQuestion  = NULL;\r
+static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;\r
+\r
 /*\r
  * The definition of all of the UEFI IFR Objects\r
  */\r
@@ -418,10 +532,11 @@ private:
   EFI_IFR_FORM_SET *mFormSet;\r
 \r
 public:\r
-  CIfrFormSet () : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet),\r
-                   CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header) {\r
+  CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),\r
+                   CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header, Size) {\r
     mFormSet->Help         = EFI_STRING_ID_INVALID;\r
     mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;\r
+    mFormSet->Flags        = 0;\r
     memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));\r
   }\r
 \r
@@ -436,6 +551,17 @@ public:
   VOID SetHelp (IN EFI_STRING_ID Help) {\r
     mFormSet->Help = Help;\r
   }\r
+\r
+  VOID SetClassGuid (IN EFI_GUID *Guid) {\r
+    if (mFormSet->Flags > 0 && ExpendObjBin(sizeof(EFI_GUID))) {\r
+      IncLength (sizeof (EFI_GUID));\r
+    }\r
+    memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));\r
+  }\r
+\r
+  UINT8 GetFlags() {\r
+    return mFormSet->Flags;\r
+  }\r
 };\r
 \r
 class CIfrEnd : public CIfrObj, public CIfrOpHeader {\r
@@ -817,7 +943,7 @@ private:
 public:\r
   CIfrResetButton () : CIfrObj (EFI_IFR_RESET_BUTTON_OP, (CHAR8 **)&mResetButton),\r
                        CIfrOpHeader (EFI_IFR_RESET_BUTTON_OP, &mResetButton->Header), \r
-                                          CIfrStatementHeader (&mResetButton->Question.Header) {\r
+                                          CIfrStatementHeader (&mResetButton->Statement) {\r
     mResetButton->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;\r
   }\r
 \r
@@ -834,7 +960,7 @@ public:
   CIfrCheckBox () : CIfrObj (EFI_IFR_CHECKBOX_OP, (CHAR8 **)&mCheckBox),\r
                      CIfrOpHeader (EFI_IFR_CHECKBOX_OP, &mCheckBox->Header), \r
                      CIfrQuestionHeader (&mCheckBox->Question) {\r
-    mCheckBox->Flags = EFI_IFR_CHECKBOX_DEFAULT;\r
+    mCheckBox->Flags = 0;\r
     gCurrentQuestion = this;\r
   }\r
 \r
@@ -860,6 +986,10 @@ public:
 \r
     return _FLAGS_ZERO (LFlags) ? VFR_RETURN_SUCCESS : VFR_RETURN_FLAGS_UNSUPPORTED;\r
   }\r
+\r
+  UINT8 GetFlags (VOID) {\r
+    return mCheckBox->Flags;\r
+  }\r
 };\r
 \r
 class CIfrAction : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {\r
@@ -929,13 +1059,15 @@ public:
   CIfrNumeric () : CIfrObj (EFI_IFR_NUMERIC_OP, (CHAR8 **)&mNumeric),\r
                    CIfrOpHeader (EFI_IFR_NUMERIC_OP, &mNumeric->Header),\r
                    CIfrQuestionHeader (&mNumeric->Question),\r
-                   CIfrMinMaxStepData (&mNumeric->data) {\r
+                   CIfrMinMaxStepData (&mNumeric->data, TRUE) {\r
     mNumeric->Flags  = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;\r
-    gCurrentQuestion = this;\r
+    gCurrentQuestion   = this;\r
+    gCurrentMinMaxData = this;\r
   }\r
 \r
   ~CIfrNumeric () {\r
-    gCurrentQuestion = NULL;\r
+    gCurrentQuestion   = NULL;\r
+    gCurrentMinMaxData = NULL;\r
   }\r
 \r
   EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {\r
@@ -965,11 +1097,13 @@ public:
                  CIfrQuestionHeader (&mOneOf->Question),\r
                  CIfrMinMaxStepData (&mOneOf->data) {\r
     mOneOf->Flags    = 0;\r
-    gCurrentQuestion = this;\r
+    gCurrentQuestion   = this;\r
+    gCurrentMinMaxData = this;\r
   }\r
 \r
   ~CIfrOneOf () {\r
-    gCurrentQuestion = NULL;\r
+    gCurrentQuestion   = NULL;\r
+    gCurrentMinMaxData = NULL;\r
   }\r
 \r
   EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {\r
@@ -1428,7 +1562,7 @@ public:
     if (QuestionId != EFI_QUESTION_ID_INVALID) {\r
       mEqIdId->QuestionId1 = QuestionId;\r
     } else {\r
-      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo);\r
+      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);\r
     }\r
   }\r
 \r
@@ -1440,7 +1574,7 @@ public:
     if (QuestionId != EFI_QUESTION_ID_INVALID) {\r
       mEqIdId->QuestionId2 = QuestionId;\r
     } else {\r
-      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo);\r
+      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);\r
     }\r
   }\r
 };\r
@@ -1466,7 +1600,7 @@ public:
     if (QuestionId != EFI_QUESTION_ID_INVALID) {\r
       mEqIdVal->QuestionId = QuestionId;\r
     } else {\r
-      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);\r
+      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);\r
     }\r
   }\r
 \r
@@ -1498,7 +1632,7 @@ public:
     if (QuestionId != EFI_QUESTION_ID_INVALID) {\r
       mEqIdVList->QuestionId = QuestionId;\r
     } else {\r
-      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);\r
+      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);\r
     }\r
   }\r
 \r
@@ -1540,7 +1674,7 @@ public:
     if (QuestionId != EFI_QUESTION_ID_INVALID) {\r
       mQuestionRef1->QuestionId = QuestionId;\r
     } else {\r
-      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);\r
+      gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);\r
     }\r
   }\r
 };\r
index 1a31b2e41de6e25c4e6b982348f4ca91777298b2..85060c8e84f1ff8ba9e87208942e1c13230f7f23 100644 (file)
@@ -29,7 +29,7 @@ Abstract:
 #include "stdio.h"\r
 #include "PBlackBox.h"\r
 #include "DLexerBase.h"\r
-#include "VfrLexer.h"    \r
+#include "VfrLexer.h"\r
 #include "AToken.h"\r
 \r
 #define GET_LINENO(Obj)       ((Obj)->getLine())\r
@@ -42,9 +42,9 @@ class CVfrDLGLexer : public VfrLexer
 {\r
 public:\r
   CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};\r
-  INT32 errstd (char *Text) \r
-  { \r
-    printf ("unrecognized input '%s'\n", Text); \r
+  INT32 errstd (char *Text)\r
+  {\r
+    printf ("unrecognized input '%s'\n", Text);\r
   }\r
 };\r
 \r
@@ -70,7 +70,7 @@ VfrParserStart (
 // is not preceeded with a backslash.\r
 //\r
 #lexclass QUOTED_STRING\r
-#token TheString            "~[\"]*\"" << mode (START); >>     \r
+#token TheString            "~[\"]*\"" << mode (START); >>\r
 \r
 //\r
 // Define a lexclass for skipping over C++ style comments\r
@@ -92,7 +92,7 @@ VfrParserStart (
 //\r
 // Skip whitespace\r
 //\r
-#token "[\ \t]"   << skip (); >> \r
+#token "[\ \t]"   << skip (); >>\r
 \r
 //\r
 // Skip over newlines, but count them\r
@@ -128,13 +128,12 @@ VfrParserStart (
 #token Title("title")                           "title"\r
 #token FormId("formid")                         "formid"\r
 #token OneOf("oneof")                           "oneof"\r
-#token EndoneOf("endoneof")                     "endoneof"\r
+#token EndOneOf("endoneof")                     "endoneof"\r
 #token Prompt("prompt")                         "prompt"\r
 #token OrderedList("orderedlist")               "orderedlist"\r
 #token MaxContainers("maxcontainers")           "maxcontainers"\r
 #token EndList("endlist")                       "endlist"\r
 #token EndForm("endform")                       "endform"\r
-#token EndOneOf("endoneof")                     "endoneof"\r
 #token Form("form")                             "form"\r
 #token Subtitle("subtitle")                     "subtitle"\r
 #token Help("help")                             "help"\r
@@ -157,26 +156,27 @@ VfrParserStart (
 #token Inventory("inventory")                   "inventory"\r
 #token NonNvDataMap("_NON_NV_DATA_MAP")         "_NON_NV_DATA_MAP"\r
 #token Struct("struct")                         "struct"\r
+#token Boolean("BOOLEAN")                       "BOOLEAN"
 #token Uint64("UINT64")                         "UINT64"\r
 #token Uint32("UINT32")                         "UINT32"\r
 #token Uint16("UINT16")                         "UINT16"\r
 #token Char16("CHAR16")                         "CHAR16"\r
 #token Uint8("UINT8")                           "UINT8"\r
-#token GUID("guid")                             "guid"\r
+#token Uuid("guid")                             "guid"\r
 #token CheckBox("checkbox")                     "checkbox"\r
 #token EndCheckBox("endcheckbox")               "endcheckbox"\r
 #token Numeric("numeric")                       "numeric"\r
-#token EndNumeric("endnumeric")                 "endnumeric"            \r
-#token Minimum("minimum")                       "minimum"         \r
-#token Maximum("maximum")                       "maximum"         \r
-#token STEP("step")                             "step"      \r
-#token Default("default")                       "default"         \r
-#token Password("password")                     "password"          \r
-#token EndPassword("endpassword")               "endpassword"             \r
+#token EndNumeric("endnumeric")                 "endnumeric"\r
+#token Minimum("minimum")                       "minimum"\r
+#token Maximum("maximum")                       "maximum"\r
+#token STEP("step")                             "step"\r
+#token Default("default")                       "default"\r
+#token Password("password")                     "password"\r
+#token EndPassword("endpassword")               "endpassword"\r
 #token String("string")                         "string"\r
-#token EndString("endstring")                   "endstring"           \r
-#token MinSize("minsize")                       "minsize"         \r
-#token MaxSize("maxsize")                       "maxsize"         \r
+#token EndString("endstring")                   "endstring"\r
+#token MinSize("minsize")                       "minsize"\r
+#token MaxSize("maxsize")                       "maxsize"\r
 #token Encoding("encoding")                     "encoding"\r
 #token SuppressIf("suppressif")                 "suppressif"\r
 #token DisableIf("disableif")                   "disableif"\r
@@ -198,6 +198,7 @@ VfrParserStart (
 #token OptionOnlyFlag("OPTIONS_ONLY")           "OPTIONS_ONLY"\r
 #token Class("class")                           "class"\r
 #token Subclass("subclass")                     "subclass"\r
+#token ClassGuid("classguid")                   "classguid"
 #token TypeDef("typedef")                       "typedef"\r
 #token Restore("restore")                       "restore"\r
 #token Save("save")                             "save"\r
@@ -253,36 +254,71 @@ VfrParserStart (
 //\r
 \r
 vfrProgram > [UINT8 Return] :\r
-  << mParserStatus = 0; >>\r
+  <<
+     mParserStatus = 0;\r
+     mConstantOnlyInExpression = FALSE;
+  >>\r
   (\r
-    (\r
-         "\#pragma" "pack" "\(" A:Number "\)"          << _PCATCH(mCVfrVarDataTypeDB.Pack (_STOU32(A->getText())), A); >>\r
-      vfrDataStructDefinition\r
-         "\#pragma" "pack" "\(" "\)"                   << mCVfrVarDataTypeDB.UnPack (); >>\r
-    )\r
-    |\r
-    (\r
-      vfrDataStructDefinition\r
-    )\r
+      vfrPragmaPackDefinition\r
+    | vfrDataStructDefinition\r
   )*\r
-  vfrFromSetDefinition\r
+  vfrFormSetDefinition\r
   << $Return = mParserStatus; >>\r
   ;\r
 \r
-//*****************************************************************************\r
-//\r
-// the syntax of data struct definition\r
-//\r
+pragmaPackShowDef :\r
+  L:"show"                                          << mCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>
+  ;
+\r
+pragmaPackStackDef :\r
+  <<
+     UINT32 LineNum;
+     UINT8  PackAction;
+     INT8   *Identifier = NULL;
+     UINT32 PackNumber  = DEFAULT_PACK_ALIGN;
+  >>
+  (
+      L1:"push"                                     << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>
+    | L2:"pop"                                      << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>
+  )
+  {
+    "," ID:StringIdentifier                         << Identifier = ID->getText(); >>
+  }
+  {
+    "," N:Number                                    << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>
+  }
+                                                    << mCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >>
+  ;
+\r
+pragmaPackNumber :
+  <<
+     UINT32 LineNum;
+     UINT32 PackNumber = DEFAULT_PACK_ALIGN;
+  >>
+  N:Number                                          << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >>
+                                                    << mCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >>
+  ;
+
+vfrPragmaPackDefinition :
+  "\#pragma" "pack" "\("
+  {
+      pragmaPackShowDef
+    | pragmaPackStackDef
+    | pragmaPackNumber
+  }
+  "\)"
+  ;
+
 vfrDataStructDefinition :\r
   { TypeDef } Struct                                << mCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>\r
-  { NonNVDataMap }\r
+  { NonNvDataMap }\r
   {\r
     N1:StringIdentifier                             << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>\r
   }\r
-  OpenBrace \r
+  OpenBrace\r
     vfrDataStructFields\r
-  CloseBrace \r
-  { \r
+  CloseBrace\r
+  {\r
     N2:StringIdentifier                             << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>\r
   }\r
   ";"                                               << mCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>\r
@@ -290,13 +326,13 @@ vfrDataStructDefinition :
 \r
 vfrDataStructFields :\r
   (\r
-     dataStructField64     | \r
-        dataStructField32     | \r
-        dataStructField16     | \r
-        dataStructField8      | \r
+     dataStructField64     |\r
+        dataStructField32     |\r
+        dataStructField16     |\r
+        dataStructField8      |\r
      dataStructFieldBool   |\r
         dataStructFieldString |\r
-        dataStructFieldDate   | \r
+        dataStructFieldDate   |\r
         dataStructFieldTime   |\r
      dataStructFieldUser\r
   )*\r
@@ -304,8 +340,8 @@ vfrDataStructFields :
 \r
 dataStructField64 :\r
   << UINT32 ArrayNum = 0; >>\r
-  "UINT64" \r
-  N:StringIdentifier \r
+  "UINT64"\r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -314,8 +350,8 @@ dataStructField64 :
 \r
 dataStructField32 :\r
   << UINT32 ArrayNum = 0; >>\r
-  "UINT32" \r
-  N:StringIdentifier \r
+  "UINT32"\r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -325,7 +361,7 @@ dataStructField32 :
 dataStructField16 :\r
   << UINT32 ArrayNum = 0; >>\r
   ("UINT16" | "CHAR16")\r
-  N:StringIdentifier \r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -335,7 +371,7 @@ dataStructField16 :
 dataStructField8 :\r
   << UINT32 ArrayNum = 0; >>\r
   "UINT8"\r
-  N:StringIdentifier \r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -345,7 +381,7 @@ dataStructField8 :
 dataStructFieldBool :\r
   << UINT32 ArrayNum = 0; >>\r
   "BOOLEAN"\r
-  N:StringIdentifier \r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -355,7 +391,7 @@ dataStructFieldBool :
 dataStructFieldString :\r
   << UINT32 ArrayNum = 0; >>\r
   "EFI_STRING_ID"\r
-  N:StringIdentifier \r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -364,8 +400,8 @@ dataStructFieldString :
 \r
 dataStructFieldDate :\r
   << UINT32 ArrayNum = 0; >>\r
-  "EFI_HII_DATE" \r
-  N:StringIdentifier \r
+  "EFI_HII_DATE"\r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -374,8 +410,8 @@ dataStructFieldDate :
 \r
 dataStructFieldTime :\r
   << UINT32 ArrayNum = 0; >>\r
-  "EFI_HII_TIME" \r
-  N:StringIdentifier \r
+  "EFI_HII_TIME"\r
+  N:StringIdentifier\r
   {\r
     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
   }\r
@@ -394,30 +430,89 @@ dataStructFieldUser :
 \r
 //*****************************************************************************\r
 //\r
-// the syntax of from set definition\r
+// the syntax of GUID definition\r
 //\r
-vfrFromSetDefinition :\r
+guidSubDefinition [EFI_GUID &Guid] :\r
+  G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
+                                                    <<\r
+                                                                                                          Guid.Data4[0] = _STOU8(G4->getText());\r
+                                                                                                          Guid.Data4[1] = _STOU8(G5->getText());\r
+                                                                                                          Guid.Data4[2] = _STOU8(G6->getText());\r
+                                                                                                          Guid.Data4[3] = _STOU8(G7->getText());
+                                                                                                          Guid.Data4[4] = _STOU8(G8->getText());
+                                                                                                          Guid.Data4[5] = _STOU8(G9->getText());
+                                                                                                          Guid.Data4[6] = _STOU8(G10->getText());
+                                                                                                          Guid.Data4[7] = _STOU8(G11->getText());
+                                                    >>\r
+  ;\r
+\r
+guidDefinition [EFI_GUID &Guid] :
+  OpenBrace\r
+    G1:Number "," G2:Number "," G3:Number ","\r
+                                                    <<
+                                                       Guid.Data1 = _STOU32 (G1->getText());
+                                                       Guid.Data2 = _STOU16 (G2->getText());
+                                                       Guid.Data3 = _STOU16 (G3->getText());
+                                                    >>
+    (
+        OpenBrace guidSubDefinition[Guid] CloseBrace
+      | guidSubDefinition[Guid]
+    )
+  CloseBrace\r
+  ;
+
+//*****************************************************************************
+//
+// the syntax of form set definition
+//
+vfrFormSetDefinition :
   <<\r
      EFI_GUID    Guid;\r
-     CIfrFormSet FSObj;\r
-     UINT16      C, SC;\r
+     EFI_GUID    DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;\r
+     EFI_GUID    ClassGuids[10];\r
+     UINT8       ClassGuidNum = 0;\r
+     CIfrFormSet *FSObj = NULL;\r
+     UINT16      C, SC;
   >>\r
-  L:FormSet                                         << SET_LINE_INFO (FSObj, L); >>\r
-  GUID "=" \r
-  OpenBrace\r
-    G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number "," \r
-    G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
-  CloseBrace\r
-                                                    << \r
-                                                       _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (), \r
-                                                                       G4->getText (), G5->getText (), G6->getText (), \r
-                                                                       G7->getText (), G8->getText (), G9->getText (), \r
-                                                                       G10->getText (), G11->getText ()); \r
-                                                       FSObj.SetGuid (&Guid);\r
-                                                    >>\r
-  ","\r
-  Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","  << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>\r
-  Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","  << FSObj.SetHelp (_STOSID(S2->getText())); >>\r
+  L:FormSet
+  Uuid "=" guidDefinition[Guid] ","
+  Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
+  Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","
+  {
+    ClassGuid "=" guidDefinition[ClassGuids[ClassGuidNum]]        <<  ++ClassGuidNum; >>
+                  (
+                   "\|" guidDefinition[ClassGuids[ClassGuidNum]]  << ++ClassGuidNum; >>
+                  )*
+                  ","\r
+  }
+                                                    <<
+                                                      switch (ClassGuidNum) {
+                                                      case 0:
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));
+                                                        FSObj->SetClassGuid(&DefaultClassGuid);
+                                                        break;
+                                                      case 1:
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));
+                                                        FSObj->SetClassGuid(&ClassGuids[0]);
+                                                        break;
+                                                      case 2:
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));
+                                                        FSObj->SetClassGuid(&ClassGuids[0]);
+                                                        FSObj->SetClassGuid(&ClassGuids[1]);
+                                                        break;
+                                                      default:
+                                                        FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 2 * sizeof(EFI_GUID));
+                                                        FSObj->SetClassGuid(&ClassGuids[0]);
+                                                        FSObj->SetClassGuid(&ClassGuids[1]);
+                                                        FSObj->SetClassGuid(&ClassGuids[2]);
+                                                        break;
+                                                      }
+
+                                                      SET_LINE_INFO (*FSObj, L);
+                                                      FSObj->SetGuid (&Guid);
+                                                      FSObj->SetFormSetTitle (_STOSID(S1->getText()));\r
+                                                      FSObj->SetHelp (_STOSID(S2->getText()));\r
+                                                    >>
   {\r
     Class "=" classDefinition[C] ","                << {CIfrClass CObj; CObj.SetClass(C);} >>\r
   }\r
@@ -429,7 +524,7 @@ vfrFromSetDefinition :
                                                        //_DeclareDefaultLinearVarStore (GET_LINENO (L));\r
                                                     >>\r
   vfrFormSetList\r
-  E:EndFormSet                                      << CRT_END_OP (E); >>\r
+  E:EndFormSet                                      << CRT_END_OP (E); if (FSObj != NULL) {delete FSObj;}>>\r
   ";"\r
   ;\r
 \r
@@ -441,7 +536,7 @@ vfrFormSetList :
     vfrStatementVarStoreEfi       |\r
     vfrStatementVarStoreNameValue |\r
     vfrStatementDefaultStore      |\r
-    vfrStatementDisableIfFromSet\r
+    vfrStatementDisableIfFormSet\r
   )*\r
   ;\r
 \r
@@ -452,7 +547,7 @@ vfrStatementDefaultStore :
   {\r
     "," Attribute "=" A:Number                      << DefaultId = _STOU16(A->getText()); >>\r
   }\r
-                                                    << \r
+                                                    <<\r
                                                        if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {\r
                                                          CIfrDefaultStore DSObj;\r
                                                          _PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();\r
@@ -468,7 +563,7 @@ vfrStatementDefaultStore :
 \r
 vfrStatementVarStoreLinear :\r
   <<\r
-     EFI_GUID        Guid; \r
+     EFI_GUID        Guid;\r
      CIfrVarStore    VSObj;\r
      INT8            *TypeName;\r
         UINT32          LineNum;\r
@@ -487,31 +582,28 @@ vfrStatementVarStoreLinear :
   )\r
   { Key "=" Number "," }                            // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR\r
   {\r
-    VarId "=" ID:Number ","                         << VarStoreId = _STOU16(ID->getText()); >>\r
+    VarId "=" ID:Number ","                         <<
+                                                       _PCATCH(
+                                                         (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,\r
+                                                         (INTN)TRUE,
+                                                         ID,
+                                                         "varid 0 is not allowed."
+                                                         );
+                                                    >>
   }\r
   Name "=" SN:StringIdentifier ","\r
-  GUID "="\r
-  OpenBrace\r
-    G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number "," \r
-    G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
-  CloseBrace\r
-                                                    << \r
-                                                       _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (), \r
-                                                                       G4->getText (), G5->getText (), G6->getText (), \r
-                                                                       G7->getText (), G8->getText (), G9->getText (), \r
-                                                                       G10->getText (), G11->getText ()); \r
-                                                    >>\r
+  Uuid "=" guidDefinition[Guid]\r
                                                     <<\r
                                                        _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (\r
-                                                                                  SN->getText(), \r
-                                                                                  &Guid, \r
-                                                                                  &mCVfrVarDataTypeDB, \r
+                                                                                  SN->getText(),\r
+                                                                                  &Guid,\r
+                                                                                  &mCVfrVarDataTypeDB,\r
                                                                                   TypeName,\r
                                                                                                                                                                  VarStoreId\r
                                                                                   ), LineNum);\r
                                                     >>\r
-                                                    << \r
-                                                       VSObj.SetGuid (&Guid); \r
+                                                    <<\r
+                                                       VSObj.SetGuid (&Guid);\r
                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
                                                        VSObj.SetVarStoreId (VarStoreId);\r
                                                        _PCATCH(mCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);\r
@@ -534,22 +626,11 @@ vfrStatementVarStoreEfi :
                                                     << VSEObj.SetAttributes (Attr); >>\r
   Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","\r
   VarSize "=" N:Number ","\r
-  GUID "=" \r
-  OpenBrace\r
-    G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number "," \r
-    G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
-  CloseBrace\r
-                                                    << \r
-                                                       _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (), \r
-                                                                       G4->getText (), G5->getText (), G6->getText (), \r
-                                                                       G7->getText (), G8->getText (), G9->getText (), \r
-                                                                       G10->getText (), G11->getText ()); \r
-                                                    >>\r
-                                                    << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>\r
-                                                    << \r
+  Uuid "=" guidDefinition[Guid]                     << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>\r
+                                                    <<\r
                                                        VSEObj.SetGuid (&Guid);\r
                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
-                                                       VSEObj.SetVarStoreId (VarStoreId); \r
+                                                       VSEObj.SetVarStoreId (VarStoreId);\r
                                                     >>\r
   ";"\r
   ;\r
@@ -560,7 +641,7 @@ vfrVarStoreEfiAttr [UINT32 & Attr] :
 \r
 vfrStatementVarStoreNameValue :\r
   <<\r
-     EFI_GUID              Guid; \r
+     EFI_GUID              Guid;\r
      CIfrVarStoreNameValue VSNVObj;\r
      EFI_VARSTORE_ID       VarStoreId;\r
   >>\r
@@ -569,22 +650,11 @@ vfrStatementVarStoreNameValue :
   (\r
     Name "=" "STRING_TOKEN" "\(" N:Number "\)" ","  << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>\r
   )+\r
-  GUID "=" \r
-  OpenBrace\r
-    G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number "," \r
-    G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
-  CloseBrace\r
-                                                    << \r
-                                                       _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (), \r
-                                                                       G4->getText (), G5->getText (), G6->getText (), \r
-                                                                       G7->getText (), G8->getText (), G9->getText (), \r
-                                                                       G10->getText (), G11->getText ()); \r
-                                                    >>\r
-                                                    << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>\r
-                                                    << \r
+  Uuid "=" guidDefinition[Guid]                     << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>\r
+                                                    <<\r
                                                        VSNVObj.SetGuid (&Guid);\r
                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
-                                                       VSNVObj.SetVarStoreId (VarStoreId); \r
+                                                       VSNVObj.SetVarStoreId (VarStoreId);\r
                                                     >>\r
   ";"\r
   ;\r
@@ -597,7 +667,7 @@ classDefinition[UINT16 & Class] :
   << $Class = 0; >>\r
   validClassNames[$Class] ( "\|" validClassNames[$Class] )*\r
   ;\r
-  \r
+\r
 validClassNames[UINT16 & Class] :\r
     ClassNonDevice                                  << $Class |= EFI_NON_DEVICE_CLASS; >>\r
   | ClassDiskDevice                                 << $Class |= EFI_DISK_DEVICE_CLASS; >>\r
@@ -618,10 +688,13 @@ subclassDefinition[UINT16 & SubClass] :
   | N:Number                                        << $SubClass |= _STOU16(N->getText()); >>\r
   ;\r
 \r
-vfrStatementDisableIfFromSet :\r
-  << CIfrDisableIf DIObj; >>\r
+vfrStatementDisableIfFormSet :\r
+  <<
+    CIfrDisableIf DIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   D:DisableIf                                       << DIObj.SetLineNo(D->getLine()); >>\r
-  vfrStatementExpression[0] ";"\r
+  vfrStatementExpression[0, ExpOpCount] ";"         << mConstantOnlyInExpression = FALSE; >>\r
   vfrFormSetList\r
   E:EndIf                                           << CRT_END_OP (E); >>\r
   ";"\r
@@ -638,7 +711,7 @@ vfrStatementHeader[CIfrStatementHeader *SHObj] :
 \r
 vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:\r
   <<\r
-     EFI_VARSTORE_INFO Info; \r
+     EFI_VARSTORE_INFO Info;\r
         EFI_QUESTION_ID   QId       = EFI_QUESTION_ID_INVALID;\r
      INT8              *QName    = NULL;\r
      INT8              *VarIdStr = NULL;\r
@@ -653,10 +726,10 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
   {\r
     QuestionId "=" ID:Number ","                    <<\r
                                                        QId = _STOQID(ID->getText());\r
-                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number"); \r
+                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");\r
                                                     >>\r
   }\r
-                                                    << \r
+                                                    <<\r
                                                        switch (QType) {\r
                                                        case QUESTION_NORMAL:\r
                                                          mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);\r
@@ -692,10 +765,10 @@ vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :
   {\r
     QuestionId "=" ID:Number ","                    <<\r
                                                        QId = _STOQID(ID->getText());\r
-                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID"); \r
+                                                       _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");\r
                                                     >>\r
   }\r
-                                                    << \r
+                                                    <<\r
                                                        mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);\r
                                                        $QHObj->SetQuestionId (QId);\r
                                                     >>\r
@@ -718,13 +791,14 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
      INT8                  *VarStr      = NULL;\r
      INT8                  *SName       = NULL;\r
      INT8                  *TName       = NULL;\r
+     EFI_IFR_TYPE_VALUE    Dummy        = {0};
   >>\r
   (\r
     SN1:StringIdentifier                            << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>\r
     OpenBracket I1:Number CloseBracket              << Idx = _STOU32(I1->getText()); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>\r
                                                     <<\r
                                                        _PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN1);\r
-                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1); \r
+                                                       _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);\r
                                                                                                           _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);\r
                                                                                                        >>\r
   )\r
@@ -739,7 +813,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
                                                                                                                 _STRCAT(&VarStr, TName);\r
                                                                                                           }\r
                                                     >>\r
-  \r
+\r
     (\r
       "."                                           <<\r
                                                        _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);\r
@@ -750,7 +824,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
         OpenBracket I2:Number CloseBracket          << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>\r
                                                     << _STRCAT(&VarStr, "["); _STRCAT(&VarStr, I2->getText()); _STRCAT(&VarStr, "]"); >>\r
       }\r
-    )*                                              << \r
+    )*                                              <<\r
                                                        switch (VarStoreType) {\r
                                                        case EFI_VFR_VARSTORE_EFI:\r
                                                          _PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);\r
@@ -758,6 +832,19 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
                                                        case EFI_VFR_VARSTORE_BUFFER:\r
                                                          _PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine());\r
                                                          //_PCATCH(mCVfrDataStorage.BufferVarStoreRequestElementAdd (SName, Info), SN2);\r
+                                                         _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (
+                                                                    SName,
+                                                                    NULL),
+                                                                 SN2->getLine());
+                                                         _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write (
+                                                                    'a',
+                                                                    SName,
+                                                                    NULL,
+                                                                    $Info.mVarType,
+                                                                    $Info.mInfo.mVarOffset,
+                                                                    $Info.mVarTotalSize,
+                                                                    Dummy),
+                                                                 SN2->getLine());
                                                          break;\r
                                                        case EFI_VFR_VARSTORE_NAME:\r
                                                        default: break;\r
@@ -775,7 +862,11 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U
     SN1:StringIdentifier                            << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>\r
     OpenBracket I1:Number CloseBracket              << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>\r
                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
-  )\r
+  )                                                 <<\r
+                                                       if (mConstantOnlyInExpression) {
+                                                         _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
+                                                       }
+                                                    >>
   |\r
   (\r
     SN2:StringIdentifier                            << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>\r
@@ -787,11 +878,15 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U
       }\r
     )*\r
                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
-  )\r
+  )                                                 <<\r
+                                                       if (mConstantOnlyInExpression) {
+                                                         _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
+                                                       }
+                                                    >>
   ;\r
 \r
 vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :\r
-    N1:Number                                       << \r
+    N1:Number                                       <<\r
                                                        switch ($Type) {\r
                                                        case EFI_IFR_TYPE_NUM_SIZE_8 :\r
                                                                                                             $Value.u8     = _STOU8(N1->getText());\r
@@ -815,7 +910,7 @@ vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
                                                                                                           case EFI_IFR_TYPE_DATE :\r
                                                                                                           default :\r
                                                                                                                 break;\r
-                                                                                                          } \r
+                                                                                                          }\r
                                                     >>\r
   | B1:True                                         << $Value.b      = TRUE; >>\r
   | B2:False                                        << $Value.b      = FALSE; >>\r
@@ -845,7 +940,7 @@ vfrFormDefinition :
     vfrStatementQuestions                    |\r
     vfrStatementConditional                  |\r
     vfrStatementLabel                        |\r
-    vfrStatementBanner                       \r
+    vfrStatementBanner\r
     // Just for framework vfr compatibility\r
     //vfrStatementInvalid\r
   )*\r
@@ -853,14 +948,17 @@ vfrFormDefinition :
   ";"\r
   ;\r
 \r
-vfrStatementRules : \r
-  << CIfrRule RObj; >>\r
+vfrStatementRules :\r
+  << 
+    CIfrRule RObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   R:Rule                                            << RObj.SetLineNo(R->getLine()); >>\r
   S1:StringIdentifier ","                           <<\r
                                                        mCVfrRulesDB.RegisterRule (S1->getText());\r
-                                                       RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText())); \r
+                                                       RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));\r
                                                     >>\r
-  vfrStatementExpression[0]\r
+  vfrStatementExpression[0, ExpOpCount]\r
   E:EndRule                                         << CRT_END_OP (E); >>\r
   ";"\r
   ;\r
@@ -868,7 +966,7 @@ vfrStatementRules :
 vfrStatementDefault :\r
   <<\r
      BOOLEAN               IsExp         = FALSE;\r
-     EFI_IFR_TYPE_VALUE    Val\r
+     EFI_IFR_TYPE_VALUE    Val = {0};\r
      CIfrDefault           DObj;\r
      EFI_DEFAULT_ID        DefaultId     = EFI_HII_DEFAULT_CLASS_STANDARD;\r
      INT8                  *VarStoreName = NULL;\r
@@ -877,30 +975,40 @@ vfrStatementDefault :
   D:Default                                         << DObj.SetLineNo(D->getLine()); >>\r
   (\r
     (\r
-        vfrStatementValue ","                       << IsExp = TRUE; DObj.SetScope (1); >>\r
-      | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","  \r
-                                                    << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >>\r
+        vfrStatementValue ","                       << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>\r
+      | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","  << \r
+                                                        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()); \r
+                                                        DObj.SetValue(Val);
+                                                    >>
     )\r
     {\r
       DefaultStore "=" SN:StringIdentifier ","      << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>\r
     }\r
-                                                    << \r
-                                                                                                          _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());\r
-                                                                                                          _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());\r
-                                                                                                          if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) { \r
-                                                                                                            _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
-                                                                                                                                                    DefaultId, \r
-                                                                                                                                                                        _GET_CURRQEST_VARTINFO(), \r
-                                                                                                                                                                        VarStoreName, \r
-                                                                                                                                                                        _GET_CURRQEST_DATATYPE (), \r
-                                                                                                                                                                        Val), D->getLine()); \r
-                                                                                                          }\r
-                                                                                                       >>\r
+                                                    <<\r
+                                                       _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());\r
+                                                       _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());\r
+                                                       if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {\r
+                                                         _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
+                                                                   DefaultId,\r
+                                                                   _GET_CURRQEST_VARTINFO(),\r
+                                                                   VarStoreName,\r
+                                                                   _GET_CURRQEST_DATATYPE (),\r
+                                                                   Val),
+                                                                   D->getLine()\r
+                                                                   );
+                                                       }\r
+                                                    >>\r
   )\r
   ;\r
 \r
 vfrStatementStat :\r
-  vfrStatementSubTitle        | \r
+  vfrStatementSubTitle        |\r
   vfrStatementStaticText      |\r
   vfrStatementCrossReference\r
   ;\r
@@ -932,14 +1040,18 @@ vfrStatementInvalid :
   ;\r
 \r
 flagsField :\r
-  Number | InteractiveFlag | ManufacturingFlag | DefaultFlag | \r
+  Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |\r
   NVAccessFlag | ResetRequiredFlag | LateCheckFlag\r
   ;\r
 \r
 vfrStatementValue :\r
-  << CIfrValue VObj; >>\r
+  << 
+    CIfrValue VObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   V:Value                                              << VObj.SetLineNo(V->getLine()); >>\r
-  "=" vfrStatementExpression[0]\r
+  "=" vfrStatementExpression[0, ExpOpCount]\r
+                                                       << { CIfrEnd EndObj; EndObj.SetLineNo(0); } >>
   ;\r
 \r
 vfrStatementSubTitle :\r
@@ -965,7 +1077,7 @@ subtitleFlagsField [UINT8 & Flags] :
   ;\r
 \r
 vfrStatementStaticText :\r
-  << \r
+  <<\r
      UINT8           Flags   = 0;\r
      EFI_QUESTION_ID QId     = EFI_QUESTION_ID_INVALID;\r
      EFI_STRING_ID   TxtTwo  = EFI_STRING_ID_INVALID;\r
@@ -983,6 +1095,7 @@ vfrStatementStaticText :
                                                        <<\r
                                                           if (Flags & EFI_IFR_FLAG_CALLBACK) {\r
                                                             CIfrAction AObj;\r
+                                                            AObj.SetLineNo (T->getLine());
                                                             mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);\r
                                                             AObj.SetQuestionId (QId);\r
                                                             AObj.SetPrompt (_STOSID(S2->getText()));\r
@@ -1013,7 +1126,7 @@ vfrStatementCrossReference :
   ;\r
 \r
 vfrStatementGoto :\r
-  << \r
+  <<\r
      UINT8               RefType = 1;\r
      EFI_STRING_ID       DevPath;\r
      EFI_GUID            FSId;\r
@@ -1030,39 +1143,23 @@ vfrStatementGoto :
   (\r
     (\r
       DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","\r
-      FormSetGuid "=" \r
-        OpenBrace\r
-          G11:Number "," G12:Number "," G13:Number "," G14:Number "," G15:Number "," G16:Number "," \r
-          G17:Number "," G18:Number "," G19:Number "," G110:Number "," G111:Number\r
-        CloseBrace ","\r
+      FormSetGuid "=" guidDefinition[FSId] ","\r
       FormId "=" F1:Number ","\r
       Question "=" QN1:Number ","\r
-                                                       << \r
+                                                       <<\r
                                                           RefType = 4;\r
-                                                          _CRGUID (&FSId, G11->getText (), G12->getText (), G13->getText (), \r
-                                                                          G14->getText (), G15->getText (), G16->getText (), \r
-                                                                          G17->getText (), G18->getText (), G19->getText (), \r
-                                                                          G110->getText (), G111->getText ()); \r
-                                                          DevPath = _STOSID(P->getText()); \r
+                                                          DevPath = _STOSID(P->getText());\r
                                                           FId = _STOFID(F1->getText());\r
                                                           QId = _STOQID(QN1->getText());\r
                                                        >>\r
     )\r
     |\r
     (\r
-      FormSetGuid "="\r
-        OpenBrace\r
-          G21:Number "," G22:Number "," G23:Number "," G24:Number "," G25:Number "," G26:Number "," \r
-          G27:Number "," G28:Number "," G29:Number "," G210:Number "," G211:Number\r
-        CloseBrace ","\r
+      FormSetGuid "=" guidDefinition[FSId] ","\r
       FormId "=" F2:Number ","\r
       Question "=" QN2:Number ","\r
                                                        <<\r
                                                           RefType = 3;\r
-                                                          _CRGUID (&FSId, G21->getText (), G22->getText (), G23->getText (), \r
-                                                                          G24->getText (), G25->getText (), G26->getText (), \r
-                                                                          G27->getText (), G28->getText (), G29->getText (), \r
-                                                                          G210->getText (), G211->getText ()); \r
                                                           FId = _STOFID(F2->getText());\r
                                                           QId = _STOQID(QN2->getText());\r
                                                        >>\r
@@ -1070,7 +1167,7 @@ vfrStatementGoto :
     |\r
     (\r
       FormId "=" F3:Number ","                         << RefType = 2; FId = _STOFID(F3->getText()); >>\r
-      Question "=" \r
+      Question "="\r
       (\r
           QN3:StringIdentifier ","                     << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>\r
         | QN4:Number ","                               << QId = _STOQID(QN4->getText()); >>\r
@@ -1078,7 +1175,7 @@ vfrStatementGoto :
     )\r
     |\r
     (\r
-      F4:Number ","                                    << \r
+      F4:Number ","                                    <<\r
                                                           RefType = 1;\r
                                                           FId = _STOFID(F4->getText());\r
                                                        >>\r
@@ -1088,31 +1185,31 @@ vfrStatementGoto :
                                                           switch (RefType) {\r
                                                           case 4:\r
                                                             {\r
-                                                              R4Obj = new CIfrRef4; \r
-                                                              QHObj = R4Obj; \r
-                                                              R4Obj->SetLineNo(G->getLine()); \r
-                                                              R4Obj->SetDevicePath (DevPath); \r
-                                                              R4Obj->SetFormSetId (FSId); \r
-                                                              R4Obj->SetFormId (FId); \r
-                                                              R4Obj->SetQuestionId (QId); \r
+                                                              R4Obj = new CIfrRef4;\r
+                                                              QHObj = R4Obj;\r
+                                                              R4Obj->SetLineNo(G->getLine());\r
+                                                              R4Obj->SetDevicePath (DevPath);\r
+                                                              R4Obj->SetFormSetId (FSId);\r
+                                                              R4Obj->SetFormId (FId);\r
+                                                              R4Obj->SetQuestionId (QId);\r
                                                               break;\r
                                                             }\r
                                                           case 3:\r
                                                             {\r
-                                                              R3Obj = new CIfrRef3; \r
-                                                              QHObj = R3Obj; \r
-                                                              R3Obj->SetLineNo(G->getLine()); \r
-                                                              R3Obj->SetFormSetId (FSId); \r
-                                                              R3Obj->SetFormId (FId); \r
-                                                              R3Obj->SetQuestionId (QId); \r
+                                                              R3Obj = new CIfrRef3;\r
+                                                              QHObj = R3Obj;\r
+                                                              R3Obj->SetLineNo(G->getLine());\r
+                                                              R3Obj->SetFormSetId (FSId);\r
+                                                              R3Obj->SetFormId (FId);\r
+                                                              R3Obj->SetQuestionId (QId);\r
                                                               break;\r
                                                             }\r
                                                           case 2:\r
                                                             {\r
-                                                              R2Obj = new CIfrRef2; \r
-                                                              QHObj = R2Obj; \r
-                                                              R2Obj->SetLineNo(G->getLine()); \r
-                                                              R2Obj->SetFormId (FId); \r
+                                                              R2Obj = new CIfrRef2;\r
+                                                              QHObj = R2Obj;\r
+                                                              R2Obj->SetLineNo(G->getLine());\r
+                                                              R2Obj->SetFormId (FId);\r
                                                               _PCATCH(R2Obj->SetQuestionId (QId), QN3);\r
                                                               break;\r
                                                             }\r
@@ -1155,12 +1252,12 @@ getStringId :
 \r
 vfrStatementResetButton :\r
   <<\r
-     CIfrResetButton RBObj; \r
+     CIfrResetButton RBObj;\r
      UINT16          DefaultId;\r
   >>\r
   L:ResetButton                                        << RBObj.SetLineNo(L->getLine()); >>\r
-  DefaultStore \r
-  "=" N:StringIdentifier ","                           << \r
+  DefaultStore\r
+  "=" N:StringIdentifier ","                           <<\r
                                                           _PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());\r
                                                           RBObj.SetDefaultId (DefaultId);\r
                                                        >>\r
@@ -1184,23 +1281,59 @@ vfrStatementBooleanType :
 //     prompt      = STRING_TOKEN(STR_CHECK_BOX_PROMPT),\r
 //     help        = STRING_TOKEN(STR_CHECK_BOX_HELP),\r
 //     flags       = CHECKBOX_DEFAULT | CALLBACK,\r
-//     default value = TRUE, defaultstore = MyDefaultStore, \r
+//     default value = TRUE, defaultstore = MyDefaultStore,\r
 //   endcheckbox;\r
 //\r
 vfrStatementCheckBox :\r
   <<\r
-     CIfrCheckBox CBObj;\r
+     CIfrCheckBox       CBObj;\r
+     EFI_IFR_TYPE_VALUE Val = {0};
+     INT8               *VarStoreName = NULL;
   >>\r
   L:CheckBox                                           << CBObj.SetLineNo(L->getLine()); >>\r
   vfrQuestionHeader[CBObj] ","\r
-  { F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] "," }\r
+  {
+    F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","\r
+                                                       <<
+                                                          _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");
+                                                          Val.b = TRUE;
+                                                          if (CBObj.GetFlags () & 0x01) {
+                                                            _PCATCH(
+                                                              mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+                                                                                  EFI_HII_DEFAULT_CLASS_STANDARD,
+                                                                                  _GET_CURRQEST_VARTINFO(),
+                                                                                  VarStoreName,
+                                                                                  _GET_CURRQEST_DATATYPE (),
+                                                                                  Val
+                                                                                  ),
+                                                              VFR_RETURN_SUCCESS,
+                                                              L,
+                                                              "No standard default storage found"
+                                                              );
+                                                          }
+                                                          if (CBObj.GetFlags () & 0x02) {
+                                                            _PCATCH(
+                                                              mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+                                                                                  EFI_HII_DEFAULT_CLASS_MANUFACTURING,
+                                                                                  _GET_CURRQEST_VARTINFO(),
+                                                                                  VarStoreName,
+                                                                                  _GET_CURRQEST_DATATYPE (),
+                                                                                  Val
+                                                                                  ),
+                                                              VFR_RETURN_SUCCESS,
+                                                              L,
+                                                              "No manufacturing default storage found"
+                                                              );
+                                                                                                                 }
+                                                                                                          >>
+  }
   {\r
     Key "=" KN:Number  ","                             << AssignQuestionKey (CBObj, KN); >>\r
   }\r
   vfrStatementQuestionOptionList\r
   E:EndCheckBox                                        << CRT_END_OP (E); >>\r
   ";"\r
-  ; \r
+  ;\r
 \r
 vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :\r
   <<\r
@@ -1256,7 +1389,7 @@ vfrStatementDate :
      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
      INT8               *VarIdStr[3] = {NULL, };\r
      CIfrDate           DObj;\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = {0};\r
   >>\r
   L:Date                                               << DObj.SetLineNo(L->getLine()); >>\r
   (\r
@@ -1285,14 +1418,14 @@ vfrStatementDate :
       Help   "=" "STRING_TOKEN" "\(" DH:Number "\)" ","\r
       minMaxDateStepDefault[Val.date, 2]\r
                                                        <<\r
-                                                          mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId); \r
+                                                          mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
                                                           DObj.SetQuestionId (QId);\r
                                                           DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);\r
                                                                                                                  DObj.SetPrompt (_STOSID(YP->getText()));\r
                                                                                                                  DObj.SetHelp (_STOSID(YH->getText()));\r
                                                                                                                  if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
                                                        >>\r
-                                                          << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val);} >>\r
+                                                          << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DObj.SetLineNo (D1Y->getLine());} >>\r
       ( vfrStatementInconsistentIf )*\r
     )\r
   )\r
@@ -1307,10 +1440,10 @@ minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :
   {\r
     "default" "=" N:Number ","                         <<\r
                                                           switch (KeyValue) {\r
-                                                          case 0: D.Year  = _STOU16(N->getText()); break; \r
-                                                          case 1: D.Month = _STOU8(N->getText()); break; \r
+                                                          case 0: D.Year  = _STOU16(N->getText()); break;\r
+                                                          case 1: D.Month = _STOU8(N->getText()); break;\r
                                                           case 2: D.Day   = _STOU8(N->getText()); break;\r
-                                                                                                                 } \r
+                                                                                                                 }\r
                                                        >>\r
   }\r
   ;\r
@@ -1400,18 +1533,38 @@ vfrStatementNumeric :
 \r
 vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :\r
   <<\r
-     UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
+     UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;\r
      UINT8 HFlags = 0;\r
+     EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
   >>\r
   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
-                                                       << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >>\r
+                                                       <<
+                                                          //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);\r
+                                                       >>
   ;\r
 \r
 numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
-  | "DISPLAY_INT_DEC"                                  << $LFlags |= 0x00; >>\r
-  | "DISPLAY_UINT_DEC"                                 << $LFlags |= 0x10; >>\r
-  | "DISPLAY_UINT_HEX"                                 << $LFlags |= 0x20; >>\r
+  | "NUMERIC_SIZE_1"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; >>\r
+  | "NUMERIC_SIZE_2"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; >>\r
+  | "NUMERIC_SIZE_4"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; >>\r
+  | "NUMERIC_SIZE_8"                                   << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; >>
+  | "DISPLAY_INT_DEC"                                  << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; >>
+  | "DISPLAY_UINT_DEC"                                 << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; >>
+  | "DISPLAY_UINT_HEX"                                 << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; >>
   | questionheaderFlagsField[HFlags]\r
   ;\r
 \r
@@ -1420,9 +1573,9 @@ vfrStatementOneOf :
      CIfrOneOf OObj;\r
   >>\r
   L:OneOf                                              << OObj.SetLineNo(L->getLine()); >>\r
-  vfrQuestionHeader[OObj] ","\r
+  vfrQuestionHeader[OObj] ","                          << _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>\r
   { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }\r
-  { \r
+  {\r
     vfrSetMinMaxStep[OObj]\r
   }\r
   vfrStatementQuestionOptionList\r
@@ -1432,11 +1585,27 @@ vfrStatementOneOf :
 \r
 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :\r
   <<\r
-     UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
+     UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;\r
      UINT8 HFlags = 0;\r
+     EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
   >>\r
   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
-                                                       << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >>\r
+                                                       <<
+                                                          //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);\r
+                                                       >>
   ;\r
 \r
 vfrStatementStringType :\r
@@ -1449,7 +1618,7 @@ vfrStatementString :
      CIfrString SObj;\r
   >>\r
   L:String                                             << SObj.SetLineNo(L->getLine()); >>\r
-  vfrQuestionHeader[SObj] ","                          << _PCATCH(SObj.SetFlags (SObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>\r
+  vfrQuestionHeader[SObj] ","\r
   { F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }\r
   {\r
     Key "=" KN:Number ","                              << AssignQuestionKey (SObj, KN); >>\r
@@ -1478,7 +1647,7 @@ stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
 \r
 vfrStatementPassword :\r
   <<\r
-     CIfrPassword PObj; \r
+     CIfrPassword PObj;\r
   >>\r
   L:Password                                           << PObj.SetLineNo(L->getLine()); >>\r
   vfrQuestionHeader[PObj] ","\r
@@ -1507,12 +1676,12 @@ passwordFlagsField [UINT8 & HFlags] :
 \r
 vfrStatementOrderedList :\r
   <<\r
-     CIfrOrderedList OLObj; \r
+     CIfrOrderedList OLObj;\r
   >>\r
   L:OrderedList                                        << OLObj.SetLineNo(L->getLine()); >>\r
   vfrQuestionHeader[OLObj] ","\r
-                                                       << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>\r
-  { \r
+                                                       << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_ARRAY_SIZE()); >>\r
+  {\r
     MaxContainers "=" M:Number ","                     << OLObj.SetMaxContainers (_STOU8(M->getText())); >>\r
   }\r
   { F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }\r
@@ -1542,14 +1711,14 @@ vfrStatementTime :
      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
      INT8               *VarIdStr[3] = {NULL, };\r
      CIfrTime           TObj;\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = {0};\r
   >>\r
   L:Time                                               << TObj.SetLineNo(L->getLine()); >>\r
   (\r
     (\r
       vfrQuestionHeader[TObj, QUESTION_TIME] ","\r
          { F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }\r
-      vfrStatementDefault\r
+      vfrStatementQuestionOptionList\r
     )\r
     |\r
     (\r
@@ -1571,14 +1740,14 @@ vfrStatementTime :
       Help   "=" "STRING_TOKEN" "\(" SH:Number "\)" ","\r
       minMaxTimeStepDefault[Val.time, 2]\r
                                                        <<\r
-                                                          mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId); \r
+                                                          mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
                                                           TObj.SetQuestionId (QId);\r
                                                           TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);\r
                                                                                                                  TObj.SetPrompt (_STOSID(HP->getText()));\r
                                                                                                                  TObj.SetHelp (_STOSID(HH->getText()));\r
                                                                                                                  if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
                                                        >>\r
-                                                       << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val);} >>\r
+                                                       << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DObj.SetLineNo (T1H->getLine());} >>\r
     )\r
   )\r
   E:EndTime                                            << CRT_END_OP (E); >>\r
@@ -1592,10 +1761,10 @@ minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :
   {\r
     "default" "=" N:Number ","                         <<\r
                                                           switch (KeyValue) {\r
-                                                          case 0: T.Hour   = _STOU8(N->getText()); break; \r
-                                                          case 1: T.Minute = _STOU8(N->getText()); break; \r
+                                                          case 0: T.Hour   = _STOU8(N->getText()); break;\r
+                                                          case 1: T.Minute = _STOU8(N->getText()); break;\r
                                                           case 2: T.Second = _STOU8(N->getText()); break;\r
-                                                                                                                 } \r
+                                                                                                                 }\r
                                                        >>\r
   }\r
   ;\r
@@ -1622,7 +1791,7 @@ vfrStatementQuestionTag :
   vfrStatementNoSubmitIf        |\r
   vfrStatementDisableIfQuest    |\r
   vfrStatementRefresh           |\r
-  vfrStatementVarstoreDevice \r
+  vfrStatementVarstoreDevice\r
   ;\r
 \r
 vfrStatementQuestionTagList :\r
@@ -1639,7 +1808,7 @@ vfrStatementQuestionOptionTag :
 vfrStatementQuestionOptionList :\r
   (\r
     vfrStatementQuestionTag     |\r
-    vfrStatementQuestionOptionTag \r
+    vfrStatementQuestionOptionTag\r
   )*\r
   ;\r
 \r
@@ -1648,34 +1817,43 @@ vfrStatementStatList :
   vfrStatementQuestions                   |\r
   vfrStatementConditional                 |\r
   // Just for framework vfr compatibility\r
-  vfrStatementLabel                       \r
+  vfrStatementLabel\r
   //vfrStatementInvalid\r
   ;\r
 \r
 vfrStatementDisableIfStat :\r
-  << CIfrDisableIf DIObj; >>\r
+  <<
+    CIfrDisableIf DIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:DisableIf                                          << DIObj.SetLineNo(L->getLine()); >>\r
-  vfrStatementExpression[0] ";"\r
+  vfrStatementExpression[0, ExpOpCount] ";"            << mConstantOnlyInExpression = FALSE; >>\r
   ( vfrStatementStatList )*\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ";"\r
   ;\r
 \r
 vfrStatementSuppressIfStat :\r
-  << CIfrSuppressIf SIObj; >>\r
+  <<
+    CIfrSuppressIf SIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0] ";"\r
+  vfrStatementExpression[0, ExpOpCount] ";"\r
   ( vfrStatementStatList )*\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ";"\r
   ;\r
 \r
 vfrStatementGrayOutIfStat :\r
-  << CIfrGrayOutIf GOIObj; >>\r
+  <<
+    CIfrGrayOutIf GOIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0]\r
+  vfrStatementExpression[0, ExpOpCount]\r
   ";"\r
   ( vfrStatementStatList )*\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
@@ -1712,27 +1890,36 @@ vfrStatementLocked :
   ;\r
 \r
 vfrStatementInconsistentIf :\r
-  << CIfrInconsistentIf IIObj; >>\r
+  <<
+    CIfrInconsistentIf IIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:InconsistentIf                                     << IIObj.SetLineNo(L->getLine()); >>\r
   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << IIObj.SetError (_STOSID(S->getText())); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0]\r
+  vfrStatementExpression[0, ExpOpCount]\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ;\r
 \r
 vfrStatementNoSubmitIf :\r
-  << CIfrNoSubmitIf NSIObj; >>\r
+  <<
+    CIfrNoSubmitIf NSIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:NoSubmitIf                                         << NSIObj.SetLineNo(L->getLine()); >>\r
   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << NSIObj.SetError (_STOSID(S->getText())); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0]\r
+  vfrStatementExpression[0, ExpOpCount]\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ;\r
 \r
 vfrStatementDisableIfQuest :\r
-  << CIfrDisableIf DIObj; >>\r
+  <<
+    CIfrDisableIf DIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:DisableIf                                          << DIObj.SetLineNo(L->getLine()); >>\r
-  vfrStatementExpression[0] ";"\r
+  vfrStatementExpression[0, ExpOpCount] ";"            << mConstantOnlyInExpression = FALSE; >>\r
   vfrStatementQuestionOptionList\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ;\r
@@ -1750,10 +1937,13 @@ vfrStatementVarstoreDevice :
   ;\r
 \r
 vfrStatementSuppressIfQuest :\r
-  << CIfrSuppressIf SIObj; >>\r
+  <<
+    CIfrSuppressIf SIObj;\r
+    UINT32 ExpOpCount = 0;
+  >>
   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0] ";"\r
+  vfrStatementExpression[0, ExpOpCount] ";"\r
   vfrStatementQuestionOptionList\r
   E:EndIf                                              << CRT_END_OP (E); >>\r
   ;\r
@@ -1764,28 +1954,51 @@ vfrStatementOptions :
 \r
 vfrStatementOneOfOption :\r
   <<\r
-     EFI_IFR_TYPE_VALUE Val;\r
+     EFI_IFR_TYPE_VALUE Val = {0};\r
      CIfrOneOfOption    OOOObj;\r
      INT8               *VarStoreName = NULL;\r
-     \r
+\r
   >>\r
   L:Option                                             << OOOObj.SetLineNo(L->getLine()); >>\r
   Text  "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << OOOObj.SetOption (_STOSID(S->getText())); >>\r
-  Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","    << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >>\r
+  Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","    \r
+                                                       << 
+                                                          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()]\r
                                                        <<\r
                                                           if (OOOObj.GetFlags () & 0x10) {\r
                                                             _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());\r
                                                             _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
-                                                                                                                                                   EFI_HII_DEFAULT_CLASS_STANDARD, \r
-                                                                                                                                                                       _GET_CURRQEST_VARTINFO(), \r
-                                                                                                                                                                       VarStoreName, \r
-                                                                                                                                                                   _GET_CURRQEST_DATATYPE (), \r
+                                                                                                                                                   EFI_HII_DEFAULT_CLASS_STANDARD,\r
+                                                                                                                                                                       _GET_CURRQEST_VARTINFO(),\r
+                                                                                                                                                                       VarStoreName,\r
+                                                                                                                                                                   _GET_CURRQEST_DATATYPE (),\r
                                                                                                                                                                        Val\r
                                                                                                                                                                        ), L->getLine());\r
                                                           }\r
                                                        >>\r
-  { "," Key "=" Number }                               // no use in UEFI2.1 VFR\r
   (\r
     "," vfrImageTag                                    << OOOObj.SetScope (1); CIfrEnd EOOOObj; >>\r
   )*\r
@@ -1794,7 +2007,7 @@ vfrStatementOneOfOption :
 \r
 vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :\r
   <<\r
-     UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
+     UINT8 LFlags = 0;\r
      UINT8 HFlags = 0;\r
   >>\r
   oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*\r
@@ -1814,27 +2027,6 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
   | DefaultFlag                                        << $LFlags |= 0x10; >>\r
   ;\r
 \r
-//vfrStatementGuid :\r
-//  <<\r
-//     EFI_GUID Guid; \r
-//     CIfrGuid GObj;\r
-//  >>\r
-//  GuidAction\r
-//  GUID "=" \r
-//  OpenBrace\r
-//    G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number "," \r
-//    G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
-//  CloseBrace\r
-//                                                       << \r
-//                                                          _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (), \r
-//                                                                          G4->getText (), G5->getText (), G6->getText (), \r
-//                                                                          G7->getText (), G8->getText (), G9->getText (), \r
-//                                                                          G10->getText (), G11->getText ()); \r
-//                                                       >>\r
-//                                                       << GObj.SetGuid (&Guid); >>\r
-//  ";"\r
-//  ;\r
-\r
 vfrStatementLabel :\r
   << CIfrLabel LObj; >>\r
   L:Label                                              << LObj.SetLineNo(L->getLine()); >>\r
@@ -1847,9 +2039,9 @@ vfrStatementBanner :
   B:Banner { "," }                                     << BObj.SetLineNo(B->getLine()); >>\r
   Title "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << BObj.SetTitle (_STOSID(S->getText())); >>\r
   (\r
-    ( \r
+    (\r
       Line L:Number ","                                << BObj.SetLine (_STOU16(L->getText())); >>\r
-      Align \r
+      Align\r
       (\r
           Left                                         << BObj.SetAlign (0); >>\r
         | Center                                       << BObj.SetAlign (1); >>\r
@@ -1867,17 +2059,18 @@ vfrStatementBanner :
 //\r
 // keep some syntax for compatibility but not generate any IFR object\r
 //\r
-vfrStatementInvalidHidden : \r
+vfrStatementInvalidHidden :\r
   Hidden\r
   Value "=" Number ","\r
   Key "=" Number ";"\r
   ;\r
 \r
 vfrStatementInvalidInconsistentIf :\r
+  << UINT32 ExpOpCount = 0; >>
   InconsistentIf\r
   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","\r
   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
-  vfrStatementExpression[0]\r
+  vfrStatementExpression[0, ExpOpCount]\r
   EndIf\r
   ";"\r
   ;\r
@@ -1889,15 +2082,15 @@ vfrStatementInvalidInventory :
   {\r
     Text  "=" "STRING_TOKEN" "\(" Number "\)"\r
   }\r
-  ";" \r
+  ";"\r
   ;\r
 \r
-vfrStatementInvalidSaveRestoreDefaults : \r
+vfrStatementInvalidSaveRestoreDefaults :\r
   (Save | Restore)\r
   Defaults ","\r
   FormId "=" Number  ","\r
   Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","\r
-  Help   "=" "STRING_TOKEN" "\(" Number "\)" \r
+  Help   "=" "STRING_TOKEN" "\(" Number "\)"\r
   { "," FLAGS "=" flagsField ( "\|" flagsField )* }\r
   { "," Key   "=" Number }\r
   ";"\r
@@ -1939,13 +2132,13 @@ vfrStatementInvalidSaveRestoreDefaults :
 #token QuestionRefVal("questionrefval")         "questionrefval"\r
 #token StringRefVal("stringrefval")             "stringrefval"\r
 \r
-vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :\r
+vfrStatementExpression [UINT32 RootLevel, UINT32 & ExpOpCount] :\r
                                                                                                           << if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>\r
   andTerm[$RootLevel, $ExpOpCount]\r
   (\r
     L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
   )*\r
-                                                       << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; } >>\r
+                                                       << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; EObj.SetLineNo (0);} >>\r
   ;\r
 \r
 andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -1956,7 +2149,7 @@ andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   ;\r
 \r
 bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
-  bitwiseandTerm[$RootLevel, $ExpOpCount]          \r
+  bitwiseandTerm[$RootLevel, $ExpOpCount]\r
   (\r
     L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount]      << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>\r
   )*\r
@@ -2004,7 +2197,7 @@ compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
   ;\r
 \r
 shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
-  addMinusTerm[$RootLevel, $ExpOpCount]           \r
+  addMinusTerm[$RootLevel, $ExpOpCount]\r
   (\r
     (\r
       L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount]    << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>\r
@@ -2030,20 +2223,42 @@ addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
   ;\r
 \r
 multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
-  atomTerm[$RootLevel, $ExpOpCount]\r
-  ( \r
+  castTerm[$RootLevel, $ExpOpCount]\r
+  (\r
     (\r
-      L1:"\*" atomTerm[$RootLevel, $ExpOpCount]         << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>\r
+      L1:"\*" castTerm[$RootLevel, $ExpOpCount]         << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>\r
     )\r
     |\r
     (\r
-      L2:"/" atomTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>\r
+      L2:"/" castTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>\r
     )\r
     |\r
     (\r
-      L3:"%" atomTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>\r
-    ) \r
+      L3:"%" castTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>\r
+    )\r
   )*\r
+  ;
+
+castTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
+  << UINT8 CastType = 0xFF; >>
+  (
+    L:"\("
+    (
+        Boolean                                         << CastType = 0; >>
+      | Uint64                                          << CastType = 1; >>
+      | Uint32                                          << CastType = 1; >>
+      | Uint16                                          << CastType = 1; >>
+      | Uint8                                           << CastType = 1; >>
+    )
+    "\)"
+  )*
+  atomTerm[$RootLevel, $ExpOpCount]
+                                                        <<
+                                                           switch (CastType) {
+                                                           case 0: { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } break;
+                                                           case 1: { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } break;
+                                                           }
+                                                                                                               >>
   ;\r
 \r
 atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
@@ -2119,7 +2334,7 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                                                                                        _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
                                                                                                                        EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
                                                                                                                        EIVObj.SetValue (ConstVal);\r
-                                                                                                                       $ExpOpCount++;                                                                                                                  \r
+                                                                                                                       $ExpOpCount++;\r
                                                                                                                  } else {\r
                                                                                                                        IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);\r
                                                                                                                  }\r
@@ -2163,7 +2378,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]\r
   (\r
     (\r
-      "==" \r
+      "=="\r
       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
                                                        <<\r
                                                                                                              if (Mask[0] & Mask[1]) {\r
@@ -2173,7 +2388,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                                                                                        _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));\r
                                                             EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);\r
                                                                                                                        EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);\r
-                                                                                                                       $ExpOpCount++;                                                                                                                  \r
+                                                                                                                       $ExpOpCount++;\r
                                                                                                                  }\r
                                                                                                           >>\r
     )\r
@@ -2215,7 +2430,7 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   >>\r
   L:IdEqValList\r
   vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]\r
-  "==" \r
+  "=="\r
   (\r
     V:Number                                           << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>\r
   )+\r
@@ -2239,9 +2454,9 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
 vareqvarlExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:VarEqVal Var "\(" V1:Number "\)" "==" V2:Number    <<\r
                                                           {\r
-                                                            CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine()); \r
-                                                            _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0)); \r
-                                                            U64Obj1.SetValue (_STOU64(V1->getText())); \r
+                                                            CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());\r
+                                                            _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));\r
+                                                            U64Obj1.SetValue (_STOU64(V1->getText()));\r
                                                             U64Obj2.SetValue (_STOU64(V2->getText()));\r
                                                           }\r
                                                        >>\r
@@ -2267,25 +2482,14 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
         Path "=" "STRING_TOKEN" "\(" S:Number "\)"     << Type = 0x4; DevPath = _STOSID(S->getText()); >>\r
       }\r
       {\r
-        GUID "=" \r
-          OpenBrace\r
-            G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number "," \r
-            G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
-          CloseBrace\r
-                                                       <<\r
-                                                          Type = 0x5;\r
-                                                          _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (), \r
-                                                                          G4->getText (), G5->getText (), G6->getText (), \r
-                                                                          G7->getText (), G8->getText (), G9->getText (), \r
-                                                                          G10->getText (), G11->getText ()); \r
-                                                       >>\r
+        Uuid "=" guidDefinition[Guid]                  << Type = 0x5; >>\r
       }\r
     )\r
     |\r
     (\r
       "\("\r
          (\r
-          QN:StringIdentifier                          << \r
+          QN:StringIdentifier                          <<\r
                                                           QName  = QN->getText();\r
                                                                                                                  LineNo = QN->getLine();\r
                                                           mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);\r
@@ -2340,6 +2544,7 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   | bitwisenotExp[$RootLevel, $ExpOpCount]\r
   | question2refExp[$RootLevel, $ExpOpCount]\r
   | stringref2Exp[$RootLevel, $ExpOpCount]\r
+  | toboolExp[$RootLevel, $ExpOpCount]
   | unintExp[$RootLevel, $ExpOpCount]\r
   | toupperExp[$RootLevel, $ExpOpCount]\r
   | tolwerExp[$RootLevel, $ExpOpCount]\r
@@ -2433,7 +2638,7 @@ findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   findFormat[Format] ( "\|" findFormat[Format] )*\r
   ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
-  "," \r
+  ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
   ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
@@ -2460,7 +2665,7 @@ tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
   ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
-  "," \r
+  ","\r
   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
@@ -2489,12 +2694,13 @@ spanFlags [UINT8 & Flags] :
 \r
 //******************************************************************************\r
 //\r
-// Parser class definition. \r
-//  \r
+// Parser class definition.\r
+//\r
 class EfiVfrParser {\r
 <<\r
 private:\r
   UINT8               mParserStatus;\r
+  BOOLEAN             mConstantOnlyInExpression;
 \r
   CVfrDefaultStore    mCVfrDefaultStore;\r
   CVfrVarDataTypeDB   mCVfrVarDataTypeDB;\r
@@ -2517,12 +2723,14 @@ private:
 \r
   UINT8               _GET_CURRQEST_DATATYPE ();\r
   UINT32              _GET_CURRQEST_VARSIZE ();\r
+  UINT32              _GET_CURRQEST_ARRAY_SIZE ();
 \r
 public:\r
-  VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr, IN INT8 *);\r
+  VOID                _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN INT8 *);\r
   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE);\r
   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);\r
   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);\r
+  VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN INT8 *);
 \r
   VOID                syn     (ANTLRAbstractToken  *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);\r
 \r
@@ -2557,7 +2765,7 @@ public:
 <<\r
 VOID\r
 EfiVfrParser::_SAVE_OPHDR_COND (\r
-  IN CIfrOpHeader &OpHdr, \r
+  IN CIfrOpHeader &OpHdr,\r
   IN BOOLEAN      Cond\r
   )\r
 {\r
@@ -2637,17 +2845,48 @@ EfiVfrParser::_GET_CURRQEST_VARSIZE (
   return mCurrQestVarInfo.mVarTotalSize;\r
 }\r
 \r
+UINT32
+EfiVfrParser::_GET_CURRQEST_ARRAY_SIZE (
+  VOID
+  )
+{
+  UINT8 Size = 1;
+
+  switch (mCurrQestVarInfo.mVarType) {
+  case EFI_IFR_TYPE_NUM_SIZE_8:
+    Size = 1;
+    break;
+
+  case EFI_IFR_TYPE_NUM_SIZE_16:
+    Size = 2;
+    break;
+
+  case EFI_IFR_TYPE_NUM_SIZE_32:
+    Size = 4;
+    break;
+
+  case EFI_IFR_TYPE_NUM_SIZE_64:
+    Size = 8;
+    break;
+
+  default:
+    break;
+  }
+
+  return (mCurrQestVarInfo.mVarTotalSize / Size);
+}
+
 VOID\r
 EfiVfrParser::_PCATCH (\r
-  IN EFI_VFR_RETURN_CODE ReturnCode,\r
-  IN EFI_VFR_RETURN_CODE ExpectCode,\r
+  IN INTN                ReturnCode,\r
+  IN INTN                ExpectCode,\r
   IN ANTLRTokenPtr       Tok,\r
   IN INT8                *ErrorMsg\r
   )\r
 {\r
   if (ReturnCode != ExpectCode) {\r
     mParserStatus++;\r
-    gCVfrErrorHandle.PrintError (Tok->getLine(), Tok->getText(), ErrorMsg);\r
+    gCVfrErrorHandle.PrintMsg (Tok->getLine(), Tok->getText(), "Error", ErrorMsg);\r
   }\r
 }\r
 \r
@@ -2675,14 +2914,24 @@ EfiVfrParser::_PCATCH (
   )\r
 {\r
   mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum);\r
+}
+
+VOID
+EfiVfrParser::_PCATCH (
+  IN EFI_VFR_RETURN_CODE ReturnCode,
+  IN UINT32              LineNum,
+  IN INT8                *ErrorMsg
+  )
+{
+  mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);
 }\r
 \r
-VOID \r
+VOID\r
 EfiVfrParser::syn (\r
-  ANTLRAbstractToken  *Tok, \r
-  ANTLRChar           *Egroup, \r
-  SetWordType         *Eset, \r
-  ANTLRTokenType      ETok, \r
+  ANTLRAbstractToken  *Tok,\r
+  ANTLRChar           *Egroup,\r
+  SetWordType         *Eset,\r
+  ANTLRTokenType      ETok,\r
   INT32               Huh\r
   )\r
 {\r
@@ -2737,7 +2986,7 @@ EfiVfrParser::_STOU8 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    } \r
+    }\r
   }\r
 \r
   return Value;\r
@@ -2767,7 +3016,7 @@ EfiVfrParser::_STOU16 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    } \r
+    }\r
   }\r
 \r
   return Value;\r
@@ -2797,7 +3046,7 @@ EfiVfrParser::_STOU32 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    } \r
+    }\r
   }\r
 \r
   return Value;\r
@@ -2807,7 +3056,7 @@ UINT64
 EfiVfrParser::_STOU64 (\r
   IN INT8 *Str\r
   )\r
-{ \r
+{\r
   BOOLEAN IsHex;\r
   UINT64  Value;\r
   INT8    c;\r
@@ -2827,16 +3076,16 @@ EfiVfrParser::_STOU64 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    } \r
+    }\r
   }\r
 \r
   return Value;\r
-} \r
+}\r
 \r
 EFI_HII_DATE\r
 EfiVfrParser::_STOD (\r
-  IN INT8 *Year, \r
-  IN INT8 *Month, \r
+  IN INT8 *Year,\r
+  IN INT8 *Month,\r
   IN INT8 *Day\r
   )\r
 {\r
@@ -2851,8 +3100,8 @@ EfiVfrParser::_STOD (
 \r
 EFI_HII_TIME\r
 EfiVfrParser::_STOT (\r
-  IN INT8 *Hour, \r
-  IN INT8 *Minute, \r
+  IN INT8 *Hour,\r
+  IN INT8 *Minute,\r
   IN INT8 *Second\r
   )\r
 {\r
@@ -2881,7 +3130,7 @@ EfiVfrParser::_STOFID (
   return (EFI_FORM_ID)_STOU16(Str);\r
 }\r
 \r
-EFI_QUESTION_ID \r
+EFI_QUESTION_ID\r
 EfiVfrParser::_STOQID (\r
   IN INT8 *Str\r
   )\r
@@ -2918,17 +3167,17 @@ EfiVfrParser::_STRCAT (
 \r
 VOID\r
 EfiVfrParser::_CRGUID (\r
-  IN EFI_GUID *Guid, \r
-  IN INT8     *G1, \r
-  IN INT8     *G2, \r
-  IN INT8     *G3, \r
-  IN INT8     *G4, \r
-  IN INT8     *G5, \r
-  IN INT8     *G6, \r
-  IN INT8     *G7, \r
-  IN INT8     *G8, \r
-  IN INT8     *G9, \r
-  IN INT8     *G10, \r
+  IN EFI_GUID *Guid,\r
+  IN INT8     *G1,\r
+  IN INT8     *G2,\r
+  IN INT8     *G3,\r
+  IN INT8     *G4,\r
+  IN INT8     *G5,\r
+  IN INT8     *G6,\r
+  IN INT8     *G7,\r
+  IN INT8     *G8,\r
+  IN INT8     *G9,\r
+  IN INT8     *G10,\r
   IN INT8     *G11\r
   )\r
 {\r
@@ -2964,9 +3213,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
 \r
     VSObj.SetLineNo (LineNo);\r
     mCVfrDataStorage.DeclareBufferVarStore (\r
-                       TypeNameList[Index], \r
-                       &DefaultGuid, \r
-                       &mCVfrVarDataTypeDB, \r
+                       TypeNameList[Index],\r
+                       &DefaultGuid,\r
+                       &mCVfrVarDataTypeDB,\r
                        TypeNameList[Index],\r
                        EFI_VARSTORE_ID_INVALID\r
                        );\r
@@ -2985,9 +3234,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
 \r
     VSObj.SetLineNo (LineNo);\r
     mCVfrDataStorage.DeclareBufferVarStore (\r
-                       "Date", \r
-                                          &DefaultGuid, \r
-                                          &mCVfrVarDataTypeDB, \r
+                       "Date",\r
+                                          &DefaultGuid,\r
+                                          &mCVfrVarDataTypeDB,\r
                                           "EFI_HII_DATE",\r
                        EFI_VARSTORE_ID_INVALID\r
                        );\r
@@ -3006,9 +3255,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
 \r
     VSObj.SetLineNo (LineNo);\r
     mCVfrDataStorage.DeclareBufferVarStore (\r
-                       "Time", \r
-                       &DefaultGuid, \r
-                       &mCVfrVarDataTypeDB, \r
+                       "Time",\r
+                       &DefaultGuid,\r
+                       &mCVfrVarDataTypeDB,\r
                        "EFI_HII_TIME",\r
                        EFI_VARSTORE_ID_INVALID\r
                        );\r
@@ -3026,7 +3275,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
   IN UINT32 LineNo\r
   )\r
 {\r
-  CIfrDefaultStore DSObj; \r
+  CIfrDefaultStore DSObj;\r
 \r
   mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);\r
   DSObj.SetLineNo (LineNo);\r
@@ -3036,7 +3285,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
 \r
 VOID\r
 EfiVfrParser::AssignQuestionKey (\r
-  IN CIfrQuestionHeader   &QHObj, \r
+  IN CIfrQuestionHeader   &QHObj,\r
   IN ANTLRTokenPtr        KeyTok\r
   )\r
 {\r
@@ -3059,7 +3308,7 @@ EfiVfrParser::AssignQuestionKey (
 \r
 VOID\r
 EfiVfrParser::ConvertIdExpr (\r
-  IN UINT32          &ExpOpCount, \r
+  IN UINT32          &ExpOpCount,\r
   IN UINT32          LineNo,\r
   IN EFI_QUESTION_ID QId,\r
   IN INT8            *VarIdStr,\r
@@ -3093,7 +3342,7 @@ EfiVfrParser::ConvertIdExpr (
 \r
 VOID\r
 EfiVfrParser::IdEqValDoSpecial (\r
-  IN UINT32           &ExpOpCount, \r
+  IN UINT32           &ExpOpCount,\r
   IN UINT32           LineNo,\r
   IN EFI_QUESTION_ID  QId,\r
   IN INT8             *VarIdStr,\r
@@ -3145,7 +3394,7 @@ EfiVfrParser::IdEqValDoSpecial (
 \r
 VOID\r
 EfiVfrParser::IdEqIdDoSpecial (\r
-  IN UINT32           &ExpOpCount, \r
+  IN UINT32           &ExpOpCount,\r
   IN UINT32           LineNo,\r
   IN EFI_QUESTION_ID  QId1,\r
   IN INT8             *VarId1Str,\r
@@ -3192,7 +3441,7 @@ EfiVfrParser::IdEqIdDoSpecial (
 \r
 VOID\r
 EfiVfrParser::IdEqListDoSpecial (\r
-  IN UINT32          &ExpOpCount, \r
+  IN UINT32          &ExpOpCount,\r
   IN UINT32          LineNo,\r
   IN EFI_QUESTION_ID QId,\r
   IN INT8            *VarIdStr,\r
index caadc29da97ef4d4f34eeb1faeb98314aa00f685..d6f5f437f25b60eb274f2c2d78e44a5b654df5e4 100644 (file)
@@ -1,5 +1,4 @@
 /*++\r
-\r
 Copyright (c) 2004 - 2010, 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
@@ -10,8 +9,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 Module Name:\r
-\r
-VfrUtilityLib.cpp\r
+  VfrUtilityLib.cpp\r
 \r
 Abstract:\r
 \r
@@ -74,12 +72,13 @@ CVfrBinaryOutput::WriteEnd (
 }\r
 \r
 SConfigInfo::SConfigInfo (\r
-  IN UINT8              Type, \r
-  IN UINT16             Offset, \r
-  IN UINT32             Width, \r
+  IN UINT8              Type,\r
+  IN UINT16             Offset,\r
+  IN UINT32             Width,\r
   IN EFI_IFR_TYPE_VALUE Value\r
   )\r
 {\r
+  mNext   = NULL;\r
   mOffset = Offset;\r
   mWidth  = (UINT16)Width;\r
   mValue  = new UINT8[mWidth];\r
@@ -125,51 +124,51 @@ SConfigInfo::~SConfigInfo (
 }\r
 \r
 SConfigItem::SConfigItem (\r
-  IN INT8                *Id, \r
-  IN INT8                *Info\r
+  IN INT8                *Name,\r
+  IN INT8                *Id\r
   )\r
 {\r
-  mId          = NULL;\r
-  mInfo        = NULL;\r
+  mName          = NULL;\r
+  mId            = NULL;\r
   mInfoStrList = NULL;\r
   mNext        = NULL;\r
 \r
-  if (Id != NULL) {\r
-    if ((mId = new INT8[strlen (Id) + 1]) != NULL) {\r
-      strcpy (mId, Id);\r
+  if (Name != NULL) {\r
+    if ((mName = new INT8[strlen (Name) + 1]) != NULL) {\r
+      strcpy (mName, Name);\r
     }\r
   }\r
 \r
-  if (Info != NULL) {\r
-    if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {\r
-      strcpy (mInfo, Info);\r
+  if (Id != NULL) {\r
+    if ((mId = new INT8[strlen (Id) + 1]) != NULL) {\r
+      strcpy (mId, Id);\r
     }\r
   }\r
 }\r
 \r
 SConfigItem::SConfigItem (\r
-  IN INT8                *Id, \r
-  IN INT8                *Info,\r
+  IN INT8                *Name,\r
+  IN INT8                *Id,\r
   IN UINT8               Type,\r
   IN UINT16              Offset,\r
   IN UINT16              Width,\r
   IN EFI_IFR_TYPE_VALUE  Value\r
   )\r
 {\r
+  mName        = NULL;\r
   mId          = NULL;\r
-  mInfo        = NULL;\r
   mInfoStrList = NULL;\r
   mNext        = NULL;\r
 \r
-  if (Id != NULL) {\r
-    if ((mId = new INT8[strlen (Id) + 1]) != NULL) {\r
-      strcpy (mId, Id);\r
+  if (Name != NULL) {\r
+    if ((mName = new INT8[strlen (Name) + 1]) != NULL) {\r
+      strcpy (mName, Name);\r
     }\r
   }\r
 \r
-  if (Info != NULL) {\r
-    if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {\r
-      strcpy (mInfo, Info);\r
+  if (Id != NULL) {\r
+    if ((mId = new INT8[strlen (Id) + 1]) != NULL) {\r
+      strcpy (mId, Id);\r
     }\r
   }\r
 \r
@@ -182,8 +181,8 @@ SConfigItem::~SConfigItem (
 {\r
   SConfigInfo  *Info;\r
 \r
+  BUFFER_SAFE_FREE (mName);\r
   BUFFER_SAFE_FREE (mId);\r
-  BUFFER_SAFE_FREE (mInfo);\r
   while (mInfoStrList != NULL) {\r
     Info = mInfoStrList;\r
     mInfoStrList = mInfoStrList->mNext;\r
@@ -194,17 +193,17 @@ SConfigItem::~SConfigItem (
 \r
 UINT8\r
 CVfrBufferConfig::Register (\r
-  IN INT8                *Id, \r
-  IN INT8                *Info\r
+  IN INT8                *Name,\r
+  IN INT8                *Id\r
   )\r
 {\r
   SConfigItem *pNew;\r
 \r
-  if (Select (Id) == 0) {\r
+  if (Select (Name) == 0) {\r
     return 1;\r
   }\r
 \r
-  if ((pNew = new SConfigItem (Id, Info)) == NULL) {\r
+  if ((pNew = new SConfigItem (Name, Id)) == NULL) {\r
     return 2;\r
   }\r
   if (mItemListHead == NULL) {\r
@@ -237,25 +236,27 @@ CVfrBufferConfig::Eof(
 \r
 UINT8\r
 CVfrBufferConfig::Select (\r
-  IN INT8 *Id,\r
-  IN INT8 *Info\r
+  IN INT8  *Name,\r
+  IN INT8  *Id\r
   )\r
 {\r
   SConfigItem *p;\r
 \r
-  if (Id == NULL) {\r
+  if (Name == NULL) {\r
     mItemListPos = mItemListHead;\r
     return 0;\r
   } else {\r
     for (p = mItemListHead; p != NULL; p = p->mNext) {\r
-      if (strcmp (p->mId, Id) != 0) {\r
+      if (strcmp (p->mName, Name) != 0) {\r
         continue;\r
       }\r
 \r
-      if ((p->mInfo != NULL) && (Info != NULL)) {\r
-        if (strcmp (p->mInfo, Info) != 0) {\r
+      if (Id != NULL) {\r
+        if (p->mId == NULL || strcmp (p->mId, Id) != 0) {\r
           continue;\r
         }\r
+      } else if (p->mId != NULL) {\r
+        continue;\r
       }\r
 \r
       mItemListPos = p;\r
@@ -269,8 +270,8 @@ CVfrBufferConfig::Select (
 UINT8\r
 CVfrBufferConfig::Write (\r
   IN CONST CHAR8         Mode,\r
-  IN INT8                *Id, \r
-  IN INT8                *Info,\r
+  IN INT8                *Name,\r
+  IN INT8                *Id,\r
   IN UINT8               Type,\r
   IN UINT16              Offset,\r
   IN UINT32              Width,\r
@@ -281,16 +282,14 @@ CVfrBufferConfig::Write (
   SConfigItem   *pItem;\r
   SConfigInfo   *pInfo;\r
 \r
+  if ((Ret = Select (Name)) != 0) {\r
+    return Ret;\r
+  }\r
+\r
   switch (Mode) {\r
   case 'a' : // add\r
-    if (Select (Id) == 0) {\r
-      if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {\r
-        return 2;\r
-      }\r
-      pInfo->mNext = mItemListPos->mInfoStrList;\r
-      mItemListPos->mInfoStrList = pInfo;\r
-    } else {\r
-      if ((pItem = new SConfigItem (Id, Info, Type, Offset, Width, Value)) == NULL) {\r
+    if (Select (Name, Id) != 0) {\r
+      if ((pItem = new SConfigItem (Name, Id, Type, Offset, Width, Value)) == NULL) {\r
         return 2;\r
       }\r
       if (mItemListHead == NULL) {\r
@@ -301,14 +300,26 @@ CVfrBufferConfig::Write (
         mItemListTail = pItem;\r
       }\r
       mItemListPos = pItem;\r
+    } else {\r
+      // tranverse the list to find out if there's already the value for the same offset\r
+      for (pInfo = mItemListPos->mInfoStrList; pInfo != NULL; pInfo = pInfo->mNext) {\r
+        if (pInfo->mOffset == Offset) {\r
+          // check if the value and width are the same; return error if not\r
+          if ((Id != NULL) && (pInfo->mWidth != Width || memcmp(pInfo->mValue, &Value, Width) != 0)) {\r
+            return VFR_RETURN_DEFAULT_VALUE_REDEFINED;\r
+          }\r
+          return 0;\r
+        }\r
+      }\r
+      if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {\r
+        return 2;\r
+      }\r
+      pInfo->mNext = mItemListPos->mInfoStrList;\r
+      mItemListPos->mInfoStrList = pInfo;\r
     }\r
     break;\r
 \r
   case 'd' : // delete\r
-    if ((Ret = Select (Id)) != 0) {\r
-      return Ret;\r
-    }\r
-\r
     if (mItemListHead == mItemListPos) {\r
       mItemListHead = mItemListPos->mNext;\r
       delete mItemListPos;\r
@@ -327,18 +338,15 @@ CVfrBufferConfig::Write (
     break;\r
 \r
   case 'i' : // set info\r
-    if ((Ret = Select (Id)) != 0) {\r
-      return Ret;\r
-    }\r
-    if (mItemListPos->mInfo != NULL) {\r
-      delete mItemListPos->mInfo;\r
+    if (mItemListPos->mId != NULL) {\r
+      delete mItemListPos->mId;\r
     }\r
-    mItemListPos->mInfo = NULL;\r
-    if (Info != NULL) {\r
-      if ((mItemListPos->mInfo = new INT8[strlen (Info) + 1]) == NULL) {\r
+    mItemListPos->mId = NULL;\r
+    if (Id != NULL) {\r
+      if ((mItemListPos->mId = new INT8[strlen (Id) + 1]) == NULL) {\r
         return 2;\r
       }\r
-      strcpy (mItemListPos->mInfo, Info);\r
+      strcpy (mItemListPos->mId, Id);\r
     }\r
     break;\r
 \r
@@ -352,29 +360,29 @@ CVfrBufferConfig::Write (
 #if 0\r
 UINT8\r
 CVfrBufferConfig::ReadId (\r
-  OUT INT8   **Id, \r
-  OUT INT8   **Info\r
+  OUT INT8   **Name,\r
+  OUT INT8   **Id\r
   )\r
 {\r
   if (mInfoStrItemListPos == NULL) {\r
     return 1; // end read or some error occur\r
   }\r
 \r
+  if (Name != NULL) {\r
+    *Name = new INT8 (strlen (mInfoStrItemListPos->mName + 1));\r
+    strcpy (*Name, mInfoStrItemListPos->mName);\r
+  }\r
   if (Id != NULL) {\r
     *Id = new INT8 (strlen (mInfoStrItemListPos->mId + 1));\r
     strcpy (*Id, mInfoStrItemListPos->mId);\r
   }\r
-  if (Info != NULL) {\r
-    *Info = new INT8 (strlen (mInfoStrItemListPos->mInfo + 1));\r
-    strcpy (*Info, mInfoStrItemListPos->mInfo);\r
-  }\r
 \r
   return 0;\r
 }\r
 \r
 UINT8\r
 CVfrBufferConfig::ReadInfo (\r
-  IN  INT8      *Id, \r
+  IN  INT8      *Name,\r
   IN  UINT32    Index,\r
   IN OUT UINT32 &Number,\r
   OUT INT8      *Offset,\r
@@ -387,8 +395,8 @@ CVfrBufferConfig::ReadInfo (
   UINT32        idx;\r
   UINT32        num;\r
 \r
-  if (Id != NULL) {\r
-    if ((ret = Select (Id)) != 0) {\r
+  if (Name != NULL) {\r
+    if ((ret = Select (Name)) != 0) {\r
       return ret;\r
     }\r
   }\r
@@ -473,8 +481,28 @@ CVfrBufferConfig::OutputCFile (
   }\r
 \r
   for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {\r
-    if (Item->mInfoStrList != NULL) {\r
-      fprintf (pFile, "\nunsigned char %s%sDefault%04x[] = {", BaseName, Item->mId, Item->mInfo);\r
+    if (Item->mId != NULL || Item->mInfoStrList == NULL) {\r
+      continue;\r
+    }\r
+    fprintf (pFile, "\nunsigned char %s%sBlockName[] = {", BaseName, Item->mName);\r
+\r
+    TotalLen = sizeof (UINT32);\r
+    for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {\r
+      TotalLen += sizeof (UINT16) * 2;\r
+    }\r
+    Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)&TotalLen, sizeof (UINT32));\r
+\r
+    for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {\r
+      fprintf (pFile, "\n");\r
+      Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)&Info->mOffset, sizeof (UINT16));\r
+      Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)&Info->mWidth, sizeof (UINT16));\r
+    }\r
+    fprintf (pFile, "\n};\n");\r
+  }\r
+\r
+  for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {\r
+    if (Item->mId != NULL && Item->mInfoStrList != NULL) {\r
+      fprintf (pFile, "\nunsigned char %s%sDefault%s[] = {", BaseName, Item->mName, Item->mId);\r
 \r
       TotalLen = sizeof (UINT32);\r
       for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {\r
@@ -483,6 +511,7 @@ CVfrBufferConfig::OutputCFile (
       Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)&TotalLen, sizeof (UINT32));\r
 \r
       for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {\r
+        fprintf (pFile, "\n");\r
         Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)&Info->mOffset, sizeof (UINT16));\r
         Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)&Info->mWidth, sizeof (UINT16));\r
         if (Info->mNext == NULL) {\r
@@ -490,9 +519,8 @@ CVfrBufferConfig::OutputCFile (
         } else {\r
           Output.WriteLine (pFile, BYTES_PRE_LINE, "  ", (INT8 *)Info->mValue, Info->mWidth);\r
         }\r
-        fprintf (pFile, "\n"); \r
       }\r
-      fprintf (pFile, "};\n"); \r
+      fprintf (pFile, "\n};\n");\r
     }\r
   }\r
 }\r
@@ -536,7 +564,7 @@ static struct {
   {"UINT16",        EFI_IFR_TYPE_NUM_SIZE_16, sizeof (UINT16),       sizeof (UINT16)},\r
   {"UINT8",         EFI_IFR_TYPE_NUM_SIZE_8,  sizeof (UINT8),        sizeof (UINT8)},\r
   {"BOOLEAN",       EFI_IFR_TYPE_BOOLEAN,     sizeof (BOOLEAN),      sizeof (BOOLEAN)},\r
-  {"EFI_HII_DATE",  EFI_IFR_TYPE_DATE,        sizeof (EFI_HII_DATE), sizeof (UINT8)},\r
+  {"EFI_HII_DATE",  EFI_IFR_TYPE_DATE,        sizeof (EFI_HII_DATE), sizeof (UINT16)},\r
   {"EFI_STRING_ID", EFI_IFR_TYPE_STRING,      sizeof (EFI_STRING_ID),sizeof (EFI_STRING_ID)},\r
   {"EFI_HII_TIME",  EFI_IFR_TYPE_TIME,        sizeof (EFI_HII_TIME), sizeof (UINT8)},\r
   {NULL,            EFI_IFR_TYPE_OTHER,       0,                     0}\r
@@ -610,7 +638,7 @@ _STR2U32 (
     }\r
     if (c >= '0' && c <= '9') {\r
       Value += (c - '0');\r
-    } \r
+    }\r
   }\r
 \r
   return Value;\r
@@ -627,7 +655,7 @@ CVfrVarDataTypeDB::RegisterNewType (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::ExtractStructTypeName (\r
-  IN  INT8 *&VarStr, \r
+  IN  INT8 *&VarStr,\r
   OUT INT8 *TName\r
   )\r
 {\r
@@ -650,7 +678,7 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::ExtractFieldNameAndArrary (\r
-  IN  INT8   *&VarStr, \r
+  IN  INT8   *&VarStr,\r
   IN  INT8   *FName,\r
   OUT UINT32 &ArrayIdx\r
   )\r
@@ -658,15 +686,15 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
   UINT32 Idx;\r
   INT8   ArrayStr[MAX_NAME_LEN + 1];\r
 \r
-  ArrayIdx = INVALID_ARRAY_INDEX; \r
+  ArrayIdx = INVALID_ARRAY_INDEX;\r
 \r
   if (FName == NULL) {\r
     return VFR_RETURN_FATAL_ERROR;\r
   }\r
 \r
   while((*VarStr != '\0') &&\r
-        (*VarStr != '.') && \r
-        (*VarStr != '[') && \r
+        (*VarStr != '.') &&\r
+        (*VarStr != '[') &&\r
         (*VarStr != ']')) {\r
     *FName = *VarStr;\r
     VarStr++;\r
@@ -703,8 +731,8 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetTypeField (\r
-  IN  INT8          *FName, \r
-  IN  SVfrDataType  *Type, \r
+  IN  INT8          *FName,\r
+  IN  SVfrDataType  *Type,\r
   OUT SVfrDataField *&Field\r
   )\r
 {\r
@@ -726,7 +754,7 @@ CVfrVarDataTypeDB::GetTypeField (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetFieldOffset (\r
-  IN  SVfrDataField *Field, \r
+  IN  SVfrDataField *Field,\r
   IN  UINT32        ArrayIdx,\r
   OUT UINT32        &Offset\r
   )\r
@@ -834,7 +862,7 @@ CVfrVarDataTypeDB::InternalTypesListInit (
         pSecondsField->mNext     = NULL;\r
         pSecondsField->mArrayNum = 0;\r
 \r
-        New->mMembers            = pHoursField;      \r
+        New->mMembers            = pHoursField;\r
       } else {\r
         New->mMembers            = NULL;\r
       }\r
@@ -853,6 +881,7 @@ CVfrVarDataTypeDB::CVfrVarDataTypeDB (
   mNewDataType   = NULL;\r
   mCurrDataField = NULL;\r
   mPackAlign     = DEFAULT_PACK_ALIGN;\r
+  mPackStack     = NULL;\r
 \r
   InternalTypesListInit ();\r
 }\r
@@ -861,8 +890,9 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
   VOID\r
   )\r
 {\r
-  SVfrDataType  *pType;\r
-  SVfrDataField *pField;\r
+  SVfrDataType      *pType;\r
+  SVfrDataField     *pField;\r
+  SVfrPackStackNode *pPack;\r
 \r
   if (mNewDataType != NULL) {\r
     delete mNewDataType;\r
@@ -879,30 +909,64 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
        delete pType;\r
   }\r
 \r
+  while (mPackStack != NULL) {\r
+    pPack = mPackStack;\r
+    mPackStack = mPackStack->mNext;\r
+    delete pPack;\r
+  }\r
 }\r
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::Pack (\r
-  IN UINT32        Align\r
+  IN UINT32         LineNum,\r
+  IN UINT8          Action,\r
+  IN INT8           *Identifier,\r
+  IN UINT32         Number\r
   )\r
 {\r
-  if (Align == 0) {\r
-    return VFR_RETURN_INVALID_PARAMETER;\r
-  } else if (Align > 1) {\r
-    mPackAlign = Align + Align % 2;\r
-  } else {\r
-    mPackAlign = Align;\r
+  UINT32            PackAlign;\r
+  INT8              Msg[64] = {0, };\r
+\r
+  if (Action & VFR_PACK_SHOW) {\r
+    sprintf (Msg, "value of pragma pack(show) == %d", mPackAlign);\r
+    gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", Msg);\r
   }\r
 \r
-  return VFR_RETURN_SUCCESS;\r
-}\r
+  if (Action & VFR_PACK_PUSH) {\r
+    SVfrPackStackNode *pNew = NULL;\r
 \r
-VOID\r
-CVfrVarDataTypeDB::UnPack (\r
-  VOID\r
-  )\r
-{\r
-  mPackAlign = DEFAULT_PACK_ALIGN;\r
+    if ((pNew = new SVfrPackStackNode (Identifier, mPackAlign)) == NULL) {\r
+      return VFR_RETURN_FATAL_ERROR;\r
+    }\r
+    pNew->mNext = mPackStack;\r
+    mPackStack  = pNew;\r
+  }\r
+\r
+  if (Action & VFR_PACK_POP) {\r
+    SVfrPackStackNode *pNode = NULL;\r
+\r
+    if (mPackStack == NULL) {\r
+      gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "#pragma pack(pop...) : more pops than pushes");\r
+    }\r
+\r
+    for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) {\r
+      if (pNode->Match (Identifier) == TRUE) {\r
+        mPackAlign = pNode->mNumber;\r
+        mPackStack = pNode->mNext;\r
+      }\r
+    }\r
+  }\r
+\r
+  if (Action & VFR_PACK_ASSIGN) {\r
+    PackAlign = (Number > 1) ? Number + Number % 2 : Number;\r
+    if ((PackAlign == 0) || (PackAlign > 16)) {\r
+      gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "expected pragma parameter to be '1', '2', '4', '8', or '16'");\r
+    } else {\r
+      mPackAlign = PackAlign;\r
+    }\r
+  }\r
+\r
+  return VFR_RETURN_SUCCESS;\r
 }\r
 \r
 VOID\r
@@ -952,8 +1016,8 @@ CVfrVarDataTypeDB::SetNewTypeName (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::DataTypeAddField (\r
-  IN INT8   *FieldName, \r
-  IN INT8   *TypeName, \r
+  IN INT8   *FieldName,\r
+  IN INT8   *TypeName,\r
   IN UINT32 ArrayNum\r
   )\r
 {\r
@@ -991,7 +1055,7 @@ CVfrVarDataTypeDB::DataTypeAddField (
     mNewDataType->mMembers = pNewField;\r
     pNewField->mNext       = NULL;\r
   } else {\r
-    for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext) \r
+    for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)\r
       ;\r
     pTmp->mNext            = pNewField;\r
     pNewField->mNext       = NULL;\r
@@ -1049,6 +1113,38 @@ CVfrVarDataTypeDB::GetDataType (
   return VFR_RETURN_UNDEFINED;\r
 }\r
 \r
+EFI_VFR_RETURN_CODE\r
+CVfrVarDataTypeDB::GetDataTypeSize (\r
+  IN  UINT8   DataType,\r
+  OUT UINT32 *Size\r
+  )\r
+{\r
+  SVfrDataType *pDataType = NULL;\r
+\r
+  if (Size == NULL) {\r
+    return VFR_RETURN_FATAL_ERROR;\r
+  }\r
+\r
+  *Size    = 0;\r
+  DataType = DataType & 0x0F;\r
+\r
+  //\r
+  // For user defined data type, the size can't be got by this function.\r
+  //\r
+  if (DataType == EFI_IFR_TYPE_OTHER) {\r
+    return VFR_RETURN_SUCCESS;\r
+  }\r
+\r
+  for (pDataType = mDataTypeList; pDataType != NULL; pDataType = pDataType->mNext) {\r
+    if (DataType == pDataType->mType) {\r
+      *Size = pDataType->mTotalSize;\r
+      return VFR_RETURN_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return VFR_RETURN_UNDEFINED;\r
+}\r
+\r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetDataTypeSize (\r
   IN  INT8   *TypeName,\r
@@ -1075,9 +1171,9 @@ CVfrVarDataTypeDB::GetDataTypeSize (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetDataFieldInfo (\r
-  IN  INT8     *VarStr, \r
-  OUT UINT16   &Offset, \r
-  OUT UINT8    &Type, \r
+  IN  INT8     *VarStr,\r
+  OUT UINT16   &Offset,\r
+  OUT UINT8    &Type,\r
   OUT UINT32   &Size\r
   )\r
 {\r
@@ -1113,7 +1209,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
 \r
 EFI_VFR_RETURN_CODE\r
 CVfrVarDataTypeDB::GetUserDefinedTypeNameList  (\r
-  OUT INT8      ***NameList, \r
+  OUT INT8      ***NameList,\r
   OUT UINT32    *ListSize\r
   )\r
 {\r
@@ -1444,10 +1540,10 @@ CVfrDataStorage::DeclareNameVarStoreEnd (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE \r
+EFI_VFR_RETURN_CODE\r
 CVfrDataStorage::DeclareEfiVarStore (\r
-  IN INT8           *StoreName, \r
-  IN EFI_GUID       *Guid, \r
+  IN INT8           *StoreName,\r
+  IN EFI_GUID       *Guid,\r
   IN EFI_STRING_ID  NameStrId,\r
   IN UINT32         VarSize\r
   )\r
@@ -1480,10 +1576,10 @@ CVfrDataStorage::DeclareEfiVarStore (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE \r
+EFI_VFR_RETURN_CODE\r
 CVfrDataStorage::DeclareBufferVarStore (\r
-  IN INT8              *StoreName, \r
-  IN EFI_GUID          *Guid, \r
+  IN INT8              *StoreName,\r
+  IN EFI_GUID          *Guid,\r
   IN CVfrVarDataTypeDB *DataTypeDB,\r
   IN INT8              *TypeName,\r
   IN EFI_VARSTORE_ID   VarStoreId\r
@@ -1521,7 +1617,7 @@ CVfrDataStorage::DeclareBufferVarStore (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE \r
+EFI_VFR_RETURN_CODE\r
 CVfrDataStorage::GetVarStoreId (\r
   IN  INT8            *StoreName,\r
   OUT EFI_VARSTORE_ID *VarStoreId\r
@@ -1625,9 +1721,47 @@ CVfrDataStorage::GetVarStoreType (
   return VFR_RETURN_UNDEFINED;\r
 }\r
 \r
+EFI_VFR_VARSTORE_TYPE\r
+CVfrDataStorage::GetVarStoreType (\r
+  IN  EFI_VARSTORE_ID        VarStoreId\r
+  )\r
+{\r
+  SVfrVarStorageNode    *pNode;\r
+  EFI_VFR_VARSTORE_TYPE VarStoreType;\r
+\r
+  VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
+\r
+  if (VarStoreId == EFI_VARSTORE_ID_INVALID) {\r
+    return VarStoreType;\r
+  }\r
+\r
+  for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {\r
+    if (pNode->mVarStoreId == VarStoreId) {\r
+      VarStoreType = pNode->mVarStoreType;\r
+      return VarStoreType;\r
+    }\r
+  }\r
+\r
+  for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) {\r
+    if (pNode->mVarStoreId == VarStoreId) {\r
+      VarStoreType = pNode->mVarStoreType;\r
+      return VarStoreType;\r
+    }\r
+  }\r
+\r
+  for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) {\r
+    if (pNode->mVarStoreId == VarStoreId) {\r
+      VarStoreType = pNode->mVarStoreType;\r
+      return VarStoreType;\r
+    }\r
+  }\r
+\r
+  return VarStoreType;\r
+}\r
+\r
 EFI_VFR_RETURN_CODE\r
 CVfrDataStorage::GetVarStoreName (\r
-  IN  EFI_VARSTORE_ID VarStoreId, \r
+  IN  EFI_VARSTORE_ID VarStoreId,\r
   OUT INT8            **VarStoreName\r
   )\r
 {\r
@@ -1725,7 +1859,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
   INT8                  NewReqElt[128] = {'\0',};\r
   INT8                  *OldReqElt = NULL;\r
   SVfrVarStorageNode    *pNode = NULL;\r
-  EFI_IFR_TYPE_VALUE    Value;\r
+  EFI_IFR_TYPE_VALUE    Value = {0};\r
 \r
   for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {\r
     if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {\r
@@ -1749,8 +1883,8 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
 \r
 SVfrDefaultStoreNode::SVfrDefaultStoreNode (\r
   IN EFI_IFR_DEFAULTSTORE *ObjBinAddr,\r
-  IN INT8                 *RefName, \r
-  IN EFI_STRING_ID        DefaultStoreNameId, \r
+  IN INT8                 *RefName,\r
+  IN EFI_STRING_ID        DefaultStoreNameId,\r
   IN UINT16               DefaultId\r
   )\r
 {\r
@@ -1828,7 +1962,7 @@ CVfrDefaultStore::RegisterDefaultStore (
 }\r
 \r
 /*\r
- * assign new reference name or new default store name id only if \r
+ * assign new reference name or new default store name id only if\r
  * the original is invalid\r
  */\r
 EFI_VFR_RETURN_CODE\r
@@ -1911,8 +2045,8 @@ CVfrDefaultStore::GetDefaultId (
 STATIC\r
 EFI_VFR_RETURN_CODE\r
 AltCfgItemPrintToBuffer (\r
-  IN INT8               *NewAltCfg, \r
-  IN EFI_VARSTORE_INFO  Info, \r
+  IN INT8               *NewAltCfg,\r
+  IN EFI_VARSTORE_INFO  Info,\r
   IN UINT8              Type,\r
   IN EFI_IFR_TYPE_VALUE Value\r
   )\r
@@ -1923,9 +2057,9 @@ AltCfgItemPrintToBuffer (
 \r
   if (NewAltCfg != NULL) {\r
     Count = sprintf (\r
-              NewAltCfg, \r
-              "&OFFSET=%x&WIDTH=%x&VALUE=", \r
-              Info.mInfo.mVarOffset, \r
+              NewAltCfg,\r
+              "&OFFSET=%x&WIDTH=%x&VALUE=",\r
+              Info.mInfo.mVarOffset,\r
               Info.mVarTotalSize\r
               );\r
     NewAltCfg += Count;\r
@@ -1984,7 +2118,7 @@ AltCfgItemPrintToBuffer (
        }\r
   }\r
 \r
-  return VFR_RETURN_FATAL_ERROR;    \r
+  return VFR_RETURN_FATAL_ERROR;\r
 }\r
 \r
 EFI_VFR_RETURN_CODE\r
@@ -1998,6 +2132,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
 {\r
   SVfrDefaultStoreNode  *pNode = NULL;\r
   INT8                  NewAltCfg[2 * 2 * sizeof (UINT16) + 1] = {0,};\r
+  INTN                  Returnvalue = 0;\r
 \r
   if (VarStoreName == NULL) {\r
     return VFR_RETURN_FATAL_ERROR;\r
@@ -2016,28 +2151,23 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
   gCVfrBufferConfig.Open ();\r
 \r
   sprintf (NewAltCfg, "%04x", pNode->mDefaultId);\r
-  if ((gCVfrBufferConfig.Select(VarStoreName) == 0) && \r
-      (gCVfrBufferConfig.Select(VarStoreName, NewAltCfg) != 0)) {\r
-    if (gCVfrBufferConfig.Write ('i', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {\r
+  if ((Returnvalue = gCVfrBufferConfig.Select(VarStoreName)) == 0) {\r
+    if ((Returnvalue = gCVfrBufferConfig.Write ('a', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value)) != 0) {\r
       goto WriteError;\r
     }\r
   }\r
 \r
-  if (gCVfrBufferConfig.Write ('a', VarStoreName, NULL, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {\r
-    goto WriteError;\r
-  }\r
-\r
   gCVfrBufferConfig.Close ();\r
 \r
   return VFR_RETURN_SUCCESS;\r
 \r
 WriteError:\r
   gCVfrBufferConfig.Close ();\r
-  return VFR_RETURN_FATAL_ERROR;\r
+  return (EFI_VFR_RETURN_CODE)Returnvalue;\r
 }\r
 \r
 SVfrRuleNode::SVfrRuleNode (\r
-  IN INT8        *RuleName, \r
+  IN INT8        *RuleName,\r
   IN UINT8       RuleId\r
   )\r
 {\r
@@ -2143,7 +2273,7 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
   mVarTotalSize    = Info.mVarTotalSize;\r
 }\r
 \r
-BOOLEAN \r
+BOOLEAN\r
 EFI_VARSTORE_INFO::operator == (\r
   IN EFI_VARSTORE_INFO  *Info\r
   )\r
@@ -2195,7 +2325,7 @@ CVfrQuestionDB::ChekQuestionIdFree (
   return (mFreeQIdBitMap[Index] & (0x80000000 >> Offset)) == 0;\r
 }\r
 \r
-VOID \r
+VOID\r
 CVfrQuestionDB::MarkQuestionIdUsed (\r
   IN EFI_QUESTION_ID QId\r
   )\r
@@ -2206,7 +2336,7 @@ CVfrQuestionDB::MarkQuestionIdUsed (
   mFreeQIdBitMap[Index] |= (0x80000000 >> Offset);\r
 }\r
 \r
-VOID \r
+VOID\r
 CVfrQuestionDB::MarkQuestionIdUnused (\r
   IN EFI_QUESTION_ID QId\r
   )\r
@@ -2321,9 +2451,9 @@ CVfrQuestionDB::RegisterQuestion (
 \r
 VOID\r
 CVfrQuestionDB::RegisterOldDateQuestion (\r
-  IN     INT8            *YearVarId, \r
-  IN     INT8            *MonthVarId, \r
-  IN     INT8            *DayVarId, \r
+  IN     INT8            *YearVarId,\r
+  IN     INT8            *MonthVarId,\r
+  IN     INT8            *DayVarId,\r
   IN OUT EFI_QUESTION_ID &QuestionId\r
   )\r
 {\r
@@ -2379,7 +2509,7 @@ Err:
 VOID\r
 CVfrQuestionDB::RegisterNewDateQuestion (\r
   IN     INT8            *Name,\r
-  IN     INT8            *BaseVarId, \r
+  IN     INT8            *BaseVarId,\r
   IN OUT EFI_QUESTION_ID &QuestionId\r
   )\r
 {\r
@@ -2463,9 +2593,9 @@ Err:
 \r
 VOID\r
 CVfrQuestionDB::RegisterOldTimeQuestion (\r
-  IN     INT8            *HourVarId, \r
-  IN     INT8            *MinuteVarId, \r
-  IN     INT8            *SecondVarId, \r
+  IN     INT8            *HourVarId,\r
+  IN     INT8            *MinuteVarId,\r
+  IN     INT8            *SecondVarId,\r
   IN OUT EFI_QUESTION_ID &QuestionId\r
   )\r
 {\r
@@ -2634,7 +2764,7 @@ CVfrQuestionDB::UpdateQuestionId (
   return VFR_RETURN_SUCCESS;\r
 }\r
 \r
-VOID \r
+VOID\r
 CVfrQuestionDB::GetQuestionId (\r
   IN  INT8              *Name,\r
   IN  INT8              *VarIdStr,\r
@@ -2672,7 +2802,7 @@ CVfrQuestionDB::GetQuestionId (
   return ;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE \r
+EFI_VFR_RETURN_CODE\r
 CVfrQuestionDB::FindQuestion (\r
   IN EFI_QUESTION_ID QuestionId\r
   )\r
@@ -2692,7 +2822,7 @@ CVfrQuestionDB::FindQuestion (
   return VFR_RETURN_UNDEFINED;\r
 }\r
 \r
-EFI_VFR_RETURN_CODE \r
+EFI_VFR_RETURN_CODE\r
 CVfrQuestionDB::FindQuestion (\r
   IN INT8 *Name\r
   )\r
index 38687b948df8955bcf35c5f4bd1dc9e50240bf50..fe37f83e160ed9e3036da674b6c0071b0a150435 100644 (file)
@@ -1,5 +1,4 @@
 /*++\r
-\r
 Copyright (c) 2004 - 2010, 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
@@ -10,8 +9,7 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 Module Name:\r
-\r
-VfrUtilityLib.h\r
+  VfrUtilityLib.h\r
 \r
 Abstract:\r
 \r
@@ -28,7 +26,7 @@ Abstract:
 \r
 #define MAX_NAME_LEN                       64\r
 #define DEFAULT_ALIGN                      1\r
-#define DEFAULT_PACK_ALIGN                 0xFFFFFFFF\r
+#define DEFAULT_PACK_ALIGN                 0x8\r
 #define DEFAULT_NAME_TABLE_ITEMS           1024\r
 \r
 #define EFI_BITS_SHIFT_PER_UINT32          0x5\r
@@ -58,9 +56,9 @@ struct SConfigInfo {
 };\r
 \r
 struct SConfigItem {\r
-  INT8          *mId;\r
-  INT8          *mInfo;\r
-  SConfigInfo   *mInfoStrList;\r
+  INT8          *mName;         // varstore name\r
+  INT8          *mId;           // varstore ID\r
+  SConfigInfo   *mInfoStrList;  // list of Offset/Value in the varstore\r
   SConfigItem   *mNext;\r
 \r
 public:\r
@@ -115,10 +113,59 @@ struct SVfrDataType {
   SVfrDataType              *mNext;\r
 };\r
 \r
+#define VFR_PACK_ASSIGN     0x01\r
+#define VFR_PACK_SHOW       0x02\r
+#define VFR_PACK_PUSH       0x04\r
+#define VFR_PACK_POP        0x08\r
+\r
+#define PACKSTACK_MAX_SIZE  0x400\r
+\r
+struct SVfrPackStackNode {\r
+  INT8                      *mIdentifier;\r
+  UINT32                    mNumber;\r
+  SVfrPackStackNode         *mNext;\r
+\r
+  SVfrPackStackNode (IN INT8 *Identifier, IN UINT32 Number) {\r
+    mIdentifier = NULL;\r
+    mNumber     = Number;\r
+    mNext       = NULL;\r
+\r
+    if (Identifier != NULL) {\r
+      mIdentifier = new INT8[strlen (Identifier) + 1];\r
+      strcpy (mIdentifier, Identifier);\r
+    }\r
+  }\r
+\r
+  ~SVfrPackStackNode (VOID) {\r
+    if (mIdentifier != NULL) {\r
+      delete mIdentifier;\r
+    }\r
+    mNext = NULL;\r
+  }\r
+\r
+  bool Match (IN INT8 *Identifier) {\r
+    if (Identifier == NULL) {\r
+      return TRUE;\r
+    } else if (mIdentifier == NULL) {\r
+      return FALSE;\r
+    } else if (strcmp (Identifier, mIdentifier) == 0) {\r
+      return TRUE;\r
+    } else {\r
+      return FALSE;\r
+    }\r
+  }\r
+};\r
+\r
 class CVfrVarDataTypeDB {\r
 private:\r
-  SVfrDataType              *mDataTypeList;\r
   UINT32                    mPackAlign;\r
+  SVfrPackStackNode         *mPackStack;\r
+\r
+public:\r
+  EFI_VFR_RETURN_CODE       Pack (IN UINT32, IN UINT8, IN INT8 *Identifier = NULL, IN UINT32 Number = DEFAULT_PACK_ALIGN);\r
+\r
+private:\r
+  SVfrDataType              *mDataTypeList;\r
 \r
   SVfrDataType              *mNewDataType;\r
   SVfrDataType              *mCurrDataType;\r
@@ -138,9 +185,6 @@ public:
   CVfrVarDataTypeDB (VOID);\r
   ~CVfrVarDataTypeDB (VOID);\r
 \r
-  EFI_VFR_RETURN_CODE Pack (IN UINT32);\r
-  VOID                UnPack (VOID);\r
-\r
   VOID                DeclareDataTypeBegin (VOID);\r
   EFI_VFR_RETURN_CODE SetNewTypeName (IN INT8 *);\r
   EFI_VFR_RETURN_CODE DataTypeAddField (IN INT8 *, IN INT8 *, IN UINT32);\r
@@ -148,6 +192,7 @@ public:
 \r
   EFI_VFR_RETURN_CODE GetDataType (IN INT8 *, OUT SVfrDataType **);\r
   EFI_VFR_RETURN_CODE GetDataTypeSize (IN INT8 *, OUT UINT32 *);\r
+  EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *);\r
   EFI_VFR_RETURN_CODE GetDataFieldInfo (IN INT8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);\r
 \r
   EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT INT8 ***, OUT UINT32 *);\r
@@ -245,6 +290,7 @@ public:
 \r
   EFI_VFR_RETURN_CODE GetVarStoreId (IN INT8 *, OUT EFI_VARSTORE_ID *);\r
   EFI_VFR_RETURN_CODE GetVarStoreType (IN INT8 *, OUT EFI_VFR_VARSTORE_TYPE &);\r
+  EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);\r
   EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT INT8 **);\r
 \r
   EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN INT8 *, OUT INT8 **);\r
index e4424fcc3f517fc4a0a79e924064977b80d80c79..b266cfe03c06d37648c0cad69f74f6d0e32ce480 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #  \r
-#  Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -55,7 +55,8 @@ INC                = -I $(SRC) \
 ANTLR_FLAGS        = -CC -e3 -ck 3 -k 2\r
 DLG_FLAGS          = -C2 -i -CC\r
 LINK_FLAGS_PCCTS   = /DEBUG  /PDB:$*.pdb\r
-C_FLAGS_PCCTS      = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG\r
+C_FLAGS_PCCTS      = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)  \\r
+                     $(BUILD_STRING_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG\r
 \r
 VFR_GRAMMER_FILE   = $(SRC)\VfrSyntax.g\r
 \r
index c520ad28f5b6819423e4b6c198b8b173a78482ae..b82713177c9a7f57941e0caead07a7ec4162e17c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -31,7 +31,8 @@ Abstract:
 // This number should be incremented with each change to the VFR compiler.\r
 // We write the version to the output list file for debug purposes.\r
 //\r
-#define VFR_COMPILER_VERSION  "1.88"\r
+#define UTILITY_VERSION  "v1.9"\r
+#define UTILITY_NAME     "VfrCompile"\r
 \r
 //\r
 // Maximum file path for filenames\r
@@ -39,7 +40,6 @@ Abstract:
 #define MAX_PATH        255\r
 #define MAX_QUEUE_COUNT 255\r
 #define MAX_LINE_LEN    1024\r
-#define PROGRAM_NAME    "VfrCompile"\r
 \r
 //\r
 // We parse C-style structure definitions which can then be referenced\r
index ce574ada12c9d0a6d2e28e2d80521739d5cdc780..7c0d78f010d3514097d47cd165637814156b11dd 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -130,7 +130,7 @@ Returns:
   // Set our program name for the error printing routines.\r
   // Then set printing limits.\r
   //\r
-  SetUtilityName (PROGRAM_NAME);\r
+  SetUtilityName (UTILITY_NAME);\r
   SetPrintLimits (20, 20, 30);\r
   //\r
   // Process the command-line arguments\r
@@ -145,7 +145,7 @@ Returns:
   // Verify the VFR script file exists\r
   //\r
   if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");\r
+    Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");\r
     Cleanup();\r
     return STATUS_ERROR;\r
   }\r
@@ -164,7 +164,7 @@ Returns:
   }\r
   Cmd = (char *)malloc (Len);\r
   if (Cmd == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");\r
+    Error (UTILITY_NAME, 0, 0, NULL, "could not allocate memory");\r
     Cleanup();\r
     return STATUS_ERROR;\r
   }  \r
@@ -182,7 +182,7 @@ Returns:
   strcat (Cmd, gOptions.PreprocessorOutputFileName);\r
   Status = system (Cmd);\r
   if (Status != 0) {\r
-    Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");\r
+    Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");\r
     printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);\r
     Cleanup();\r
     return STATUS_ERROR;\r
@@ -192,7 +192,7 @@ Returns:
   // Open the preprocessor output file\r
   //\r
   if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file", \r
+    Error (UTILITY_NAME, 0, 0, "failed to open input VFR preprocessor output file", \r
       gOptions.PreprocessorOutputFileName);\r
     Cleanup();\r
     return STATUS_ERROR;\r
@@ -339,7 +339,7 @@ Returns:
     //\r
     } else if (_stricmp (Argv[0], "-i") == 0) {\r
       if ((Argc < 2) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing path argument");\r
         return STATUS_ERROR;\r
       }\r
       Argc--;\r
@@ -351,7 +351,7 @@ Returns:
       }\r
       IncludePaths = (INT8 *)malloc (Len);\r
       if (IncludePaths == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
       IncludePaths[0] = 0;\r
@@ -367,7 +367,7 @@ Returns:
     //\r
     } else if (_stricmp (Argv[0], "-od") == 0) {\r
       if ((Argc < 2) || (Argv[1][0] == '-')) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing output directory name");\r
         return STATUS_ERROR;\r
       }\r
       Argc--;\r
@@ -383,7 +383,7 @@ Returns:
     //\r
     } else if (_stricmp (Argv[0], "-ppflag") == 0) {\r
       if (Argc < 2) {\r
-        Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");\r
+        Error (UTILITY_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");\r
         return STATUS_ERROR;\r
       }\r
       Argc--;\r
@@ -394,7 +394,7 @@ Returns:
       }\r
       CPreprocessorOptions = (INT8 *)malloc (Len);\r
       if (CPreprocessorOptions == NULL) {\r
-        Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+        Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
         return STATUS_ERROR;\r
       }\r
       CPreprocessorOptions[0] = 0;\r
@@ -406,7 +406,7 @@ Returns:
       strcat (CPreprocessorOptions, Argv[0]);\r
       gOptions.CPreprocessorOptions = CPreprocessorOptions;\r
     } else {\r
-      Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");\r
+      Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");\r
       return STATUS_ERROR;\r
     }\r
     Argc--;\r
@@ -416,10 +416,10 @@ Returns:
   // Must specify at least the vfr file name\r
   //\r
   if (Argc > 1) {\r
-    Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");\r
+    Error (UTILITY_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");\r
     return STATUS_ERROR;\r
   } else if (Argc < 1) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");\r
+    Error (UTILITY_NAME, 0, 0, NULL, "must specify VFR file name");\r
     return STATUS_ERROR;\r
   }\r
   strcpy (gOptions.VfrFileName, Argv[0]);\r
@@ -501,26 +501,31 @@ Returns:
 \r
 --*/\r
 {\r
-  int Index;\r
-  const char *Help[] = {\r
-    " ", \r
-    "VfrCompile version " VFR_COMPILER_VERSION,\r
-    " ",\r
-    "  Usage: VfrCompile {options} [VfrFile]",\r
-    " ",\r
-    "    where options include:",\r
-    "      -? or -h       prints this help",\r
-    "      -l             create an output IFR listing file",\r
-    "      -i IncPath     add IncPath to the search path for VFR included files",\r
-    "      -od OutputDir  deposit all output files to directory OutputDir (default=cwd)",\r
-    "      -ibin          create an IFR HII pack file",\r
-    "    where parameters include:",\r
-    "      VfrFile        name of the input VFR script file",\r
-    " ",\r
+  int          Index;\r
+  const char   *Str[] = {\r
+    UTILITY_NAME" "UTILITY_VERSION" - Intel VFR Compiler Utility",\r
+    "  Copyright (C), 2004 - 2008 Intel Corporation",\r
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )\r
+    "  Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,\r
+#endif\r
+    "",\r
+    "Usage:",\r
+    "  "UTILITY_NAME" [OPTION] VFRFILE",\r
+    "Description:",\r
+    "  Compile VFRFILE.",\r
+    "Options:",\r
+    "  -? or -h        print this help",\r
+    "  -l              create an output IFR listing file",\r
+    "  -i IncPath      add IncPath to the search path for VFR included files",\r
+    "  -od OutputDir   deposit all output files to directory OutputDir (default=cwd)",\r
+    "  -ibin           create an IFR HII pack file",\r
+    "  -ppflag CFlags  pass Flags as C-preprocessor-flag",\r
+    "  -v or -version  print version information",\r
     NULL\r
-    };\r
-  for (Index = 0; Help[Index] != NULL; Index++) {\r
-    fprintf (stdout, "%s\n", Help[Index]);\r
+  };\r
+\r
+  for (Index = 0; Str[Index] != NULL; Index++) {\r
+    fprintf (stdout, "%s\n", Str[Index]);\r
   }\r
 }\r
     \r
@@ -591,7 +596,7 @@ Returns:
     }\r
     gLastLineDefinition = LineDef;\r
   } else {\r
-    Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);\r
+    Error (UTILITY_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);\r
     free (LineDef);\r
     return;\r
   }\r
@@ -2318,7 +2323,7 @@ EfiVfrParser::QueueIdEqValList (
   \r
   U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));\r
   if (U16 == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");\r
+    Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failed");\r
   } else {\r
     memset ((char *)U16, 0, sizeof (UINT16_LIST));\r
     U16->Value = Value;\r
@@ -2378,7 +2383,7 @@ EfiVfrParser::PrintErrorMessage (
     FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
     Error (FileName, LineNum, 0, Msg1, Msg2);\r
   } else {\r
-    Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
+    Error (UTILITY_NAME, 0, 0, Msg1, Msg2);\r
   }\r
 }\r
 VOID \r
@@ -2394,7 +2399,7 @@ EfiVfrParser::PrintWarningMessage (
     FileName = ConvertLineNumber ((UINT32 *)&LineNum);\r
     Warning (FileName, LineNum, 0, Msg1, Msg2);\r
   } else {\r
-    Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);\r
+    Warning (UTILITY_NAME, 0, 0, Msg1, Msg2);\r
   }\r
 }\r
 VOID \r
@@ -3357,7 +3362,7 @@ Returns:
   \r
   NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));\r
   if (NewRef == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+    Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
     return;\r
   }\r
   memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));\r
@@ -3423,7 +3428,7 @@ Returns:
   //\r
   NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));\r
   if (NewFormId == NULL) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");\r
+    Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");\r
     return;\r
   }\r
   memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));\r
index 4d3ba3d3189d4298356cb3fa884292bba51cbd9d..8555f2eb73c3181be75192c9c78c115651e17989 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -220,7 +220,7 @@ Returns:
   //\r
   if (GetUtilityStatus () != STATUS_ERROR) {\r
     if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
+      Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
       return;\r
     }\r
     //\r
@@ -290,7 +290,7 @@ Returns:
       strcat (gOptions.IfrOutputFileName, ".hpk");\r
     }\r
     if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {\r
-      Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
+      Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");\r
       return;\r
     }\r
     //\r
@@ -329,10 +329,10 @@ Returns:
     // Open the input VFR file and the output list file\r
     //\r
     if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {\r
-      Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");\r
+      Warning (UTILITY_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");\r
     } else {\r
       if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {\r
-        Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");\r
+        Warning (UTILITY_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");\r
         fclose (InFptr);\r
         InFptr = NULL;\r
       } else {\r
@@ -350,7 +350,7 @@ Returns:
     //\r
     // Write out the VFR compiler version\r
     //\r
-    fprintf (OutFptr, "//\n//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+    fprintf (OutFptr, "//\n//  VFR compiler version " UTILITY_VERSION "\n//\n");\r
     Curr = mIfrBytes;\r
     while (Curr != NULL) {\r
       //\r
@@ -590,7 +590,7 @@ Returns:
   // Check for buffer overflow\r
   //\r
   if (mQueuedByteCount >= MAX_QUEUE_COUNT) {\r
-    Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");\r
+    Error (UTILITY_NAME, 0, 0, NULL, "opcode queue overflow");\r
   } else {\r
     mQueuedBytes[mQueuedByteCount]    = ByteVal;\r
     mQueuedKeyBytes[mQueuedByteCount] = KeyByte;\r
@@ -750,5 +750,5 @@ Returns:
   //\r
   // Write out the VFR compiler version\r
   //\r
-  fprintf (OutFptr, "//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+  fprintf (OutFptr, "//  VFR compiler version " UTILITY_VERSION "\n//\n");\r
 }\r
index b55b09c4ed12d9fd862d6f9f480de0ff9a164ee8..1859deb03eb6d94caa896393fa64faeb02557756 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #  \r
-#  Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2004 - 2010, 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
@@ -37,7 +37,7 @@ TOOLCHAIN = TOOLCHAIN_MSVC
 \r
 TARGET_NAME       = VfrCompile\r
 ANTLR_H           = $(PCCTS_DIR)\h\r
-C_FLAGS_PCCTS     = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)\r
+C_FLAGS_PCCTS     = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) $(BUILD_STRING_FLAGS)\r
 C_FLAGS_PCCTS     = $(C_FLAGS_PCCTS)  \r
 \r
 LINK_FLAGS_PCCTS  =\r
index 1c6e9a9f03efe2cfa44d79e8996d675375c6eada..cef19d4ce96c0ba8c43d27b9b48756b39a79de2e 100644 (file)
@@ -1,6 +1,6 @@
 #/*++\r
 #   \r
-#  Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2010, 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
@@ -39,3 +39,5 @@ PI_SPECIFICATION_VERSION = 0x00000009
 !ENDIF\r
 \r
 TIANO_RELEASE_VERSION     = 0x00080006\r
+\r
+EDK_BUILD_VERSION         = Edk1.06\r